Dhanno98 commented on code in PR #5940:
URL: https://github.com/apache/fineract/pull/5940#discussion_r3454289379
##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanChargeWritePlatformServiceImpl.java:
##########
@@ -206,21 +206,38 @@ public CommandProcessingResult addLoanCharge(final Long
loanId, final JsonComman
LoanTrancheDisbursementCharge loanTrancheDisbursementCharge;
ExternalId externalId =
externalIdFactory.createFromCommand(command, "externalId");
boolean isFirst = true;
+ boolean atLeastOneChargePersisted = false;
+ boolean eligibleDisbursementFound = false;
for (LoanDisbursementDetails disbursementDetail :
loanDisburseDetails) {
if (disbursementDetail.actualDisbursementDate() == null) {
+ eligibleDisbursementFound = true;
// If multiple charges to be applied, only the first one
will get the provided externalId, for the
// rest we generate new ones (if needed)
if (!isFirst) {
externalId = externalIdFactory.create();
}
LocalDate dueDate =
disbursementDetail.expectedDisbursementDateAsLocalDate();
- loanCharge =
loanChargeAssembler.createNewWithoutLoan(chargeDefinition,
disbursementDetail.getPrincipal(), null, null,
- null, dueDate, null, null, externalId);
- loanTrancheDisbursementCharge = new
LoanTrancheDisbursementCharge(loanCharge, disbursementDetail);
-
loanCharge.updateLoanTrancheDisbursementCharge(loanTrancheDisbursementCharge);
- businessEventNotifierService.notifyPreBusinessEvent(new
LoanAddChargeBusinessEvent(loanCharge));
- validateAddLoanCharge(loan, chargeDefinition, loanCharge);
- addCharge(loan, chargeDefinition, loanCharge);
+ LoanCharge tempCharge =
loanChargeAssembler.createNewWithoutLoan(chargeDefinition,
disbursementDetail.getPrincipal(),
+ null, null, null, dueDate, null, null, externalId);
+ loanTrancheDisbursementCharge = new
LoanTrancheDisbursementCharge(tempCharge, disbursementDetail);
+
tempCharge.updateLoanTrancheDisbursementCharge(loanTrancheDisbursementCharge);
+ businessEventNotifierService.notifyPreBusinessEvent(new
LoanAddChargeBusinessEvent(tempCharge));
+ validateAddLoanCharge(loan, chargeDefinition, tempCharge);
+ addCharge(loan, chargeDefinition, tempCharge);
+
+ // if charge amount is rounded to zero, then continue and
look for another disbursement
+ if (isZeroCharge(tempCharge)) {
+ continue;
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]