Search in sources :

Example 1 with PurchaseOrderTransmissionMethodDataRulesServiceImpl

use of edu.cornell.kfs.module.purap.document.service.impl.PurchaseOrderTransmissionMethodDataRulesServiceImpl 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)

Aggregations

PurchaseOrderTransmissionMethodDataRulesServiceImpl (edu.cornell.kfs.module.purap.document.service.impl.PurchaseOrderTransmissionMethodDataRulesServiceImpl)1 MessageMap (org.kuali.kfs.krad.util.MessageMap)1 PurchaseOrderAmendmentDocument (org.kuali.kfs.module.purap.document.PurchaseOrderAmendmentDocument)1 PurchaseOrderDocument (org.kuali.kfs.module.purap.document.PurchaseOrderDocument)1 PurchasingDocumentBase (org.kuali.kfs.module.purap.document.PurchasingDocumentBase)1 RequisitionDocument (org.kuali.kfs.module.purap.document.RequisitionDocument)1