Search in sources :

Example 1 with VendorSupplierDiversity

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

the class CuVendorRule method processAddCollectionLineBusinessRules.

public boolean processAddCollectionLineBusinessRules(MaintenanceDocument document, String collectionName, PersistableBusinessObject bo) {
    boolean success = super.processAddCollectionLineBusinessRules(document, collectionName, bo);
    if (collectionName.equals(VendorConstants.VENDOR_HEADER_ATTR + "." + VendorPropertyConstants.VENDOR_SUPPLIER_DIVERSITIES)) {
        VendorDetail vendorDetail = (VendorDetail) document.getDocumentBusinessObject();
        VendorHeader vendorHeader = vendorDetail.getVendorHeader();
        List<VendorSupplierDiversity> vendorSupplierDiversities = vendorHeader.getVendorSupplierDiversities();
        if (vendorSupplierDiversities.size() > 0) {
            int i = 0;
            for (VendorSupplierDiversity vendor : vendorSupplierDiversities) {
                if (((CuVendorSupplierDiversityExtension) vendor.getExtension()).getVendorSupplierDiversityExpirationDate() == null) {
                    success = false;
                    putFieldError(VendorConstants.VENDOR_HEADER_ATTR + "." + VendorPropertyConstants.VENDOR_SUPPLIER_DIVERSITIES + "[" + i + "]." + CUVendorPropertyConstants.SUPPLIER_DIVERSITY_EXPRIATION, CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_SUPPLIER_DIVERSITY_DATE_BLANK);
                } else if (((CuVendorSupplierDiversityExtension) vendor.getExtension()).getVendorSupplierDiversityExpirationDate().before(new Date())) {
                    // Only check expiration date on new vendors
                    if (document.isNew()) {
                        success = false;
                        putFieldError(VendorConstants.VENDOR_HEADER_ATTR + "." + VendorPropertyConstants.VENDOR_SUPPLIER_DIVERSITIES + "[" + i + "]." + CUVendorPropertyConstants.SUPPLIER_DIVERSITY_EXPRIATION, CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_SUPPLIER_DIVERSITY_DATE_IN_PAST);
                    }
                }
                i++;
            }
        }
        if (!success) {
            return success;
        }
    }
    if (collectionName.equals("vendorCommodities")) {
        VendorCommodityCode codeToBeValidated = (VendorCommodityCode) bo;
        CommodityCode persistedCommodity = commodityCodeService.getByPrimaryId(codeToBeValidated.getPurchasingCommodityCode());
        if (persistedCommodity == null) {
            // a commodity code entered by a user does not exist
            putFieldError("add.vendorCommodities.purchasingCommodityCode", CUVendorKeyConstants.ERROR_VENDOR_COMMODITY_CODE_DOES_NOT_EXIST, codeToBeValidated.getPurchasingCommodityCode());
            success = false;
        }
        if (codeToBeValidated.isCommodityDefaultIndicator()) {
            VendorDetail vendorDetail = (VendorDetail) document.getDocumentBusinessObject();
            List<VendorCommodityCode> vendorCommodities = vendorDetail.getVendorCommodities();
            Iterator<VendorCommodityCode> commodities = vendorCommodities.iterator();
            int indice = 0;
            while (commodities.hasNext()) {
                VendorCommodityCode commodity = (VendorCommodityCode) commodities.next();
                if (commodity.isCommodityDefaultIndicator()) {
                    // more than one "default" commodity code has been specified
                    putFieldError("add.vendorCommodities.commodityDefaultIndicator", CUVendorKeyConstants.ERROR_DEFAULT_VENDOR_COMMODITY_CODE_ALREADY_EXISTS, Integer.toString(indice));
                    success = false;
                }
                indice++;
            }
        }
        VendorDetail vendorDetail = (VendorDetail) document.getDocumentBusinessObject();
        boolean commodityAlreadyAssignedToThisVendor = false;
        Iterator<VendorCommodityCode> codes = vendorDetail.getVendorCommodities().iterator();
        while (codes.hasNext()) {
            VendorCommodityCode vcc = codes.next();
            if (vcc.getPurchasingCommodityCode().equals(codeToBeValidated.getPurchasingCommodityCode())) {
                commodityAlreadyAssignedToThisVendor = true;
                break;
            }
        }
        if (commodityAlreadyAssignedToThisVendor) {
            putFieldError("add.vendorCommodities.purchasingCommodityCode", CUVendorKeyConstants.ERROR_VENDOR_COMMODITY_CODE_ALREADY_ASSIGNED_TO_VENDOR);
            success = false;
        }
        return success;
    }
    return success;
}
Also used : VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) VendorHeader(org.kuali.kfs.vnd.businessobject.VendorHeader) VendorCommodityCode(org.kuali.kfs.vnd.businessobject.VendorCommodityCode) CommodityCode(org.kuali.kfs.vnd.businessobject.CommodityCode) CuVendorSupplierDiversityExtension(edu.cornell.kfs.vnd.businessobject.CuVendorSupplierDiversityExtension) VendorSupplierDiversity(org.kuali.kfs.vnd.businessobject.VendorSupplierDiversity) Date(java.util.Date) VendorCommodityCode(org.kuali.kfs.vnd.businessobject.VendorCommodityCode)

