Search in sources :

Example 1 with PaymentRequestForm

use of org.kuali.kfs.module.purap.document.web.struts.PaymentRequestForm in project cu-kfs by CU-CommunityApps.

the class CuPaymentRequestAction method clearTaxInfo.

/**
 * Calls service to clear tax info.
 */
public ActionForward clearTaxInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    PaymentRequestForm prForm = (PaymentRequestForm) form;
    PaymentRequestDocument document = (PaymentRequestDocument) prForm.getDocument();
    PaymentRequestService taxService = SpringContext.getBean(PaymentRequestService.class);
    /* call service to clear previous lines */
    taxService.clearTax(document);
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : PaymentRequestForm(org.kuali.kfs.module.purap.document.web.struts.PaymentRequestForm) PaymentRequestService(org.kuali.kfs.module.purap.document.service.PaymentRequestService) PaymentRequestDocument(org.kuali.kfs.module.purap.document.PaymentRequestDocument)

Example 2 with PaymentRequestForm

use of org.kuali.kfs.module.purap.document.web.struts.PaymentRequestForm in project cu-kfs by CU-CommunityApps.

the class CuPaymentRequestAction method docHandler.

@Override
public ActionForward docHandler(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    ActionForward forward = super.docHandler(mapping, form, request, response);
    PaymentRequestForm preqForm = (PaymentRequestForm) form;
    PaymentRequestDocument document = (PaymentRequestDocument) preqForm.getDocument();
    if (CollectionUtils.isNotEmpty(document.getItems())) {
        Collections.sort(document.getItems(), new Comparator() {

            public int compare(Object o1, Object o2) {
                PaymentRequestItem item1 = (PaymentRequestItem) o1;
                PaymentRequestItem item2 = (PaymentRequestItem) o2;
                Integer inv1 = ((CuPaymentRequestItemExtension) item1.getExtension()).getInvLineNumber();
                Integer inv2 = ((CuPaymentRequestItemExtension) item2.getExtension()).getInvLineNumber();
                if (inv1 == null) {
                    if (inv2 == null) {
                        return -1;
                    } else {
                        return 1;
                    }
                } else {
                    if (inv2 == null) {
                        return -1;
                    } else {
                        return inv1.compareTo(inv2);
                    }
                }
            }
        });
    }
    return forward;
}
Also used : PaymentRequestForm(org.kuali.kfs.module.purap.document.web.struts.PaymentRequestForm) PaymentRequestItem(org.kuali.kfs.module.purap.businessobject.PaymentRequestItem) PaymentRequestDocument(org.kuali.kfs.module.purap.document.PaymentRequestDocument) ActionForward(org.apache.struts.action.ActionForward) Comparator(java.util.Comparator)

Example 3 with PaymentRequestForm

use of org.kuali.kfs.module.purap.document.web.struts.PaymentRequestForm 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

PaymentRequestDocument (org.kuali.kfs.module.purap.document.PaymentRequestDocument)3 PaymentRequestForm (org.kuali.kfs.module.purap.document.web.struts.PaymentRequestForm)3 ActionForward (org.apache.struts.action.ActionForward)2 Comparator (java.util.Comparator)1 KualiRuleService (org.kuali.kfs.krad.service.KualiRuleService)1 PaymentRequestItem (org.kuali.kfs.module.purap.businessobject.PaymentRequestItem)1 PaymentRequestService (org.kuali.kfs.module.purap.document.service.PaymentRequestService)1 PurapService (org.kuali.kfs.module.purap.document.service.PurapService)1 AttributedPreCalculateAccountsPayableEvent (org.kuali.kfs.module.purap.document.validation.event.AttributedPreCalculateAccountsPayableEvent)1 PurapAccountRevisionService (org.kuali.kfs.module.purap.service.PurapAccountRevisionService)1