Search in sources :

Example 1 with RequisitionDocument

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

the class CuRequisitionDocumentPresentationController method getEditModes.

public Set<String> getEditModes(Document document) {
    Set<String> editModes = super.getEditModes(document);
    RequisitionDocument reqDocument = (RequisitionDocument) document;
    WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
    if (workflowDocument.isEnroute()) {
        Set<String> nodeNames = workflowDocument.getNodeNames();
        for (Iterator<String> iterator = nodeNames.iterator(); iterator.hasNext(); ) {
            String nodeNamesNode = iterator.next();
            if (RequisitionStatuses.NODE_ACCOUNT.equals(nodeNamesNode)) {
                // KFSPTS-1792 : Should check whetehr object code is capital asset code ?
                editModes.add(CURequisitionEditMode.ENABLE_CAPITAL_ASSET);
            }
        }
        if (SpringContext.getBean(CuPurapAccountingService.class).isFiscalOfficersForAllAcctLines(reqDocument)) {
            editModes.remove(RequisitionEditMode.DISABLE_SETUP_ACCT_DISTRIBUTION);
            editModes.remove(RequisitionEditMode.DISABLE_REMOVE_ACCTS);
            editModes.add(RequisitionEditMode.ENABLE_COMMODITY_CODE);
        }
    }
    if (document instanceof RequisitionDocument && !editModes.contains(RequisitionEditMode.DISABLE_SETUP_ACCT_DISTRIBUTION) && !hasEmptyAcctline((RequisitionDocument) document)) {
        editModes.add(RequisitionEditMode.DISABLE_SETUP_ACCT_DISTRIBUTION);
    }
    return editModes;
}
Also used : RequisitionDocument(org.kuali.kfs.module.purap.document.RequisitionDocument) WorkflowDocument(org.kuali.rice.kew.api.WorkflowDocument) CuPurapAccountingService(edu.cornell.kfs.module.purap.service.CuPurapAccountingService)

Example 2 with RequisitionDocument

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

the class PurchasingActionBase method isAttachmentReqChanged.

/*
     * check if the 'send to vendor' flag is changed.  
     */
private boolean isAttachmentReqChanged(ActionForm form) {
    boolean ischanged = false;
    KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form;
    List<Note> savedNotes = getPersistedBoNotesNotes(kualiDocumentFormBase.getDocument());
    List<Note> boNotes = kualiDocumentFormBase.getDocument().getNotes();
    if (!(kualiDocumentFormBase.getDocument() instanceof RequisitionDocument)) {
        restoreSendToVendorFlag(boNotes, ((CuPurchaseOrderForm) kualiDocumentFormBase).getCopiedNotes());
    }
    boolean isChanged = false;
    for (Note savedNote : savedNotes) {
        for (Note note : boNotes) {
            if (note.getNoteIdentifier().equals(savedNote.getNoteIdentifier()) && !StringUtils.equals(note.getNoteTopicText(), savedNote.getNoteTopicText()) && (StringUtils.equalsIgnoreCase(note.getNoteTopicText(), CUPurapConstants.AttachemntToVendorIndicators.SEND_TO_VENDOR) || StringUtils.equalsIgnoreCase(savedNote.getNoteTopicText(), CUPurapConstants.AttachemntToVendorIndicators.SEND_TO_VENDOR))) {
                isChanged = true;
                break;
            }
        }
    }
    return isChanged;
}
Also used : RequisitionDocument(org.kuali.kfs.module.purap.document.RequisitionDocument) KualiDocumentFormBase(org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase) Note(org.kuali.kfs.krad.bo.Note)

Example 3 with RequisitionDocument

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

the class CuB2BPurchaseOrderSciquestServiceImpl method sendPurchaseOrder.

