janez89 commented on code in PR #4099:
URL: https://github.com/apache/fineract/pull/4099#discussion_r1801769317
##########
fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/data/ProgressiveLoanInterestScheduleModel.java:
##########
@@ -19,45 +19,167 @@
package org.apache.fineract.portfolio.loanaccount.loanschedule.data;
import java.math.BigDecimal;
-import java.math.MathContext;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
+import java.util.Optional;
+import java.util.function.Consumer;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.apache.fineract.organisation.monetary.domain.Money;
import
org.apache.fineract.portfolio.loanproduct.domain.LoanProductRelatedDetail;
-public record
ProgressiveLoanInterestScheduleModel(List<ProgressiveLoanInterestRepaymentModel>
repayments, //
- List<ProgressiveLoanInterestRate> interestRates, //
- LoanProductRelatedDetail loanProductRelatedDetail, //
- Integer installmentAmountInMultiplesOf, //
- MathContext mc) {
+@Data
+@Accessors(fluent = true)
+public class ProgressiveLoanInterestScheduleModel {
- public
ProgressiveLoanInterestScheduleModel(List<ProgressiveLoanInterestRepaymentModel>
repayments,
- LoanProductRelatedDetail loanProductRelatedDetail, Integer
installmentAmountInMultiplesOf, MathContext mc) {
- this(repayments, new ArrayList<>(1), loanProductRelatedDetail,
installmentAmountInMultiplesOf, mc);
+ private final List<RepaymentPeriod> repaymentPeriods;
+ private final List<InterestRate> interestRates;
+ private final LoanProductRelatedDetail loanProductRelatedDetail;
+ private final Integer installmentAmountInMultiplesOf;
+
+ public ProgressiveLoanInterestScheduleModel(List<RepaymentPeriod>
repaymentPeriods, LoanProductRelatedDetail loanProductRelatedDetail,
+ Integer installmentAmountInMultiplesOf) {
+ this.repaymentPeriods = repaymentPeriods;
+ this.interestRates = new ArrayList<>();
+ this.loanProductRelatedDetail = loanProductRelatedDetail;
+ this.installmentAmountInMultiplesOf = installmentAmountInMultiplesOf;
+ }
+
+ private ProgressiveLoanInterestScheduleModel(List<RepaymentPeriod>
repaymentPeriods, final List<InterestRate> interestRates,
+ LoanProductRelatedDetail loanProductRelatedDetail, Integer
installmentAmountInMultiplesOf) {
+ this.repaymentPeriods = copyRepaymentPeriods(repaymentPeriods);
+ this.interestRates = new ArrayList<>(interestRates);
+ this.loanProductRelatedDetail = loanProductRelatedDetail;
+ this.installmentAmountInMultiplesOf = installmentAmountInMultiplesOf;
+ }
+
+ public ProgressiveLoanInterestScheduleModel deepCopy() {
+ return new ProgressiveLoanInterestScheduleModel(repaymentPeriods,
interestRates, loanProductRelatedDetail,
+ installmentAmountInMultiplesOf);
}
- public void addInterestRate(final LocalDate newInterestDueDate, final
BigDecimal newInterestRate) {
- interestRates.add(new ProgressiveLoanInterestRate(newInterestDueDate,
newInterestDueDate.plusDays(1), newInterestRate));
- interestRates.sort(Collections.reverseOrder());
+ private List<RepaymentPeriod> copyRepaymentPeriods(final
List<RepaymentPeriod> repaymentPeriods) {
Review Comment:
The model has a "deepCopy" method and that method makes a copy from the
whole nested model.
This method contains an extracted copy logic which responsible for making a
copy from repayment periods including their interest periods. Each class
(RepaymentPeriod, InterestPeriod) has its own copy constructor.
--
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]