FINERACT-2181: Reset Last Closed Business date after Loan undo disbursement
This commit is contained in:
committed by
Adam Saghy
parent
98b7328508
commit
a8cb6806b0
+1
@@ -3076,6 +3076,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
|||||||
final boolean isScheduleRegenerateRequired = loan.isActualDisbursedOnDateEarlierOrLaterThanExpected(actualDisbursementDate);
|
final boolean isScheduleRegenerateRequired = loan.isActualDisbursedOnDateEarlierOrLaterThanExpected(actualDisbursementDate);
|
||||||
loan.setActualDisbursementDate(null);
|
loan.setActualDisbursementDate(null);
|
||||||
loan.setDisbursedBy(null);
|
loan.setDisbursedBy(null);
|
||||||
|
loan.setLastClosedBusinessDate(null);
|
||||||
final boolean isDisbursedAmountChanged = !MathUtil.isEqualTo(loan.getApprovedPrincipal(),
|
final boolean isDisbursedAmountChanged = !MathUtil.isEqualTo(loan.getApprovedPrincipal(),
|
||||||
loan.getLoanRepaymentScheduleDetail().getPrincipal().getAmount());
|
loan.getLoanRepaymentScheduleDetail().getPrincipal().getAmount());
|
||||||
loan.getLoanRepaymentScheduleDetail().setPrincipal(loan.getApprovedPrincipal());
|
loan.getLoanRepaymentScheduleDetail().setPrincipal(loan.getApprovedPrincipal());
|
||||||
|
|||||||
+43
@@ -18,6 +18,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.fineract.integrationtests;
|
package org.apache.fineract.integrationtests;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -682,6 +685,46 @@ public class LoanCOBCreateAccrualsTest extends BaseLoanIntegrationTest {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRunCOBJobAfterUndoDisbursement() {
|
||||||
|
AtomicReference<Long> loanIdRef = new AtomicReference<>();
|
||||||
|
setup();
|
||||||
|
final PostLoanProductsResponse loanProductsResponse = loanProductHelper
|
||||||
|
.createLoanProduct(create4IProgressive().enableAccrualActivityPosting(true));
|
||||||
|
|
||||||
|
runAt("1 April 2025", () -> {
|
||||||
|
Long loanId = applyAndApproveProgressiveLoan(client.getClientId(), loanProductsResponse.getResourceId(), "1 March 2025", 430.0,
|
||||||
|
26.0, 6, null);
|
||||||
|
|
||||||
|
loanIdRef.set(loanId);
|
||||||
|
|
||||||
|
disburseLoan(loanId, BigDecimal.valueOf(430), "1 March 2025");
|
||||||
|
|
||||||
|
executeInlineCOB(loanId);
|
||||||
|
|
||||||
|
GetLoansLoanIdResponse loanDetails = loanTransactionHelper.getLoanDetails(loanId);
|
||||||
|
validateTransactionsExist(loanDetails, //
|
||||||
|
transaction(9.02, "Accrual", "31 March 2025", 0.0, 0.0, 9.02, 0.0, 0.0, 0.0, 0.0));
|
||||||
|
assertEquals(LocalDate.of(2025, 3, 31), loanDetails.getLastClosedBusinessDate());
|
||||||
|
|
||||||
|
undoDisbursement(loanId.intValue());
|
||||||
|
loanDetails = loanTransactionHelper.getLoanDetails(loanId);
|
||||||
|
assertNull(loanDetails.getLastClosedBusinessDate());
|
||||||
|
|
||||||
|
disburseLoan(loanIdRef.get(), BigDecimal.valueOf(430), "2 March 2025");
|
||||||
|
loanDetails = loanTransactionHelper.getLoanDetails(loanId);
|
||||||
|
assertNull(loanDetails.getLastClosedBusinessDate());
|
||||||
|
});
|
||||||
|
|
||||||
|
runAt("2 April 2025", () -> {
|
||||||
|
executeInlineCOB(loanIdRef.get());
|
||||||
|
GetLoansLoanIdResponse loanDetails = loanTransactionHelper.getLoanDetails(loanIdRef.get());
|
||||||
|
validateTransactionsExist(loanDetails, //
|
||||||
|
transaction(9.02, "Accrual", "01 April 2025", 0.0, 0.0, 9.02, 0.0, 0.0, 0.0, 0.0));
|
||||||
|
assertEquals(LocalDate.of(2025, 4, 1), loanDetails.getLastClosedBusinessDate());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private List<CreditAllocationData> chargebackCreditAllocationOrders(List<String> allocationIds) {
|
private List<CreditAllocationData> chargebackCreditAllocationOrders(List<String> allocationIds) {
|
||||||
List<CreditAllocationOrder> creditAllocationOrders = new ArrayList<>(allocationIds.size());
|
List<CreditAllocationOrder> creditAllocationOrders = new ArrayList<>(allocationIds.size());
|
||||||
for (int i = 0; i < allocationIds.size(); i++) {
|
for (int i = 0; i < allocationIds.size(); i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user