|
@@ -210,11 +210,11 @@ module.exports = app => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- async _reCalcLedger(tenderId, newDecimal, oldDecimal) {
|
|
|
+ async _reCalcLedger(tenderId, billsService, newDecimal, oldDecimal) {
|
|
|
const changeBills = [];
|
|
|
const calcUp = newDecimal.up < oldDecimal.up, calcTp = newDecimal.tp !== oldDecimal.tp;
|
|
|
if (calcUp || calcTp) {
|
|
|
- const bills = await this.ctx.service.ledger.getAllDataByCondition({
|
|
|
+ const bills = await billsService.getAllDataByCondition({
|
|
|
columns: ['id', 'unit_price', 'sgfh_qty', 'sjcl_qty', 'qtcl_qty', 'deal_qty', 'quantity'],
|
|
|
where: { tender_id: tenderId, is_leaf: true },
|
|
|
});
|
|
@@ -292,7 +292,11 @@ module.exports = app => {
|
|
|
changeAdvanceBills.push(cb);
|
|
|
}
|
|
|
}
|
|
|
- const changeBills = await this._reCalcLedger(tenderId, newDecimal, oldDecimal);
|
|
|
+
|
|
|
+ const billsService = this.ctx.tender.data.status === auditConst.ledger.status.checked
|
|
|
+ ? this.ctx.service.ledger
|
|
|
+ : this.ctx.service.reviseBills;
|
|
|
+ const changeBills = await this._reCalcLedger(tenderId, billsService, newDecimal, oldDecimal);
|
|
|
const [changeSj, changeSb, changeSo] = await this._reCalcStageExtra(tenderId, newDecimal, oldDecimal);
|
|
|
if (changeBills.length > 0 ||
|
|
|
changeAdvanceBills.length > 0 ||
|
|
@@ -301,7 +305,7 @@ module.exports = app => {
|
|
|
try {
|
|
|
await transaction.update(this.tableName,
|
|
|
{ decimal: JSON.stringify(newDecimal) }, { where: { tid: tenderId } });
|
|
|
- if (changeBills.length > 0) await transaction.updateRows(this.ctx.service.ledger.tableName, changeBills);
|
|
|
+ if (changeBills.length > 0) await transaction.updateRows(billsService.tableName, changeBills);
|
|
|
if (changeSj.length > 0) await transaction.updateRows(this.ctx.service.stageJgcl.tableName, changeSj);
|
|
|
if (changeSb.length > 0) await transaction.updateRows(this.ctx.service.stageBonus.tableName, changeSb);
|
|
|
if (changeSo.length > 0) await transaction.updateRows(this.ctx.service.stageOther.tableName, changeSo);
|