update loan loan charge functionality to show percentage value correctly if percentage of amount type of charge.

This commit is contained in:
Keith Woodlock
2013-05-06 13:39:14 +01:00
parent 187c37437e
commit 50628ad943
3 changed files with 16 additions and 31 deletions
@@ -108,7 +108,13 @@ public class ChargeData implements Comparable<ChargeData> {
}
public LoanChargeData toLoanChargeData() {
return LoanChargeData.newLoanChargeDetails(this.id, this.name, this.currency, this.amount, this.chargeTimeType,
BigDecimal percentage = null;
if (this.chargeCalculationType.getId() == 2) {
percentage = this.amount;
}
return LoanChargeData.newLoanChargeDetails(this.id, this.name, this.currency, this.amount, percentage, this.chargeTimeType,
this.chargeCalculationType, this.penalty);
}
}
@@ -67,7 +67,7 @@ public class LoanChargeData {
private final boolean penalty;
public static LoanChargeData template(final Collection<ChargeData> chargeOptions) {
return new LoanChargeData(null, null, null, null, null, null, null, chargeOptions, false);
return new LoanChargeData(null, null, null, null, null, null, null, null, chargeOptions, false);
}
/**
@@ -75,8 +75,9 @@ public class LoanChargeData {
* charges)
*/
public static LoanChargeData newLoanChargeDetails(final Long chargeId, final String name, final CurrencyData currency,
final BigDecimal value, final EnumOptionData chargeTimeType, final EnumOptionData chargeCalculationType, final boolean penalty) {
return new LoanChargeData(null, chargeId, name, currency, value, chargeTimeType, chargeCalculationType, null, penalty);
final BigDecimal amount, final BigDecimal percentage, final EnumOptionData chargeTimeType,
final EnumOptionData chargeCalculationType, final boolean penalty) {
return new LoanChargeData(null, chargeId, name, currency, amount, percentage, chargeTimeType, chargeCalculationType, null, penalty);
}
public LoanChargeData(final Long id, final Long chargeId, final String name, final CurrencyData currency, final BigDecimal amount,
@@ -110,8 +111,8 @@ public class LoanChargeData {
}
private LoanChargeData(final Long id, final Long chargeId, final String name, final CurrencyData currency, final BigDecimal amount,
final EnumOptionData chargeTimeType, final EnumOptionData chargeCalculationType, final Collection<ChargeData> chargeOptions,
final boolean penalty) {
final BigDecimal pecentage, final EnumOptionData chargeTimeType, final EnumOptionData chargeCalculationType,
final Collection<ChargeData> chargeOptions, final boolean penalty) {
this.id = id;
this.chargeId = chargeId;
this.name = name;
@@ -124,7 +125,7 @@ public class LoanChargeData {
this.chargeTimeType = chargeTimeType;
this.dueDate = null;
this.chargeCalculationType = chargeCalculationType;
this.percentage = null;
this.percentage = pecentage;
this.amountPercentageAppliedTo = null;
this.penalty = penalty;
@@ -833,19 +833,10 @@ public class Loan extends AbstractPersistable<Long> {
//FIXME: AA - We may require separate api command to move loan from one group to another
final String groupIdParamName = "groupId";
final Long groupId = this.group == null ? null : this.group.getId();
if (command.isChangeInLongParameterNamed(clientIdParamName, groupId)) {
if (command.isChangeInLongParameterNamed(groupIdParamName, groupId)) {
final Long newValue = command.longValueOfParameterNamed(groupIdParamName);
actualChanges.put(groupIdParamName, newValue);
}
//Do not support loan type modification
/*final String loanTypeParamName = "loanType";
final String loanTypeStr = LoanType.fromInt(this.loanType).getName();
if (command.isChangeInStringParameterNamed(loanTypeParamName, loanTypeStr)) {
final String newValue = command.stringValueOfParameterNamed(loanTypeParamName);
actualChanges.put(loanTypeParamName, newValue);
this.loanType = LoanType.fromName(newValue).getValue();
}*/
final String productIdParamName = "productId";
if (command.isChangeInLongParameterNamed(productIdParamName, this.loanProduct.getId())) {
@@ -912,7 +903,6 @@ public class Loan extends AbstractPersistable<Long> {
final LocalDate newValue = command.localDateValueOfParameterNamed(expectedDisbursementDateParamName);
this.expectedDisbursementDate = newValue.toDate();
removeFirstDisbursementTransaction();
disburse(getExpectedDisbursedOnLocalDate());
}
final String repaymentsStartingFromDateParamName = "repaymentsStartingFromDate";
@@ -1252,18 +1242,6 @@ public class Loan extends AbstractPersistable<Long> {
return actualChanges;
}
private void disburse(final LocalDate expectedDisbursedOnLocalDate) {
this.actualDisbursementDate = expectedDisbursedOnLocalDate.toDate();
updateLoanScheduleDependentDerivedFields();
/****
* Vishwas TODO: Re-factor to skip unnecessary creation of Disbursement
* and fees applied transactions (though they are not persisted) on
* modifications to loan application modification
*****/
PaymentDetail paymentDetail = null;
handleDisbursementTransaction(paymentDetail, expectedDisbursedOnLocalDate);
}
private Collection<Long> findExistingTransactionIds() {
Collection<Long> ids = new ArrayList<Long>();
@@ -1988,7 +1966,7 @@ public class Loan extends AbstractPersistable<Long> {
private boolean hasDisbursementTransaction() {
boolean hasRepaymentTransaction = false;
for (LoanTransaction loanTransaction : this.loanTransactions) {
if (loanTransaction.isDisbursement()) {
if (loanTransaction.isDisbursement() && loanTransaction.isNotReversed()) {
hasRepaymentTransaction = true;
break;
}