Search in sources :

Example 1 with FinancialException

use of org.mifos.accounts.financial.exceptions.FinancialException in project head by mifos.

the class FinancialInitializer method initalizeFinancialAction.

@SuppressWarnings("unchecked")
public static void initalizeFinancialAction() throws FinancialException {
    Session session = StaticHibernateUtil.getSessionTL();
    try {
        Query queryFinancialAction = session.getNamedQuery(FinancialQueryConstants.GET_ALL_FINANCIAL_ACTION);
        List<FinancialActionTypeEntity> listFinancialAction = queryFinancialAction.list();
        for (FinancialActionTypeEntity fabo : listFinancialAction) {
            FinancialActionCache.addToCache(fabo);
        }
    } catch (Exception e) {
        throw new FinancialException(FinancialExceptionConstants.FINANCIALACTION_INITFAILED, e);
    }
}
Also used : FinancialActionTypeEntity(org.mifos.accounts.financial.business.FinancialActionTypeEntity) Query(org.hibernate.Query) FinancialException(org.mifos.accounts.financial.exceptions.FinancialException) FinancialException(org.mifos.accounts.financial.exceptions.FinancialException) IOException(java.io.IOException) ConfigurationException(org.mifos.config.exceptions.ConfigurationException) Session(org.hibernate.Session)

Example 2 with FinancialException

use of org.mifos.accounts.financial.exceptions.FinancialException in project head by mifos.

the class FeeServiceFacadeWebTier method parameters.

private FeeParameters parameters() {
    try {
        List<GLCodeEntity> glCodes = generalLedgerDao.retreiveGlCodesBy(FinancialActionConstants.FEEPOSTING, FinancialConstants.CREDIT);
        List<CategoryTypeEntity> categories = this.feeDao.doRetrieveFeeCategories();
        List<FeeFormulaEntity> formulas = this.feeDao.retrieveFeeFormulae();
        List<FeeFrequencyTypeEntity> frequencies = this.feeDao.retrieveFeeFrequencies();
        List<FeePaymentEntity> timesOfCharging = this.feeDao.retrieveFeePayments();
        List<MasterDataEntity> timesOfChargeingCustomer = new ArrayList<MasterDataEntity>();
        for (MasterDataEntity timeOfCharging : timesOfCharging) {
            if (timeOfCharging.getId().equals(FeePayment.UPFRONT.getValue())) {
                timesOfChargeingCustomer.add(timeOfCharging);
            }
        }
        return new FeeParameters(listToMap(categories), listToMap(timesOfCharging), listToMap(timesOfChargeingCustomer), listToMap(formulas), listToMap(frequencies), glCodesToMap(glCodes));
    } catch (FinancialException e) {
        throw new BusinessRuleException(e.getKey(), e);
    }
}
Also used : MasterDataEntity(org.mifos.application.master.business.MasterDataEntity) ArrayList(java.util.ArrayList) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) FeePaymentEntity(org.mifos.accounts.fees.business.FeePaymentEntity) BusinessRuleException(org.mifos.service.BusinessRuleException) FeeFormulaEntity(org.mifos.accounts.fees.business.FeeFormulaEntity) FeeFrequencyTypeEntity(org.mifos.accounts.fees.business.FeeFrequencyTypeEntity) CategoryTypeEntity(org.mifos.accounts.fees.business.CategoryTypeEntity) FinancialException(org.mifos.accounts.financial.exceptions.FinancialException) FeeParameters(org.mifos.dto.screen.FeeParameters)

Example 3 with FinancialException

use of org.mifos.accounts.financial.exceptions.FinancialException in project head by mifos.

the class ApplicationInitializer method dbUpgrade.

