FINERACT-1806: Fix mapping to handle multiple loan product configuration
This commit is contained in:
+7
-6
@@ -37,6 +37,7 @@ import org.apache.fineract.accounting.journalentry.service.AccountingProcessorHe
|
||||
import org.apache.fineract.accounting.journalentry.service.AccrualBasedAccountingProcessorForLoan;
|
||||
import org.apache.fineract.accounting.producttoaccountmapping.domain.ProductToGLAccountMapping;
|
||||
import org.apache.fineract.organisation.office.domain.Office;
|
||||
import org.apache.fineract.portfolio.PortfolioProductType;
|
||||
import org.apache.fineract.portfolio.loanaccount.data.LoanTransactionEnumData;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -48,7 +49,7 @@ import org.mockito.junit.jupiter.MockitoExtension;
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class CreateJournalEntriesForChargeOffLoanTest {
|
||||
|
||||
private static final Long chargeOffReasons = 15L;
|
||||
private static final Long chargeOffReasonId = 15L;
|
||||
|
||||
@Mock
|
||||
private AccountingProcessorHelper helper;
|
||||
@@ -71,7 +72,7 @@ class CreateJournalEntriesForChargeOffLoanTest {
|
||||
transactionType, new BigDecimal("500.00"), new BigDecimal("500.00"), null, null, null, null, false, Collections.emptyList(),
|
||||
Collections.emptyList(), false, "", null, null, null, null);
|
||||
|
||||
loanDTO = new LoanDTO(1L, 1L, 1L, "USD", false, true, true, List.of(loanTransactionDTO), false, false, chargeOffReasons);
|
||||
loanDTO = new LoanDTO(1L, 1L, 1L, "USD", false, true, true, List.of(loanTransactionDTO), false, false, chargeOffReasonId);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -84,7 +85,7 @@ class CreateJournalEntriesForChargeOffLoanTest {
|
||||
ProductToGLAccountMapping chargeToGLAccountMapper = new ProductToGLAccountMapping();
|
||||
chargeToGLAccountMapper.setGlAccount(chargeOffGLAccount);
|
||||
|
||||
when(helper.getChargeOffMappingByCodeValue(chargeOffReasons)).thenReturn(chargeToGLAccountMapper);
|
||||
when(helper.getChargeOffMappingByCodeValue(1L, PortfolioProductType.LOAN, chargeOffReasonId)).thenReturn(chargeToGLAccountMapper);
|
||||
|
||||
GLAccount loanPortfolioGLAccount = new GLAccount();
|
||||
loanPortfolioGLAccount.setId(20L);
|
||||
@@ -96,7 +97,7 @@ class CreateJournalEntriesForChargeOffLoanTest {
|
||||
|
||||
processor.createJournalEntriesForLoan(loanDTO);
|
||||
|
||||
verify(helper, times(1)).getChargeOffMappingByCodeValue(chargeOffReasons);
|
||||
verify(helper, times(1)).getChargeOffMappingByCodeValue(1L, PortfolioProductType.LOAN, chargeOffReasonId);
|
||||
verify(helper, times(1)).getLinkedGLAccountForLoanProduct(1L, AccrualAccountsForLoan.LOAN_PORTFOLIO.getValue(), 1L);
|
||||
verify(helper, times(1)).createCreditJournalEntryOrReversalForLoan(helper.getOfficeById(1L), "USD",
|
||||
AccrualAccountsForLoan.LOAN_PORTFOLIO, 1L, null, 1L, "txn-123", LocalDate.now(ZoneId.systemDefault()),
|
||||
@@ -110,7 +111,7 @@ class CreateJournalEntriesForChargeOffLoanTest {
|
||||
void shouldCreateJournalEntriesForChargeOffWithFraud() {
|
||||
loanDTO.setMarkedAsFraud(true);
|
||||
|
||||
when(helper.getChargeOffMappingByCodeValue(chargeOffReasons)).thenReturn(null);
|
||||
when(helper.getChargeOffMappingByCodeValue(1L, PortfolioProductType.LOAN, chargeOffReasonId)).thenReturn(null);
|
||||
|
||||
GLAccount loanPortfolioGLAccount = new GLAccount();
|
||||
loanPortfolioGLAccount.setId(20L);
|
||||
@@ -138,7 +139,7 @@ class CreateJournalEntriesForChargeOffLoanTest {
|
||||
void shouldCreateJournalEntriesForChargeOffWithoutFraud() {
|
||||
loanDTO.setMarkedAsFraud(false);
|
||||
|
||||
when(helper.getChargeOffMappingByCodeValue(chargeOffReasons)).thenReturn(null);
|
||||
when(helper.getChargeOffMappingByCodeValue(1L, PortfolioProductType.LOAN, chargeOffReasonId)).thenReturn(null);
|
||||
|
||||
GLAccount loanPortfolioGLAccount = new GLAccount();
|
||||
loanPortfolioGLAccount.setId(20L);
|
||||
|
||||
Reference in New Issue
Block a user