From 2fb68e81c96e750e7817cacc8286b253121d15bf Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 15 Feb 2024 15:17:39 +0100 Subject: [PATCH] fix: refs #6276 rollback sale --- modules/ticket/back/models/sale.js | 5 ++--- modules/ticket/back/models/specs/sale.spec.js | 19 ------------------- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/modules/ticket/back/models/sale.js b/modules/ticket/back/models/sale.js index 035c4cb11..6204e9a02 100644 --- a/modules/ticket/back/models/sale.js +++ b/modules/ticket/back/models/sale.js @@ -70,8 +70,7 @@ module.exports = Self => { }, ctx.options); if (item.family == 'EMB') return; - const isInPreparing = await models.ACL.checkAccessAcl(ctx, 'Sale', 'isInPreparing', '*'); - if (!ctx.isNewInstance && isInPreparing) return; + if (await models.ACL.checkAccessAcl(ctx, 'Sale', 'isInPreparing', '*')) return; await models.Sale.rawSql(`CALL catalog_calcFromItem(?,?,?,?)`, [ ticket.landed, @@ -89,7 +88,7 @@ module.exports = Self => { if (await models.ACL.checkAccessAcl(ctx, 'Ticket', 'isRoleAdvanced', '*')) return; - if (newQuantity < item.minQuantity && newQuantity != available && !isInPreparing) + if (newQuantity < item.minQuantity && newQuantity != available) throw new UserError('The amount cannot be less than the minimum'); if (ctx.isNewInstance || isReduction) return; diff --git a/modules/ticket/back/models/specs/sale.spec.js b/modules/ticket/back/models/specs/sale.spec.js index 26d64cfe2..d078dc8e2 100644 --- a/modules/ticket/back/models/specs/sale.spec.js +++ b/modules/ticket/back/models/specs/sale.spec.js @@ -233,25 +233,6 @@ describe('sale model ', () => { } }); - it('should change the quantity if it has production role and is not a new instance', async() => { - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getActiveCtx(9)); - const tx = await models.Sale.beginTransaction({}); - const options = {transaction: tx}; - - try { - const saleId = 1; - const newQuantity = 10; - - const {quantity} = await models.Collection.setSaleQuantity(saleId, newQuantity, options); - - expect(quantity).toEqual(newQuantity); - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } - }); - describe('newPrice', () => { it('should increase quantity if you have enough available and the new price is the same as the previous one', async() => { const ctx = {