Fix up issue with fee charges not been summed up correctly for preview loan schedule.
This commit is contained in:
+3
-4
@@ -62,8 +62,6 @@ public class EqualInstallmentsAmortizationLoanScheduleGenerator implements Amort
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BigDecimal cumulativeChargesToDate = chargesDueAtTimeOfDisbursement;
|
|
||||||
|
|
||||||
// create entries of disbursement period on loan schedule
|
// create entries of disbursement period on loan schedule
|
||||||
final LoanSchedulePeriodData disbursementPeriod = LoanSchedulePeriodData.disbursementOnlyPeriod(disbursementDate,
|
final LoanSchedulePeriodData disbursementPeriod = LoanSchedulePeriodData.disbursementOnlyPeriod(disbursementDate,
|
||||||
principalDisbursed.getAmount(), chargesDueAtTimeOfDisbursement, false);
|
principalDisbursed.getAmount(), chargesDueAtTimeOfDisbursement, false);
|
||||||
@@ -74,7 +72,7 @@ public class EqualInstallmentsAmortizationLoanScheduleGenerator implements Amort
|
|||||||
BigDecimal totalPrincipalExpected = BigDecimal.ZERO;
|
BigDecimal totalPrincipalExpected = BigDecimal.ZERO;
|
||||||
BigDecimal totalPrincipalPaid = BigDecimal.ZERO;
|
BigDecimal totalPrincipalPaid = BigDecimal.ZERO;
|
||||||
BigDecimal totalInterestCharged = BigDecimal.ZERO;
|
BigDecimal totalInterestCharged = BigDecimal.ZERO;
|
||||||
BigDecimal totalFeeChargesCharged = BigDecimal.ZERO;
|
BigDecimal totalFeeChargesCharged = chargesDueAtTimeOfDisbursement;
|
||||||
BigDecimal totalPenaltyChargesCharged = BigDecimal.ZERO;
|
BigDecimal totalPenaltyChargesCharged = BigDecimal.ZERO;
|
||||||
BigDecimal totalWaived = BigDecimal.ZERO;
|
BigDecimal totalWaived = BigDecimal.ZERO;
|
||||||
BigDecimal totalWrittenOff = BigDecimal.ZERO;
|
BigDecimal totalWrittenOff = BigDecimal.ZERO;
|
||||||
@@ -135,7 +133,6 @@ public class EqualInstallmentsAmortizationLoanScheduleGenerator implements Amort
|
|||||||
monetaryCurrency);
|
monetaryCurrency);
|
||||||
final Money totalInstallmentDue = principalForInstallment.plus(interestForInstallment).plus(feeChargesForInstallment)
|
final Money totalInstallmentDue = principalForInstallment.plus(interestForInstallment).plus(feeChargesForInstallment)
|
||||||
.plus(penaltyChargesForInstallment);
|
.plus(penaltyChargesForInstallment);
|
||||||
cumulativeChargesToDate = cumulativeChargesToDate.add(feeChargesForInstallment.getAmount());
|
|
||||||
|
|
||||||
LoanSchedulePeriodData installment = LoanSchedulePeriodData.repaymentOnlyPeriod(periodNumber, startDate, scheduledDueDate,
|
LoanSchedulePeriodData installment = LoanSchedulePeriodData.repaymentOnlyPeriod(periodNumber, startDate, scheduledDueDate,
|
||||||
principalForInstallment.getAmount(), outstandingBalance.getAmount(), interestForInstallment.getAmount(),
|
principalForInstallment.getAmount(), outstandingBalance.getAmount(), interestForInstallment.getAmount(),
|
||||||
@@ -147,6 +144,8 @@ public class EqualInstallmentsAmortizationLoanScheduleGenerator implements Amort
|
|||||||
loanTermInDays += daysInPeriod;
|
loanTermInDays += daysInPeriod;
|
||||||
totalPrincipalExpected = totalPrincipalExpected.add(principalForInstallment.getAmount());
|
totalPrincipalExpected = totalPrincipalExpected.add(principalForInstallment.getAmount());
|
||||||
totalInterestCharged = totalInterestCharged.add(interestForInstallment.getAmount());
|
totalInterestCharged = totalInterestCharged.add(interestForInstallment.getAmount());
|
||||||
|
totalFeeChargesCharged = totalFeeChargesCharged.add(feeChargesForInstallment.getAmount());
|
||||||
|
totalPenaltyChargesCharged = totalPenaltyChargesCharged.add(penaltyChargesForInstallment.getAmount());
|
||||||
totalRepaymentExpected = totalRepaymentExpected.add(totalInstallmentDue.getAmount());
|
totalRepaymentExpected = totalRepaymentExpected.add(totalInstallmentDue.getAmount());
|
||||||
startDate = scheduledDueDate;
|
startDate = scheduledDueDate;
|
||||||
|
|
||||||
|
|||||||
+37
-7
@@ -57,8 +57,6 @@ public class EqualPrincipalAmortizationLoanScheduleGenerator implements Amortiza
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BigDecimal cumulativeChargesToDate = chargesDueAtTimeOfDisbursement;
|
|
||||||
|
|
||||||
// create entries of disbursement period on loan schedule
|
// create entries of disbursement period on loan schedule
|
||||||
final LoanSchedulePeriodData disbursementPeriod = LoanSchedulePeriodData.disbursementOnlyPeriod(disbursementDate,
|
final LoanSchedulePeriodData disbursementPeriod = LoanSchedulePeriodData.disbursementOnlyPeriod(disbursementDate,
|
||||||
principalDisbursed.getAmount(), chargesDueAtTimeOfDisbursement, false);
|
principalDisbursed.getAmount(), chargesDueAtTimeOfDisbursement, false);
|
||||||
@@ -69,7 +67,7 @@ public class EqualPrincipalAmortizationLoanScheduleGenerator implements Amortiza
|
|||||||
BigDecimal totalPrincipalExpected = BigDecimal.ZERO;
|
BigDecimal totalPrincipalExpected = BigDecimal.ZERO;
|
||||||
BigDecimal totalPrincipalPaid = BigDecimal.ZERO;
|
BigDecimal totalPrincipalPaid = BigDecimal.ZERO;
|
||||||
BigDecimal totalInterestCharged = BigDecimal.ZERO;
|
BigDecimal totalInterestCharged = BigDecimal.ZERO;
|
||||||
BigDecimal totalFeeChargesCharged = BigDecimal.ZERO;
|
BigDecimal totalFeeChargesCharged = chargesDueAtTimeOfDisbursement;
|
||||||
BigDecimal totalPenaltyChargesCharged = BigDecimal.ZERO;
|
BigDecimal totalPenaltyChargesCharged = BigDecimal.ZERO;
|
||||||
BigDecimal totalWaived = BigDecimal.ZERO;
|
BigDecimal totalWaived = BigDecimal.ZERO;
|
||||||
BigDecimal totalWrittenOff = BigDecimal.ZERO;
|
BigDecimal totalWrittenOff = BigDecimal.ZERO;
|
||||||
@@ -117,10 +115,12 @@ public class EqualPrincipalAmortizationLoanScheduleGenerator implements Amortiza
|
|||||||
|
|
||||||
outstandingBalance = outstandingBalance.minus(principalForInstallment);
|
outstandingBalance = outstandingBalance.minus(principalForInstallment);
|
||||||
|
|
||||||
Money feeChargesForInstallment = Money.zero(monetaryCurrency);
|
final Money feeChargesForInstallment = cumulativeFeeChargesDueWithin(startDate, scheduledDueDate, loanCharges, monetaryCurrency);
|
||||||
Money penaltyChargesForInstallment = Money.zero(monetaryCurrency);
|
final Money penaltyChargesForInstallment = cumulativePenaltyChargesDueWithin(startDate, scheduledDueDate, loanCharges,
|
||||||
Money totalInstallmentDue = principalForInstallment.plus(interestForInstallment).plus(feeChargesForInstallment);
|
monetaryCurrency);
|
||||||
cumulativeChargesToDate = cumulativeChargesToDate.add(feeChargesForInstallment.getAmount());
|
|
||||||
|
final Money totalInstallmentDue = principalForInstallment.plus(interestForInstallment).plus(feeChargesForInstallment)
|
||||||
|
.plus(penaltyChargesForInstallment);
|
||||||
|
|
||||||
LoanSchedulePeriodData installment = LoanSchedulePeriodData.repaymentOnlyPeriod(periodNumber, startDate, scheduledDueDate,
|
LoanSchedulePeriodData installment = LoanSchedulePeriodData.repaymentOnlyPeriod(periodNumber, startDate, scheduledDueDate,
|
||||||
principalForInstallment.getAmount(), outstandingBalance.getAmount(), interestForInstallment.getAmount(),
|
principalForInstallment.getAmount(), outstandingBalance.getAmount(), interestForInstallment.getAmount(),
|
||||||
@@ -132,6 +132,8 @@ public class EqualPrincipalAmortizationLoanScheduleGenerator implements Amortiza
|
|||||||
loanTermInDays += daysInPeriod;
|
loanTermInDays += daysInPeriod;
|
||||||
totalPrincipalExpected = totalPrincipalExpected.add(principalForInstallment.getAmount());
|
totalPrincipalExpected = totalPrincipalExpected.add(principalForInstallment.getAmount());
|
||||||
totalInterestCharged = totalInterestCharged.add(interestForInstallment.getAmount());
|
totalInterestCharged = totalInterestCharged.add(interestForInstallment.getAmount());
|
||||||
|
totalFeeChargesCharged = totalFeeChargesCharged.add(feeChargesForInstallment.getAmount());
|
||||||
|
totalPenaltyChargesCharged = totalPenaltyChargesCharged.add(penaltyChargesForInstallment.getAmount());
|
||||||
totalRepaymentExpected = totalRepaymentExpected.add(totalInstallmentDue.getAmount());
|
totalRepaymentExpected = totalRepaymentExpected.add(totalInstallmentDue.getAmount());
|
||||||
startDate = scheduledDueDate;
|
startDate = scheduledDueDate;
|
||||||
|
|
||||||
@@ -145,4 +147,32 @@ public class EqualPrincipalAmortizationLoanScheduleGenerator implements Amortiza
|
|||||||
totalPrincipalPaid, totalInterestCharged, totalFeeChargesCharged, totalPenaltyChargesCharged, totalWaived, totalWrittenOff,
|
totalPrincipalPaid, totalInterestCharged, totalFeeChargesCharged, totalPenaltyChargesCharged, totalWaived, totalWrittenOff,
|
||||||
totalRepaymentExpected, totalRepayment, totalOutstanding);
|
totalRepaymentExpected, totalRepayment, totalOutstanding);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Money cumulativeFeeChargesDueWithin(final LocalDate periodStart, final LocalDate periodEnd, final Set<LoanCharge> loanCharges,
|
||||||
|
final MonetaryCurrency monetaryCurrency) {
|
||||||
|
|
||||||
|
Money cumulative = Money.zero(monetaryCurrency);
|
||||||
|
|
||||||
|
for (LoanCharge loanCharge : loanCharges) {
|
||||||
|
if (loanCharge.isDueForCollectionFromAndUpToAndIncluding(periodStart, periodEnd) && loanCharge.isFeeCharge()) {
|
||||||
|
cumulative = cumulative.plus(loanCharge.amount());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return cumulative;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Money cumulativePenaltyChargesDueWithin(final LocalDate periodStart, final LocalDate periodEnd,
|
||||||
|
final Set<LoanCharge> loanCharges, final MonetaryCurrency monetaryCurrency) {
|
||||||
|
|
||||||
|
Money cumulative = Money.zero(monetaryCurrency);
|
||||||
|
|
||||||
|
for (LoanCharge loanCharge : loanCharges) {
|
||||||
|
if (loanCharge.isDueForCollectionFromAndUpToAndIncluding(periodStart, periodEnd) && loanCharge.isPenaltyCharge()) {
|
||||||
|
cumulative = cumulative.plus(loanCharge.amount());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return cumulative;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+3
-6
@@ -67,8 +67,6 @@ public class FlatMethodLoanScheduleGenerator implements LoanScheduleGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BigDecimal cumulativeChargesToDate = chargesDueAtTimeOfDisbursement;
|
|
||||||
|
|
||||||
// create entries of disbursement period on loan schedule
|
// create entries of disbursement period on loan schedule
|
||||||
final LoanSchedulePeriodData disbursementPeriod = LoanSchedulePeriodData.disbursementOnlyPeriod(disbursementDate,
|
final LoanSchedulePeriodData disbursementPeriod = LoanSchedulePeriodData.disbursementOnlyPeriod(disbursementDate,
|
||||||
principalDisbursed.getAmount(), chargesDueAtTimeOfDisbursement, false);
|
principalDisbursed.getAmount(), chargesDueAtTimeOfDisbursement, false);
|
||||||
@@ -79,7 +77,7 @@ public class FlatMethodLoanScheduleGenerator implements LoanScheduleGenerator {
|
|||||||
BigDecimal totalPrincipalExpected = BigDecimal.ZERO;
|
BigDecimal totalPrincipalExpected = BigDecimal.ZERO;
|
||||||
BigDecimal totalPrincipalPaid = BigDecimal.ZERO;
|
BigDecimal totalPrincipalPaid = BigDecimal.ZERO;
|
||||||
BigDecimal totalInterestCharged = BigDecimal.ZERO;
|
BigDecimal totalInterestCharged = BigDecimal.ZERO;
|
||||||
BigDecimal totalFeeChargesCharged = BigDecimal.ZERO;
|
BigDecimal totalFeeChargesCharged = chargesDueAtTimeOfDisbursement;
|
||||||
BigDecimal totalPenaltyChargesCharged = BigDecimal.ZERO;
|
BigDecimal totalPenaltyChargesCharged = BigDecimal.ZERO;
|
||||||
BigDecimal totalWaived = BigDecimal.ZERO;
|
BigDecimal totalWaived = BigDecimal.ZERO;
|
||||||
BigDecimal totalWrittenOff = BigDecimal.ZERO;
|
BigDecimal totalWrittenOff = BigDecimal.ZERO;
|
||||||
@@ -124,9 +122,6 @@ public class FlatMethodLoanScheduleGenerator implements LoanScheduleGenerator {
|
|||||||
.plus(feeChargesForInstallment) //
|
.plus(feeChargesForInstallment) //
|
||||||
.plus(penaltyChargesForInstallment);
|
.plus(penaltyChargesForInstallment);
|
||||||
|
|
||||||
cumulativeChargesToDate = cumulativeChargesToDate.add(feeChargesForInstallment.getAmount()).add(
|
|
||||||
penaltyChargesForInstallment.getAmount());
|
|
||||||
|
|
||||||
LoanSchedulePeriodData installment = LoanSchedulePeriodData.repaymentOnlyPeriod(periodNumber, startDate, scheduledDueDate,
|
LoanSchedulePeriodData installment = LoanSchedulePeriodData.repaymentOnlyPeriod(periodNumber, startDate, scheduledDueDate,
|
||||||
principalPerInstallment.getAmount(), outstandingBalance.getAmount(), interestPerInstallment.getAmount(),
|
principalPerInstallment.getAmount(), outstandingBalance.getAmount(), interestPerInstallment.getAmount(),
|
||||||
feeChargesForInstallment.getAmount(), penaltyChargesForInstallment.getAmount(), totalInstallmentDue.getAmount());
|
feeChargesForInstallment.getAmount(), penaltyChargesForInstallment.getAmount(), totalInstallmentDue.getAmount());
|
||||||
@@ -137,6 +132,8 @@ public class FlatMethodLoanScheduleGenerator implements LoanScheduleGenerator {
|
|||||||
loanTermInDays += daysInPeriod;
|
loanTermInDays += daysInPeriod;
|
||||||
totalPrincipalExpected = totalPrincipalExpected.add(principalPerInstallment.getAmount());
|
totalPrincipalExpected = totalPrincipalExpected.add(principalPerInstallment.getAmount());
|
||||||
totalInterestCharged = totalInterestCharged.add(interestPerInstallment.getAmount());
|
totalInterestCharged = totalInterestCharged.add(interestPerInstallment.getAmount());
|
||||||
|
totalFeeChargesCharged = totalFeeChargesCharged.add(feeChargesForInstallment.getAmount());
|
||||||
|
totalPenaltyChargesCharged = totalPenaltyChargesCharged.add(penaltyChargesForInstallment.getAmount());
|
||||||
totalRepaymentExpected = totalRepaymentExpected.add(totalInstallmentDue.getAmount());
|
totalRepaymentExpected = totalRepaymentExpected.add(totalInstallmentDue.getAmount());
|
||||||
startDate = scheduledDueDate;
|
startDate = scheduledDueDate;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user