use of org.mifos.config.business.MifosConfigurationManager in project head by mifos.
the class AccountingRulesTest method testGetDigitsAfterDecimalMultiple.
@Test
public void testGetDigitsAfterDecimalMultiple() {
MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
Short digitsAfterDecimalSaved = AccountingRules.getDigitsAfterDecimal();
try {
checkDigitsAfterDecimalMultiple(2, "0.01");
checkDigitsAfterDecimalMultiple(1, "0.1");
checkDigitsAfterDecimalMultiple(0, "1");
checkDigitsAfterDecimalMultiple(-1, "10");
checkDigitsAfterDecimalMultiple(-2, "100");
} finally {
configMgr.setProperty(AccountingRulesConstants.DIGITS_AFTER_DECIMAL, digitsAfterDecimalSaved);
}
}
use of org.mifos.config.business.MifosConfigurationManager in project head by mifos.
the class AccountingRulesTest method testGetFinalRoundOffMultiple.
@Test
public void testGetFinalRoundOffMultiple() {
BigDecimal configuredRoundOffMultiple = AccountingRules.getFinalRoundOffMultiple();
String roundOffMultiple = "1";
MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
configMgr.setProperty(AccountingRulesConstants.FINAL_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.getFinalRoundOffMultiple());
// clear the RoundingRule property from the config file
configMgr.clearProperty(AccountingRulesConstants.FINAL_ROUND_OFF_MULTIPLE);
BigDecimal defaultValue = AccountingRules.getFinalRoundOffMultiple();
assertEquals(defaultValue, new BigDecimal("1"));
// save it back
configMgr.addProperty(AccountingRulesConstants.FINAL_ROUND_OFF_MULTIPLE, configuredRoundOffMultiple.toString());
}
use of org.mifos.config.business.MifosConfigurationManager in project head by mifos.
the class ClientRulesIntegrationTest method testGetGroupCanApplyLoans.
@Test
public void testGetGroupCanApplyLoans() throws Exception {
MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
ConfigurationPersistence configPersistence = new ConfigurationPersistence();
ConfigurationKeyValue savedDBValue = null;
savedDBValue = configPersistence.getConfigurationKeyValue(ClientRules.GroupCanApplyLoansKey);
Boolean savedValue = ClientRules.getGroupCanApplyLoans();
configMgr.setProperty(ClientRules.ClientRulesGroupCanApplyLoans, false);
configPersistence.updateConfigurationKeyValueInteger(ClientRules.GroupCanApplyLoansKey, Constants.NO);
ClientRules.refresh();
// set db value to false, too
Assert.assertFalse(ClientRules.getGroupCanApplyLoans());
// now the return value from accounting rules class has to be what is in
// the database (0)
ClientRules.refresh();
Assert.assertFalse(ClientRules.getGroupCanApplyLoans());
// set the saved value back for following tests
configPersistence.updateConfigurationKeyValueInteger(ClientRules.GroupCanApplyLoansKey, Integer.parseInt(savedDBValue.getValue()));
configMgr.setProperty(ClientRules.ClientRulesGroupCanApplyLoans, savedValue);
ClientRules.refresh();
}
use of org.mifos.config.business.MifosConfigurationManager in project head by mifos.
the class ClientRulesIntegrationTest method testClientCanExistOutsideGroup.
@Test
public void testClientCanExistOutsideGroup() throws Exception {
MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
ConfigurationPersistence configPersistence = new ConfigurationPersistence();
ConfigurationKeyValue savedDBValue = null;
savedDBValue = configPersistence.getConfigurationKeyValue(ClientRules.ClientCanExistOutsideGroupKey);
Boolean savedValue = ClientRules.getClientCanExistOutsideGroup();
configMgr.setProperty(ClientRules.ClientRulesClientCanExistOutsideGroup, false);
configPersistence.updateConfigurationKeyValueInteger(ClientRules.ClientCanExistOutsideGroupKey, Constants.NO);
ClientRules.refresh();
// set db value to false, too
Assert.assertFalse(ClientRules.getClientCanExistOutsideGroup());
// now the return value from accounting rules class has to be what is in
// the database (0)
ClientRules.refresh();
Assert.assertFalse(ClientRules.getClientCanExistOutsideGroup());
// set the saved value back for following tests
configPersistence.updateConfigurationKeyValueInteger(ClientRules.ClientCanExistOutsideGroupKey, Integer.parseInt(savedDBValue.getValue()));
configMgr.setProperty(ClientRules.ClientRulesClientCanExistOutsideGroup, savedValue);
ClientRules.refresh();
}
use of org.mifos.config.business.MifosConfigurationManager in project head by mifos.
the class AccountingRulesTest method testGetCurrencyRoundingMode.
@Test
public void testGetCurrencyRoundingMode() {
RoundingMode configuredMode = AccountingRules.getCurrencyRoundingMode();
String roundingMode = "FLOOR";
RoundingMode configRoundingMode = RoundingMode.FLOOR;
MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
configMgr.setProperty(AccountingRulesConstants.CURRENCY_ROUNDING_MODE, roundingMode);
// return value from accounting rules class has to be the value defined
// in the config file
assertEquals(configRoundingMode, AccountingRules.getCurrencyRoundingMode());
// clear the RoundingRule property from the config file so should get
// the default value
configMgr.clearProperty(AccountingRulesConstants.CURRENCY_ROUNDING_MODE);
RoundingMode defaultValue = AccountingRules.getCurrencyRoundingMode();
assertEquals(defaultValue, RoundingMode.HALF_UP);
// now set a wrong rounding mode in config
roundingMode = "UP";
configMgr.addProperty(AccountingRulesConstants.CURRENCY_ROUNDING_MODE, roundingMode);
try {
AccountingRules.getCurrencyRoundingMode();
fail();
} catch (RuntimeException e) {
assertEquals("CurrencyRoundingMode defined in the config file is not CEILING, FLOOR, HALF_UP. It is " + roundingMode, e.getMessage());
}
// save it back
configMgr.setProperty(AccountingRulesConstants.CURRENCY_ROUNDING_MODE, configuredMode.toString());
}
Aggregations