更新资金计划下面的小表的统计数字

master
xxssyyyyssxx 2021-11-05 12:19:01 +08:00
parent 0e98b14671
commit 9cff2184bd
11 changed files with 295 additions and 9 deletions

View File

@ -0,0 +1,34 @@
package cn.palmte.work.bean;
import java.math.BigDecimal;
/**
*
* @author xiongshiyan at 2021/11/5 , contact me with email yanshixiong@126.com or phone 15208384257
*/
public class ProjectConfigBean {
/**
*
*/
private BigDecimal underwrittenTaxRate;
/**
*
*/
private BigDecimal projectContributionProfitRateThreshold;
public BigDecimal getUnderwrittenTaxRate() {
return underwrittenTaxRate;
}
public void setUnderwrittenTaxRate(BigDecimal underwrittenTaxRate) {
this.underwrittenTaxRate = underwrittenTaxRate;
}
public BigDecimal getProjectContributionProfitRateThreshold() {
return projectContributionProfitRateThreshold;
}
public void setProjectContributionProfitRateThreshold(BigDecimal projectContributionProfitRateThreshold) {
this.projectContributionProfitRateThreshold = projectContributionProfitRateThreshold;
}
}

View File

@ -0,0 +1,46 @@
package cn.palmte.work.bean;
import java.math.BigDecimal;
/**
*
* @author xiongshiyan at 2021/11/5 , contact me with email yanshixiong@126.com or phone 15208384257
*/
public class ProjectUnderwrittenPlanStatisticBean {
/**
*
*/
private String maxMonth;
/**
*
*/
private BigDecimal amount;
/**
*
*/
private BigDecimal capitalInterest;
public String getMaxMonth() {
return maxMonth;
}
public void setMaxMonth(String maxMonth) {
this.maxMonth = maxMonth;
}
public BigDecimal getAmount() {
return amount;
}
public void setAmount(BigDecimal amount) {
this.amount = amount;
}
public BigDecimal getCapitalInterest() {
return capitalInterest;
}
public void setCapitalInterest(BigDecimal capitalInterest) {
this.capitalInterest = capitalInterest;
}
}

View File

@ -8,6 +8,7 @@ import cn.palmte.work.model.*;
import cn.palmte.work.service.ProjectBudgetService;
import cn.palmte.work.service.ProjectEstimateService;
import cn.palmte.work.service.ProjectService;
import cn.palmte.work.utils.FreeMarkerUtil;
import cn.palmte.work.utils.InterfaceUtil;
import cn.palmte.work.utils.Utils;
import cn.palmte.work.utils.excel.ExportUtils;
@ -150,8 +151,12 @@ public class ProjectController extends BaseController{
List<ProjectBudgetPlanDetail> projectBudgetPlanDetails = projectBudgetService.getProjectBudgetPlanDetails(project);
//资金计划明细
model.put("projectBudgetPlanDetails", projectBudgetPlanDetails);
//资金计划总
model.put("projectBudgetPlanDetailTotal", projectBudgetService.getProjectBudgetPlanDetailTotal(projectBudgetPlanDetails));
//资金计划总【上面汇总表】
model.put("projectBudgetPlanDetailTotal", projectBudgetService.getProjectBudgetPlanDetailTotal(project, projectBudgetPlanDetails));
//资金计划表中的统计信息【下面资金小表】
model.put("underwrittenPlanStatistic", projectBudgetService.getProjectUnderwrittenPlanStatisticBean(projectBudgetPlanDetails));
//freemarker可以利用的静态方法
model.put("Utils", FreeMarkerUtil.fromStaticPackage("cn.palmte.work.utils.Utils"));
return "admin/project_budget_edit";
}

View File

