Browse Source

中间计量,计量单元-清单模式,计算调整

MaiXinRong 2 years ago
parent
commit
cca021c143
1 changed files with 11 additions and 4 deletions
  1. 11 4
      app/public/js/stage_im.js

+ 11 - 4
app/public/js/stage_im.js

@@ -624,13 +624,14 @@ const stageIm = (function () {
                 checkZero(ZhCalc.sub(bills.unit_price, x.unit_price));
         });
         if (!gcl) {
-            gcl = {b_code: bills.b_code, name: bills.name, unit: bills.unit, unit_price: bills.unit_price};
+            gcl = {b_code: bills.b_code, name: bills.name, unit: bills.unit, unit_price: bills.unit_price, org_price: bills.org_price};
             im.gclBills.push(gcl);
         }
         gcl.contract_jl = ZhCalc.add(gcl.contract_jl, bills.contract_jl);
         gcl.qc_jl = ZhCalc.add(gcl.qc_jl, bills.qc_jl);
         gcl.qc_minus_jl = ZhCalc.add(gcl.qc_minus_jl, bills.qc_minus_jl);
         gcl.jl = ZhCalc.add(gcl.jl, bills.jl);
+        gcl.pre_jl = ZhCalc.add(gcl.pre_jl, bills.pre_jl);
     }
     function calculateBwBillsIm(im) {
         im.contract_jl = 0;
@@ -639,8 +640,14 @@ const stageIm = (function () {
         for (const b of im.gclBills) {
             im.contract_jl = ZhCalc.add(im.contract_jl, ZhCalc.mul(b.contract_jl, b.unit_price, decimal.tp));
             im.qc_jl = ZhCalc.add(im.qc_jl, ZhCalc.mul(b.qc_jl, b.unit_price, decimal.tp));
+            const priceDiff = b.org_price ? ZhCalc.sub(b.unit_price, b.org_price) : 0;
+            if (priceDiff) {
+                const pc_jl = ZhCalc.sub(ZhCalc.mul(b.unit_price, b.pre_jl, decimal.tp), ZhCalc.mul(b.org_price, b.pre_jl, decimal.tp));
+                im.pc_jl = ZhCalc.add(im.pc_jl, pc_jl);
+
+            }
         }
-        im.jl = ZhCalc.add(im.contract_jl, im.qc_jl);
+        im.jl = ZhCalc.sum([im.contract_jl, im.qc_jl, im.pc_jl]);
     }
     function generateBwBillsImData (node) {
         if (checkUsed(node)) {
@@ -694,8 +701,8 @@ const stageIm = (function () {
                             }
                         }
                         addBwBillsGclBills(im, {
-                            b_code: p.b_code, name: p.name, unit: p.unit, unit_price: p.unit_price,
-                            jl: pp.gather_qty, contract_jl: pp.contract_qty, qc_jl: pp.qc_qty, qc_minus_jl: pp.qc_minus_qty,
+                            b_code: p.b_code, name: p.name, unit: p.unit, unit_price: p.unit_price, org_price: p.org_price,
+                            jl: pp.gather_qty, contract_jl: pp.contract_qty, qc_jl: pp.qc_qty, qc_minus_jl: pp.qc_minus_qty, pre_jl: pp.pre_gather_qty,
                         });
 
                         if (pp.drawing_code && im.drawing_code instanceof Array)