Search in sources :

Example 16 with VendorDetail

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

the class CuVendorRule method processCuAddressValidation.

// CU enhancement related po transmission KFSUPGRADE-348
// can't override processAddressValidation because it has no modifier, so only class/package can access it.
boolean processCuAddressValidation(MaintenanceDocument document) {
    boolean valid = true;
    VendorDetail newVendor = (VendorDetail) document.getNewMaintainableObject().getBusinessObject();
    List<VendorAddress> addresses = newVendor.getVendorAddresses();
    String vendorTypeCode = newVendor.getVendorHeader().getVendorTypeCode();
    String vendorAddressTypeRequiredCode = newVendor.getVendorHeader().getVendorType().getVendorAddressTypeRequiredCode();
    verifyPOTransmissionTypeAllowedForVendorType(vendorTypeCode, addresses);
    for (int i = 0; i < addresses.size(); i++) {
        VendorAddress address = addresses.get(i);
        String errorPath = MAINTAINABLE_ERROR_PREFIX + VendorPropertyConstants.VENDOR_ADDRESS + "[" + i + "]";
        GlobalVariables.getMessageMap().clearErrorPath();
        GlobalVariables.getMessageMap().addToErrorPath(errorPath);
        String propertyName = VendorPropertyConstants.VENDOR_ADDRESS + "[" + i + "].";
        valid &= checkAddressMethodOfPOTransmissionAndData(vendorTypeCode, vendorAddressTypeRequiredCode, address, propertyName);
        GlobalVariables.getMessageMap().clearErrorPath();
    }
    return valid;
}
Also used : VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) VendorAddress(org.kuali.kfs.vnd.businessobject.VendorAddress)

Example 17 with VendorDetail

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

the class CuVendorRule method checkUmbrellaPolicyAmountAndExpiration.

protected boolean checkUmbrellaPolicyAmountAndExpiration(MaintenanceDocument document) {
    boolean success = true;
    VendorDetail vendorDetail = (VendorDetail) document.getNewMaintainableObject().getBusinessObject();
    VendorDetailExtension vendorDetailExt = ((VendorDetailExtension) vendorDetail.getExtension());
    if (vendorDetailExt.getExcessLiabilityUmbrellaAmount() != null && vendorDetailExt.getExcessLiabilityUmbExpiration() == null) {
        success = false;
        putFieldError(CUVendorPropertyConstants.EXCESS_LIABILITY_UMBRELLA_AMOUNT, CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_UMB_EXPR_NEEDED);
    }
    if (vendorDetailExt.getExcessLiabilityUmbrellaAmount() == null && vendorDetailExt.getExcessLiabilityUmbExpiration() != null) {
        success = false;
        putFieldError(CUVendorPropertyConstants.EXCESS_LIABILITY_UMBRELLA_EXPIRATION, CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_UMB_COVERAGE_NEEDED);
    }
    if (vendorDetailExt.getExcessLiabilityUmbExpiration() != null && vendorDetailExt.getExcessLiabilityUmbExpiration().before(new Date())) {
        // Only check expiration date on new vendors
        if (document.isNew()) {
            success = false;
            putFieldError(CUVendorPropertyConstants.EXCESS_LIABILITY_UMBRELLA_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 18 with VendorDetail

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

the class CuVendorRule method validateB2BDefaultCommodityCode.

protected boolean validateB2BDefaultCommodityCode(MaintenanceDocument document) {
    VendorDetail vendorDetail = (VendorDetail) document.getNewMaintainableObject().getBusinessObject();
    boolean success = true;
    List<VendorContract> vendorContracts = vendorDetail.getVendorContracts();
    List<VendorCommodityCode> vendorCommodities = vendorDetail.getVendorCommodities();
    Iterator<VendorContract> it = vendorContracts.iterator();
    boolean isB2b = false;
    while (it.hasNext()) {
        VendorContract contract = (VendorContract) it.next();
        if (contract.getVendorB2bIndicator()) {
            isB2b = true;
            break;
        }
    }
    if (isB2b) {
        if (vendorCommodities.size() == 0) {
            success = false;
            // no vendor commodities exist
            putFieldError("vendorCommodities", CUVendorKeyConstants.ERROR_VENDOR_COMMODITY_CODE_DEFAULT_IS_REQUIRED_FOR_B2B);
            return success;
        }
        boolean defaultCommodityCodeSpecified = false;
        Iterator<VendorCommodityCode> commodities = vendorCommodities.iterator();
        int indice = 0;
        while (commodities.hasNext()) {
            VendorCommodityCode commodity = (VendorCommodityCode) commodities.next();
            if (commodity.isCommodityDefaultIndicator() && !defaultCommodityCodeSpecified) {
                defaultCommodityCodeSpecified = true;
            } else if (commodity.isCommodityDefaultIndicator()) {
                // more than one "default" commodity code has been specified
                putFieldError("vendorCommodities[" + indice + "].commodityDefaultIndicator", CUVendorKeyConstants.ERROR_DEFAULT_VENDOR_COMMODITY_CODE_ALREADY_EXISTS);
                success = false;
            }
            CommodityCode persistedCommodity = commodityCodeService.getByPrimaryId(commodity.getPurchasingCommodityCode());
            if (persistedCommodity == null) {
                // a commodity code entered by a user does not exist
                putFieldError("vendorCommodities[" + indice + "].purchasingCommodityCode", CUVendorKeyConstants.ERROR_VENDOR_COMMODITY_CODE_DOES_NOT_EXIST, commodity.getPurchasingCommodityCode());
                success = false;
            }
            indice++;
        }
        if (!defaultCommodityCodeSpecified) {
            // no default commodity code has been specified and the vendor has a b2b contract
            putFieldError("vendorCommodities", CUVendorKeyConstants.ERROR_VENDOR_COMMODITY_CODE_DEFAULT_IS_REQUIRED_FOR_B2B);
            success = false;
        }
    }
    return success;
}
Also used : VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) VendorContract(org.kuali.kfs.vnd.businessobject.VendorContract) VendorCommodityCode(org.kuali.kfs.vnd.businessobject.VendorCommodityCode) CommodityCode(org.kuali.kfs.vnd.businessobject.CommodityCode) VendorCommodityCode(org.kuali.kfs.vnd.businessobject.VendorCommodityCode)

Example 19 with VendorDetail

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

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

the class CuVendorRule method checkPOHasPaymentTerms.

/**
 * This routine ensures that there is a Payment Terms value set when the Vendor is a PO type
 */
private boolean checkPOHasPaymentTerms(MaintenanceDocument document) {
    boolean valid = true;
    VendorDetail vendorDetail = (VendorDetail) document.getNewMaintainableObject().getBusinessObject();
    String paymentTermsCode = vendorDetail.getVendorPaymentTermsCode();
    String vendorTypeCode = vendorDetail.getVendorHeader().getVendorTypeCode();
    // (vendorTypeCode = PO) && (payment terms is blank ) == error
    if (StringUtils.equalsIgnoreCase(vendorTypeCode, KFSConstants.FinancialDocumentTypeCodes.PURCHASE_ORDER) && StringUtils.isBlank(paymentTermsCode)) {
        putFieldError(CUVendorPropertyConstants.VENDOR_PAYMENT_TERMS, CUVendorKeyConstants.ERROR_PO_VENDOR_REQUIRES_PAYMENT_TERMS);
        valid = false;
    }
    return valid;
}
Also used : VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail)

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