fix: refs #6276 rollback sale
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Jorge Penadés 2024-02-15 15:17:39 +01:00
parent 4aeb88229d
commit 2fb68e81c9
2 changed files with 2 additions and 22 deletions

View File

@ -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;

View File

@ -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 = {