7773-testToMaster_2430 #2774
|
@ -211,7 +211,7 @@ describe('sale model ', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw an error if the quantity is greater than the minimum quantity of the item but is out of range', async() => {
|
it('should throw an error if the quantity is lower than the minimum quantity of the item and is in range', async() => {
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getCtx(employeeId, true));
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getCtx(employeeId, true));
|
||||||
|
|
||||||
const saleId = 25;
|
const saleId = 25;
|
||||||
|
@ -233,6 +233,25 @@ describe('sale model ', () => {
|
||||||
expect(e).toEqual(new Error('The amount cannot be less than the minimum'));
|
expect(e).toEqual(new Error('The amount cannot be less than the minimum'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should update the quantity if the quantity is lower than the minimum quantity of the item and is out of the range', async() => {
|
||||||
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getCtx(employeeId, true));
|
||||||
|
|
||||||
|
const saleId = 17;
|
||||||
|
const newQuantity = 8;
|
||||||
|
|
||||||
|
spyOn(models.Sale, 'rawSql').and.callFake((sqlStatement, params, opts) => {
|
||||||
|
if (sqlStatement.includes('catalog_calcFromItem')) {
|
||||||
|
sqlStatement = `
|
||||||
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketCalculateItem ENGINE = MEMORY SELECT ${newQuantity} as available;
|
||||||
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketComponentPrice ENGINE = MEMORY SELECT 1 as grouping, 100000 as price;`;
|
||||||
|
params = null;
|
||||||
|
}
|
||||||
|
return models.Ticket.rawSql(sqlStatement, params, opts);
|
||||||
|
});
|
||||||
|
|
||||||
|
await models.Sale.updateQuantity(ctx, saleId, newQuantity, opts);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue