Search in sources :

Example 31 with PaymentRequestDocument

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

the class CuAccountsPayableBankCodeValidation method validate.

@Override
public boolean validate(AttributedDocumentEvent event) {
    AccountsPayableDocumentBase apDocument = (AccountsPayableDocumentBase) getAccountingDocumentForValidation();
    // check if one of the extended UA documents, if so, take the payment method into account, otherwise, revert to baseline behavior
    boolean isValid = true;
    if (apDocument instanceof PaymentRequestDocument) {
        if (StringUtils.isNotBlank(apDocument.getBankCode())) {
            // PREQ bank code is not required
            isValid = CuBankCodeValidation.validate(apDocument.getBankCode(), "document." + PurapPropertyConstants.BANK_CODE, ((CuPaymentRequestDocument) apDocument).getPaymentMethodCode(), false, true);
            if (isValid) {
                if (!(event instanceof AttributedRouteDocumentEvent) && StringUtils.isNotBlank(apDocument.getBankCode()) && !CuBankCodeValidation.doesBankCodeNeedToBePopulated(((CuPaymentRequestDocument) apDocument).getPaymentMethodCode())) {
                    apDocument.setBank(null);
                    apDocument.setBankCode(null);
                }
            }
        }
    } else if (apDocument instanceof VendorCreditMemoDocument) {
        if (StringUtils.isNotBlank(apDocument.getBankCode())) {
            isValid = CuBankCodeValidation.validate(apDocument.getBankCode(), "document." + PurapPropertyConstants.BANK_CODE, ((CuVendorCreditMemoDocument) apDocument).getPaymentMethodCode(), false, true);
            if (isValid) {
                // clear out the bank code on the document if not needed (per the message set by the call above)
                if (StringUtils.isNotBlank(apDocument.getBankCode()) && !CuBankCodeValidation.doesBankCodeNeedToBePopulated(((CuVendorCreditMemoDocument) apDocument).getPaymentMethodCode())) {
                    apDocument.setBank(null);
                    apDocument.setBankCode(null);
                }
            }
        }
    } else {
        isValid = CuBankCodeValidation.validate(apDocument.getBankCode(), "document." + PurapPropertyConstants.BANK_CODE, false, true);
    }
    return isValid;
}
Also used : AccountsPayableDocumentBase(org.kuali.kfs.module.purap.document.AccountsPayableDocumentBase) CuVendorCreditMemoDocument(edu.cornell.kfs.module.purap.document.CuVendorCreditMemoDocument) VendorCreditMemoDocument(org.kuali.kfs.module.purap.document.VendorCreditMemoDocument) AttributedRouteDocumentEvent(org.kuali.kfs.sys.document.validation.event.AttributedRouteDocumentEvent) CuVendorCreditMemoDocument(edu.cornell.kfs.module.purap.document.CuVendorCreditMemoDocument) CuPaymentRequestDocument(edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument) PaymentRequestDocument(org.kuali.kfs.module.purap.document.PaymentRequestDocument) CuPaymentRequestDocument(edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument)

Example 32 with PaymentRequestDocument

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

the class CuLineItemQuantityNotZero method validate.

public boolean validate(AttributedDocumentEvent event) {
    boolean valid = true;
    PaymentRequestDocument document = (PaymentRequestDocument) event.getDocument();
    GlobalVariables.getMessageMap().clearErrorPath();
    GlobalVariables.getMessageMap().addToErrorPath(KFSPropertyConstants.DOCUMENT);
    int i = 0;
    for (PurApItem item : (List<PurApItem>) document.getItems()) {
        KualiDecimal itemQuantity = item.getItemQuantity();
        if (!((PaymentRequestItem) item).isNoQtyItem() && itemQuantity != null) {
            if (!itemQuantity.isNonZero()) {
                GlobalVariables.getMessageMap().putError("item[" + i + "].itemQuantity", PurapKeyConstants.ERROR_PAYMENT_REQUEST_LINE_ITEM_QUANTITY_ZERO);
                GlobalVariables.getMessageMap().clearErrorPath();
                valid = false;
                break;
            }
            i++;
        }
    }
    return valid;
}
Also used : PaymentRequestItem(org.kuali.kfs.module.purap.businessobject.PaymentRequestItem) PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) PaymentRequestDocument(org.kuali.kfs.module.purap.document.PaymentRequestDocument) List(java.util.List)

Example 33 with PaymentRequestDocument

use of org.kuali.kfs.module.purap.document.PaymentRequestDocument 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)

Example 34 with PaymentRequestDocument

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

the class CuPaymentRequestForm method getExtraButtons.

