|
@@ -218,7 +218,7 @@ class revisePriceCalc {
|
|
|
const decimal = this.ctx.tender.info.decimal;
|
|
|
const changeBills = await this.ctx.service.changeAuditList.getAllDataByCondition({ where: { cid: change.cid } });
|
|
|
const updateBills = [];
|
|
|
- let total_price = 0, positive_tp = 0, negative_tp = 0;
|
|
|
+ const sumBills = [];
|
|
|
for (const b of changeBills) {
|
|
|
const p = this.findChangeBillsPrice(b.code, b.name, b.unit, b.unit_price, change.cid);
|
|
|
const settleGcl = b.gcl_id ? this.settleBills.find(x => { return x.lid === b.gcl_id; }) : null;
|
|
@@ -231,16 +231,38 @@ class revisePriceCalc {
|
|
|
} else {
|
|
|
bills_tp = this.ctx.helper.mul(b.unit_price, b.spamount, change.tp_decimal || decimal.tp);
|
|
|
}
|
|
|
- total_price = this.ctx.helper.add(total_price, bills_tp);
|
|
|
+ let sb = sumBills.find(x => { return x.gcl_id === b.gcl_id });
|
|
|
+ if (!sb) {
|
|
|
+ sb = {gcl_id: b.gcl_id, unit_price: b.unit_price, v_qty: 0, uv_qty: 0, p_qty: 0, n_qty: 0 };
|
|
|
+ sumBills.push(sb);
|
|
|
+ }
|
|
|
if (b.spamount >= 0) {
|
|
|
- positive_tp = this.ctx.helper.add(positive_tp, bills_tp);
|
|
|
+ sb.p_qty = this.ctx.helper.add(sb.p_qty, b.spamount);
|
|
|
+ } else {
|
|
|
+ sb.n_qty = this.ctx.helper.add(sb.n_qty, b.spamount);
|
|
|
+ }
|
|
|
+ if (b.is_valuation) {
|
|
|
+ sb.v_qty = this.ctx.helper.add(sb.v_qty, b.spamount);
|
|
|
} else {
|
|
|
- negative_tp = this.ctx.helper.add(negative_tp, bills_tp);
|
|
|
+ sb.uv_qty = this.ctx.helper.add(sb.uv_qty, b.spamount);
|
|
|
}
|
|
|
}
|
|
|
+ let positive_tp = 0, negative_tp = 0, valuation_tp = 0, unvaluation_tp = 0;
|
|
|
+ for (const sb of sumBills) {
|
|
|
+ sb.v_tp = this.ctx.helper.mul(sb.v_qty, sb.unit_price, change.tp_decimal || decimal.tp);
|
|
|
+ sb.uv_tp = this.ctx.helper.mul(sb.uv_qty, sb.unit_price, change.tp_decimal || decimal.tp);
|
|
|
+ sb.p_tp = this.ctx.helper.mul(sb.p_qty, sb.unit_price, change.tp_decimal || decimal.tp);
|
|
|
+ sb.n_tp = this.ctx.helper.mul(sb.n_qty, sb.unit_price, change.tp_decimal || decimal.tp);
|
|
|
+
|
|
|
+ valuation_tp = this.ctx.helper.add(sb.v_tp, valuation_tp);
|
|
|
+ unvaluation_tp = this.ctx.helper.add(sb.uv_tp, unvaluation_tp);
|
|
|
+ positive_tp = this.ctx.helper.add(sb.p_tp, positive_tp);
|
|
|
+ negative_tp = this.ctx.helper.add(sb.n_tp, negative_tp);
|
|
|
+ }
|
|
|
+ const total_price = this.ctx.helper.add(valuation_tp, unvaluation_tp);
|
|
|
if (updateBills.length > 0) {
|
|
|
await transaction.updateRows(this.ctx.service.changeAuditList.tableName, updateBills);
|
|
|
- await transaction.update(this.ctx.service.change.tableName, { total_price, positive_tp, negative_tp }, { where: { cid: change.cid } });
|
|
|
+ await transaction.update(this.ctx.service.change.tableName, { total_price, positive_tp, negative_tp, valuation_tp, unvaluation_tp }, { where: { cid: change.cid } });
|
|
|
}
|
|
|
}
|
|
|
/**
|