adamsaghy commented on code in PR #3919:
URL: https://github.com/apache/fineract/pull/3919#discussion_r1632987113


##########
fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/calc/EMICalculator.java:
##########
@@ -0,0 +1,160 @@
+/**
+ * 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.loanproduct.calc;
+
+import org.springframework.stereotype.Component;
+
+import java.math.BigDecimal;
+import java.math.MathContext;
+import java.util.List;
+
+@Component
+public class EMICalculator {
+
+    /**
+     * Calculate EMI parts and return an EMI calculation result object with 
period rate factors
+     *
+     * @param repaymentPeriodDays List of day gaps between periods
+     * @param principal
+     * @param interestRate
+     * @param daysInYear
+     * @param mc
+     * @return
+     */
+    public EMICalculationResult calculateEMI(final List<Integer> 
repaymentPeriodDays,
+                                             final BigDecimal principal,
+                                             final BigDecimal interestRate,
+                                             final Integer daysInYear,
+                                             final MathContext mc) {
+        final List<BigDecimal> rateFactorList = 
getRateFactorList(repaymentPeriodDays, interestRate, daysInYear, mc);
+        final List<BigDecimal> rateFactorMinus1List = 
getRateFactorMinus1List(rateFactorList, mc);

Review Comment:
   yeah, but it is not really the same... the first one is deducting 1 from the 
calculated rate factor amount, the other one just simply taking the period -1 
from the list, but not deducting anything.
   
   I found it a little misleading or not straightforward...
   
   I was wondering whether it would make sense to calculate and store the 
ratefactor (which is bigger than 1) and when the calculation requires us to 
take the ratefactor - 1 just simply do the calculation... I am not a big fan of 
having `getRateFactorMinus1List` methods which sometimes give you a the period 
-1 ratefactor and sometimes it is calculating and having the ratefactor -1 as 
value



##########
fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/calc/EMICalculator.java:
##########
@@ -0,0 +1,160 @@
+/**
+ * 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.loanproduct.calc;
+
+import org.springframework.stereotype.Component;
+
+import java.math.BigDecimal;
+import java.math.MathContext;
+import java.util.List;
+
+@Component
+public class EMICalculator {
+
+    /**
+     * Calculate EMI parts and return an EMI calculation result object with 
period rate factors
+     *
+     * @param repaymentPeriodDays List of day gaps between periods
+     * @param principal
+     * @param interestRate
+     * @param daysInYear
+     * @param mc
+     * @return
+     */
+    public EMICalculationResult calculateEMI(final List<Integer> 
repaymentPeriodDays,
+                                             final BigDecimal principal,
+                                             final BigDecimal interestRate,
+                                             final Integer daysInYear,
+                                             final MathContext mc) {
+        final List<BigDecimal> rateFactorList = 
getRateFactorList(repaymentPeriodDays, interestRate, daysInYear, mc);
+        final List<BigDecimal> rateFactorMinus1List = 
getRateFactorMinus1List(rateFactorList, mc);

Review Comment:
   yeah, but it is not really the same... the first one is deducting 1 from the 
calculated rate factor amount, the other one just simply taking the period -1 
from the list, but not deducting anything.
   
   I found it a little misleading or not straightforward...
   
   I was wondering whether it would make sense to calculate and store the 
ratefactor (which is bigger than 1) and when the calculation requires us to 
take the ratefactor - 1 just simply do the calculation... I am not a big fan of 
having `getRateFactorMinus1List` methods which sometimes give you a the period 
-1 ratefactor and sometimes it is calculating and having the ratefactor -1 as 
value.
   
   What do you think?



-- 
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]

Reply via email to