Search in sources :

Example 1 with AttributedPreCalculateAccountsPayableEvent

use of org.kuali.kfs.module.purap.document.validation.event.AttributedPreCalculateAccountsPayableEvent in project cu-kfs by CU-CommunityApps.

the class CuPaymentRequestAction method approve.

@Override
public ActionForward approve(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    PaymentRequestDocument preq = ((PaymentRequestForm) form).getPaymentRequestDocument();
    SpringContext.getBean(PurapService.class).prorateForTradeInAndFullOrderDiscount(preq);
    // if tax is required but not yet calculated, return and prompt user to calculate
    if (requiresCalculateTax((PaymentRequestForm) form)) {
        GlobalVariables.getMessageMap().putError(KFSConstants.DOCUMENT_ERRORS, PurapKeyConstants.ERROR_APPROVE_REQUIRES_CALCULATE);
        return mapping.findForward(KFSConstants.MAPPING_BASIC);
    }
    // and thus system wouldn't know it's not re-calculated after tax data are changed
    if (SpringContext.getBean(KualiRuleService.class).applyRules(new AttributedPreCalculateAccountsPayableEvent(preq))) {
        ActionForward forward = super.approve(mapping, form, request, response);
        // TODO : this preqacctrevision is new.  need to validate with existing system to see if '0' is normal ?
        if (StringUtils.equals(preq.getApplicationDocumentStatus(), PaymentRequestStatuses.APPDOC_PAYMENT_METHOD_REVIEW) || StringUtils.equals(preq.getApplicationDocumentStatus(), PaymentRequestStatuses.APPDOC_AWAITING_TAX_REVIEW)) {
            SpringContext.getBean(PurapAccountRevisionService.class).savePaymentRequestAccountRevisions(preq.getItems(), preq.getPostingYearFromPendingGLEntries(), preq.getPostingPeriodCodeFromPendingGLEntries());
        }
        return forward;
    } else {
        // pre-calculation rules fail, go back to same page with error messages
        return mapping.findForward(KFSConstants.MAPPING_BASIC);
    }
}
Also used : KualiRuleService(org.kuali.kfs.krad.service.KualiRuleService) PurapAccountRevisionService(org.kuali.kfs.module.purap.service.PurapAccountRevisionService) PurapService(org.kuali.kfs.module.purap.document.service.PurapService) PaymentRequestForm(org.kuali.kfs.module.purap.document.web.struts.PaymentRequestForm) AttributedPreCalculateAccountsPayableEvent(org.kuali.kfs.module.purap.document.validation.event.AttributedPreCalculateAccountsPayableEvent) PaymentRequestDocument(org.kuali.kfs.module.purap.document.PaymentRequestDocument) ActionForward(org.apache.struts.action.ActionForward)

Aggregations

ActionForward (org.apache.struts.action.ActionForward)1 KualiRuleService (org.kuali.kfs.krad.service.KualiRuleService)1 PaymentRequestDocument (org.kuali.kfs.module.purap.document.PaymentRequestDocument)1 PurapService (org.kuali.kfs.module.purap.document.service.PurapService)1 AttributedPreCalculateAccountsPayableEvent (org.kuali.kfs.module.purap.document.validation.event.AttributedPreCalculateAccountsPayableEvent)1 PaymentRequestForm (org.kuali.kfs.module.purap.document.web.struts.PaymentRequestForm)1 PurapAccountRevisionService (org.kuali.kfs.module.purap.service.PurapAccountRevisionService)1