|
@@ -4,8 +4,13 @@
|
|
|
|
|
|
const rationContent = 0, rationPrice = 1, rationPriceConverse = 2, billsPrice = 3;
|
|
|
|
|
|
+// sumTotalFeeFlag: sum(child.totalFee), totalFeeFlag: bills.quantity × bills.unitFee
|
|
|
const sumTotalFeeFlag = 0, totalFeeFlag = 1;
|
|
|
-const rationContentUnitFeeFlag = 0, averageQtyUnitFeeFlag = 1, billsPriceUnitFeeFlag = 2;
|
|
|
+// rationContentUnitFeeFlag: sum(child.unitFee * child.quantity / bills.quantity)
|
|
|
+// averageQtyUnitFeeFlag: sum(child.totalFee/bills.quantity)
|
|
|
+// billsPriceUnitFeeFlag: 根据定额计算程序
|
|
|
+// converseUnitFeeFalg: bills.totalFee / bills.quantity
|
|
|
+const rationContentUnitFeeFlag = 0, averageQtyUnitFeeFlag = 1, billsPriceUnitFeeFlag = 2, converseUnitFeeFlag = 3;
|
|
|
|
|
|
let rationContentCalcFields = [
|
|
|
{'type': 'common', 'unitFeeFlag': rationContentUnitFeeFlag, 'totalFeeFlag': totalFeeFlag},
|
|
@@ -83,6 +88,15 @@ let nodeCalcObj = {
|
|
|
result += (childUnitFee * childQuantity / qty).toDecimal(this.digit);
|
|
|
}
|
|
|
return result;
|
|
|
+ },
|
|
|
+ converseUnitFee: function (digit) {
|
|
|
+ let totalFee = this.sumTotalFee().toDecimal(digit);
|
|
|
+ let qty = this.getFee(this.node.data, 'quantity');
|
|
|
+ if (qty !== 0){
|
|
|
+ return totalFee / qty;
|
|
|
+ } else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -251,7 +265,7 @@ class BillsCalcHelper {
|
|
|
nodeCalcObj.node = node;
|
|
|
nodeCalcObj.digit = this.project.Decimal.unitFee;
|
|
|
calcFees.checkFields(node.data, fields);
|
|
|
- let nodeCalc = nodeCalcObj, virData= null;
|
|
|
+ let nodeCalc = nodeCalcObj, virData= null, decimal = this.project.Decimal;
|
|
|
|
|
|
// 清单单价:套用定额计算程序
|
|
|
if (this.project.calcFlag === billsPrice) {
|
|
@@ -265,24 +279,27 @@ class BillsCalcHelper {
|
|
|
nodeCalcObj.field = field;
|
|
|
switch (field.unitFeeFlag) {
|
|
|
case rationContentUnitFeeFlag:
|
|
|
- node.data.feesIndex[field.type].unitFee = nodeCalcObj.rationContentUnitFee().toDecimal(this.project.Decimal.common.unitFee);
|
|
|
+ node.data.feesIndex[field.type].unitFee = nodeCalcObj.rationContentUnitFee().toDecimal(decimal.common.unitFee);
|
|
|
break;
|
|
|
case averageQtyUnitFeeFlag:
|
|
|
- node.data.feesIndex[field.type].unitFee = nodeCalcObj.averageQty().toDecimal(this.project.Decimal.common.unitFee);
|
|
|
+ node.data.feesIndex[field.type].unitFee = nodeCalcObj.averageQty().toDecimal(decimal.common.unitFee);
|
|
|
+ break;
|
|
|
+ case billsPriceUnitFeeFlag:
|
|
|
+ node.data.feesIndex[field.type].unitFee = virData[field.type];
|
|
|
+ break;
|
|
|
+ case converseUnitFeeFlag:
|
|
|
+ node.data.feesIndex[field.type].unitFee = nodeCalcObj.converseUnitFee(decimal.common.totalFee).toDecimal(decimal.common.unitFee);
|
|
|
break;
|
|
|
- case billsPriceUnitFeeFlag:
|
|
|
- node.data.feesIndex[field.type].unitFee = virData[field.type];
|
|
|
- break;
|
|
|
default:
|
|
|
node.data.feesIndex[field.type].unitFee = 0;
|
|
|
}
|
|
|
let value = 0;
|
|
|
switch (field.totalFeeFlag) {
|
|
|
case sumTotalFeeFlag:
|
|
|
- value = nodeCalcObj.sumTotalFee().toDecimal(this.project.Decimal.common.totalFee);
|
|
|
+ value = nodeCalcObj.sumTotalFee().toDecimal(decimal.common.totalFee);
|
|
|
break;
|
|
|
case totalFeeFlag:
|
|
|
- value = nodeCalcObj.totalFee().toDecimal(this.project.Decimal.common.totalFee);
|
|
|
+ value = nodeCalcObj.totalFee().toDecimal(decimal.common.totalFee);
|
|
|
break;
|
|
|
default:
|
|
|
value = 0;
|