Search in sources :

Example 51 with MifosConfigurationManager

use of org.mifos.config.business.MifosConfigurationManager in project head by mifos.

the class ClientRules method getGroupCanApplyLoansFromConfig.

private static boolean getGroupCanApplyLoansFromConfig() {
    boolean cfgValue;
    try {
        int dbValue = getConfigPersistence().getConfigurationValueInteger(GroupCanApplyLoansKey);
        MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
        cfgValue = configMgr.getBoolean(ClientRulesGroupCanApplyLoans);
        if (dbValue == Constants.NO && cfgValue == true) {
            getConfigPersistence().updateConfigurationKeyValueInteger(GroupCanApplyLoansKey, Constants.YES);
        } else if (dbValue == Constants.YES && cfgValue == false) {
            if (ApplicationContextProvider.getBean(LegacyLoanDao.class).countOfGroupLoanAccounts() > 0) {
                // in the config file violates business rules.
                throw new MifosRuntimeException(getBadOverrideMsg(GroupCanApplyLoansKey, "Group loans may already exist."));
            }
            makeDatabaseConfigMatchFilebasedConfig();
        }
    } catch (PersistenceException ex) {
        throw new MifosRuntimeException(ex);
    }
    return cfgValue;
}
Also used : PersistenceException(org.mifos.framework.exceptions.PersistenceException) MifosConfigurationManager(org.mifos.config.business.MifosConfigurationManager) LegacyLoanDao(org.mifos.accounts.loan.persistance.LegacyLoanDao) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 52 with MifosConfigurationManager

use of org.mifos.config.business.MifosConfigurationManager in project head by mifos.

the class ClientRules method getClientCanExistOutsideGroupFromConfig.

private static boolean getClientCanExistOutsideGroupFromConfig() {
    boolean cfgValue;
    try {
        int dbValue = getConfigPersistence().getConfigurationValueInteger(ClientCanExistOutsideGroupKey);
        MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
        cfgValue = configMgr.getBoolean(ClientRulesClientCanExistOutsideGroup);
        if (dbValue == Constants.NO && cfgValue == true) {
            getConfigPersistence().updateConfigurationKeyValueInteger(ClientCanExistOutsideGroupKey, Constants.YES);
        } else if (dbValue == Constants.YES && cfgValue == false) {
            // in the config file violates business rules.
            throw new MifosRuntimeException(getBadOverrideMsg(ClientCanExistOutsideGroupKey, "Clients outside of groups may already exist."));
        }
    } catch (PersistenceException ex) {
        throw new MifosRuntimeException(ex);
    }
    return cfgValue;
}
Also used : PersistenceException(org.mifos.framework.exceptions.PersistenceException) MifosConfigurationManager(org.mifos.config.business.MifosConfigurationManager) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 53 with MifosConfigurationManager

use of org.mifos.config.business.MifosConfigurationManager in project head by mifos.

the class ClientRules method getNameSequence.

/*
     * Fetches and populates ClientRules#nameSequence.
     */
public static String[] getNameSequence() {
    if (nameSequence == null) {
        MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
        nameSequence = configMgr.getStringArray(ClientRulesNameSequence);
    }
    return nameSequence;
}
Also used : MifosConfigurationManager(org.mifos.config.business.MifosConfigurationManager)

Example 54 with MifosConfigurationManager

use of org.mifos.config.business.MifosConfigurationManager in project head by mifos.

the class FiscalCalendarRules method getScheduleMeetingIfNonWorkingDay.

public String getScheduleMeetingIfNonWorkingDay() {
    String scheduleType = null;
    MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
    if (configMgr.containsKey(FiscalCalendarRulesScheduleTypeForMeetingIfNonWorkingDay)) {
        scheduleType = configMgr.getString(FiscalCalendarRulesScheduleTypeForMeetingIfNonWorkingDay);
    } else {
        throw new RuntimeException("The schedule type for meeting if non working day is not defined in the config file.");
    }
    return scheduleType;
}
Also used : MifosConfigurationManager(org.mifos.config.business.MifosConfigurationManager)

Example 55 with MifosConfigurationManager

use of org.mifos.config.business.MifosConfigurationManager in project head by mifos.

the class AccountingRules method getRoundingMode.

public static Short getRoundingMode(Short defaultValue) {
    Short mode;
    MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
    if (configMgr.containsKey(AccountingRulesConstants.ROUNDING_RULE)) {
        String returnStr = configMgr.getString(AccountingRulesConstants.ROUNDING_RULE);
        if (returnStr.equals("FLOOR")) {
            mode = MifosCurrency.FLOOR_MODE;
        } else if (returnStr.equals("CEILING")) {
            mode = MifosCurrency.CEILING_MODE;
        } else if (returnStr.equals("HALF_UP")) {
            mode = MifosCurrency.HALF_UP_MODE;
        } else {
            throw new RuntimeException("The rounding mode defined in the config file is not CEILING, FLOOR, HALF_UP. It is " + returnStr);
        }
    } else {
        mode = defaultValue;
    }
    return mode;
}
Also used : MifosRuntimeException(org.mifos.core.MifosRuntimeException) MifosConfigurationManager(org.mifos.config.business.MifosConfigurationManager)

Aggregations

MifosConfigurationManager (org.mifos.config.business.MifosConfigurationManager)66 Test (org.junit.Test)18 ConfigurationException (org.mifos.config.exceptions.ConfigurationException)8 Properties (java.util.Properties)5 MifosRuntimeException (org.mifos.core.MifosRuntimeException)5 PersistenceException (org.mifos.framework.exceptions.PersistenceException)5 ApplicationException (org.mifos.framework.exceptions.ApplicationException)4 RoundingMode (java.math.RoundingMode)3 ConfigurationPersistence (org.mifos.config.persistence.ConfigurationPersistence)3 CustomerAccountBO (org.mifos.customers.business.CustomerAccountBO)3 SystemException (org.mifos.framework.exceptions.SystemException)3 BigDecimal (java.math.BigDecimal)2 Ignore (org.junit.Ignore)2 AccountBO (org.mifos.accounts.business.AccountBO)2 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)2 ConfigurationKeyValue (org.mifos.config.business.ConfigurationKeyValue)2 CurrencyMismatchException (org.mifos.core.CurrencyMismatchException)2 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1