余额的计算

master
xxssyyyyssxx 2021-11-04 17:17:40 +08:00
parent f5c1a994fe
commit b821b9f0e0
1 changed files with 38 additions and 3 deletions

View File

@ -62,13 +62,13 @@ function bindBudgetPlanDeleteBtn() {
updateBudgetPlanTotal("input-changeable-sale-income-budget-plan","input-total-sale-income-budget-plan");
updateBudgetPlanTotal("input-changeable-earnest-money-income-budget-plan","input-total-earnest-money-income-budget-plan");
updateBudgetPlanTotal("input-changeable-total-income-budget-plan","input-total-total-income-budget-plan");
/*updateBudgetPlanTotal("input-changeable-fund-balance-budget-plan","input-total-fund-balance-budget-plan");*/
updateBudgetPlanTotal("input-changeable-capital-interest-budget-plan","input-total-capital-interest-budget-plan");
updateBudgetPlanTotal("input-changeable-underwritten-plan-budget-plan","input-total-underwritten-plan-budget-plan");
updateBudgetPlanTotal("input-changeable-repayment-plan-budget-plan","input-total-repayment-plan-budget-plan");
/*updateBudgetPlanTotal("input-changeable-fund-balance-budget-plan","input-total-fund-balance-budget-plan");*/
//每个月的余额=本月收入-支出+上月余额
//更新余额
updateEachFundBanlance();
});
}
@ -89,6 +89,8 @@ function bindChangeableInputBudgetPlanDetail() {
updateBudgetPlanTotal("input-changeable-device-cost-budget-plan","input-total-device-cost-budget-plan");
//更新所有月支出总额
updateBudgetPlanTotal("input-changeable-total-cost-budget-plan","input-total-total-cost-budget-plan");
//更新余额
updateEachFundBanlance();
});
//工程支出改变
$(".input-changeable-engineer-cost-budget-plan").change(function () {
@ -105,6 +107,8 @@ function bindChangeableInputBudgetPlanDetail() {
updateBudgetPlanTotal("input-changeable-engineer-cost-budget-plan","input-total-engineer-cost-budget-plan");
//更新所有月支出总额
updateBudgetPlanTotal("input-changeable-total-cost-budget-plan","input-total-total-cost-budget-plan");
//更新余额
updateEachFundBanlance();
});
//经营性支出改变
$(".input-changeable-project-manage-cost-budget-plan").change(function () {
@ -121,6 +125,8 @@ function bindChangeableInputBudgetPlanDetail() {
updateBudgetPlanTotal("input-changeable-project-manage-cost-budget-plan","input-total-project-manage-cost-budget-plan");
//更新所有月支出总额
updateBudgetPlanTotal("input-changeable-total-cost-budget-plan","input-total-total-cost-budget-plan");
//更新余额
updateEachFundBanlance();
});
//保证金改变
$(".input-changeable-earnest-money-cost-budget-plan").change(function () {
@ -137,6 +143,8 @@ function bindChangeableInputBudgetPlanDetail() {
updateBudgetPlanTotal("input-changeable-earnest-money-cost-budget-plan","input-total-earnest-money-cost-budget-plan");
//更新所有月支出总额
updateBudgetPlanTotal("input-changeable-total-cost-budget-plan","input-total-total-cost-budget-plan");
//更新余额
updateEachFundBanlance();
});
//销售收款改变
@ -152,6 +160,8 @@ function bindChangeableInputBudgetPlanDetail() {
updateBudgetPlanTotal("input-changeable-sale-income-budget-plan","input-total-sale-income-budget-plan");
//更新所有月收入总额
updateBudgetPlanTotal("input-changeable-total-income-budget-plan","input-total-total-income-budget-plan");
//更新余额
updateEachFundBanlance();
});
//保证金收款改变
$(".input-changeable-earnest-money-income-budget-plan").change(function () {
@ -166,6 +176,8 @@ function bindChangeableInputBudgetPlanDetail() {
updateBudgetPlanTotal("input-changeable-earnest-money-income-budget-plan","input-total-earnest-money-income-budget-plan");
//更新所有月收入总额
updateBudgetPlanTotal("input-changeable-total-income-budget-plan","input-total-total-income-budget-plan");
//更新余额
updateEachFundBanlance();
});
@ -200,7 +212,30 @@ function updateBudgetPlanTotal(className, totalClassName) {
$("."+totalClassName).val(total);
}
/**
* 更新每一行即每个月的资金余额
* 每个月的余额=本月收入-支出+上月余额
*/
function updateEachFundBanlance() {
var fundBalance = 0;
//找到每个月的资金余额输入框
$(".input-changeable-fund-balance-budget-plan").each(function (t) {
//找到当前月的收入和支出
var income = parseFloat($(this).parent().parent().find(".input-changeable-total-income-budget-plan").val());
var cost = parseFloat($(this).parent().parent().find(".input-changeable-total-cost-budget-plan").val());
//我的上月余额
var prevFundBalance = parseFloat($(this).parent().parent().prev("tr").find(".input-changeable-fund-balance-budget-plan").val());
if(!prevFundBalance){
//第一个月的话上月余额就为0
prevFundBalance = 0;
}
fundBalance = income - cost + prevFundBalance;
$(this).val(fundBalance);
});
//总余额=最后一个月的余额
$(".input-total-fund-balance-budget-plan").val(fundBalance);
}
/**