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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations