Search in sources :

Example 1 with CustomerApplyAdjustmentActionForm

use of org.mifos.customers.struts.actionforms.CustomerApplyAdjustmentActionForm in project head by mifos.

the class CustomerApplyAdjustmentAction method applyAdjustment.

@TransactionDemarcate(validateAndResetToken = true)
@CloseSession
public ActionForward applyAdjustment(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    String forward = null;
    request.setAttribute(CustomerConstants.METHOD, CustomerConstants.METHOD_APPLY_ADJUSTMENT);
    CustomerApplyAdjustmentActionForm applyAdjustmentActionForm = (CustomerApplyAdjustmentActionForm) form;
    String globalCustNum = applyAdjustmentActionForm.getGlobalCustNum();
    CustomerBO customerBO = this.customerDao.findCustomerBySystemId(globalCustNum);
    SessionUtils.removeAttribute(Constants.BUSINESS_KEY, request);
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, customerBO, request);
    if (null == customerBO.getCustomerAccount().findMostRecentNonzeroPaymentByPaymentDate()) {
        request.setAttribute(CustomerConstants.METHOD, CustomerConstants.METHOD_PREVIEW_ADJUSTMENT);
        throw new ApplicationException(AccountExceptionConstants.ZEROAMNTADJUSTMENT);
    }
    try {
        this.centerServiceFacade.revertLastChargesPayment(globalCustNum, applyAdjustmentActionForm.getAdjustmentNote());
    } catch (BusinessRuleException e) {
        request.setAttribute(CustomerConstants.METHOD, CustomerConstants.METHOD_PREVIEW_ADJUSTMENT);
        throw e;
    }
    String inputPage = applyAdjustmentActionForm.getInput();
    resetActionFormFields(applyAdjustmentActionForm);
    if (inputPage != null) {
        if (inputPage.equals(CustomerConstants.VIEW_GROUP_CHARGES)) {
            forward = CustomerConstants.APPLY_ADJUSTMENT_GROUP_SUCCESS;
        } else if (inputPage.equals(CustomerConstants.VIEW_CENTER_CHARGES)) {
            forward = CustomerConstants.APPLY_ADJUSTMENT_CENTER_SUCCESS;
        } else if (inputPage.equals(CustomerConstants.VIEW_CLIENT_CHARGES)) {
            forward = CustomerConstants.APPLY_ADJUSTMENT_CLIENT_SUCCESS;
        }
    }
    return mapping.findForward(forward);
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) CustomerBO(org.mifos.customers.business.CustomerBO) CustomerApplyAdjustmentActionForm(org.mifos.customers.struts.actionforms.CustomerApplyAdjustmentActionForm) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 2 with CustomerApplyAdjustmentActionForm

use of org.mifos.customers.struts.actionforms.CustomerApplyAdjustmentActionForm in project head by mifos.

the class CustomerApplyAdjustmentAction method loadAdjustment.

@TransactionDemarcate(joinToken = true)
public ActionForward loadAdjustment(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    CustomerApplyAdjustmentActionForm applyAdjustmentActionForm = (CustomerApplyAdjustmentActionForm) form;
    resetActionFormFields(applyAdjustmentActionForm);
    String globalCustNum = applyAdjustmentActionForm.getGlobalCustNum();
    CustomerBO customerBO = this.customerDao.findCustomerBySystemId(globalCustNum);
    SessionUtils.removeAttribute(Constants.BUSINESS_KEY, request);
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, customerBO, request);
    request.setAttribute(CustomerConstants.METHOD, CustomerConstants.METHOD_LOAD_ADJUSTMENT);
    if (null == customerBO.getCustomerAccount().findMostRecentNonzeroPaymentByPaymentDate()) {
        request.setAttribute("isDisabled", "true");
        throw new ApplicationException(AccountExceptionConstants.ZEROAMNTADJUSTMENT);
    }
    return mapping.findForward(CustomerConstants.METHOD_LOAD_ADJUSTMENT_SUCCESS);
}
Also used : ApplicationException(org.mifos.framework.exceptions.ApplicationException) CustomerBO(org.mifos.customers.business.CustomerBO) CustomerApplyAdjustmentActionForm(org.mifos.customers.struts.actionforms.CustomerApplyAdjustmentActionForm) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 3 with CustomerApplyAdjustmentActionForm

