|
|
@@ -396,7 +396,7 @@ public class ProjectRenewalFundManage { |
|
|
|
} |
|
|
|
|
|
|
|
//判断金额 |
|
|
|
checkPaymentAmount(projectCode,projectYear,dto.getAnnualPaymentAmount()); |
|
|
|
// checkPaymentAmount(projectCode,projectYear,dto.getAnnualPaymentAmount()); |
|
|
|
|
|
|
|
declaration.setApprovalStatus(ProjectRenewalApprovalStatusEnum.PENDING.name()); |
|
|
|
if(Objects.nonNull(project)){ |
|
|
@@ -443,17 +443,24 @@ public class ProjectRenewalFundManage { |
|
|
|
|
|
|
|
//3. 算出 所能申报的最大金额 |
|
|
|
//3.1 算出 申报年 以及 之前的所有合同计划金额 |
|
|
|
Double planSum = paymentPlans.stream().filter(c -> Objects.nonNull(c.getPaymentTime()) && |
|
|
|
BigDecimal planSum = BigDecimal.ZERO; |
|
|
|
Optional<BigDecimal> planSumOp = paymentPlans.stream().filter(c -> Objects.nonNull(c.getPaymentTime()) && |
|
|
|
(c.getPaymentTime().getYear() - projectYear) <= 0) |
|
|
|
.mapToDouble(c -> Objects.nonNull(c.getPaymentAmount()) ? c.getPaymentAmount().doubleValue() : 0.0) |
|
|
|
.sum(); |
|
|
|
|
|
|
|
Double actualPlanSum = paymentPlans.stream().filter(c -> Objects.nonNull(c.getPaymentTime()) && |
|
|
|
.map(c -> Objects.nonNull(c.getPaymentAmount()) ? c.getPaymentAmount() : BigDecimal.ZERO) |
|
|
|
.reduce(BigDecimal::add); |
|
|
|
if(planSumOp.isPresent()){ |
|
|
|
planSum = planSumOp.get(); |
|
|
|
} |
|
|
|
BigDecimal actualPlanSum = BigDecimal.ZERO; |
|
|
|
Optional<BigDecimal> actualPlanSumOp = paymentPlans.stream().filter(c -> Objects.nonNull(c.getPaymentTime()) && |
|
|
|
(c.getPaymentTime().getYear() - projectYear) < 0) |
|
|
|
.mapToDouble(c -> Objects.nonNull(c.getActualPaymentAmount()) ? c.getActualPaymentAmount().doubleValue() : 0.0) |
|
|
|
.sum(); |
|
|
|
Double maxAmount = planSum - actualPlanSum; |
|
|
|
VUtils.isTrue(annualPlanAmount.compareTo(BigDecimal.valueOf(maxAmount)) > 0).throwMessage("所填年度支付金额 超出 最大限额"); |
|
|
|
.map(c -> Objects.nonNull(c.getActualPaymentAmount()) ? c.getActualPaymentAmount() : BigDecimal.ZERO) |
|
|
|
.reduce(BigDecimal::add); |
|
|
|
if(actualPlanSumOp.isPresent()){ |
|
|
|
actualPlanSum = actualPlanSumOp.get(); |
|
|
|
} |
|
|
|
BigDecimal maxAmount = planSum.subtract(actualPlanSum); |
|
|
|
VUtils.isTrue(annualPlanAmount.compareTo(maxAmount) > 0).throwMessage("所填年度支付金额 超出 最大限额"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|