http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/763cf18b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanInterestRecalculationDetails.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanInterestRecalculationDetails.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanInterestRecalculationDetails.java index fe071f5..a56c004 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanInterestRecalculationDetails.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanInterestRecalculationDetails.java @@ -18,23 +18,16 @@ */ package org.apache.fineract.portfolio.loanaccount.domain; -import java.util.Date; -import java.util.Map; - import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.JoinColumn; import javax.persistence.OneToOne; import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import org.apache.fineract.infrastructure.core.api.JsonCommand; -import org.apache.fineract.portfolio.loanproduct.LoanProductConstants; import org.apache.fineract.portfolio.loanproduct.domain.InterestRecalculationCompoundingMethod; +import org.apache.fineract.portfolio.loanproduct.domain.LoanProductInterestRecalculationDetails; import org.apache.fineract.portfolio.loanproduct.domain.LoanRescheduleStrategyMethod; import org.apache.fineract.portfolio.loanproduct.domain.RecalculationFrequencyType; -import org.joda.time.LocalDate; import org.springframework.data.jpa.domain.AbstractPersistable; /** @@ -70,9 +63,14 @@ public class LoanInterestRecalculationDetails extends AbstractPersistable<Long> @Column(name = "rest_frequency_interval", nullable = false) private Integer restInterval; - @Temporal(TemporalType.DATE) - @Column(name = "rest_freqency_date") - private Date restFrequencyDate; + @Column(name = "rest_frequency_nth_day_enum", nullable = true) + private Integer restFrequencyNthDay; + + @Column(name = "rest_frequency_weekday_enum", nullable = true) + private Integer restFrequencyWeekday; + + @Column(name = "rest_frequency_on_day", nullable = true) + private Integer restFrequencyOnDay; @Column(name = "compounding_frequency_type_enum", nullable = true) private Integer compoundingFrequencyType; @@ -80,78 +78,63 @@ public class LoanInterestRecalculationDetails extends AbstractPersistable<Long> @Column(name = "compounding_frequency_interval", nullable = true) private Integer compoundingInterval; - @Temporal(TemporalType.DATE) - @Column(name = "compounding_freqency_date") - private Date compoundingFrequencyDate; + @Column(name = "compounding_frequency_nth_day_enum", nullable = true) + private Integer compoundingFrequencyNthDay; + @Column(name = "compounding_frequency_weekday_enum", nullable = true) + private Integer compoundingFrequencyWeekday; + @Column(name = "compounding_frequency_on_day", nullable = true) + private Integer compoundingFrequencyOnDay; + + @Column(name = "is_compounding_to_be_posted_as_transaction") + private Boolean isCompoundingToBePostedAsTransaction; + @Column(name = "allow_compounding_on_eod") + private Boolean allowCompoundingOnEod; protected LoanInterestRecalculationDetails() { // Default constructor for jpa repository } private LoanInterestRecalculationDetails(final Integer interestRecalculationCompoundingMethod, final Integer rescheduleStrategyMethod, - final Integer restFrequencyType, final Integer restInterval, final Date restFrequencyDate, Integer compoundingFrequencyType, - Integer compoundingInterval, Date compoundingFrequencyDate) { + final Integer restFrequencyType, final Integer restInterval, final Integer restFrequencyNthDay, Integer restFrequencyWeekday, + Integer restFrequencyOnDay, Integer compoundingFrequencyType, Integer compoundingInterval, Integer compoundingFrequencyNthDay, + Integer compoundingFrequencyWeekday, Integer compoundingFrequencyOnDay, final boolean isCompoundingToBePostedAsTransaction, + final boolean allowCompoundingOnEod) { this.interestRecalculationCompoundingMethod = interestRecalculationCompoundingMethod; this.rescheduleStrategyMethod = rescheduleStrategyMethod; - this.restFrequencyDate = restFrequencyDate; + this.restFrequencyNthDay = restFrequencyNthDay; + this.restFrequencyWeekday = restFrequencyWeekday; + this.restFrequencyOnDay = restFrequencyOnDay; this.restFrequencyType = restFrequencyType; this.restInterval = restInterval; - this.compoundingFrequencyDate = compoundingFrequencyDate; + this.compoundingFrequencyNthDay = compoundingFrequencyNthDay; + this.compoundingFrequencyWeekday = compoundingFrequencyWeekday; + this.compoundingFrequencyOnDay = compoundingFrequencyOnDay; this.compoundingFrequencyType = compoundingFrequencyType; this.compoundingInterval = compoundingInterval; + this.isCompoundingToBePostedAsTransaction = isCompoundingToBePostedAsTransaction; + this.allowCompoundingOnEod = allowCompoundingOnEod; } - public static LoanInterestRecalculationDetails createFrom(final Integer interestRecalculationCompoundingMethod, - final Integer rescheduleStrategyMethod, final Integer restFrequencyType, final Integer restInterval, - final Date restFrequencyDate, final Integer compoundingFrequencyType, final Integer compoundingInterval, - final Date compoundingFrequencyDate) { - return new LoanInterestRecalculationDetails(interestRecalculationCompoundingMethod, rescheduleStrategyMethod, restFrequencyType, - restInterval, restFrequencyDate, compoundingFrequencyType, compoundingInterval, compoundingFrequencyDate); + public static LoanInterestRecalculationDetails createFrom( + final LoanProductInterestRecalculationDetails loanProductInterestRecalculationDetails) { + return new LoanInterestRecalculationDetails(loanProductInterestRecalculationDetails.getInterestRecalculationCompoundingMethod(), + loanProductInterestRecalculationDetails.getRescheduleStrategyMethod(), loanProductInterestRecalculationDetails + .getRestFrequencyType().getValue(), loanProductInterestRecalculationDetails.getRestInterval(), + loanProductInterestRecalculationDetails.getRestFrequencyNthDay(), + loanProductInterestRecalculationDetails.getRestFrequencyWeekday(), + loanProductInterestRecalculationDetails.getRestFrequencyOnDay(), loanProductInterestRecalculationDetails + .getCompoundingFrequencyType().getValue(), loanProductInterestRecalculationDetails.getCompoundingInterval(), + loanProductInterestRecalculationDetails.getCompoundingFrequencyNthDay(), + loanProductInterestRecalculationDetails.getCompoundingFrequencyWeekday(), + loanProductInterestRecalculationDetails.getCompoundingFrequencyOnDay(), + loanProductInterestRecalculationDetails.getIsCompoundingToBePostedAsTransaction(), + loanProductInterestRecalculationDetails.allowCompoundingOnEod()); } public void updateLoan(final Loan loan) { this.loan = loan; } - public void update(final JsonCommand command, final Map<String, Object> actualChanges) { - if (command.isChangeInLocalDateParameterNamed(LoanProductConstants.recalculationRestFrequencyDateParamName, - getRestFrequencyLocalDate())) { - final String dateFormatAsInput = command.dateFormat(); - final String localeAsInput = command.locale(); - final String valueAsInput = command.stringValueOfParameterNamed(LoanProductConstants.recalculationRestFrequencyDateParamName); - actualChanges.put(LoanProductConstants.recalculationRestFrequencyDateParamName, valueAsInput); - actualChanges.put("dateFormat", dateFormatAsInput); - actualChanges.put("locale", localeAsInput); - - final LocalDate newValue = command.localDateValueOfParameterNamed(LoanProductConstants.recalculationRestFrequencyDateParamName); - if (newValue == null || getRestFrequencyType().isSameAsRepayment()) { - this.restFrequencyDate = null; - } else { - this.restFrequencyDate = newValue.toDate(); - } - } - - if (command.isChangeInLocalDateParameterNamed(LoanProductConstants.recalculationCompoundingFrequencyDateParamName, - getCompoundingFrequencyLocalDate())) { - final String dateFormatAsInput = command.dateFormat(); - final String localeAsInput = command.locale(); - final String valueAsInput = command - .stringValueOfParameterNamed(LoanProductConstants.recalculationCompoundingFrequencyDateParamName); - actualChanges.put(LoanProductConstants.recalculationCompoundingFrequencyDateParamName, valueAsInput); - actualChanges.put("dateFormat", dateFormatAsInput); - actualChanges.put("locale", localeAsInput); - - final LocalDate newValue = command - .localDateValueOfParameterNamed(LoanProductConstants.recalculationCompoundingFrequencyDateParamName); - if (newValue == null || !getInterestRecalculationCompoundingMethod().isCompoundingEnabled() - || getCompoundingFrequencyType().isSameAsRepayment()) { - this.compoundingFrequencyDate = null; - } else { - this.compoundingFrequencyDate = newValue.toDate(); - } - } - } - public InterestRecalculationCompoundingMethod getInterestRecalculationCompoundingMethod() { return InterestRecalculationCompoundingMethod.fromInt(this.interestRecalculationCompoundingMethod); } @@ -160,14 +143,6 @@ public class LoanInterestRecalculationDetails extends AbstractPersistable<Long> return LoanRescheduleStrategyMethod.fromInt(this.rescheduleStrategyMethod); } - public LocalDate getRestFrequencyLocalDate() { - LocalDate recurrenceOnLocalDate = null; - if (this.restFrequencyDate != null) { - recurrenceOnLocalDate = new LocalDate(this.restFrequencyDate); - } - return recurrenceOnLocalDate; - } - public RecalculationFrequencyType getRestFrequencyType() { return RecalculationFrequencyType.fromInt(this.restFrequencyType); } @@ -176,14 +151,6 @@ public class LoanInterestRecalculationDetails extends AbstractPersistable<Long> return this.restInterval; } - public LocalDate getCompoundingFrequencyLocalDate() { - LocalDate recurrenceOnLocalDate = null; - if (this.compoundingFrequencyDate != null) { - recurrenceOnLocalDate = new LocalDate(this.compoundingFrequencyDate); - } - return recurrenceOnLocalDate; - } - public RecalculationFrequencyType getCompoundingFrequencyType() { return RecalculationFrequencyType.fromInt(this.compoundingFrequencyType); } @@ -191,4 +158,36 @@ public class LoanInterestRecalculationDetails extends AbstractPersistable<Long> public Integer getCompoundingInterval() { return this.compoundingInterval; } + + public Integer getRestFrequencyNthDay() { + return this.restFrequencyNthDay; + } + + public Integer getRestFrequencyWeekday() { + return this.restFrequencyWeekday; + } + + public Integer getRestFrequencyOnDay() { + return this.restFrequencyOnDay; + } + + public Integer getCompoundingFrequencyNthDay() { + return this.compoundingFrequencyNthDay; + } + + public Integer getCompoundingFrequencyWeekday() { + return this.compoundingFrequencyWeekday; + } + + public Integer getCompoundingFrequencyOnDay() { + return this.compoundingFrequencyOnDay; + } + + public boolean isCompoundingToBePostedAsTransaction() { + return null == this.isCompoundingToBePostedAsTransaction ? false : this.isCompoundingToBePostedAsTransaction; + } + + public boolean allowCompoundingOnEod() { + return this.allowCompoundingOnEod; + } }
http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/763cf18b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepaymentScheduleInstallment.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepaymentScheduleInstallment.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepaymentScheduleInstallment.java index 73aedb6..711a313 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepaymentScheduleInstallment.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepaymentScheduleInstallment.java @@ -19,13 +19,17 @@ package org.apache.fineract.portfolio.loanaccount.domain; import java.math.BigDecimal; +import java.util.ArrayList; import java.util.Comparator; import java.util.Date; +import java.util.List; +import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; @@ -34,6 +38,8 @@ import org.apache.fineract.infrastructure.core.domain.AbstractAuditableCustom; import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency; import org.apache.fineract.organisation.monetary.domain.Money; import org.apache.fineract.useradministration.domain.AppUser; +import org.hibernate.annotations.LazyCollection; +import org.hibernate.annotations.LazyCollectionOption; import org.joda.time.LocalDate; @Entity @@ -125,6 +131,10 @@ public final class LoanRepaymentScheduleInstallment extends AbstractAuditableCus @Column(name = "recalculated_interest_component", nullable = false) private boolean recalculatedInterestComponent; + @LazyCollection(LazyCollectionOption.FALSE) + @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) + @JoinColumn(name = "loan_repayment_schedule_id", referencedColumnName = "id", nullable = false) + private List<LoanInterestRecalcualtionAdditionalDetails> loanCompoundingDetails = new ArrayList<>(); protected LoanRepaymentScheduleInstallment() { this.installmentNumber = null; this.fromDate = null; @@ -134,7 +144,8 @@ public final class LoanRepaymentScheduleInstallment extends AbstractAuditableCus public LoanRepaymentScheduleInstallment(final Loan loan, final Integer installmentNumber, final LocalDate fromDate, final LocalDate dueDate, final BigDecimal principal, final BigDecimal interest, final BigDecimal feeCharges, - final BigDecimal penaltyCharges, boolean recalculatedInterestComponent) { + final BigDecimal penaltyCharges, final boolean recalculatedInterestComponent, + final List<LoanInterestRecalcualtionAdditionalDetails> compoundingDetails) { this.loan = loan; this.installmentNumber = installmentNumber; this.fromDate = fromDate.toDateTimeAtStartOfDay().toDate(); @@ -145,6 +156,7 @@ public final class LoanRepaymentScheduleInstallment extends AbstractAuditableCus this.penaltyCharges = defaultToNullIfZero(penaltyCharges); this.obligationsMet = false; this.recalculatedInterestComponent = recalculatedInterestComponent; + this.loanCompoundingDetails = compoundingDetails; } public LoanRepaymentScheduleInstallment(final Loan loan) { @@ -770,4 +782,7 @@ public final class LoanRepaymentScheduleInstallment extends AbstractAuditableCus public Money getDue(MonetaryCurrency currency) { return getPrincipal(currency).plus(getInterestCharged(currency)).plus(getFeeChargesCharged(currency)).plus(getPenaltyChargesCharged(currency)); } + public List<LoanInterestRecalcualtionAdditionalDetails> getLoanCompoundingDetails() { + return this.loanCompoundingDetails; + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/763cf18b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanTransaction.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanTransaction.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanTransaction.java index 6d4783a..8172d0b 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanTransaction.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanTransaction.java @@ -146,6 +146,19 @@ public final class LoanTransaction extends AbstractPersistable<Long> { this.appUser = null; } + public static LoanTransaction incomePosting(final Loan loan, final Office office, final Date dateOf, + final BigDecimal amount, final BigDecimal interestPortion, final BigDecimal feeChargesPortion, + final BigDecimal penaltyChargesPortion, final AppUser appUser){ + final Integer typeOf = LoanTransactionType.INCOME_POSTING.getValue(); + final BigDecimal principalPortion = BigDecimal.ZERO; + final BigDecimal overPaymentPortion = BigDecimal.ZERO; + final boolean reversed = false; + final PaymentDetail paymentDetail = null; + final String externalId = null; + final LocalDateTime createdDate = DateUtils.getLocalDateTimeOfTenant(); + return new LoanTransaction(loan, office, typeOf, dateOf, amount, principalPortion, interestPortion, feeChargesPortion, + penaltyChargesPortion, overPaymentPortion, reversed, paymentDetail, externalId, createdDate, appUser); + } public static LoanTransaction disbursement(final Office office, final Money amount, final PaymentDetail paymentDetail, final LocalDate disbursementDate, final String externalId, final LocalDateTime createdDate, final AppUser appUser) { return new LoanTransaction(null, office, LoanTransactionType.DISBURSEMENT, paymentDetail, amount.getAmount(), disbursementDate, @@ -199,6 +212,19 @@ public final class LoanTransaction extends AbstractPersistable<Long> { principalPortion, interestPortion, feesPortion, penaltiesPortion, overPaymentPortion, reversed, paymentDetail, externalId, createdDate, appUser); } + public static LoanTransaction accrueTransaction(final Loan loan, final Office office, final LocalDate dateOf, final BigDecimal amount, + final BigDecimal interestPortion, final BigDecimal feeChargesPortion, + final BigDecimal penaltyChargesPortion, final AppUser appUser) { + BigDecimal principalPortion = null; + BigDecimal overPaymentPortion = null; + boolean reversed = false; + PaymentDetail paymentDetail = null; + String externalId = null; + LocalDateTime createdDate = DateUtils.getLocalDateTimeOfTenant(); + return new LoanTransaction(loan, office, LoanTransactionType.ACCRUAL.getValue(), dateOf.toDate(), amount, + principalPortion, interestPortion, feeChargesPortion, penaltyChargesPortion, overPaymentPortion, reversed, paymentDetail, externalId, + createdDate, appUser); + } public static LoanTransaction initiateTransfer(final Office office, final Loan loan, final LocalDate transferDate, final LocalDateTime createdDate, final AppUser appUser) { @@ -461,6 +487,9 @@ public final class LoanTransaction extends AbstractPersistable<Long> { return !isRepayment(); } + public boolean isIncomePosting() { + return LoanTransactionType.INCOME_POSTING.equals(getTypeOf()) && isNotReversed(); + } public boolean isDisbursement() { return LoanTransactionType.DISBURSEMENT.equals(getTypeOf()) && isNotReversed(); } http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/763cf18b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanTransactionType.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanTransactionType.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanTransactionType.java index 2e1ae0d..d898561 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanTransactionType.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanTransactionType.java @@ -51,7 +51,8 @@ public enum LoanTransactionType { REJECT_TRANSFER(15, "loanTransactionType.rejectTransfer"), // REFUND(16, "loanTransactionType.refund"), // CHARGE_PAYMENT(17, "loanTransactionType.chargePayment"), // - REFUND_FOR_ACTIVE_LOAN(18, "loanTransactionType.refund"); + REFUND_FOR_ACTIVE_LOAN(18, "loanTransactionType.refund"), // + INCOME_POSTING(19,"loanTransactionType.incomePosting"); private final Integer value; private final String code; @@ -126,6 +127,9 @@ public enum LoanTransactionType { case 18: loanTransactionType = LoanTransactionType.REFUND_FOR_ACTIVE_LOAN; break; + case 19: + loanTransactionType = LoanTransactionType.INCOME_POSTING; + break; default: loanTransactionType = LoanTransactionType.INVALID; break; @@ -172,4 +176,7 @@ public enum LoanTransactionType { public boolean isRefundForActiveLoan() { return this.value.equals(LoanTransactionType.REFUND_FOR_ACTIVE_LOAN.getValue()); } + public boolean isIncomePosting() { + return this.value.equals(LoanTransactionType.INCOME_POSTING.getValue()); + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/763cf18b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/data/LoanScheduleParams.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/data/LoanScheduleParams.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/data/LoanScheduleParams.java index 679964a..446c64e 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/data/LoanScheduleParams.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/data/LoanScheduleParams.java @@ -69,8 +69,19 @@ public class LoanScheduleParams { // date(after applying compounding frequency) // from when these amounts will effect the outstanding balance for // interest calculation - private final TreeMap<LocalDate, Money> compoundingMap; - private final Map<LocalDate, TreeMap<LocalDate, Money>> compoundingDateVariations = new HashMap<>(); + private final Map<LocalDate, Money> compoundingMap; + private final Map<LocalDate, Map<LocalDate, Money>> compoundingDateVariations = new HashMap<>(); + private Money unCompoundedAmount; + private Money compoundedInLastInstallment; + + + public Money getCompoundedInLastInstallment() { + return this.compoundedInLastInstallment; + } + + public void setCompoundedInLastInstallment(Money compoundedInLastInstallment) { + this.compoundedInLastInstallment = compoundedInLastInstallment; + } // disbursement map for tranche details(will added to outstanding // balance as per the start date) @@ -94,7 +105,7 @@ public class LoanScheduleParams { final LocalDate actualRepaymentDate, final Money totalCumulativePrincipal, final Money totalCumulativeInterest, final Money totalFeeChargesCharged, final Money totalPenaltyChargesCharged, final Money totalRepaymentExpected, Money totalOutstandingInterestPaymentDueToGrace, final Money reducePrincipal, final Map<LocalDate, Money> principalPortionMap, - final Map<LocalDate, Money> latePaymentMap, final TreeMap<LocalDate, Money> compoundingMap, + final Map<LocalDate, Money> latePaymentMap, final Map<LocalDate, Money> compoundingMap, final Money unCompoundedAmount, final Map<LocalDate, Money> disburseDetailMap, Money principalToBeScheduled, final Money outstandingBalance, final Money outstandingBalanceAsPerRest, final List<LoanRepaymentScheduleInstallment> installments, final Collection<RecalculationDetail> recalculationDetails, @@ -115,6 +126,7 @@ public class LoanScheduleParams { this.principalPortionMap = principalPortionMap; this.latePaymentMap = latePaymentMap; this.compoundingMap = compoundingMap; + this.unCompoundedAmount = unCompoundedAmount; this.disburseDetailMap = disburseDetailMap; this.principalToBeScheduled = principalToBeScheduled; this.outstandingBalance = outstandingBalance; @@ -126,6 +138,9 @@ public class LoanScheduleParams { this.partialUpdate = partialUpdate; this.currency = currency; this.applyInterestRecalculation = applyInterestRecalculation; + if (this.currency != null) { + this.compoundedInLastInstallment = Money.zero(this.currency); + } } public static LoanScheduleParams createLoanScheduleParamsForPartialUpdate(final int periodNumber, final int instalmentNumber, @@ -133,8 +148,8 @@ public class LoanScheduleParams { final Money totalCumulativeInterest, final Money totalFeeChargesCharged, final Money totalPenaltyChargesCharged, final Money totalRepaymentExpected, Money totalOutstandingInterestPaymentDueToGrace, final Money reducePrincipal, final Map<LocalDate, Money> principalPortionMap, final Map<LocalDate, Money> latePaymentMap, - final TreeMap<LocalDate, Money> compoundingMap, final Map<LocalDate, Money> disburseDetailMap, Money principalToBeScheduled, - final Money outstandingBalance, final Money outstandingBalanceAsPerRest, + final Map<LocalDate, Money> compoundingMap, Money unCompoundedAmount, final Map<LocalDate, Money> disburseDetailMap, + final Money principalToBeScheduled, final Money outstandingBalance, final Money outstandingBalanceAsPerRest, final List<LoanRepaymentScheduleInstallment> installments, final Collection<RecalculationDetail> recalculationDetails, final LoanRepaymentScheduleTransactionProcessor loanRepaymentScheduleTransactionProcessor, final LocalDate scheduleTillDate, final MonetaryCurrency currency, final boolean applyInterestRecalculation) { @@ -142,9 +157,9 @@ public class LoanScheduleParams { return new LoanScheduleParams(periodNumber, instalmentNumber, loanTermInDays, periodStartDate, actualRepaymentDate, totalCumulativePrincipal, totalCumulativeInterest, totalFeeChargesCharged, totalPenaltyChargesCharged, totalRepaymentExpected, totalOutstandingInterestPaymentDueToGrace, reducePrincipal, principalPortionMap, latePaymentMap, - compoundingMap, disburseDetailMap, principalToBeScheduled, outstandingBalance, outstandingBalanceAsPerRest, installments, - recalculationDetails, loanRepaymentScheduleTransactionProcessor, scheduleTillDate, partialUpdate, currency, - applyInterestRecalculation); + compoundingMap, unCompoundedAmount, disburseDetailMap, principalToBeScheduled, outstandingBalance, + outstandingBalanceAsPerRest, installments, recalculationDetails, loanRepaymentScheduleTransactionProcessor, + scheduleTillDate, partialUpdate, currency, applyInterestRecalculation); } public static LoanScheduleParams createLoanScheduleParamsForCompleteUpdate(final Collection<RecalculationDetail> recalculationDetails, @@ -162,7 +177,7 @@ public class LoanScheduleParams { final Money reducePrincipal = null; final Map<LocalDate, Money> principalPortionMap = null; final Map<LocalDate, Money> latePaymentMap = null; - final TreeMap<LocalDate, Money> compoundingMap = null; + final Map<LocalDate, Money> compoundingMap = null; final Map<LocalDate, Money> disburseDetailMap = null; final Money principalToBeScheduled = null; final Money outstandingBalance = null; @@ -172,12 +187,13 @@ public class LoanScheduleParams { final int loanTermInDays = 0; final Money totalOutstandingInterestPaymentDueToGrace = null; final MonetaryCurrency currency = null; + final Money unCompoundedAmount = null; return new LoanScheduleParams(periodNumber, instalmentNumber, loanTermInDays, periodStartDate, actualRepaymentDate, totalCumulativePrincipal, totalCumulativeInterest, totalFeeChargesCharged, totalPenaltyChargesCharged, totalRepaymentExpected, totalOutstandingInterestPaymentDueToGrace, reducePrincipal, principalPortionMap, latePaymentMap, - compoundingMap, disburseDetailMap, principalToBeScheduled, outstandingBalance, outstandingBalanceAsPerRest, installments, - recalculationDetails, loanRepaymentScheduleTransactionProcessor, scheduleTillDate, partialUpdate, currency, - applyInterestRecalculation); + compoundingMap, unCompoundedAmount, disburseDetailMap, principalToBeScheduled, outstandingBalance, + outstandingBalanceAsPerRest, installments, recalculationDetails, loanRepaymentScheduleTransactionProcessor, + scheduleTillDate, partialUpdate, currency, applyInterestRecalculation); } public static LoanScheduleParams createLoanScheduleParams(final MonetaryCurrency currency, final Money chargesDueAtTimeOfDisbursement, @@ -195,7 +211,7 @@ public class LoanScheduleParams { final Money reducePrincipal = Money.zero(currency); final Map<LocalDate, Money> principalPortionMap = new HashMap<>(); final Map<LocalDate, Money> latePaymentMap = new HashMap<>(); - final TreeMap<LocalDate, Money> compoundingMap = new TreeMap<>(); + final Map<LocalDate, Money> compoundingMap = new TreeMap<>(); final Map<LocalDate, Money> disburseDetailMap = new TreeMap<>(); final Money outstandingBalance = principalToBeScheduled; final Money outstandingBalanceAsPerRest = principalToBeScheduled; @@ -205,12 +221,13 @@ public class LoanScheduleParams { final LoanRepaymentScheduleTransactionProcessor loanRepaymentScheduleTransactionProcessor = null; final LocalDate scheduleTillDate = null; final boolean applyInterestRecalculation = false; + final Money unCompoundedAmount = Money.zero(currency); return new LoanScheduleParams(periodNumber, instalmentNumber, loanTermInDays, periodStartDate, actualRepaymentDate, totalCumulativePrincipal, totalCumulativeInterest, totalFeeChargesCharged, totalPenaltyChargesCharged, totalRepaymentExpected, totalOutstandingInterestPaymentDueToGrace, reducePrincipal, principalPortionMap, latePaymentMap, - compoundingMap, disburseDetailMap, principalToBeScheduled, outstandingBalance, outstandingBalanceAsPerRest, installments, - recalculationDetails, loanRepaymentScheduleTransactionProcessor, scheduleTillDate, partialUpdate, currency, - applyInterestRecalculation); + compoundingMap, unCompoundedAmount, disburseDetailMap, principalToBeScheduled, outstandingBalance, + outstandingBalanceAsPerRest, installments, recalculationDetails, loanRepaymentScheduleTransactionProcessor, + scheduleTillDate, partialUpdate, currency, applyInterestRecalculation); } public static LoanScheduleParams createLoanScheduleParams(final MonetaryCurrency currency, final Money chargesDueAtTimeOfDisbursement, @@ -228,7 +245,7 @@ public class LoanScheduleParams { final Money reducePrincipal = Money.zero(currency); final Map<LocalDate, Money> principalPortionMap = new HashMap<>(); final Map<LocalDate, Money> latePaymentMap = new HashMap<>(); - final TreeMap<LocalDate, Money> compoundingMap = new TreeMap<>(); + final Map<LocalDate, Money> compoundingMap = new TreeMap<>(); final Map<LocalDate, Money> disburseDetailMap = new TreeMap<>(); final Money outstandingBalance = principalToBeScheduled; final Money outstandingBalanceAsPerRest = principalToBeScheduled; @@ -238,12 +255,13 @@ public class LoanScheduleParams { final LoanRepaymentScheduleTransactionProcessor loanRepaymentScheduleTransactionProcessor = loanScheduleParams.loanRepaymentScheduleTransactionProcessor; final LocalDate scheduleTillDate = loanScheduleParams.scheduleTillDate; final boolean applyInterestRecalculation = loanScheduleParams.applyInterestRecalculation; + final Money unCompoundedAmount = Money.zero(currency); return new LoanScheduleParams(periodNumber, instalmentNumber, loanTermInDays, periodStartDate, actualRepaymentDate, totalCumulativePrincipal, totalCumulativeInterest, totalFeeChargesCharged, totalPenaltyChargesCharged, totalRepaymentExpected, totalOutstandingInterestPaymentDueToGrace, reducePrincipal, principalPortionMap, latePaymentMap, - compoundingMap, disburseDetailMap, principalToBeScheduled, outstandingBalance, outstandingBalanceAsPerRest, installments, - recalculationDetails, loanRepaymentScheduleTransactionProcessor, scheduleTillDate, partialUpdate, currency, - applyInterestRecalculation); + compoundingMap, unCompoundedAmount, disburseDetailMap, principalToBeScheduled, outstandingBalance, + outstandingBalanceAsPerRest, installments, recalculationDetails, loanRepaymentScheduleTransactionProcessor, + scheduleTillDate, partialUpdate, currency, applyInterestRecalculation); } public int getPeriodNumber() { @@ -310,7 +328,7 @@ public class LoanScheduleParams { return this.latePaymentMap; } - public TreeMap<LocalDate, Money> getCompoundingMap() { + public Map<LocalDate, Money> getCompoundingMap() { return this.compoundingMap; } @@ -434,7 +452,7 @@ public class LoanScheduleParams { this.totalOutstandingInterestPaymentDueToGrace = totalOutstandingInterestPaymentDueToGrace; } - public Map<LocalDate, TreeMap<LocalDate, Money>> getCompoundingDateVariations() { + public Map<LocalDate, Map<LocalDate, Money>> getCompoundingDateVariations() { return this.compoundingDateVariations; } @@ -446,4 +464,18 @@ public class LoanScheduleParams { return this.applyInterestRecalculation; } + public Money getUnCompoundedAmount() { + return this.unCompoundedAmount; + } + public void addUnCompoundedAmount(Money unCompoundedAmount) { + this.unCompoundedAmount = this.unCompoundedAmount.plus(unCompoundedAmount); + } + + public void minusUnCompoundedAmount(Money unCompoundedAmount) { + this.unCompoundedAmount = this.unCompoundedAmount.minus(unCompoundedAmount); + } + + public void setUnCompoundedAmount(Money unCompoundedAmount) { + this.unCompoundedAmount = unCompoundedAmount; + } }
