Browse Source

分账逻辑优化

liuj 5 months ago
parent
commit
95d1875a57

+ 4 - 0
src/main/java/com/sunxung/factoring/service/ledger/impl/LedgerManagementServiceImpl.java

@@ -1384,6 +1384,8 @@ public class LedgerManagementServiceImpl implements LedgerManagementService {
                                 if (surplusInterest.compareTo(BigDecimal.ZERO) != 0) {
                                 if (surplusInterest.compareTo(BigDecimal.ZERO) != 0) {
                                     PaymentCollectionPlanFactoring lastInterestFactoring = getLastPrincipalFactoring(allPlanFactoringList, interestDict, lastPlanDate);
                                     PaymentCollectionPlanFactoring lastInterestFactoring = getLastPrincipalFactoring(allPlanFactoringList, interestDict, lastPlanDate);
                                     if (lastInterestFactoring == null) {
                                     if (lastInterestFactoring == null) {
+                                        //这种场景可能存在未分配的利息,要删除
+                                        deleteUnAssignList(interestFactoringList, ledgerPlanFactoringAssignList, goodsAssignVo);
                                         ledgerPlanFactoringAssignList.add(addPlanFactoringInsertAssign(ledgerDate, surplusInterest, BigDecimal.ZERO,
                                         ledgerPlanFactoringAssignList.add(addPlanFactoringInsertAssign(ledgerDate, surplusInterest, BigDecimal.ZERO,
                                                 IncomeExpenditureTypeDict.ChildEnum.INTEREST.getCode(), goodsAssignVo, 0));
                                                 IncomeExpenditureTypeDict.ChildEnum.INTEREST.getCode(), goodsAssignVo, 0));
                                     } else {
                                     } else {
@@ -1409,6 +1411,8 @@ public class LedgerManagementServiceImpl implements LedgerManagementService {
                                 if (surplusManagement.compareTo(BigDecimal.ZERO) != 0) {
                                 if (surplusManagement.compareTo(BigDecimal.ZERO) != 0) {
                                     PaymentCollectionPlanFactoring lastManagementFactoring = getLastPrincipalFactoring(allPlanFactoringList, managementFeeDict, lastPlanDate);
                                     PaymentCollectionPlanFactoring lastManagementFactoring = getLastPrincipalFactoring(allPlanFactoringList, managementFeeDict, lastPlanDate);
                                     if (lastManagementFactoring == null) {
                                     if (lastManagementFactoring == null) {
+                                        //这种场景可能存在未分配的管理费,要删除
+                                        deleteUnAssignList(managementFeeFactoringList, ledgerPlanFactoringAssignList, goodsAssignVo);
                                         ledgerPlanFactoringAssignList.add(addPlanFactoringInsertAssign(ledgerDate, surplusManagement, BigDecimal.ZERO,
                                         ledgerPlanFactoringAssignList.add(addPlanFactoringInsertAssign(ledgerDate, surplusManagement, BigDecimal.ZERO,
                                                 IncomeExpenditureTypeDict.ChildEnum.MANAGEMENT_FEE.getCode(), goodsAssignVo, 0));
                                                 IncomeExpenditureTypeDict.ChildEnum.MANAGEMENT_FEE.getCode(), goodsAssignVo, 0));
                                     } else {
                                     } else {