adamsaghy commented on code in PR #5358:
URL: https://github.com/apache/fineract/pull/5358#discussion_r2721069775
##########
fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/data/ProgressiveLoanRescheduleRequestDataValidator.java:
##########
@@ -223,17 +222,14 @@ public void validateForRejectAction(JsonCommand
jsonCommand, LoanRescheduleReque
throw new UnsupportedOperationException("Nothing to override here");
}
- private void validateInterestRateChangeRescheduleFromDate(Loan loan,
LocalDate rescheduleFromDate) {
- boolean alreadyExistInterestRateChange =
loanRescheduleRequestRepository.exists((root, query, criteriaBuilder) -> {
- Predicate loanPredicate = criteriaBuilder.equal(root.get("loan"),
loan);
- Predicate statusPredicate = root.get("statusEnum")
-
.in(List.of(LoanStatus.SUBMITTED_AND_PENDING_APPROVAL.getValue(),
LoanStatus.APPROVED.getValue()));
- Predicate datePredicate =
criteriaBuilder.equal(root.get("rescheduleFromDate"), rescheduleFromDate);
- return criteriaBuilder.and(loanPredicate, statusPredicate,
datePredicate);
- });
- if (alreadyExistInterestRateChange) {
- throw new
GeneralPlatformDomainRuleException("loan.reschedule.interest.rate.change.already.exists",
- "Interest rate change for the provided date is already
exists.", rescheduleFromDate);
+ private void validateInterestRateChangeRescheduleFromDate(final Loan loan,
final LocalDate rescheduleFromDate) {
+ Optional<LoanRescheduleRequest> optLoanRescheduleRequest =
loanRescheduleRequestRepository.fetchByLoanAndFromDateAndStatus(loan, //
+ rescheduleFromDate,
List.of(LoanStatus.SUBMITTED_AND_PENDING_APPROVAL.getValue(),
LoanStatus.APPROVED.getValue()));
+
+ if (optLoanRescheduleRequest.isPresent()) {
+ LoanRescheduleRequest loanRescheduleRequest =
optLoanRescheduleRequest.get();
+
loanRescheduleRequest.reject(loanRescheduleRequest.getSubmittedByUser(),
rescheduleFromDate);
+ loanRescheduleRequestRepository.save(loanRescheduleRequest);
Review Comment:
Also i dont think we should automatically reject is... it is misleading.
Leave it APPROVED, but when we fetch these term variations, if the same applies
to the same date, take the latter only.
Can it work?
--
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]