Search in sources :

Example 6 with FinancialException

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

the class CoaServiceFacadeWebTier method reloadCache.

private void reloadCache() {
    ChartOfAccountsCache.clear();
    FinancialActionCache.clear();
    try {
        FinancialInitializer.initialize();
    } catch (FinancialException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : FinancialException(org.mifos.accounts.financial.exceptions.FinancialException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 7 with FinancialException

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

the class SavingsAdjustmentAccountingEntryTest method runOneTestMockFinancialBusinessServiceThrowsException.

private void runOneTestMockFinancialBusinessServiceThrowsException(SavingsType savingsType, AccountActionTypes accountActionType, GLCategoryType bankCategoryType, GLCategoryType savingsCategoryType, FinancialActionConstants financialAction, FinancialConstants bankDebitCredit) throws FinancialException {
    /*
         * Test-specific settings
         */
    setUpOneMandatorySavingsTest(savingsType, accountActionType, bankCategoryType, savingsCategoryType, bankDebitCredit, financialAction);
    SavingsAdjustmentAccountingEntry entry = new SavingsAdjustmentAccountingEntry();
    when(mockedFinancialBusinessService.getFinancialAction(financialAction)).thenThrow(new FinancialException("a FinancialException"));
    doBuild(entry, mockedFinancialBusinessService, mockedSavingsHelper, mockedFinancialActivity);
}
Also used : FinancialException(org.mifos.accounts.financial.exceptions.FinancialException)

Example 8 with FinancialException

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

the class SavingsBO method doPostInterest.

private void doPostInterest(LocalDate currentPostingDate, Money actualInterestToBePosted, PersonnelBO loggedInUser) {
    this.savingsBalance = this.savingsBalance.add(actualInterestToBePosted);
    this.savingsPerformance.setTotalInterestDetails(actualInterestToBePosted);
    SavingsActivityEntity savingsActivity = SavingsActivityEntity.savingsInterestPosting(this, personnel, this.savingsBalance, actualInterestToBePosted, currentPostingDate.toDateMidnight().toDate());
    savingsActivityDetails.add(savingsActivity);
    AccountPaymentEntity interestPayment = AccountPaymentEntity.savingsInterestPosting(this, actualInterestToBePosted, currentPostingDate.toDateMidnight().toDate(), loggedInUser);
    DateTime dueDate = new DateTime();
    SavingsTrxnDetailEntity interestPostingTransaction = SavingsTrxnDetailEntity.savingsInterestPosting(interestPayment, this.customer, this.savingsBalance, currentPostingDate.toDateMidnight().toDate(), dueDate, loggedInUser);
    interestPayment.addAccountTrxn(interestPostingTransaction);
    this.addAccountPayment(interestPayment);
    // NOTE: financial Transaction Processing should be decoupled from application domain model.
    try {
        BaseFinancialActivity baseFinancialActivity = new SavingsInterestPostingFinancialActivity(interestPostingTransaction);
        baseFinancialActivity.buildAccountEntries();
    } catch (FinancialException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : BaseFinancialActivity(org.mifos.accounts.financial.business.service.activity.BaseFinancialActivity) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) SavingsInterestPostingFinancialActivity(org.mifos.accounts.financial.business.service.activity.SavingsInterestPostingFinancialActivity) FinancialException(org.mifos.accounts.financial.exceptions.FinancialException) DateTime(org.joda.time.DateTime) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 9 with FinancialException

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

the class FinancialInitializer method initialize.

public static void initialize() throws FinancialException {
    try {
        StaticHibernateUtil.startTransaction();
        initalizeFinancialAction();
        loadCOA();
        StaticHibernateUtil.commitTransaction();
        // necessary or cacheCOA() doesn't work correctly. Is that because
        // the commitTransaction() isn't clearing the session?
        StaticHibernateUtil.clearSession();
        cacheCOA();
    } catch (Exception e) {
        StaticHibernateUtil.rollbackTransaction();
        throw new FinancialException(FinancialExceptionConstants.ACTIONNOTFOUND, e);
    }
}
Also used : FinancialException(org.mifos.accounts.financial.exceptions.FinancialException) FinancialException(org.mifos.accounts.financial.exceptions.FinancialException) IOException(java.io.IOException) ConfigurationException(org.mifos.config.exceptions.ConfigurationException)

Example 10 with FinancialException

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

the class FinancialInitializer method loadCOA.

/**
     * Reads chart of accounts from a configuration file and inserts into the
     * database. Deleting accounts is not currently supported, but if the user
     * tries to do this (by leaving it out of the custom chart of accounts
     * config file), there is currently no error reported.
     * <p>
     * QUESION: what if custom config was missing entries from default config,
     * but then is moved _out_ of the app server classpath?
     * <p>
     * ANSWER: once ChartOfAccountsConfig.isLoaded() returns true, <em>only
     * the custom CoA config file will be considered</em>. Using the custom
     * config will be the only way to add new accounts after the initial CoA
     * data is loaded in the database.
     */
public static void loadCOA() throws FinancialException {
    Session session = StaticHibernateUtil.getSessionTL();
    final String coaLocation;
    try {
        if (!ChartOfAccountsConfig.canLoadCoa(session)) {
            logger.info("Chart of accounts data will not be modified since " + "the custom chart of accounts configuration file was " + "not found on the classpath.");
            return;
        }
        coaLocation = ChartOfAccountsConfig.getCoaUri(session);
        logger.info("going to load or modify chart of accounts " + "configuration from " + coaLocation);
    } catch (IOException e) {
        throw new FinancialException("Charts of accounts loading failed", e);
    }
    ChartOfAccountsConfig coa;
    try {
        coa = ChartOfAccountsConfig.load(coaLocation);
    } catch (ConfigurationException e) {
        throw new FinancialException(coaLocation + " loading failed", e);
    }
    LegacyAccountDao ap = ApplicationContextProvider.getBean(LegacyAccountDao.class);
    for (GLAccount glAccount : coa.getGLAccounts()) {
        Short accountId = ap.getAccountIdFromGlCode(glAccount.glCode);
        if (null == accountId) {
            logger.info("Adding new general ledger account: " + glAccount);
            ap.addGeneralLedgerAccount(glAccount.name, glAccount.glCode, glAccount.parentGlCode, glAccount.categoryType);
        } else {
            COABO account = (COABO) session.load(COABO.class, accountId);
            if (account.getCategoryType() != glAccount.categoryType) {
                throw new FinancialException("category type change not supported");
            }
            if (!accountHierarchyMatch(account, glAccount)) {
                throw new FinancialException("chart of accounts hierarchy change not supported");
            }
            if (!account.getAccountName().equals(glAccount.name)) {
                logger.info("updating general ledger account name. code=" + account.getGlCode() + ". old name=" + account.getAccountName() + ", new name=" + glAccount.name);
                ap.updateAccountName(account, glAccount.name);
            }
        }
    }
}
Also used : ChartOfAccountsConfig(org.mifos.config.ChartOfAccountsConfig) ConfigurationException(org.mifos.config.exceptions.ConfigurationException) LegacyAccountDao(org.mifos.accounts.persistence.LegacyAccountDao) COABO(org.mifos.accounts.financial.business.COABO) GLAccount(org.mifos.config.GLAccount) IOException(java.io.IOException) FinancialException(org.mifos.accounts.financial.exceptions.FinancialException) Session(org.hibernate.Session)

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