|
|
@@ -36,6 +36,14 @@ if(typeof materialComponent !== 'undefined'){
|
|
|
//可以作为材料工料机组成物的工料机类型:普通材料
|
|
|
materialComponent = [201];
|
|
|
}
|
|
|
+
|
|
|
+// 计算单个人材机定额价小数位数
|
|
|
+let singleDecimal = -6,
|
|
|
+ // 汇总小数位数
|
|
|
+ summaryDecimal = -2,
|
|
|
+ // 中间过程
|
|
|
+ processDecimal = -6;
|
|
|
+
|
|
|
//覆盖前端定额基价计算
|
|
|
//基价=人工费+材料费+机械费+管理费利润
|
|
|
//管理费利润=Round(人工费*(管理费消耗量+利润消耗量)%,2) 注:书中管理费、利润的单位都是“%”
|
|
|
@@ -56,8 +64,8 @@ if (typeof rationGLJOprObj !== 'undefined' && typeof rationGLJOprObj.rationCal !
|
|
|
if(gljData.gljType && gljData.consumeAmt && gljData.unit !== '%'){
|
|
|
let parentGLJType = parseInt(String(gljData.gljType)[0]);
|
|
|
if (parentGLJType <= 3) { // 人工、材料、机械
|
|
|
- let single = scMathUtil.roundTo(gljData.basePrice * gljData.consumeAmt, -3);
|
|
|
- tempPrice['gljType' + parentGLJType] = scMathUtil.roundTo(tempPrice['gljType' + parentGLJType] + single, me.processDecimal);
|
|
|
+ let single = scMathUtil.roundTo(gljData.basePrice * gljData.consumeAmt, singleDecimal);
|
|
|
+ tempPrice['gljType' + parentGLJType] = scMathUtil.roundTo(tempPrice['gljType' + parentGLJType] + single, processDecimal);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
@@ -70,41 +78,41 @@ if (typeof rationGLJOprObj !== 'undefined' && typeof rationGLJOprObj.rationCal !
|
|
|
let parentGLJType = parseInt(String(gljData.gljType)[0]);
|
|
|
if (parentGLJType <= 3 && gljData.unit === '%') { // 人工、材料、机械
|
|
|
// %的单个材料费算法是临时材料费*消耗量*0.01
|
|
|
- price['gljType' + parentGLJType].push(scMathUtil.roundTo(tempPrice['gljType' + parentGLJType] * gljData.consumeAmt * 0.01, -3));//取三位
|
|
|
+ price['gljType' + parentGLJType].push(scMathUtil.roundTo(tempPrice['gljType' + parentGLJType] * gljData.consumeAmt * 0.01, singleDecimal));
|
|
|
} else if([6, 7].includes(gljData.gljType)){
|
|
|
- manageProfitConsume = scMathUtil.roundTo(manageProfitConsume + gljData.consumeAmt, -6);
|
|
|
+ manageProfitConsume = scMathUtil.roundTo(manageProfitConsume + gljData.consumeAmt, processDecimal);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
if(price.gljType1.length > 0){
|
|
|
let labourPrice = 0;
|
|
|
price.gljType1.forEach(function (singlePrc) {
|
|
|
- labourPrice = scMathUtil.roundTo(labourPrice + singlePrc, me.processDecimal);
|
|
|
+ labourPrice = scMathUtil.roundTo(labourPrice + singlePrc, processDecimal);
|
|
|
});
|
|
|
- let roundPrice = scMathUtil.roundTo(labourPrice, -2);
|
|
|
+ let roundPrice = scMathUtil.roundTo(labourPrice, summaryDecimal);
|
|
|
rst.labourPrice = roundPrice;
|
|
|
- rationBasePrc = scMathUtil.roundTo(rationBasePrc + roundPrice, -2);
|
|
|
+ rationBasePrc = scMathUtil.roundTo(rationBasePrc + roundPrice, summaryDecimal);
|
|
|
//管理费利润
|
|
|
- let manageProfitPrc = scMathUtil.roundTo(roundPrice * manageProfitConsume * 0.01, -2);
|
|
|
- rationBasePrc = scMathUtil.roundTo(rationBasePrc + manageProfitPrc, -2);
|
|
|
+ let manageProfitPrc = scMathUtil.roundTo(roundPrice * manageProfitConsume * 0.01, summaryDecimal);
|
|
|
+ rationBasePrc = scMathUtil.roundTo(rationBasePrc + manageProfitPrc, summaryDecimal);
|
|
|
}
|
|
|
if(price.gljType2.length > 0){
|
|
|
let materialPrice = 0;
|
|
|
price.gljType2.forEach(function (singlePrc) {
|
|
|
- materialPrice = scMathUtil.roundTo(materialPrice + singlePrc, me.processDecimal);
|
|
|
+ materialPrice = scMathUtil.roundTo(materialPrice + singlePrc, processDecimal);
|
|
|
});
|
|
|
- let roundPrice = scMathUtil.roundTo(materialPrice, -2);
|
|
|
+ let roundPrice = scMathUtil.roundTo(materialPrice, summaryDecimal);
|
|
|
rst.materialPrice = roundPrice;
|
|
|
- rationBasePrc = scMathUtil.roundTo(rationBasePrc + roundPrice, -2);
|
|
|
+ rationBasePrc = scMathUtil.roundTo(rationBasePrc + roundPrice, summaryDecimal);
|
|
|
}
|
|
|
if(price.gljType3.length > 0){
|
|
|
let machinePrice = 0;
|
|
|
price.gljType3.forEach(function (singlePrc) {
|
|
|
- machinePrice = scMathUtil.roundTo(machinePrice + singlePrc, me.processDecimal);
|
|
|
+ machinePrice = scMathUtil.roundTo(machinePrice + singlePrc, processDecimal);
|
|
|
});
|
|
|
- let roundPrice = scMathUtil.roundTo(machinePrice, -2);
|
|
|
+ let roundPrice = scMathUtil.roundTo(machinePrice, summaryDecimal);
|
|
|
rst.machinePrice = roundPrice;
|
|
|
- rationBasePrc = scMathUtil.roundTo(rationBasePrc + roundPrice, -2);
|
|
|
+ rationBasePrc = scMathUtil.roundTo(rationBasePrc + roundPrice, summaryDecimal);
|
|
|
}
|
|
|
rst.rationBasePrc = rationBasePrc;
|
|
|
}
|
|
|
@@ -125,8 +133,8 @@ function calcRation(gljArr, scMathUtil) {
|
|
|
if (gljItem.gljParentType !== -1 &&
|
|
|
gljItem.gljParentType <= 3 &&
|
|
|
gljItem.unit !== '%') {
|
|
|
- let single = scMathUtil.roundTo(gljItem.basePrice * gljItem.consumeAmt, -3);
|
|
|
- tempPrice['gljType' + gljItem.gljParentType] = scMathUtil.roundTo(tempPrice['gljType' + gljItem.gljParentType] + single, -6);
|
|
|
+ let single = scMathUtil.roundTo(gljItem.basePrice * gljItem.consumeAmt, singleDecimal);
|
|
|
+ tempPrice['gljType' + gljItem.gljParentType] = scMathUtil.roundTo(tempPrice['gljType' + gljItem.gljParentType] + single, processDecimal);
|
|
|
}
|
|
|
});
|
|
|
labourPrc.push(tempPrice.gljType1);
|
|
|
@@ -136,9 +144,9 @@ function calcRation(gljArr, scMathUtil) {
|
|
|
let singlePrc = 0;
|
|
|
if(gljItem.gljParentType !== -1){
|
|
|
if (gljItem.gljParentType <= 3 && gljItem.unit === '%') {
|
|
|
- singlePrc = scMathUtil.roundTo(tempPrice['gljType' + gljItem.gljParentType] * gljItem.consumeAmt * 0.01, -3);
|
|
|
+ singlePrc = scMathUtil.roundTo(tempPrice['gljType' + gljItem.gljParentType] * gljItem.consumeAmt * 0.01, singleDecimal);
|
|
|
} else if (gljItem.gljParentType > 3) {
|
|
|
- singlePrc = scMathUtil.roundTo(gljItem.basePrice * gljItem.consumeAmt, -3);
|
|
|
+ singlePrc = scMathUtil.roundTo(gljItem.basePrice * gljItem.consumeAmt, singleDecimal);
|
|
|
}
|
|
|
if(gljItem.gljParentType === 1){
|
|
|
labourPrc.push(singlePrc);
|
|
|
@@ -147,36 +155,36 @@ function calcRation(gljArr, scMathUtil) {
|
|
|
} else if(gljItem.gljParentType === 3){
|
|
|
machinePrc.push(singlePrc);
|
|
|
} else if(gljItem.gljParentType === 6){
|
|
|
- manageProfitConsume = scMathUtil.roundTo(manageProfitConsume + gljItem.consumeAmt, -6);
|
|
|
+ manageProfitConsume = scMathUtil.roundTo(manageProfitConsume + gljItem.consumeAmt, processDecimal);
|
|
|
} else if(gljItem.gljParentType === 7){
|
|
|
- manageProfitConsume = scMathUtil.roundTo(manageProfitConsume + gljItem.consumeAmt, -6);
|
|
|
+ manageProfitConsume = scMathUtil.roundTo(manageProfitConsume + gljItem.consumeAmt, processDecimal);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
if(labourPrc.length > 0){
|
|
|
let sumLaP = 0;
|
|
|
for(let i=0; i<labourPrc.length; i++){
|
|
|
- sumLaP = scMathUtil.roundTo(sumLaP + labourPrc[i], -6);
|
|
|
+ sumLaP = scMathUtil.roundTo(sumLaP + labourPrc[i], processDecimal);
|
|
|
}
|
|
|
- updatePrc.labourPrice = scMathUtil.roundTo(sumLaP, -2);
|
|
|
- updatePrc.manageProfitPrice = scMathUtil.roundTo(updatePrc.labourPrice * manageProfitConsume * 0.01, -2);
|
|
|
- updatePrc.basePrice = scMathUtil.roundTo(updatePrc.labourPrice + updatePrc.manageProfitPrice, -2);
|
|
|
+ updatePrc.labourPrice = scMathUtil.roundTo(sumLaP, summaryDecimal);
|
|
|
+ updatePrc.manageProfitPrice = scMathUtil.roundTo(updatePrc.labourPrice * manageProfitConsume * 0.01, summaryDecimal);
|
|
|
+ updatePrc.basePrice = scMathUtil.roundTo(updatePrc.labourPrice + updatePrc.manageProfitPrice, summaryDecimal);
|
|
|
}
|
|
|
if(materialPrc.length > 0){
|
|
|
let sumMtP = 0;
|
|
|
for(let i= 0; i<materialPrc.length; i++){
|
|
|
- sumMtP = scMathUtil.roundTo(sumMtP + materialPrc[i], -6);
|
|
|
+ sumMtP = scMathUtil.roundTo(sumMtP + materialPrc[i], processDecimal);
|
|
|
}
|
|
|
- updatePrc.materialPrice = scMathUtil.roundTo(sumMtP, -2);
|
|
|
- updatePrc.basePrice = scMathUtil.roundTo(updatePrc.basePrice + updatePrc.materialPrice, -2);
|
|
|
+ updatePrc.materialPrice = scMathUtil.roundTo(sumMtP, summaryDecimal);
|
|
|
+ updatePrc.basePrice = scMathUtil.roundTo(updatePrc.basePrice + updatePrc.materialPrice, summaryDecimal);
|
|
|
}
|
|
|
if(machinePrc.length > 0){
|
|
|
let sumMaP = 0;
|
|
|
for(let i =0; i< machinePrc.length; i++){
|
|
|
- sumMaP = scMathUtil.roundTo(sumMaP + machinePrc[i], -6);
|
|
|
+ sumMaP = scMathUtil.roundTo(sumMaP + machinePrc[i], processDecimal);
|
|
|
}
|
|
|
- updatePrc.machinePrice = scMathUtil.roundTo(sumMaP, -2);
|
|
|
- updatePrc.basePrice = scMathUtil.roundTo(updatePrc.basePrice + updatePrc.machinePrice, -2);
|
|
|
+ updatePrc.machinePrice = scMathUtil.roundTo(sumMaP, summaryDecimal);
|
|
|
+ updatePrc.basePrice = scMathUtil.roundTo(updatePrc.basePrice + updatePrc.machinePrice, summaryDecimal);
|
|
|
}
|
|
|
return updatePrc;
|
|
|
}
|