所有小数保留两位

master
xxssyyyyssxx 2021-12-27 09:37:46 +08:00
parent 2378154032
commit 68316c4c83
7 changed files with 75 additions and 66 deletions

View File

@ -189,8 +189,8 @@ function bindChangeableInput() {
var taxRate = f2($(this).parent().parent().find(".input-changeable-tax-rate").val());
console.log(amount,price,taxRate);
$(this).parent().parent().find(".input-changeable-total-tax-include").val(f2(amount*price));
$(this).parent().parent().find(".input-changeable-total-tax-exclude").val(f2(amount*price/(1+taxRate/100)));
$(this).parent().parent().find(".input-changeable-total-tax-include").val(f2Fixed(amount*price));
$(this).parent().parent().find(".input-changeable-total-tax-exclude").val(f2Fixed(amount*price/(1+taxRate/100)));
});
//单价改变
$(".input-changeable-price").change(function () {
@ -200,8 +200,8 @@ function bindChangeableInput() {
var taxRate = f2($(this).parent().parent().find(".input-changeable-tax-rate").val());
console.log(amount,price,taxRate);
$(this).parent().parent().find(".input-changeable-total-tax-include").val(f2(amount*price));
$(this).parent().parent().find(".input-changeable-total-tax-exclude").val(f2(amount*price/(1+taxRate/100)));
$(this).parent().parent().find(".input-changeable-total-tax-include").val(f2Fixed(amount*price));
$(this).parent().parent().find(".input-changeable-total-tax-exclude").val(f2Fixed(amount*price/(1+taxRate/100)));
});
//税率改变
$(".input-changeable-tax-rate").change(function () {
@ -211,7 +211,7 @@ function bindChangeableInput() {
var price = f2($(this).parent().parent().find(".input-changeable-price").val());
console.log(amount,price,taxRate);
$(this).parent().parent().find(".input-changeable-total-tax-exclude").val(f2(amount*price/(1+taxRate/100)));
$(this).parent().parent().find(".input-changeable-total-tax-exclude").val(f2Fixed(amount*price/(1+taxRate/100)));
});
}
/**
@ -245,10 +245,10 @@ function updateProjectContributionProfitRate() {
//公司管理费用
var costCompanyManageTaxExclude = f2(inputVal("costCompanyManageTaxExclude"));
var projectGrossProfit = f2(incomeTotalTaxExclude-costTotalTaxExclude-costExpropriationTaxExclude);
var projectGrossProfitRate = rate(projectGrossProfit, incomeTotalTaxExclude);
var projectContributionProfit = f2(projectGrossProfit-costCompanyManageTaxExclude);
var projectContributionProfitRate = rate(projectContributionProfit, incomeTotalTaxExclude);
var projectGrossProfit = f2Fixed(incomeTotalTaxExclude-costTotalTaxExclude-costExpropriationTaxExclude);
var projectGrossProfitRate = f2Fixed(rate(projectGrossProfit, incomeTotalTaxExclude));
var projectContributionProfit = f2Fixed(projectGrossProfit-costCompanyManageTaxExclude);
var projectContributionProfitRate = f2Fixed(rate(projectContributionProfit, incomeTotalTaxExclude));
$("input[name='projectGrossProfit']").val(projectGrossProfit);
$("input[name='projectGrossProfitRate']").val(projectGrossProfitRate);

View File

@ -191,20 +191,20 @@ function updateCostData(data, returnData) {
otherTaxExclude += f2(t["totalTaxExclude"]);
}
});
$("input[name='costPurchaseDeviceTaxInclude']").val(f2(deviceTaxInclude));
$("input[name='costPurchaseDeviceTaxExclude']").val(f2(deviceTaxExclude));
$("input[name='costPurchaseBuildTaxInclude']").val(f2(buildTaxInclude));
$("input[name='costPurchaseBuildTaxExclude']").val(f2(buildTaxExclude));
$("input[name='costPurchaseServiceTaxInclude']").val(f2(serviceTaxInclude));
$("input[name='costPurchaseServiceTaxExclude']").val(f2(serviceTaxExclude));
$("input[name='costPurchaseOtherTaxInclude']").val(f2(otherTaxInclude));
$("input[name='costPurchaseOtherTaxExclude']").val(f2(otherTaxExclude));
$("input[name='costPurchaseDeviceTaxInclude']").val(f2Fixed(deviceTaxInclude));
$("input[name='costPurchaseDeviceTaxExclude']").val(f2Fixed(deviceTaxExclude));
$("input[name='costPurchaseBuildTaxInclude']").val(f2Fixed(buildTaxInclude));
$("input[name='costPurchaseBuildTaxExclude']").val(f2Fixed(buildTaxExclude));
$("input[name='costPurchaseServiceTaxInclude']").val(f2Fixed(serviceTaxInclude));
$("input[name='costPurchaseServiceTaxExclude']").val(f2Fixed(serviceTaxExclude));
$("input[name='costPurchaseOtherTaxInclude']").val(f2Fixed(otherTaxInclude));
$("input[name='costPurchaseOtherTaxExclude']").val(f2Fixed(otherTaxExclude));
//资金计划表中的
$(".input-total-title-device-cost-budget-plan").val(f2(deviceTaxInclude));
$(".input-total-title-engineer-cost-budget-plan").val(f2(f2(serviceTaxInclude)+f2(buildTaxInclude)+f2(otherTaxInclude)));
$(".input-total-title-total-cost-budget-plan").val(f2(f2(deviceTaxInclude)+f2(buildTaxInclude)+f2(serviceTaxInclude)+f2(otherTaxInclude)
$(".input-total-title-device-cost-budget-plan").val(f2Fixed(deviceTaxInclude));
$(".input-total-title-engineer-cost-budget-plan").val(f2Fixed(f2(serviceTaxInclude)+f2(buildTaxInclude)+f2(otherTaxInclude)));
$(".input-total-title-total-cost-budget-plan").val(f2Fixed(f2(deviceTaxInclude)+f2(buildTaxInclude)+f2(serviceTaxInclude)+f2(otherTaxInclude)
+f2($(".input-total-title-project-manage-cost-budget-plan").val())
+f2($(".input-total-title-earnest-money-cost-budget-plan").val())));

View File

@ -103,11 +103,11 @@ function updateCostProjectManageData(data,returnData) {
total = f2(total);
$("input[name='costProjectManageTaxExclude']").val(total);
$("input[name='costProjectManageTaxInclude']").val(total);
$("input[name='costProjectManageTaxExclude']").val(f2Fixed(total));
$("input[name='costProjectManageTaxInclude']").val(f2Fixed(total));
//资金计划表中的
$(".input-total-title-project-manage-cost-budget-plan").val(total);
$(".input-total-title-project-manage-cost-budget-plan").val(f2Fixed(total));
var deviceTaxExclude = $("input[name='costPurchaseDeviceTaxExclude']").val();
@ -122,7 +122,7 @@ function updateCostProjectManageData(data,returnData) {
var buildTaxInclude = $("input[name='costPurchaseBuildTaxInclude']").val();
var serviceTaxInclude = $("input[name='costPurchaseServiceTaxInclude']").val();
var otherTaxInclude = $("input[name='costPurchaseOtherTaxInclude']").val();
$(".input-total-title-total-cost-budget-plan").val(f2(f2(deviceTaxInclude)+f2(buildTaxInclude)+f2(serviceTaxInclude)+f2(otherTaxInclude)
$(".input-total-title-total-cost-budget-plan").val(f2Fixed(f2(deviceTaxInclude)+f2(buildTaxInclude)+f2(serviceTaxInclude)+f2(otherTaxInclude)
+total
+f2($(".input-total-title-earnest-money-cost-budget-plan").val())));

View File

@ -63,20 +63,20 @@ function updateIncomeData(data,returnData) {
serviceTaxExclude += f2(t["totalTaxExclude"]);
}
});
$("input[name='incomeDeviceTaxInclude']").val(f2(deviceTaxInclude));
$("input[name='incomeDeviceTaxExclude']").val(f2(deviceTaxExclude));
$("input[name='incomeEngineerTaxInclude']").val(f2(engineerTaxInclude));
$("input[name='incomeEngineerTaxExclude']").val(f2(engineerTaxExclude));
$("input[name='incomeServiceTaxInclude']").val(f2(serviceTaxInclude));
$("input[name='incomeServiceTaxExclude']").val(f2(serviceTaxExclude));
$("input[name='incomeDeviceTaxInclude']").val(f2Fixed(deviceTaxInclude));
$("input[name='incomeDeviceTaxExclude']").val(f2Fixed(deviceTaxExclude));
$("input[name='incomeEngineerTaxInclude']").val(f2Fixed(engineerTaxInclude));
$("input[name='incomeEngineerTaxExclude']").val(f2Fixed(engineerTaxExclude));
$("input[name='incomeServiceTaxInclude']").val(f2Fixed(serviceTaxInclude));
$("input[name='incomeServiceTaxExclude']").val(f2Fixed(serviceTaxExclude));
$("input[name='incomeTotalTaxInclude']").val(f2(deviceTaxInclude+engineerTaxInclude+serviceTaxInclude));
$("input[name='incomeTotalTaxExclude']").val(f2(deviceTaxExclude+engineerTaxExclude+serviceTaxExclude));
$("input[name='incomeTotalTaxInclude']").val(f2Fixed(deviceTaxInclude+engineerTaxInclude+serviceTaxInclude));
$("input[name='incomeTotalTaxExclude']").val(f2Fixed(deviceTaxExclude+engineerTaxExclude+serviceTaxExclude));
$(".input-total-title-sale-income-budget-plan").val($("input[name='incomeTotalTaxInclude']").val());
$(".input-total-title-total-income-budget-plan").val(f2($("input[name='incomeTotalTaxInclude']").val())
+f2($(".input-total-title-earnest-money-income-budget-plan").val()));
$(".input-total-title-total-income-budget-plan").val(f2Fixed(f2($("input[name='incomeTotalTaxInclude']").val())
+f2($(".input-total-title-earnest-money-income-budget-plan").val())));
updateProjectContributionProfitRate();

View File

@ -356,7 +356,7 @@ function updateBudgetPlanTotal(className, totalClassName) {
total += f2($(this).val());
});
$("."+totalClassName).val(f2(total));
$("."+totalClassName).val(f2Fixed(total));
}
/**
@ -377,12 +377,12 @@ function updateEachFundBalance() {
prevFundBalance = 0;
}
fundBalance = income - cost + prevFundBalance;
$(this).val(f2(fundBalance));
$(this).val(f2Fixed(fundBalance));
});
//总余额=最后一个月的余额
$(".input-total-fund-balance-budget-plan").val(f2(fundBalance));
$(".input-total-title-fund-balance-budget-plan").val(f2(fundBalance));
$(".input-total-fund-balance-budget-plan").val(f2Fixed(fundBalance));
$(".input-total-title-fund-balance-budget-plan").val(f2Fixed(fundBalance));
}
@ -406,14 +406,14 @@ function updateEachUnderwrittenPlan() {
total += underwrittenPlan;
$(this).val(underwrittenPlan);
$(this).val(f2Fixed(underwrittenPlan));
});
//总垫资计划=所有月累加
$(".input-total-underwritten-plan-budget-plan").val(f2(total));
$(".input-total-title-underwritten-plan-budget-plan").val(f2(total));
$(".input-total-underwritten-plan-budget-plan").val(f2Fixed(total));
$(".input-total-title-underwritten-plan-budget-plan").val(f2Fixed(total));
//下放小表的垫资峰值金额
$(".input-underwritten-plan-statistic-amount-budget-plan").val(f2(total));
$(".input-underwritten-plan-statistic-amount-budget-plan").val(f2Fixed(total));
}
/**
@ -469,13 +469,13 @@ function updateEachRepaymentPlan() {
total += repaymentPlan;
$(this).val(repaymentPlan);
$(this).val(f2Fixed(repaymentPlan));
});
//总回款计划=所有月累加
$(".input-total-repayment-plan-budget-plan").val(f2(total));
$(".input-total-title-repayment-plan-budget-plan").val(f2(total));
$(".input-total-repayment-plan-budget-plan").val(f2Fixed(total));
$(".input-total-title-repayment-plan-budget-plan").val(f2Fixed(total));
}
/**
@ -528,15 +528,15 @@ function updateEachCapitalInterest() {
var capitalInterest = f2((underwrittenPlan-repaymentPlan)*underwrittenPlanTaxRate/100/12);
total += capitalInterest;
$(this).val(capitalInterest);
$(this).val(f2Fixed(capitalInterest));
});
//总资金利息=所有月累加
$(".input-total-capital-interest-budget-plan").val(f2(total));
$(".input-total-title-capital-interest-budget-plan").val(f2(total));
$(".input-total-capital-interest-budget-plan").val(f2Fixed(total));
$(".input-total-title-capital-interest-budget-plan").val(f2Fixed(total));
//下方小表的资金利息
$(".input-underwritten-plan-statistic-capital-interest-budget-plan").val(f2(total));
$(".input-underwritten-plan-statistic-capital-interest-budget-plan").val(f2Fixed(total));
}
/**
@ -659,16 +659,16 @@ function updateCashFlow() {
d,f,g,m,m);*/
$("input[name='saleIncomeCash']").val(saleIncome);
$("input[name='earnestMoneyIncome']").val(earnestMoneyIncome);
$("input[name='purchaseCost']").val(d);
$("input[name='earnestMoneyCost']").val(f);
$("input[name='saleIncomeCash']").val(f2Fixed(saleIncome));
$("input[name='earnestMoneyIncome']").val(f2Fixed(earnestMoneyIncome));
$("input[name='purchaseCost']").val(f2Fixed(d));
$("input[name='earnestMoneyCost']").val(f2Fixed(f));
$("input[name='netCashFlow']").val(g);
$("input[name='netCashFlow']").val(f2Fixed(g));
$("input[name='financingCapitalInflow']").val(underwrittenPlan);
$("input[name='financingCapitalOutflow']").val(repaymentPlan);
$("input[name='financingCapitalInflow']").val(f2Fixed(underwrittenPlan));
$("input[name='financingCapitalOutflow']").val(f2Fixed(repaymentPlan));
$("input[name='financingCapitalCashflow']").val(m);
$("input[name='netIncreaseMonetaryFunds']").val(n);
$("input[name='financingCapitalCashflow']").val(f2Fixed(m));
$("input[name='netIncreaseMonetaryFunds']").val(f2Fixed(n));
}

