From 2e48263636fb96a7971b6c4be92a5caf3aaa1309 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 11 Jul 2024 11:10:01 +0200 Subject: [PATCH] feat: refs #7704 Fix --- modules/ticket/back/models/sale.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/ticket/back/models/sale.js b/modules/ticket/back/models/sale.js index af76444bf..c28f1b8b3 100644 --- a/modules/ticket/back/models/sale.js +++ b/modules/ticket/back/models/sale.js @@ -83,19 +83,19 @@ module.exports = Self => { const [itemInfo] = await models.Sale.rawSql(`SELECT available FROM tmp.ticketCalculateItem`, null, ctx.options); const available = itemInfo?.available; - // if ((!isReduction && !available) || available < quantityAdded) - // throw new UserError(`This item is not available`); + if ((!isReduction && !available) || available < quantityAdded) + throw new UserError(`This item is not available`); if (await models.ACL.checkAccessAcl(ctx, 'Ticket', 'isRoleAdvanced', '*')) return; - const today = new Date(); + const now = Date.vnNew(); const minQuantity = await models.ItemMinimumQuantity.findOne({ fields: ['quantity'], where: { itemFk: itemId, - started: {lte: today}, + started: {lte: now}, or: [ - {ended: {gte: today}}, + {ended: {gte: now}}, {ended: null} ], // eslint-disable-next-line no-dupe-keys