MIFOSX-376: sum up advance and late payments for each repayment period for totals display.

This commit is contained in:
Keith Woodlock
2013-06-06 15:50:15 +01:00
parent 066adccc44
commit d7bbdad075
4 changed files with 15 additions and 3 deletions
@@ -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<Long> {
@SuppressWarnings("unused")
@ManyToOne
@JoinColumn(name = "acc_rule_id", nullable = false)
private AccountingRule accountingRule;
@@ -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;
}
@@ -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<LoanScheduleModelPeriod> getPeriods() {
@@ -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());
}
}