소스 검색

feat(合同制作):金额保留两位小数

Wangyafan 5 달 전
부모
커밋
b2ef179dd8
1개의 변경된 파일37개의 추가작업 그리고 38개의 파일을 삭제
  1. 37 38
      src/main/java/com/sunxung/factoring/service/financing/contract/impl/NewContractMakingServiceImpl.java

+ 37 - 38
src/main/java/com/sunxung/factoring/service/financing/contract/impl/NewContractMakingServiceImpl.java

@@ -46,7 +46,6 @@ import org.springframework.stereotype.Service;
 
 import java.io.File;
 import java.math.BigDecimal;
-import java.math.RoundingMode;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -221,7 +220,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
             // 融资金额
             BigDecimal financingAmount = new BigDecimal(0.00);
             if (null != contractFinancingInfo && null != contractFinancingInfo.getFinancingAmount()) {
-                financingAmount = contractFinancingInfo.getFinancingAmount().setScale(2,BigDecimal.ROUND_HALF_UP);
+                financingAmount = contractFinancingInfo.getFinancingAmount().setScale(2, BigDecimal.ROUND_HALF_UP);
             }
             // 币种中文名称
             String currency_cn = "人民币";
@@ -285,7 +284,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                     // 授信金额
                     BigDecimal creditLine = new BigDecimal(0.00);
                     if (null != creditResolution && null != creditResolution.getProposedCreditLine()) {
-                        creditLine = creditResolution.getProposedCreditLine().setScale(2,BigDecimal.ROUND_HALF_UP);
+                        creditLine = creditResolution.getProposedCreditLine().setScale(2, BigDecimal.ROUND_HALF_UP);
                     }
                     if (creditLine != null) {
                         amountCname = MoneyToCNFormatUtil
@@ -403,7 +402,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                                 String loanBalanceStr = "";
                                 BigDecimal loanBalance = estate.getLoanBalance();
                                 if (null != loanBalance) {
-                                    loanBalance = loanBalance.setScale(2,BigDecimal.ROUND_HALF_UP);
+                                    loanBalance = loanBalance.setScale(2, BigDecimal.ROUND_HALF_UP);
                                     loanBalanceStr = NumberFormatUtil.convertDecimal(loanBalance,
                                             NumberFormatUtil.THOUSAND_SEPARATOR_TWO_DECIMAL) + "元";
                                 }
@@ -444,7 +443,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                                 String loanBalanceStr = "";
                                 BigDecimal loanBalance = vehicle.getLoanBalance();
                                 if (null != loanBalance) {
-                                    loanBalance = loanBalance.setScale(2,BigDecimal.ROUND_HALF_UP);
+                                    loanBalance = loanBalance.setScale(2, BigDecimal.ROUND_HALF_UP);
                                     loanBalanceStr = NumberFormatUtil.convertDecimal(loanBalance,
                                             NumberFormatUtil.THOUSAND_SEPARATOR_TWO_DECIMAL) + "元";
                                 }
@@ -466,7 +465,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                                 String registeredCapitalStr = "";
                                 BigDecimal registeredCapital = equityAssets.getRegisteredCapital();
                                 if (null != registeredCapital) {
-                                    registeredCapital = registeredCapital.setScale(2,BigDecimal.ROUND_HALF_UP);
+                                    registeredCapital = registeredCapital.setScale(2, BigDecimal.ROUND_HALF_UP);
                                     registeredCapitalStr = NumberFormatUtil.convertDecimal(registeredCapital,
                                             NumberFormatUtil.THOUSAND_SEPARATOR_TWO_DECIMAL) + "元";
                                 }
@@ -483,7 +482,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                                 String investmentAmountStr = "";
                                 BigDecimal investmentAmount = equityAssets.getInvestmentAmount();
                                 if (null != investmentAmount) {
-                                    investmentAmount = investmentAmount.setScale(2,BigDecimal.ROUND_HALF_UP);
+                                    investmentAmount = investmentAmount.setScale(2, BigDecimal.ROUND_HALF_UP);
                                     investmentAmountStr = NumberFormatUtil.convertDecimal(investmentAmount,
                                             NumberFormatUtil.THOUSAND_SEPARATOR_TWO_DECIMAL) + "元";
                                 }
@@ -627,7 +626,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                                 String loanBalanceStr = "";
                                 BigDecimal loanBalance = vehicle.getLoanBalance();
                                 if (null != loanBalance) {
-                                    loanBalance = loanBalance.setScale(2,BigDecimal.ROUND_HALF_UP);
+                                    loanBalance = loanBalance.setScale(2, BigDecimal.ROUND_HALF_UP);
                                     loanBalanceStr = NumberFormatUtil.convertDecimal(loanBalance,
                                             NumberFormatUtil.THOUSAND_SEPARATOR_TWO_DECIMAL) + "元";
                                 }
@@ -649,7 +648,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                                 String registeredCapitalStr = "";
                                 BigDecimal registeredCapital = equityAssets.getRegisteredCapital();
                                 if (null != registeredCapital) {
-                                    registeredCapital = registeredCapital.setScale(2,BigDecimal.ROUND_HALF_UP);
+                                    registeredCapital = registeredCapital.setScale(2, BigDecimal.ROUND_HALF_UP);
                                     registeredCapitalStr = NumberFormatUtil.convertDecimal(registeredCapital,
                                             NumberFormatUtil.THOUSAND_SEPARATOR_TWO_DECIMAL) + "元";
                                 }
@@ -667,7 +666,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                                 String investmentAmountStr = "";
                                 BigDecimal investmentAmount = equityAssets.getInvestmentAmount();
                                 if (null != investmentAmount) {
-                                    investmentAmount = investmentAmount.setScale(2,BigDecimal.ROUND_HALF_UP);
+                                    investmentAmount = investmentAmount.setScale(2, BigDecimal.ROUND_HALF_UP);
                                     investmentAmountStr = NumberFormatUtil.convertDecimal(investmentAmount,
                                             NumberFormatUtil.THOUSAND_SEPARATOR_TWO_DECIMAL) + "元";
                                 }
@@ -871,7 +870,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                     // 融资金额中文
                     String financingAmount_cn = "";
                     if (null != financingAmount && StringUtil.isNotEmpty(currency_cn)) {
-                        financingAmount = financingAmount.setScale(2,BigDecimal.ROUND_HALF_UP);
+                        financingAmount = financingAmount.setScale(2, BigDecimal.ROUND_HALF_UP);
                         financingAmount_cn = MoneyToCNFormatUtil.formatToCN(financingAmount.doubleValue());
                     }
                     // 融资金额英文
@@ -996,7 +995,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                     map.put("day", DateUtil.getDay(date));
                     String financingAmountCname = "";
                     if (null != financingInfo.getFinancingAmount()) {
-                        financingAmount = financingInfo.getFinancingAmount().setScale(2,BigDecimal.ROUND_HALF_UP);
+                        financingAmount = financingInfo.getFinancingAmount().setScale(2, BigDecimal.ROUND_HALF_UP);
                         financingAmountCname = MoneyToCNFormatUtil
                                 .formatToCN(financingInfo.getFinancingAmount().doubleValue());
                     }
@@ -1045,9 +1044,9 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
             String creditLineCname = "";
             String creditLine = "";
             if (null != creditResolution.getProposedCreditLine()) {
-                creditLine = creditResolution.getProposedCreditLine().setScale(2,BigDecimal.ROUND_HALF_UP).toString();
+                creditLine = creditResolution.getProposedCreditLine().setScale(2, BigDecimal.ROUND_HALF_UP).toString();
                 creditLineCname = MoneyToCNFormatUtil
-                        .formatToCN(creditResolution.getProposedCreditLine().setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
+                        .formatToCN(creditResolution.getProposedCreditLine().setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
             }
             // 合同名称
             String contractName = masterContract.getContractName();
@@ -1139,7 +1138,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                     String amountEname = "";
                     String amountCname = "";
                     if (financingAmount != null) {
-                        financingAmount = financingAmount.setScale(2,BigDecimal.ROUND_HALF_UP);
+                        financingAmount = financingAmount.setScale(2, BigDecimal.ROUND_HALF_UP);
                         amountCname = MoneyToCNFormatUtil.formatToCN(financingAmount.doubleValue());
                         amountEname = financingAmount + "元";
                     }
@@ -1234,7 +1233,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
             // 融资金额
             BigDecimal financingAmount = null;
             if (null != contractFinancingInfo && null != contractFinancingInfo.getFinancingAmount()) {
-                financingAmount = contractFinancingInfo.getFinancingAmount().setScale(2,BigDecimal.ROUND_HALF_UP);
+                financingAmount = contractFinancingInfo.getFinancingAmount().setScale(2, BigDecimal.ROUND_HALF_UP);
             }
             ReviewRltRepay rltRepay = reviewRltRepayService.getById(reviewRltRepayId);
             //社会统一信用代码/身份证号码
@@ -1351,16 +1350,16 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                     .eq("review_quota_disburse_id", contractInfo.getReviewQuotaDisburseId()));
             if (null != financingInfo) {
                 //融资利息
-                BigDecimal financingInterest = financingInfo.getFinancingInterest().setScale(2,BigDecimal.ROUND_HALF_UP);
+                BigDecimal financingInterest = financingInfo.getFinancingInterest().setScale(2, BigDecimal.ROUND_HALF_UP);
                 //融资金额
-                BigDecimal financingAmount = financingInfo.getFinancingAmount().setScale(2,BigDecimal.ROUND_HALF_UP);
+                BigDecimal financingAmount = financingInfo.getFinancingAmount().setScale(2, BigDecimal.ROUND_HALF_UP);
                 BigDecimal financingTotal = new BigDecimal(0.00);
                 financingTotal = financingTotal
-                        .add(null == financingAmount ? new BigDecimal(0.00) : financingAmount.setScale(2,BigDecimal.ROUND_HALF_UP))
-                        .add(null == financingInterest ? new BigDecimal(0.00) : financingInterest.setScale(2,BigDecimal.ROUND_HALF_UP));
+                        .add(null == financingAmount ? new BigDecimal(0.00) : financingAmount.setScale(2, BigDecimal.ROUND_HALF_UP))
+                        .add(null == financingInterest ? new BigDecimal(0.00) : financingInterest.setScale(2, BigDecimal.ROUND_HALF_UP));
                 map.put("financingTotal", financingTotal);
                 BigDecimal managementFeeAmount = financingInfo.getManagementFeeAmount();
-                map.put("managementFeeAmount", managementFeeAmount == null ? new BigDecimal(0.00) : managementFeeAmount.setScale(2,BigDecimal.ROUND_HALF_UP));
+                map.put("managementFeeAmount", managementFeeAmount == null ? new BigDecimal(0.00) : managementFeeAmount.setScale(2, BigDecimal.ROUND_HALF_UP));
             }
             // 保理合同编号
             String factoringContractNo = masterContract.getContractNo();
@@ -1949,7 +1948,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                     // 融资利息
                     financingInterest = financingInfo.getFinancingInterest();
                     if (null != financingInterest) {
-                        financingInterest = financingInterest.setScale(2,BigDecimal.ROUND_HALF_UP);
+                        financingInterest = financingInterest.setScale(2, BigDecimal.ROUND_HALF_UP);
                         financingInterestName = MoneyToCNFormatUtil.formatToCN(financingInterest.doubleValue());
                     }
                     // 支付方式
@@ -1971,7 +1970,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                     manageFeeRate = StringUtil.subZeroAndDot(PercentageUtil.convertPercentage(financingInfo.getManagementFeeRatio().doubleValue()).split("%")[0] + "%");
                     // 管理费金额大写
                     if (null != manageFeeAmount) {
-                        manageFeeAmount = manageFeeAmount.setScale(2,BigDecimal.ROUND_HALF_UP);
+                        manageFeeAmount = manageFeeAmount.setScale(2, BigDecimal.ROUND_HALF_UP);
                         manageFeeAmountName = MoneyToCNFormatUtil.formatToCN(manageFeeAmount.doubleValue());
                     }
                     //管理费支付方式
@@ -1982,7 +1981,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                     otherFeeCollectionMethod = contractFinancingInfo.getOtherFeeCollectionMethod();
                     // 其他费用金额大写
                     if (null != otherFee) {
-                        otherFee = otherFee.setScale(2,BigDecimal.ROUND_HALF_UP);
+                        otherFee = otherFee.setScale(2, BigDecimal.ROUND_HALF_UP);
                         otherFeeName = MoneyToCNFormatUtil.formatToCN(otherFee.doubleValue());
                     }
                     // 信用风险担保金额
@@ -2006,7 +2005,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                     transferNoticeMethodId = transferNoticeMethodId.trim();
                 }
                 if (null != financingAmmount) {
-                    financingAmmount = financingAmmount.setScale(2,BigDecimal.ROUND_HALF_UP);
+                    financingAmmount = financingAmmount.setScale(2, BigDecimal.ROUND_HALF_UP);
                     financingAmmountCname = MoneyToCNFormatUtil.formatToCN(financingAmmount.doubleValue());
                 }
                 // 提款条件
@@ -2084,14 +2083,14 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                         // 金额合计
                         amountTotal = loanConditionList.stream().filter(e -> {
                                     if (null != e.getAmount()) {
-                                        e.setAmount(e.getAmount().setScale(2,BigDecimal.ROUND_HALF_UP));
+                                        e.setAmount(e.getAmount().setScale(2, BigDecimal.ROUND_HALF_UP));
                                     }
                                     return null != e.getAmount();
                                 })
                                 .map(ReviewLoanCondition::getAmount)
                                 .reduce(new BigDecimal(0.00), BigDecimal::add);
                         if (null != amountTotal) {
-                            amountTotal = amountTotal.setScale(2,BigDecimal.ROUND_HALF_UP);
+                            amountTotal = amountTotal.setScale(2, BigDecimal.ROUND_HALF_UP);
                             amountTotalName = MoneyToCNFormatUtil.formatToCN(amountTotal.doubleValue());
                         }
                         map.put("fixedConditionNo", fixedConditionNo);
@@ -2145,10 +2144,10 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                 map3.put("receivableType", "货款");
                 //计算应收账款金融
                 BigDecimal accountsReceivableAmount = calculateAccountsReceivableAmount(reviewQuotaDisburse.getFinancingBasicInfoId());
-                map3.put("receivableAmount", null == accountsReceivableAmount ? new BigDecimal(0.00) : accountsReceivableAmount.setScale(2,BigDecimal.ROUND_HALF_UP));
+                map3.put("receivableAmount", null == accountsReceivableAmount ? new BigDecimal(0.00) : accountsReceivableAmount.setScale(2, BigDecimal.ROUND_HALF_UP));
                 BigDecimal accountsReceivableNetAmountTotal = reviewQuotaDisburse.getAccountsReceivableNetAmountTotal();
                 map3.put("receivableNetAmount",
-                        accountsReceivableNetAmountTotal == null ? new BigDecimal(0.00) : accountsReceivableNetAmountTotal.setScale(2,BigDecimal.ROUND_HALF_UP));
+                        accountsReceivableNetAmountTotal == null ? new BigDecimal(0.00) : accountsReceivableNetAmountTotal.setScale(2, BigDecimal.ROUND_HALF_UP));
                 if (null != reviewQuotaDisburse.getTerm()) {
                     map3.put("term", reviewQuotaDisburse.getTerm());
                 }
