FINERACT-1981: Fix interest calculation logic (rounding issues with sub interest periods)
This commit is contained in:
+6
-6
@@ -5013,10 +5013,10 @@ public class AdvancedPaymentAllocationLoanRepaymentScheduleTest extends BaseLoan
|
||||
.transactionAmount(BigDecimal.valueOf(200.0)).locale("en"));
|
||||
|
||||
loanDetails = loanTransactionHelper.getLoanDetails(loanResponse.getLoanId());
|
||||
validateLoanSummaryBalances(loanDetails, 307.99, 0.0, 300.0, 0.0, null);
|
||||
validateLoanSummaryBalances(loanDetails, 307.98, 0.0, 300.0, 0.0, null);
|
||||
|
||||
validateRepaymentPeriod(loanDetails, 1, LocalDate.of(2024, 2, 1), 49.31, 0.0, 49.31, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.02, 0.0,
|
||||
2.02, 0.0, 0.0);
|
||||
validateRepaymentPeriod(loanDetails, 1, LocalDate.of(2024, 2, 1), 49.32, 0.0, 49.32, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.01, 0.0,
|
||||
2.01, 0.0, 0.0);
|
||||
validateRepaymentPeriod(loanDetails, 2, LocalDate.of(2024, 3, 1), 49.35, 0.0, 49.35, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.98, 0.0,
|
||||
1.98, 0.0, 0.0);
|
||||
validateRepaymentPeriod(loanDetails, 3, LocalDate.of(2024, 4, 1), 49.74, 0.0, 49.74, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.59, 0.0,
|
||||
@@ -5025,7 +5025,7 @@ public class AdvancedPaymentAllocationLoanRepaymentScheduleTest extends BaseLoan
|
||||
1.20, 0.0, 0.0);
|
||||
validateRepaymentPeriod(loanDetails, 5, LocalDate.of(2024, 6, 1), 50.53, 0.0, 50.53, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.80, 0.0,
|
||||
0.80, 0.0, 0.0);
|
||||
validateRepaymentPeriod(loanDetails, 6, LocalDate.of(2024, 7, 1), 50.94, 0.0, 50.94, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.40, 0.0,
|
||||
validateRepaymentPeriod(loanDetails, 6, LocalDate.of(2024, 7, 1), 50.93, 0.0, 50.93, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.40, 0.0,
|
||||
0.40, 0.0, 0.0);
|
||||
assertTrue(loanDetails.getStatus().getActive());
|
||||
assertEquals(loanDetails.getNumberOfRepayments(), 6);
|
||||
@@ -5724,8 +5724,8 @@ public class AdvancedPaymentAllocationLoanRepaymentScheduleTest extends BaseLoan
|
||||
// On the due date of 2nd period
|
||||
prepayAmounts = loanTransactionHelper.getPrepayAmount(requestSpec, responseSpec, createdLoanId.intValue(),
|
||||
LocalDate.of(2024, 3, 1));
|
||||
assertEquals(79.05f, prepayAmounts.get("amount"));
|
||||
assertEquals(0.48f, prepayAmounts.get("interestPortion"));
|
||||
assertEquals(79.04f, prepayAmounts.get("amount"));
|
||||
assertEquals(0.47f, prepayAmounts.get("interestPortion"));
|
||||
assertEquals(78.57f, prepayAmounts.get("principalPortion"));
|
||||
|
||||
loanTransactionHelper.makeLoanRepayment(createdLoanId.get(), new PostLoansLoanIdTransactionsRequest()
|
||||
|
||||
+2
-2
@@ -1119,8 +1119,8 @@ public abstract class BaseLoanIntegrationTest extends IntegrationTest {
|
||||
return new Journal(amount, account, "CREDIT");
|
||||
}
|
||||
|
||||
protected Transaction transaction(double principalAmount, String type, String date) {
|
||||
return new Transaction(principalAmount, type, date, null);
|
||||
protected Transaction transaction(double amount, String type, String date) {
|
||||
return new Transaction(amount, type, date, null);
|
||||
}
|
||||
|
||||
protected Transaction reversedTransaction(double principalAmount, String type, String date) {
|
||||
|
||||
+4
-4
@@ -388,8 +388,8 @@ public class LoanInterestRecalculationCOBTest extends BaseLoanIntegrationTest {
|
||||
validateFullyPaidRepaymentPeriod(loanDetails, 1, "01 February 2023", 1975.17, 0.0, 0.0, 66.67);
|
||||
validateRepaymentPeriod(loanDetails, 2, LocalDate.of(2023, 3, 1), 1991.63, 1041.84, 949.79, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 50.21,
|
||||
0, 50.21, 0, 1041.84);
|
||||
validateFullyUnpaidRepaymentPeriod(loanDetails, 3, "01 April 2023", 2000.85, 0.0, 0.0, 40.99);
|
||||
validateFullyUnpaidRepaymentPeriod(loanDetails, 4, "01 May 2023", 2032.35, 0.0, 0.0, 16.94);
|
||||
validateFullyUnpaidRepaymentPeriod(loanDetails, 3, "01 April 2023", 2000.86, 0.0, 0.0, 40.98);
|
||||
validateFullyUnpaidRepaymentPeriod(loanDetails, 4, "01 May 2023", 2032.34, 0.0, 0.0, 16.94);
|
||||
|
||||
loanTransactionHelper.makeLoanRepayment("20 March 2023", 1000f, loanId.intValue());
|
||||
|
||||
@@ -398,8 +398,8 @@ public class LoanInterestRecalculationCOBTest extends BaseLoanIntegrationTest {
|
||||
|
||||
validateFullyPaidRepaymentPeriod(loanDetails, 1, "01 February 2023", 1975.17, 0.0, 0.0, 66.67);
|
||||
validateFullyPaidRepaymentPeriod(loanDetails, 2, "01 March 2023", 1991.63, 0.0, 0.0, 50.21, 2041.84);
|
||||
validateFullyUnpaidRepaymentPeriod(loanDetails, 3, "01 April 2023", 2000.85, 0.0, 0.0, 40.99);
|
||||
validateFullyUnpaidRepaymentPeriod(loanDetails, 4, "01 May 2023", 2032.35, 0.0, 0.0, 16.94);
|
||||
validateFullyUnpaidRepaymentPeriod(loanDetails, 3, "01 April 2023", 2000.86, 0.0, 0.0, 40.98);
|
||||
validateFullyUnpaidRepaymentPeriod(loanDetails, 4, "01 May 2023", 2032.34, 0.0, 0.0, 16.94);
|
||||
});
|
||||
payoffOnDateAndVerifyStatus("1 April 2023", loanIdRef.get());
|
||||
}
|
||||
|
||||
+36
-13
@@ -636,8 +636,8 @@ public class LoanInterestRefundTest extends BaseLoanIntegrationTest {
|
||||
verifyTransactions(loanId, transaction(750.0, "Disbursement", "04 January 2021"), //
|
||||
transaction(250.0, "Disbursement", "01 January 2021"), //
|
||||
transaction(1000.0, "Payout Refund", "22 January 2021"), //
|
||||
transaction(5.14, "Accrual", "22 January 2021"), //
|
||||
transaction(5.14, "Interest Refund", "22 January 2021") //
|
||||
transaction(5.13, "Accrual", "22 January 2021"), //
|
||||
transaction(5.13, "Interest Refund", "22 January 2021") //
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -889,7 +889,7 @@ public class LoanInterestRefundTest extends BaseLoanIntegrationTest {
|
||||
transaction(171.29, "Repayment", "01 May 2021"), //
|
||||
transaction(171.29, "Repayment", "01 June 2021"), //
|
||||
transaction(171.32, "Repayment", "01 July 2021"), //
|
||||
transaction(27.76, "Accrual", "01 July 2021") //
|
||||
transaction(27.77, "Accrual", "01 July 2021") //
|
||||
); //
|
||||
});
|
||||
runAt("11 July 2021", () -> {
|
||||
@@ -909,8 +909,8 @@ public class LoanInterestRefundTest extends BaseLoanIntegrationTest {
|
||||
transaction(171.29, "Repayment", "01 June 2021"), //
|
||||
transaction(171.32, "Repayment", "01 July 2021"), //
|
||||
transaction(500.0, "Payout Refund", "11 July 2021"), //
|
||||
transaction(20.40, "Interest Refund", "11 July 2021"), //
|
||||
transaction(27.76, "Accrual", "01 July 2021") //
|
||||
transaction(20.41, "Interest Refund", "11 July 2021"), //
|
||||
transaction(27.77, "Accrual", "01 July 2021") //
|
||||
); //
|
||||
});
|
||||
}
|
||||
@@ -1048,7 +1048,17 @@ public class LoanInterestRefundTest extends BaseLoanIntegrationTest {
|
||||
});
|
||||
runAt("1 February 2021", () -> {
|
||||
Long loanId = loanIdRef.get();
|
||||
loanTransactionHelper.makeLoanRepayment("Repayment", "1 February 2021", 100.85F, loanId.intValue());
|
||||
loanTransactionHelper.makeLoanRepayment("Repayment", "1 February 2021", 100.84F, loanId.intValue());
|
||||
|
||||
verifyTransactions(loanId, transaction(250.0, "Disbursement", "01 January 2021"), //
|
||||
transaction(750.0, "Disbursement", "01 January 2021"), //
|
||||
transaction(500.0, "Merchant Issued Refund", "22 January 2021"), //
|
||||
transaction(2.88, "Interest Refund", "22 January 2021"), //
|
||||
transaction(400.0, "Payout Refund", "26 January 2021"), //
|
||||
transaction(2.74, "Interest Refund", "26 January 2021"), //
|
||||
transaction(100.84, "Repayment", "01 February 2021"), //
|
||||
transaction(6.46, "Accrual", "01 February 2021")); //
|
||||
|
||||
GetLoansLoanIdResponse loanDetails = loanTransactionHelper.getLoanDetails(loanId);
|
||||
Assertions.assertNotNull(loanDetails);
|
||||
Assertions.assertNotNull(loanDetails.getStatus());
|
||||
@@ -1110,9 +1120,22 @@ public class LoanInterestRefundTest extends BaseLoanIntegrationTest {
|
||||
Long loanId = loanIdRef.get();
|
||||
loanTransactionHelper.makeLoanRepayment("Repayment", "1 February 2021", 171.41F, loanId.intValue());
|
||||
loanTransactionHelper.makeLoanRepayment("Repayment", "1 March 2021", 171.41F, loanId.intValue());
|
||||
loanTransactionHelper.makeLoanRepayment("Repayment", "1 April 2021", 11.25F, loanId.intValue());
|
||||
GetLoansLoanIdResponse loanDetails = loanTransactionHelper.getLoanDetails(loanId);
|
||||
loanTransactionHelper.makeLoanRepayment("Repayment", "1 April 2021", 11.24F, loanId.intValue());
|
||||
|
||||
verifyTransactions(loanId, transaction(200.0, "Disbursement", "01 January 2021"), //
|
||||
transaction(300.0, "Disbursement", "01 January 2021"), //
|
||||
transaction(500.0, "Disbursement", "05 January 2021"), //
|
||||
transaction(250.0, "Merchant Issued Refund", "22 January 2021"), //
|
||||
transaction(1.44, "Interest Refund", "22 January 2021"), //
|
||||
transaction(400.0, "Payout Refund", "26 January 2021"), //
|
||||
transaction(2.58, "Interest Refund", "26 January 2021"), //
|
||||
transaction(171.41, "Repayment", "01 February 2021"), //
|
||||
transaction(171.41, "Repayment", "01 March 2021"), //
|
||||
transaction(11.24, "Repayment", "01 April 2021"), //
|
||||
transaction(8.08, "Accrual", "01 April 2021") //
|
||||
);
|
||||
|
||||
GetLoansLoanIdResponse loanDetails = loanTransactionHelper.getLoanDetails(loanId);
|
||||
Assertions.assertNotNull(loanDetails);
|
||||
Assertions.assertNotNull(loanDetails.getStatus());
|
||||
Assertions.assertEquals(600, loanDetails.getStatus().getId());
|
||||
@@ -1159,7 +1182,7 @@ public class LoanInterestRefundTest extends BaseLoanIntegrationTest {
|
||||
transaction(500.0, "Disbursement", "05 January 2021"), //
|
||||
transaction(171.41, "Repayment", "01 February 2021"), //
|
||||
transaction(250.0, "Payout Refund", "13 February 2021"), //
|
||||
transaction(2.96, "Interest Refund", "13 February 2021") //
|
||||
transaction(2.95, "Interest Refund", "13 February 2021") //
|
||||
);
|
||||
});
|
||||
runAt("24 February 2021", () -> {
|
||||
@@ -1171,7 +1194,7 @@ public class LoanInterestRefundTest extends BaseLoanIntegrationTest {
|
||||
transaction(500.0, "Disbursement", "05 January 2021"), //
|
||||
transaction(171.41, "Repayment", "01 February 2021"), //
|
||||
transaction(250.0, "Payout Refund", "13 February 2021"), //
|
||||
transaction(2.96, "Interest Refund", "13 February 2021"), //
|
||||
transaction(2.95, "Interest Refund", "13 February 2021"), //
|
||||
transaction(400.0, "Merchant Issued Refund", "24 February 2021"), //
|
||||
transaction(5.77, "Interest Refund", "24 February 2021") //
|
||||
);
|
||||
@@ -1228,7 +1251,7 @@ public class LoanInterestRefundTest extends BaseLoanIntegrationTest {
|
||||
transaction(500.0, "Disbursement", "05 January 2021"), //
|
||||
transaction(171.41, "Repayment", "01 February 2021"), //
|
||||
transaction(250.0, "Payout Refund", "13 February 2021"), //
|
||||
transaction(2.96, "Interest Refund", "13 February 2021") //
|
||||
transaction(2.95, "Interest Refund", "13 February 2021") //
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1248,9 +1271,9 @@ public class LoanInterestRefundTest extends BaseLoanIntegrationTest {
|
||||
transaction(171.41, "Repayment", "01 March 2021"), //
|
||||
transaction(171.41, "Repayment", "01 April 2021"), //
|
||||
transaction(250.0, "Payout Refund", "13 February 2021"), //
|
||||
transaction(2.96, "Interest Refund", "13 February 2021"), //
|
||||
transaction(2.95, "Interest Refund", "13 February 2021"), //
|
||||
transaction(400.0, "Merchant Issued Refund", "06 April 2021"), //
|
||||
transaction(10.11, "Interest Refund", "06 April 2021"), //
|
||||
transaction(10.12, "Interest Refund", "06 April 2021"), //
|
||||
transaction(17.14, "Accrual", "06 April 2021") //
|
||||
);
|
||||
GetLoansLoanIdResponse loanDetails = loanTransactionHelper.getLoanDetails(loanId);
|
||||
|
||||
+4
-4
@@ -1019,10 +1019,10 @@ public class LoanTransactionChargebackTest extends BaseLoanIntegrationTest {
|
||||
installment(100.0, null, "01 January 2024"), //
|
||||
fullyRepaidInstallment(16.43, 0.58, "01 February 2024"), //
|
||||
fullyRepaidInstallment(16.52, 0.49, "01 March 2024"), //
|
||||
unpaidInstallment(33.08, 0.94, "01 April 2024"), //
|
||||
unpaidInstallment(33.09, 0.93, "01 April 2024"), //
|
||||
unpaidInstallment(16.72, 0.29, "01 May 2024"), //
|
||||
unpaidInstallment(16.81, 0.20, "01 June 2024"), //
|
||||
unpaidInstallment(16.96, 0.10, "01 July 2024") //
|
||||
unpaidInstallment(16.95, 0.10, "01 July 2024") //
|
||||
); //
|
||||
verifyTransactions(loanId,
|
||||
new TransactionExt(100.0, "Disbursement", "01 January 2024", 100.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, false),
|
||||
@@ -1249,10 +1249,10 @@ public class LoanTransactionChargebackTest extends BaseLoanIntegrationTest {
|
||||
installment(100.0, null, "01 January 2024"), //
|
||||
fullyRepaidInstallment(16.43, 0.58, "01 February 2024"), //
|
||||
fullyRepaidInstallment(16.52, 0.49, "01 March 2024"), //
|
||||
unpaidInstallment(33.08, 0.94, "01 April 2024"), //
|
||||
unpaidInstallment(33.09, 0.93, "01 April 2024"), //
|
||||
unpaidInstallment(16.72, 0.29, "01 May 2024"), //
|
||||
unpaidInstallment(16.81, 0.20, "01 June 2024"), //
|
||||
unpaidInstallment(16.96, 0.10, "01 July 2024") //
|
||||
unpaidInstallment(16.95, 0.10, "01 July 2024") //
|
||||
); //
|
||||
verifyTransactions(loanId,
|
||||
new TransactionExt(100.0, "Disbursement", "01 January 2024", 100.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, false),
|
||||
|
||||
Reference in New Issue
Block a user