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


##########
fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/calc/data/RepaymentPeriod.java:
##########
@@ -138,27 +150,101 @@ public Money getDueInterest() {
         return dueInterestCalculation.get();
     }
 
+    /**
+     * Gives back an EMI amount which includes chargeback amounts as well
+     *
+     * @return
+     */
+    public Money getCalculatedEmi() {
+        return getEmi().plus(getTotalChargebackAmount(), mc); //
+    }
+
+    /**
+     * Gives back principal due + charge back principal based on (EMI - 
Calculated Due Interest)
+     *
+     * @return
+     */
     public Money getCalculatedDuePrincipal() {
-        return getEmi().minus(getCalculatedDueInterest(), mc);
+        return getCalculatedEmi().minus(getCalculatedDueInterest(), mc);
+    }
+
+    /**
+     * Sum of chargeback principals
+     *
+     * @return
+     */
+    public Money getChargebackPrincipal() {
+        return interestPeriods.stream() //
+                .map(InterestPeriod::getChargebackPrincipal) //
+                .reduce(getZero(mc), (value, previous) -> value.plus(previous, 
mc)); //
     }
 
+    /**
+     * Sum of chargeback interests
+     *
+     * @return
+     */
+    public Money getChargebackInterest() {
+        return interestPeriods.stream() //
+                .map(InterestPeriod::getChargebackInterest) //
+                .reduce(getZero(mc), (value, previous) -> value.plus(previous, 
mc)); //
+    }
+
+    /**
+     * Gives back due principal + chargeback principal or paid principal
+     *
+     * @return
+     */
     public Money getDuePrincipal() {
         // Due principal might be the maximum paid if there is pay-off or 
early repayment
-        return MathUtil.max(getEmi().minus(getDueInterest(), mc), 
getPaidPrincipal(), false);
+        return MathUtil.max(getCalculatedEmi().minus(getDueInterest(), mc), 
getPaidPrincipal(), false);
     }
 
+    /**
+     * Gives back sum of all chargeback principal + chargeback interest
+     *
+     * @return
+     */
+    public Money getTotalChargebackAmount() {
+        return getChargebackPrincipal().plus(getChargebackInterest(), mc);
+    }
+
+    /**
+     * Total paid amounts has everything: paid principal + paid interest + 
paid charge principal + paid charge interest
+     *
+     * @return
+     */
     public Money getTotalPaidAmount() {
         return getPaidPrincipal().plus(getPaidInterest());
     }
 
+    /**
+     * These contain all (principal + interest) amounts except chargeback 
amounts
+     *
+     * @return
+     */
+    public Money getTotalCountablePaidAmount() {

Review Comment:
   Why do we need this distinction?



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