Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id BCA64200AE3 for ; Wed, 4 May 2016 16:26:20 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id BAFE9160A00; Wed, 4 May 2016 14:26:20 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 3D4B61609A1 for ; Wed, 4 May 2016 16:26:19 +0200 (CEST) Received: (qmail 79020 invoked by uid 500); 4 May 2016 14:26:18 -0000 Mailing-List: contact commits-help@fineract.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@fineract.incubator.apache.org Delivered-To: mailing list commits@fineract.incubator.apache.org Received: (qmail 79007 invoked by uid 99); 4 May 2016 14:26:18 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 May 2016 14:26:18 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id E7DDECA5CC for ; Wed, 4 May 2016 14:26:17 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -5.299 X-Spam-Level: X-Spam-Status: No, score=-5.299 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-2.079] autolearn=disabled Received: from mx2-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id JqQRFNZcac-O for ; Wed, 4 May 2016 14:26:15 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx2-lw-us.apache.org (ASF Mail Server at mx2-lw-us.apache.org) with SMTP id 9029160D4A for ; Wed, 4 May 2016 14:26:14 +0000 (UTC) Received: (qmail 78681 invoked by uid 99); 4 May 2016 14:26:13 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 May 2016 14:26:13 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 589C3E0103; Wed, 4 May 2016 14:26:13 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: rajuan@apache.org To: commits@fineract.incubator.apache.org Date: Wed, 04 May 2016 14:26:18 -0000 Message-Id: In-Reply-To: <90afa0d811124be9931189049d8c3710@git.apache.org> References: <90afa0d811124be9931189049d8c3710@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [06/10] incubator-fineract git commit: FINERACT-60 : Interest compounding, nth day rest frequency and meeting calendar date changes archived-at: Wed, 04 May 2016 14:26:20 -0000 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 @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 @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 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 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 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 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 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 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 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 { 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 { 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 { 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 compoundingMap; - private final Map> compoundingDateVariations = new HashMap<>(); + private final Map compoundingMap; + private final Map> 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 principalPortionMap, - final Map latePaymentMap, final TreeMap compoundingMap, + final Map latePaymentMap, final Map compoundingMap, final Money unCompoundedAmount, final Map disburseDetailMap, Money principalToBeScheduled, final Money outstandingBalance, final Money outstandingBalanceAsPerRest, final List installments, final Collection 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 principalPortionMap, final Map latePaymentMap, - final TreeMap compoundingMap, final Map disburseDetailMap, Money principalToBeScheduled, - final Money outstandingBalance, final Money outstandingBalanceAsPerRest, + final Map compoundingMap, Money unCompoundedAmount, final Map disburseDetailMap, + final Money principalToBeScheduled, final Money outstandingBalance, final Money outstandingBalanceAsPerRest, final List installments, final Collection 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 recalculationDetails, @@ -162,7 +177,7 @@ public class LoanScheduleParams { final Money reducePrincipal = null; final Map principalPortionMap = null; final Map latePaymentMap = null; - final TreeMap compoundingMap = null; + final Map compoundingMap = null; final Map 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 principalPortionMap = new HashMap<>(); final Map latePaymentMap = new HashMap<>(); - final TreeMap compoundingMap = new TreeMap<>(); + final Map compoundingMap = new TreeMap<>(); final Map 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 principalPortionMap = new HashMap<>(); final Map latePaymentMap = new HashMap<>(); - final TreeMap compoundingMap = new TreeMap<>(); + final Map compoundingMap = new TreeMap<>(); final Map 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 getCompoundingMap() { + public Map getCompoundingMap() { return this.compoundingMap; } @@ -434,7 +452,7 @@ public class LoanScheduleParams { this.totalOutstandingInterestPaymentDueToGrace = totalOutstandingInterestPaymentDueToGrace; } - public Map> getCompoundingDateVariations() { + public Map> 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; + } }