7152-devToTest_2414 #2228
|
@ -70,8 +70,7 @@ module.exports = Self => {
|
||||||
}, ctx.options);
|
}, ctx.options);
|
||||||
if (item.family == 'EMB') return;
|
if (item.family == 'EMB') return;
|
||||||
|
|
||||||
const isInPreparing = await models.ACL.checkAccessAcl(ctx, 'Sale', 'isInPreparing', '*');
|
if (await models.ACL.checkAccessAcl(ctx, 'Sale', 'isInPreparing', '*')) return;
|
||||||
if (!ctx.isNewInstance && isInPreparing) return;
|
|
||||||
|
|
||||||
await models.Sale.rawSql(`CALL catalog_calcFromItem(?,?,?,?)`, [
|
await models.Sale.rawSql(`CALL catalog_calcFromItem(?,?,?,?)`, [
|
||||||
ticket.landed,
|
ticket.landed,
|
||||||
|
@ -89,7 +88,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
if (await models.ACL.checkAccessAcl(ctx, 'Ticket', 'isRoleAdvanced', '*')) return;
|
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');
|
throw new UserError('The amount cannot be less than the minimum');
|
||||||
|
|
||||||
if (ctx.isNewInstance || isReduction) return;
|
if (ctx.isNewInstance || isReduction) return;
|
||||||
|
|
|
@ -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', () => {
|
describe('newPrice', () => {
|
||||||
it('should increase quantity if you have enough available and the new price is the same as the previous one', async() => {
|
it('should increase quantity if you have enough available and the new price is the same as the previous one', async() => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
|
|
Loading…
Reference in New Issue