FINERACT-115 : In Loan tranche details page if any tranche is added, Tranche disbursement charge is getting added twice

This commit is contained in:
nazeer1100126
2017-03-08 18:23:01 +05:30
parent b36ba8e0f1
commit df93ce64db
2 changed files with 9 additions and 5 deletions
@@ -5868,10 +5868,14 @@ public class Loan extends AbstractPersistableCustom<Long> {
}
return actualDisbursementDate;
}
public void addTrancheLoanCharge(Charge charge) {
if (!trancheCharges.contains(charge)) {
trancheCharges.add(new LoanTrancheCharge(charge, this));
public void addTrancheLoanCharge(final Charge charge) {
final List<Charge> appliedCharges = new ArrayList<>();
for(final LoanTrancheCharge loanTrancheCharge: this.trancheCharges){
appliedCharges.add(loanTrancheCharge.getCharge());
}
if (!appliedCharges.contains(charge)) {
this.trancheCharges.add(new LoanTrancheCharge(charge, this));
}
}
@@ -34,7 +34,7 @@ public class LoanTrancheDisbursementCharge extends AbstractPersistableCustom<Lon
@JoinColumn(name = "loan_charge_id", referencedColumnName = "id", nullable = false)
private LoanCharge loancharge;
@ManyToOne(cascade = CascadeType.PERSIST, optional = false)
@ManyToOne(cascade = CascadeType.ALL, optional = false)
@JoinColumn(name="disbursement_detail_id", referencedColumnName = "id", nullable = false)
private LoanDisbursementDetails loanDisbursementDetails;