FINERACT-303 - % Loan Amount + Interest or %Amount if collected as disbursement fees it is not working as expected
This commit is contained in:
+30
-1
@@ -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
|
||||
*/
|
||||
|
||||
+4
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user