|
18 | 18 | */ |
19 | 19 | package org.apache.fineract.integrationtests; |
20 | 20 |
|
| 21 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 22 | +import static org.junit.jupiter.api.Assertions.assertNull; |
| 23 | + |
21 | 24 | import java.math.BigDecimal; |
22 | 25 | import java.time.LocalDate; |
23 | 26 | import java.util.ArrayList; |
@@ -682,6 +685,46 @@ public void testProgressiveChargeBackInterestRecalculation() { |
682 | 685 | }); |
683 | 686 | } |
684 | 687 |
|
| 688 | + @Test |
| 689 | + public void testRunCOBJobAfterUndoDisbursement() { |
| 690 | + AtomicReference<Long> loanIdRef = new AtomicReference<>(); |
| 691 | + setup(); |
| 692 | + final PostLoanProductsResponse loanProductsResponse = loanProductHelper |
| 693 | + .createLoanProduct(create4IProgressive().enableAccrualActivityPosting(true)); |
| 694 | + |
| 695 | + runAt("1 April 2025", () -> { |
| 696 | + Long loanId = applyAndApproveProgressiveLoan(client.getClientId(), loanProductsResponse.getResourceId(), "1 March 2025", 430.0, |
| 697 | + 26.0, 6, null); |
| 698 | + |
| 699 | + loanIdRef.set(loanId); |
| 700 | + |
| 701 | + disburseLoan(loanId, BigDecimal.valueOf(430), "1 March 2025"); |
| 702 | + |
| 703 | + executeInlineCOB(loanId); |
| 704 | + |
| 705 | + GetLoansLoanIdResponse loanDetails = loanTransactionHelper.getLoanDetails(loanId); |
| 706 | + validateTransactionsExist(loanDetails, // |
| 707 | + transaction(9.02, "Accrual", "31 March 2025", 0.0, 0.0, 9.02, 0.0, 0.0, 0.0, 0.0)); |
| 708 | + assertEquals(LocalDate.of(2025, 3, 31), loanDetails.getLastClosedBusinessDate()); |
| 709 | + |
| 710 | + undoDisbursement(loanId.intValue()); |
| 711 | + loanDetails = loanTransactionHelper.getLoanDetails(loanId); |
| 712 | + assertNull(loanDetails.getLastClosedBusinessDate()); |
| 713 | + |
| 714 | + disburseLoan(loanIdRef.get(), BigDecimal.valueOf(430), "2 March 2025"); |
| 715 | + loanDetails = loanTransactionHelper.getLoanDetails(loanId); |
| 716 | + assertNull(loanDetails.getLastClosedBusinessDate()); |
| 717 | + }); |
| 718 | + |
| 719 | + runAt("2 April 2025", () -> { |
| 720 | + executeInlineCOB(loanIdRef.get()); |
| 721 | + GetLoansLoanIdResponse loanDetails = loanTransactionHelper.getLoanDetails(loanIdRef.get()); |
| 722 | + validateTransactionsExist(loanDetails, // |
| 723 | + transaction(9.02, "Accrual", "01 April 2025", 0.0, 0.0, 9.02, 0.0, 0.0, 0.0, 0.0)); |
| 724 | + assertEquals(LocalDate.of(2025, 4, 1), loanDetails.getLastClosedBusinessDate()); |
| 725 | + }); |
| 726 | + } |
| 727 | + |
685 | 728 | private List<CreditAllocationData> chargebackCreditAllocationOrders(List<String> allocationIds) { |
686 | 729 | List<CreditAllocationOrder> creditAllocationOrders = new ArrayList<>(allocationIds.size()); |
687 | 730 | for (int i = 0; i < allocationIds.size(); i++) { |
|
0 commit comments