adamsaghy commented on code in PR #3377: URL: https://github.com/apache/fineract/pull/3377#discussion_r1297134957
########## fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/data/LoanScheduleModelDownPaymentPeriod.java: ########## @@ -0,0 +1,148 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.loanaccount.loanschedule.data; + +import java.math.BigDecimal; +import java.time.LocalDate; +import java.util.Set; +import org.apache.fineract.organisation.monetary.domain.Money; +import org.apache.fineract.portfolio.loanaccount.domain.LoanInterestRecalcualtionAdditionalDetails; +import org.apache.fineract.portfolio.loanaccount.loanschedule.domain.LoanScheduleModelPeriod; + +public class LoanScheduleModelDownPaymentPeriod implements LoanScheduleModelPeriod { + + private final int periodNumber; + private final LocalDate periodDate; + private Money principalDue; + private final Money outstandingLoanBalance; + + public static LoanScheduleModelDownPaymentPeriod downPayment(final int periodNumber, final LocalDate periodDate, + final Money principalDue, final Money outstandingLoanBalance) { + + return new LoanScheduleModelDownPaymentPeriod(periodNumber, periodDate, principalDue, outstandingLoanBalance); + } + + public LoanScheduleModelDownPaymentPeriod(int periodNumber, LocalDate periodDate, Money principalDue, Money outstandingLoanBalance) { + this.periodNumber = periodNumber; + this.periodDate = periodDate; + this.principalDue = principalDue; + this.outstandingLoanBalance = outstandingLoanBalance; + } + + @Override + public LoanSchedulePeriodData toData() { + return LoanSchedulePeriodData.downPaymentOnlyPeriod(this.periodNumber, this.periodDate, this.principalDue.getAmount(), + this.outstandingLoanBalance.getAmount()); + } + + @Override + public boolean isRepaymentPeriod() { + return false; + } + + @Override + public boolean isDownPaymentPeriod() { + return true; + } + + @Override + public Integer periodNumber() { + return this.periodNumber; + } + + @Override + public LocalDate periodFromDate() { + return this.periodDate; + } + + @Override + public LocalDate periodDueDate() { + return this.periodDate; + } + + @Override + public BigDecimal principalDue() { + BigDecimal value = null; + if (this.principalDue != null) { + value = this.principalDue.getAmount(); + } + + return value; + } + + @Override + public BigDecimal interestDue() { + return BigDecimal.ZERO; + } + + @Override + public BigDecimal feeChargesDue() { + return BigDecimal.ZERO; + } + + @Override + public BigDecimal penaltyChargesDue() { + return BigDecimal.ZERO; + } + + @Override + public void addLoanCharges(BigDecimal feeCharge, BigDecimal penaltyCharge) { Review Comment: Should we have UnsupportedOperationException here? (and all the below not implemented functionalities?) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
