|
@@ -108,8 +108,10 @@ class revisePriceCalc {
|
|
|
const billsTree = new Ledger.billsTree(this.ctx, { id: 'ledger_id', pid: 'ledger_pid', order: 'order', level: 'level', rootId: -1, calcFields: [] });
|
|
|
billsTree.loadDatas(bills);
|
|
|
|
|
|
- // 计算 insertBills billsPriceChange reCalcBillsCur/reCalcBillsPrice
|
|
|
- const result = { ibData: [], bpcData: [] };
|
|
|
+ const stageChange = await this.ctx.service.stageChange.getFinalStageData(stage.tid, stage.id);
|
|
|
+
|
|
|
+ // 计算 insertBills billsPriceChange stageChange
|
|
|
+ const result = { ibData: [], bpcData: [], scData: [] };
|
|
|
const helper = this.ctx.helper;
|
|
|
const decimal = this.ctx.tender.info.decimal;
|
|
|
const said = this.ctx.session.sessionUser.accountId;
|
|
@@ -140,10 +142,15 @@ class revisePriceCalc {
|
|
|
positive_qc_pc_tp: node.positive_qc_pc_tp, negative_qc_pc_tp: node.negative_qc_pc_tp,
|
|
|
});
|
|
|
}
|
|
|
+ const scDetail = stageChange.filter(x => { return x.lid === node.id; });
|
|
|
+ for (const scd of scDetail) {
|
|
|
+ result.scData.push({ id: scd.id, unit_price: node.unit_price });
|
|
|
+ }
|
|
|
});
|
|
|
if (result.ibData.length > 0) await transaction.insert(this.ctx.service.stageBills.tableName, result.ibData);
|
|
|
await transaction.delete(this.ctx.service.stageBillsPc.tableName, { sid: stage.id });
|
|
|
if (result.bpcData.length > 0) await transaction.insert(this.ctx.service.stageBillsPc.tableName, result.bpcData);
|
|
|
+ if (result.scData.length > 0) await transaction.updateRows(this.ctx.service.stageChange.tableName, result.scData);
|
|
|
|
|
|
let contract_pc_tp = 0, qc_pc_tp = 0, pc_tp = 0, positive_qc_pc_tp = 0, negative_qc_pc_tp = 0;
|
|
|
for (const bpc of result.bpcData) {
|
|
@@ -212,9 +219,10 @@ class revisePriceCalc {
|
|
|
]);
|
|
|
const billsTree = new Ledger.billsTree(this.ctx, { id: 'ledger_id', pid: 'ledger_pid', order: 'order', level: 'level', rootId: -1, calcFields: [] });
|
|
|
billsTree.loadDatas(bills);
|
|
|
+ const stageChange = await this.ctx.service.stageChange.getFinalStageData(stage.tid, stage.id);
|
|
|
|
|
|
- // 计算 insertBills/updateBills billsPriceChange
|
|
|
- const result = { ibData: [], ubData: [], bpcData: [] };
|
|
|
+ // 计算 insertBills/updateBills billsPriceChange StageChange
|
|
|
+ const result = { ibData: [], ubData: [], bpcData: [], scData: [] };
|
|
|
const helper = this.ctx.helper;
|
|
|
const decimal = this.ctx.tender.info.decimal;
|
|
|
const said = this.ctx.session.sessionUser.accountId;
|
|
@@ -251,11 +259,16 @@ class revisePriceCalc {
|
|
|
positive_qc_pc_tp: node.positive_qc_pc_tp, negative_qc_pc_tp: node.negative_qc_pc_tp,
|
|
|
});
|
|
|
}
|
|
|
+ const scDetail = stageChange.filter(x => { return x.lid === node.id; });
|
|
|
+ for (const scd of scDetail) {
|
|
|
+ result.scData.push({ id: scd.id, unit_price: node.unit_price });
|
|
|
+ }
|
|
|
});
|
|
|
if (result.ibData.length > 0) await transaction.insert(this.ctx.service.stageBills.tableName, result.ibData);
|
|
|
if (result.ubData.length > 0) await transaction.updateRows(this.ctx.service.stageBills.tableName, result.ubData);
|
|
|
await transaction.delete(this.ctx.service.stageBillsPc.tableName, { sid: stage.id });
|
|
|
if (result.bpcData.length > 0) await transaction.insert(this.ctx.service.stageBillsPc.tableName, result.bpcData);
|
|
|
+ if (result.scData.length > 0) await transaction.updateRows(this.ctx.service.stageChange.tableName, result.scData);
|
|
|
|
|
|
let contract_pc_tp = 0, qc_pc_tp = 0, pc_tp = 0, positive_qc_pc_tp = 0, negative_qc_pc_tp = 0;
|
|
|
for (const bpc of result.bpcData) {
|