@ -134,6 +134,16 @@ public class Project {
*/
@Column(name = "main_contract_collection_terms")
private String mainContractCollectionTerms;
/**
*
*/
@Column(name = "project_contribution_profit_rate_threshold")
private BigDecimal projectContributionProfitRateThreshold;
/**
*
*/
@Column(name = "underwritten_tax_rate")
private BigDecimal underwrittenTaxRate;
/**
*
*/
@ -389,6 +399,22 @@ public class Project {
this.mainContractCollectionTerms = mainContractCollectionTerms;
}
public BigDecimal getProjectContributionProfitRateThreshold() {
return projectContributionProfitRateThreshold;
}
public void setProjectContributionProfitRateThreshold(BigDecimal projectContributionProfitRateThreshold) {
this.projectContributionProfitRateThreshold = projectContributionProfitRateThreshold;
}
public BigDecimal getUnderwrittenTaxRate() {
return underwrittenTaxRate;
}
public void setUnderwrittenTaxRate(BigDecimal underwrittenTaxRate) {
this.underwrittenTaxRate = underwrittenTaxRate;
}
public Date getCreateTime() {
return createTime;
}

View File

@ -69,6 +69,11 @@ public class ProjectBudgetPlanDetail {
*/
@Column(name = "fund_balance")
private BigDecimal fundBalance;
/**
*
*/
@Column(name = "underwritten_tax_rate")
private BigDecimal underwrittenTaxRate;
/**
*
*/
@ -181,6 +186,14 @@ public class ProjectBudgetPlanDetail {
this.fundBalance = fundBalance;
}
public BigDecimal getUnderwrittenTaxRate() {
return underwrittenTaxRate;
}
public void setUnderwrittenTaxRate(BigDecimal underwrittenTaxRate) {
this.underwrittenTaxRate = underwrittenTaxRate;
}
public BigDecimal getCapitalInterest() {
return capitalInterest;
}

View File

@ -1,6 +1,8 @@
package cn.palmte.work.service;
import cn.palmte.work.bean.BudgetBean;
import cn.palmte.work.bean.ProjectConfigBean;
import cn.palmte.work.bean.ProjectUnderwrittenPlanStatisticBean;
import cn.palmte.work.model.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@ -346,6 +348,7 @@ public class ProjectBudgetService {
if(CollectionUtil.isNotEmpty(detailList)){
for (ProjectBudgetPlanDetail projectBudgetPlanDetail : detailList) {
projectBudgetPlanDetail.setProjectId(project.getId());
projectBudgetPlanDetail.setUnderwrittenTaxRate(project.getUnderwrittenTaxRate());
}
projectBudgetPlanDetailRepository.save(detailList);
}
@ -361,7 +364,7 @@ public class ProjectBudgetService {
/**
*
*/
public ProjectBudgetPlanDetail getProjectBudgetPlanDetailTotal(List<ProjectBudgetPlanDetail> projectBudgetPlanDetails) {
public ProjectBudgetPlanDetail getProjectBudgetPlanDetailTotal(Project project, List<ProjectBudgetPlanDetail> projectBudgetPlanDetails) {
ProjectBudgetPlanDetail projectBudgetPlanDetail = new ProjectBudgetPlanDetail();
BigDecimal deviceCost = new BigDecimal(0);
BigDecimal engineerCost = new BigDecimal(0);
@ -375,6 +378,7 @@ public class ProjectBudgetService {
BigDecimal capitalInterest = new BigDecimal(0);
BigDecimal underwrittenPlan = new BigDecimal(0);
BigDecimal repaymentPlan = new BigDecimal(0);
/*BigDecimal underwrittenTaxRate = project.getUnderwrittenTaxRate();*/
if(CollectionUtil.isNotEmpty(projectBudgetPlanDetails)){
for (ProjectBudgetPlanDetail budgetPlan : projectBudgetPlanDetails) {
@ -407,9 +411,51 @@ public class ProjectBudgetService {
projectBudgetPlanDetail.setEarnestMoneyIncome(earnestMoneyIncome);
projectBudgetPlanDetail.setTotalIncome(totalIncome);
projectBudgetPlanDetail.setFundBalance(fundBalance);
/*projectBudgetPlanDetail.setUnderwrittenTaxRate(underwrittenTaxRate);*/
projectBudgetPlanDetail.setCapitalInterest(capitalInterest);
projectBudgetPlanDetail.setUnderwrittenPlan(underwrittenPlan);
projectBudgetPlanDetail.setRepaymentPlan(repaymentPlan);
return projectBudgetPlanDetail;
}
public ProjectConfigBean getProjectConfigBeanConfig(){
//TODO 从数据库配置中来
ProjectConfigBean projectConfigBean = new ProjectConfigBean();
projectConfigBean.setUnderwrittenTaxRate(new BigDecimal("5.66"));
projectConfigBean.setProjectContributionProfitRateThreshold(new BigDecimal("5"));
return projectConfigBean;
}
/**
* 使
*
*
*
*/
public ProjectUnderwrittenPlanStatisticBean getProjectUnderwrittenPlanStatisticBean(List<ProjectBudgetPlanDetail> projectBudgetPlanDetails){
ProjectUnderwrittenPlanStatisticBean bean = new ProjectUnderwrittenPlanStatisticBean();
if(CollectionUtil.isEmpty(projectBudgetPlanDetails)){
return bean;
}
BigDecimal amount = new BigDecimal(0);
BigDecimal capitalInterest = new BigDecimal(0);
BigDecimal max = new BigDecimal(0);
String maxMonth = "";
for (ProjectBudgetPlanDetail projectBudgetPlanDetail : projectBudgetPlanDetails) {
capitalInterest = capitalInterest.add(projectBudgetPlanDetail.getCapitalInterest());
BigDecimal underwrittenPlan = projectBudgetPlanDetail.getUnderwrittenPlan();
amount = amount.add(underwrittenPlan);
if(underwrittenPlan.compareTo(max)>0){
max = underwrittenPlan;
maxMonth = projectBudgetPlanDetail.getMonth();
}
}
bean.setMaxMonth(maxMonth);
bean.setAmount(amount);
bean.setCapitalInterest(capitalInterest);
return bean;
}
}

View File

@ -104,6 +104,11 @@ public class ProjectService {
p.setStatus(StatusEnum.CREATED.getStatus());
p.setStatusDesc(StatusEnum.CREATED.getStatusDesc());
p.setApproveStatusEstimate(approveStatusEnum.getApproveStatus());
ProjectConfigBean projectConfigBeanConfig = projectBudgetService.getProjectConfigBeanConfig();
project.setProjectContributionProfitRateThreshold(projectConfigBeanConfig.getProjectContributionProfitRateThreshold());
project.setUnderwrittenTaxRate(projectConfigBeanConfig.getUnderwrittenTaxRate());
p = projectRepository.saveAndFlush(p);
//清空重新保存概算信息
projectEstimateService.clearEstimate(p);
@ -118,6 +123,10 @@ public class ProjectService {
project.setCreatorId(admin.getId());
project.setCreatorName(admin.getUserName());
ProjectConfigBean projectConfigBeanConfig = projectBudgetService.getProjectConfigBeanConfig();
project.setProjectContributionProfitRateThreshold(projectConfigBeanConfig.getProjectContributionProfitRateThreshold());
project.setUnderwrittenTaxRate(projectConfigBeanConfig.getUnderwrittenTaxRate());
project.setApproveId(null);
project.setApproveName("");

View File

@ -0,0 +1,25 @@
package cn.palmte.work.utils;
import freemarker.ext.beans.BeansWrapper;
import freemarker.ext.beans.BeansWrapperBuilder;
import freemarker.template.TemplateHashModel;
import freemarker.template.Version;
/**
* @author xiongshiyan at 2021/11/5 , contact me with email yanshixiong@126.com or phone 15208384257
*/
public class FreeMarkerUtil {
public static TemplateHashModel fromStaticPackage(String packageName) {
try
{
BeansWrapperBuilder beansWrapperBuilder = new BeansWrapperBuilder(new Version(2,3,26));
//BeansWrapper wrapper = BeansWrapper.getDefaultInstance();
BeansWrapper wrapper = beansWrapperBuilder.build();
TemplateHashModel staticModels = wrapper.getStaticModels();
return (TemplateHashModel) staticModels.get(packageName);
}catch (Exception e) {
e.printStackTrace();
return null;
}
}
}

View File

@ -46,6 +46,23 @@ public class Utils {
return PHONE_PATTERN.matcher(str).matches();
}
/**
*
*
*/
public static String format(Number number, String defaultValue){
if (null == number) {
return defaultValue;
}else {
return new java.text.DecimalFormat("#0.##").format(number);
}
}
public static String format(Number number){
return format(number, "");
}
public static void main(String[] args) throws Exception {
AesCrypto aesCrypto = new AesCrypto("CDGXQHCJ-HHYC2021017");
String encoded = "fdKQaLHH1kt/pW3s4APoUA==";

View File

@ -25,7 +25,7 @@ $(function () {
*/
function appendTrBudgetPlan() {
var template = '<tr>\n' +
' <td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-budget-plan-detail"></td>\n' +
' <td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-budget-plan-detail input-changeable-month-budget-plan"></td>\n' +
' <td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-budget-plan-detail input-changeable-device-cost-budget-plan"></td>\n' +
' <td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-budget-plan-detail input-changeable-engineer-cost-budget-plan"></td>\n' +
' <td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-budget-plan-detail input-changeable-project-manage-cost-budget-plan"></td>\n' +
@ -75,6 +75,8 @@ function bindBudgetPlanDeleteBtn() {
updateEachRepaymentPlan();
//更新资金利息
updateEachCapitalInterest();
//更新垫资峰值月
updateUnderwrittenInfo();
});
}
@ -103,6 +105,8 @@ function bindChangeableInputBudgetPlanDetail() {
updateEachRepaymentPlan();
//更新资金利息
updateEachCapitalInterest();
//更新垫资峰值月
updateUnderwrittenInfo();
});
//工程支出改变
$(".input-changeable-engineer-cost-budget-plan").change(function () {
@ -127,6 +131,8 @@ function bindChangeableInputBudgetPlanDetail() {
updateEachRepaymentPlan();
//更新资金利息
updateEachCapitalInterest();
//更新垫资峰值月
updateUnderwrittenInfo();
});
//经营性支出改变
$(".input-changeable-project-manage-cost-budget-plan").change(function () {
@ -151,6 +157,8 @@ function bindChangeableInputBudgetPlanDetail() {
updateEachRepaymentPlan();
//更新资金利息
updateEachCapitalInterest();
//更新垫资峰值月
updateUnderwrittenInfo();
});
//保证金改变
$(".input-changeable-earnest-money-cost-budget-plan").change(function () {
@ -175,6 +183,8 @@ function bindChangeableInputBudgetPlanDetail() {
updateEachRepaymentPlan();
//更新资金利息
updateEachCapitalInterest();
//更新垫资峰值月
updateUnderwrittenInfo();
});
//销售收款改变
@ -198,6 +208,8 @@ function bindChangeableInputBudgetPlanDetail() {
updateEachRepaymentPlan();
//更新资金利息
updateEachCapitalInterest();
//更新垫资峰值月
updateUnderwrittenInfo();
});
//保证金收款改变
$(".input-changeable-earnest-money-income-budget-plan").change(function () {
@ -220,6 +232,8 @@ function bindChangeableInputBudgetPlanDetail() {
updateEachRepaymentPlan();
//更新资金利息
updateEachCapitalInterest();
//更新垫资峰值月
updateUnderwrittenInfo();
});
@ -306,6 +320,8 @@ function updateEachUnderwrittenPlan() {
//总垫资计划=所有月累加
$(".input-total-underwritten-plan-budget-plan").val(total);
//下放小表的垫资峰值金额
$(".input-underwritten-plan-statistic-amount-budget-plan").val(total);
}
/**
@ -405,12 +421,13 @@ function calRepaymentPlan(income, cost, prevFundBalance) {
* 更新每一行即每个月的资金利息
*/
function updateEachCapitalInterest() {
var underwrittenPlanTaxRate = parseFloat($(".input-underwritten-plan-statistic-tax-rate-budget-plan").val());
var total = 0;
//找到每个月的资金利息输入框
$(".input-changeable-capital-interest-budget-plan").each(function (t) {
//找到当前月的垫资计划
var underwrittenPlan = parseFloat($(this).parent().parent().find(".input-changeable-underwritten-plan-budget-plan").val());
var capitalInterest = underwrittenPlan*0.0566/12;
var capitalInterest = underwrittenPlan*underwrittenPlanTaxRate/100/12;
total += capitalInterest;
$(this).val(capitalInterest);
@ -419,6 +436,35 @@ function updateEachCapitalInterest() {
//总资金利息=所有月累加
$(".input-total-capital-interest-budget-plan").val(total);
//下方小表的资金利息
$(".input-underwritten-plan-statistic-capital-interest-budget-plan").val(total);
//主页面上的财务费用
$("input[name='costExpropriationTaxExclude']").val(total);
}
/**
* 更新资金相关信息
*
垫资峰值时间 垫资最大的那一个月
垫资峰值金额 垫资累计 @see updateEachUnderwrittenPlan
资金利息 垫资每月利息累加 @see updateEachCapitalInterest
*/
function updateUnderwrittenInfo() {
var max = 0;
var month = '';
//找到每个月的垫资计划输入框
$(".input-changeable-underwritten-plan-budget-plan").each(function (t) {
//找到当前月垫资计划
var underwrittenPlan = parseFloat($(this).val());
//当月比最大的还大,就取当月的
if(underwrittenPlan > max){
month = $(this).parent().parent().find(".input-changeable-month-budget-plan").val();
max = underwrittenPlan;
}
});
//垫资峰值时间为每个月最大的那个月
$(".input-underwritten-plan-statistic-max-month-budget-plan").val(month);
}

View File

@ -1,8 +1,8 @@
<#assign base=request.contextPath />
<#import "../common/defaultLayout.ftl" as defaultLayout>
<@defaultLayout.layout>
<style type="text/css">
/**让所有的模态对话框都居中*/
@ -306,7 +306,7 @@
<tr>
<td>财务费用</td>
<td>资金占用成本</td>
<td><input name="costExpropriationTaxExclude" value="${budgetBean.costExpropriationTaxExclude!20}" required readonly title="资金占用成本不含税总额"></td>
<td><input name="costExpropriationTaxExclude" value="${budgetBean.costExpropriationTaxExclude!0}" required readonly title="资金占用成本不含税总额"></td>
</tr>
<tr>
<td>公司管理费用</td>
@ -607,7 +607,7 @@
<td>操作</td>
</tr>
<tr>
<td><input type="text" class="am-modal-prompt-input" value="${projectBudgetPlanDetailTotal.month}" readonly/></td>
<td><input type="text" class="am-modal-prompt-input input-total-month-budget-plan" value="${projectBudgetPlanDetailTotal.month}" readonly/></td>
<td><input type="text" class="am-modal-prompt-input input-total-device-cost-budget-plan" value="${projectBudgetPlanDetailTotal.deviceCost}" readonly/></td>
<td><input type="text" class="am-modal-prompt-input input-total-engineer-cost-budget-plan" value="${projectBudgetPlanDetailTotal.engineerCost}" readonly/></td>
<td><input type="text" class="am-modal-prompt-input input-total-project-manage-cost-budget-plan" value="${projectBudgetPlanDetailTotal.projectManageCost}" readonly/></td>
@ -626,7 +626,7 @@
<#if projectBudgetPlanDetails??>
<#list projectBudgetPlanDetails as projectBudgetPlanDetail>
<tr>
<td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-budget-plan-detail" value="${projectBudgetPlanDetail.month!}"></td>
<td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-budget-plan-detail input-changeable-month-budget-plan" value="${projectBudgetPlanDetail.month!}"></td>
<td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-budget-plan-detail input-changeable-device-cost-budget-plan" value="${projectBudgetPlanDetail.deviceCost!}"></td>
<td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-budget-plan-detail input-changeable-engineer-cost-budget-plan" value="${projectBudgetPlanDetail.engineerCost!}"></td>
<td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-budget-plan-detail input-changeable-project-manage-cost-budget-plan" value="${projectBudgetPlanDetail.projectManageCost!}"></td>
@ -647,6 +647,25 @@
</tbody>
</table>
<button type="button" id="budgetPlanDetailAddBtn" class="am-btn am-btn-primary am-btn-xs am-round"><span class="am-icon-plus"></span></button>
<table class="am-table am-table-bordered am-table-radius table-main" style="padding:0;">
<tbody>
<tr>
<td>垫资峰值时间</td>
<td>垫资峰值金额</td>
<td>利率</td>
<td>资金利息</td>
</tr>
<tr>
<td><input type="text" class="am-modal-prompt-input input-underwritten-plan-statistic-max-month-budget-plan" value="${underwrittenPlanStatistic.maxMonth!}" readonly/></td>
<td><input type="text" class="am-modal-prompt-input input-underwritten-plan-statistic-amount-budget-plan" value="${Utils.format(underwrittenPlanStatistic.amount,'')}" readonly/></td>
<td><input type="text" class="am-modal-prompt-input input-underwritten-plan-statistic-tax-rate-budget-plan" value="${Utils.format(project.underwrittenTaxRate,'')}" readonly/></td>
<td><input type="text" class="am-modal-prompt-input input-underwritten-plan-statistic-capital-interest-budget-plan" value="${Utils.format(underwrittenPlanStatistic.capitalInterest,'')}" readonly/></td>
</tr>
</tbody>
</table>
</div>
<div class="am-modal-footer">
<span class="am-modal-btn" data-am-modal-cancel>取消</span>