refs #6199 fix(sale_quantity): add isReduction
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alex Moreno 2023-10-23 09:52:06 +02:00
parent cf856a585b
commit 247aa5af2a
1 changed files with 3 additions and 2 deletions

View File

@ -81,13 +81,14 @@ module.exports = Self => {
ctx.options);
const [itemInfo] = await models.Sale.rawSql(`SELECT available FROM tmp.ticketCalculateItem`, null, ctx.options);
const available = itemInfo?.available;
if ((!isReduction && !itemInfo?.available) || itemInfo.available < quantityAdded)
if ((!isReduction && !available) || available < quantityAdded)
throw new UserError(`This item is not available`);
if (await models.ACL.checkAccessAcl(ctx, 'Ticket', 'isRoleAdvanced', '*')) return;
if (newQuantity < item.minQuantity && newQuantity != itemInfo?.available)
if (newQuantity < item.minQuantity && newQuantity != available)
throw new UserError('The amount cannot be less than the minimum');
if (ctx.isNewInstance || isReduction) return;