Search in sources :

Example 1 with CuVendorAddressExtension

use of edu.cornell.kfs.vnd.businessobject.CuVendorAddressExtension in project cu-kfs by CU-CommunityApps.

the class CuVendorRule method verifyPOTransmissionTypeAllowedForVendorType.

/**
 * Method verifies that only vendors of type purchase order have method of PO transmission set for their address type.
 */
private void verifyPOTransmissionTypeAllowedForVendorType(String vendorTypeCode, List<VendorAddress> addresses) {
    // Check that there is at least one PO Address Type specified when the Vendor Type is PO
    if ((!StringUtils.isBlank(vendorTypeCode)) && StringUtils.equals(vendorTypeCode, KFSConstants.FinancialDocumentTypeCodes.PURCHASE_ORDER)) {
        boolean poAddressExistsForPOVendor = false;
        int i = 0;
        while ((i < addresses.size()) && !poAddressExistsForPOVendor) {
            VendorAddress address = addresses.get(i);
            if ((!StringUtils.isBlank(address.getVendorAddressTypeCode())) && (StringUtils.equals(address.getVendorAddressTypeCode(), KFSConstants.FinancialDocumentTypeCodes.PURCHASE_ORDER))) {
                poAddressExistsForPOVendor = true;
            }
            i++;
        }
        if (!poAddressExistsForPOVendor) {
            // display error message
            putFieldError(VendorPropertyConstants.VENDOR_TYPE_CODE, CUVendorKeyConstants.ERROR_PO_TRANSMISSION_REQUIRES_PO_ADDRESS);
        }
    }
    // Check that there are no PO Transmission Method values set when the Vendor Type is not PO
    if ((!StringUtils.isBlank(vendorTypeCode)) && (!StringUtils.equals(vendorTypeCode, KFSConstants.FinancialDocumentTypeCodes.PURCHASE_ORDER))) {
        boolean poTransmissionMethodExistsForVendor = false;
        int i = 0;
        while ((i < addresses.size()) && !poTransmissionMethodExistsForVendor) {
            VendorAddress address = addresses.get(i);
            if ((!StringUtils.isBlank(((CuVendorAddressExtension) address.getExtension()).getPurchaseOrderTransmissionMethodCode())) && (!StringUtils.equals(((CuVendorAddressExtension) address.getExtension()).getPurchaseOrderTransmissionMethodCode(), KFSConstants.FinancialDocumentTypeCodes.PURCHASE_ORDER))) {
                poTransmissionMethodExistsForVendor = true;
            }
            i++;
        }
        if (poTransmissionMethodExistsForVendor) {
            // display error message
            putFieldError(VendorPropertyConstants.VENDOR_TYPE_CODE, CUVendorKeyConstants.ERROR_PO_TRANMSISSION_NOT_ALLOWED_FOR_VENDOR_TYPE);
        }
    }
}
Also used : CuVendorAddressExtension(edu.cornell.kfs.vnd.businessobject.CuVendorAddressExtension) VendorAddress(org.kuali.kfs.vnd.businessobject.VendorAddress)

Example 2 with CuVendorAddressExtension

use of edu.cornell.kfs.vnd.businessobject.CuVendorAddressExtension in project cu-kfs by CU-CommunityApps.

the class CuVendorMaintainableImpl method populateGeneratedAddressId.

private void populateGeneratedAddressId(VendorDetail vendorDetail) {
    if (CollectionUtils.isNotEmpty(vendorDetail.getVendorAddresses())) {
        for (VendorAddress vendorAddress : vendorDetail.getVendorAddresses()) {
            if (vendorAddress.getVendorAddressGeneratedIdentifier() == null) {
                Integer generatedHeaderId = SpringContext.getBean(SequenceAccessorService.class).getNextAvailableSequenceNumber(ADDRESS_HEADER_ID_SEQ).intValue();
                vendorAddress.setVendorAddressGeneratedIdentifier(generatedHeaderId);
                ((CuVendorAddressExtension) vendorAddress.getExtension()).setVendorAddressGeneratedIdentifier(generatedHeaderId);
            }
        }
    }
}
Also used : CuVendorAddressExtension(edu.cornell.kfs.vnd.businessobject.CuVendorAddressExtension) VendorAddress(org.kuali.kfs.vnd.businessobject.VendorAddress)

Example 3 with CuVendorAddressExtension

use of edu.cornell.kfs.vnd.businessobject.CuVendorAddressExtension in project cu-kfs by CU-CommunityApps.

the class CuVendorRule method validateVendorAddressForMethodOfPOTransmission.

/**
 * This routine verifies that the data necessary for the Method of PO Transmission chosen exists and that data
 * is in the proper format on the VendorAddress section of the Vendor maintenance document.
 * If the data does not exist or is not in the proper format, the field(s) in question on that maintenance
 * document is/are noted as being in error.
 *
 * NOTE: This method call the same rule checks (PurchaseOrderTransmissionMethodDataRulesService)
 * for each data element on this maintenance document as the REQ, PO, and POA.
 */
