Search in sources :

Example 21 with AccountBusinessService

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);
    }
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) CustomerLevel(org.mifos.customers.api.CustomerLevel) AccountBusinessService(org.mifos.accounts.business.service.AccountBusinessService) ServiceException(org.mifos.framework.exceptions.ServiceException) UserContext(org.mifos.security.util.UserContext) MifosUser(org.mifos.security.MifosUser) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 22 with AccountBusinessService

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;
}
Also used : SavingsDetailDto(org.mifos.dto.domain.SavingsDetailDto) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) BigDecimal(java.math.BigDecimal) Money(org.mifos.framework.util.helpers.Money) AccountBusinessService(org.mifos.accounts.business.service.AccountBusinessService) ServiceException(org.mifos.framework.exceptions.ServiceException) ArrayList(java.util.ArrayList) List(java.util.List) MifosCurrency(org.mifos.application.master.business.MifosCurrency) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 23 with AccountBusinessService

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();
    }
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) WaiveEnum(org.mifos.accounts.util.helpers.WaiveEnum) BusinessRuleException(org.mifos.service.BusinessRuleException) AccountBusinessService(org.mifos.accounts.business.service.AccountBusinessService) ApplicationException(org.mifos.framework.exceptions.ApplicationException) ServiceException(org.mifos.framework.exceptions.ServiceException) UserContext(org.mifos.security.util.UserContext) MifosUser(org.mifos.security.MifosUser) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 24 with AccountBusinessService

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);
        }
    }
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) AccountBusinessService(org.mifos.accounts.business.service.AccountBusinessService) ApplicationException(org.mifos.framework.exceptions.ApplicationException) SystemException(org.mifos.framework.exceptions.SystemException) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) UserContext(org.mifos.security.util.UserContext) CustomerBO(org.mifos.customers.business.CustomerBO) MifosUser(org.mifos.security.MifosUser) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 25 with AccountBusinessService

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());
}
Also used : AccountBusinessService(org.mifos.accounts.business.service.AccountBusinessService) AdminDocumentBO(org.mifos.reports.admindocuments.business.AdminDocumentBO) BirtAdminDocumentUploadActionForm(org.mifos.reports.admindocuments.struts.actionforms.BirtAdminDocumentUploadActionForm) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) AdminDocAccActionMixBO(org.mifos.reports.admindocuments.business.AdminDocAccActionMixBO) AdminDocAccStateMixBO(org.mifos.reports.admindocuments.business.AdminDocAccStateMixBO) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

AccountBusinessService (org.mifos.accounts.business.service.AccountBusinessService)26 AccountBO (org.mifos.accounts.business.AccountBO)20 MifosRuntimeException (org.mifos.core.MifosRuntimeException)16 ServiceException (org.mifos.framework.exceptions.ServiceException)16 UserContext (org.mifos.security.util.UserContext)16 MifosUser (org.mifos.security.MifosUser)11 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)10 LoanBO (org.mifos.accounts.loan.business.LoanBO)8 BusinessRuleException (org.mifos.service.BusinessRuleException)7 ArrayList (java.util.ArrayList)6 AccountException (org.mifos.accounts.exceptions.AccountException)6 ApplicationException (org.mifos.framework.exceptions.ApplicationException)6 CustomerAccountBO (org.mifos.customers.business.CustomerAccountBO)5 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)4 BigDecimal (java.math.BigDecimal)3 Date (java.util.Date)3 List (java.util.List)3 AccountStateEntity (org.mifos.accounts.business.AccountStateEntity)3 EditStatusActionForm (org.mifos.accounts.struts.actionforms.EditStatusActionForm)3 CloseSession (org.mifos.framework.util.helpers.CloseSession)3