Merge pull request #1198 from pramodn02/MIFOSX-1744

MIFOSX-1744 : added portion of recovery incase guarantee is more than 100%
This commit is contained in:
Vishwas Babu A J
2014-12-17 17:34:22 -08:00
2 changed files with 82 additions and 5 deletions
@@ -235,11 +235,14 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService {
final Long fromAccountId = fromSavingsAccount.getId();
releaseLoanIds.put(loanId, guarantorFundingDetails.getId());
try {
AccountTransferDTO accountTransferDTO = new AccountTransferDTO(transactionDate,
guarantorFundingDetails.getAmountRemaining(), fromAccountType, toAccountType, fromAccountId, toAccountId,
description, locale, fmt, paymentDetail, fromTransferType, toTransferType, chargeId, loanInstallmentNumber,
transferType, accountTransferDetails, noteText, txnExternalId, loan, toSavingsAccount, fromSavingsAccount,
isRegularTransaction, isExceptionForBalanceCheck);
BigDecimal remainingAmount = guarantorFundingDetails.getAmountRemaining();
if(loan.getGuaranteeAmount().compareTo(loan.getPrincpal().getAmount()) == 1){
remainingAmount = remainingAmount.multiply(loan.getPrincpal().getAmount()).divide(loan.getGuaranteeAmount(), roundingMode);
}
AccountTransferDTO accountTransferDTO = new AccountTransferDTO(transactionDate, remainingAmount, fromAccountType,
toAccountType, fromAccountId, toAccountId, description, locale, fmt, paymentDetail, fromTransferType,
toTransferType, chargeId, loanInstallmentNumber, transferType, accountTransferDetails, noteText,
txnExternalId, loan, toSavingsAccount, fromSavingsAccount, isRegularTransaction, isExceptionForBalanceCheck);
transferAmount(accountTransferDTO);
} finally {
releaseLoanIds.remove(loanId);