adamsaghy commented on code in PR #3873:
URL: https://github.com/apache/fineract/pull/3873#discussion_r1574757157
##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/AdvancedPaymentAllocationLoanRepaymentScheduleTest.java:
##########
@@ -4011,6 +4011,46 @@ public void uc135() {
});
}
+ // UC136: Advanced payment allocation, using auto downpayment with
installment amount in multiples of 1
+ // ADVANCED_PAYMENT_ALLOCATION_STRATEGY
+ // 1. Create a Loan product with Adv. Pment. Alloc.
+ // 2. Submit Loan and approve
+ // 3. Disburse the loan and validate downpayment
+ @Test
+ public void uc136() {
+ AtomicLong createdLoanId = new AtomicLong();
+ runAt("23 March 2024", () -> {
+ PostLoanProductsRequest product =
createOnePeriod30DaysLongNoInterestPeriodicAccrualProductWithAdvancedPaymentAllocation()
+
.installmentAmountInMultiplesOf(null).numberOfRepayments(3).repaymentEvery(15).enableDownPayment(true)
+
.enableAutoRepaymentForDownPayment(true).disbursedAmountPercentageForDownPayment(BigDecimal.valueOf(25))
+ .minPrincipal(10.0).installmentAmountInMultiplesOf(1);
+ PostLoanProductsResponse loanProductResponse =
loanProductHelper.createLoanProduct(product);
+ PostLoansRequest applicationRequest =
applyLoanRequest(client.getClientId(), loanProductResponse.getResourceId(),
+ "23 March 2024", 10.0, 4);
+
+ applicationRequest =
applicationRequest.numberOfRepayments(3).loanTermFrequency(45)
+
.transactionProcessingStrategyCode(LoanProductTestBuilder.ADVANCED_PAYMENT_ALLOCATION_STRATEGY).repaymentEvery(15);
+
+ PostLoansResponse loanResponse =
loanTransactionHelper.applyLoan(applicationRequest);
+
+ loanTransactionHelper.approveLoan(loanResponse.getLoanId(), new
PostLoansLoanIdRequest()
+
.approvedLoanAmount(BigDecimal.valueOf(10)).dateFormat(DATETIME_PATTERN).approvedOnDate("23
March 2024").locale("en"));
+
+ loanTransactionHelper.disburseLoan(loanResponse.getLoanId(),
+ new PostLoansLoanIdRequest().actualDisbursementDate("23
March 2024").dateFormat(DATETIME_PATTERN)
+
.transactionAmount(BigDecimal.valueOf(10.0)).locale("en"));
+
+ // verify schedule
+ verifyRepaymentSchedule(loanResponse.getLoanId(), //
+ installment(10, null, "23 March 2024"), //
+ installment(3, 0, 0, 0, 0.0, true, "23 March 2024", 7), //
Review Comment:
Something does not add up here...
First installment is 3
2nd and 3rd are 2
4th is 3 again.
For 1st one 2.5 is the calculated but it does using force HALF_UP rounding
(i guess it is hardcoded somewhere), however for 2nd and 3rd it is does not
using HALF_UP, i guess it comes from a configuration which is not HALF_UP..
Please make sure all calculation is using the some rounding to avoid these
situations.
--
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]