FINERACT-1981: Order disbursements and repayment periods properly
This commit is contained in:
+12
-2
@@ -23,6 +23,7 @@ import java.time.LocalDate;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||
import org.apache.fineract.portfolio.loanaccount.loanschedule.domain.LoanScheduleType;
|
||||
|
||||
/**
|
||||
* Immutable data object representing disbursement information.
|
||||
@@ -89,9 +90,12 @@ public final class DisbursementData implements Comparable<DisbursementData> {
|
||||
return DateUtils.compare(obj.expectedDisbursementDate, this.expectedDisbursementDate);
|
||||
}
|
||||
|
||||
public boolean isDueForDisbursement(final LocalDate fromNotInclusive, final LocalDate upToAndInclusive) {
|
||||
public boolean isDueForDisbursement(LoanScheduleType loanScheduleType, final LocalDate fromDate, final LocalDate toDate) {
|
||||
final LocalDate dueDate = disbursementDate();
|
||||
return occursOnDayFromAndUpToAndIncluding(fromNotInclusive, upToAndInclusive, dueDate);
|
||||
return switch (loanScheduleType) {
|
||||
case CUMULATIVE -> occursOnDayFromAndUpToAndIncluding(fromDate, toDate, dueDate);
|
||||
case PROGRESSIVE -> occursOnDayFromAndIncludingAndUpTo(fromDate, toDate, dueDate);
|
||||
};
|
||||
}
|
||||
|
||||
private boolean occursOnDayFromAndUpToAndIncluding(final LocalDate fromNotInclusive, final LocalDate upToAndInclusive,
|
||||
@@ -99,6 +103,12 @@ public final class DisbursementData implements Comparable<DisbursementData> {
|
||||
return DateUtils.isAfter(target, fromNotInclusive) && !DateUtils.isAfter(target, upToAndInclusive);
|
||||
}
|
||||
|
||||
private boolean occursOnDayFromAndIncludingAndUpTo(final LocalDate fromInclusive, final LocalDate upToNotInclusive,
|
||||
final LocalDate target) {
|
||||
return (DateUtils.isEqual(target, fromInclusive) || DateUtils.isAfter(target, fromInclusive))
|
||||
&& DateUtils.isBefore(target, upToNotInclusive);
|
||||
}
|
||||
|
||||
public BigDecimal getWaivedChargeAmount() {
|
||||
return this.waivedChargeAmount == null ? BigDecimal.ZERO : this.waivedChargeAmount;
|
||||
}
|
||||
|
||||
+1
-1
@@ -282,7 +282,7 @@ public class AdvancedPaymentScheduleTransactionProcessor extends AbstractLoanRep
|
||||
List<LoanRepaymentScheduleInstallment> installments) {
|
||||
final MathContext mc = MoneyHelper.getMathContext();
|
||||
List<LoanRepaymentScheduleInstallment> candidateRepaymentInstallments = installments.stream().filter(
|
||||
i -> !i.getDueDate().isBefore(disbursementTransaction.getTransactionDate()) && !i.isDownPayment() && !i.isAdditional())
|
||||
i -> i.getDueDate().isAfter(disbursementTransaction.getTransactionDate()) && !i.isDownPayment() && !i.isAdditional())
|
||||
.toList();
|
||||
int noCandidateRepaymentInstallments = candidateRepaymentInstallments.size();
|
||||
LoanProductRelatedDetail loanProductRelatedDetail = disbursementTransaction.getLoan().getLoanRepaymentScheduleDetail();
|
||||
|
||||
+7
@@ -39,4 +39,11 @@ public enum LoanScheduleType {
|
||||
public EnumOptionData asEnumOptionData() {
|
||||
return new EnumOptionData((long) this.ordinal(), this.name(), this.humanReadableName);
|
||||
}
|
||||
|
||||
public static LoanScheduleType fromEnumOptionData(EnumOptionData enumOptionData) {
|
||||
if (enumOptionData == null) {
|
||||
return null;
|
||||
}
|
||||
return valueOf(enumOptionData.getCode());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user