// end KFSUPGRADE-583
public String sendPurchaseOrder(PurchaseOrderDocument purchaseOrder) {
    /*
         * IMPORTANT DESIGN NOTE: We need the contract manager's name, phone number, and e-mail address. B2B orders that don't
         * qualify to become APO's will have contract managers on the PO, and the ones that DO become APO's will not. We decided to
         * always get the contract manager from the B2B contract associated with the order, and for B2B orders to ignore the
         * contract manager field on the PO. We pull the name and phone number from the contract manager table and get the e-mail
         * address from the user data.
         */
    // CU change for contract manager
    // non-catalog POs might not have a vendor contract, so we need to get the contract manager from the PO which will always be there
    ContractManager contractManager = null;
    if (!PurapConstants.RequisitionSources.B2B.equals(purchaseOrder.getRequisitionSourceCode())) {
        contractManager = purchaseOrder.getContractManager();
    } else {
        contractManager = purchaseOrder.getVendorContract().getContractManager();
    }
    String contractManagerEmail = getContractManagerEmail(contractManager);
    String vendorDuns = purchaseOrder.getVendorDetail().getVendorDunsNumber();
    RequisitionDocument r = requisitionService.getRequisitionById(purchaseOrder.getRequisitionIdentifier());
    WorkflowDocument reqWorkflowDoc = r.getDocumentHeader().getWorkflowDocument();
    String requisitionInitiatorPrincipalId = getRequisitionInitiatorPrincipal(reqWorkflowDoc.getInitiatorPrincipalId());
    if (LOG.isDebugEnabled()) {
        LOG.debug("sendPurchaseOrder(): b2bPurchaseOrderURL is " + getB2bPurchaseOrderURL());
    }
    if (!PurapConstants.RequisitionSources.B2B.equals(purchaseOrder.getRequisitionSourceCode())) {
        prepareNonB2BPurchaseOrderForTransmission(purchaseOrder);
    }
    String validateErrors = verifyCxmlPOData(purchaseOrder, requisitionInitiatorPrincipalId, getB2bPurchaseOrderPassword(), contractManager, contractManagerEmail, vendorDuns);
    if (!StringUtils.isEmpty(validateErrors)) {
        return validateErrors;
    }
    StringBuffer transmitErrors = new StringBuffer();
    try {
        LOG.debug("sendPurchaseOrder() Generating cxml");
        String cxml = getCxml(purchaseOrder, requisitionInitiatorPrincipalId, getB2bPurchaseOrderPassword(), contractManager, contractManagerEmail, vendorDuns, true);
        LOG.debug("sendPurchaseOrder() Sending cxml\n" + cxml);
        LOG.debug("sendPurchaseOrder() Sending cxml\n" + cxml);
        String responseCxml = b2bDao.sendPunchOutRequest(cxml, getB2bPurchaseOrderURL());
        LOG.info("b2bPurchaseOrderURL " + getB2bPurchaseOrderURL());
        LOG.info("sendPurchaseOrder(): Response cXML for po #" + purchaseOrder.getPurapDocumentIdentifier() + ":\n" + responseCxml);
        // allow PO to use old form, then POA use new form for testing
        if (!responseCxml.contains("Success") && responseCxml.contains("No custom field found") && responseCxml.contains("document configuration (DeliveryEmail)")) {
            String cxml1 = cxml.substring(0, cxml.indexOf("<CustomFieldValueSet label=\"Delivery Phone")) + cxml.substring(cxml.indexOf("</POHeader>"));
            LOG.info("sendPurchaseOrder() re-Sending cxml\n" + cxml1);
            responseCxml = b2bDao.sendPunchOutRequest(cxml1, getB2bPurchaseOrderURL());
            cxml = getCxml(purchaseOrder, requisitionInitiatorPrincipalId, getB2bPurchaseOrderPassword(), contractManager, contractManagerEmail, vendorDuns, false);
            LOG.debug("sendPurchaseOrder() re-Sending cxml\n" + cxml);
            responseCxml = b2bDao.sendPunchOutRequest(cxml, getB2bPurchaseOrderURL());
            LOG.info("re-sendPurchaseOrder(): Response cXML for po number " + purchaseOrder.getPurapDocumentIdentifier() + ":" + responseCxml);
        }
        PurchaseOrderResponse poResponse = B2BParserHelper.getInstance().parsePurchaseOrderResponse(responseCxml);
        String statusText = poResponse.getStatusText();
        if (LOG.isDebugEnabled()) {
            LOG.debug("sendPurchaseOrder(): statusText is " + statusText);
        }
        if (ObjectUtils.isNull(statusText) || (!"success".equalsIgnoreCase(statusText.trim()))) {
            LOG.error("sendPurchaseOrder(): PO cXML for po number " + purchaseOrder.getPurapDocumentIdentifier() + " failed sending to SciQuest:\n" + statusText);
            transmitErrors.append("Unable to send Purchase Order: " + statusText);
            // find any additional error messages that might have been sent
            List errorMessages = poResponse.getPOResponseErrorMessages();
            if (ObjectUtils.isNotNull(errorMessages) && !errorMessages.isEmpty()) {
                for (Iterator iter = errorMessages.iterator(); iter.hasNext(); ) {
                    String errorMessage = (String) iter.next();
                    if (ObjectUtils.isNotNull(errorMessage)) {
                        LOG.error("sendPurchaseOrder(): SciQuest error message for po number " + purchaseOrder.getPurapDocumentIdentifier() + ": " + errorMessage);
                        transmitErrors.append("Error sending Purchase Order: " + errorMessage);
                    }
                }
            }
        }
    } catch (B2BConnectionException e) {
        LOG.error("sendPurchaseOrder() Error connecting to b2b", e);
        transmitErrors.append("Connection to vendor failed.");
    } catch (CxmlParseError e) {
        LOG.error("sendPurchaseOrder() Error Parsing", e);
        transmitErrors.append("Unable to read cxml returned from vendor.");
    } catch (Throwable e) {
        LOG.error("sendPurchaseOrder() Unknown Error", e);
        transmitErrors.append("Unexpected error occurred while attempting to transmit Purchase Order.");
    }
    return transmitErrors.toString();
}
Also used : RequisitionDocument(org.kuali.kfs.module.purap.document.RequisitionDocument) ContractManager(org.kuali.kfs.vnd.businessobject.ContractManager) WorkflowDocument(org.kuali.rice.kew.api.WorkflowDocument) PurchaseOrderResponse(org.kuali.kfs.module.purap.util.cxml.PurchaseOrderResponse) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) B2BConnectionException(org.kuali.kfs.module.purap.exception.B2BConnectionException) CxmlParseError(org.kuali.kfs.module.purap.exception.CxmlParseError)