@@ -2184,7 +2183,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                     creditLine = creditResolution.getProposedCreditLine();
                     creditBalance = reviewQuotaDisburse.getBusinessCreditBalance();
                     if (null != creditBalance) {
-                        creditBalance = creditBalance.setScale(2,BigDecimal.ROUND_HALF_UP);
+                        creditBalance = creditBalance.setScale(2, BigDecimal.ROUND_HALF_UP);
                         if (creditBalance.compareTo(BigDecimal.ZERO) == -1) {
                             creditBalanceName = MoneyToCNFormatUtil.formatToCN(creditBalance.abs().doubleValue());
                             creditBalanceName = "负" + creditBalanceName;
@@ -2194,7 +2193,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                     }
                     // 授信金额中文
                     if (null != creditLine) {
-                        creditLine = creditLine.setScale(2,BigDecimal.ROUND_HALF_UP);
+                        creditLine = creditLine.setScale(2, BigDecimal.ROUND_HALF_UP);
                         creditLineName = MoneyToCNFormatUtil.formatToCN(creditLine.doubleValue());
                     }
                     // 授信期限
@@ -2389,7 +2388,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
             accountsReceivableAmount = informationList.stream()
                     .filter(accountsReceivable -> {
                         if (null != accountsReceivable.getAccountsReceivableAmount()) {
-                            accountsReceivable.setAccountsReceivableAmount(accountsReceivable.getAccountsReceivableAmount().setScale(2, BigDecimal.ROUND_HALF_UP));
+                            accountsReceivable.setAccountsReceivableAmount(accountsReceivable.getAccountsReceivableAmount());
                         }
                         return null != accountsReceivable.getAccountsReceivableAmount();
                     })
@@ -2555,9 +2554,9 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                 }
                 noticeMap.put("financingRateStr", financingRateStr);
                 BigDecimal financingAmmount = financingInfo.getFinancingAmount() == null ?
