use of org.mifos.core.CurrencyMismatchException in project head by mifos.
the class GroupServiceFacadeWebTier method assembleGroupPerformanceHistoryDto.
private GroupPerformanceHistoryDto assembleGroupPerformanceHistoryDto(GroupPerformanceHistoryEntity groupPerformanceHistory, String searchId, Short branchId, Integer groupId) {
Integer activeClientCount = this.customerDao.getActiveAndOnHoldClientCountForGroup(searchId, branchId);
Money lastGroupLoanAmountMoney = groupPerformanceHistory.getLastGroupLoanAmount();
String lastGroupLoanAmount = "";
if (lastGroupLoanAmountMoney != null) {
lastGroupLoanAmount = lastGroupLoanAmountMoney.toString();
}
String avgLoanAmountForMember = this.customerDao.getAvgLoanAmountForMemberInGoodOrBadStanding(searchId, branchId);
String totalLoanAmountForGroup = this.customerDao.getTotalLoanAmountForGroup(searchId, branchId);
String portfolioAtRisk;
String totalSavingsAmount;
try {
if (groupPerformanceHistory.getPortfolioAtRisk() == null) {
portfolioAtRisk = "0";
} else {
portfolioAtRisk = groupPerformanceHistory.getPortfolioAtRisk().toString();
}
} catch (CurrencyMismatchException e) {
portfolioAtRisk = localizedMessageLookup("errors.multipleCurrencies");
}
totalSavingsAmount = this.customerDao.getTotalSavingsAmountForGroupandClientsOfGroup(searchId, branchId);
List<LoanCycleCounter> loanCycleCounters = this.customerDao.fetchLoanCycleCounter(groupId, CustomerLevel.GROUP.getValue());
return new GroupPerformanceHistoryDto(activeClientCount.toString(), lastGroupLoanAmount, avgLoanAmountForMember, totalLoanAmountForGroup, portfolioAtRisk, totalSavingsAmount, loanCycleCounters);
}
use of org.mifos.core.CurrencyMismatchException in project head by mifos.
the class CustomerDaoHibernate method getCenterPerformanceHistory.
/**
* FIXME: THIS METHOD DOES NOT WORK. Specifically, the portfolioAtRisk calculation. Please see issue 2204.
*/
@Override
public CenterPerformanceHistoryDto getCenterPerformanceHistory(String searchId, Short officeId) {
Integer activeAndOnHoldGroupCount;
Integer activeAndOnHoldClientCount;
String totalSavings;
String totalLoan;
activeAndOnHoldGroupCount = getActiveAndOnHoldChildrenCount(searchId, officeId, CustomerLevel.GROUP);
activeAndOnHoldClientCount = getActiveAndOnHoldChildrenCount(searchId, officeId, CustomerLevel.CLIENT);
try {
totalSavings = retrieveTotalSavings(searchId, officeId).toString();
} catch (CurrencyMismatchException e) {
totalSavings = localizedMessageLookup("errors.multipleCurrencies");
}
try {
totalLoan = retrieveTotalLoan(searchId, officeId).toString();
} catch (CurrencyMismatchException e) {
totalLoan = localizedMessageLookup("errors.multipleCurrencies");
}
String portfolioAtRisk = "0.2";
return new CenterPerformanceHistoryDto(activeAndOnHoldGroupCount, activeAndOnHoldClientCount, totalLoan, totalSavings, portfolioAtRisk);
}
use of org.mifos.core.CurrencyMismatchException in project head by mifos.
the class ClientServiceFacadeWebTier method assembleClientPerformanceHistoryDto.
private ClientPerformanceHistoryDto assembleClientPerformanceHistoryDto(ClientPerformanceHistoryEntity clientPerformanceHistory, Integer clientId) {
Integer loanCycleNumber = clientPerformanceHistory.getLoanCycleNumber();
Money lastLoanAmount = clientPerformanceHistory.getLastLoanAmount();
Integer noOfActiveLoans = clientPerformanceHistory.getNoOfActiveLoans();
String delinquentPortfolioAmountString;
try {
Money delinquentPortfolioAmount = clientPerformanceHistory.getDelinquentPortfolioAmount();
delinquentPortfolioAmountString = delinquentPortfolioAmount.toString();
} catch (CurrencyMismatchException e) {
delinquentPortfolioAmountString = localizedMessageLookup("errors.multipleCurrencies");
}
// TODO currency mismatch check
Money totalSavingsAmount = clientPerformanceHistory.getTotalSavingsAmount();
Integer meetingsAttended = this.customerDao.numberOfMeetings(true, clientId).getMeetingsAttended();
Integer meetingsMissed = customerDao.numberOfMeetings(false, clientId).getMeetingsMissed();
List<LoanCycleCounter> loanCycleCounters = this.customerDao.fetchLoanCycleCounter(clientId, CustomerLevel.CLIENT.getValue());
return new ClientPerformanceHistoryDto(loanCycleNumber, lastLoanAmount.toString(), noOfActiveLoans, delinquentPortfolioAmountString, totalSavingsAmount.toString(), meetingsAttended, meetingsMissed, loanCycleCounters);
}
use of org.mifos.core.CurrencyMismatchException in project head by mifos.
the class CustomerDaoHibernate method retrieveTotalForQuery.
@SuppressWarnings("unchecked")
private Money retrieveTotalForQuery(String query, final String searchId, final Short officeId) {
Map<String, Object> queryParameters = new HashMap<String, Object>();
queryParameters.put("SEARCH_STRING1", searchId);
queryParameters.put("SEARCH_STRING2", searchId + ".%");
queryParameters.put("OFFICE_ID", officeId);
List queryResult = this.genericDao.executeNamedQuery(query, queryParameters);
if (queryResult.size() > 1) {
throw new CurrencyMismatchException(ExceptionConstants.ILLEGALMONEYOPERATION);
}
if (queryResult.size() == 0) {
// if we found no results, then return zero using the default currency
return new Money(Money.getDefaultCurrency(), "0.0");
}
Integer currencyId = (Integer) ((Object[]) queryResult.get(0))[0];
MifosCurrency currency = AccountingRules.getCurrencyByCurrencyId(currencyId.shortValue());
BigDecimal total = (BigDecimal) ((Object[]) queryResult.get(0))[1];
return new Money(currency, total);
}
use of org.mifos.core.CurrencyMismatchException in project head by mifos.
the class CustomerPersistence method getCurrencyForTotalAmountForAllClientsOfGroup.
private MifosCurrency getCurrencyForTotalAmountForAllClientsOfGroup(final Short officeId, final AccountState accountState, final String searchIdString) throws PersistenceException {
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("officeId", officeId);
params.put("accountState", accountState.getValue());
params.put("searchId", searchIdString);
List queryResult = executeNamedQuery(NamedQueryConstants.GET_LOAN_SUMMARY_CURRENCIES_FOR_ALL_CLIENTS_OF_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);
}
Aggregations