You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by "somasorosdpc (via GitHub)" <gi...@apache.org> on 2024/10/22 05:51:04 UTC
[PR] FINERACT-2107: Interest Refund - Partial Refund cases [fineract]
somasorosdpc opened a new pull request, #4116:
URL: https://github.com/apache/fineract/pull/4116
## Description
[FINERACT-2107](https://issues.apache.org/jira/browse/FINERACT-2107): Interest Refund - Partial Refund cases
Interest Refund calculation on Payout Refund and Merchant Issued Refund if configured for interest bearing progressive loans. + Integration tests
** covering partial refund in single transaction.
## Checklist
Please make sure these boxes are checked before submitting your pull request - thanks!
- [x] Write the commit message as per https://github.com/apache/fineract/#pull-requests
- [x] Acknowledge that we will not review PRs that are not passing the build _("green")_ - it is your responsibility to get a proposed PR to pass the build, not primarily the project's maintainers.
- [ ] Create/update unit or integration tests for verifying the changes made.
- [ ] Follow coding conventions at https://cwiki.apache.org/confluence/display/FINERACT/Coding+Conventions.
- [ ] Add required Swagger annotation and update API documentation at fineract-provider/src/main/resources/static/legacy-docs/apiLive.htm with details of any API changes
- [ ] Submission is not a "code dump". (Large changes can be made "in repository" via a branch. Ask on the developer mailing list for guidance, if required.)
FYI our guidelines for code reviews are at https://cwiki.apache.org/confluence/display/FINERACT/Code+Review+Guide.
--
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: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2107: Interest Refund - Partial Refund cases [fineract]
Posted by "galovics (via GitHub)" <gi...@apache.org>.
galovics commented on code in PR #4116:
URL: https://github.com/apache/fineract/pull/4116#discussion_r1822109698
##########
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"), //
Review Comment:
Comment.
##########
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"), //
Review Comment:
Comment.
##########
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") //
Review Comment:
Would it be possible to create constants for these static values? Would be much better for maintainability.
##########
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:
Comment.
##########
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
+ public void verifyUC11x2() {
+ 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,
+ 2, null);
+ Assertions.assertNotNull(loanId);
+ loanIdRef.set(loanId);
+ disburseLoan(loanId, BigDecimal.valueOf(1000), "1 January 2021");
+
+ GetLoansLoanIdResponse loanDetails = loanTransactionHelper.getLoanDetails(loanId);
+ logLoanDetails(loanDetails);
+ });
+ runAt("11 January 2021", () -> {
+ Long loanId = loanIdRef.get();
+ PostLoansLoanIdTransactionsResponse postLoansLoanIdTransactionsResponse = loanTransactionHelper
+ .makeLoanRepayment("MerchantIssuedRefund", "11 January 2021", 500.0F, loanId.intValue());
+ Assertions.assertNotNull(postLoansLoanIdTransactionsResponse);
+ Assertions.assertNotNull(postLoansLoanIdTransactionsResponse.getResourceId());
+
+ logTransactions(loanId);
+ verifyTransactions(loanId, transaction(1000.0, "Disbursement", "01 January 2021"), //
+ transaction(500.0, "Merchant Issued Refund", "11 January 2021"), //
+ transaction(1.37, "Interest Refund", "11 January 2021")); //
+ });
+ runAt("22 January 2021", () -> {
+ Long loanId = loanIdRef.get();
+ PostLoansLoanIdTransactionsResponse postLoansLoanIdTransactionsResponse = loanTransactionHelper
+ .makeLoanRepayment("PayoutRefund", "22 January 2021", 500.0F, loanId.intValue());
+ Assertions.assertNotNull(postLoansLoanIdTransactionsResponse);
+ Assertions.assertNotNull(postLoansLoanIdTransactionsResponse.getResourceId());
+
+ logTransactions(loanId);
+ verifyTransactions(loanId, transaction(1000.0, "Disbursement", "01 January 2021"), //
+ transaction(500.0, "Merchant Issued Refund", "11 January 2021"), //
+ transaction(1.37, "Interest Refund", "11 January 2021"), //
+ transaction(500.0, "Payout Refund", "22 January 2021"), //
+ transaction(2.87, "Interest Refund", "22 January 2021")); //
+ });
+ }
+
+ private void logLoanDetails(GetLoansLoanIdResponse loanDetails) {
Review Comment:
This doesn't only log, please name the method appropriately.
--
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: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2107: Interest Refund - Partial Refund cases [fineract]
Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on code in PR #4116:
URL: https://github.com/apache/fineract/pull/4116#discussion_r1821586318
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/ProgressiveLoanInterestRefundServiceImpl.java:
##########
@@ -54,53 +54,48 @@ public boolean canHandle(Loan loan) {
return loan != null && loan.isInterestBearing() && processor.accept(loan.getTransactionProcessingStrategyCode());
}
- private static boolean omitDisbursements(LoanTransaction lt, final AtomicReference<BigDecimal> refundFinal) {
+ private static void simulateRepaymentForDisbursements(LoanTransaction lt, final AtomicReference<BigDecimal> refundFinal,
+ List<LoanTransaction> collect) {
+ collect.add(lt);
if (lt.getTypeOf().isDisbursement() && refundFinal.get().compareTo(BigDecimal.ZERO) > 0) {
if (lt.getAmount().compareTo(refundFinal.get()) <= 0) {
+ collect.add(
+ new LoanTransaction(lt.getLoan(), lt.getLoan().getOffice(), REPAYMENT.getValue(), lt.getDateOf(), lt.getAmount(),
Review Comment:
Can you please tell me about this? I thought we were just amending the disbursement and calculate interest based on the remaining amount.
--
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: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2107: Interest Refund - Partial Refund cases [fineract]
Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy merged PR #4116:
URL: https://github.com/apache/fineract/pull/4116
--
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: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2107: Interest Refund - Partial Refund cases [fineract]
Posted by "somasorosdpc (via GitHub)" <gi...@apache.org>.
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: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2107: Interest Refund - Partial Refund cases [fineract]
Posted by "somasorosdpc (via GitHub)" <gi...@apache.org>.
somasorosdpc commented on code in PR #4116:
URL: https://github.com/apache/fineract/pull/4116#discussion_r1822186867
##########
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") //
Review Comment:
I've created a static class in Base class for options, and removed the unnecessary `.supportedInterestRefundTypes(new ArrayList<>())`
--
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: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org