Search in sources :

Example 6 with WaiveEnum

use of org.mifos.accounts.util.helpers.WaiveEnum in project head by mifos.

the class AccountAppAction method waiveChargeOverDue.

@TransactionDemarcate(joinToken = true)
public ActionForward waiveChargeOverDue(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    UserContext uc = (UserContext) SessionUtils.getAttribute(Constants.USERCONTEXT, request.getSession());
    Integer accountId = getIntegerValue(request.getParameter("accountId"));
    WaiveEnum waiveEnum = getWaiveType(request.getParameter(AccountConstants.WAIVE_TYPE));
    this.centerServiceFacade.waiveChargesOverDue(accountId, waiveEnum.ordinal());
    AccountBO account = getAccountBusinessService().getAccount(accountId);
    account.updateDetails(uc);
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, account, request);
    return mapping.findForward("waiveChargesOverDue_Success");
}
Also used : WaiveEnum(org.mifos.accounts.util.helpers.WaiveEnum) AccountBO(org.mifos.accounts.business.AccountBO) UserContext(org.mifos.security.util.UserContext) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 7 with WaiveEnum

use of org.mifos.accounts.util.helpers.WaiveEnum in project head by mifos.

the class AccountAppAction method waiveChargeDue.

@TransactionDemarcate(joinToken = true)
public ActionForward waiveChargeDue(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    UserContext uc = (UserContext) SessionUtils.getAttribute(Constants.USERCONTEXT, request.getSession());
    Integer accountId = getIntegerValue(request.getParameter("accountId"));
    WaiveEnum waiveEnum = getWaiveType(request.getParameter(AccountConstants.WAIVE_TYPE));
    this.centerServiceFacade.waiveChargesDue(accountId, waiveEnum.ordinal());
    AccountBO account = getAccountBusinessService().getAccount(accountId);
    account.updateDetails(uc);
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, account, request);
    return mapping.findForward("waiveChargesDue_Success");
}
Also used : WaiveEnum(org.mifos.accounts.util.helpers.WaiveEnum) AccountBO(org.mifos.accounts.business.AccountBO) UserContext(org.mifos.security.util.UserContext) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 8 with WaiveEnum

use of org.mifos.accounts.util.helpers.WaiveEnum 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)

Aggregations

WaiveEnum (org.mifos.accounts.util.helpers.WaiveEnum)8 Test (org.junit.Test)4 AccountBO (org.mifos.accounts.business.AccountBO)4 UserContext (org.mifos.security.util.UserContext)4 AccountBusinessService (org.mifos.accounts.business.service.AccountBusinessService)2 MifosRuntimeException (org.mifos.core.MifosRuntimeException)2 CustomerAccountBO (org.mifos.customers.business.CustomerAccountBO)2 ApplicationException (org.mifos.framework.exceptions.ApplicationException)2 ServiceException (org.mifos.framework.exceptions.ServiceException)2 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)2 MifosUser (org.mifos.security.MifosUser)2 BusinessRuleException (org.mifos.service.BusinessRuleException)2 AccountException (org.mifos.accounts.exceptions.AccountException)1 LoanBO (org.mifos.accounts.loan.business.LoanBO)1 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)1 CustomerException (org.mifos.customers.exceptions.CustomerException)1 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)1 PageExpiredException (org.mifos.framework.exceptions.PageExpiredException)1 StatesInitializationException (org.mifos.framework.exceptions.StatesInitializationException)1 SystemException (org.mifos.framework.exceptions.SystemException)1