private boolean validateVendorAddressForMethodOfPOTransmission(VendorAddress address, String propertyScope) {
    boolean valid = true;
    String propertyName;
    String[] parameters;
    String transmissionMethod = ((CuVendorAddressExtension) address.getExtension()).getPurchaseOrderTransmissionMethodCode();
    String addressTypeCode = address.getVendorAddressTypeCode();
    PurchaseOrderTransmissionMethodDataRulesService purchaseOrderTransmissionMethodDataRulesService = SpringContext.getBean(PurchaseOrderTransmissionMethodDataRulesService.class);
    if ((transmissionMethod == null) || (StringUtils.isBlank(transmissionMethod))) {
    // no-op, nothing to verify, default return value is valid
    } else if ((StringUtils.isBlank(addressTypeCode)) || (transmissionMethod.equalsIgnoreCase(CUPurapConstants.POTransmissionMethods.CONVERSION))) {
    // no-op, nothing to verify, default return value is valid
    } else if (transmissionMethod.equalsIgnoreCase(PurapConstants.POTransmissionMethods.FAX)) {
        // requires fax number is entered in format (xxx-xxx-xxxx)
        if (!purchaseOrderTransmissionMethodDataRulesService.isFaxNumberValid(address.getVendorFaxNumber())) {
            propertyName = new String(propertyScope + VendorPropertyConstants.VENDOR_FAX_NUMBER);
            putFieldError(propertyName, CUVendorKeyConstants.ERROR_PO_TRANSMISSION_REQUIRES_FAX_NUMBER);
            valid &= false;
        }
    } else if (transmissionMethod.equalsIgnoreCase(CUPurapConstants.POTransmissionMethods.EMAIL)) {
        // requires an email address is entered
        if (!purchaseOrderTransmissionMethodDataRulesService.isEmailAddressValid(address.getVendorAddressEmailAddress())) {
            propertyName = new String(propertyScope + CUVendorPropertyConstants.VENDOR_ADDRESS_EMAIL_ADDRESS);
            putFieldError(propertyName, CUVendorKeyConstants.ERROR_PO_TRANSMISSION_REQUIRES_EMAIL);
            valid &= false;
        }
    } else if (transmissionMethod.equalsIgnoreCase(CUPurapConstants.POTransmissionMethods.MANUAL)) {
        // has all the required data been entered?
        if (!purchaseOrderTransmissionMethodDataRulesService.isCountryCodeValid(address.getVendorCountryCode())) {
            propertyName = new String(propertyScope + VendorPropertyConstants.VENDOR_ADDRESS_COUNTRY);
            putFieldError(propertyName, CUVendorKeyConstants.ERROR_PO_TRANSMISSION_REQUIRES_US_POSTAL);
            valid &= false;
        }
        if (!purchaseOrderTransmissionMethodDataRulesService.isStateCodeValid(address.getVendorStateCode())) {
            propertyName = new String(propertyScope + VendorPropertyConstants.VENDOR_ADDRESS_STATE_CODE);
            putFieldError(propertyName, CUVendorKeyConstants.ERROR_PO_TRANSMISSION_REQUIRES_US_POSTAL);
            valid &= false;
        }
        if (!purchaseOrderTransmissionMethodDataRulesService.isZipCodeValid(address.getVendorZipCode())) {
            propertyName = new String(propertyScope + VendorPropertyConstants.VENDOR_ADDRESS_ZIP);
            putFieldError(propertyName, CUVendorKeyConstants.ERROR_PO_TRANSMISSION_REQUIRES_US_POSTAL);
            valid &= false;
        }
        if (!purchaseOrderTransmissionMethodDataRulesService.isAddress1Valid(address.getVendorLine1Address())) {
            propertyName = new String(propertyScope + VendorPropertyConstants.VENDOR_ADDRESS_LINE_1);
            putFieldError(propertyName, CUVendorKeyConstants.ERROR_PO_TRANSMISSION_REQUIRES_US_POSTAL);
            valid &= false;
        }
        if (!purchaseOrderTransmissionMethodDataRulesService.isCityValid(address.getVendorCityName())) {
            propertyName = new String(propertyScope + VendorPropertyConstants.VENDOR_ADDRESS_CITY);
            putFieldError(propertyName, CUVendorKeyConstants.ERROR_PO_TRANSMISSION_REQUIRES_US_POSTAL);
            valid &= false;
        }
        if (valid) {
            // user entered all the data, now verify relationships in the data
            // verify US, state and zip are valid as they are related to each other, error message taken care of in called routine
            valid &= SpringContext.getBean(PostalCodeValidationService.class).validateAddress(address.getVendorCountryCode(), address.getVendorStateCode(), address.getVendorZipCode(), propertyScope + VendorPropertyConstants.VENDOR_ADDRESS_STATE, propertyScope + VendorPropertyConstants.VENDOR_ADDRESS_ZIP);
        }
    } else {
        // Method of PO Transmission maintenance table has a value that is not coded for processing
        parameters = new String[] { transmissionMethod };
        propertyName = new String(propertyScope + CUVendorPropertyConstants.VENDOR_ADDRESS_METHOD_OF_PO_TRANSMISSION);
        putFieldError(propertyName, CUVendorKeyConstants.ERROR_PO_TRANSMISSION_METHOD_UNKNOWN, parameters);
        valid &= false;
    }
    return valid;
}
Also used : CuVendorAddressExtension(edu.cornell.kfs.vnd.businessobject.CuVendorAddressExtension) PurchaseOrderTransmissionMethodDataRulesService(edu.cornell.kfs.module.purap.document.service.PurchaseOrderTransmissionMethodDataRulesService)

Aggregations

CuVendorAddressExtension (edu.cornell.kfs.vnd.businessobject.CuVendorAddressExtension)3 VendorAddress (org.kuali.kfs.vnd.businessobject.VendorAddress)2 PurchaseOrderTransmissionMethodDataRulesService (edu.cornell.kfs.module.purap.document.service.PurchaseOrderTransmissionMethodDataRulesService)1