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


##########
fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/service/WorkingCapitalLoanWritePlatformServiceImpl.java:
##########
@@ -668,6 +659,64 @@ public CommandProcessingResult creditBalanceRefund(final 
Long loanId, final Json
                 
.withClientId(loan.getClientId()).withLoanId(loanId).with(changes).build();
     }
 
+    @Override
+    public CommandProcessingResult makeGoodwillCredit(Long loanId, JsonCommand 
command) {
+        final WorkingCapitalLoan loan = this.loanRepository.findById(loanId)
+                .orElseThrow(() -> new 
WorkingCapitalLoanNotFoundException(loanId));
+        this.validator.validateRepayment(command.json(), loan);
+
+        if (!LoanStatus.ACTIVE.equals(loan.getLoanStatus()) && 
!LoanStatus.CLOSED_OBLIGATIONS_MET.equals(loan.getLoanStatus())
+                && !LoanStatus.OVERPAID.equals(loan.getLoanStatus())) {
+            throw new 
PlatformApiDataValidationException("validation.msg.wc.loan.transition.not.allowed",
+                    "Goodwill Credit is allowed only for active/closed 
obligations met/overpaid loans", "loanStatus");
+        }

Review Comment:
   Should we move this into the validator?



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