Skip to content

Commit

Permalink
Merge pull request #1461 from fiterlatam/fix/FBR-743
Browse files Browse the repository at this point in the history
fix/FBR-743
  • Loading branch information
BrianMuhimbura authored Jan 6, 2025
2 parents 529e3f9 + aa954c7 commit d69a3cb
Showing 1 changed file with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public void reprocess(final MonetaryCurrency currency, final LocalDate disbursem
final Money penaltyChargesDueForRepaymentPeriod = cumulativePenaltyChargesDueWithin(startDate, period.getDueDate(), loanCharges,
currency, period, totalPrincipal, totalInterest, !period.isRecalculatedInterestComponent());
final Money penaltyChargesWaivedForRepaymentPeriod = cumulativePenaltyChargesWaivedWithin(startDate, period.getDueDate(),
loanCharges, currency, !period.isRecalculatedInterestComponent());
loanCharges, currency, !period.isRecalculatedInterestComponent(),period);
final Money penaltyChargesWrittenOffForRepaymentPeriod = cumulativePenaltyChargesWrittenOffWithin(startDate,
period.getDueDate(), loanCharges, currency, !period.isRecalculatedInterestComponent());
period.getDueDate(), loanCharges, currency, !period.isRecalculatedInterestComponent(), period);

period.updateChargePortion(feeChargesDueForRepaymentPeriod, feeChargesWaivedForRepaymentPeriod,
feeChargesWrittenOffForRepaymentPeriod, penaltyChargesDueForRepaymentPeriod, penaltyChargesWaivedForRepaymentPeriod,
Expand Down Expand Up @@ -219,7 +219,7 @@ private Money cumulativePenaltyChargesDueWithin(final LocalDate periodStart, fin
}

private Money cumulativePenaltyChargesWaivedWithin(final LocalDate periodStart, final LocalDate periodEnd,
final Set<LoanCharge> loanCharges, final MonetaryCurrency currency, boolean isInstallmentChargeApplicable) {
final Set<LoanCharge> loanCharges, final MonetaryCurrency currency, boolean isInstallmentChargeApplicable, LoanRepaymentScheduleInstallment period) {

Money cumulative = Money.zero(currency);

Expand All @@ -230,8 +230,11 @@ private Money cumulativePenaltyChargesWaivedWithin(final LocalDate periodStart,
if (loanChargePerInstallment != null) {
cumulative = cumulative.plus(loanChargePerInstallment.getAmountWaived(currency));
}
} else if (loanCharge.isDueForCollectionFromAndUpToAndIncluding(periodStart, periodEnd)) {
cumulative = cumulative.plus(loanCharge.getAmountWaived(currency));
} else if (loanCharge.getOverdueInstallmentCharge()!=null){
LoanOverdueInstallmentCharge overdueInstallmentCharge =loanCharge.getOverdueInstallmentCharge() ;
if (overdueInstallmentCharge.getInstallment().getInstallmentNumber().equals(period.getInstallmentNumber())) {
cumulative = cumulative.plus(loanCharge.getAmountWaived(currency));
}
}
}
}
Expand All @@ -240,7 +243,7 @@ private Money cumulativePenaltyChargesWaivedWithin(final LocalDate periodStart,
}

private Money cumulativePenaltyChargesWrittenOffWithin(final LocalDate periodStart, final LocalDate periodEnd,
final Set<LoanCharge> loanCharges, final MonetaryCurrency currency, boolean isInstallmentChargeApplicable) {
final Set<LoanCharge> loanCharges, final MonetaryCurrency currency, boolean isInstallmentChargeApplicable, LoanRepaymentScheduleInstallment period) {

Money cumulative = Money.zero(currency);

Expand All @@ -251,8 +254,11 @@ private Money cumulativePenaltyChargesWrittenOffWithin(final LocalDate periodSta
if (loanChargePerInstallment != null) {
cumulative = cumulative.plus(loanChargePerInstallment.getAmountWrittenOff(currency));
}
} else if (loanCharge.isDueForCollectionFromAndUpToAndIncluding(periodStart, periodEnd)) {
cumulative = cumulative.plus(loanCharge.getAmountWrittenOff(currency));
} else if (loanCharge.getOverdueInstallmentCharge()!=null){
LoanOverdueInstallmentCharge overdueInstallmentCharge =loanCharge.getOverdueInstallmentCharge() ;
if (overdueInstallmentCharge.getInstallment().getInstallmentNumber().equals(period.getInstallmentNumber())) {
cumulative = cumulative.plus(loanCharge.getAmountWaived(currency));
}
}
}
}
Expand Down

0 comments on commit d69a3cb

Please sign in to comment.