refs #4671 uses sale_calculateComponent
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
7876561188
commit
4ebc812876
|
@ -73,28 +73,10 @@ module.exports = Self => {
|
|||
|
||||
const usesMana = await models.Sale.usesMana(ctx, myOptions);
|
||||
const componentCode = usesMana ? 'mana' : 'buyerDiscount';
|
||||
const discount = await models.Component.findOne({where: {code: componentCode}}, myOptions);
|
||||
const componentId = discount.id;
|
||||
const componentValue = newPrice - sale.price;
|
||||
|
||||
const where = {
|
||||
componentFk: componentId,
|
||||
saleFk: id
|
||||
};
|
||||
const saleComponent = await models.SaleComponent.findOne({where}, myOptions);
|
||||
if (saleComponent) {
|
||||
await models.SaleComponent.updateAll(where, {
|
||||
value: saleComponent.value + componentValue
|
||||
}, myOptions);
|
||||
} else {
|
||||
await models.SaleComponent.create({
|
||||
saleFk: id,
|
||||
componentFk: componentId,
|
||||
value: componentValue
|
||||
}, myOptions);
|
||||
}
|
||||
await sale.updateAttributes({price: newPrice}, myOptions);
|
||||
|
||||
await Self.rawSql('CALL vn.sale_calculateComponent(?, ?)', [id, componentCode], myOptions);
|
||||
await Self.rawSql('CALL vn.manaSpellersRequery(?)', [userId], myOptions);
|
||||
await Self.rawSql('CALL vn.ticket_recalc(?, NULL)', [sale.ticketFk], myOptions);
|
||||
|
||||
|
|
Loading…
Reference in New Issue