adamsaghy commented on code in PR #2882:
URL: https://github.com/apache/fineract/pull/2882#discussion_r1087894698
##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanApplicationUndoLastTrancheTest.java:
##########
@@ -129,6 +134,140 @@ public void loanApplicationUndoLastTranche() {
validateDisbursedAmount(disbursedAmount);
}
+ @Test
+ public void loanApplicationUndoLastTrancheToClose() {
+ final LocalDate todaysDate = Utils.getLocalDateOfTenant();
+ LocalDate transactionDate = LocalDate.of(todaysDate.getYear(), 1, 1);
+ String operationDate = Utils.dateFormatter.format(transactionDate);
+ LOG.info("Operation date {}", transactionDate);
+
+ final String proposedAmount = "5000";
+
+ // CREATE CLIENT
+ final Integer clientID = ClientHelper.createClient(this.requestSpec,
this.responseSpec, "01 January 2014");
+ LOG.info("---------------------------------CLIENT CREATED WITH
ID--------------------------------------------------- {}", clientID);
+
+ // CREATE LOAN MULTIDISBURSAL PRODUCT
+ final Integer loanProductID = this.loanTransactionHelper
+ .getLoanProductId(new
LoanProductTestBuilder().withInterestTypeAsDecliningBalance().withTranches(true)
+
.withDisallowExpectedDisbursements(true).withInterestCalculationPeriodTypeAsRepaymentPeriod(true).build(null));
+ LOG.info("----------------------------------LOAN PRODUCT CREATED WITH
ID------------------------------------------- {}",
+ loanProductID);
+
+ // APPLY FOR LOAN WITH TRANCHES
+ final Integer loanID = applyForLoanApplicationWithTranches(clientID,
loanProductID, proposedAmount, new ArrayList<>());
+
+ LOG.info("-----------------------------------LOAN CREATED WITH
LOANID------------------------------------------------- {}", loanID);
+
+ LOG.info("-----------------------------------APPROVE
LOAN-----------------------------------------------------------");
+ this.loanTransactionHelper.approveLoan(operationDate, proposedAmount,
loanID, null);
+
+ GetLoansLoanIdResponse getLoansLoanIdResponse =
loanTransactionHelper.getLoan(requestSpec, responseSpec, loanID);
+ assertNotNull(getLoansLoanIdResponse);
+ loanTransactionHelper.validateLoanStatus(getLoansLoanIdResponse,
"loanStatusType.approved");
+
+ // DISBURSE A LOAN
+ loanTransactionHelper.disburseLoanWithTransactionAmount(operationDate,
loanID, "500");
+ getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec,
responseSpec, loanID);
+ assertNotNull(getLoansLoanIdResponse);
+ // VALIDATE THE LOAN IS ACTIVE STATUS
+ loanTransactionHelper.validateLoanStatus(getLoansLoanIdResponse,
"loanStatusType.active");
+
loanTransactionHelper.evaluateLoanDisbursementDetails(getLoansLoanIdResponse,
1, Double.valueOf("500.00"));
+
+ // DISBURSE A LOAN (second)
+ transactionDate = transactionDate.plusDays(2);
+ operationDate = Utils.dateFormatter.format(transactionDate);
+ LOG.info("Operation date {}", transactionDate);
+ loanTransactionHelper.disburseLoanWithTransactionAmount(operationDate,
loanID, "500");
+ getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec,
responseSpec, loanID);
+ assertNotNull(getLoansLoanIdResponse);
+ // VALIDATE THE LOAN IS ACTIVE STATUS
+ loanTransactionHelper.validateLoanStatus(getLoansLoanIdResponse,
"loanStatusType.active");
+
loanTransactionHelper.evaluateLoanDisbursementDetails(getLoansLoanIdResponse,
2, Double.valueOf("1000.00"));
+
+ // BACKDATE REPAYMENT
+ transactionDate = transactionDate.minusDays(1);
+ operationDate = Utils.dateFormatter.format(transactionDate);
+ LOG.info("Operation date {}", transactionDate);
+ Float amount = Float.valueOf("559.36");
+ PostLoansLoanIdTransactionsResponse loanIdTransactionsResponse =
loanTransactionHelper.makeLoanRepayment(operationDate, amount,
+ loanID);
+ assertNotNull(loanIdTransactionsResponse);
+ LOG.info("Loan Transaction Id: {} {}", loanID,
loanIdTransactionsResponse.getResourceId());
+ getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec,
responseSpec, loanID);
+ assertNotNull(getLoansLoanIdResponse);
+ // VALIDATE THE LOAN IS ACTIVE STATUS
+ loanTransactionHelper.validateLoanStatus(getLoansLoanIdResponse,
"loanStatusType.active");
+
loanTransactionHelper.evaluateLoanDisbursementDetails(getLoansLoanIdResponse,
2, Double.valueOf("1000.00"));
+
loanTransactionHelper.validateLoanTotalOustandingBalance(getLoansLoanIdResponse,
Double.valueOf("500.00"));
+
+ // UNDO LAST TRANCHE
+ this.loanTransactionHelper.undoLastDisbursal(loanID);
+
+ getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec,
responseSpec, loanID);
+ assertNotNull(getLoansLoanIdResponse);
+ // VALIDATE THE LOAN IS ACTIVE STATUS
+ loanTransactionHelper.validateLoanStatus(getLoansLoanIdResponse,
"loanStatusType.active");
Review Comment:
it should be closed, no?
--
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]