Merge branch 'test' into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
8c4d3bac0d
|
@ -48,7 +48,7 @@ module.exports = Self => {
|
||||||
CALL vn.sale_recalcComponent(null);
|
CALL vn.sale_recalcComponent(null);
|
||||||
DROP TEMPORARY TABLE tmp.recalculateSales;`;
|
DROP TEMPORARY TABLE tmp.recalculateSales;`;
|
||||||
|
|
||||||
const recalculation = await Self.rawSql(query, salesIds, myOptions);
|
const recalculation = await Self.rawSql(query, [salesIds], myOptions);
|
||||||
|
|
||||||
if (tx) await tx.commit();
|
if (tx) await tx.commit();
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,25 @@ describe('sale updatePrice()', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should check if priceFixed has changed', async() => {
|
||||||
|
const tx = await models.Sale.beginTransaction({});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
const price = 3;
|
||||||
|
const beforeUpdate = await models.Sale.findById(saleId, null, options);
|
||||||
|
await models.Sale.updatePrice(ctx, saleId, price, options);
|
||||||
|
const afterUpdate = await models.Sale.findById(saleId, null, options);
|
||||||
|
|
||||||
|
expect(beforeUpdate.priceFixed).not.toEqual(afterUpdate.priceFixed);
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
it('should set price as a decimal number and check the sale has the mana component changing the salesPersonMana', async() => {
|
it('should set price as a decimal number and check the sale has the mana component changing the salesPersonMana', async() => {
|
||||||
const tx = await models.Sale.beginTransaction({});
|
const tx = await models.Sale.beginTransaction({});
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,21 @@ module.exports = Self => {
|
||||||
value: componentValue
|
value: componentValue
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
}
|
}
|
||||||
await sale.updateAttributes({price: newPrice}, myOptions);
|
|
||||||
|
const [priceFixed] = await Self.rawSql(`
|
||||||
|
SELECT SUM(value) value
|
||||||
|
FROM sale s
|
||||||
|
JOIN saleComponent sc ON sc.saleFk = s.id
|
||||||
|
JOIN component c ON c.id = sc.componentFk
|
||||||
|
JOIN componentType ct ON ct.id = c.typeFk
|
||||||
|
WHERE ct.isBase
|
||||||
|
AND s.id = ?
|
||||||
|
`, [id], myOptions);
|
||||||
|
|
||||||
|
await sale.updateAttributes({
|
||||||
|
price: newPrice,
|
||||||
|
priceFixed: priceFixed.value
|
||||||
|
}, myOptions);
|
||||||
|
|
||||||
await Self.rawSql('CALL vn.manaSpellersRequery(?)', [userId], myOptions);
|
await Self.rawSql('CALL vn.manaSpellersRequery(?)', [userId], myOptions);
|
||||||
await Self.rawSql('CALL vn.ticket_recalc(?, NULL)', [sale.ticketFk], myOptions);
|
await Self.rawSql('CALL vn.ticket_recalc(?, NULL)', [sale.ticketFk], myOptions);
|
||||||
|
|
|
@ -28,6 +28,9 @@
|
||||||
"discount": {
|
"discount": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
|
"priceFixed": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
"reserved": {
|
"reserved": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue