From d7bbdad07519340fe7e95e77c2cdf68323a45cb9 Mon Sep 17 00:00:00 2001 From: Keith Woodlock Date: Thu, 6 Jun 2013 15:50:15 +0100 Subject: [PATCH] MIFOSX-376: sum up advance and late payments for each repayment period for totals display. --- .../accounting/rule/domain/AccountingTagRule.java | 1 + .../loanaccount/loanschedule/data/LoanScheduleData.java | 7 ++++++- .../loanaccount/loanschedule/domain/LoanScheduleModel.java | 4 +++- .../loanaccount/service/LoanReadPlatformServiceImpl.java | 6 +++++- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/rule/domain/AccountingTagRule.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/rule/domain/AccountingTagRule.java index f43a99cef..16b03e806 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/rule/domain/AccountingTagRule.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/rule/domain/AccountingTagRule.java @@ -20,6 +20,7 @@ import org.springframework.data.jpa.domain.AbstractPersistable; @Table(name = "acc_rule_tags", uniqueConstraints = { @UniqueConstraint(columnNames = { "acc_rule_id", "tag_id", "acc_type_enum" }, name = "UNIQUE_ACCOUNT_RULE_TAGS") }) public class AccountingTagRule extends AbstractPersistable { + @SuppressWarnings("unused") @ManyToOne @JoinColumn(name = "acc_rule_id", nullable = false) private AccountingRule accountingRule; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/data/LoanScheduleData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/data/LoanScheduleData.java index aa8e6076f..baa33502e 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/data/LoanScheduleData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/data/LoanScheduleData.java @@ -38,6 +38,8 @@ public class LoanScheduleData { private final BigDecimal totalWrittenOff; private final BigDecimal totalRepaymentExpected; private final BigDecimal totalRepayment; + private final BigDecimal totalPaidInAdvance; + private final BigDecimal totalPaidLate; private final BigDecimal totalOutstanding; /** @@ -51,7 +53,8 @@ public class LoanScheduleData { final BigDecimal totalPrincipalDisbursed, final BigDecimal totalPrincipalExpected, final BigDecimal totalPrincipalPaid, final BigDecimal totalInterestCharged, final BigDecimal totalFeeChargesCharged, final BigDecimal totalPenaltyChargesCharged, final BigDecimal totalWaived, final BigDecimal totalWrittenOff, final BigDecimal totalRepaymentExpected, - final BigDecimal totalRepayment, final BigDecimal totalOutstanding) { + final BigDecimal totalRepayment, final BigDecimal totalPaidInAdvance, final BigDecimal totalPaidLate, + final BigDecimal totalOutstanding) { this.currency = currency; this.periods = periods; this.loanTermInDays = loanTermInDays; @@ -65,6 +68,8 @@ public class LoanScheduleData { this.totalWrittenOff = totalWrittenOff; this.totalRepaymentExpected = totalRepaymentExpected; this.totalRepayment = totalRepayment; + this.totalPaidInAdvance = totalPaidInAdvance; + this.totalPaidLate = totalPaidLate; this.totalOutstanding = totalOutstanding; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/LoanScheduleModel.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/LoanScheduleModel.java index 0a8ea9e54..495fcdbea 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/LoanScheduleModel.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/LoanScheduleModel.java @@ -72,11 +72,13 @@ public final class LoanScheduleModel { BigDecimal totalWaived = null; BigDecimal totalWrittenOff = null; BigDecimal totalRepayment = null; + BigDecimal totalPaidInAdvance = null; + BigDecimal totalPaidLate = null; return new LoanScheduleData(currency, periodsData, this.loanTermInDays, this.totalPrincipalDisbursed.getAmount(), this.totalPrincipalExpected, this.totalPrincipalPaid, this.totalInterestCharged, this.totalFeeChargesCharged, this.totalPenaltyChargesCharged, totalWaived, totalWrittenOff, this.totalRepaymentExpected, totalRepayment, - this.totalOutstanding); + totalPaidInAdvance, totalPaidLate, this.totalOutstanding); } public Collection getPeriods() { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java index 1678499a8..424d6dc63 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java @@ -702,6 +702,8 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { Money totalWrittenOff = Money.zero(monCurrency); Money totalRepaymentExpected = Money.zero(monCurrency); Money totalRepayment = Money.zero(monCurrency); + Money totalPaidInAdvance = Money.zero(monCurrency); + Money totalPaidLate = Money.zero(monCurrency); Money totalOutstanding = Money.zero(monCurrency); // update totals with details of fees charged during disbursement @@ -783,6 +785,8 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { totalRepaymentExpected = totalRepaymentExpected.plus(totalDueForPeriod); totalRepayment = totalRepayment.plus(totalPaidForPeriod); + totalPaidInAdvance = totalPaidInAdvance.plus(totalPaidInAdvanceForPeriod); + totalPaidLate = totalPaidLate.plus(totalPaidLateForPeriod); totalOutstanding = totalOutstanding.plus(totalOutstandingForPeriod); if (fromDate == null) { @@ -810,7 +814,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { totalPrincipalExpected.getAmount(), totalPrincipalPaid.getAmount(), totalInterestCharged.getAmount(), totalFeeChargesCharged.getAmount(), totalPenaltyChargesCharged.getAmount(), totalWaived.getAmount(), totalWrittenOff.getAmount(), totalRepaymentExpected.getAmount(), totalRepayment.getAmount(), - totalOutstanding.getAmount()); + totalPaidInAdvance.getAmount(), totalPaidLate.getAmount(), totalOutstanding.getAmount()); } }