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);
}
}
Aggregations