-                        new BigDecimal(0.00) : financingInfo.getFinancingAmount().setScale(2,BigDecimal.ROUND_HALF_UP);
+                        new BigDecimal(0.00) : financingInfo.getFinancingAmount().setScale(2, BigDecimal.ROUND_HALF_UP);
                 financingAmountInterest = financingAmmount
-                        .add(financingInfo.getFinancingInterest() == null ? new BigDecimal(0.00) : financingInfo.getFinancingInterest().setScale(2,BigDecimal.ROUND_HALF_UP));
+                        .add(financingInfo.getFinancingInterest() == null ? new BigDecimal(0.00) : financingInfo.getFinancingInterest().setScale(2, BigDecimal.ROUND_HALF_UP));
                 noticeMap.put("financingAmountInterest", financingAmountInterest);
                 Map<Long, List<Map<String, Object>>> groupingByMap = new HashMap<>();
 
@@ -2574,7 +2573,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                 iMap.put("debtor", debtorList.get(0).getCompanyName());
                 iMap.put("accountsReceivableType", "货款");
                 //计算应收账款金额
-                BigDecimal accountsReceivableAmount = calculateAccountsReceivableAmount(reviewQuotaDisburse.getFinancingBasicInfoId());
+                BigDecimal accountsReceivableAmount = calculateAccountsReceivableAmount(reviewQuotaDisburse.getFinancingBasicInfoId()).setScale(2, BigDecimal.ROUND_HALF_UP);
                 iMap.put("accountsReceivableAmount", accountsReceivableAmount);
                 //应收账款净额
                 iMap.put("netAmount", reviewQuotaDisburse.getAccountsReceivableNetAmountTotal().toString());
