Search in sources :

Example 36 with PersistenceException

use of org.mifos.framework.exceptions.PersistenceException in project head by mifos.

the class AccountBusinessService method getAppllicableFees.

public List<ApplicableCharge> getAppllicableFees(Integer accountId, UserContext userContext) throws ServiceException {
    List<ApplicableCharge> applicableChargeList = null;
    try {
        AccountBO account = getlegacyAccountDao().getAccount(accountId);
        FeeCategory categoryType = getCategoryType(account.getCustomer());
        if (account.getType() == AccountTypes.LOAN_ACCOUNT || account.getType() == AccountTypes.GROUP_LOAN_ACCOUNT) {
            applicableChargeList = getLoanApplicableCharges(getlegacyAccountDao().getAllApplicableFees(accountId, FeeCategory.LOAN), userContext, (LoanBO) account);
        } else if (account.getType() == AccountTypes.CUSTOMER_ACCOUNT) {
            if (account.getCustomer().getCustomerMeeting() == null) {
                throw new ServiceException(AccountExceptionConstants.APPLY_CAHRGE_NO_CUSTOMER_MEETING_EXCEPTION);
            }
            applicableChargeList = getCustomerApplicableCharges(getlegacyAccountDao().getAllApplicableFees(accountId, categoryType), userContext, ((CustomerAccountBO) account).getCustomer().getCustomerMeeting().getMeeting().getMeetingDetails().getRecurrenceType().getRecurrenceId());
        }
        addMiscFeeAndPenalty(applicableChargeList);
    } catch (PersistenceException pe) {
        throw new ServiceException(pe);
    }
    return applicableChargeList;
}
Also used : CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) AccountBO(org.mifos.accounts.business.AccountBO) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) ServiceException(org.mifos.framework.exceptions.ServiceException) LoanBO(org.mifos.accounts.loan.business.LoanBO) ApplicableCharge(org.mifos.dto.domain.ApplicableCharge) PersistenceException(org.mifos.framework.exceptions.PersistenceException) FeeCategory(org.mifos.accounts.fees.util.helpers.FeeCategory)

Example 37 with PersistenceException

use of org.mifos.framework.exceptions.PersistenceException in project head by mifos.

the class FeeBO method update.

public void update() throws FeeException {
    try {
        setUpdateDetails();
        ApplicationContextProvider.getBean(LegacyAccountDao.class).createOrUpdate(this);
    } catch (PersistenceException e) {
        throw new FeeException(FeeConstants.FEE_UPDATE_ERROR, e);
    }
}
Also used : FeeException(org.mifos.accounts.fees.exceptions.FeeException) LegacyAccountDao(org.mifos.accounts.persistence.LegacyAccountDao) PersistenceException(org.mifos.framework.exceptions.PersistenceException)

Example 38 with PersistenceException

use of org.mifos.framework.exceptions.PersistenceException in project head by mifos.

the class WebTierAccountServiceFacade method constructPaymentTypeList.

private List<ListItem<Short>> constructPaymentTypeList(String paymentType, Short localeId) {
    try {
        List<PaymentTypeEntity> paymentTypeList = null;
        if (paymentType != null && !Constants.EMPTY_STRING.equals(paymentType.trim())) {
            if (isLoanPayment(paymentType)) {
                paymentTypeList = acceptedPaymentTypePersistence.getAcceptedPaymentTypesForATransaction(localeId, TrxnTypes.loan_repayment.getValue());
            } else {
                paymentTypeList = acceptedPaymentTypePersistence.getAcceptedPaymentTypesForATransaction(localeId, TrxnTypes.fee.getValue());
            }
        }
        List<ListItem<Short>> listItems = new ArrayList<ListItem<Short>>();
        for (PaymentTypeEntity paymentTypeEntity : paymentTypeList) {
            listItems.add(new ListItem<Short>(paymentTypeEntity.getId(), paymentTypeEntity.getName()));
        }
        return listItems;
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : PaymentTypeEntity(org.mifos.application.master.business.PaymentTypeEntity) ArrayList(java.util.ArrayList) PersistenceException(org.mifos.framework.exceptions.PersistenceException) ListItem(org.mifos.application.servicefacade.ListItem) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 39 with PersistenceException

use of org.mifos.framework.exceptions.PersistenceException in project head by mifos.

the class CollectionSheetDaoHibernate method findAmountDueWhenInterestIsDueAtDibursementTime.

private Double findAmountDueWhenInterestIsDueAtDibursementTime(final Integer accountId) {
    final Map<String, Object> queryParameters = new HashMap<String, Object>();
    queryParameters.put("ACCOUNT_ID", accountId);
    try {
        final Object[] loanScheduleData = (Object[]) execUniqueResultNamedQuery("findFirstLoanSchedule", queryParameters);
        final Integer loanScheduleId = Integer.valueOf(loanScheduleData[0].toString());
        final Double firstScheduledPaymentAmount = calculateAmountDueFromLoanScheduleFields(loanScheduleData);
        final Map<String, Object> feeQueryParameters = new HashMap<String, Object>();
        queryParameters.put("LOAN_SCHEDULE_ID", loanScheduleId);
        final Object[] loanScheduleFee = (Object[]) execUniqueResultNamedQuery("findLoanFeeSchedulesForALoanSchedule", feeQueryParameters);
        final Double feesDueOnLoanSchedule = calculateFeesDueOnLoanSchedule(loanScheduleFee);
        return firstScheduledPaymentAmount.doubleValue() + feesDueOnLoanSchedule.doubleValue();
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : HashMap(java.util.HashMap) PersistenceException(org.mifos.framework.exceptions.PersistenceException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 40 with PersistenceException

use of org.mifos.framework.exceptions.PersistenceException in project head by mifos.

the class AccountingDaoHibernate method updateLastProcessDate.

public void updateLastProcessDate(Date lastProcessDate) {
    Query q = createdNamedQuery("getConfigurationKeyValueByKey");
    q.setString("KEY", "MisProcessing");
    List<ConfigurationKeyValue> list = q.list();
    if (list.size() > 0) {
        ConfigurationKeyValue configurationKeyValue = list.get(0);
        configurationKeyValue.setValue(DateUtils.format(lastProcessDate));
        try {
            createOrUpdate(configurationKeyValue);
        } catch (PersistenceException e) {
            throw new MifosRuntimeException(e);
        }
    }
}
Also used : Query(org.hibernate.Query) PersistenceException(org.mifos.framework.exceptions.PersistenceException) ConfigurationKeyValue(org.mifos.config.business.ConfigurationKeyValue) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

PersistenceException (org.mifos.framework.exceptions.PersistenceException)215 MifosRuntimeException (org.mifos.core.MifosRuntimeException)98 ArrayList (java.util.ArrayList)55 ServiceException (org.mifos.framework.exceptions.ServiceException)53 AccountException (org.mifos.accounts.exceptions.AccountException)40 Test (org.junit.Test)35 ExpectedException (org.springframework.test.annotation.ExpectedException)32 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)24 BusinessRuleException (org.mifos.service.BusinessRuleException)23 Money (org.mifos.framework.util.helpers.Money)22 HibernateSearchException (org.mifos.framework.exceptions.HibernateSearchException)20 MifosUser (org.mifos.security.MifosUser)19 UserContext (org.mifos.security.util.UserContext)19 HashMap (java.util.HashMap)18 HibernateException (org.hibernate.HibernateException)18 Query (org.hibernate.Query)18 LoanBO (org.mifos.accounts.loan.business.LoanBO)18 Session (org.hibernate.Session)14 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)14 QueryResult (org.mifos.framework.hibernate.helper.QueryResult)14