FINERACT-1806: Charge-off validation

This commit is contained in:
Adam Saghy
2023-03-09 20:05:26 +01:00
committed by Arnold Gálovics
parent 83de7652e6
commit 0928fb5136
2 changed files with 13 additions and 0 deletions
@@ -2729,6 +2729,11 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
"Loan: " + loanId + " charge-off cannot be executed. User transaction was found after the charge-off transaction date!",
loanId);
}
if (transactionDate.isAfter(DateUtils.getBusinessLocalDate())) {
final String errorMessage = "The transaction date cannot be in the future.";
throw new GeneralPlatformDomainRuleException("error.msg.loan.transaction.cannot.be.a.future.date", errorMessage,
transactionDate);
}
if (loan.isInterestBearing()) {
throw new GeneralPlatformDomainRuleException("error.msg.loan.is.interest.bearing",
"Loan: " + loanId + " Charge-off is not allowed. Loan Account is interest bearing", loanId);
@@ -7003,6 +7003,14 @@ public class ClientLoanIntegrationTest {
loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithTransactionAmount("03 September 2022", loanID, "1000");
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
exception = assertThrows(CallFailedRuntimeException.class, () -> {
this.loanTransactionHelper.chargeOffLoan((long) loanID,
new PostLoansLoanIdTransactionsRequest().transactionDate("1 October 2022").locale("en").dateFormat("dd MMMM yyyy")
.chargeOffReasonId((long) chargeOffReasonId));
});
assertEquals(403, exception.getResponse().code());
assertTrue(exception.getMessage().contains("error.msg.loan.transaction.cannot.be.a.future.date"));
GetLoansLoanIdResponse loanDetails = this.loanTransactionHelper.getLoanDetails((long) loanID);
assertTrue(loanDetails.getStatus().getActive());
assertEquals(2000.0, loanDetails.getSummary().getTotalOutstanding());