use of org.mifos.core.CurrencyMismatchException in project head by mifos.
the class CustomerPersistence method getCurrencyForTotalAmountForGroup.
private MifosCurrency getCurrencyForTotalAmountForGroup(final Integer groupId, final AccountState accountState) throws PersistenceException {
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("customerId", groupId);
params.put("accountState", accountState.getValue());
List queryResult = executeNamedQuery(NamedQueryConstants.GET_LOAN_SUMMARY_CURRENCIES_FOR_GROUP, params);
if (queryResult.size() > 1) {
throw new CurrencyMismatchException(ExceptionConstants.ILLEGALMONEYOPERATION);
}
if (queryResult.size() == 0) {
// if we found no results, then return the default currency
return Money.getDefaultCurrency();
}
Short currencyId = (Short) queryResult.get(0);
return AccountingRules.getCurrencyByCurrencyId(currencyId);
}
use of org.mifos.core.CurrencyMismatchException 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.core.CurrencyMismatchException 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);
}
}
Aggregations