Quellcode durchsuchen

内蒙定额基价计算问题

zhongzewei vor 6 Jahren
Ursprung
Commit
df777aeb3e

+ 1 - 1
modules/ration_repository/controllers/ration_repository_controller.js

@@ -269,7 +269,7 @@ class RationRepositoryController extends baseController {
             let stdGLJList = {};
             let stdGLJListByID = {};
             for (const tmp of stdGLJData) {
-                if (tmp.priceProperty && tmp.priceProperty.price1) {
+                if (tmp.priceProperty && Object.keys(tmp.priceProperty).length) {
                     tmp.basePrice = tmp.priceProperty.price1;
                 }
                 stdGLJList[tmp.code.toString()] = tmp.ID;

+ 26 - 29
modules/ration_repository/models/ration_item.js

@@ -497,10 +497,9 @@ rationItemDAO.prototype.updateRationBasePrc = function (basePrcArr, overWriteUrl
                                         gljArr.push({gljId: theGlj.ID, basePrice: adjBasePrice, gljParentType: gljParentType, unit: theGlj.unit});
                                     } else {
                                         if(theGlj.priceProperty && Object.keys(theGlj.priceProperty).length > 0){
-                                            let priceKeys = Object.keys(theGlj.priceProperty);
                                             gljArr.push({
                                                 gljId: theGlj.ID,
-                                                basePrice: parseFloat(theGlj.priceProperty[priceKeys[0]]),
+                                                basePrice: parseFloat(theGlj.priceProperty.price1),
                                                 gljParentType: gljParentType,
                                                 unit: theGlj.unit});
                                         } else {
@@ -731,35 +730,33 @@ rationItemDAO.prototype.calcForRation = function (stdGljList, ration, overWriteU
     for(let rationGlj of rationGljList) {
         let glj = stdGljList[rationGlj.gljId];
         let gljPType = parseInt(glj.gljType.toString().match(/\d+?/)[0]);
-        if (glj.priceProperty && Object.keys(glj.priceProperty).length > 0) {
-            let priceKeys = Object.keys(glj.priceProperty);
-            gljArr.push({
-                gljId: glj.ID,
-                basePrice: parseFloat(glj.priceProperty[priceKeys[0]]),
-                consumeAmt: rationGlj.consumeAmt,
-                gljParentType: gljPType,
-                unit: glj.unit
-            });
-        } else {
-            gljArr.push({gljId: glj.ID, basePrice: parseFloat(glj.basePrice), consumeAmt: rationGlj.consumeAmt, gljParentType: gljPType, unit: glj.unit});
-        }
-        let updatePrc = null;
-        let overWriteCalc = false;  //需要重写算法
-        if (overWriteUrl) {
-            let overWriteExports = require(overWriteUrl);
-            if (typeof overWriteExports.calcRation !== 'undefined') {
-                overWriteCalc = true;
-                updatePrc = overWriteExports.calcRation(gljArr, scMathUtil);
-            }
-        }
-        if (!overWriteCalc) {
-            updatePrc = calcRation(gljArr);
+        let newGlj = {
+            gljId: glj.ID,
+            consumeAmt: rationGlj.consumeAmt,
+            gljParentType: gljPType,
+            unit: glj.unit
+        };
+        newGlj.basePrice = glj.priceProperty && Object.keys(glj.priceProperty).length > 0
+            ? parseFloat(glj.priceProperty.price1)
+            : parseFloat(glj.basePrice);
+        gljArr.push(newGlj);
+    }
+    let updatePrc = null;
+    let overWriteCalc = false;  //需要重写算法
+    if (overWriteUrl) {
+        let overWriteExports = require(overWriteUrl);
+        if (typeof overWriteExports.calcRation !== 'undefined') {
+            overWriteCalc = true;
+            updatePrc = overWriteExports.calcRation(gljArr, scMathUtil);
         }
-        ration.labourPrice = updatePrc.labourPrice.toString();
-        ration.materialPrice = updatePrc.materialPrice.toString();
-        ration.machinePrice = updatePrc.machinePrice.toString();
-        ration.basePrice = updatePrc.basePrice.toString();
     }
+    if (!overWriteCalc) {
+        updatePrc = calcRation(gljArr);
+    }
+    ration.labourPrice = updatePrc.labourPrice.toString();
+    ration.materialPrice = updatePrc.materialPrice.toString();
+    ration.machinePrice = updatePrc.machinePrice.toString();
+    ration.basePrice = updatePrc.basePrice.toString();
 };
 
 /**