public void dbUpgrade(ApplicationContext applicationContext) throws ConfigurationException, PersistenceException, FinancialException, TaskSystemException {
    logger.info("Logger has been initialised");
    initializeHibernate(applicationContext);
    logger.info(getDatabaseConnectionInfo());
    // if a database upgrade loads an instance of Money then MoneyCompositeUserType needs the default
    // currency
    MoneyCompositeUserType.setDefaultCurrency(AccountingRules.getMifosCurrency(new ConfigurationPersistence()));
    // load the additional currencies
    AccountingRules.init();
    Money.setDefaultCurrency(AccountingRules.getMifosCurrency(new ConfigurationPersistence()));
    final MifosConfigurationManager configuration = MifosConfigurationManager.getInstance();
    final String imageStorageConfig = configuration.getString(IMAGESTORE_CONFIG_KEY);
    if (imageStorageConfig == null || !imageStorageConfig.equals(DB_CONFIG)) {
        ImageStorageManager.initStorage();
    }
    DatabaseMigrator migrator = new DatabaseMigrator();
    initializeDBConnectionForHibernate(migrator);
    if (!databaseError.isError) {
        try {
            migrator.upgrade(applicationContext);
        } catch (Throwable t) {
            setDatabaseError(DatabaseErrorCode.UPGRADE_FAILURE, "Failed to upgrade database.", t);
        }
    }
    if (databaseError.isError) {
        databaseError.logError();
    } else {
        initializeDB(applicationContext);
        /*
             * John W - Added in G Release and back patched to F Release.
             * Related to jira issue MIFOS-4948
             *
             * Can find all code and the related query by searching for mifos4948
             *
            */
        CustomJDBCService customJdbcService = applicationContext.getBean(CustomJDBCService.class);
        boolean keyExists = customJdbcService.mifos4948IssueKeyExists();
        if (!keyExists) {
            try {
                StaticHibernateUtil.startTransaction();
                applyMifos4948Fix();
                customJdbcService.insertMifos4948Issuekey();
                StaticHibernateUtil.commitTransaction();
            } catch (AccountException e) {
                StaticHibernateUtil.rollbackTransaction();
                e.printStackTrace();
            } finally {
                StaticHibernateUtil.closeSession();
            }
        }
        boolean key5722Exists = customJdbcService.mifos5722IssueKeyExists();
        if (!key5722Exists) {
            try {
                applyMifos5722Fix();
                customJdbcService.insertMifos5722Issuekey();
            } catch (Exception e) {
                logger.error("Could not apply Mifos-5692 and mifos-5722 fix");
                e.printStackTrace();
            } finally {
                StaticHibernateUtil.closeSession();
            }
        }
        boolean key5763Exists = customJdbcService.mifos5763IssueKeyExists();
        if (!key5763Exists) {
            try {
                applyMifos5763Fix();
                customJdbcService.insertMifos5763Issuekey();
            } catch (Exception e) {
                logger.info("Failed to apply Mifos-5763 fix");
                e.printStackTrace();
            } finally {
                StaticHibernateUtil.closeSession();
            }
        }
        boolean key5632Exists = customJdbcService.mifos5632IssueKeyExists();
        if (!key5632Exists) {
            try {
                applyMifos5632();
                customJdbcService.insertMifos5632IssueKey();
            } catch (Exception e) {
                logger.info("Failed to apply Mifos-5632 fix");
                e.printStackTrace();
            } finally {
                StaticHibernateUtil.closeSession();
            }
        }
    }
}
Also used : AccountException(org.mifos.accounts.exceptions.AccountException) DatabaseMigrator(org.mifos.framework.persistence.DatabaseMigrator) ConfigurationPersistence(org.mifos.config.persistence.ConfigurationPersistence) CustomJDBCService(org.mifos.application.servicefacade.CustomJDBCService) SystemException(org.mifos.framework.exceptions.SystemException) TaskSystemException(org.mifos.framework.components.batchjobs.exceptions.TaskSystemException) XMLReaderException(org.mifos.framework.exceptions.XMLReaderException) HibernateProcessException(org.mifos.framework.exceptions.HibernateProcessException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) ConfigurationException(org.mifos.config.exceptions.ConfigurationException) AppNotConfiguredException(org.mifos.framework.exceptions.AppNotConfiguredException) AccountException(org.mifos.accounts.exceptions.AccountException) FinancialException(org.mifos.accounts.financial.exceptions.FinancialException) NameAlreadyBoundException(javax.naming.NameAlreadyBoundException) IOException(java.io.IOException) HibernateStartUpException(org.mifos.framework.exceptions.HibernateStartUpException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) MifosConfigurationManager(org.mifos.config.business.MifosConfigurationManager)

Example 4 with FinancialException

use of org.mifos.accounts.financial.exceptions.FinancialException in project head by mifos.

the class InterestPostingAccountingEntryTest method setupAndInjectMocks.

