use of org.mifos.accounts.business.service.AccountBusinessService in project head by mifos.
the class WebTierAccountServiceFacade method isPaymentPermitted.
@Override
public boolean isPaymentPermitted(Integer accountId) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
try {
AccountBO account = new AccountBusinessService().getAccount(accountId);
CustomerLevel customerLevel = null;
if (account.getType().equals(AccountTypes.CUSTOMER_ACCOUNT)) {
customerLevel = account.getCustomer().getLevel();
}
Short personnelId = userContext.getId();
if (account.getPersonnel() != null) {
personnelId = account.getPersonnel().getPersonnelId();
}
return ActivityMapper.getInstance().isPaymentPermittedForAccounts(account.getType(), customerLevel, userContext, account.getOffice().getOfficeId(), personnelId);
} catch (ServiceException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.accounts.business.service.AccountBusinessService in project head by mifos.
the class CustomerDaoHibernate method getSavingsDetailDto.
@SuppressWarnings("unchecked")
@Override
public List<SavingsDetailDto> getSavingsDetailDto(Integer customerId, UserContext userContext) {
Map<String, Object> queryParameters = new HashMap<String, Object>();
queryParameters.put("CUSTOMER_ID", customerId);
List<Object[]> queryResult = (List<Object[]>) this.genericDao.executeNamedQuery("Customer.getSavingsDetailDto", queryParameters);
if (queryResult.size() == 0) {
return null;
}
List<SavingsDetailDto> savingsDetails = new ArrayList<SavingsDetailDto>();
String globalAccountNum;
String prdOfferingName;
Short accountStateId;
String accountStateName;
Money savingsBalance;
String lookupName;
Short currency;
BigDecimal maxWithdrawalAmount;
String savingsType = "";
MifosCurrency mifosCurrency = Money.getDefaultCurrency();
for (Object[] savingsDetail : queryResult) {
globalAccountNum = (String) savingsDetail[0];
prdOfferingName = (String) savingsDetail[1];
accountStateId = (Short) savingsDetail[2];
lookupName = (String) savingsDetail[3];
accountStateName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(lookupName);
// TODO - use default currency or retrieved currency?
currency = (Short) savingsDetail[4];
savingsBalance = new Money(mifosCurrency, (BigDecimal) savingsDetail[5]);
try {
SavingsBO savingsBO = (SavingsBO) new AccountBusinessService().findBySystemId(globalAccountNum);
maxWithdrawalAmount = savingsBO.getSavingsOffering().getMaxAmntWithdrawl().getAmount();
if (savingsBO.getSavingsOffering().getSavingsType().getLookUpValue() != null) {
savingsType = savingsBO.getSavingsOffering().getSavingsType().getName();
}
savingsDetails.add(new SavingsDetailDto(globalAccountNum, prdOfferingName, accountStateId, accountStateName, savingsBalance.toString(), maxWithdrawalAmount, savingsType));
} catch (ServiceException e) {
throw new MifosRuntimeException(e);
}
}
return savingsDetails;
}
use of org.mifos.accounts.business.service.AccountBusinessService in project head by mifos.
the class CenterServiceFacadeWebTier method waiveChargesOverDue.
@Override
public void waiveChargesOverDue(Integer accountId, Integer waiveType) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
try {
AccountBO account = new AccountBusinessService().getAccount(accountId);
account.updateDetails(userContext);
WaiveEnum waiveEnum = WaiveEnum.fromInt(waiveType);
if (account.getPersonnel() != null) {
new AccountBusinessService().checkPermissionForWaiveDue(waiveEnum, account.getType(), account.getCustomer().getLevel(), userContext, account.getOffice().getOfficeId(), account.getPersonnel().getPersonnelId());
} else {
new AccountBusinessService().checkPermissionForWaiveDue(waiveEnum, account.getType(), account.getCustomer().getLevel(), userContext, account.getOffice().getOfficeId(), userContext.getId());
}
this.transactionHelper.startTransaction();
account.waiveAmountOverDue(waiveEnum);
this.customerDao.save(account);
this.transactionHelper.commitTransaction();
} catch (ServiceException e) {
this.transactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} catch (ApplicationException e) {
this.transactionHelper.rollbackTransaction();
throw new BusinessRuleException(e.getKey(), e);
} finally {
this.transactionHelper.closeSession();
}
}
use of org.mifos.accounts.business.service.AccountBusinessService in project head by mifos.
the class CenterServiceFacadeWebTier method revertLastChargesPayment.
@Override
public void revertLastChargesPayment(String globalCustNum, String adjustmentNote) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
PersonnelBO loggedInUser = this.personnelDao.findPersonnelById(userContext.getId());
CustomerBO customerBO = this.customerDao.findCustomerBySystemId(globalCustNum);
customerBO.updateDetails(userContext);
if (customerBO.getCustomerAccount().findMostRecentNonzeroPaymentByPaymentDate() != null) {
customerBO.getCustomerAccount().updateDetails(userContext);
try {
if (customerBO.getPersonnel() != null) {
new AccountBusinessService().checkPermissionForAdjustment(AccountTypes.CUSTOMER_ACCOUNT, customerBO.getLevel(), userContext, customerBO.getOffice().getOfficeId(), customerBO.getPersonnel().getPersonnelId());
} else {
new AccountBusinessService().checkPermissionForAdjustment(AccountTypes.CUSTOMER_ACCOUNT, customerBO.getLevel(), userContext, customerBO.getOffice().getOfficeId(), userContext.getId());
}
this.transactionHelper.startTransaction();
customerBO.adjustPmnt(adjustmentNote, loggedInUser);
this.customerDao.save(customerBO);
this.transactionHelper.commitTransaction();
} catch (SystemException e) {
this.transactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} catch (ApplicationException e) {
this.transactionHelper.rollbackTransaction();
throw new BusinessRuleException(e.getKey(), e);
}
}
}
use of org.mifos.accounts.business.service.AccountBusinessService in project head by mifos.
the class BirtAdminDocumentUploadAction method edit.
@TransactionDemarcate(saveToken = true)
public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
BirtAdminDocumentUploadActionForm birtReportsUploadActionForm = (BirtAdminDocumentUploadActionForm) form;
List masterList = null;
List selectedlist = null;
AdminDocumentBO adminDocumentBO = this.legacyAdminDocumentDao.getAdminDocumentById(Short.valueOf(request.getParameter("admindocId")));
List<AdminDocAccStateMixBO> admindoclist = legacyAdminDocAccStateMixDao.getMixByAdminDocuments(Short.valueOf(request.getParameter("admindocId")));
if (admindoclist != null && !admindoclist.isEmpty()) {
SessionUtils.setAttribute("admindocId", adminDocumentBO.getAdmindocId(), request);
birtReportsUploadActionForm.setAdminiDocumentTitle(adminDocumentBO.getAdminDocumentName());
birtReportsUploadActionForm.setAccountTypeId(admindoclist.get(0).getAccountStateID().getPrdType().getProductTypeID().toString());
birtReportsUploadActionForm.setIsActive(adminDocumentBO.getIsActive().toString());
selectedlist = new ArrayList<AccountStateEntity>();
for (AdminDocAccStateMixBO admindoc : admindoclist) {
selectedlist.add(admindoc.getAccountStateID());
}
if (birtReportsUploadActionForm.getAccountTypeId() != null) {
Short accountTypeId = Short.valueOf(birtReportsUploadActionForm.getAccountTypeId());
masterList = new AccountBusinessService().retrieveAllActiveAccountStateList(AccountTypes.getAccountType(accountTypeId));
masterList.removeAll(selectedlist);
}
} else if (adminDocumentBO != null) {
List<AdminDocAccActionMixBO> adminDocAccActionMixList = legacyAdminDocAccStateMixDao.getAccActionMixByAdminDocument(Short.valueOf(request.getParameter("admindocId")));
SessionUtils.setAttribute("admindocId", adminDocumentBO.getAdmindocId(), request);
birtReportsUploadActionForm.setAdminiDocumentTitle(adminDocumentBO.getAdminDocumentName());
birtReportsUploadActionForm.setAccountTypeId("3");
birtReportsUploadActionForm.setIsActive(adminDocumentBO.getIsActive().toString());
masterList = getAvailableLoanTransactions((Short) SessionUtils.getAttribute("CURRENT_LOCALE_ID", request));
if ((adminDocAccActionMixList != null) && (!adminDocAccActionMixList.isEmpty())) {
selectedlist = new ArrayList<AccountActionEntity>();
for (AdminDocAccActionMixBO admindoc : adminDocAccActionMixList) {
selectedlist.add(admindoc.getAccountAction());
}
masterList.removeAll(selectedlist);
}
}
SessionUtils.setCollectionAttribute(ProductDefinitionConstants.AVAILABLEACCOUNTSTATUS, masterList, request);
SessionUtils.setCollectionAttribute(ProductDefinitionConstants.SELECTEDACCOUNTSTATUS, selectedlist, request);
SessionUtils.setCollectionAttribute(ProductDefinitionConstants.PRODUCTTYPELIST, getProductTypes(), request);
request.setAttribute(Constants.BUSINESS_KEY, adminDocumentBO);
birtReportsUploadActionForm.setStatusList(null);
return mapping.findForward(ActionForwards.edit_success.toString());
}
Aggregations