FINERACT-2205: Add tests when charge is added after the charge off date and forbid backdated charge-off transactions in the middle of the monetary activity.

This commit is contained in:
mariiaKraievska
2025-02-03 16:29:45 +01:00
committed by Adam Saghy
parent bc0293bfa1
commit 69317d62c8
11 changed files with 582 additions and 215 deletions
@@ -6135,7 +6135,7 @@ public class ClientLoanIntegrationTest extends BaseLoanIntegrationTest {
globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE,
new PutGlobalConfigurationsRequest().enabled(true));
BUSINESS_DATE_HELPER.updateBusinessDate(new BusinessDateRequest().type(BusinessDateType.BUSINESS_DATE.getName())
.date("30 September 2022").dateFormat(DATETIME_PATTERN).locale("en"));
.date("04 September 2022").dateFormat(DATETIME_PATTERN).locale("en"));
final Account assetAccount = ACCOUNT_HELPER.createAssetAccount();
final Account incomeAccount = ACCOUNT_HELPER.createIncomeAccount();
final Account expenseAccount = ACCOUNT_HELPER.createExpenseAccount();
@@ -6271,6 +6271,9 @@ public class ClientLoanIntegrationTest extends BaseLoanIntegrationTest {
assertEquals(403, exception.getResponse().code());
assertTrue(exception.getMessage().contains("error.msg.loan.is.not.charged.off"));
BUSINESS_DATE_HELPER.updateBusinessDate(new BusinessDateRequest().type(BusinessDateType.BUSINESS_DATE.getName())
.date("08 September 2022").dateFormat(DATETIME_PATTERN).locale("en"));
PostLoansLoanIdTransactionsResponse loanRepaymentResponse = LOAN_TRANSACTION_HELPER.makeLoanRepayment((long) loanID,
new PostLoansLoanIdTransactionsRequest().dateFormat(DATETIME_PATTERN).transactionDate("05 September 2022").locale("en")
.transactionAmount(5.0));
@@ -147,64 +147,66 @@ public class LoanAccountChargeOffWithAdvancedPaymentAllocationTest extends BaseL
// Charge-off accounting and balances
@Test
public void loanChargeOffWithAdvancedPaymentStrategyTest() {
String loanExternalIdStr = UUID.randomUUID().toString();
final Integer loanProductID = createLoanProductWithPeriodicAccrualAccountingAndAdvancedPaymentAllocationStrategy();
final Integer clientId = clientHelper.createClient(ClientHelper.defaultClientCreationRequest()).getClientId().intValue();
final Integer loanId = createLoanAccount(clientId, loanProductID, loanExternalIdStr);
runAt("10 September 2022", () -> {
String loanExternalIdStr = UUID.randomUUID().toString();
final Integer loanProductID = createLoanProductWithPeriodicAccrualAccountingAndAdvancedPaymentAllocationStrategy();
final Integer clientId = clientHelper.createClient(ClientHelper.defaultClientCreationRequest()).getClientId().intValue();
final Integer loanId = createLoanAccount(clientId, loanProductID, loanExternalIdStr);
// apply charges
Integer feeCharge = ChargesHelper.createCharges(requestSpec, responseSpec,
ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, "10", false));
// apply charges
Integer feeCharge = ChargesHelper.createCharges(requestSpec, responseSpec,
ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, "10", false));
LocalDate targetDate = LocalDate.of(2022, 9, 5);
final String feeCharge1AddedDate = DATE_FORMATTER.format(targetDate);
Integer feeLoanChargeId = loanTransactionHelper.addChargesForLoan(loanId,
LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(feeCharge), feeCharge1AddedDate, "10"));
LocalDate targetDate = LocalDate.of(2022, 9, 5);
final String feeCharge1AddedDate = DATE_FORMATTER.format(targetDate);
Integer feeLoanChargeId = loanTransactionHelper.addChargesForLoan(loanId,
LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(feeCharge), feeCharge1AddedDate, "10"));
// apply penalty
Integer penalty = ChargesHelper.createCharges(requestSpec, responseSpec,
ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, "10", true));
// apply penalty
Integer penalty = ChargesHelper.createCharges(requestSpec, responseSpec,
ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, "10", true));
final String penaltyCharge1AddedDate = DATE_FORMATTER.format(targetDate);
final String penaltyCharge1AddedDate = DATE_FORMATTER.format(targetDate);
Integer penalty1LoanChargeId = this.loanTransactionHelper.addChargesForLoan(loanId,
LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(penalty), penaltyCharge1AddedDate, "10"));
Integer penalty1LoanChargeId = this.loanTransactionHelper.addChargesForLoan(loanId,
LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(penalty), penaltyCharge1AddedDate, "10"));
// make Repayment
final PostLoansLoanIdTransactionsResponse repaymentTransaction = loanTransactionHelper.makeLoanRepayment(loanExternalIdStr,
new PostLoansLoanIdTransactionsRequest().dateFormat("dd MMMM yyyy").transactionDate("9 September 2022").locale("en")
.transactionAmount(10.0));
// make Repayment
final PostLoansLoanIdTransactionsResponse repaymentTransaction = loanTransactionHelper.makeLoanRepayment(loanExternalIdStr,
new PostLoansLoanIdTransactionsRequest().dateFormat("dd MMMM yyyy").transactionDate("9 September 2022").locale("en")
.transactionAmount(10.0));
GetLoansLoanIdResponse loanDetails = this.loanTransactionHelper.getLoanDetails((long) loanId);
assertTrue(loanDetails.getStatus().getActive());
GetLoansLoanIdResponse loanDetails = this.loanTransactionHelper.getLoanDetails((long) loanId);
assertTrue(loanDetails.getStatus().getActive());
// set loan as chargeoff
String randomText = Utils.randomStringGenerator("en", 5) + Utils.randomNumberGenerator(6) + Utils.randomStringGenerator("is", 5);
Integer chargeOffReasonId = CodeHelper.createChargeOffCodeValue(requestSpec, responseSpec, randomText, 1);
String transactionExternalId = UUID.randomUUID().toString();
PostLoansLoanIdTransactionsResponse chargeOffTransaction = this.loanTransactionHelper.chargeOffLoan((long) loanId,
new PostLoansLoanIdTransactionsRequest().transactionDate("10 September 2022").locale("en").dateFormat("dd MMMM yyyy")
.externalId(transactionExternalId).chargeOffReasonId((long) chargeOffReasonId));
// set loan as chargeoff
String randomText = Utils.randomStringGenerator("en", 5) + Utils.randomNumberGenerator(6)
+ Utils.randomStringGenerator("is", 5);
Integer chargeOffReasonId = CodeHelper.createChargeOffCodeValue(requestSpec, responseSpec, randomText, 1);
String transactionExternalId = UUID.randomUUID().toString();
PostLoansLoanIdTransactionsResponse chargeOffTransaction = this.loanTransactionHelper.chargeOffLoan((long) loanId,
new PostLoansLoanIdTransactionsRequest().transactionDate("10 September 2022").locale("en").dateFormat("dd MMMM yyyy")
.externalId(transactionExternalId).chargeOffReasonId((long) chargeOffReasonId));
loanDetails = this.loanTransactionHelper.getLoanDetails((long) loanId);
assertTrue(loanDetails.getStatus().getActive());
assertTrue(loanDetails.getChargedOff());
loanDetails = this.loanTransactionHelper.getLoanDetails((long) loanId);
assertTrue(loanDetails.getStatus().getActive());
assertTrue(loanDetails.getChargedOff());
// verify amounts for charge-off transaction
verifyTransaction(LocalDate.of(2022, 9, 10), 1010.0f, 1000.0f, 0.0f, 10.0f, 0.0f, loanId, "chargeoff");
// verify journal entries
GetJournalEntriesTransactionIdResponse journalEntriesForChargeOff = journalEntryHelper
.getJournalEntries("L" + chargeOffTransaction.getResourceId().toString());
// verify amounts for charge-off transaction
verifyTransaction(LocalDate.of(2022, 9, 10), 1010.0f, 1000.0f, 0.0f, 10.0f, 0.0f, loanId, "chargeoff");
// verify journal entries
GetJournalEntriesTransactionIdResponse journalEntriesForChargeOff = journalEntryHelper
.getJournalEntries("L" + chargeOffTransaction.getResourceId().toString());
assertNotNull(journalEntriesForChargeOff);
List<JournalEntryTransactionItem> journalEntries = journalEntriesForChargeOff.getPageItems();
assertEquals(4, journalEntries.size());
verifyJournalEntry(journalEntries.get(3), 1000.0, LocalDate.of(2022, 9, 10), loansReceivable, "CREDIT");
verifyJournalEntry(journalEntries.get(2), 10.0, LocalDate.of(2022, 9, 10), interestFeeReceivable, "CREDIT");
verifyJournalEntry(journalEntries.get(1), 1000.0, LocalDate.of(2022, 9, 10), creditLossBadDebt, "DEBIT");
verifyJournalEntry(journalEntries.get(0), 10.0, LocalDate.of(2022, 9, 10), feeChargeOff, "DEBIT");
assertNotNull(journalEntriesForChargeOff);
List<JournalEntryTransactionItem> journalEntries = journalEntriesForChargeOff.getPageItems();
assertEquals(4, journalEntries.size());
verifyJournalEntry(journalEntries.get(3), 1000.0, LocalDate.of(2022, 9, 10), loansReceivable, "CREDIT");
verifyJournalEntry(journalEntries.get(2), 10.0, LocalDate.of(2022, 9, 10), interestFeeReceivable, "CREDIT");
verifyJournalEntry(journalEntries.get(1), 1000.0, LocalDate.of(2022, 9, 10), creditLossBadDebt, "DEBIT");
verifyJournalEntry(journalEntries.get(0), 10.0, LocalDate.of(2022, 9, 10), feeChargeOff, "DEBIT");
});
}
// Reverse Replay of Charge-Off
@@ -105,7 +105,7 @@ public class LoanChargeOffAccountingTest extends BaseLoanIntegrationTest {
@Test
public void loanChargeOffAccountingTreatmentTestForPeriodicAccrualAccounting() {
runAt("12 September 2022", () -> {
runAt("6 September 2022", () -> {
// Loan ExternalId
String loanExternalIdStr = UUID.randomUUID().toString();
@@ -161,6 +161,7 @@ public class LoanChargeOffAccountingTest extends BaseLoanIntegrationTest {
this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, "6 September 2022",
new JournalEntry(20, JournalEntry.TransactionType.DEBIT));
updateBusinessDate("12 September 2022");
// make Repayment
final PostLoansLoanIdTransactionsResponse repaymentTransaction = loanTransactionHelper.makeLoanRepayment(loanExternalIdStr,
new PostLoansLoanIdTransactionsRequest().dateFormat("dd MMMM yyyy").transactionDate("7 September 2022").locale("en")
@@ -261,7 +262,7 @@ public class LoanChargeOffAccountingTest extends BaseLoanIntegrationTest {
@Test
public void loanChargeOffFraudAccountingTreatmentTestForCashBasedAccounting() {
runAt("12 September 2022", () -> {
runAt("6 September 2022", () -> {
// Loan ExternalId
String loanExternalIdStr = UUID.randomUUID().toString();
@@ -330,6 +331,8 @@ public class LoanChargeOffAccountingTest extends BaseLoanIntegrationTest {
this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, "6 September 2022",
new JournalEntry(20, JournalEntry.TransactionType.DEBIT));
updateBusinessDate("12 September 2022");
// make Repayment
final PostLoansLoanIdTransactionsResponse repaymentTransaction = loanTransactionHelper.makeLoanRepayment(loanExternalIdStr,
new PostLoansLoanIdTransactionsRequest().dateFormat("dd MMMM yyyy").transactionDate("7 September 2022").locale("en")
@@ -494,7 +497,7 @@ public class LoanChargeOffAccountingTest extends BaseLoanIntegrationTest {
@Test
public void loanAccountingTreatmentTestForGoodwillCreditPeriodicAccrualAccounting_ChargeOff() {
runAt("12 September 2022", () -> {
runAt("6 September 2022", () -> {
// Loan ExternalId
String loanExternalIdStr = UUID.randomUUID().toString();
@@ -550,6 +553,8 @@ public class LoanChargeOffAccountingTest extends BaseLoanIntegrationTest {
this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, "6 September 2022",
new JournalEntry(20, JournalEntry.TransactionType.DEBIT));
updateBusinessDate("12 September 2022");
// Goodwill Credit
final PostLoansLoanIdTransactionsResponse goodwillCredit_1 = loanTransactionHelper.makeGoodwillCredit((long) loanId,
new PostLoansLoanIdTransactionsRequest().dateFormat("dd MMMM yyyy").transactionDate("08 September 2022").locale("en")
@@ -633,7 +638,7 @@ public class LoanChargeOffAccountingTest extends BaseLoanIntegrationTest {
@Test
public void loanAccountingTreatmentTestForCashBasedAccounting_ChargeOff() {
runAt("12 September 2022", () -> {
runAt("6 September 2022", () -> {
// Loan ExternalId
String loanExternalIdStr = UUID.randomUUID().toString();
@@ -694,6 +699,8 @@ public class LoanChargeOffAccountingTest extends BaseLoanIntegrationTest {
this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, "6 September 2022",
new JournalEntry(20, JournalEntry.TransactionType.DEBIT));
updateBusinessDate("12 September 2022");
// Goodwill Credit
final PostLoansLoanIdTransactionsResponse goodwillCredit_1 = loanTransactionHelper.makeGoodwillCredit((long) loanId,
new PostLoansLoanIdTransactionsRequest().dateFormat("dd MMMM yyyy").transactionDate("10 September 2022").locale("en")
@@ -72,7 +72,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@ExtendWith(LoanTestLifecycleExtension.class)
public class LoanPostChargeOffScenariosTest {
public class LoanPostChargeOffScenariosTest extends BaseLoanIntegrationTest {
private static final DateTimeFormatter DATE_FORMATTER = new DateTimeFormatterBuilder().appendPattern("dd MMMM yyyy").toFormatter();
private ResponseSpecification responseSpec;
@@ -143,172 +143,177 @@ public class LoanPostChargeOffScenariosTest {
@Test
public void postChargeOffAddBackdatedTransactionTest() {
String loanExternalIdStr = UUID.randomUUID().toString();
final Integer loanProductID = createLoanProductWithPeriodicAccrualAccounting();
final Integer clientId = clientHelper.createClient(ClientHelper.defaultClientCreationRequest()).getClientId().intValue();
final Integer loanId = createLoanAccount(clientId, loanProductID, loanExternalIdStr);
runAt("14 September 2022", () -> {
String loanExternalIdStr = UUID.randomUUID().toString();
final Integer loanProductID = createLoanProductWithPeriodicAccrualAccounting();
final Integer clientId = clientHelper.createClient(ClientHelper.defaultClientCreationRequest()).getClientId().intValue();
final Integer loanId = createLoanAccount(clientId, loanProductID, loanExternalIdStr);
// apply charges
Integer feeCharge = ChargesHelper.createCharges(requestSpec, responseSpec,
ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, "10", false));
// apply charges
Integer feeCharge = ChargesHelper.createCharges(requestSpec, responseSpec,
ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, "10", false));
LocalDate targetDate = LocalDate.of(2022, 9, 5);
final String feeCharge1AddedDate = DATE_FORMATTER.format(targetDate);
Integer feeLoanChargeId = loanTransactionHelper.addChargesForLoan(loanId,
LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(feeCharge), feeCharge1AddedDate, "10"));
LocalDate targetDate = LocalDate.of(2022, 9, 5);
final String feeCharge1AddedDate = DATE_FORMATTER.format(targetDate);
Integer feeLoanChargeId = loanTransactionHelper.addChargesForLoan(loanId,
LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(feeCharge), feeCharge1AddedDate, "10"));
// set loan as chargeoff
String randomText = Utils.randomStringGenerator("en", 5) + Utils.randomNumberGenerator(6) + Utils.randomStringGenerator("is", 5);
Integer chargeOffReasonId = CodeHelper.createChargeOffCodeValue(requestSpec, responseSpec, randomText, 1);
String transactionExternalId = UUID.randomUUID().toString();
PostLoansLoanIdTransactionsResponse chargeOffTransaction = loanTransactionHelper.chargeOffLoan((long) loanId,
new PostLoansLoanIdTransactionsRequest().transactionDate("14 September 2022").locale("en").dateFormat("dd MMMM yyyy")
.externalId(transactionExternalId).chargeOffReasonId((long) chargeOffReasonId));
// set loan as chargeoff
String randomText = Utils.randomStringGenerator("en", 5) + Utils.randomNumberGenerator(6)
+ Utils.randomStringGenerator("is", 5);
Integer chargeOffReasonId = CodeHelper.createChargeOffCodeValue(requestSpec, responseSpec, randomText, 1);
String transactionExternalId = UUID.randomUUID().toString();
PostLoansLoanIdTransactionsResponse chargeOffTransaction = loanTransactionHelper.chargeOffLoan((long) loanId,
new PostLoansLoanIdTransactionsRequest().transactionDate("14 September 2022").locale("en").dateFormat("dd MMMM yyyy")
.externalId(transactionExternalId).chargeOffReasonId((long) chargeOffReasonId));
GetLoansLoanIdResponse loanDetails = loanTransactionHelper.getLoanDetails((long) loanId);
assertTrue(loanDetails.getStatus().getActive());
assertTrue(loanDetails.getChargedOff());
GetLoansLoanIdResponse loanDetails = loanTransactionHelper.getLoanDetails((long) loanId);
assertTrue(loanDetails.getStatus().getActive());
assertTrue(loanDetails.getChargedOff());
// verify Journal Entries For ChargeOff Transaction
GetJournalEntriesTransactionIdResponse journalEntriesForChargeOff = journalEntryHelper
.getJournalEntries("L" + chargeOffTransaction.getResourceId().toString());
// verify Journal Entries For ChargeOff Transaction
GetJournalEntriesTransactionIdResponse journalEntriesForChargeOff = journalEntryHelper
.getJournalEntries("L" + chargeOffTransaction.getResourceId().toString());
assertNotNull(journalEntriesForChargeOff);
List<JournalEntryTransactionItem> journalEntries = journalEntriesForChargeOff.getPageItems();
assertEquals(4, journalEntries.size());
assertNotNull(journalEntriesForChargeOff);
List<JournalEntryTransactionItem> journalEntries = journalEntriesForChargeOff.getPageItems();
assertEquals(4, journalEntries.size());
assertEquals(1000, journalEntries.get(3).getAmount());
assertEquals(LocalDate.of(2022, 9, 14), journalEntries.get(3).getTransactionDate());
assertEquals(loansReceivable.getAccountID().longValue(), journalEntries.get(3).getGlAccountId().longValue());
assertEquals("CREDIT", journalEntries.get(3).getEntryType().getValue());
assertEquals(1000, journalEntries.get(3).getAmount());
assertEquals(LocalDate.of(2022, 9, 14), journalEntries.get(3).getTransactionDate());
assertEquals(loansReceivable.getAccountID().longValue(), journalEntries.get(3).getGlAccountId().longValue());
assertEquals("CREDIT", journalEntries.get(3).getEntryType().getValue());
assertEquals(10, journalEntries.get(2).getAmount());
assertEquals(LocalDate.of(2022, 9, 14), journalEntries.get(2).getTransactionDate());
assertEquals(interestFeeReceivable.getAccountID().longValue(), journalEntries.get(2).getGlAccountId().longValue());
assertEquals("CREDIT", journalEntries.get(2).getEntryType().getValue());
assertEquals(10, journalEntries.get(2).getAmount());
assertEquals(LocalDate.of(2022, 9, 14), journalEntries.get(2).getTransactionDate());
assertEquals(interestFeeReceivable.getAccountID().longValue(), journalEntries.get(2).getGlAccountId().longValue());
assertEquals("CREDIT", journalEntries.get(2).getEntryType().getValue());
assertEquals(1000, journalEntries.get(1).getAmount());
assertEquals(LocalDate.of(2022, 9, 14), journalEntries.get(1).getTransactionDate());
assertEquals(creditLossBadDebt.getAccountID().longValue(), journalEntries.get(1).getGlAccountId().longValue());
assertEquals("DEBIT", journalEntries.get(1).getEntryType().getValue());
assertEquals(1000, journalEntries.get(1).getAmount());
assertEquals(LocalDate.of(2022, 9, 14), journalEntries.get(1).getTransactionDate());
assertEquals(creditLossBadDebt.getAccountID().longValue(), journalEntries.get(1).getGlAccountId().longValue());
assertEquals("DEBIT", journalEntries.get(1).getEntryType().getValue());
assertEquals(10, journalEntries.get(0).getAmount());
assertEquals(LocalDate.of(2022, 9, 14), journalEntries.get(0).getTransactionDate());
assertEquals(feeChargeOff.getAccountID().longValue(), journalEntries.get(0).getGlAccountId().longValue());
assertEquals("DEBIT", journalEntries.get(0).getEntryType().getValue());
assertEquals(10, journalEntries.get(0).getAmount());
assertEquals(LocalDate.of(2022, 9, 14), journalEntries.get(0).getTransactionDate());
assertEquals(feeChargeOff.getAccountID().longValue(), journalEntries.get(0).getGlAccountId().longValue());
assertEquals("DEBIT", journalEntries.get(0).getEntryType().getValue());
// make Repayment before chargeoff date
final PostLoansLoanIdTransactionsResponse repaymentTransaction = loanTransactionHelper.makeLoanRepayment(loanExternalIdStr,
new PostLoansLoanIdTransactionsRequest().dateFormat("dd MMMM yyyy").transactionDate("7 September 2022").locale("en")
.transactionAmount(100.0));
// make Repayment before chargeoff date
final PostLoansLoanIdTransactionsResponse repaymentTransaction = loanTransactionHelper.makeLoanRepayment(loanExternalIdStr,
new PostLoansLoanIdTransactionsRequest().dateFormat("dd MMMM yyyy").transactionDate("7 September 2022").locale("en")
.transactionAmount(100.0));
loanDetails = loanTransactionHelper.getLoanDetails((long) loanId);
assertTrue(loanDetails.getStatus().getActive());
assertTrue(loanDetails.getChargedOff());
loanDetails = loanTransactionHelper.getLoanDetails((long) loanId);
assertTrue(loanDetails.getStatus().getActive());
assertTrue(loanDetails.getChargedOff());
// verify Journal Entries for Repayment transaction
// verify Journal Entries for Repayment transaction
GetJournalEntriesTransactionIdResponse journalEntriesForRepayment = journalEntryHelper
.getJournalEntries("L" + repaymentTransaction.getResourceId().toString());
assertNotNull(journalEntriesForRepayment);
GetJournalEntriesTransactionIdResponse journalEntriesForRepayment = journalEntryHelper
.getJournalEntries("L" + repaymentTransaction.getResourceId().toString());
assertNotNull(journalEntriesForRepayment);
journalEntries = journalEntriesForRepayment.getPageItems();
assertEquals(3, journalEntries.size());
journalEntries = journalEntriesForRepayment.getPageItems();
assertEquals(3, journalEntries.size());
assertEquals(90, journalEntries.get(2).getAmount());
assertEquals(LocalDate.of(2022, 9, 7), journalEntries.get(2).getTransactionDate());
assertEquals(loansReceivable.getAccountID().longValue(), journalEntries.get(2).getGlAccountId().longValue());
assertEquals("CREDIT", journalEntries.get(2).getEntryType().getValue());
assertEquals(90, journalEntries.get(2).getAmount());
assertEquals(LocalDate.of(2022, 9, 7), journalEntries.get(2).getTransactionDate());
assertEquals(loansReceivable.getAccountID().longValue(), journalEntries.get(2).getGlAccountId().longValue());
assertEquals("CREDIT", journalEntries.get(2).getEntryType().getValue());
assertEquals(10, journalEntries.get(1).getAmount());
assertEquals(LocalDate.of(2022, 9, 7), journalEntries.get(1).getTransactionDate());
assertEquals(interestFeeReceivable.getAccountID().longValue(), journalEntries.get(1).getGlAccountId().longValue());
assertEquals("CREDIT", journalEntries.get(1).getEntryType().getValue());
assertEquals(10, journalEntries.get(1).getAmount());
assertEquals(LocalDate.of(2022, 9, 7), journalEntries.get(1).getTransactionDate());
assertEquals(interestFeeReceivable.getAccountID().longValue(), journalEntries.get(1).getGlAccountId().longValue());
assertEquals("CREDIT", journalEntries.get(1).getEntryType().getValue());
assertEquals(100, journalEntries.get(0).getAmount());
assertEquals(LocalDate.of(2022, 9, 7), journalEntries.get(0).getTransactionDate());
assertEquals(suspenseClearingAccount.getAccountID().longValue(), journalEntries.get(0).getGlAccountId().longValue());
assertEquals("DEBIT", journalEntries.get(0).getEntryType().getValue());
assertEquals(100, journalEntries.get(0).getAmount());
assertEquals(LocalDate.of(2022, 9, 7), journalEntries.get(0).getTransactionDate());
assertEquals(suspenseClearingAccount.getAccountID().longValue(), journalEntries.get(0).getGlAccountId().longValue());
assertEquals("DEBIT", journalEntries.get(0).getEntryType().getValue());
// Goodwill Credit before chargeoff date
final PostLoansLoanIdTransactionsResponse goodwillCredit = loanTransactionHelper.makeGoodwillCredit((long) loanId,
new PostLoansLoanIdTransactionsRequest().dateFormat("dd MMMM yyyy").transactionDate("10 September 2022").locale("en")
.transactionAmount(100.0));
// Goodwill Credit before chargeoff date
final PostLoansLoanIdTransactionsResponse goodwillCredit = loanTransactionHelper.makeGoodwillCredit((long) loanId,
new PostLoansLoanIdTransactionsRequest().dateFormat("dd MMMM yyyy").transactionDate("10 September 2022").locale("en")
.transactionAmount(100.0));
loanDetails = loanTransactionHelper.getLoanDetails((long) loanId);
assertTrue(loanDetails.getStatus().getActive());
assertTrue(loanDetails.getChargedOff());
loanDetails = loanTransactionHelper.getLoanDetails((long) loanId);
assertTrue(loanDetails.getStatus().getActive());
assertTrue(loanDetails.getChargedOff());
// verify Journal Entries for Goodwill Credit
GetJournalEntriesTransactionIdResponse journalEntriesForGoodWillCredit = journalEntryHelper
.getJournalEntries("L" + goodwillCredit.getResourceId().toString());
assertNotNull(journalEntriesForGoodWillCredit);
// verify Journal Entries for Goodwill Credit
GetJournalEntriesTransactionIdResponse journalEntriesForGoodWillCredit = journalEntryHelper
.getJournalEntries("L" + goodwillCredit.getResourceId().toString());
assertNotNull(journalEntriesForGoodWillCredit);
journalEntries = journalEntriesForGoodWillCredit.getPageItems();
assertEquals(2, journalEntries.size());
journalEntries = journalEntriesForGoodWillCredit.getPageItems();
assertEquals(2, journalEntries.size());
assertEquals(100, journalEntries.get(1).getAmount());
assertEquals(LocalDate.of(2022, 9, 10), journalEntries.get(1).getTransactionDate());
assertEquals(loansReceivable.getAccountID().longValue(), journalEntries.get(1).getGlAccountId().longValue());
assertEquals("CREDIT", journalEntries.get(1).getEntryType().getValue());
assertEquals(100, journalEntries.get(1).getAmount());
assertEquals(LocalDate.of(2022, 9, 10), journalEntries.get(1).getTransactionDate());
assertEquals(loansReceivable.getAccountID().longValue(), journalEntries.get(1).getGlAccountId().longValue());
assertEquals("CREDIT", journalEntries.get(1).getEntryType().getValue());
assertEquals(100, journalEntries.get(0).getAmount());
assertEquals(LocalDate.of(2022, 9, 10), journalEntries.get(0).getTransactionDate());
assertEquals(goodwillExpenseAccount.getAccountID().longValue(), journalEntries.get(0).getGlAccountId().longValue());
assertEquals("DEBIT", journalEntries.get(0).getEntryType().getValue());
assertEquals(100, journalEntries.get(0).getAmount());
assertEquals(LocalDate.of(2022, 9, 10), journalEntries.get(0).getTransactionDate());
assertEquals(goodwillExpenseAccount.getAccountID().longValue(), journalEntries.get(0).getGlAccountId().longValue());
assertEquals("DEBIT", journalEntries.get(0).getEntryType().getValue());
// make Repayment after chargeoff date
final PostLoansLoanIdTransactionsResponse repaymentTransaction_1 = loanTransactionHelper.makeLoanRepayment(loanExternalIdStr,
new PostLoansLoanIdTransactionsRequest().dateFormat("dd MMMM yyyy").transactionDate("15 September 2022").locale("en")
.transactionAmount(100.0));
updateBusinessDate("16 September 2022");
loanDetails = loanTransactionHelper.getLoanDetails((long) loanId);
assertTrue(loanDetails.getStatus().getActive());
assertTrue(loanDetails.getChargedOff());
// make Repayment after chargeoff date
final PostLoansLoanIdTransactionsResponse repaymentTransaction_1 = loanTransactionHelper.makeLoanRepayment(loanExternalIdStr,
new PostLoansLoanIdTransactionsRequest().dateFormat("dd MMMM yyyy").transactionDate("15 September 2022").locale("en")
.transactionAmount(100.0));
// verify Journal Entries for Repayment transaction
journalEntriesForRepayment = journalEntryHelper.getJournalEntries("L" + repaymentTransaction_1.getResourceId().toString());
loanDetails = loanTransactionHelper.getLoanDetails((long) loanId);
assertTrue(loanDetails.getStatus().getActive());
assertTrue(loanDetails.getChargedOff());
assertNotNull(journalEntriesForRepayment);
// verify Journal Entries for Repayment transaction
journalEntriesForRepayment = journalEntryHelper.getJournalEntries("L" + repaymentTransaction_1.getResourceId().toString());
journalEntries = journalEntriesForRepayment.getPageItems();
assertEquals(2, journalEntries.size());
assertNotNull(journalEntriesForRepayment);
assertEquals(100, journalEntries.get(1).getAmount());
assertEquals(LocalDate.of(2022, 9, 15), journalEntries.get(1).getTransactionDate());
assertEquals(recoveries.getAccountID().longValue(), journalEntries.get(1).getGlAccountId().longValue());
assertEquals("CREDIT", journalEntries.get(1).getEntryType().getValue());
journalEntries = journalEntriesForRepayment.getPageItems();
assertEquals(2, journalEntries.size());
assertEquals(100, journalEntries.get(0).getAmount());
assertEquals(LocalDate.of(2022, 9, 15), journalEntries.get(0).getTransactionDate());
assertEquals(suspenseClearingAccount.getAccountID().longValue(), journalEntries.get(0).getGlAccountId().longValue());
assertEquals("DEBIT", journalEntries.get(0).getEntryType().getValue());
assertEquals(100, journalEntries.get(1).getAmount());
assertEquals(LocalDate.of(2022, 9, 15), journalEntries.get(1).getTransactionDate());
assertEquals(recoveries.getAccountID().longValue(), journalEntries.get(1).getGlAccountId().longValue());
assertEquals("CREDIT", journalEntries.get(1).getEntryType().getValue());
// Goodwill Credit after chargeoff date
final PostLoansLoanIdTransactionsResponse goodwillCredit_1 = loanTransactionHelper.makeGoodwillCredit((long) loanId,
new PostLoansLoanIdTransactionsRequest().dateFormat("dd MMMM yyyy").transactionDate("16 September 2022").locale("en")
.transactionAmount(100.0));
assertEquals(100, journalEntries.get(0).getAmount());
assertEquals(LocalDate.of(2022, 9, 15), journalEntries.get(0).getTransactionDate());
assertEquals(suspenseClearingAccount.getAccountID().longValue(), journalEntries.get(0).getGlAccountId().longValue());
assertEquals("DEBIT", journalEntries.get(0).getEntryType().getValue());
loanDetails = loanTransactionHelper.getLoanDetails((long) loanId);
assertTrue(loanDetails.getStatus().getActive());
assertTrue(loanDetails.getChargedOff());
// Goodwill Credit after chargeoff date
final PostLoansLoanIdTransactionsResponse goodwillCredit_1 = loanTransactionHelper.makeGoodwillCredit((long) loanId,
new PostLoansLoanIdTransactionsRequest().dateFormat("dd MMMM yyyy").transactionDate("16 September 2022").locale("en")
.transactionAmount(100.0));
// verify Journal Entries for Goodwill Credit
journalEntriesForGoodWillCredit = journalEntryHelper.getJournalEntries("L" + goodwillCredit_1.getResourceId().toString());
assertNotNull(journalEntriesForGoodWillCredit);
loanDetails = loanTransactionHelper.getLoanDetails((long) loanId);
assertTrue(loanDetails.getStatus().getActive());
assertTrue(loanDetails.getChargedOff());
journalEntries = journalEntriesForGoodWillCredit.getPageItems();
assertEquals(2, journalEntries.size());
// verify Journal Entries for Goodwill Credit
journalEntriesForGoodWillCredit = journalEntryHelper.getJournalEntries("L" + goodwillCredit_1.getResourceId().toString());
assertNotNull(journalEntriesForGoodWillCredit);
assertEquals(100, journalEntries.get(1).getAmount());
assertEquals(LocalDate.of(2022, 9, 16), journalEntries.get(1).getTransactionDate());
assertEquals(recoveries.getAccountID().longValue(), journalEntries.get(1).getGlAccountId().longValue());
assertEquals("CREDIT", journalEntries.get(1).getEntryType().getValue());
journalEntries = journalEntriesForGoodWillCredit.getPageItems();
assertEquals(2, journalEntries.size());
assertEquals(100, journalEntries.get(0).getAmount());
assertEquals(LocalDate.of(2022, 9, 16), journalEntries.get(0).getTransactionDate());
assertEquals(goodwillExpenseAccount.getAccountID().longValue(), journalEntries.get(0).getGlAccountId().longValue());
assertEquals("DEBIT", journalEntries.get(0).getEntryType().getValue());
assertEquals(100, journalEntries.get(1).getAmount());
assertEquals(LocalDate.of(2022, 9, 16), journalEntries.get(1).getTransactionDate());
assertEquals(recoveries.getAccountID().longValue(), journalEntries.get(1).getGlAccountId().longValue());
assertEquals("CREDIT", journalEntries.get(1).getEntryType().getValue());
assertEquals(100, journalEntries.get(0).getAmount());
assertEquals(LocalDate.of(2022, 9, 16), journalEntries.get(0).getTransactionDate());
assertEquals(goodwillExpenseAccount.getAccountID().longValue(), journalEntries.get(0).getGlAccountId().longValue());
assertEquals("DEBIT", journalEntries.get(0).getEntryType().getValue());
});
}
@Test
@@ -1353,7 +1353,7 @@ public class LoanTransactionInterestPaymentWaiverTest extends BaseLoanIntegratio
// reverse 4 - 1 Interest Payment Waiver transactions
@Test
public void testInterestPaymentWaiverTransactionAccountingAccuralForInterestPenaltyFeeOverpaymentChargeOFFLoan() {
runAt("15 May 2023", () -> {
runAt("2 January 2023", () -> {
final String disbursementDay = "01 January 2023";
final String repaymentPeriod1DueDate = "01 February 2023";
@@ -1385,6 +1385,8 @@ public class LoanTransactionInterestPaymentWaiverTest extends BaseLoanIntegratio
new PostLoansLoanIdTransactionsRequest().transactionDate("2 January 2023").locale("en").dateFormat("dd MMMM yyyy")
.externalId(transactionExternalId).chargeOffReasonId((long) chargeOffReasonId));
updateBusinessDate("15 May 2023");
GetLoansLoanIdResponse loanDetails = loanTransactionHelper.getLoanDetails(loanId);
validateLoanSummaryBalances(loanDetails, 1260.0, 0.0, 1000.0, 0.0, null);
validateRepaymentPeriod(loanDetails, 1, LocalDate.of(2023, 2, 1), 250.0, 0.0, 250.0, 40.0, 0.0, 40.0, 30.0, 0.0, 30.0, 20.0,