@Before
public void setupAndInjectMocks() {
    // Build a little Chart of Accounts
    coaLiability = makeCategory((short) 1, GLCategoryType.LIABILITY, "22000");
    coaSavingsInterestPayable = makeChildCoaboOf(coaLiability, (short) 2, "SavingsInterest Payable", "22100");
    coaClientsSavings = makeChildCoaboOf(coaLiability, (short) 3, "ClientsSavings", "22200");
    interestPostingAccountingEntry = new InterestPostingAccountingEntry() {

        @Override
        protected FinancialActionTypeEntity getFinancialAction(@SuppressWarnings("unused") final FinancialActionConstants financialActionId) throws FinancialException {
            return financialAction;
        }

        @Override
        protected COABO getChartOfAccountsEntry(final String glcode) throws FinancialException {
            if (glcode.equals("22000")) {
                return coaLiability;
            } else if (glcode.equals("22100")) {
                return coaSavingsInterestPayable;
            } else if (glcode.equals("22200")) {
                return coaClientsSavings;
            } else {
                throw new FinancialException("unexpected glcode: " + glcode);
            }
        }
    };
}
Also used : FinancialActionConstants(org.mifos.accounts.financial.util.helpers.FinancialActionConstants) FinancialActionTypeEntity(org.mifos.accounts.financial.business.FinancialActionTypeEntity) COABO(org.mifos.accounts.financial.business.COABO) FinancialException(org.mifos.accounts.financial.exceptions.FinancialException) Before(org.junit.Before)

Example 5 with FinancialException

use of org.mifos.accounts.financial.exceptions.FinancialException in project head by mifos.

the class WebTierPenaltyServiceFacade method getPenaltyParameters.

@Override
public PenaltyParametersDto getPenaltyParameters() {
    try {
        List<GLCodeEntity> glCodes = generalLedgerDao.retreiveGlCodesBy(FinancialActionConstants.PENALTYPOSTING, FinancialConstants.CREDIT);
        List<PenaltyCategoryEntity> categories = this.penaltyDao.getPenaltiesCategories();
        List<PenaltyPeriodEntity> periods = this.penaltyDao.getPenaltiesPeriods();
        List<PenaltyFormulaEntity> formulas = this.penaltyDao.getPenaltiesFormulas();
        List<PenaltyFrequencyEntity> frequencies = this.penaltyDao.getPenaltiesFrequencies();
        List<PenaltyStatusEntity> statuses = this.penaltyDao.getPenaltiesStatuses();
        return new PenaltyParametersDto(listToMap(categories), listToMap(statuses), listToMap(periods), listToMap(formulas), listToMap(frequencies), glCodesToMap(glCodes));
    } catch (FinancialException e) {
        throw new BusinessRuleException(e.getKey(), e);
    }
}
Also used : PenaltyStatusEntity(org.mifos.accounts.penalties.business.PenaltyStatusEntity) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) PenaltyPeriodEntity(org.mifos.accounts.penalties.business.PenaltyPeriodEntity) PenaltyCategoryEntity(org.mifos.accounts.penalties.business.PenaltyCategoryEntity) BusinessRuleException(org.mifos.service.BusinessRuleException) PenaltyFrequencyEntity(org.mifos.accounts.penalties.business.PenaltyFrequencyEntity) FinancialException(org.mifos.accounts.financial.exceptions.FinancialException) PenaltyParametersDto(org.mifos.dto.screen.PenaltyParametersDto) PenaltyFormulaEntity(org.mifos.accounts.penalties.business.PenaltyFormulaEntity)

Aggregations

FinancialException (org.mifos.accounts.financial.exceptions.FinancialException)10 IOException (java.io.IOException)4 ConfigurationException (org.mifos.config.exceptions.ConfigurationException)4 Session (org.hibernate.Session)2 COABO (org.mifos.accounts.financial.business.COABO)2 FinancialActionTypeEntity (org.mifos.accounts.financial.business.FinancialActionTypeEntity)2 GLCodeEntity (org.mifos.accounts.financial.business.GLCodeEntity)2 MifosRuntimeException (org.mifos.core.MifosRuntimeException)2 BusinessRuleException (org.mifos.service.BusinessRuleException)2 ArrayList (java.util.ArrayList)1 NameAlreadyBoundException (javax.naming.NameAlreadyBoundException)1 Query (org.hibernate.Query)1 DateTime (org.joda.time.DateTime)1 Before (org.junit.Before)1 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)1 AccountException (org.mifos.accounts.exceptions.AccountException)1 CategoryTypeEntity (org.mifos.accounts.fees.business.CategoryTypeEntity)1 FeeFormulaEntity (org.mifos.accounts.fees.business.FeeFormulaEntity)1 FeeFrequencyTypeEntity (org.mifos.accounts.fees.business.FeeFrequencyTypeEntity)1 FeePaymentEntity (org.mifos.accounts.fees.business.FeePaymentEntity)1