function calIncomeAndCost() { $("input[name='contractAmount']").change(function () { digitalSelf("contractAmount", "input[name='contractAmount']"); }); $("input[name='huazhiProductAmount']").change(function () { digitalSelf("huazhiProductAmount", "input[name='huazhiProductAmount']"); }); $("input[name='ziguangOtherAmount']").change(function () { digitalSelf("ziguangOtherAmount", "input[name='ziguangOtherAmount']"); }); $("input[name='incomeDeviceTaxInclude']").change(function () { calIncomeInclude(); calIncomeCost(); calIncomeDeviceTaxExclude(); digitalSelf("incomeDeviceTaxInclude", "input[name='incomeDeviceTaxInclude']"); }); $("input[name='incomeEngineerTaxInclude']").change(function () { calIncomeInclude(); calIncomeCost(); calIncomeEngineerTaxExclude(); digitalSelf("incomeEngineerTaxInclude", "input[name='incomeEngineerTaxInclude']"); }); $("input[name='incomeServiceTaxInclude']").change(function () { calIncomeInclude(); calIncomeCost(); calIncomeServiceTaxExclude(); digitalSelf("incomeServiceTaxInclude", "input[name='incomeServiceTaxInclude']"); }); $("input[name='incomeDeviceTaxExclude']").change(function () { calIncomeExclude(); calIncomeCost(); digitalSelf("incomeDeviceTaxExclude", "input[name='incomeDeviceTaxExclude']"); }); $("input[name='incomeEngineerTaxExclude']").change(function () { calIncomeExclude(); calIncomeCost(); digitalSelf("incomeEngineerTaxExclude", "input[name='incomeEngineerTaxExclude']"); }); $("input[name='incomeServiceTaxExclude']").change(function () { calIncomeExclude(); calIncomeCost(); digitalSelf("incomeServiceTaxExclude", "input[name='incomeServiceTaxExclude']"); }); $("input[name='costPurchaseDeviceTaxInclude']").change(function () { calCostInclude(); calIncomeCost(); calCostPurchaseDeviceTaxInclude(); digitalSelf("costPurchaseDeviceTaxInclude", "input[name='costPurchaseDeviceTaxInclude']"); }); $("input[name='costPurchaseBuildTaxInclude']").change(function () { calCostInclude(); calIncomeCost(); calCostPurchaseBuildTaxInclude(); digitalSelf("costPurchaseBuildTaxInclude", "input[name='costPurchaseBuildTaxInclude']"); }); $("input[name='costPurchaseServiceTaxInclude']").change(function () { calCostInclude(); calIncomeCost(); calCostPurchaseServiceTaxInclude(); digitalSelf("costPurchaseServiceTaxInclude", "input[name='costPurchaseServiceTaxInclude']"); }); $("input[name='costPurchaseOtherTaxInclude']").change(function () { calCostInclude(); calIncomeCost(); calCostPurchaseOtherTaxInclude(); digitalSelf("costPurchaseOtherTaxInclude", "input[name='costPurchaseOtherTaxInclude']"); }); /*$("input[name='costProjectManageTaxInclude']").change(function () { calCostInclude(); calIncomeCost(); });*/ $("input[name='costOtherOtherTaxInclude']").change(function () { calCostInclude(); calIncomeCost(); calCostOtherOtherTaxInclude(); digitalSelf("costOtherOtherTaxInclude", "input[name='costOtherOtherTaxInclude']"); }); $("input[name='costPurchaseDeviceTaxExclude']").change(function () { calCostExclude(); calIncomeCost(); digitalSelf("costPurchaseDeviceTaxExclude", "input[name='costPurchaseDeviceTaxExclude']"); }); $("input[name='costPurchaseBuildTaxExclude']").change(function () { calCostExclude(); calIncomeCost(); digitalSelf("costPurchaseBuildTaxExclude", "input[name='costPurchaseBuildTaxExclude']"); }); $("input[name='costPurchaseServiceTaxExclude']").change(function () { calCostExclude(); calIncomeCost(); digitalSelf("costPurchaseServiceTaxExclude", "input[name='costPurchaseServiceTaxExclude']"); }); $("input[name='costPurchaseOtherTaxExclude']").change(function () { calCostExclude(); calIncomeCost(); digitalSelf("costPurchaseOtherTaxExclude", "input[name='costPurchaseOtherTaxExclude']"); }); $("input[name='costProjectManageTaxExclude']").change(function () { calCostExclude(); //不含税的=含税的 //含税的总额更新 $("input[name='costProjectManageTaxInclude']").val($("input[name='costProjectManageTaxExclude']").val()); calCostInclude(); calIncomeCost(); digitalSelf("costProjectManageTaxExclude", "input[name='costProjectManageTaxExclude']"); digitalSelf("costProjectManageTaxInclude", "input[name='costProjectManageTaxInclude']"); }); $("input[name='costOtherOtherTaxExclude']").change(function () { calCostExclude(); calIncomeCost(); digitalSelf("costOtherOtherTaxExclude", "input[name='costOtherOtherTaxExclude']"); }); $("input[name='costExpropriationTaxExclude']").change(function () { calIncomeCost(); digitalSelf("costExpropriationTaxExclude", "input[name='costExpropriationTaxExclude']"); }); $("input[name='costCompanyManageTaxExclude']").change(function () { calIncomeCost(); digitalSelf("costCompanyManageTaxExclude", "input[name='costCompanyManageTaxExclude']"); }); //设备类收入 $("select[name='incomeDeviceSelect']").change(function () { let val = $('#incomeDeviceSelect option:selected').val(); var $incomeDeviceTaxExclude = $("input[name='incomeDeviceTaxExclude']"); if(val == "自定义"){ $("input[name='incomeDeviceTaxExclude']").attr('readonly',false); $("input[name='incomeDeviceTaxExclude']").attr("required",true); }else if(val == "请选择税率"){ $("input[name='incomeDeviceTaxExclude']").attr('readonly',true); $incomeDeviceTaxExclude.val(""); } else { $("input[name='incomeDeviceTaxExclude']").attr('readonly',true); var incomeDeviceTaxInclude = inputVal("incomeDeviceTaxInclude"); $incomeDeviceTaxExclude.val(f2Fixed(f2(incomeDeviceTaxInclude)/(1+Number(val)))); } calIncomeExclude(); calIncomeCost(); }); function calIncomeDeviceTaxExclude(){ let val = $('#incomeDeviceSelect option:selected').val(); var $incomeDeviceTaxExclude = $("input[name='incomeDeviceTaxExclude']"); var incomeDeviceTaxInclude = inputVal("incomeDeviceTaxInclude"); if(val == "自定义"){ return; }else if(val == "请选择税率"){ return; } else { $incomeDeviceTaxExclude.val(f2Fixed(f2(incomeDeviceTaxInclude)/(1+Number(val)))); } calIncomeExclude(); calIncomeCost(); } //工程类收入 $("select[name='incomeEngineerSelect']").change(function () { let val = $('#incomeEngineerSelect option:selected').val(); var $incomeEngineerTaxExclude = $("input[name='incomeEngineerTaxExclude']"); if(val == "自定义"){ $("input[name='incomeEngineerTaxExclude']").attr('readonly',false) $("input[name='incomeEngineerTaxExclude']").attr("required",true); }else if(val == "请选择税率"){ $("input[name='incomeEngineerTaxExclude']").attr('readonly',true); $incomeEngineerTaxExclude.val(""); } else { $("input[name='incomeEngineerTaxExclude']").attr('readonly',true); var incomeEngineerTaxInclude = inputVal("incomeEngineerTaxInclude"); $incomeEngineerTaxExclude.val(f2Fixed(f2(incomeEngineerTaxInclude)/(1+Number(val)))); } calIncomeExclude(); calIncomeCost(); }); function calIncomeEngineerTaxExclude(){ let val = $('#incomeEngineerSelect option:selected').val(); var $incomeEngineerTaxExclude = $("input[name='incomeEngineerTaxExclude']"); if(val == "自定义"){ return; }else if(val == "请选择税率"){ return; } else { var incomeEngineerTaxInclude = inputVal("incomeEngineerTaxInclude"); $incomeEngineerTaxExclude.val(f2Fixed(f2(incomeEngineerTaxInclude)/(1+Number(val)))); } calIncomeExclude(); calIncomeCost(); } //服务类收入 $("select[name='incomeServiceSelect']").change(function () { let val = $('#incomeServiceSelect option:selected').val(); var $incomeServiceTaxExclude = $("input[name='incomeServiceTaxExclude']"); if(val == "自定义"){ $("input[name='incomeServiceTaxExclude']").attr('readonly',false); $("input[name='incomeServiceTaxExclude']").attr("required",true); }else if(val == "请选择税率"){ $("input[name='incomeServiceTaxExclude']").attr('readonly',true); $incomeServiceTaxExclude.val(""); } else { $("input[name='incomeServiceTaxExclude']").attr('readonly',true); var incomeServiceTaxInclude = inputVal("incomeServiceTaxInclude"); $incomeServiceTaxExclude.val(f2Fixed(f2(incomeServiceTaxInclude)/(1+Number(val)))); } calIncomeExclude(); calIncomeCost(); }); function calIncomeServiceTaxExclude(){ let val = $('#incomeServiceSelect option:selected').val(); var $incomeServiceTaxExclude = $("input[name='incomeServiceTaxExclude']"); if(val == "自定义"){ return; }else if(val == "请选择税率"){ return; } else { var incomeServiceTaxInclude = inputVal("incomeServiceTaxInclude"); $incomeServiceTaxExclude.val(f2Fixed(f2(incomeServiceTaxInclude)/(1+Number(val)))); } calIncomeExclude(); calIncomeCost(); } //设备类采购成本 $("select[name='costPurchaseDeviceSelect']").change(function () { let val = $('#costPurchaseDeviceSelect option:selected').val(); var $costPurchaseDeviceTaxExclude = $("input[name='costPurchaseDeviceTaxExclude']"); if(val == "自定义"){ $("input[name='costPurchaseDeviceTaxExclude']").attr('readonly',false) $("input[name='costPurchaseDeviceTaxExclude']").attr("required",true); }else if(val == "请选择税率"){ $("input[name='costPurchaseDeviceTaxExclude']").attr('readonly',true); $costPurchaseDeviceTaxExclude.val(""); } else { $("input[name='costPurchaseDeviceTaxExclude']").attr('readonly',true); var costPurchaseDeviceTaxInclude = inputVal("costPurchaseDeviceTaxInclude"); $costPurchaseDeviceTaxExclude.val(f2Fixed(f2(costPurchaseDeviceTaxInclude)/(1+Number(val)))); } calCostExclude(); calIncomeCost(); }); function calCostPurchaseDeviceTaxInclude(){ let val = $('#costPurchaseDeviceSelect option:selected').val(); var $costPurchaseDeviceTaxExclude = $("input[name='costPurchaseDeviceTaxExclude']"); if(val == "自定义"){ return; }else if(val == "请选择税率"){ return; } else { var costPurchaseDeviceTaxInclude = inputVal("costPurchaseDeviceTaxInclude"); $costPurchaseDeviceTaxExclude.val(f2Fixed(f2(costPurchaseDeviceTaxInclude)/(1+Number(val)))); } calCostExclude(); calIncomeCost(); } //施工类采购成本 $("select[name='costPurchaseBuildSelect']").change(function () { let val = $('#costPurchaseBuildSelect option:selected').val(); var $costPurchaseBuildTaxExclude = $("input[name='costPurchaseBuildTaxExclude']"); if(val == "自定义"){ $("input[name='costPurchaseBuildTaxExclude']").attr('readonly',false) $("input[name='costPurchaseBuildTaxExclude']").attr("required",true); }else if(val == "请选择税率"){ $("input[name='costPurchaseBuildTaxExclude']").attr('readonly',true); $costPurchaseBuildTaxExclude.val(""); } else { $("input[name='costPurchaseBuildTaxExclude']").attr('readonly',true); var costPurchaseBuildTaxInclude = inputVal("costPurchaseBuildTaxInclude"); $costPurchaseBuildTaxExclude.val(f2Fixed(f2(costPurchaseBuildTaxInclude)/(1+Number(val)))); } calCostExclude(); calIncomeCost(); }); function calCostPurchaseBuildTaxInclude(){ let val = $('#costPurchaseBuildSelect option:selected').val(); var $costPurchaseBuildTaxExclude = $("input[name='costPurchaseBuildTaxExclude']"); if(val == "自定义"){ return; }else if(val == "请选择税率"){ return; } else { var costPurchaseBuildTaxInclude = inputVal("costPurchaseBuildTaxInclude"); $costPurchaseBuildTaxExclude.val(f2Fixed(f2(costPurchaseBuildTaxInclude)/(1+Number(val)))); } calCostExclude(); calIncomeCost(); } //服务类采购成本 $("select[name='costPurchaseServiceSelect']").change(function () { let val = $('#costPurchaseServiceSelect option:selected').val(); var $costPurchaseServiceTaxExclude = $("input[name='costPurchaseServiceTaxExclude']"); if(val == "自定义"){ $("input[name='costPurchaseServiceTaxExclude']").attr('readonly',false) $("input[name='costPurchaseServiceTaxExclude']").attr("required",true); }else if(val == "请选择税率"){ $("input[name='costPurchaseServiceTaxExclude']").attr('readonly',true); $costPurchaseServiceTaxExclude.val(""); } else { $("input[name='costPurchaseServiceTaxExclude']").attr('readonly',true); var costPurchaseServiceTaxInclude = inputVal("costPurchaseServiceTaxInclude"); $costPurchaseServiceTaxExclude.val(f2Fixed(f2(costPurchaseServiceTaxInclude)/(1+Number(val)))); } calCostExclude(); calIncomeCost(); }); function calCostPurchaseServiceTaxInclude(){ let val = $('#costPurchaseServiceSelect option:selected').val(); var $costPurchaseServiceTaxExclude = $("input[name='costPurchaseServiceTaxExclude']"); if(val == "自定义"){ return; }else if(val == "请选择税率"){ return; } else { var costPurchaseServiceTaxInclude = inputVal("costPurchaseServiceTaxInclude"); $costPurchaseServiceTaxExclude.val(f2Fixed(f2(costPurchaseServiceTaxInclude)/(1+Number(val)))); } calCostExclude(); calIncomeCost(); } //其他类采购成本 $("select[name='costOtherOtherSelect']").change(function () { let val = $('#costOtherOtherSelect option:selected').val(); var $costOtherOtherTaxExclude = $("input[name='costOtherOtherTaxExclude']"); if(val == "自定义"){ $("input[name='costOtherOtherTaxExclude']").attr('readonly',false) $("input[name='costOtherOtherTaxExclude']").attr("required",true); }else if(val == "请选择税率"){ $("input[name='costOtherOtherTaxExclude']").attr('readonly',true); $costOtherOtherTaxExclude.val(""); } else { $("input[name='costOtherOtherTaxExclude']").attr('readonly',true); var costOtherOtherTaxInclude = inputVal("costOtherOtherTaxInclude"); $costOtherOtherTaxExclude.val(f2Fixed(f2(costOtherOtherTaxInclude)/(1+Number(val)))); } calCostExclude(); calIncomeCost(); }); function calCostOtherOtherTaxInclude(){ let val = $('#costOtherOtherSelect option:selected').val(); var $costOtherOtherTaxExclude = $("input[name='costOtherOtherTaxExclude']"); if(val == "自定义"){ return; }else if(val == "请选择税率"){ return; } else { var costOtherOtherTaxInclude = inputVal("costOtherOtherTaxInclude"); $costOtherOtherTaxExclude.val(f2Fixed(f2(costOtherOtherTaxInclude)/(1+Number(val)))); } calCostExclude(); calIncomeCost(); } //其他成本 $("select[name='costPurchaseOtherSelect']").change(function () { let val = $('#costPurchaseOtherSelect option:selected').val(); var $costPurchaseOtherTaxExclude = $("input[name='costPurchaseOtherTaxExclude']"); if(val == "自定义"){ $("input[name='costPurchaseOtherTaxExclude']").attr('readonly',false) $("input[name='costPurchaseOtherTaxExclude']").attr("required",true); }else if(val == "请选择税率"){ $("input[name='costPurchaseOtherTaxExclude']").attr('readonly',true); $costPurchaseOtherTaxExclude.val(""); } else { $("input[name='costPurchaseOtherTaxExclude']").attr('readonly',true); var costPurchaseOtherTaxInclude = inputVal("costPurchaseOtherTaxInclude"); $costPurchaseOtherTaxExclude.val(f2Fixed(f2(costPurchaseOtherTaxInclude)/(1+Number(val)))); } calCostExclude(); calIncomeCost(); }); function calCostPurchaseOtherTaxInclude(){ let val = $('#costPurchaseOtherSelect option:selected').val(); var $costPurchaseOtherTaxExclude = $("input[name='costPurchaseOtherTaxExclude']"); if(val == "自定义"){ return; }else if(val == "请选择税率"){ return; } else { var costPurchaseOtherTaxInclude = inputVal("costPurchaseOtherTaxInclude"); $costPurchaseOtherTaxExclude.val(f2Fixed(f2(costPurchaseOtherTaxInclude)/(1+Number(val)))); } calCostExclude(); calIncomeCost(); } } /** * 统计收入(含税),有一项没填就置空 */ function calIncomeInclude() { var incomeDeviceTaxInclude = inputVal("incomeDeviceTaxInclude"); var incomeEngineerTaxInclude = inputVal("incomeEngineerTaxInclude"); var incomeServiceTaxInclude = inputVal("incomeServiceTaxInclude"); var $incomeTotalTaxInclude = $("input[name='incomeTotalTaxInclude']"); $incomeTotalTaxInclude.val(f2Fixed(f2(incomeDeviceTaxInclude)+f2(incomeEngineerTaxInclude)+f2(incomeServiceTaxInclude))); } /** * 统计收入(不含税),有一项没填就置空 */ function calIncomeExclude() { var incomeDeviceTaxExclude = inputVal("incomeDeviceTaxExclude"); var incomeEngineerTaxExclude = inputVal("incomeEngineerTaxExclude"); var incomeServiceTaxExclude = inputVal("incomeServiceTaxExclude"); var $incomeTotalTaxExclude = $("input[name='incomeTotalTaxExclude']"); $incomeTotalTaxExclude.val(f2Fixed(f2(incomeDeviceTaxExclude)+f2(incomeEngineerTaxExclude)+f2(incomeServiceTaxExclude))); } /** * 计算毛利、毛利率、贡献、贡献率 */ function calIncomeCost() { var incomeTotalTaxExclude = inputVal("incomeTotalTaxExclude"); var costTotalTaxExclude = inputVal("costTotalTaxExclude"); var costExpropriationTaxExclude = inputVal("costExpropriationTaxExclude"); var costCompanyManageTaxExclude = inputVal("costCompanyManageTaxExclude"); var $projectGrossProfit = $("input[name='projectGrossProfit']"); var $projectGrossProfitRate = $("input[name='projectGrossProfitRate']"); var $projectContributionProfit = $("input[name='projectContributionProfit']"); var $projectContributionProfitRate = $("input[name='projectContributionProfitRate']"); var incomeTotalTaxExcludeValue = f2(incomeTotalTaxExclude); if (incomeTotalTaxExcludeValue != 0) { $projectGrossProfit.val(f2Fixed(f2(incomeTotalTaxExclude) - f2(costTotalTaxExclude) - f2(costExpropriationTaxExclude))); $projectGrossProfitRate.val(f2Fixed(f2($projectGrossProfit.val()) * 100 / incomeTotalTaxExcludeValue)); } else { $projectGrossProfit.val("0.00"); $projectGrossProfitRate.val("0.00"); } if ($projectGrossProfit.val()) { $projectContributionProfit.val(f2Fixed(f2($projectGrossProfit.val()) - f2(costCompanyManageTaxExclude))); $projectContributionProfitRate.val(f2Fixed(f2($projectContributionProfit.val()) * 100 / f2(incomeTotalTaxExclude))) } else { $projectContributionProfit.val("0.00"); $projectContributionProfitRate.val("0.00"); } }