|
|
@@ -484,21 +484,21 @@ module.exports = app => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- async calcCamountSum(transaction, updateTpDecimal = false) {
|
|
|
+ async calcCamountSum(transaction, updateTpDecimal = false, change = this.ctx.change) {
|
|
|
// const sql = 'SELECT SUM(ROUND(`camount`*`unit_price`, )) as total_price FROM ?? WHERE cid = ?';
|
|
|
// const sqlParam = [this.tableName, this.change.cid];
|
|
|
// const tp = await transaction.queryOne(sql, sqlParam);
|
|
|
// 防止小数位不精确,采用取值计算
|
|
|
const sql = 'SELECT unit_price, spamount, is_valuation, gcl_id, unit FROM ?? WHERE cid = ?';
|
|
|
- const sqlParam = [this.tableName, this.ctx.change.cid];
|
|
|
+ const sqlParam = [this.tableName, change.cid];
|
|
|
const changeList = await transaction.query(sql, sqlParam);
|
|
|
let total_price = 0;
|
|
|
let positive_tp = 0;
|
|
|
let negative_tp = 0;
|
|
|
let valuation_tp = 0;
|
|
|
let unvaluation_tp = 0;
|
|
|
- const tp_decimal = this.ctx.change.tp_decimal ? this.ctx.change.tp_decimal : this.ctx.tender.info.decimal.tp;
|
|
|
- const up_decimal = this.ctx.change.up_decimal ? this.ctx.change.up_decimal : this.ctx.tender.info.decimal.up;
|
|
|
+ const tp_decimal = change.tp_decimal ? change.tp_decimal : this.ctx.tender.info.decimal.tp;
|
|
|
+ const up_decimal = change.up_decimal ? change.up_decimal : this.ctx.tender.info.decimal.up;
|
|
|
const gclChangeList = this._.uniq(this._.map(changeList, 'gcl_id'));
|
|
|
for (const g of gclChangeList) {
|
|
|
if (g) {
|
|
|
@@ -560,7 +560,7 @@ module.exports = app => {
|
|
|
}
|
|
|
const options = {
|
|
|
where: {
|
|
|
- cid: this.ctx.change.cid,
|
|
|
+ cid: change.cid,
|
|
|
},
|
|
|
};
|
|
|
await transaction.update(this.ctx.service.change.tableName, updateData, options);
|
|
|
@@ -645,7 +645,7 @@ module.exports = app => {
|
|
|
await transaction.delete(this.tableName, delData);
|
|
|
for (const c of changes) {
|
|
|
// 重算选了此清单的变更令已变更金额
|
|
|
- await this.reCalcTp(transaction, c.cid);
|
|
|
+ await this.calcCamountSum(transaction, false, c);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -718,7 +718,7 @@ module.exports = app => {
|
|
|
if (updateArr.length > 0) await transaction.updateRows(this.tableName, updateArr);
|
|
|
if (cidList.length > 0) {
|
|
|
for (const c of cidList) {
|
|
|
- await this.reCalcTp(transaction, c);
|
|
|
+ await this.calcCamountSum(transaction, false, c);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -941,9 +941,9 @@ module.exports = app => {
|
|
|
async reCalcTp(transaction, cid) {
|
|
|
const change = await transaction.get(this.ctx.service.change.tableName, { cid });
|
|
|
let count = '';
|
|
|
- if (change.status === audit.flow.status.uncheck || change.status === audit.flow.status.back || change.status === audit.flow.status.revise) {
|
|
|
+ if (change.status === audit.change.status.uncheck || change.status === audit.change.status.checkNo || change.status === audit.change.status.revise) {
|
|
|
count = '`camount`';
|
|
|
- } else if (change.status === audit.flow.status.checking || change.status === audit.flow.status.backnew) {
|
|
|
+ } else if (change.status === audit.change.status.checking || change.status === audit.change.status.checkNoPre) {
|
|
|
count = '`spamount`';
|
|
|
}
|
|
|
if (count) {
|