|
@@ -40,7 +40,11 @@ let nodeCalcObj = {
|
|
|
sumTotalFee: function() {
|
|
|
let result = 0, child;
|
|
|
for (child of this.node.children) {
|
|
|
- result += this.getFee(child.data, this.field.totalFee);
|
|
|
+ let value = this.getFee(child.data, this.field.totalFee);
|
|
|
+ if (Object.prototype.toString.apply(value) === "[object String]") {
|
|
|
+ value = parseFloat(value);
|
|
|
+ }
|
|
|
+ result += value;
|
|
|
}
|
|
|
return result;
|
|
|
},
|
|
@@ -48,6 +52,9 @@ let nodeCalcObj = {
|
|
|
let result = 0, child, qty;
|
|
|
result = this.sumTotalFee(this.field);
|
|
|
qty = this.getFee(this.node.data, 'quantity');
|
|
|
+ if (Object.prototype.toString.apply(qty) === "[object String]") {
|
|
|
+ qty = parseFloat(qty);
|
|
|
+ }
|
|
|
if (qty !== 0) {
|
|
|
result = result / qty;
|
|
|
}
|
|
@@ -58,11 +65,22 @@ let nodeCalcObj = {
|
|
|
},
|
|
|
rationContentUnitFee: function () {
|
|
|
let result = 0, child, qty = this.getFee(this.node.data, 'quantity');
|
|
|
+ if (Object.prototype.toString.apply(qty) === "[object String]") {
|
|
|
+ qty = parseFloat(qty);
|
|
|
+ }
|
|
|
if (qty === 0) {
|
|
|
qty = 1;
|
|
|
}
|
|
|
for (child of this.node.children) {
|
|
|
- result += (this.getFee(child.data, this.field.unitFee) * this.getFee(child.data, 'quantity') / qty).toDecimal(this.digit);
|
|
|
+ let childUnitFee = this.getFee(child.data, this.field.unitFee);
|
|
|
+ if (Object.prototype.toString.apply(childUnitFee) === "[object String]") {
|
|
|
+ childUnitFee = parseFloat(childUnitFee);
|
|
|
+ }
|
|
|
+ let childQuantity = this.getFee(child.data, 'quantity');
|
|
|
+ if (Object.prototype.toString.apply(childQuantity) === "[object String]") {
|
|
|
+ childQuantity = parseFloat(childQuantity);
|
|
|
+ }
|
|
|
+ result += (childUnitFee * childQuantity / qty).toDecimal(this.digit);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
@@ -220,21 +238,26 @@ class BillsCalcHelper {
|
|
|
constructor (project, CalcFlag) {
|
|
|
this.project = project;
|
|
|
this.CalcFlag = CalcFlag;
|
|
|
- switch (this.CalcFlag) {
|
|
|
- case rationContent:
|
|
|
- this.calcField = rationContentCalcFields;
|
|
|
- break;
|
|
|
- case rationPrice:
|
|
|
- this.calcField = rationPriceCalcFields;
|
|
|
- break;
|
|
|
- case rationPriceConverse:
|
|
|
- this.calcField = rationPriceConverseCalcFields;
|
|
|
- break;
|
|
|
- case billsPrice:
|
|
|
- this.calcField = billsPriceCalcFields;
|
|
|
- break;
|
|
|
- default:
|
|
|
- this.calcField = [];
|
|
|
+ this.calcField = JSON.parse(JSON.stringify(feeType));
|
|
|
+ for (let field of this.calcField) {
|
|
|
+ // unitFeeCalcFlag
|
|
|
+ if (this.calcFlag === rationContent) {
|
|
|
+ field.unitFeeFlag = rationContentUnitFeeFlag;
|
|
|
+ } else if ( this.calcFlag === billsPrice) {
|
|
|
+ field.unitFeeFlag = billsPriceUnitFeeFlag;
|
|
|
+ } else {
|
|
|
+ field.unitFeeFlag = averageQtyUnitFeeFlag;
|
|
|
+ }
|
|
|
+ // totalFeeCalcFlag
|
|
|
+ if (field.type === 'common') {
|
|
|
+ if (this.CalcFlag === rationPriceConverse) {
|
|
|
+ field.totalFeeFlag = sumTotalFeeFlag;
|
|
|
+ } else {
|
|
|
+ field.totalFeeFlag = totalFeeFlag;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ field.totalFeeFlag = sumTotalFeeFlag;
|
|
|
+ }
|
|
|
}
|
|
|
this.InitFields(this.calcField);
|
|
|
};
|
|
@@ -289,7 +312,10 @@ class BillsCalcHelper {
|
|
|
}
|
|
|
};
|
|
|
calcVolumePriceLeaf (node, fields) {
|
|
|
-
|
|
|
+ let total = 0;
|
|
|
+ for (let child of this.node.children) {
|
|
|
+ total += this.getFee(child.data, 'feesIndex.common.totalFee');
|
|
|
+ }
|
|
|
};
|
|
|
calcParent (node, fields) {
|
|
|
nodeCalcObj.node = node;
|