Example 4 with RequisitionDocument

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

the class CuPurchasingProcessVendorValidation method validateDataForMethodOfPOTransmissionExistsOnVendorAddress.

/**
 * This routine verifies that the data necessary for the Method of PO Transmission chosen on the REQ,
 * PO, or POA document exists on the document's VendorAddress record for the chosen Vendor.
 * If the required checks pass, true is returned.
 * If the required checks fail, false is returned.
 *
 * NOTE: This routine could not be used for the VendorAddress validation checks on the Vendor maintenance
 * document because the Method of PO Transmission value selectable on that document pertains to the specific
 * VendorAddress being maintained.  The method of PO transmission being used for this routine's validation
 * checks is the one that is present on the input parameter purchasing document (REQ, PO, or POA) and could
 * be different from the value of the same name that is on the VendorAddress.  It is ok if these two values
 * are different because the user could have changed it after the default was obtained via the lookup and
 * used to populate the REQ, PO, or POA value as long as the data required for the method of PO transmission
 * selected in that document exists on the VendorAddress record chosen on the REQ, PO, or POA.
 *
 * 	For KFSPTS-1458: This method was changed extensively to address new business rules.
 */
public boolean validateDataForMethodOfPOTransmissionExistsOnVendorAddress(Document document) {
    boolean dataExists = true;
    MessageMap errorMap = GlobalVariables.getMessageMap();
    errorMap.clearErrorPath();
    errorMap.addToErrorPath(PurapConstants.VENDOR_ERRORS);
    // for REQ, PO, and POA verify that data exists on form for method of PO transmission value selected
    if ((document instanceof RequisitionDocument) || (document instanceof PurchaseOrderDocument) || (document instanceof PurchaseOrderAmendmentDocument)) {
        PurchaseOrderTransmissionMethodDataRulesServiceImpl purchaseOrderTransmissionMethodDataRulesServiceImpl = SpringContext.getBean(PurchaseOrderTransmissionMethodDataRulesServiceImpl.class);
        PurchasingDocumentBase purapDocument = (PurchasingDocumentBase) document;
        String poTransMethodCode = purapDocument.getPurchaseOrderTransmissionMethodCode();
        if (poTransMethodCode != null && !StringUtils.isBlank(poTransMethodCode)) {
            if (poTransMethodCode.equals(PurapConstants.POTransmissionMethods.FAX)) {
                dataExists = purchaseOrderTransmissionMethodDataRulesServiceImpl.isFaxNumberValid(purapDocument.getVendorFaxNumber());
                if (!dataExists) {
                    errorMap.putError(VendorPropertyConstants.VENDOR_FAX_NUMBER, CUPurapKeyConstants.PURAP_MOPOT_REQUIRED_DATA_MISSING);
                }
            } else if (poTransMethodCode.equals(CUPurapConstants.POTransmissionMethods.EMAIL)) {
                dataExists = purchaseOrderTransmissionMethodDataRulesServiceImpl.isEmailAddressValid(purapDocument.getVendorEmailAddress());
                if (!dataExists) {
                    errorMap.putError("vendorEmailAddress", CUPurapKeyConstants.PURAP_MOPOT_REQUIRED_DATA_MISSING);
                }
            } else if (poTransMethodCode.equals(CUPurapConstants.POTransmissionMethods.MANUAL)) {
                dataExists = purchaseOrderTransmissionMethodDataRulesServiceImpl.isPostalAddressValid(purapDocument.getVendorLine1Address(), purapDocument.getVendorCityName(), purapDocument.getVendorStateCode(), purapDocument.getVendorPostalCode(), purapDocument.getVendorCountryCode());
                if (!dataExists) {
                    errorMap.putError(VendorPropertyConstants.VENDOR_ADDRESS_LINE_1, CUPurapKeyConstants.PURAP_MOPOT_REQUIRED_DATA_MISSING);
                }
            }
        }
    }
    return dataExists;
}
Also used : RequisitionDocument(org.kuali.kfs.module.purap.document.RequisitionDocument) PurchaseOrderAmendmentDocument(org.kuali.kfs.module.purap.document.PurchaseOrderAmendmentDocument) PurchaseOrderDocument(org.kuali.kfs.module.purap.document.PurchaseOrderDocument) PurchaseOrderTransmissionMethodDataRulesServiceImpl(edu.cornell.kfs.module.purap.document.service.impl.PurchaseOrderTransmissionMethodDataRulesServiceImpl) MessageMap(org.kuali.kfs.krad.util.MessageMap) PurchasingDocumentBase(org.kuali.kfs.module.purap.document.PurchasingDocumentBase)