View File

@ -27,6 +27,15 @@ function f2(x) {
return Math.round(x*100)/100;
}
/**
* 给定一个数字保留两位小数输出
* @param f
* @returns {string}
*/
function f2Fixed(f) {
return Number(f).toFixed(2);
}
/**
* 计算利润率
@ -154,7 +163,7 @@ function calCostInclude() {
var $costTotalTaxInclude = $("input[name='costTotalTaxInclude']");
$costTotalTaxInclude.val(f2(f2(costPurchaseDeviceTaxInclude) +f2(costPurchaseBuildTaxInclude)
$costTotalTaxInclude.val(f2Fixed(f2(costPurchaseDeviceTaxInclude) +f2(costPurchaseBuildTaxInclude)
+f2(costPurchaseServiceTaxInclude)+f2(costPurchaseOtherTaxInclude)
+f2(costProjectManageTaxInclude)+f2(costOtherOtherTaxInclude)));
}
@ -172,7 +181,7 @@ function calCostExclude() {
var $costTotalTaxExclude = $("input[name='costTotalTaxExclude']");
$costTotalTaxExclude.val(f2(f2(costPurchaseDeviceTaxExclude)+f2(costPurchaseBuildTaxExclude)
$costTotalTaxExclude.val(f2Fixed(f2(costPurchaseDeviceTaxExclude)+f2(costPurchaseBuildTaxExclude)
+f2(costPurchaseServiceTaxExclude)+f2(costPurchaseOtherTaxExclude)
+f2(costProjectManageTaxExclude)+f2(costOtherOtherTaxExclude)));
}

View File

@ -102,7 +102,7 @@ function calIncomeInclude() {
var $incomeTotalTaxInclude = $("input[name='incomeTotalTaxInclude']");
$incomeTotalTaxInclude.val(f2(f2(incomeDeviceTaxInclude)+f2(incomeEngineerTaxInclude)+f2(incomeServiceTaxInclude)));
$incomeTotalTaxInclude.val(f2Fixed(f2(incomeDeviceTaxInclude)+f2(incomeEngineerTaxInclude)+f2(incomeServiceTaxInclude)));
}
/**
* 统计收入(不含税)有一项没填就置空
@ -114,7 +114,7 @@ function calIncomeExclude() {
var $incomeTotalTaxExclude = $("input[name='incomeTotalTaxExclude']");
$incomeTotalTaxExclude.val(f2(f2(incomeDeviceTaxExclude)+f2(incomeEngineerTaxExclude)+f2(incomeServiceTaxExclude)));
$incomeTotalTaxExclude.val(f2Fixed(f2(incomeDeviceTaxExclude)+f2(incomeEngineerTaxExclude)+f2(incomeServiceTaxExclude)));
}
/**
@ -133,16 +133,16 @@ function calIncomeCost() {
var incomeTotalTaxExcludeValue = f2(incomeTotalTaxExclude);
if (incomeTotalTaxExcludeValue != 0) {
$projectGrossProfit.val(f2(f2(incomeTotalTaxExclude) - f2(costTotalTaxExclude) - f2(costExpropriationTaxExclude)));
$projectGrossProfitRate.val(f2(f2($projectGrossProfit.val()) * 100 / incomeTotalTaxExcludeValue));
$projectGrossProfit.val(f2Fixed(f2(incomeTotalTaxExclude) - f2(costTotalTaxExclude) - f2(costExpropriationTaxExclude)));
$projectGrossProfitRate.val(f2Fixed(f2($projectGrossProfit.val()) * 100 / incomeTotalTaxExcludeValue));
} else {
$projectGrossProfit.val("");
$projectGrossProfitRate.val("");
}
if ($projectGrossProfit.val()) {
$projectContributionProfit.val(f2(f2($projectGrossProfit.val()) - f2(costCompanyManageTaxExclude)));
$projectContributionProfitRate.val(f2(f2($projectContributionProfit.val()) * 100 / f2(incomeTotalTaxExclude)))
$projectContributionProfit.val(f2(f2Fixed($projectGrossProfit.val()) - f2(costCompanyManageTaxExclude)));
$projectContributionProfitRate.val(f2Fixed(f2($projectContributionProfit.val()) * 100 / f2(incomeTotalTaxExclude)))
} else {
$projectContributionProfit.val("");
$projectContributionProfitRate.val("");