Search in sources :

Example 1 with VendorHeader

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

the class PaymentWorksVendorToKfsVendorDetailConversionServiceImpl method populateDataForTaxRuleIndividualUsEin.

private KfsVendorDataWrapper populateDataForTaxRuleIndividualUsEin(KfsVendorDataWrapper kfsVendorDataWrapper, PaymentWorksVendor pmwVendor, Map<String, List<PaymentWorksIsoFipsCountryItem>> paymentWorksIsoToFipsCountryMap) {
    VendorHeader vendorHeader = new VendorHeader();
    vendorHeader.setVendorForeignIndicator(new Boolean(false));
    vendorHeader.setVendorTaxNumber(pmwVendor.getRequestingCompanyTin());
    vendorHeader.setVendorTaxTypeCode(PaymentWorksConstants.PaymentWorksTinType.FEIN.getKfsTaxTypeCodeAsString());
    vendorHeader.setVendorOwnershipCode(PaymentWorksConstants.PaymentWorksTaxClassification.INDIVIDUAL_SOLE_PROPRIETOR.getTranslationToKfsOwnershipTypeCode());
    vendorHeader.setVendorCorpCitizenCode(convertIsoCountryCodeToFipsCountryCode(pmwVendor.getRequestingCompanyTaxCountry(), paymentWorksIsoToFipsCountryMap));
    kfsVendorDataWrapper.getVendorDetail().setVendorHeader(vendorHeader);
    kfsVendorDataWrapper = populateW9Attributes(kfsVendorDataWrapper, pmwVendor);
    kfsVendorDataWrapper = populateBusinessLegalName(pmwVendor, kfsVendorDataWrapper);
    return kfsVendorDataWrapper;
}
Also used : VendorHeader(org.kuali.kfs.vnd.businessobject.VendorHeader)

Example 2 with VendorHeader

use of org.kuali.kfs.vnd.businessobject.VendorHeader 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 3 with VendorHeader

use of org.kuali.kfs.vnd.businessobject.VendorHeader 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 4 with VendorHeader

use of org.kuali.kfs.vnd.businessobject.VendorHeader 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 5 with VendorHeader

use of org.kuali.kfs.vnd.businessobject.VendorHeader 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

VendorHeader (org.kuali.kfs.vnd.businessobject.VendorHeader)17 VendorDetail (org.kuali.kfs.vnd.businessobject.VendorDetail)8 ArrayList (java.util.ArrayList)4 VendorSupplierDiversity (org.kuali.kfs.vnd.businessobject.VendorSupplierDiversity)4 Date (java.util.Date)3 PaymentWorksVendor (edu.cornell.kfs.pmw.batch.businessobject.PaymentWorksVendor)2 CuVendorSupplierDiversityExtension (edu.cornell.kfs.vnd.businessobject.CuVendorSupplierDiversityExtension)2 List (java.util.List)2 Test (org.junit.jupiter.api.Test)2 MessageMap (org.kuali.kfs.krad.util.MessageMap)2 ParseException (org.kuali.kfs.sys.exception.ParseException)2 TaxRule (edu.cornell.kfs.pmw.batch.TaxRule)1 KfsVendorDataWrapper (edu.cornell.kfs.pmw.batch.businessobject.KfsVendorDataWrapper)1 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 Date (java.sql.Date)1 HashMap (java.util.HashMap)1