Example 2 with VendorSupplierDiversity

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

the class CuVendorRule method processCustomAddCollectionLineBusinessRules.

public boolean processCustomAddCollectionLineBusinessRules(MaintenanceDocument document, String collectionName, PersistableBusinessObject bo) {
    boolean success = super.processCustomAddCollectionLineBusinessRules(document, collectionName, bo);
    if (bo instanceof VendorAddress) {
        VendorAddress address = (VendorAddress) bo;
        VendorDetail vendorDetail = (VendorDetail) document.getNewMaintainableObject().getBusinessObject();
        VendorHeader vendorHeader = vendorDetail.getVendorHeader();
        // String propertyConstant = KFSConstants.ADD_PREFIX + "." + VendorPropertyConstants.VENDOR_ADDRESS + ".";
        String propertyConstant = "add.vendorAddresses.";
        if (StringUtils.isBlank(vendorHeader.getVendorTypeCode())) {
            success = false;
            putFieldError(VendorPropertyConstants.VENDOR_TYPE_CODE, CUVendorKeyConstants.ERROR_DOCUMENT_VENDOR_TYPE_IS_REQUIRED_FOR_ADD_VENDORADRESS);
        } else {
            vendorHeader.refreshReferenceObject(KFSPropertyConstants.VENDOR_TYPE_CODE);
            success &= this.checkAddressMethodOfPOTransmissionAndData(vendorHeader.getVendorTypeCode(), vendorHeader.getVendorType().getVendorAddressTypeRequiredCode(), address, propertyConstant);
        }
    }
    if (bo instanceof CuVendorCreditCardMerchant) {
        CuVendorCreditCardMerchant vendorMerchant = (CuVendorCreditCardMerchant) bo;
        VendorDetail vendorDetail = (VendorDetail) document.getNewMaintainableObject().getBusinessObject();
        success &= validateCreditCardMerchantAddition(vendorDetail, vendorMerchant);
    }
    if (bo instanceof VendorSupplierDiversity) {
        VendorSupplierDiversity vendorSupplierDiversity = (VendorSupplierDiversity) bo;
        success &= validateSupplierDiversityAddition(vendorSupplierDiversity);
    }
    return success;
}
Also used : VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) VendorHeader(org.kuali.kfs.vnd.businessobject.VendorHeader) CuVendorCreditCardMerchant(edu.cornell.kfs.vnd.businessobject.CuVendorCreditCardMerchant) VendorAddress(org.kuali.kfs.vnd.businessobject.VendorAddress) VendorSupplierDiversity(org.kuali.kfs.vnd.businessobject.VendorSupplierDiversity)

Example 3 with VendorSupplierDiversity

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

the class CuVendorRule method checkSupplierDiversityExpirationDate.

protected boolean checkSupplierDiversityExpirationDate(MaintenanceDocument document) {
    boolean success = true;
    VendorDetail vendorDetail = (VendorDetail) document.getNewMaintainableObject().getBusinessObject();
    VendorHeader vendorHeader = vendorDetail.getVendorHeader();
    List<VendorSupplierDiversity> vendorSupplierDiversities = vendorHeader.getVendorSupplierDiversities();
    if (vendorSupplierDiversities.size() > 0) {
        int i = 0;
        for (VendorSupplierDiversity vendor : vendorSupplierDiversities) {
            if (((CuVendorSupplierDiversityExtension) vendor.getExtension()).getVendorSupplierDiversityExpirationDate() == null) {
                success = false;
                putFieldError(VendorConstants.VENDOR_HEADER_ATTR + "." + VendorPropertyConstants.VENDOR_SUPPLIER_DIVERSITIES + "[" + i + "]." + CUVendorPropertyConstants.SUPPLIER_DIVERSITY_EXPRIATION, CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_SUPPLIER_DIVERSITY_DATE_BLANK);
            } else if (((CuVendorSupplierDiversityExtension) vendor.getExtension()).getVendorSupplierDiversityExpirationDate().before(new Date())) {
                // Only check expiration date on new vendors
                if (document.isNew()) {
                    success = false;
                    putFieldError(VendorConstants.VENDOR_HEADER_ATTR + "." + VendorPropertyConstants.VENDOR_SUPPLIER_DIVERSITIES + "[" + i + "]." + CUVendorPropertyConstants.SUPPLIER_DIVERSITY_EXPRIATION, CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_SUPPLIER_DIVERSITY_DATE_IN_PAST);
                }
            }
            i++;
        }
    }
    return success;
}
Also used : VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) VendorHeader(org.kuali.kfs.vnd.businessobject.VendorHeader) CuVendorSupplierDiversityExtension(edu.cornell.kfs.vnd.businessobject.CuVendorSupplierDiversityExtension) VendorSupplierDiversity(org.kuali.kfs.vnd.businessobject.VendorSupplierDiversity) Date(java.util.Date)

