FINERACT-303 - % Loan Amount + Interest or %Amount if collected as disbursement fees it is not working as expected

This commit is contained in:
nazeer1100126
2017-03-24 17:20:40 +05:30
parent 935d6146c0
commit f59dacbfc8
2 changed files with 34 additions and 1 deletions
@@ -862,7 +862,11 @@ public class Loan extends AbstractPersistableCustom<Long> {
break;
case PERCENT_OF_AMOUNT_AND_INTEREST:
final BigDecimal totalInterestCharged = getTotalInterest();
amount = getPrincpal().getAmount().add(totalInterestCharged);
if (isMultiDisburmentLoan() && loanCharge.isDisbursementCharge()) {
amount = getTotalAllTrancheDisbursementAmount().getAmount().add(totalInterestCharged);
}else{
amount = getPrincpal().getAmount().add(totalInterestCharged);
}
break;
case PERCENT_OF_INTEREST:
amount = getTotalInterest();
@@ -880,6 +884,31 @@ public class Loan extends AbstractPersistableCustom<Long> {
return amount;
}
private Money getTotalAllTrancheDisbursementAmount() {
Money amount = Money.zero(getCurrency());
if (isMultiDisburmentLoan()) {
for (final LoanDisbursementDetails loanDisbursementDetail : this.disbursementDetails) {
amount = amount.plus(loanDisbursementDetail.principal());
}
}
return amount;
}
private boolean isFirstTrancheDisbursement() {
if (isMultiDisburmentLoan()) {
int totalTranchDisbursementCount = 0;
for (final LoanDisbursementDetails loanDisbursementDetail : this.disbursementDetails) {
if(loanDisbursementDetail.actualDisbursementDate() != null){
totalTranchDisbursementCount++;
}
}
if(totalTranchDisbursementCount < 2){
return true;
}
}
return false;
}
/**
* @return
*/
@@ -990,6 +990,10 @@ public class LoanCharge extends AbstractPersistableCustom<Long> {
return this.loan;
}
public boolean isDisbursementCharge() {
return ChargeTimeType.fromInt(this.chargeTime).equals(ChargeTimeType.DISBURSEMENT);
}
public boolean isTrancheDisbursementCharge() {
return ChargeTimeType.fromInt(this.chargeTime).equals(ChargeTimeType.TRANCHE_DISBURSEMENT);
}