#1486 back test updateDiscount
This commit is contained in:
parent
68f67f12d7
commit
9671307688
|
@ -442,7 +442,7 @@ INSERT INTO `vn`.`ticket`(`id`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped
|
|||
(5, 3, 3, 3, DATE_ADD(CURDATE(), INTERVAL -3 DAY), DATE_ADD(CURDATE(), INTERVAL -3 DAY), 103, 'address 23', 123, 'T3333333', 0, DATE_ADD(CURDATE(), INTERVAL -3 DAY)),
|
||||
(6, 3, 3, 4, DATE_ADD(CURDATE(), INTERVAL -2 DAY), DATE_ADD(CURDATE(), INTERVAL -2 DAY), 103, 'address 23', 123, 'T4444444', 0, DATE_ADD(CURDATE(), INTERVAL -2 DAY)),
|
||||
(7, 4, 4, 4, DATE_ADD(CURDATE(), INTERVAL -1 DAY), DATE_ADD(CURDATE(), INTERVAL -1 DAY), 104, 'address 24', 124, 'T4444444', 0, DATE_ADD(CURDATE(), INTERVAL -1 DAY)),
|
||||
(8, 1, 1, 4, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), 104, 'address 24', 124, NULL, 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)),
|
||||
(8, 1, 1, 4, CURDATE(), CURDATE(), 104, 'address 24', 124, NULL, 0, CURDATE()),
|
||||
(9, 5, 5, 4, DATE_ADD(CURDATE(), INTERVAL -2 MONTH), DATE_ADD(CURDATE(), INTERVAL -2 MONTH), 105, 'address 25', 125, 'A1111111', 0, DATE_ADD(CURDATE(), INTERVAL -2 MONTH)),
|
||||
(10, 6, 5, 5, DATE_ADD(CURDATE(), INTERVAL -3 MONTH), DATE_ADD(CURDATE(), INTERVAL -3 MONTH), 105, 'address 25', 125, 'A1111111', 0, DATE_ADD(CURDATE(), INTERVAL -3 MONTH)),
|
||||
(11, 7, 1, 1, CURDATE() , CURDATE() , 101, 'address 21', 121, NULL, 0, CURDATE()),
|
||||
|
|
|
@ -2,12 +2,27 @@ const app = require('vn-loopback/server/server');
|
|||
|
||||
// #1486 back test updateDiscount
|
||||
xdescribe('sale updateDiscount()', () => {
|
||||
const originalSaleId = 14;
|
||||
let componentId;
|
||||
let originalSale;
|
||||
let createdSaleComponent;
|
||||
let saleComponentsRestore;
|
||||
|
||||
beforeAll(async done => {
|
||||
originalSale = await app.models.Sale.findById(originalSaleId);
|
||||
let manaDiscount = await app.models.ComponentRate.findOne({where: {code: 'mana'}});
|
||||
componentId = manaDiscount.id;
|
||||
saleComponentsRestore = await app.models.SaleComponent.findOne({
|
||||
where: {
|
||||
componentFk: componentId,
|
||||
saleFk: originalSaleId
|
||||
}
|
||||
});
|
||||
done();
|
||||
});
|
||||
|
||||
afterAll(async done => {
|
||||
originalSale.save();
|
||||
createdSaleComponent.destroy();
|
||||
saleComponentsRestore.save();
|
||||
done();
|
||||
});
|
||||
|
||||
|
@ -45,15 +60,10 @@ xdescribe('sale updateDiscount()', () => {
|
|||
});
|
||||
|
||||
it('should update the discount if the salesPerson has mana', async() => {
|
||||
const saleId = 1;
|
||||
originalSale = await app.models.Sale.findById(saleId);
|
||||
|
||||
let manaDiscount = await app.models.ComponentRate.findOne({where: {code: 'mana'}});
|
||||
let componentId = manaDiscount.id;
|
||||
createdSaleComponent = await app.models.SaleComponent.findOne({
|
||||
let createdSaleComponent = await app.models.SaleComponent.findOne({
|
||||
where: {
|
||||
componentFk: componentId,
|
||||
saleFk: saleId
|
||||
saleFk: originalSaleId
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -62,17 +72,17 @@ xdescribe('sale updateDiscount()', () => {
|
|||
const ticketId = 8;
|
||||
const sales = [
|
||||
{
|
||||
id: saleId,
|
||||
id: originalSaleId,
|
||||
discount: 100}
|
||||
];
|
||||
|
||||
await app.models.Sale.updateDiscount(ticketId, sales);
|
||||
|
||||
let updatedSale = await app.models.Sale.findById(saleId);
|
||||
let updatedSale = await app.models.Sale.findById(originalSaleId);
|
||||
createdSaleComponent = await app.models.SaleComponent.findOne({
|
||||
where: {
|
||||
componentFk: componentId,
|
||||
saleFk: saleId
|
||||
saleFk: originalSaleId
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue