use of org.kuali.kfs.vnd.businessobject.VendorCommodityCode 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;
}
use of org.kuali.kfs.vnd.businessobject.VendorCommodityCode in project cu-kfs by CU-CommunityApps.
the class CuRequisitionServiceImpl method checkAPORulesPerItemForCommodityCodes.
/**
* Checks the APO rules for Commodity Codes.
* The rules are as follow:
* 1. If an institution does not require a commodity code on a requisition but does require a commodity code on a
* purchase order:
* a. If the requisition qualifies for an APO and the commodity code is blank on any line item then the system
* should use the default commodity code for the vendor.
* b. If there is not a default commodity code for the vendor then the requisition is not eligible to become an
* APO.
* 2. The commodity codes where the restricted indicator is Y should disallow the requisition from becoming an
* APO.
*
* KFSPTS-1319 Removed this validation check
* 3. If the commodity code is Inactive when the requisition is finally approved do not allow the requisition to
* become an APO.
*
* @param purItem
* @param vendorCommodityCodes
* @param commodityCodeRequired
* @return
*/
protected String checkAPORulesPerItemForCommodityCodes(RequisitionItem purItem, List<VendorCommodityCode> vendorCommodityCodes, boolean commodityCodeRequired) {
// use the default commodity code for the vendor
if (purItem.getCommodityCode() == null && commodityCodeRequired) {
for (VendorCommodityCode vcc : vendorCommodityCodes) {
if (vcc.isCommodityDefaultIndicator()) {
purItem.setCommodityCode(vcc.getCommodityCode());
purItem.setPurchasingCommodityCode(vcc.getPurchasingCommodityCode());
}
}
}
if (purItem.getCommodityCode() == null) {
// an APO.
if (commodityCodeRequired) {
return "There are missing commodity code(s).";
}
// KFSPTS-1319: Removed inactive commodity code validation check
// } else if (!purItem.getCommodityCode().isActive()) {
// return "Requisition contains inactive commodity codes.";
} else if (purItem.getCommodityCode().isRestrictedItemsIndicator()) {
return "Requisition contains an item with a restricted commodity code.";
}
return "";
}
Aggregations