FINERACT-2326: Loan contract termination same disbursement date

This commit is contained in:
Jose Alberto Hernandez
2025-11-13 12:47:46 +01:00
committed by Adam Saghy
parent fdb9e5518c
commit a0b31bbb25
9 changed files with 155 additions and 40 deletions
@@ -18,13 +18,17 @@
*/
package org.apache.fineract.integrationtests;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.math.BigDecimal;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.fineract.client.models.GetLoansLoanIdResponse;
import org.apache.fineract.client.models.PostClientsResponse;
import org.apache.fineract.client.models.PostLoanProductsResponse;
import org.apache.fineract.client.models.PostLoansLoanIdRequest;
import org.apache.fineract.client.util.CallFailedRuntimeException;
import org.apache.fineract.integrationtests.common.ClientHelper;
import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper;
import org.apache.fineract.integrationtests.common.Utils;
import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder;
import org.apache.fineract.portfolio.loanaccount.loanschedule.domain.LoanScheduleType;
@@ -118,4 +122,31 @@ public class LoanContractTerminationTest extends BaseLoanIntegrationTest {
});
}
@Test
public void testLoanContractTerminationSameDisbursementDate() {
final PostClientsResponse client = clientHelper.createClient(ClientHelper.defaultClientCreationRequest());
final GlobalConfigurationHelper globalConfigurationHelper = new GlobalConfigurationHelper();
runAt("1 January 2024", () -> {
PostLoanProductsResponse loanProductsResponse = loanProductHelper
.createLoanProduct(create4IProgressive().interestRecognitionOnDisbursementDate(false));
Long loanId = applyAndApproveProgressiveLoan(client.getClientId(), loanProductsResponse.getResourceId(), "1 January 2024",
500.0, 7.0, 6, (request) -> request.interestRecognitionOnDisbursementDate(false));
disburseLoan(loanId, BigDecimal.valueOf(100), "1 January 2024");
loanTransactionHelper.moveLoanState(loanId,
new PostLoansLoanIdRequest().note("Contract Termination Test").externalId(Utils.randomStringGenerator("", 20)),
"contractTermination");
verifyTransactions(loanId, //
transaction(100.0, "Disbursement", "01 January 2024"), //
transaction(100.0, "Contract Termination", "01 January 2024"));
GetLoansLoanIdResponse loanDetails = loanTransactionHelper.getLoanDetails(loanId);
assertEquals(BigDecimal.ZERO.stripTrailingZeros(), loanDetails.getSummary().getInterestCharged().stripTrailingZeros());
});
}
}