Преглед изворни кода

feat: 通用累进算法变更,支持金额限定值的处理

vian пре 5 година
родитељ
комит
7b4c522e1b
2 измењених фајлова са 12 додато и 3 уклоњено
  1. 3 1
      modules/main/facade/project_facade.js
  2. 9 2
      public/calculate_util.js

+ 3 - 1
modules/main/facade/project_facade.js

@@ -420,7 +420,9 @@ function getReportData(nameList, items, prjTypeNames, compilationScopes, decimal
     if (progressiveInterval && isProgressiveType && rootFlag == fixedFlag.MAINTENANCE_EXPENSES) {
       let baseArr = calcUtil.getProgressive(bills.calcBase, overWrite ? overWrite.progression : undefined);
       if (baseArr.length > 0) {
-        let calcTotal = calcUtil.getProgressiveFee(baseTotal, baseArr[0], progressiveInterval, decimal.bills.totalPrice, overWrite ? overWrite.deficiency : undefined);
+        let deficiency = overWrite && overWrite.deficiency || null;
+        let beyond = overWrite && overWrite.beyond || null;
+        let calcTotal = calcUtil.getProgressiveFee(baseTotal, baseArr[0], progressiveInterval, decimal.bills.totalPrice, deficiency, beyond );
         tem.billsTtlPrice = calcTotal;
         let rate = scMathUtil.roundForObj(calcTotal * 100 / baseTotal, decimal.feeRate);
         tem.billsMemos = "费率:" + rate + "%";

+ 9 - 2
public/calculate_util.js

@@ -29,9 +29,10 @@
      * @param {Array} progressiveData - 项目的累进数据(property.progressiveInterval)
      * @param {Number} decimal - 精度
      * @param {Object} deficiency - 不足处理映射 @example: {'路线工程监理费': 20000 } // 不足2万按2万
+     * @param {Object} beyond - 超出处理映射 @example: {'路线工程监理费': 500000 } // 超过50万按50万
      * @return {Number}
      */
-    function getProgressiveFee(baseFee, name, progressiveData, decimal, deficiency) {
+    function getProgressiveFee(baseFee, name, progressiveData, decimal, deficiency, beyond) {
         if (!progressiveData) {
             throw '该项目不存在累进区间数据';
         }
@@ -104,8 +105,14 @@
         }
         //累进所在区间
         fee = scMathUtil.roundForObj(fee + (baseFee - withinData.min) * withinData.feeRate * 0.01, decimal);
-        // 不足处理
+        // 不足、超出处理
         const deficiencyFee = deficiency && deficiency[name] || 0;
+        const beyondFee = beyond && beyond[name] || 0;
+        return deficiencyFee && fee > 0 && fee < deficiencyFee
+            ? deficiencyFee
+            : beyondFee && fee > beyondFee
+                ? beyondFee
+                : fee;
         return deficiencyFee
             ? fee > 0 && fee < deficiencyFee
                 ? deficiencyFee