Example 5 with RequisitionDocument

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

the class CuRequisitionServiceImplTest method testCheckAutomaticPurchaseOrderRules.

public void testCheckAutomaticPurchaseOrderRules() throws WorkflowException {
    RequisitionDocument requisitionDocument = RequisitionFixture.REQ_NON_B2B_CAP_ASSET_ITEM.createRequisition();
    String result = cuRequisitionServiceImpl.checkAutomaticPurchaseOrderRules(requisitionDocument);
    // validation for capital asset items was removed with customization so validation should not return anything
    assertEquals(KFSConstants.EMPTY_STRING, result);
}
Also used : RequisitionDocument(org.kuali.kfs.module.purap.document.RequisitionDocument)

Aggregations

RequisitionDocument (org.kuali.kfs.module.purap.document.RequisitionDocument)21 PurchaseOrderDocument (org.kuali.kfs.module.purap.document.PurchaseOrderDocument)6 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)6 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)4 PaymentRequestItem (org.kuali.kfs.module.purap.businessobject.PaymentRequestItem)3 PaymentRequestDocument (org.kuali.kfs.module.purap.document.PaymentRequestDocument)3 IWantDocument (edu.cornell.kfs.module.purap.document.IWantDocument)2 File (java.io.File)2 BigDecimal (java.math.BigDecimal)2 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 List (java.util.List)2 DocumentService (org.kuali.kfs.krad.service.DocumentService)2 ElectronicInvoiceLoad (org.kuali.kfs.module.purap.businessobject.ElectronicInvoiceLoad)2 PaymentRequestAccount (org.kuali.kfs.module.purap.businessobject.PaymentRequestAccount)2 RequisitionItem (org.kuali.kfs.module.purap.businessobject.RequisitionItem)2 WorkflowDocument (org.kuali.rice.kew.api.WorkflowDocument)2 CuPaymentRequestItemExtension (edu.cornell.kfs.module.purap.businessobject.CuPaymentRequestItemExtension)1 CuPaymentRequestDocument (edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument)1 CuRequisitionDocument (edu.cornell.kfs.module.purap.document.CuRequisitionDocument)1