use of org.mifos.accounts.loan.business.GuarantyEntity in project head by mifos.
the class LoanAccountServiceFacadeWebTier method linkGuarantor.
public void linkGuarantor(Integer guarantorId, Integer loanId) {
CustomerBO customerBO = this.customerDao.findCustomerById(guarantorId);
if (customerBO == loanDao.findById(loanId).getCustomer()) {
return;
}
transactionHelper.startTransaction();
GuarantyEntity guaranty = new GuarantyEntity();
guaranty.setGuarantorId(guarantorId);
guaranty.setLoanId(loanId);
guaranty.setState(true);
genericDao.getSession().save(guaranty);
try {
transactionHelper.commitTransaction();
} catch (Exception e) {
transactionHelper.rollbackTransaction();
}
}
use of org.mifos.accounts.loan.business.GuarantyEntity in project head by mifos.
the class LoanAccountServiceFacadeWebTier method unlinkGuaranty.
@Override
public void unlinkGuaranty(Integer guarantorId, Integer loanId) throws PersistenceException {
transactionHelper.startTransaction();
List<GuarantyEntity> guaranties = legacyAccountDao.getGuarantyByLoanIdAndGuarantorId(guarantorId, loanId);
if (guaranties != null && guaranties.size() > 0) {
for (GuarantyEntity en : guaranties) {
genericDao.getSession().delete(en);
}
}
try {
transactionHelper.commitTransaction();
} catch (Exception e) {
transactionHelper.rollbackTransaction();
}
}
use of org.mifos.accounts.loan.business.GuarantyEntity in project head by mifos.
the class LoanAccountServiceFacadeWebTier method getGuarantorsByLoanId.
public List<CustomerDto> getGuarantorsByLoanId(Integer loanId) throws PersistenceException {
List<CustomerDto> guarantors = new ArrayList<CustomerDto>();
List<GuarantyEntity> guaranties = legacyAccountDao.getGuarantyByLoanId(loanId);
for (GuarantyEntity guaranty : guaranties) {
ClientBO guarantor = customerDao.findClientById(guaranty.getGuarantorId());
CustomerDto customerDto = new CustomerDto(guarantor.getCustomerId(), guarantor.getClientName().getDisplayName(), guarantor.getGlobalCustNum(), null);
guarantors.add(customerDto);
}
return guarantors;
}
Aggregations