use of org.mifos.core.MifosRuntimeException in project head by mifos.
the class LegacyLoanDao method findClientPerformanceHistoryLastLoanAmountWhenRepaidLoanAdjusted.
public Money findClientPerformanceHistoryLastLoanAmountWhenRepaidLoanAdjusted(Integer clientId, Integer excludeAccountId) {
HashMap<String, Object> queryParameters = new HashMap<String, Object>();
queryParameters.put("CLIENT_ID", clientId);
queryParameters.put("EXCLUDE_ACCOUNT_ID", excludeAccountId);
try {
final Object[] obj = (Object[]) execUniqueResultNamedQuery("ClientPerformanceHistory.getLastLoanAmountWhenRepaidLoanAdjusted", queryParameters);
if (obj == null || obj[1] == null) {
return null;
}
Integer loanAccountId = (Integer) obj[0];
BigDecimal lastLoanAmount = (BigDecimal) obj[1];
LoanBO loan = (LoanBO) StaticHibernateUtil.getSessionTL().get(LoanBO.class, loanAccountId);
return new Money(loan.getCurrency(), lastLoanAmount);
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.core.MifosRuntimeException in project head by mifos.
the class LegacyLoanDao method countOfSavingsAccounts.
@SuppressWarnings("unchecked")
public int countOfSavingsAccounts() {
HashMap<String, Object> queryParameters = new HashMap<String, Object>();
try {
List queryResult = executeNamedQuery("countOfSavingsAccounts", queryParameters);
int count = 0;
if (null != queryResult && queryResult.size() > 0) {
Object obj = queryResult.get(0);
if (obj != null) {
count = ((Number) obj).intValue();
}
}
return count;
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.core.MifosRuntimeException in project head by mifos.
the class LegacyLoanDao method countOfLoanAccounts.
@SuppressWarnings("unchecked")
public int countOfLoanAccounts() {
HashMap<String, Object> queryParameters = new HashMap<String, Object>();
try {
List queryResult = executeNamedQuery("countOfLoanAccounts", queryParameters);
int count = 0;
if (null != queryResult && queryResult.size() > 0) {
Object obj = queryResult.get(0);
if (obj != null) {
count = ((Number) obj).intValue();
}
}
return count;
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.core.MifosRuntimeException in project head by mifos.
the class CenterServiceFacadeWebTier method waiveChargesDue.
@Override
public void waiveChargesDue(Integer accountId, Integer waiveType) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
try {
AccountBO account = new AccountBusinessService().getAccount(accountId);
account.updateDetails(userContext);
PersonnelBO loggedInUser = this.personnelDao.findPersonnelById(userContext.getId());
WaiveEnum waiveEnum = WaiveEnum.fromInt(waiveType);
if (account.getPersonnel() != null) {
new AccountBusinessService().checkPermissionForWaiveDue(waiveEnum, account.getType(), account.getCustomer().getLevel(), userContext, account.getOffice().getOfficeId(), account.getPersonnel().getPersonnelId());
} else {
new AccountBusinessService().checkPermissionForWaiveDue(waiveEnum, account.getType(), account.getCustomer().getLevel(), userContext, account.getOffice().getOfficeId(), userContext.getId());
}
try {
this.transactionHelper.startTransaction();
if (account instanceof LoanBO) {
((LoanBO) account).waiveAmountDue(waiveEnum);
} else if (account instanceof SavingsBO) {
((SavingsBO) account).waiveNextDepositAmountDue(loggedInUser);
} else {
((CustomerAccountBO) account).waiveAmountDue();
}
this.customerDao.save(account);
this.transactionHelper.commitTransaction();
} catch (Exception e) {
this.transactionHelper.rollbackTransaction();
throw new BusinessRuleException(account.getAccountId().toString(), e);
} finally {
this.transactionHelper.closeSession();
}
} catch (ServiceException e) {
throw new MifosRuntimeException(e);
} catch (ApplicationException e) {
throw new BusinessRuleException(e.getKey(), e);
}
}
use of org.mifos.core.MifosRuntimeException in project head by mifos.
the class CenterServiceFacadeWebTier method removeAccountFee.
@Override
public void removeAccountFee(Integer accountId, Short feeId) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
try {
AccountBO account = new AccountBusinessService().getAccount(accountId);
if (account instanceof LoanBO) {
List<LoanBO> individualLoans = this.loanDao.findIndividualLoans(account.getAccountId());
if (individualLoans != null && individualLoans.size() > 0) {
for (LoanBO individual : individualLoans) {
individual.updateDetails(userContext);
individual.removeFeesAssociatedWithUpcomingAndAllKnownFutureInstallments(feeId, userContext.getId());
this.customerDao.save(individual);
}
}
}
account.updateDetails(userContext);
if (account.getPersonnel() != null) {
new AccountBusinessService().checkPermissionForRemoveFees(account.getType(), account.getCustomer().getLevel(), userContext, account.getOffice().getOfficeId(), account.getPersonnel().getPersonnelId());
} else {
new AccountBusinessService().checkPermissionForRemoveFees(account.getType(), account.getCustomer().getLevel(), userContext, account.getOffice().getOfficeId(), userContext.getId());
}
this.transactionHelper.startTransaction();
account.removeFeesAssociatedWithUpcomingAndAllKnownFutureInstallments(feeId, userContext.getId());
this.customerDao.save(account);
this.transactionHelper.commitTransaction();
} catch (ServiceException e) {
this.transactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} catch (AccountException e) {
this.transactionHelper.rollbackTransaction();
throw new BusinessRuleException(e.getKey(), e);
} catch (ApplicationException e) {
this.transactionHelper.rollbackTransaction();
throw new BusinessRuleException(e.getKey(), e);
} finally {
this.transactionHelper.closeSession();
}
}
Aggregations