Dhanno98 commented on code in PR #5940:
URL: https://github.com/apache/fineract/pull/5940#discussion_r3454299188
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanChargeWritePlatformServiceImpl.java:
##########
@@ -231,18 +248,36 @@ public CommandProcessingResult addLoanCharge(final Long
loanId, final JsonComman
isFirst = false;
}
}
- if (loanCharge == null) {
+ // No eligible disbursement
+ if (!eligibleDisbursementFound) {
final String errorMessage = "Charge with identifier " +
chargeDefinition.getId()
+ " cannot be applied: No valid loan disbursement
available";
throw new ChargeCannotBeAppliedToException("loan",
errorMessage, chargeDefinition.getId());
}
+
+ // Eligible disbursement exists but all zero
+ if (!atLeastOneChargePersisted) {
+ return new
CommandProcessingResultBuilder().withCommandId(command.commandId()).withOfficeId(loan.getOfficeId())
+
.withClientId(loan.getClientId()).withGroupId(loan.getGroupId()).withLoanId(loanId).build();
+ }
+
+ // At least one valid persisted charge
loan.addTrancheLoanCharge(chargeDefinition);
} else {
loanCharge = loanChargeAssembler.createNewFromJson(loan,
chargeDefinition, command);
businessEventNotifierService.notifyPreBusinessEvent(new
LoanAddChargeBusinessEvent(loanCharge));
-
validateAddLoanCharge(loan, chargeDefinition, loanCharge);
isAppliedOnBackDate = addCharge(loan, chargeDefinition,
loanCharge);
+
+ // if charge amount is rounded to zero, then return early
Review Comment:
Reverted.
--
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]