use of org.mifos.customers.struts.actionforms.CustomerApplyAdjustmentActionForm in project head by mifos.

the class CustomerApplyAdjustmentAction method cancelAdjustment.

@TransactionDemarcate(validateAndResetToken = true)
public ActionForward cancelAdjustment(ActionMapping mapping, ActionForm form, @SuppressWarnings("unused") HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    String forward = null;
    CustomerApplyAdjustmentActionForm applyAdjustmentActionForm = (CustomerApplyAdjustmentActionForm) form;
    String inputPage = applyAdjustmentActionForm.getInput();
    resetActionFormFields(applyAdjustmentActionForm);
    if (inputPage != null) {
        if (inputPage.equals(CustomerConstants.VIEW_GROUP_CHARGES)) {
            forward = CustomerConstants.CANCELADJ_GROUP_SUCCESS;
        } else if (inputPage.equals(CustomerConstants.VIEW_CENTER_CHARGES)) {
            forward = CustomerConstants.CANCELADJ_CENTER_SUCCESS;
        } else if (inputPage.equals(CustomerConstants.VIEW_CLIENT_CHARGES)) {
            forward = CustomerConstants.CANCELADJ_CLIENT_SUCCESS;
        }
    }
    return mapping.findForward(forward);
}
Also used : CustomerApplyAdjustmentActionForm(org.mifos.customers.struts.actionforms.CustomerApplyAdjustmentActionForm) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 4 with CustomerApplyAdjustmentActionForm

use of org.mifos.customers.struts.actionforms.CustomerApplyAdjustmentActionForm in project head by mifos.

the class CustomerApplyAdjustmentAction method previewAdjustment.

@TransactionDemarcate(joinToken = true)
public ActionForward previewAdjustment(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    request.setAttribute(CustomerConstants.METHOD, CustomerConstants.METHOD_PREVIEW_ADJUSTMENT);
    CustomerApplyAdjustmentActionForm applyAdjustmentActionForm = (CustomerApplyAdjustmentActionForm) form;
    String globalCustNum = applyAdjustmentActionForm.getGlobalCustNum();
    CustomerBO customerBO = this.customerDao.findCustomerBySystemId(globalCustNum);
    SessionUtils.removeAttribute(Constants.BUSINESS_KEY, request);
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, customerBO, request);
    if (null == customerBO.getCustomerAccount().findMostRecentNonzeroPaymentByPaymentDate()) {
        request.setAttribute(CustomerConstants.METHOD, CustomerConstants.METHOD_LOAD_ADJUSTMENT);
        request.setAttribute("isDisabled", "true");
        throw new ApplicationException(AccountExceptionConstants.ZEROAMNTADJUSTMENT);
    }
    return mapping.findForward(CustomerConstants.METHOD_PREVIEW_ADJUSTMENT_SUCCESS);
}
Also used : ApplicationException(org.mifos.framework.exceptions.ApplicationException) CustomerBO(org.mifos.customers.business.CustomerBO) CustomerApplyAdjustmentActionForm(org.mifos.customers.struts.actionforms.CustomerApplyAdjustmentActionForm) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

CustomerApplyAdjustmentActionForm (org.mifos.customers.struts.actionforms.CustomerApplyAdjustmentActionForm)4 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)4 CustomerBO (org.mifos.customers.business.CustomerBO)3 ApplicationException (org.mifos.framework.exceptions.ApplicationException)3 CloseSession (org.mifos.framework.util.helpers.CloseSession)1 BusinessRuleException (org.mifos.service.BusinessRuleException)1