adamsaghy commented on code in PR #5771:
URL: https://github.com/apache/fineract/pull/5771#discussion_r3170441614


##########
fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/service/WorkingCapitalLoanWritePlatformServiceImpl.java:
##########
@@ -577,6 +580,67 @@ public CommandProcessingResult creditBalanceRefund(final 
Long loanId, final Json
                 
.withClientId(loan.getClientId()).withLoanId(loanId).with(changes).build();
     }
 
+    @Override
+    @Transactional
+    public CommandProcessingResult updateRate(final Long loanId, final 
JsonCommand command) {
+        final WorkingCapitalLoan loan = this.loanRepository.findById(loanId)
+                .orElseThrow(() -> new 
WorkingCapitalLoanNotFoundException(loanId));
+        this.validator.validateUpdateRate(command.json(), loan);
+
+        if (loan.getLoanStatus() != LoanStatus.ACTIVE) {
+            throw new 
PlatformApiDataValidationException("validation.msg.wc.loan.rate.change.not.allowed",
+                    "Period payment rate change is allowed only for active 
loans", "loanStatus");
+        }
+
+        final BigDecimal newRate = 
this.fromApiJsonHelper.extractBigDecimalNamed(WorkingCapitalLoanConstants.periodPaymentRateParamName,
+                command.parsedJson(), new HashSet<>());
+        final BigDecimal previousRate = 
loan.getLoanProductRelatedDetails().getPeriodPaymentRate();
+
+        if (previousRate != null && previousRate.compareTo(newRate) == 0) {
+            throw new 
PlatformApiDataValidationException("validation.msg.wc.loan.rate.change.same.rate",
+                    "New period payment rate is the same as the current rate", 
WorkingCapitalLoanConstants.periodPaymentRateParamName);
+        }

Review Comment:
   These should be in the validator class, no?



-- 
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]

Reply via email to