FINERACT-78 : Specified due date percentage charge calculation uses loan principal amount instead of installment principal amount
This commit is contained in:
+14
-2
@@ -6065,12 +6065,24 @@ public class Loan extends AbstractPersistableCustom<Long> {
|
|||||||
return nextRepaymentDate;
|
return nextRepaymentDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getDerivedAmountForCharge(LoanCharge loanCharge) {
|
public BigDecimal getDerivedAmountForCharge(final LoanCharge loanCharge) {
|
||||||
BigDecimal amount = BigDecimal.ZERO;
|
BigDecimal amount = BigDecimal.ZERO;
|
||||||
if (isMultiDisburmentLoan() && (loanCharge.getCharge().getChargeTimeType() == ChargeTimeType.DISBURSEMENT.getValue())) {
|
if (isMultiDisburmentLoan() && (loanCharge.getCharge().getChargeTimeType() == ChargeTimeType.DISBURSEMENT.getValue())) {
|
||||||
amount = getApprovedPrincipal();
|
amount = getApprovedPrincipal();
|
||||||
} else {
|
} else {
|
||||||
amount = getPrincpal().getAmount();
|
// If charge type is specified due date and loan is multi disburment
|
||||||
|
// loan.
|
||||||
|
// Then we need to get as of this loan charge due date how much
|
||||||
|
// amount disbursed.
|
||||||
|
if (loanCharge.isSpecifiedDueDate() && this.isMultiDisburmentLoan()) {
|
||||||
|
for (final LoanDisbursementDetails loanDisbursementDetails : this.getDisbursementDetails()) {
|
||||||
|
if (!loanDisbursementDetails.expectedDisbursementDate().after(loanCharge.getDueDate())) {
|
||||||
|
amount = amount.add(loanDisbursementDetails.principal());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
amount = getPrincpal().getAmount();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return amount;
|
return amount;
|
||||||
}
|
}
|
||||||
|
|||||||
+30
-1
@@ -182,6 +182,19 @@ public class LoanCharge extends AbstractPersistableCustom<Long> {
|
|||||||
percentage);
|
percentage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If charge type is specified due date and loan is multi disburment
|
||||||
|
// loan.
|
||||||
|
// Then we need to get as of this loan charge due date how much amount
|
||||||
|
// disbursed.
|
||||||
|
if (chargeDefinition.getChargeTimeType().equals(ChargeTimeType.SPECIFIED_DUE_DATE.getValue()) && loan.isMultiDisburmentLoan()) {
|
||||||
|
amountPercentageAppliedTo = BigDecimal.ZERO;
|
||||||
|
for (final LoanDisbursementDetails loanDisbursementDetails : loan.getDisbursementDetails()) {
|
||||||
|
if (!loanDisbursementDetails.expectedDisbursementDate().after(dueDate.toDate())) {
|
||||||
|
amountPercentageAppliedTo = amountPercentageAppliedTo.add(loanDisbursementDetails.principal());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return new LoanCharge(loan, chargeDefinition, amountPercentageAppliedTo, amount, chargeTime, chargeCalculation, dueDate,
|
return new LoanCharge(loan, chargeDefinition, amountPercentageAppliedTo, amount, chargeTime, chargeCalculation, dueDate,
|
||||||
chargePaymentMode, null, loanCharge);
|
chargePaymentMode, null, loanCharge);
|
||||||
}
|
}
|
||||||
@@ -408,7 +421,19 @@ public class LoanCharge extends AbstractPersistableCustom<Long> {
|
|||||||
if (this.loan != null) {
|
if (this.loan != null) {
|
||||||
switch (ChargeCalculationType.fromInt(this.chargeCalculation)) {
|
switch (ChargeCalculationType.fromInt(this.chargeCalculation)) {
|
||||||
case PERCENT_OF_AMOUNT:
|
case PERCENT_OF_AMOUNT:
|
||||||
amountPercentageAppliedTo = this.loan.getPrincpal().getAmount();
|
// If charge type is specified due date and loan is multi
|
||||||
|
// disburment loan.
|
||||||
|
// Then we need to get as of this loan charge due date how
|
||||||
|
// much amount disbursed.
|
||||||
|
if (this.loan.isMultiDisburmentLoan() && this.isSpecifiedDueDate()) {
|
||||||
|
for (final LoanDisbursementDetails loanDisbursementDetails : this.loan.getDisbursementDetails()) {
|
||||||
|
if (!loanDisbursementDetails.expectedDisbursementDate().after(this.getDueDate())) {
|
||||||
|
amountPercentageAppliedTo = amountPercentageAppliedTo.add(loanDisbursementDetails.principal());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
amountPercentageAppliedTo = this.loan.getPrincpal().getAmount();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case PERCENT_OF_AMOUNT_AND_INTEREST:
|
case PERCENT_OF_AMOUNT_AND_INTEREST:
|
||||||
amountPercentageAppliedTo = this.loan.getPrincpal().getAmount().add(this.loan.getTotalInterest());
|
amountPercentageAppliedTo = this.loan.getPrincpal().getAmount().add(this.loan.getTotalInterest());
|
||||||
@@ -553,6 +578,10 @@ public class LoanCharge extends AbstractPersistableCustom<Long> {
|
|||||||
}
|
}
|
||||||
return dueDate;
|
return dueDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Date getDueDate() {
|
||||||
|
return this.dueDate;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean determineIfFullyPaid() {
|
private boolean determineIfFullyPaid() {
|
||||||
if (this.amount == null) { return true; }
|
if (this.amount == null) { return true; }
|
||||||
|
|||||||
+14
-2
@@ -19,6 +19,7 @@
|
|||||||
package org.apache.fineract.portfolio.loanaccount.domain;
|
package org.apache.fineract.portfolio.loanaccount.domain;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -71,7 +72,6 @@ public class LoanRepaymentScheduleProcessingWrapper {
|
|||||||
final Money totalInterest, boolean isInstallmentChargeApplicable) {
|
final Money totalInterest, boolean isInstallmentChargeApplicable) {
|
||||||
|
|
||||||
Money cumulative = Money.zero(monetaryCurrency);
|
Money cumulative = Money.zero(monetaryCurrency);
|
||||||
|
|
||||||
for (final LoanCharge loanCharge : loanCharges) {
|
for (final LoanCharge loanCharge : loanCharges) {
|
||||||
if (loanCharge.isFeeCharge() && !loanCharge.isDueAtDisbursement()) {
|
if (loanCharge.isFeeCharge() && !loanCharge.isDueAtDisbursement()) {
|
||||||
if (loanCharge.isInstalmentFee() && isInstallmentChargeApplicable) {
|
if (loanCharge.isInstalmentFee() && isInstallmentChargeApplicable) {
|
||||||
@@ -102,7 +102,19 @@ public class LoanRepaymentScheduleProcessingWrapper {
|
|||||||
} else if (loanCharge.getChargeCalculation().isPercentageOfInterest()) {
|
} else if (loanCharge.getChargeCalculation().isPercentageOfInterest()) {
|
||||||
amount = amount.add(totalInterest.getAmount());
|
amount = amount.add(totalInterest.getAmount());
|
||||||
} else {
|
} else {
|
||||||
amount = amount.add(totalPrincipal.getAmount());
|
// If charge type is specified due date and loan is
|
||||||
|
// multi disburment loan.
|
||||||
|
// Then we need to get as of this loan charge due date
|
||||||
|
// how much amount disbursed.
|
||||||
|
if (loanCharge.getLoan() != null && loanCharge.isSpecifiedDueDate() && loanCharge.getLoan().isMultiDisburmentLoan()) {
|
||||||
|
for (final LoanDisbursementDetails loanDisbursementDetails : loanCharge.getLoan().getDisbursementDetails()) {
|
||||||
|
if (!loanDisbursementDetails.expectedDisbursementDate().after(loanCharge.getDueDate())) {
|
||||||
|
amount = amount.add(loanDisbursementDetails.principal());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
amount = amount.add(totalPrincipal.getAmount());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
BigDecimal loanChargeAmt = amount.multiply(loanCharge.getPercentage()).divide(BigDecimal.valueOf(100));
|
BigDecimal loanChargeAmt = amount.multiply(loanCharge.getPercentage()).divide(BigDecimal.valueOf(100));
|
||||||
cumulative = cumulative.plus(loanChargeAmt);
|
cumulative = cumulative.plus(loanChargeAmt);
|
||||||
|
|||||||
Reference in New Issue
Block a user