use of org.mifos.framework.exceptions.PersistenceException 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.framework.exceptions.PersistenceException 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.framework.exceptions.PersistenceException in project head by mifos.
the class LegacyLoanDao method getTotalOutstandingPrincipalOfLoanAccountsInActiveGoodStanding.
@SuppressWarnings("unchecked")
public BigDecimal getTotalOutstandingPrincipalOfLoanAccountsInActiveGoodStanding(final Short branchId, final Short loanOfficerId, final Short loanProductId) throws PersistenceException {
BigDecimal loanBalanceAmount = new BigDecimal(0);
try {
Session session = StaticHibernateUtil.getSessionTL();
Criteria criteria = session.createCriteria(LoanBO.class).setProjection(Projections.sum("loanBalance.amount")).add(Restrictions.eq("accountState.id", (short) 5)).add(Restrictions.eq("office.officeId", branchId));
if (loanOfficerId != (short) -1) {
criteria.add(Restrictions.eq("personnel.personnelId", loanOfficerId));
}
if (loanProductId != (short) -1) {
criteria.add(Restrictions.eq("loanOffering.prdOfferingId", loanProductId));
}
List list = criteria.list();
loanBalanceAmount = (BigDecimal) list.get(0);
} catch (Exception e) {
throw new PersistenceException(e);
}
return loanBalanceAmount;
}
use of org.mifos.framework.exceptions.PersistenceException 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.framework.exceptions.PersistenceException in project head by mifos.
the class LegacyLoanDao method getLoanAccountsInActiveBadStanding.
@SuppressWarnings("unchecked")
public List<LoanBO> getLoanAccountsInActiveBadStanding(final Short branchId, final Short loanOfficerId, final Short loanProductId) throws PersistenceException {
String activeBadAccountIdQuery = "from org.mifos.accounts.loan.business.LoanBO loan where loan.accountState.id = 9";
StringBuilder queryString = loanQueryString(branchId, loanOfficerId, loanProductId, activeBadAccountIdQuery);
try {
Session session = StaticHibernateUtil.getSessionTL();
Query query = session.createQuery(queryString.toString());
return query.list();
} catch (Exception e) {
throw new PersistenceException(e);
}
}
Aggregations