From ad3a77d70c04590fa7a7fa2186c30e83c1a78a1d Mon Sep 17 00:00:00 2001 From: bharathc27 Date: Thu, 5 Feb 2015 09:38:20 +0530 Subject: [PATCH] guaranterdomainserviceissue --- .../service/GuarantorDomainServiceImpl.java | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/guarantor/service/GuarantorDomainServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/guarantor/service/GuarantorDomainServiceImpl.java index 00210e740..f56caa96d 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/guarantor/service/GuarantorDomainServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/guarantor/service/GuarantorDomainServiceImpl.java @@ -378,21 +378,23 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService { BigDecimal amountForRelease = loanTransaction.getPrincipalPortion(); BigDecimal totalGuaranteeAmount = loan.getGuaranteeAmount(); BigDecimal principal = loan.getPrincpal().getAmount(); + if((amountForRelease!=null)&&(totalGuaranteeAmount!=null)) + { + amountForRelease = amountForRelease.multiply(totalGuaranteeAmount).divide(principal,this.roundingMode); + List accountOnHoldTransactions = new ArrayList<>(); - amountForRelease = amountForRelease.multiply(totalGuaranteeAmount).divide(principal); - List accountOnHoldTransactions = new ArrayList<>(); - - BigDecimal amountLeft = calculateAndRelaseGuarantorFunds(externalGuarantorList, guarantorGuarantee, amountForRelease, + BigDecimal amountLeft = calculateAndRelaseGuarantorFunds(externalGuarantorList, guarantorGuarantee, amountForRelease, loanTransaction, accountOnHoldTransactions); - if (amountLeft.compareTo(BigDecimal.ZERO) == 1) { - calculateAndRelaseGuarantorFunds(selfGuarantorList, selfGuarantee, amountLeft, loanTransaction, accountOnHoldTransactions); - externalGuarantorList.addAll(selfGuarantorList); - } + if (amountLeft.compareTo(BigDecimal.ZERO) == 1) { + calculateAndRelaseGuarantorFunds(selfGuarantorList, selfGuarantee, amountLeft, loanTransaction, accountOnHoldTransactions); + externalGuarantorList.addAll(selfGuarantorList); + } - if (!externalGuarantorList.isEmpty()) { - this.depositAccountOnHoldTransactionRepository.save(accountOnHoldTransactions); - this.guarantorFundingRepository.save(externalGuarantorList); + if (!externalGuarantorList.isEmpty()) { + this.depositAccountOnHoldTransactionRepository.save(accountOnHoldTransactions); + this.guarantorFundingRepository.save(externalGuarantorList); + } } }