use of org.mifos.application.master.business.MifosCurrency in project head by mifos.
the class CustomerPersistence method getLoanDetailDto.
@SuppressWarnings("unchecked")
public List<LoanDetailDto> getLoanDetailDto(Integer customerId, UserContext userContext) throws PersistenceException {
Map<String, Object> queryParameters = new HashMap<String, Object>();
queryParameters.put("CUSTOMER_ID", customerId);
List<Object[]> queryResult = executeNamedQuery("Customer.getLoanDetailDto", queryParameters);
if (queryResult.size() == 0) {
return null;
}
List<LoanDetailDto> loanDetails = new ArrayList<LoanDetailDto>();
String globalAccountNum;
String prdOfferingName;
Short accountStateId;
String accountStateName;
Money outstandingBalance;
Money totalAmountDue;
String lookupName;
Short currency;
MifosCurrency mifosCurrency = Money.getDefaultCurrency();
for (Object[] loanDetail : queryResult) {
globalAccountNum = (String) loanDetail[0];
prdOfferingName = (String) loanDetail[1];
accountStateId = (Short) loanDetail[2];
lookupName = (String) loanDetail[3];
accountStateName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(lookupName);
// TODO - use default currency or retrieved currency?
currency = (Short) loanDetail[4];
outstandingBalance = new Money(mifosCurrency, (BigDecimal) loanDetail[5]);
// TODO
totalAmountDue = new Money(mifosCurrency, "7.7");
loanDetails.add(new LoanDetailDto(globalAccountNum, prdOfferingName, accountStateId, accountStateName, outstandingBalance.toString(), totalAmountDue.toString(), "0"));
}
return loanDetails;
}
use of org.mifos.application.master.business.MifosCurrency in project head by mifos.
the class CustomerPersistence method getTotalAmountForGroup.
public Money getTotalAmountForGroup(final Integer groupId, final AccountState accountState) throws PersistenceException {
MifosCurrency currency = getCurrencyForTotalAmountForGroup(groupId, accountState);
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("customerId", groupId);
params.put("accountState", accountState.getValue());
BigDecimal amount = getCalculateValueFromQueryResult(executeNamedQuery(NamedQueryConstants.GET_TOTAL_AMOUNT_FOR_GROUP, params));
Money totalAmount = new Money(currency, amount);
return totalAmount;
}
use of org.mifos.application.master.business.MifosCurrency in project head by mifos.
the class LoanAccountServiceFacadeWebTier method validateInputInstallments.
@Override
public Errors validateInputInstallments(Date disbursementDate, Integer minGapInDays, Integer maxGapInDays, BigDecimal minInstallmentAmount, List<LoanCreationInstallmentDto> dtoInstallments, Integer customerId) {
Short officeId = customerDao.findCustomerById(customerId).getOfficeId();
VariableInstallmentDetailsBO variableInstallmentDetails = new VariableInstallmentDetailsBO();
variableInstallmentDetails.setMinGapInDays(minGapInDays);
variableInstallmentDetails.setMaxGapInDays(maxGapInDays);
InstallmentValidationContext context = new InstallmentValidationContext(disbursementDate, variableInstallmentDetails, minInstallmentAmount, holidayServiceFacade, officeId);
MifosCurrency currency = Money.getDefaultCurrency();
List<RepaymentScheduleInstallment> installments = new ArrayList<RepaymentScheduleInstallment>();
for (LoanCreationInstallmentDto dto : dtoInstallments) {
Money principal = new Money(currency, dto.getPrincipal());
Money interest = new Money(currency, dto.getInterest());
Money fees = new Money(currency, dto.getFees());
Money miscFees = new Money(currency);
Money miscPenalty = new Money(currency);
RepaymentScheduleInstallment installment = new RepaymentScheduleInstallment(dto.getInstallmentNumber(), dto.getDueDate(), principal, interest, fees, miscFees, miscPenalty);
installment.setTotalAndTotalValue(new Money(currency, dto.getTotal()));
installments.add(installment);
}
return installmentsValidator.validateInputInstallments(installments, context);
}
use of org.mifos.application.master.business.MifosCurrency in project head by mifos.
the class BulkEntryDisplayHelper method buildForCenter.
public Money[] buildForCenter(final CollectionSheetEntryDto centerEntry, final List<ProductDto> loanProducts, final List<ProductDto> savingsProducts, final List<CustomValueListElementDto> custAttTypes, final StringBuilder builder, final String method, final UserContext userContext) {
int rowIndex = 0;
final int totalProductsSize = 2 * (loanProducts.size() + savingsProducts.size());
final Money[] centerTotals = new Money[(totalProductsSize + 1)];
Money[] groupTotals = new Money[(totalProductsSize + 1)];
for (int i = 0; i < centerTotals.length; i++) {
centerTotals[i] = new Money(centerEntry.getCurrency());
}
final MifosCurrency currency = centerEntry.getCurrency();
final String accountLabel = getLocalizedMessage(CollectionSheetEntryConstants.ACCOUNTS_GROUP_CENTER);
final List<CollectionSheetEntryDto> groupEntries = centerEntry.getCollectionSheetEntryChildren();
for (CollectionSheetEntryDto groupEntry : groupEntries) {
groupTotals = new Money[(totalProductsSize + 1)];
int groupInitialAccNum = rowIndex;
final List<CollectionSheetEntryDto> clientEntries = groupEntry.getCollectionSheetEntryChildren();
final int clientCount = clientEntries.size();
final String groupName = groupEntry.getCustomerDetail().getDisplayName();
buildGroupName(builder, groupName, totalProductsSize + 1);
for (CollectionSheetEntryDto clientEntry : clientEntries) {
final int levelId = 1;
buildClientRow(clientEntry, loanProducts, savingsProducts, clientCount, groupInitialAccNum, rowIndex, groupTotals, clientEntry.getCustomerDetail().getDisplayName(), builder, method, levelId, currency);
generateAttendance(builder, custAttTypes, rowIndex, clientEntry, method);
BulkEntryTagUIHelper.getInstance().generateEndTR(builder);
rowIndex++;
}
final int levelId = 2;
final String groupLabel = getLabel(ConfigurationConstants.GROUP, userContext);
final String formattedGroupAccountStr = accountLabel.format(accountLabel, groupLabel);
final String groupAccountStr = " " + formattedGroupAccountStr + " ";
buildClientRow(groupEntry, loanProducts, savingsProducts, clientCount, groupInitialAccNum, rowIndex, groupTotals, groupAccountStr, builder, method, levelId, currency);
BulkEntryTagUIHelper.getInstance().generateEmptyTD(builder, true);
BulkEntryTagUIHelper.getInstance().generateEndTR(builder);
rowIndex++;
getTotalForRow(builder, groupEntry, groupTotals, rowIndex, method, userContext, loanProducts.size(), savingsProducts.size());
for (int i = 0; i < groupTotals.length; i++) {
if (groupTotals[i] != null) {
centerTotals[i] = centerTotals[i].add(groupTotals[i]);
}
}
}
final int levelId = 3;
final String center = getLabel(ConfigurationConstants.CENTER, userContext);
final String formattedCenterAccountStr = accountLabel.format(accountLabel, center);
final String centerAccountStr = " " + formattedCenterAccountStr + " ";
buildClientRow(centerEntry, loanProducts, savingsProducts, 0, 0, rowIndex, groupTotals, centerAccountStr, builder, method, levelId, currency);
BulkEntryTagUIHelper.getInstance().generateEmptyTD(builder, true);
BulkEntryTagUIHelper.getInstance().generateEndTR(builder);
getTotalForRow(builder, centerEntry, centerTotals, rowIndex, method, userContext, loanProducts.size(), savingsProducts.size());
return centerTotals;
}
use of org.mifos.application.master.business.MifosCurrency in project head by mifos.
the class BulkEntryDisplayHelper method buildForGroup.
public Money[] buildForGroup(final CollectionSheetEntryDto parent, final List<ProductDto> loanProducts, final List<ProductDto> savingsProducts, final List<CustomValueListElementDto> custAttTypes, final StringBuilder builder, final String method, final UserContext userContext) {
int rowIndex = 0;
int totalProductsSize = 2 * (loanProducts.size() + savingsProducts.size());
Money[] groupTotals = new Money[(totalProductsSize + 1)];
MifosCurrency currency = parent.getCurrency();
Locale locale = userContext.getPreferredLocale();
String account = getLocalizedMessage(CollectionSheetEntryConstants.ACCOUNTS_GROUP_CENTER);
String group = getLabel(ConfigurationConstants.GROUP, userContext);
String groupAccountStr = account.format(account, group);
groupAccountStr = " " + groupAccountStr + " ";
for (CollectionSheetEntryDto child : parent.getCollectionSheetEntryChildren()) {
buildClientRow(child, loanProducts, savingsProducts, parent.getCollectionSheetEntryChildren().size(), 0, rowIndex, groupTotals, child.getCustomerDetail().getDisplayName(), builder, method, 1, currency);
generateAttendance(builder, custAttTypes, rowIndex, child, method);
BulkEntryTagUIHelper.getInstance().generateEndTR(builder);
rowIndex++;
}
buildClientRow(parent, loanProducts, savingsProducts, parent.getCollectionSheetEntryChildren().size(), 0, rowIndex, groupTotals, groupAccountStr, builder, method, 2, currency);
BulkEntryTagUIHelper.getInstance().generateEmptyTD(builder, true);
BulkEntryTagUIHelper.getInstance().generateEndTR(builder);
rowIndex++;
getTotalForRow(builder, parent, groupTotals, rowIndex, method, userContext, loanProducts.size(), savingsProducts.size());
return groupTotals;
}
Aggregations