瀏覽代碼

变更概况,变更清单指标数据调整

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

+ 10 - 5
app/service/report_memory.js

@@ -1092,16 +1092,21 @@ module.exports = app => {
             if (!this.changeInfo) await this.getChangeInfo(tid, sid);
             this.changeInfoBills = [];
             for (const c of this.changeInfo) {
-                const cb = await this.ctx.service.stageChange.getUsedData(tid, c.cid);
+                const cb = await this.ctx.service.changeAuditList.getAllDataByCondition({ where: { cid: c.cid } });
+                const cbu = await this.ctx.service.stageChange.getUsedData(tid, c.cid);
                 const curUsedBills = await this.ctx.service.stageChange.getStageUsedData(sid, c.cid);
                 for (const b of cb) {
                     b.qty = this.ctx.helper._.toNumber(b.samount);
-                    b.valid_qty = this.ctx.helper.sub(b.qty, b.used_qty);
                     b.tp = this.ctx.helper.round(this.ctx.helper.mul(b.qty, b.unit_price), this.ctx.tender.info.decimal.tp);
-                    const pos = this.ctx.helper._.filter(curUsedBills, { cbid: b.id });
+
+                    const u = cbu.find(x => { return x.id === b.id; });
+                    b.used_qty = u ? u.used_qty : 0;
+
+                    b.valid_qty = this.ctx.helper.sub(b.qty, b.used_qty);
+                    const cur = this.ctx.helper._.filter(curUsedBills, { cbid: b.id });
                     b.cur_qty = 0;
-                    for (const p of pos) {
-                        b.cur_qty = this.ctx.helper.add(b.cur_qty, p.qty);
+                    for (const cc of cur) {
+                        b.cur_qty = this.ctx.helper.add(b.cur_qty, cc.qty);
                     }
                     b.cur_used = !!b.cur_qty;
                     this.changeInfoBills.push(b);