@@ -2604,7 +2603,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                 noticeMap.put("changeList", changeList);
                 noticeMap.put("receivableAmountAll", accountsReceivableAmount);
                 if (null != invoiceAmmountAll) {
-                    noticeMap.put("invoiceAmmountAll", invoiceAmmountAll.setScale(2,BigDecimal.ROUND_HALF_UP));
+                    noticeMap.put("invoiceAmmountAll", invoiceAmmountAll.setScale(2, BigDecimal.ROUND_HALF_UP));
                 } else {
                     noticeMap.put("invoiceAmmountAll", "");
                 }
@@ -2699,7 +2698,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                         .eq("review_master_contract_id", masterContract.getId()));
                 String debtor = "";
                 ReviewQuotaDisburse reviewQuotaDisburse = reviewQuotaDisburseService.getById(contractInfo.getReviewQuotaDisburseId());
-                BigDecimal accountsReceivableAmount = calculateAccountsReceivableAmount(reviewQuotaDisburse.getFinancingBasicInfoId());
+                BigDecimal accountsReceivableAmount = calculateAccountsReceivableAmount(reviewQuotaDisburse.getFinancingBasicInfoId()).setScale(2, BigDecimal.ROUND_HALF_UP);
                 confirmMap.put("receivableAmountTotal", accountsReceivableAmount);
                 confirmMap.put("factoringContractNo", factoringContractNo);
                 confirmMap.put("contractName", contractName);
@@ -2730,7 +2729,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                             .add(financingAmmount
                                     .multiply(new BigDecimal("0.12").subtract(financingInfo.getManagementFeeRatio()))
                                     .divide(new BigDecimal("360"), 8, BigDecimal.ROUND_HALF_UP).multiply(financingDays));
-                    BigDecimal balance = balanceLong.setScale(2,BigDecimal.ROUND_HALF_UP);
+                    BigDecimal balance = balanceLong.setScale(2, BigDecimal.ROUND_HALF_UP);
                     confirmMap.put("balance", balance);
                 } else {
                     confirmMap.put("balance", BigDecimal.ZERO);