somasorosdpc commented on code in PR #4116:
URL: https://github.com/apache/fineract/pull/4116#discussion_r1822184425
##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanInterestRefundTest.java:
##########
@@ -432,6 +435,285 @@ public void verifyUC05() {
});
}
+ @Test
+ public void verifyUC06() {
+ AtomicReference<Long> loanIdRef = new AtomicReference<>();
+ runAt("1 December 2020", () -> {
+ PostLoanProductsResponse loanProduct = loanProductHelper
+
.createLoanProduct(create4IProgressive().daysInMonthType(DaysInMonthType.ACTUAL)
//
+ .daysInYearType(DaysInYearType.ACTUAL) //
+ .supportedInterestRefundTypes(new
ArrayList<>()).addSupportedInterestRefundTypesItem("PAYOUT_REFUND") //
+
.addSupportedInterestRefundTypesItem("MERCHANT_ISSUED_REFUND") //
+
.recalculationRestFrequencyType(RecalculationRestFrequencyType.DAILY) //
+ );
+ Long loanId = applyAndApproveProgressiveLoan(client.getClientId(),
loanProduct.getResourceId(), "1 December 2020", 1000.0, 9.99,
+ 6, null);
+ Assertions.assertNotNull(loanId);
+ loanIdRef.set(loanId);
+ disburseLoan(loanId, BigDecimal.valueOf(1000), "1 December 2020");
+
+ });
+ runAt("14 December 2020", () -> {
+ Long loanId = loanIdRef.get();
+ PostLoansLoanIdTransactionsResponse
postLoansLoanIdTransactionsResponse = loanTransactionHelper
+ .makeLoanRepayment("PayoutRefund", "14 December 2020",
500F, loanId.intValue());
+ Assertions.assertNotNull(postLoansLoanIdTransactionsResponse);
+
Assertions.assertNotNull(postLoansLoanIdTransactionsResponse.getResourceId());
+
+ logTransactions(loanId);
+ verifyTransactions(loanId, transaction(1000.0, "Disbursement", "01
December 2020"), //
+ transaction(500.0, "Payout Refund", "14 December 2020"), //
+ transaction(1.78, "Interest Refund", "14 December 2020"));
+ });
+ }
+
+ @Test
+ public void verifyUC07() {
+ AtomicReference<Long> loanIdRef = new AtomicReference<>();
+ runAt("1 January 2021", () -> {
+ PostLoanProductsResponse loanProduct = loanProductHelper
+
.createLoanProduct(create4IProgressive().daysInMonthType(DaysInMonthType.ACTUAL)
//
+ .daysInYearType(DaysInYearType.ACTUAL) //
+ .supportedInterestRefundTypes(new
ArrayList<>()).addSupportedInterestRefundTypesItem("PAYOUT_REFUND") //
+
.addSupportedInterestRefundTypesItem("MERCHANT_ISSUED_REFUND") //
+
.recalculationRestFrequencyType(RecalculationRestFrequencyType.DAILY) //
+ );
+ Long loanId = applyAndApproveProgressiveLoan(client.getClientId(),
loanProduct.getResourceId(), "1 January 2021", 1000.0, 9.99,
+ 12, null);
+ Assertions.assertNotNull(loanId);
+ loanIdRef.set(loanId);
+ disburseLoan(loanId, BigDecimal.valueOf(1000), "1 January 2021");
+
+ GetLoansLoanIdResponse loanDetails =
loanTransactionHelper.getLoanDetails(loanId);
+ logLoanDetails(loanDetails);
+ });
+ runAt("1 February 2021", () -> {
+ Long loanId = loanIdRef.get();
+ PostLoansLoanIdTransactionsResponse
postLoansLoanIdTransactionsResponse =
loanTransactionHelper.makeLoanRepayment("Repayment",
+ "1 February 2021", 87.89F, loanId.intValue());
+ Assertions.assertNotNull(postLoansLoanIdTransactionsResponse);
+
Assertions.assertNotNull(postLoansLoanIdTransactionsResponse.getResourceId());
+
+ logTransactions(loanId);
+ verifyTransactions(loanId, transaction(1000.0, "Disbursement", "01
January 2021"), //
+ transaction(87.89, "Repayment", "01 February 2021"));
+ });
+ runAt("9 February 2021", () -> {
+ Long loanId = loanIdRef.get();
+ PostLoansLoanIdTransactionsResponse
postLoansLoanIdTransactionsResponse = loanTransactionHelper
+ .makeLoanRepayment("PayoutRefund", "09 February 2021",
500F, loanId.intValue());
+ Assertions.assertNotNull(postLoansLoanIdTransactionsResponse);
+
Assertions.assertNotNull(postLoansLoanIdTransactionsResponse.getResourceId());
+
+ logTransactions(loanId);
+ verifyTransactions(loanId, transaction(1000.0, "Disbursement", "01
January 2021"), //
+ transaction(87.89, "Repayment", "01 February 2021"), //
+ transaction(500.0, "Payout Refund", "09 February 2021"), //
+ transaction(5.35, "Interest Refund", "09 February 2021"));
+ });
+ }
+
+ @Test
+ public void verifyUC08() {
+ AtomicReference<Long> loanIdRef = new AtomicReference<>();
+ runAt("1 January 2021", () -> {
+ PostLoanProductsResponse loanProduct = loanProductHelper
+
.createLoanProduct(create4IProgressive().daysInMonthType(DaysInMonthType.ACTUAL)
//
+ .daysInYearType(DaysInYearType.ACTUAL) //
+ .supportedInterestRefundTypes(new ArrayList<>())//
+ .disallowExpectedDisbursements(true)//
+ .multiDisburseLoan(true)//
+
.maxTrancheCount(2).addSupportedInterestRefundTypesItem("PAYOUT_REFUND") //
+
.addSupportedInterestRefundTypesItem("MERCHANT_ISSUED_REFUND") //
+
.recalculationRestFrequencyType(RecalculationRestFrequencyType.DAILY) //
+ );
+ Long loanId = applyAndApproveProgressiveLoan(client.getClientId(),
loanProduct.getResourceId(), "1 January 2021", 1000.0, 9.99,
+ 6, null);
+ Assertions.assertNotNull(loanId);
+ loanIdRef.set(loanId);
+ disburseLoan(loanId, BigDecimal.valueOf(250), "1 January 2021");
+ disburseLoan(loanId, BigDecimal.valueOf(750), "1 January 2021");
+ });
+ runAt("22 January 2021", () -> {
+ Long loanId = loanIdRef.get();
+ PostLoansLoanIdTransactionsResponse
postLoansLoanIdTransactionsResponse = loanTransactionHelper
+ .makeLoanRepayment("PayoutRefund", "22 January 2021",
500F, loanId.intValue());
+ Assertions.assertNotNull(postLoansLoanIdTransactionsResponse);
+
Assertions.assertNotNull(postLoansLoanIdTransactionsResponse.getResourceId());
+
+ logTransactions(loanId);
+ verifyTransactions(loanId, transaction(250.0, "Disbursement", "01
January 2021"), //
+ transaction(750.0, "Disbursement", "01 January 2021"), //
+ transaction(500.0, "Payout Refund", "22 January 2021"), //
+ // transaction(5.75, "Accrual", "22 January 2021"), //
+ transaction(2.88, "Interest Refund", "22 January 2021"));
+ });
+ }
+
+ @Test
+ public void verifyUC09() {
+ AtomicReference<Long> loanIdRef = new AtomicReference<>();
+ runAt("1 January 2021", () -> {
+ PostLoanProductsResponse loanProduct = loanProductHelper
+
.createLoanProduct(create4IProgressive().daysInMonthType(DaysInMonthType.ACTUAL)
//
+ .daysInYearType(DaysInYearType.ACTUAL) //
+ .supportedInterestRefundTypes(new
ArrayList<>()).disallowExpectedDisbursements(true).multiDisburseLoan(true)
+
.maxTrancheCount(2).addSupportedInterestRefundTypesItem("PAYOUT_REFUND") //
+
.addSupportedInterestRefundTypesItem("MERCHANT_ISSUED_REFUND") //
+
.recalculationRestFrequencyType(RecalculationRestFrequencyType.DAILY) //
+ );
+ Long loanId = applyAndApproveProgressiveLoan(client.getClientId(),
loanProduct.getResourceId(), "1 January 2021", 1000.0, 9.99,
+ 6, null);
+ Assertions.assertNotNull(loanId);
+ loanIdRef.set(loanId);
+ disburseLoan(loanId, BigDecimal.valueOf(250), "1 January 2021");
+ });
+ runAt("7 January 2021", () -> {
+ Long loanId = loanIdRef.get();
+ disburseLoan(loanId, BigDecimal.valueOf(750), "7 January 2021");
+ });
+ runAt("22 January 2021", () -> {
+ Long loanId = loanIdRef.get();
+ PostLoansLoanIdTransactionsResponse
postLoansLoanIdTransactionsResponse = loanTransactionHelper
+ .makeLoanRepayment("PayoutRefund", "22 January 2021",
500F, loanId.intValue());
+ Assertions.assertNotNull(postLoansLoanIdTransactionsResponse);
+
Assertions.assertNotNull(postLoansLoanIdTransactionsResponse.getResourceId());
+
+ logTransactions(loanId);
+ verifyTransactions(loanId, transaction(250.0, "Disbursement", "01
January 2021"), //
+ transaction(750.0, "Disbursement", "07 January 2021"), //
+ transaction(500.0, "Payout Refund", "22 January 2021"), //
+ // transaction(2.46, "Accrual", "22 January 2021"), //
+ transaction(2.47, "Interest Refund", "22 January 2021"));
+ });
+ }
+
+ @Test
+ public void verifyUC10() {
+ AtomicReference<Long> loanIdRef = new AtomicReference<>();
+ runAt("1 January 2021", () -> {
+ PostLoanProductsResponse loanProduct = loanProductHelper
+
.createLoanProduct(create4IProgressive().daysInMonthType(DaysInMonthType.ACTUAL)
//
+ .daysInYearType(DaysInYearType.ACTUAL) //
+ .supportedInterestRefundTypes(new
ArrayList<>()).disallowExpectedDisbursements(true).multiDisburseLoan(true)
+
.maxTrancheCount(2).addSupportedInterestRefundTypesItem("PAYOUT_REFUND") //
+
.addSupportedInterestRefundTypesItem("MERCHANT_ISSUED_REFUND") //
+
.recalculationRestFrequencyType(RecalculationRestFrequencyType.DAILY) //
+ );
+ Long loanId = applyAndApproveProgressiveLoan(client.getClientId(),
loanProduct.getResourceId(), "1 January 2021", 1000.0, 9.99,
+ 6, null);
+ Assertions.assertNotNull(loanId);
+ loanIdRef.set(loanId);
+ disburseLoan(loanId, BigDecimal.valueOf(250), "1 January 2021");
+
+ });
+ runAt("7 January 2021", () -> {
+ Long loanId = loanIdRef.get();
+ disburseLoan(loanId, BigDecimal.valueOf(750), "7 January 2021");
+
+ GetLoansLoanIdResponse loanDetails =
loanTransactionHelper.getLoanDetails(loanId);
+ logLoanDetails(loanDetails);
+ });
+ runAt("1 July 2021", () -> {
+ Long loanId = loanIdRef.get();
+ loanTransactionHelper.makeLoanRepayment("Repayment", "1 February
2021", 171.29F, loanId.intValue());
+ loanTransactionHelper.makeLoanRepayment("Repayment", "1 March
2021", 171.29F, loanId.intValue());
+ loanTransactionHelper.makeLoanRepayment("Repayment", "1 April
2021", 171.29F, loanId.intValue());
+ loanTransactionHelper.makeLoanRepayment("Repayment", "1 May 2021",
171.29F, loanId.intValue());
+ loanTransactionHelper.makeLoanRepayment("Repayment", "1 June
2021", 171.29F, loanId.intValue());
+ loanTransactionHelper.makeLoanRepayment("Repayment", "1 July
2021", 171.32F, loanId.intValue());
+
+ logTransactions(loanId);
+ verifyTransactions(loanId, transaction(250.0, "Disbursement", "01
January 2021"), //
+ transaction(750.0, "Disbursement", "07 January 2021"), //
+ transaction(171.29, "Repayment", "01 February 2021"), //
+ transaction(171.29, "Repayment", "01 March 2021"), //
+ transaction(171.29, "Repayment", "01 April 2021"), //
+ transaction(171.29, "Repayment", "01 May 2021"), //
+ transaction(171.29, "Repayment", "01 June 2021"), //
+ transaction(171.32, "Repayment", "01 July 2021") //
+ ); //
+ });
+ runAt("11 July 2021", () -> {
+ Long loanId = loanIdRef.get();
+ PostLoansLoanIdTransactionsResponse
postLoansLoanIdTransactionsResponse = loanTransactionHelper
+ .makeLoanRepayment("PayoutRefund", "11 July 2021", 500.0F,
loanId.intValue());
+ Assertions.assertNotNull(postLoansLoanIdTransactionsResponse);
+
Assertions.assertNotNull(postLoansLoanIdTransactionsResponse.getResourceId());
+
+ logTransactions(loanId);
+ verifyTransactions(loanId, transaction(250.0, "Disbursement", "01
January 2021"), //
+ transaction(750.0, "Disbursement", "07 January 2021"), //
+ transaction(171.29, "Repayment", "01 February 2021"), //
+ transaction(171.29, "Repayment", "01 March 2021"), //
+ transaction(171.29, "Repayment", "01 April 2021"), //
+ transaction(171.29, "Repayment", "01 May 2021"), //
+ transaction(171.29, "Repayment", "01 June 2021"), //
+ transaction(171.32, "Repayment", "01 July 2021"), //
+ transaction(500.0, "Payout Refund", "11 July 2021"), //
+ transaction(20.41, "Interest Refund", "11 July 2021")); //
+ });
+ }
+
+ // @Test
Review Comment:
I removed the unused test case too
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]