Allow to add charge with same disbursement date

This commit is contained in:
Jose Alberto Hernandez
2022-10-26 13:55:41 +02:00
committed by Arnold Gálovics
parent 7c6e85be10
commit 8954de5ded
6 changed files with 202 additions and 0 deletions
@@ -712,6 +712,17 @@ public class LoanCharge extends AbstractPersistableCustom {
return target != null && target.isAfter(fromNotInclusive) && !target.isAfter(upToAndInclusive);
}
public boolean isDueForCollectionFromIncludingAndUpToAndIncluding(final LocalDate fromNotInclusive, final LocalDate upToAndInclusive) {
final LocalDate dueDate = getDueLocalDate();
return occursOnDayFromAndIncludingAndUpToAndIncluding(fromNotInclusive, upToAndInclusive, dueDate);
}
private boolean occursOnDayFromAndIncludingAndUpToAndIncluding(final LocalDate fromAndInclusive, final LocalDate upToAndInclusive,
final LocalDate target) {
return target != null && (target.isEqual(fromAndInclusive) || target.isAfter(fromAndInclusive))
&& !target.isAfter(upToAndInclusive);
}
public boolean isFeeCharge() {
return !this.penaltyCharge;
}
@@ -894,4 +894,8 @@ public class LoanRepaymentScheduleInstallment extends AbstractAuditableWithUTCDa
this.additional = true;
}
public boolean isFirstPeriod() {
return (this.installmentNumber == 1);
}
}
@@ -118,6 +118,10 @@ public class LoanRepaymentScheduleProcessingWrapper {
cumulative = cumulative.plus(loanChargeAmt);
} else if (loanCharge.isDueForCollectionFromAndUpToAndIncluding(periodStart, periodEnd)) {
cumulative = cumulative.plus(loanCharge.amount());
// Special case for Loan Charges (Due Date) added the same disbursement date
} else if (period.isFirstPeriod()
&& loanCharge.isDueForCollectionFromIncludingAndUpToAndIncluding(periodStart, periodEnd)) {
cumulative = cumulative.plus(loanCharge.amount());
}
}
}