@Override
public List<ExtraButton> getExtraButtons() {
    super.getExtraButtons();
    PaymentRequestDocument paymentRequestDocument = this.getPaymentRequestDocument();
    if (StringUtils.equalsIgnoreCase(paymentRequestDocument.getFinancialSystemDocumentHeader().getApplicationDocumentStatus(), PaymentRequestStatuses.APPDOC_DEPARTMENT_APPROVED) && paymentRequestDocument.getFinancialSystemDocumentHeader().getWorkflowDocument().isFinal() && !SpringContext.getBean(CUPaymentMethodGeneralLedgerPendingEntryService.class).isPaymentMethodProcessedUsingPdp(((CuPaymentRequestDocument) paymentRequestDocument).getPaymentMethodCode())) {
        ExtraButton cancelButton = null;
        for (ExtraButton extraButton : extraButtons) {
            if (StringUtils.equals("methodToCall.cancel", extraButton.getExtraButtonProperty())) {
                cancelButton = extraButton;
            }
        }
        if (ObjectUtils.isNotNull(cancelButton)) {
            extraButtons.remove(cancelButton);
        }
    }
    return extraButtons;
}
Also used : CUPaymentMethodGeneralLedgerPendingEntryService(edu.cornell.kfs.fp.service.CUPaymentMethodGeneralLedgerPendingEntryService) PaymentRequestDocument(org.kuali.kfs.module.purap.document.PaymentRequestDocument) CuPaymentRequestDocument(edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument) ExtraButton(org.kuali.kfs.kns.web.ui.ExtraButton)

Example 35 with PaymentRequestDocument

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

the class CuPurchasingAccountsPayableObjectCodeOverrideBranchingValidation method determineBranch.

@Override
protected String determineBranch(AttributedDocumentEvent event) {
    if (!StringUtils.isBlank(propertyPath)) {
        refreshByPath(accountingLineForValidation);
    }
    boolean isTaxApproval = false;
    // KFSPTS-1891 : treasury manager also skip this object type allowed check
    boolean isTreasuryApproval = false;
    // or if this accounting line is from a Tax Charge line.
    if (accountingDocumentForValidation instanceof PaymentRequestDocument) {
        PaymentRequestDocument preq = (PaymentRequestDocument) accountingDocumentForValidation;
        PurApAccountingLine purapAccountingLine = (PurApAccountingLine) accountingLineForValidation;
        PurApItem item = purapAccountingLine.getPurapItem();
        if (StringUtils.equals(PaymentRequestStatuses.APPDOC_AWAITING_TAX_REVIEW, preq.getApplicationDocumentStatus())) {
            isTaxApproval = true;
        } else if (StringUtils.equals(PaymentRequestStatuses.APPDOC_PAYMENT_METHOD_REVIEW, preq.getApplicationDocumentStatus())) {
            isTreasuryApproval = true;
        } else if (StringUtils.equals(PaymentRequestStatuses.APPDOC_DEPARTMENT_APPROVED, preq.getApplicationDocumentStatus()) && (ObjectUtils.isNotNull(item) && item.getItemType().getIsTaxCharge())) {
            isTaxApproval = true;
        }
    }
    if (isTaxApproval || isTreasuryApproval) {
        return null;
    } else if (isAccountingLineValueAllowed(accountingDocumentForValidation.getClass(), accountingLineForValidation, parameterToCheckAgainst, propertyPath, (responsibleProperty != null ? responsibleProperty : propertyPath))) {
        return OBJECT_CODE_OVERRIDEN;
    } else {
        return OBJECT_CODE_NOT_OVERRIDEN;
    }
}
Also used : PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) PurApAccountingLine(org.kuali.kfs.module.purap.businessobject.PurApAccountingLine) PaymentRequestDocument(org.kuali.kfs.module.purap.document.PaymentRequestDocument)

Aggregations

PaymentRequestDocument (org.kuali.kfs.module.purap.document.PaymentRequestDocument)36 CuPaymentRequestDocument (edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument)21 PurchaseOrderDocument (org.kuali.kfs.module.purap.document.PurchaseOrderDocument)15 DocumentService (org.kuali.kfs.krad.service.DocumentService)12 PaymentRequestItem (org.kuali.kfs.module.purap.businessobject.PaymentRequestItem)6 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)5 VendorCreditMemoDocument (org.kuali.kfs.module.purap.document.VendorCreditMemoDocument)4 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)4 RemoteException (java.rmi.RemoteException)3 KualiRuleService (org.kuali.kfs.krad.service.KualiRuleService)3 PurApItem (org.kuali.kfs.module.purap.businessobject.PurApItem)3 PaymentRequestService (org.kuali.kfs.module.purap.document.service.PaymentRequestService)3 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 BigDecimal (java.math.BigDecimal)2 HashMap (java.util.HashMap)2 ActionForward (org.apache.struts.action.ActionForward)2 ValidationException (org.kuali.kfs.krad.exception.ValidationException)2 MessageMap (org.kuali.kfs.krad.util.MessageMap)2 WorkflowDocumentService (org.kuali.kfs.krad.workflow.service.WorkflowDocumentService)2