Example 4 with VendorSupplierDiversity

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

the class CuVendorMaintainableImpl method populateGeneratedHerderId.

private void populateGeneratedHerderId(VendorHeader vendorHeader) {
    if (vendorHeader.getVendorHeaderGeneratedIdentifier() == null) {
        Integer generatedHeaderId = SpringContext.getBean(SequenceAccessorService.class).getNextAvailableSequenceNumber(HEADER_ID_SEQ).intValue();
        vendorHeader.setVendorHeaderGeneratedIdentifier(generatedHeaderId.intValue());
        ((CuVendorHeaderExtension) vendorHeader.getExtension()).setVendorHeaderGeneratedIdentifier(generatedHeaderId);
    }
    if (CollectionUtils.isNotEmpty(vendorHeader.getVendorSupplierDiversities())) {
        for (VendorSupplierDiversity supplierDiversity : vendorHeader.getVendorSupplierDiversities()) {
            supplierDiversity.setVendorHeaderGeneratedIdentifier(vendorHeader.getVendorHeaderGeneratedIdentifier());
            ((CuVendorSupplierDiversityExtension) supplierDiversity.getExtension()).setVendorHeaderGeneratedIdentifier(vendorHeader.getVendorHeaderGeneratedIdentifier());
            ((CuVendorSupplierDiversityExtension) supplierDiversity.getExtension()).setVendorSupplierDiversityCode(supplierDiversity.getVendorSupplierDiversityCode());
        }
    }
}
Also used : CuVendorHeaderExtension(edu.cornell.kfs.vnd.businessobject.CuVendorHeaderExtension) CuVendorSupplierDiversityExtension(edu.cornell.kfs.vnd.businessobject.CuVendorSupplierDiversityExtension) VendorSupplierDiversity(org.kuali.kfs.vnd.businessobject.VendorSupplierDiversity)

Example 5 with VendorSupplierDiversity

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

the class CuVendorPreRules method detectAndConfirmExpirationDates.

