瀏覽代碼

修复修订计算正负变更值bug

laiguoran 2 年之前
父節點
當前提交
256d0bd14e
共有 1 個文件被更改,包括 6 次插入5 次删除
  1. 6 5
      app/lib/revise_price.js

+ 6 - 5
app/lib/revise_price.js

@@ -175,16 +175,17 @@ class revisePriceCalc {
         let total_price = 0, positive_tp = 0, negative_tp = 0;
         for (const b of changeBills) {
             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);
             if (p) {
                 updateBills.push({ id: b.id, unit_price: p.new_price });
-                total_price = this.ctx.helper.add(total_price, this.ctx.helper.mul(p.new_price, b.spamount, change.tp_decimal));
-            } else {
-                total_price = this.ctx.helper.add(total_price, this.ctx.helper.mul(b.unit_price, b.spamount, change.tp_decimal));
+                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));
             }
+            total_price = this.ctx.helper.add(total_price, newPrice);
             if (b.spamount >= 0) {
-                positive_tp = this.ctx.helper.add(positive_tp, total_price);
+                positive_tp = this.ctx.helper.add(positive_tp, newPrice);
             } else {
-                negative_tp = this.ctx.helper.add(negative_tp, total_price);
+                negative_tp = this.ctx.helper.add(negative_tp, newPrice);
             }
         }
         if (updateBills.length > 0) {