瀏覽代碼

通用金额、单价小数位数策略调整(未开始计量前,台账修订时,可修订并重算)

MaiXinRong 4 年之前
父節點
當前提交
d50ae903a9
共有 1 個文件被更改,包括 8 次插入4 次删除
  1. 8 4
      app/service/tender_info.js

+ 8 - 4
app/service/tender_info.js

@@ -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);