Search in sources :

Example 11 with VendorDetail

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

the class DisbursementVoucherAction method setupPayeeAsVendor.

/**
 * setup the payee as a vendor with the given id number and address id
 */
protected void setupPayeeAsVendor(DisbursementVoucherForm dvForm, String payeeIdNumber, String payeeAddressIdentifier) {
    VendorDetail vendorDetail = new VendorDetail();
    vendorDetail.setVendorNumber(payeeIdNumber);
    vendorDetail = (VendorDetail) SpringContext.getBean(BusinessObjectService.class).retrieve(vendorDetail);
    VendorAddress vendorAddress = new VendorAddress();
    if (StringUtils.isNotBlank(payeeAddressIdentifier)) {
        try {
            vendorAddress.setVendorAddressGeneratedIdentifier(new Integer(payeeAddressIdentifier));
            vendorAddress = (VendorAddress) SpringContext.getBean(BusinessObjectService.class).retrieve(vendorAddress);
            dvForm.setTempPayeeIdNumber(payeeIdNumber);
            dvForm.setOldPayeeType(KFSConstants.PaymentPayeeTypes.VENDOR);
        } catch (Exception e) {
            LOG.error("Exception while attempting to retrieve vendor address for vendor address id " + payeeAddressIdentifier + ": " + e);
        }
    }
    ((DisbursementVoucherDocument) dvForm.getDocument()).templateVendor(vendorDetail, vendorAddress);
}
Also used : VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) VendorAddress(org.kuali.kfs.vnd.businessobject.VendorAddress) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService)

Example 12 with VendorDetail

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

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

the class CuVendorRule method checkWorkmansCompAmountAndExpiration.

protected boolean checkWorkmansCompAmountAndExpiration(MaintenanceDocument document) {
    boolean success = true;
    VendorDetail vendorDetail = (VendorDetail) document.getNewMaintainableObject().getBusinessObject();
    VendorDetailExtension vendorDetailExt = ((VendorDetailExtension) vendorDetail.getExtension());
    if (vendorDetailExt.getWorkmansCompCoverageAmount() != null && vendorDetailExt.getWorkmansCompExpiration() == null) {
        success = false;
        putFieldError(CUVendorPropertyConstants.WORKMANS_COMP_EXPIRATION, CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_WC_EXPR_NEEDED);
    }
    if (vendorDetailExt.getWorkmansCompCoverageAmount() == null && vendorDetailExt.getWorkmansCompExpiration() != null) {
        success = false;
        putFieldError(CUVendorPropertyConstants.WORKMANS_COMP_AMOUNT, CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_WC_COVERAGE_NEEDED);
    }
    if (vendorDetailExt.getWorkmansCompExpiration() != null && vendorDetailExt.getWorkmansCompExpiration().before(new Date())) {
        // Only check expiration date on new vendors
        if (document.isNew()) {
            success = false;
            putFieldError(CUVendorPropertyConstants.WORKMANS_COMP_EXPIRATION, CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_DATE_IN_PAST);
        }
    }
    return success;
}
Also used : VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) VendorDetailExtension(edu.cornell.kfs.vnd.businessobject.VendorDetailExtension) Date(java.util.Date)

Example 14 with VendorDetail

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

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

the class CuVendorRule method checkHealthLicenseAndExpiration.

protected boolean checkHealthLicenseAndExpiration(MaintenanceDocument document) {
    boolean success = true;
    VendorDetail vendorDetail = (VendorDetail) document.getNewMaintainableObject().getBusinessObject();
    Boolean offSiteCateringLicenseRequired = ((VendorDetailExtension) vendorDetail.getExtension()).getHealthOffSiteCateringLicenseReq();
    if (offSiteCateringLicenseRequired == null) {
        offSiteCateringLicenseRequired = false;
    }
    if (offSiteCateringLicenseRequired && ((VendorDetailExtension) vendorDetail.getExtension()).getHealthOffSiteLicenseExpirationDate() == null) {
        success = false;
        putFieldError(CUVendorPropertyConstants.HEALTH_OFFSITE_LICENSE_EXPIRATION, CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_HEALTH_LICENSE_EXPR_NEEDED);
    }
    if (!offSiteCateringLicenseRequired && ((VendorDetailExtension) vendorDetail.getExtension()).getHealthOffSiteLicenseExpirationDate() != null) {
        success = false;
        putFieldError(CUVendorPropertyConstants.HEALTH_OFFSITE_LICENSE_REQUIRED, CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_HEALTH_LICENSE_NEEDED);
    }
    if (((VendorDetailExtension) vendorDetail.getExtension()).getHealthOffSiteLicenseExpirationDate() != null && ((VendorDetailExtension) vendorDetail.getExtension()).getHealthOffSiteLicenseExpirationDate().before(new Date())) {
        // Only check expiration date on new vendors
        if (document.isNew()) {
            success = false;
            putFieldError(CUVendorPropertyConstants.HEALTH_OFFSITE_LICENSE_EXPIRATION, CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_DATE_IN_PAST);
        }
    }
    return success;
}
Also used : VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) VendorDetailExtension(edu.cornell.kfs.vnd.businessobject.VendorDetailExtension) Date(java.util.Date)

Aggregations

VendorDetail (org.kuali.kfs.vnd.businessobject.VendorDetail)54 ArrayList (java.util.ArrayList)14 VendorAddress (org.kuali.kfs.vnd.businessobject.VendorAddress)12 Date (java.util.Date)10 List (java.util.List)10 VendorDetailExtension (edu.cornell.kfs.vnd.businessobject.VendorDetailExtension)9 HashMap (java.util.HashMap)9 BusinessObjectService (org.kuali.kfs.krad.service.BusinessObjectService)7 VendorHeader (org.kuali.kfs.vnd.businessobject.VendorHeader)7 VendorService (org.kuali.kfs.vnd.document.service.VendorService)7 Iterator (java.util.Iterator)6 CuDisbursementVoucherDocument (edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)5 MessageMap (org.kuali.kfs.krad.util.MessageMap)5 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)5 Person (org.kuali.rice.kim.api.identity.Person)5 IOException (java.io.IOException)4 VendorCommodityCode (org.kuali.kfs.vnd.businessobject.VendorCommodityCode)4 VendorContract (org.kuali.kfs.vnd.businessobject.VendorContract)4 VendorSupplierDiversity (org.kuali.kfs.vnd.businessobject.VendorSupplierDiversity)4 FileNotFoundException (java.io.FileNotFoundException)3