Forráskód Böngészése

暂存计量,总额计量相关

MaiXinRong 3 éve
szülő
commit
0cb24f2d3c
1 módosított fájl, 19 hozzáadás és 12 törlés
  1. 19 12
      app/service/stage_stash.js

+ 19 - 12
app/service/stage_stash.js

@@ -124,20 +124,27 @@ module.exports = app => {
                     nbs.contract_tp = this.ctx.helper.mul(nbs.contract_qty, b.unit_price, decimal.tp);
                     nbs.qc_tp = this.ctx.helper.mul(nbs.qc_qty, b.unit_price, decimal.tp);
                 } else {
-                    nbs.contract_qty = this.ctx.helper.round(d.contract_qty, decimal.qty);
-                    nbs.contract_tp = this.ctx.helper.mul(nbs.contract_qty, b.unit_price, decimal.tp);
-                    nbs.qc_qty = 0;
-                    if (d.change) {
-                        for (const c of d.change) {
-                            if (!c.qty) continue;
-                            const ncs = { tid: stage.tid, sid: stage.id, lid: d.id, pid: -1, stimes: 1, sorder: 0, cid: c.cid, cbid: c.cbid, minus: c.minus };
-                            const validQty = await this.ctx.service.stageChangeFinal.getChangeBillsValidQty(c.cbid);
-                            ncs.qty = validQty >= c.qty ? c.qty : validQty;
-                            insertChangeData.push(ncs);
-                            if (!ncs.minus) nbs.qc_qty = await this.ctx.helper.add(nbs.qc_qty, ncs.qty);
+                    if (b.is_tp) {
+                        nbs.contract_qty = 0;
+                        nbs.contract_tp = this.ctx.helper.round(d.contract_tp, decimal.tp);
+                        nbs.qc_qty = 0;
+                        nbs.qc_tp = 0;
+                    } else {
+                        nbs.contract_qty = this.ctx.helper.round(d.contract_qty, decimal.qty);
+                        nbs.contract_tp = this.ctx.helper.mul(nbs.contract_qty, b.unit_price, decimal.tp);
+                        nbs.qc_qty = 0;
+                        if (d.change) {
+                            for (const c of d.change) {
+                                if (!c.qty) continue;
+                                const ncs = { tid: stage.tid, sid: stage.id, lid: d.id, pid: -1, stimes: 1, sorder: 0, cid: c.cid, cbid: c.cbid, minus: c.minus };
+                                const validQty = await this.ctx.service.stageChangeFinal.getChangeBillsValidQty(c.cbid);
+                                ncs.qty = validQty >= c.qty ? c.qty : validQty;
+                                insertChangeData.push(ncs);
+                                if (!ncs.minus) nbs.qc_qty = await this.ctx.helper.add(nbs.qc_qty, ncs.qty);
+                            }
                         }
+                        nbs.qc_tp = this.ctx.helper.mul(nbs.qc_qty, b.unit_price, decimal.tp);
                     }
-                    nbs.qc_tp = this.ctx.helper.mul(nbs.qc_qty, b.unit_price, decimal.tp);
                 }
                 insertBillsData.push(nbs);
             }