|
@@ -211,6 +211,8 @@ module.exports = app => {
|
|
|
}
|
|
|
|
|
|
async _reCalcLedger(tenderId, billsService, newDecimal, oldDecimal) {
|
|
|
+ if (!billsService) return [];
|
|
|
+
|
|
|
const changeBills = [];
|
|
|
const calcUp = newDecimal.up < oldDecimal.up, calcTp = newDecimal.tp !== oldDecimal.tp;
|
|
|
if (calcUp || calcTp) {
|
|
@@ -293,9 +295,18 @@ module.exports = app => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- const billsService = this.ctx.tender.data.status === auditConst.ledger.status.checked
|
|
|
- ? this.ctx.service.ledger
|
|
|
- : this.ctx.service.reviseBills;
|
|
|
+ let billsService = null;
|
|
|
+ if (this.ctx.tender.data.status === auditConst.ledger.status.checked) {
|
|
|
+ const stageCount = this.ctx.service.stage.count({tid: tenderId});
|
|
|
+ if (stageCount === 0) {
|
|
|
+ const revise = await ctx.service.ledgerRevise.getLastestRevise(tenderId);
|
|
|
+ if (revise.status === auditConst.revise.status.uncheck || revise.status === auditConst.revise.status.checkNo) {
|
|
|
+ billsService = this.ctx.service.reviseBills;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ billsService = this.ctx.service.ledger;
|
|
|
+ }
|
|
|
const changeBills = await this._reCalcLedger(tenderId, billsService, newDecimal, oldDecimal);
|
|
|
const [changeSj, changeSb, changeSo] = await this._reCalcStageExtra(tenderId, newDecimal, oldDecimal);
|
|
|
if (changeBills.length > 0 ||
|