FINERACT-1785: Allow to add charge (penalty) with same disbursement date

This commit is contained in:
Jose Alberto Hernandez
2022-12-13 14:13:41 +01:00
committed by Arnold Gálovics
parent e938104b84
commit a987956cbc
5 changed files with 76 additions and 21 deletions
@@ -632,17 +632,6 @@ 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;
}
@@ -119,8 +119,7 @@ public class LoanRepaymentScheduleProcessingWrapper {
} 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)) {
} else if (period.isFirstPeriod() && periodStart.equals(loanCharge.getDueDate())) {
cumulative = cumulative.plus(loanCharge.amount());
}
}
@@ -213,6 +212,9 @@ 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() && periodStart.equals(loanCharge.getDueDate())) {
cumulative = cumulative.plus(loanCharge.amount());
}
}
}
@@ -21,13 +21,11 @@ package org.apache.fineract.portfolio.loanaccount.domain;
import java.util.List;
import java.util.Optional;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.portfolio.loanaccount.domain.transactionprocessor.LoanRepaymentScheduleTransactionProcessor;
import org.apache.fineract.portfolio.loanaccount.exception.LoanTransactionProcessingStrategyNotFoundException;
import org.apache.fineract.portfolio.loanproduct.data.TransactionProcessingStrategyData;
import org.springframework.beans.factory.annotation.Value;
@Slf4j
@RequiredArgsConstructor
public class LoanRepaymentScheduleTransactionProcessorFactory {