|
@@ -144,35 +144,38 @@ class revisePriceCalc {
|
|
|
const said = this.ctx.session.sessionUser.accountId;
|
|
|
billsTree.calculateAll(node => {
|
|
|
if (node.children && node.children.length > 0) return;
|
|
|
- const priceDiff = helper.sub(node.unit_price, node.pre_unit_price);
|
|
|
- if (!priceDiff) return;
|
|
|
+ // const priceDiff = helper.sub(node.unit_price, node.pre_unit_price);
|
|
|
+ // if (!priceDiff) return;
|
|
|
if (node.cur_id && (node.cur_contract_qty || node.cur_qc_qty)) {
|
|
|
- node.cur_contract_tp = helper.mul(node.cur_contract_qty, node.unit_price, decimal.tp);
|
|
|
- node.cur_qc_tp = helper.mul(node.cur_qc_qty, node.unit_price, decimal.tp);
|
|
|
- node.cur_positive_qc_tp = helper.mul(node.cur_positive_qc_qty, node.unit_price, decimal.tp);
|
|
|
- node.cur_negative_qc_tp = helper.mul(node.cur_negative_qc_qty, node.unit_price, decimal.tp);
|
|
|
- result.ibData.push({
|
|
|
- tid: stage.tid, sid: stage.id, said,
|
|
|
- lid: node.id,
|
|
|
- times: stage.times, order: auditOrder,
|
|
|
- contract_qty: node.cur_contract_qty, contract_tp: node.cur_contract_tp,
|
|
|
- qc_qty: node.cur_qc_qty, qc_tp: node.cur_qc_tp,
|
|
|
- positive_qc_qty: node.cur_positive_qc_qty, positive_qc_tp: node.cur_positive_qc_tp,
|
|
|
- negative_qc_qty: node.cur_negative_qc_qty, negative_qc_tp: node.cur_negative_qc_tp,
|
|
|
- postil: node.postil,
|
|
|
- });
|
|
|
+ const cur_contract_tp = helper.mul(node.cur_contract_qty, node.unit_price, decimal.tp);
|
|
|
+ const cur_qc_tp = helper.mul(node.cur_qc_qty, node.unit_price, decimal.tp);
|
|
|
+ const cur_positive_qc_tp = helper.mul(node.cur_positive_qc_qty, node.unit_price, decimal.tp);
|
|
|
+ const cur_negative_qc_tp = helper.mul(node.cur_negative_qc_qty, node.unit_price, decimal.tp);
|
|
|
+ if (cur_contract_tp !== node.cur_contract_tp || cur_qc_tp !== node.cur_qc_tp || cur_positive_qc_tp !== node.cur_positive_qc_tp || cur_negative_qc_tp !== node.cur_positive_qc_tp) {
|
|
|
+ result.ibData.push({
|
|
|
+ tid: stage.tid, sid: stage.id, said,
|
|
|
+ lid: node.id,
|
|
|
+ times: stage.times, order: auditOrder,
|
|
|
+ contract_qty: node.cur_contract_qty, contract_tp: cur_contract_tp,
|
|
|
+ qc_qty: node.cur_qc_qty, qc_tp: cur_qc_tp,
|
|
|
+ positive_qc_qty: node.cur_positive_qc_qty, positive_qc_tp: cur_positive_qc_tp,
|
|
|
+ negative_qc_qty: node.cur_negative_qc_qty, negative_qc_tp: cur_negative_qc_tp,
|
|
|
+ postil: node.postil,
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
if (node.pre_id && (node.pre_contract_qty || node.pre_qc_qty)) {
|
|
|
- node.contract_pc_tp = helper.sub(helper.mul(node.pre_contract_qty, node.unit_price, decimal.tp), node.pre_contract_tp);
|
|
|
- node.qc_pc_tp = helper.sub(helper.mul(node.pre_qc_qty, node.unit_price, decimal.tp), node.pre_qc_tp);
|
|
|
- node.pc_tp = helper.add(node.contract_pc_tp, node.qc_pc_tp);
|
|
|
- node.positive_qc_pc_tp = helper.sub(helper.mul(node.pre_positive_qc_qty, node.unit_price, decimal.tp), node.pre_positive_qc_tp);
|
|
|
- node.negative_qc_pc_tp = helper.sub(helper.mul(node.pre_negative_qc_qty, node.unit_price, decimal.tp), node.pre_negative_qc_tp);
|
|
|
- result.bpcData.push({
|
|
|
- tid: stage.tid, sid: stage.id, sorder: stage.order, lid: node.id, org_price: node.pre_unit_price, unit_price: node.unit_price,
|
|
|
- contract_pc_tp: node.contract_pc_tp, qc_pc_tp: node.qc_pc_tp, pc_tp: node.pc_tp,
|
|
|
- positive_qc_pc_tp: node.positive_qc_pc_tp, negative_qc_pc_tp: node.negative_qc_pc_tp,
|
|
|
- });
|
|
|
+ const contract_pc_tp = helper.sub(helper.mul(node.pre_contract_qty, node.unit_price, decimal.tp), node.pre_contract_tp);
|
|
|
+ const qc_pc_tp = helper.sub(helper.mul(node.pre_qc_qty, node.unit_price, decimal.tp), node.pre_qc_tp);
|
|
|
+ const pc_tp = helper.add(contract_pc_tp, qc_pc_tp);
|
|
|
+ const positive_qc_pc_tp = helper.sub(helper.mul(node.pre_positive_qc_qty, node.unit_price, decimal.tp), node.pre_positive_qc_tp);
|
|
|
+ const negative_qc_pc_tp = helper.sub(helper.mul(node.pre_negative_qc_qty, node.unit_price, decimal.tp), node.pre_negative_qc_tp);
|
|
|
+ if (contract_pc_tp || qc_pc_tp || pc_tp || positive_qc_pc_tp || negative_qc_pc_tp) {
|
|
|
+ result.bpcData.push({
|
|
|
+ tid: stage.tid, sid: stage.id, sorder: stage.order, lid: node.id, org_price: node.pre_unit_price, unit_price: node.unit_price,
|
|
|
+ contract_pc_tp, qc_pc_tp, pc_tp, positive_qc_pc_tp, negative_qc_pc_tp,
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
const scDetail = stageChange.filter(x => { return x.lid === node.id; });
|
|
|
for (const scd of scDetail) {
|