updating fee_charges_charged and fee_charges_repaid to include charges due at disbursal

This commit is contained in:
Vishwas Babu AJ
2013-03-26 01:24:41 +05:30
parent ef223b346c
commit 17ad0984c0
2 changed files with 14 additions and 5 deletions
@@ -770,7 +770,8 @@ public class Loan extends AbstractPersistable<Long> {
this.summaryArrearsAging = null; this.summaryArrearsAging = null;
} else { } else {
final Money principal = this.loanRepaymentScheduleDetail.getPrincipal(); final Money principal = this.loanRepaymentScheduleDetail.getPrincipal();
this.summary.updateSummary(loanCurrency(), principal, this.repaymentScheduleInstallments, this.loanSummaryWrapper); this.summary.updateSummary(loanCurrency(), principal, this.repaymentScheduleInstallments, this.loanSummaryWrapper,
isDisbursed());
if (this.summaryArrearsAging == null) { if (this.summaryArrearsAging == null) {
this.summaryArrearsAging = new LoanSummaryArrearsAging(this); this.summaryArrearsAging = new LoanSummaryArrearsAging(this);
} }
@@ -130,7 +130,7 @@ public final class LoanSummary {
public boolean isRepaidInFull(final MonetaryCurrency currency) { public boolean isRepaidInFull(final MonetaryCurrency currency) {
return getTotalOutstanding(currency).isZero(); return getTotalOutstanding(currency).isZero();
} }
public BigDecimal getTotalInterestCharged() { public BigDecimal getTotalInterestCharged() {
return this.totalInterestCharged; return this.totalInterestCharged;
} }
@@ -169,7 +169,8 @@ public final class LoanSummary {
} }
public void updateSummary(final MonetaryCurrency currency, final Money principal, public void updateSummary(final MonetaryCurrency currency, final Money principal,
final List<LoanRepaymentScheduleInstallment> repaymentScheduleInstallments, final LoanSummaryWrapper summaryWrapper) { final List<LoanRepaymentScheduleInstallment> repaymentScheduleInstallments, final LoanSummaryWrapper summaryWrapper,
final Boolean disbursed) {
this.totalPrincipalDisbursed = principal.getAmount(); this.totalPrincipalDisbursed = principal.getAmount();
this.totalPrincipalRepaid = summaryWrapper.calculateTotalPrincipalRepaid(repaymentScheduleInstallments, currency).getAmount(); this.totalPrincipalRepaid = summaryWrapper.calculateTotalPrincipalRepaid(repaymentScheduleInstallments, currency).getAmount();
@@ -189,9 +190,16 @@ public final class LoanSummary {
.minus(this.totalInterestWrittenOff).getAmount(); .minus(this.totalInterestWrittenOff).getAmount();
} }
final Money totalFeeChargesCharged = summaryWrapper.calculateTotalFeeChargesCharged(repaymentScheduleInstallments, currency); final Money totalFeeChargesCharged = summaryWrapper.calculateTotalFeeChargesCharged(repaymentScheduleInstallments, currency).plus(
this.totalFeeChargesDueAtDisbursement);
this.totalFeeChargesCharged = totalFeeChargesCharged.getAmount(); this.totalFeeChargesCharged = totalFeeChargesCharged.getAmount();
this.totalFeeChargesRepaid = summaryWrapper.calculateTotalFeeChargesRepaid(repaymentScheduleInstallments, currency).getAmount();
Money totalFeeChargesRepaid = summaryWrapper.calculateTotalFeeChargesRepaid(repaymentScheduleInstallments, currency);
if (disbursed) {
totalFeeChargesRepaid = totalFeeChargesRepaid.plus(this.totalFeeChargesDueAtDisbursement);
}
this.totalFeeChargesRepaid = totalFeeChargesRepaid.getAmount();
this.totalFeeChargesWaived = summaryWrapper.calculateTotalFeeChargesWaived(repaymentScheduleInstallments, currency).getAmount(); this.totalFeeChargesWaived = summaryWrapper.calculateTotalFeeChargesWaived(repaymentScheduleInstallments, currency).getAmount();
this.totalFeeChargesWrittenOff = summaryWrapper.calculateTotalFeeChargesWrittenOff(repaymentScheduleInstallments, currency) this.totalFeeChargesWrittenOff = summaryWrapper.calculateTotalFeeChargesWrittenOff(repaymentScheduleInstallments, currency)
.getAmount(); .getAmount();