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());
}
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);
}
}
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);
}
}
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);
}
}
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);
}
Aggregations