protected void detectAndConfirmExpirationDates(MaintenanceDocument document) {
    boolean proceed = true;
    ArrayList<String> expired = new ArrayList<String>();
    VendorDetail vendorDetail = (VendorDetail) document.getNewMaintainableObject().getBusinessObject();
    VendorDetailExtension vendorDetailext = (VendorDetailExtension) vendorDetail.getExtension();
    if (vendorDetailext.getGeneralLiabilityExpiration() != null && vendorDetailext.getGeneralLiabilityExpiration().before(new Date())) {
        expired.add(CUVendorConstants.EXPIRABLE_COVERAGES.GENERAL_LIABILITY_COVERAGE);
        GlobalVariables.getMessageMap().putError(KFSConstants.MAINTENANCE_NEW_MAINTAINABLE + CUVendorPropertyConstants.GENERAL_LIABILITY_EXPIRATION, CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_GENERAL_LIABILITY_EXPR_DATE_IN_PAST);
    }
    if (vendorDetailext.getAutomobileLiabilityExpiration() != null && vendorDetailext.getAutomobileLiabilityExpiration().before(new Date())) {
        expired.add(CUVendorConstants.EXPIRABLE_COVERAGES.AUTOMOBILE_LIABILITY_COVERAGE);
        GlobalVariables.getMessageMap().putError(KFSConstants.MAINTENANCE_NEW_MAINTAINABLE + CUVendorPropertyConstants.AUTOMOBILE_LIABILITY_EXPIRATION, CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_AUTO_EXPR_IN_PAST);
    }
    if (vendorDetailext.getWorkmansCompExpiration() != null && vendorDetailext.getWorkmansCompExpiration().before(new Date())) {
        expired.add(CUVendorConstants.EXPIRABLE_COVERAGES.WORKMAN_COMP_COVERAGE);
        GlobalVariables.getMessageMap().putError(KFSConstants.MAINTENANCE_NEW_MAINTAINABLE + CUVendorPropertyConstants.WORKMANS_COMP_EXPIRATION, CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_WC_EXPR_IN_PAST);
    }
    if (vendorDetailext.getExcessLiabilityUmbExpiration() != null && vendorDetailext.getExcessLiabilityUmbExpiration().before(new Date())) {
        expired.add(CUVendorConstants.EXPIRABLE_COVERAGES.EXCESS_LIABILITY_UMBRELLA_COVERAGE);
        GlobalVariables.getMessageMap().putError(KFSConstants.MAINTENANCE_NEW_MAINTAINABLE + CUVendorPropertyConstants.EXCESS_LIABILITY_UMBRELLA_EXPIRATION, CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_UMB_EXPR_IN_PAST);
    }
    if (vendorDetailext.getHealthOffSiteLicenseExpirationDate() != null && vendorDetailext.getHealthOffSiteLicenseExpirationDate().before(new Date())) {
        expired.add(CUVendorConstants.EXPIRABLE_COVERAGES.HEALTH_DEPARTMENT_LICENSE);
        GlobalVariables.getMessageMap().putError(KFSConstants.MAINTENANCE_NEW_MAINTAINABLE + CUVendorPropertyConstants.HEALTH_OFFSITE_LICENSE_EXPIRATION, CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_HEALTH_LICENSE_EXPR_IN_PAST);
    }
    VendorHeader vendorHeader = vendorDetail.getVendorHeader();
    List<VendorSupplierDiversity> vendorSupplierDiversities = vendorHeader.getVendorSupplierDiversities();
    if (vendorSupplierDiversities.size() > 0) {
        int i = 0;
        for (VendorSupplierDiversity vendor : vendorSupplierDiversities) {
            if (((CuVendorSupplierDiversityExtension) vendor.getExtension()).getVendorSupplierDiversityExpirationDate().before(new Date())) {
                expired.add(CUVendorConstants.EXPIRABLE_COVERAGES.SUPPLIER_DIVERSITY_CERTIFICATION);
                GlobalVariables.getMessageMap().putError(KFSConstants.MAINTENANCE_NEW_MAINTAINABLE + VendorConstants.VENDOR_HEADER_ATTR + "." + VendorPropertyConstants.VENDOR_SUPPLIER_DIVERSITIES + "[" + i + "]." + CUVendorPropertyConstants.SUPPLIER_DIVERSITY_EXPRIATION, CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_SUPPLIER_DIVERSITY_DATE_IN_PAST);
                break;
            }
            i++;
        }
    }
    if (!expired.isEmpty()) {
        String expiredNames = "";
        for (String name : expired) {
            expiredNames = expiredNames + "[br] - " + name;
        }
        proceed &= askOrAnalyzeYesNoQuestion(CUVendorConstants.EXPIRED_DATE_QUESTION_ID, VendorUtils.buildMessageText(CUVendorKeyConstants.CONFIRM_VENDOR_DATE_EXPIRED, expiredNames));
    }
    if (!proceed) {
        abortRulesCheck();
    } else {
        GlobalVariables.getMessageMap().clearErrorMessages();
    }
}
Also used : VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) VendorHeader(org.kuali.kfs.vnd.businessobject.VendorHeader) ArrayList(java.util.ArrayList) VendorDetailExtension(edu.cornell.kfs.vnd.businessobject.VendorDetailExtension) VendorSupplierDiversity(org.kuali.kfs.vnd.businessobject.VendorSupplierDiversity) Date(java.util.Date)

Aggregations

VendorSupplierDiversity (org.kuali.kfs.vnd.businessobject.VendorSupplierDiversity)11 CuVendorSupplierDiversityExtension (edu.cornell.kfs.vnd.businessobject.CuVendorSupplierDiversityExtension)6 ArrayList (java.util.ArrayList)4 VendorDetail (org.kuali.kfs.vnd.businessobject.VendorDetail)4 VendorHeader (org.kuali.kfs.vnd.businessobject.VendorHeader)4 Date (java.util.Date)3 VendorBatchSupplierDiversity (edu.cornell.kfs.vnd.businessobject.VendorBatchSupplierDiversity)2 SupplierDiversity (org.kuali.kfs.vnd.businessobject.SupplierDiversity)2 CuVendorCreditCardMerchant (edu.cornell.kfs.vnd.businessobject.CuVendorCreditCardMerchant)1 CuVendorHeaderExtension (edu.cornell.kfs.vnd.businessobject.CuVendorHeaderExtension)1 VendorDetailExtension (edu.cornell.kfs.vnd.businessobject.VendorDetailExtension)1 Date (java.sql.Date)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 CommodityCode (org.kuali.kfs.vnd.businessobject.CommodityCode)1 VendorAddress (org.kuali.kfs.vnd.businessobject.VendorAddress)1 VendorCommodityCode (org.kuali.kfs.vnd.businessobject.VendorCommodityCode)1