Search in sources :

Example 11 with VendorHeader

use of org.kuali.kfs.vnd.businessobject.VendorHeader in project cu-kfs by CU-CommunityApps.

the class CuPurchasingProcessVendorValidation method validate.

@Override
public boolean validate(AttributedDocumentEvent event) {
    boolean valid = true;
    PurchasingDocument purDocument = (PurchasingDocument) event.getDocument();
    MessageMap errorMap = GlobalVariables.getMessageMap();
    errorMap.clearErrorPath();
    errorMap.addToErrorPath(PurapConstants.VENDOR_ERRORS);
    if (!purDocument.getRequisitionSourceCode().equals(PurapConstants.RequisitionSources.B2B)) {
        // CU enhancement here. Replaced foundation implementation block
        if ((purDocument.getVendorHeaderGeneratedIdentifier() != null) && (!(isDocumentInNodeWhereMopotDataValidationIsBypassed(purDocument))) && (purDocument.getPurchaseOrderTransmissionMethodCode().equals(CUPurapConstants.POTransmissionMethods.EMAIL) || purDocument.getPurchaseOrderTransmissionMethodCode().equals(PurapConstants.POTransmissionMethods.FAX) || purDocument.getPurchaseOrderTransmissionMethodCode().equals(CUPurapConstants.POTransmissionMethods.MANUAL))) {
            valid &= this.validateDataForMethodOfPOTransmissionExistsOnVendorAddress(purDocument);
        // called routine took care of presenting error message to user
        }
    }
    VendorDetail vendorDetail = getVendorService().getVendorDetail(purDocument.getVendorHeaderGeneratedIdentifier(), purDocument.getVendorDetailAssignedIdentifier());
    if (ObjectUtils.isNull(vendorDetail)) {
        return valid;
    }
    VendorHeader vendorHeader = vendorDetail.getVendorHeader();
    // make sure that the vendor is not debarred
    if (vendorDetail.isVendorDebarred()) {
        if (getParameterService().getParameterValueAsBoolean(KFSConstants.OptionalModuleNamespaces.PURCHASING_ACCOUNTS_PAYABLE, "Requisition", PurapParameterConstants.SHOW_DEBARRED_VENDOR_WARNING_IND)) {
            if (StringUtils.isEmpty(((PurchasingDocumentBase) purDocument).getJustification())) {
                errorMap.putWarning(VendorPropertyConstants.VENDOR_NAME, PurapKeyConstants.WARNING_DEBARRED_VENDOR, vendorDetail.getVendorName());
                valid &= false;
            }
        } else {
            errorMap.putError(VendorPropertyConstants.VENDOR_NAME, PurapKeyConstants.ERROR_DEBARRED_VENDOR);
            valid &= false;
        }
    }
    // make sure that the vendor is of allowed type
    List<String> allowedVendorTypes = new ArrayList<String>(getParameterService().getParameterValuesAsString(KfsParameterConstants.PURCHASING_DOCUMENT.class, PurapRuleConstants.PURAP_VENDOR_TYPE_ALLOWED_ON_REQ_AND_PO));
    if (allowedVendorTypes != null && !allowedVendorTypes.isEmpty()) {
        if (ObjectUtils.isNotNull(vendorHeader) && ObjectUtils.isNotNull(vendorHeader.getVendorTypeCode()) && !allowedVendorTypes.contains(vendorHeader.getVendorTypeCode())) {
            valid &= false;
            errorMap.putError(VendorPropertyConstants.VENDOR_NAME, PurapKeyConstants.ERROR_INVALID_VENDOR_TYPE);
        }
    }
    // make sure that the vendor is active
    if (!vendorDetail.isActiveIndicator()) {
        valid &= false;
        errorMap.putError(VendorPropertyConstants.VENDOR_NAME, PurapKeyConstants.ERROR_INACTIVE_VENDOR);
    }
    // make sure that the vendor contract is active and not expired.
    // KFSUPGRADE-266 remove kfsmi-8690/kfscntrb-929
    // if (ObjectUtils.isNotNull(purDocument.getVendorContractGeneratedIdentifier())) {
    // VendorContract vendorContract = SpringContext.getBean(BusinessObjectService.class).findBySinglePrimaryKey(VendorContract.class, purDocument.getVendorContractGeneratedIdentifier());
    // Date currentDate = SpringContext.getBean(DateTimeService.class).getCurrentSqlDate();
    // 
    // if (currentDate.compareTo(vendorContract.getVendorContractEndDate()) > 0 || !vendorContract.isActive()) {
    // valid &= false;
    // errorMap.putError(VendorPropertyConstants.VENDOR_CONTRACT_NAME, PurapKeyConstants.ERROR_INACTIVE_OR_EXPIRED_VENDOR_CONTRACT);
    // }
    // }
    // validate vendor address
    getPostalCodeValidationService().validateAddress(purDocument.getVendorCountryCode(), purDocument.getVendorStateCode(), purDocument.getVendorPostalCode(), PurapPropertyConstants.VENDOR_STATE_CODE, PurapPropertyConstants.VENDOR_POSTAL_CODE);
    errorMap.clearErrorPath();
    return valid;
}
Also used : VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) VendorHeader(org.kuali.kfs.vnd.businessobject.VendorHeader) ArrayList(java.util.ArrayList) PurchasingDocument(org.kuali.kfs.module.purap.document.PurchasingDocument) MessageMap(org.kuali.kfs.krad.util.MessageMap)

Aggregations

VendorHeader (org.kuali.kfs.vnd.businessobject.VendorHeader)11 VendorDetail (org.kuali.kfs.vnd.businessobject.VendorDetail)7 ArrayList (java.util.ArrayList)4 VendorSupplierDiversity (org.kuali.kfs.vnd.businessobject.VendorSupplierDiversity)4 Date (java.util.Date)3 CuVendorSupplierDiversityExtension (edu.cornell.kfs.vnd.businessobject.CuVendorSupplierDiversityExtension)2 List (java.util.List)2 MessageMap (org.kuali.kfs.krad.util.MessageMap)2 ParseException (org.kuali.kfs.sys.exception.ParseException)2 CuVendorCreditCardMerchant (edu.cornell.kfs.vnd.businessobject.CuVendorCreditCardMerchant)1 VendorDetailExtension (edu.cornell.kfs.vnd.businessobject.VendorDetailExtension)1 VendorInactivateConvertBatch (edu.cornell.kfs.vnd.businessobject.VendorInactivateConvertBatch)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 UserSession (org.kuali.kfs.krad.UserSession)1 ValidationException (org.kuali.kfs.krad.exception.ValidationException)1 MaintenanceDocument (org.kuali.kfs.krad.maintenance.MaintenanceDocument)1 PurchasingDocument (org.kuali.kfs.module.purap.document.PurchasingDocument)1