janez89 commented on code in PR #4099: URL: https://github.com/apache/fineract/pull/4099#discussion_r1801367563
########## fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/data/InterestPeriod.java: ########## @@ -0,0 +1,110 @@ +/** + * 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 jakarta.validation.constraints.NotNull; +import java.math.BigDecimal; +import java.time.LocalDate; +import java.util.Optional; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import org.apache.fineract.infrastructure.core.service.MathUtil; +import org.apache.fineract.organisation.monetary.domain.Money; + +@Getter +@EqualsAndHashCode(exclude = { "repaymentPeriod" }) +public class InterestPeriod implements Comparable<InterestPeriod> { + + private final RepaymentPeriod repaymentPeriod; + private final LocalDate fromDate; + @Setter + private LocalDate dueDate; + @Setter + private BigDecimal rateFactor; + private Money disbursementAmount; + private Money balanceCorrectionAmount; + private Money outstandingLoanBalance; + + public InterestPeriod(RepaymentPeriod repaymentPeriod, LocalDate fromDate, LocalDate dueDate, BigDecimal rateFactor, + Money disbursementAmount, Money balanceCorrectionAmount, Money outstandingLoanBalance) { + this.repaymentPeriod = repaymentPeriod; + this.fromDate = fromDate; + this.dueDate = dueDate; + this.rateFactor = rateFactor; + this.disbursementAmount = disbursementAmount; + this.balanceCorrectionAmount = balanceCorrectionAmount; + this.outstandingLoanBalance = outstandingLoanBalance; + } + + public InterestPeriod(RepaymentPeriod repaymentPeriod, InterestPeriod interestPeriod) { + this(repaymentPeriod, interestPeriod.getFromDate(), interestPeriod.getDueDate(), interestPeriod.getRateFactor(), + interestPeriod.getDisbursementAmount(), interestPeriod.getBalanceCorrectionAmount(), + interestPeriod.getOutstandingLoanBalance()); + } + + @Override + public int compareTo(@NotNull InterestPeriod o) { + return dueDate.compareTo(o.dueDate); Review Comment: Yes, someone can set it to null, but the Interest Period "dueDate" has value and is not intended to override from outside, except the EMI Calculator Service. We can also flag the setter with a "NotNull" annotation to indicate it. -- 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]
