MaiXinRong 2 年之前
父节点
当前提交
c4318733cb
共有 1 个文件被更改,包括 7 次插入6 次删除
  1. 7 6
      app/lib/revise_price.js

+ 7 - 6
app/lib/revise_price.js

@@ -175,17 +175,18 @@ class revisePriceCalc {
         let total_price = 0, positive_tp = 0, negative_tp = 0;
         let total_price = 0, positive_tp = 0, negative_tp = 0;
         for (const b of changeBills) {
         for (const b of changeBills) {
             const p = this.findPrice(b.code, b.name, b.unit, b.unit_price);
             const p = this.findPrice(b.code, b.name, b.unit, b.unit_price);
-            let newPrice = this.ctx.helper.mul(b.unit_price, b.spamount, change.tp_decimal);
+            let bills_tp;
             if (p) {
             if (p) {
                 updateBills.push({ id: b.id, unit_price: p.new_price });
                 updateBills.push({ id: b.id, unit_price: p.new_price });
-                newPrice = this.ctx.helper.mul(p.new_price, b.spamount, change.tp_decimal);
-                // total_price = this.ctx.helper.add(total_price, this.ctx.helper.mul(p.new_price, b.spamount, change.tp_decimal));
+                bills_tp = this.ctx.helper.mul(p.new_price, b.spamount, change.tp_decimal);
+            } else {
+                bills_tp = this.ctx.helper.mul(p.unit_price, b.spamount, change.tp_decimal);
             }
             }
-            total_price = this.ctx.helper.add(total_price, newPrice);
+            total_price = this.ctx.helper.add(total_price, bills_tp);
             if (b.spamount >= 0) {
             if (b.spamount >= 0) {
-                positive_tp = this.ctx.helper.add(positive_tp, newPrice);
+                positive_tp = this.ctx.helper.add(positive_tp, bills_tp);
             } else {
             } else {
-                negative_tp = this.ctx.helper.add(negative_tp, newPrice);
+                negative_tp = this.ctx.helper.add(negative_tp, bills_tp);
             }
             }
         }
         }
         if (updateBills.length > 0) {
         if (updateBills.length > 0) {