Search in sources :

Example 26 with MifosConfigurationManager

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

the class AccountingRulesTest method testGetInitialRoundOffMultiple.

@Test
public void testGetInitialRoundOffMultiple() {
    BigDecimal configuredRoundOffMultiple = AccountingRules.getInitialRoundOffMultiple();
    String roundOffMultiple = "1";
    MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
    configMgr.setProperty(AccountingRulesConstants.INITIAL_ROUND_OFF_MULTIPLE, roundOffMultiple);
    // return value from accounting rules class has to be the value defined
    // in the config file
    assertEquals(new BigDecimal(roundOffMultiple), AccountingRules.getInitialRoundOffMultiple());
    // clear the RoundingRule property from the config file
    configMgr.clearProperty(AccountingRulesConstants.INITIAL_ROUND_OFF_MULTIPLE);
    BigDecimal defaultValue = AccountingRules.getInitialRoundOffMultiple();
    assertEquals(defaultValue, new BigDecimal("1"));
    // save it back
    configMgr.addProperty(AccountingRulesConstants.INITIAL_ROUND_OFF_MULTIPLE, configuredRoundOffMultiple.toString());
}
Also used : BigDecimal(java.math.BigDecimal) MifosConfigurationManager(org.mifos.config.business.MifosConfigurationManager) Test(org.junit.Test)

Example 27 with MifosConfigurationManager

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

the class AccountingRulesTest method digitsAfterDecimalFallsBackToDefault.

@Ignore
@Test
public void digitsAfterDecimalFallsBackToDefault() {
    MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
    try {
        configMgr.setProperty(AccountingRulesConstants.ADDITIONAL_CURRENCY_CODES, TestUtils.EURO.getCurrencyCode());
        assertEquals(new Short("1"), AccountingRules.getDigitsAfterDecimal(TestUtils.EURO));
    } finally {
        configMgr.clearProperty(AccountingRulesConstants.ADDITIONAL_CURRENCY_CODES);
    }
}
Also used : MifosConfigurationManager(org.mifos.config.business.MifosConfigurationManager) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 28 with MifosConfigurationManager

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

the class AccountingRulesTest method globalMulticurrencyFlagWorks.

@Ignore
@Test
public void globalMulticurrencyFlagWorks() {
    assertFalse(AccountingRules.isMultiCurrencyEnabled());
    List<String> codes = new ArrayList<String>();
    codes.add("LBP");
    MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
    try {
        configMgr.setProperty(AccountingRulesConstants.ADDITIONAL_CURRENCY_CODES, codes);
        assertTrue(AccountingRules.isMultiCurrencyEnabled());
    } finally {
        configMgr.clearProperty(AccountingRulesConstants.ADDITIONAL_CURRENCY_CODES);
    }
}
Also used : ArrayList(java.util.ArrayList) MifosConfigurationManager(org.mifos.config.business.MifosConfigurationManager) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 29 with MifosConfigurationManager

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

the class AccountingRulesTest method testGetNumberOfInterestDays.

@Test
public void testGetNumberOfInterestDays() {
    Short interestDaysInConfig = AccountingRules.getNumberOfInterestDays();
    MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
    Short insertedDays = 365;
    configMgr.setProperty(AccountingRulesConstants.NUMBER_OF_INTEREST_DAYS, insertedDays);
    assertEquals(insertedDays, AccountingRules.getNumberOfInterestDays());
    insertedDays = 360;
    // set new value
    configMgr.setProperty(AccountingRulesConstants.NUMBER_OF_INTEREST_DAYS, insertedDays);
    // return value from accounting rules class has to be the value defined
    // in the config file
    assertEquals(insertedDays, AccountingRules.getNumberOfInterestDays());
    insertedDays = 355;
    configMgr.setProperty(AccountingRulesConstants.NUMBER_OF_INTEREST_DAYS, insertedDays);
    // throw exception because the invalid value 355
    try {
        AccountingRules.getNumberOfInterestDays();
        fail();
    } catch (RuntimeException e) {
        assertEquals("Invalid number of interest days defined in property file " + insertedDays.shortValue(), e.getMessage());
    } finally {
        configMgr.setProperty(AccountingRulesConstants.NUMBER_OF_INTEREST_DAYS, interestDaysInConfig);
    }
}
Also used : MifosConfigurationManager(org.mifos.config.business.MifosConfigurationManager) Test(org.junit.Test)

Example 30 with MifosConfigurationManager

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

the class AccountingRulesTest method testgetMifosCurrency.

@Test
public void testgetMifosCurrency() {
    when(configurationPersistence.getCurrency("INR")).thenReturn(TestUtils.RUPEE);
    when(configurationPersistence.getCurrency("EUR")).thenReturn(TestUtils.EURO);
    MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
    String currencyCode = configMgr.getString(AccountingRulesConstants.CURRENCY_CODE);
    configMgr.setProperty(AccountingRulesConstants.CURRENCY_CODE, "INR");
    MifosCurrency currency = AccountingRules.getMifosCurrency(configurationPersistence);
    assertEquals(currency.getCurrencyCode(), "INR");
    configMgr.setProperty(AccountingRulesConstants.CURRENCY_CODE, "EUR");
    currency = AccountingRules.getMifosCurrency(configurationPersistence);
    assertEquals(currency.getCurrencyCode(), "EUR");
    configMgr.setProperty(AccountingRulesConstants.CURRENCY_CODE, "UUU");
    try {
        currency = AccountingRules.getMifosCurrency(configurationPersistence);
        fail();
    } catch (Exception e) {
    }
    configMgr.setProperty(AccountingRulesConstants.CURRENCY_CODE, currencyCode);
}
Also used : MifosCurrency(org.mifos.application.master.business.MifosCurrency) MifosConfigurationManager(org.mifos.config.business.MifosConfigurationManager) Test(org.junit.Test)

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