budaidev commented on code in PR #4654:
URL: https://github.com/apache/fineract/pull/4654#discussion_r2113537531


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanDisbursementService.java:
##########
@@ -187,23 +187,35 @@ public void handleDisbursementTransaction(final Loan 
loan, final LocalDate disbu
         final Integer installmentNumber = null;
         for (final LoanCharge charge : loan.getActiveCharges()) {
             LocalDate actualDisbursementDate = 
loan.getActualDisbursementDate(charge);
+
+            boolean isDisbursementCharge = 
charge.getCharge().getChargeTimeType().equals(ChargeTimeType.DISBURSEMENT.getValue())
+                    && disbursedOn.equals(actualDisbursementDate) && 
!charge.isWaived() && !charge.isFullyPaid();
+
+            boolean isTrancheDisbursementCharge = 
charge.getCharge().getChargeTimeType()
+                    .equals(ChargeTimeType.TRANCHE_DISBURSEMENT.getValue()) && 
disbursedOn.equals(actualDisbursementDate)
+                    && !charge.isWaived() && !charge.isFullyPaid();
+
             /*
              * create a Charge applied transaction if Up front Accrual, None 
or Cash based accounting is enabled
              */
-            if 
((charge.getCharge().getChargeTimeType().equals(ChargeTimeType.DISBURSEMENT.getValue())
-                    && disbursedOn.equals(actualDisbursementDate) && 
!charge.isWaived() && !charge.isFullyPaid())
-                    || 
(charge.getCharge().getChargeTimeType().equals(ChargeTimeType.TRANCHE_DISBURSEMENT.getValue())
-                            && disbursedOn.equals(actualDisbursementDate) && 
!charge.isWaived() && !charge.isFullyPaid())) {
+            if (isDisbursementCharge || isTrancheDisbursementCharge) {
                 if (totalFeeChargesDueAtDisbursement.isGreaterThanZero() && 
!charge.getChargePaymentMode().isPaymentModeAccountTransfer()) {
                     charge.markAsFullyPaid();
                     // Add "Loan Charge Paid By" details to this transaction
                     final LoanChargePaidBy loanChargePaidBy = new 
LoanChargePaidBy(chargesPayment, charge, charge.amount(),
                             installmentNumber);
                     chargesPayment.getLoanChargesPaid().add(loanChargePaidBy);
                     disbursentMoney = disbursentMoney.plus(charge.amount());
+
+                    // For tranche disbursement charges, we need to ensure 
they don't affect the loan schedule
+                    if (isTrancheDisbursementCharge) {

Review Comment:
   In my undersanding: tranche-specific disbursement charges are meant to be 
one-off fees associated only with that particular tranche.
   Also markAsFullyPaid should set the amount paid to zero, so no need to set 
it again



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