use of org.mifos.config.business.MifosConfigurationManager in project head by mifos.
the class AccountingRulesTest method testGetFinalRoundingMode.
@Test
public void testGetFinalRoundingMode() {
RoundingMode configuredMode = AccountingRules.getFinalRoundingMode();
String roundingMode = "CEILING";
RoundingMode configRoundingMode = RoundingMode.CEILING;
MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
configMgr.setProperty(AccountingRulesConstants.FINAL_ROUNDING_MODE, roundingMode);
// return value from accounting rules class has to be the value defined
// in the config file
assertEquals(configRoundingMode, AccountingRules.getFinalRoundingMode());
// clear the RoundingRule property from the config file
configMgr.clearProperty(AccountingRulesConstants.FINAL_ROUNDING_MODE);
RoundingMode defaultValue = AccountingRules.getFinalRoundingMode();
assertEquals(defaultValue, RoundingMode.CEILING);
// now set a wrong rounding mode in config
roundingMode = "DOWN";
configMgr.addProperty(AccountingRulesConstants.FINAL_ROUNDING_MODE, roundingMode);
try {
AccountingRules.getFinalRoundingMode();
fail();
} catch (RuntimeException e) {
assertEquals("FinalRoundingMode defined in the config file is not CEILING, FLOOR, HALF_UP. It is " + roundingMode, e.getMessage());
}
// save it back
configMgr.setProperty(AccountingRulesConstants.FINAL_ROUNDING_MODE, configuredMode.toString());
}
use of org.mifos.config.business.MifosConfigurationManager in project head by mifos.
the class CustomerPersistenceIntegrationTest method testGetTotalAmountForAllClientsOfGroupForMultipleCurrencies.
/*
* When trying to sum amounts across loans with different currencies, we should get an exception
*/
@Test
public void testGetTotalAmountForAllClientsOfGroupForMultipleCurrencies() throws Exception {
MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
configMgr.setProperty(AccountingRulesConstants.ADDITIONAL_CURRENCY_CODES, TestUtils.EURO.getCurrencyCode());
AccountBO clientAccount1;
AccountBO clientAccount2;
try {
MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
center = createCenter("new_center");
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
client = TestObjectFactory.createClient("client1", CustomerStatus.CLIENT_ACTIVE, group);
clientAccount1 = getLoanAccount(client, meeting, "fdbdhgsgh", "54hg", TestUtils.RUPEE);
clientAccount2 = getLoanAccount(client, meeting, "fasdfdsfasdf", "1qwe", TestUtils.EURO);
try {
customerPersistence.getTotalAmountForAllClientsOfGroup(group.getOffice().getOfficeId(), AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, group.getSearchId() + ".%");
Assert.fail("didn't get the expected CurrencyMismatchException");
} catch (CurrencyMismatchException e) {
// if we got here then we got the exception we were expecting
Assert.assertNotNull(e);
} catch (Exception e) {
Assert.fail("didn't get the expected CurrencyMismatchException");
}
} finally {
configMgr.clearProperty(AccountingRulesConstants.ADDITIONAL_CURRENCY_CODES);
}
}
use of org.mifos.config.business.MifosConfigurationManager in project head by mifos.
the class CustomerPersistenceIntegrationTest method testGetTotalAmountForGroupForMultipleCurrencies.
/*
* When trying to sum amounts across loans with different currencies, we should get an exception
*/
@Test
public void testGetTotalAmountForGroupForMultipleCurrencies() throws Exception {
MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
configMgr.setProperty(AccountingRulesConstants.ADDITIONAL_CURRENCY_CODES, TestUtils.EURO.getCurrencyCode());
GroupBO group1;
AccountBO account1;
AccountBO account2;
try {
CustomerPersistence customerPersistence = new CustomerPersistence();
meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
group1 = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group1", CustomerStatus.GROUP_ACTIVE, center);
account1 = getLoanAccount(group1, meeting, "adsfdsfsd", "3saf", TestUtils.RUPEE);
account2 = getLoanAccount(group1, meeting, "adspp", "kkaf", TestUtils.EURO);
try {
customerPersistence.getTotalAmountForGroup(group1.getCustomerId(), AccountState.LOAN_ACTIVE_IN_GOOD_STANDING);
Assert.fail("didn't get the expected CurrencyMismatchException");
} catch (CurrencyMismatchException e) {
// if we got here then we got the exception we were expecting
Assert.assertNotNull(e);
} catch (Exception e) {
Assert.fail("didn't get the expected CurrencyMismatchException");
}
} finally {
configMgr.clearProperty(AccountingRulesConstants.ADDITIONAL_CURRENCY_CODES);
}
}
use of org.mifos.config.business.MifosConfigurationManager in project head by mifos.
the class MoneyTest method testIsRoundedAmount.
@Test
public void testIsRoundedAmount() {
String currencyCodeSuffix = "." + TestUtils.EURO.getCurrencyCode();
MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
configMgr.setProperty(AccountingRulesConstants.DIGITS_AFTER_DECIMAL + currencyCodeSuffix, "1");
configMgr.setProperty(AccountingRulesConstants.INITIAL_ROUND_OFF_MULTIPLE + currencyCodeSuffix, "1");
configMgr.setProperty(AccountingRulesConstants.FINAL_ROUND_OFF_MULTIPLE + currencyCodeSuffix, "1");
configMgr.setProperty(AccountingRulesConstants.ADDITIONAL_CURRENCY_CODES, TestUtils.EURO.getCurrencyCode());
try {
Assert.assertTrue(MoneyUtils.isRoundedAmount(new Money(EURO, "1")));
Assert.assertFalse(MoneyUtils.isRoundedAmount(new Money(EURO, "1.1")));
Money.setDefaultCurrency(RUPEE);
Assert.assertFalse(MoneyUtils.isRoundedAmount(1.1));
} finally {
configMgr.clearProperty(AccountingRulesConstants.DIGITS_AFTER_DECIMAL + currencyCodeSuffix);
configMgr.clearProperty(AccountingRulesConstants.INITIAL_ROUND_OFF_MULTIPLE + currencyCodeSuffix);
configMgr.clearProperty(AccountingRulesConstants.FINAL_ROUND_OFF_MULTIPLE + currencyCodeSuffix);
configMgr.clearProperty(AccountingRulesConstants.ADDITIONAL_CURRENCY_CODES);
}
}
use of org.mifos.config.business.MifosConfigurationManager in project head by mifos.
the class StandardTestingService method setProcessFlow.
@Override
public void setProcessFlow(String processFlowParamName, String processFlowParamValue) throws MifosException {
MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
if (processFlowParamValue == null || processFlowParamValue.equals("")) {
configMgr.clearProperty(processFlowParamName);
return;
}
configMgr.setProperty(processFlowParamName, processFlowParamValue);
}
Aggregations