FINERACT-2358: Advanced-accounting-rules-based-on-write-off-reason E2E tests
This commit is contained in:
committed by
Arnold Gálovics
parent
c518d8622a
commit
3b62d562a2
+1
@@ -50,4 +50,5 @@ public class LoanDTO {
|
||||
private boolean merchantBuyDownFee;
|
||||
private List<AdvancedMappingtDTO> buydownFeeAdvancedMappingData;
|
||||
private List<AdvancedMappingtDTO> capitalizedIncomeAdvancedMappingData;
|
||||
private AdvancedMappingtDTO writeOffReasonAdvancedMappingData;
|
||||
}
|
||||
|
||||
+7
-2
@@ -174,7 +174,7 @@ public class AccountingProcessorHelper {
|
||||
periodicAccrualBasedAccountingEnabled, newLoanTransactions, isLoanMarkedAsChargeOff, isLoanMarkedAsFraud,
|
||||
chargeOffReasonCodeValue, isLoanMarkedAsWrittenOff, merchantBuyDownFee,
|
||||
accountingBridgeData.getBuydownFeeClassificationCodeValue(),
|
||||
accountingBridgeData.getCapitalizedIncomeClassificationCodeValue());
|
||||
accountingBridgeData.getCapitalizedIncomeClassificationCodeValue(), accountingBridgeData.getWriteOffReasonCodeValue());
|
||||
}
|
||||
|
||||
public ProductToGLAccountMapping getChargeOffMappingByCodeValue(Long loanProductId, PortfolioProductType productType,
|
||||
@@ -182,6 +182,11 @@ public class AccountingProcessorHelper {
|
||||
return accountMappingRepository.findChargeOffReasonMapping(loanProductId, productType.getValue(), chargeOffReasonId);
|
||||
}
|
||||
|
||||
public ProductToGLAccountMapping getWriteOffMappingByCodeValue(Long loanProductId, PortfolioProductType productType,
|
||||
Long writeOffReasonId) {
|
||||
return accountMappingRepository.findWriteOffReasonMapping(loanProductId, productType.getValue(), writeOffReasonId);
|
||||
}
|
||||
|
||||
public ProductToGLAccountMapping getClassificationMappingByCodeValue(Long loanProductId, PortfolioProductType productType,
|
||||
final Long classificationId, final String classificationType) {
|
||||
if (LoanProductAccountingParams.BUYDOWN_FEE_CLASSIFICATION_TO_INCOME_ACCOUNT_MAPPINGS.getValue().equals(classificationType)) {
|
||||
@@ -937,7 +942,7 @@ public class AccountingProcessorHelper {
|
||||
persistJournalEntry(journalEntry);
|
||||
}
|
||||
|
||||
private void createDebitJournalEntryForLoan(final Office office, final String currencyCode, final GLAccount account, final Long loanId,
|
||||
public void createDebitJournalEntryForLoan(final Office office, final String currencyCode, final GLAccount account, final Long loanId,
|
||||
final String transactionId, final LocalDate transactionDate, final BigDecimal amount) {
|
||||
final boolean manualEntry = false;
|
||||
Long loanTransactionId = null;
|
||||
|
||||
+14
-2
@@ -1913,8 +1913,20 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
||||
* Single DEBIT transaction for write-offs
|
||||
***/
|
||||
if (MathUtil.isGreaterThanZero(totalDebitAmount)) {
|
||||
this.helper.createDebitJournalEntryForLoan(office, currencyCode, AccrualAccountsForLoan.LOSSES_WRITTEN_OFF.getValue(),
|
||||
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, totalDebitAmount);
|
||||
final AdvancedMappingtDTO writeAdvancedMappingtDTO = loanDTO.getWriteOffReasonAdvancedMappingData();
|
||||
final ProductToGLAccountMapping mapping = (writeAdvancedMappingtDTO != null
|
||||
&& writeAdvancedMappingtDTO.getReferenceValueId() != null)
|
||||
? helper.getWriteOffMappingByCodeValue(loanProductId, PortfolioProductType.LOAN,
|
||||
writeAdvancedMappingtDTO.getReferenceValueId())
|
||||
: null;
|
||||
|
||||
if (mapping == null) {
|
||||
this.helper.createDebitJournalEntryForLoan(office, currencyCode, AccrualAccountsForLoan.LOSSES_WRITTEN_OFF.getValue(),
|
||||
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, totalDebitAmount);
|
||||
} else {
|
||||
this.helper.createDebitJournalEntryForLoan(office, currencyCode, mapping.getGlAccount(), loanId, transactionId,
|
||||
transactionDate, totalDebitAmount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-1
@@ -872,13 +872,17 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
|
||||
} else if (loanTransaction.isCapitalizedIncomeAmortization()) {
|
||||
capitalizedIncomeAdvancedMappingData = getLoanTransactionClassificationId(loanTransaction);
|
||||
}
|
||||
AdvancedMappingtDTO writeOffReasonAdvancedMappingData = null;
|
||||
if (loan.isClosedWrittenOff() && loan.getWriteOffReason() != null) {
|
||||
writeOffReasonAdvancedMappingData = new AdvancedMappingtDTO(loan.getWriteOffReason().getId(), BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
return new AccountingBridgeDataDTO(loan.getId(), loan.productId(), loan.getOfficeId(), currencyCode,
|
||||
loan.getSummary().getTotalInterestCharged(), loan.isCashBasedAccountingEnabledOnLoanProduct(),
|
||||
loan.isUpfrontAccrualAccountingEnabledOnLoanProduct(), loan.isPeriodicAccrualAccountingEnabledOnLoanProduct(),
|
||||
isAccountTransfer, wasChargedOffAtTransactionTime, loan.isFraud(), loan.fetchChargeOffReasonId(), loan.isClosedWrittenOff(),
|
||||
transactions, loan.getLoanProductRelatedDetail().isMerchantBuyDownFee(), buydownFeeAdvancedMappingData,
|
||||
capitalizedIncomeAdvancedMappingData);
|
||||
capitalizedIncomeAdvancedMappingData, writeOffReasonAdvancedMappingData);
|
||||
}
|
||||
|
||||
private List<AdvancedMappingtDTO> getLoanTransactionClassificationId(final LoanTransaction loanTransaction) {
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ class CreateJournalEntriesForChargeOffLoanTest {
|
||||
Collections.emptyList(), false, "", null, null, null, null);
|
||||
|
||||
loanDTO = new LoanDTO(1L, 1L, 1L, "USD", false, true, true, List.of(loanTransactionDTO), false, false, chargeOffReasonId, false,
|
||||
false, null, null);
|
||||
false, null, null, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user