use of org.kuali.kfs.module.purap.document.PurchasingDocument in project cu-kfs by CU-CommunityApps.
the class PurchasingProcessItemValidation method validate.
/* (non-Javadoc)
* @see org.kuali.kfs.sys.document.validation.Validation#validate(org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent)
*/
public boolean validate(AttributedDocumentEvent event) {
boolean valid = true;
PurchasingDocument purDocument = (PurchasingDocument) event.getDocument();
MessageMap errorMap = GlobalVariables.getMessageMap();
errorMap.clearErrorPath();
// errorMap.addToErrorPath(PurapConstants.ITEM_TAB_ERRORS);
// KFSPTS-1719 : remove this validation
// // Check that item isn't a non-qty item on an e-invoice vendor order
// Check that there aren't any req items that already have non-qty values entered
List<PurApItem> reqItems = purDocument.getItems();
// KFSPTS-2096
if (!reqItems.isEmpty()) {
String itemTypeCode = KFSConstants.EMPTY_STRING;
int i = 0;
for (PurApItem item : reqItems) {
if (StringUtils.isEmpty(itemTypeCode) && (PurapConstants.ItemTypeCodes.ITEM_TYPE_SERVICE_CODE.equalsIgnoreCase(item.getItemTypeCode()) || PurapConstants.ItemTypeCodes.ITEM_TYPE_ITEM_CODE.equalsIgnoreCase(item.getItemTypeCode()))) {
itemTypeCode = item.getItemTypeCode();
}
if (StringUtils.isNotBlank(itemTypeCode) && (PurapConstants.ItemTypeCodes.ITEM_TYPE_SERVICE_CODE.equalsIgnoreCase(item.getItemTypeCode()) || PurapConstants.ItemTypeCodes.ITEM_TYPE_ITEM_CODE.equalsIgnoreCase(item.getItemTypeCode())) && !itemTypeCode.equalsIgnoreCase(item.getItemTypeCode())) {
// Throw error that mix qty and no-qty
// errorMap.addToErrorPath("document.item["+ i + "].itemTypeCode");
errorMap.putError("document.item[" + i + "].itemTypeCode", CUPurapKeyConstants.PURAP_MIX_ITEM_QTY_NONQTY);
// errorMap.removeFromErrorPath("document.item["+ i + "].itemTypeCode");
valid &= false;
}
if (PurapConstants.ItemTypeCodes.ITEM_TYPE_SERVICE_CODE.equalsIgnoreCase(item.getItemTypeCode()) || PurapConstants.ItemTypeCodes.ITEM_TYPE_ITEM_CODE.equalsIgnoreCase(item.getItemTypeCode())) {
i++;
}
}
}
// errorMap.clearErrorPath();
return valid;
}
use of org.kuali.kfs.module.purap.document.PurchasingDocument in project cu-kfs by CU-CommunityApps.
the class CuPurchasingProcessVendorValidation method validate.
@Override
public boolean validate(AttributedDocumentEvent event) {
boolean valid = true;
PurchasingDocument purDocument = (PurchasingDocument) event.getDocument();
MessageMap errorMap = GlobalVariables.getMessageMap();
errorMap.clearErrorPath();
errorMap.addToErrorPath(PurapConstants.VENDOR_ERRORS);
if (!purDocument.getRequisitionSourceCode().equals(PurapConstants.RequisitionSources.B2B)) {
// CU enhancement here. Replaced foundation implementation block
if ((purDocument.getVendorHeaderGeneratedIdentifier() != null) && (!(isDocumentInNodeWhereMopotDataValidationIsBypassed(purDocument))) && (purDocument.getPurchaseOrderTransmissionMethodCode().equals(CUPurapConstants.POTransmissionMethods.EMAIL) || purDocument.getPurchaseOrderTransmissionMethodCode().equals(PurapConstants.POTransmissionMethods.FAX) || purDocument.getPurchaseOrderTransmissionMethodCode().equals(CUPurapConstants.POTransmissionMethods.MANUAL))) {
valid &= this.validateDataForMethodOfPOTransmissionExistsOnVendorAddress(purDocument);
// called routine took care of presenting error message to user
}
}
VendorDetail vendorDetail = getVendorService().getVendorDetail(purDocument.getVendorHeaderGeneratedIdentifier(), purDocument.getVendorDetailAssignedIdentifier());
if (ObjectUtils.isNull(vendorDetail)) {
return valid;
}
VendorHeader vendorHeader = vendorDetail.getVendorHeader();
// make sure that the vendor is not debarred
if (vendorDetail.isVendorDebarred()) {
if (getParameterService().getParameterValueAsBoolean(KFSConstants.OptionalModuleNamespaces.PURCHASING_ACCOUNTS_PAYABLE, "Requisition", PurapParameterConstants.SHOW_DEBARRED_VENDOR_WARNING_IND)) {
if (StringUtils.isEmpty(((PurchasingDocumentBase) purDocument).getJustification())) {
errorMap.putWarning(VendorPropertyConstants.VENDOR_NAME, PurapKeyConstants.WARNING_DEBARRED_VENDOR, vendorDetail.getVendorName());
valid &= false;
}
} else {
errorMap.putError(VendorPropertyConstants.VENDOR_NAME, PurapKeyConstants.ERROR_DEBARRED_VENDOR);
valid &= false;
}
}
// make sure that the vendor is of allowed type
List<String> allowedVendorTypes = new ArrayList<String>(getParameterService().getParameterValuesAsString(KfsParameterConstants.PURCHASING_DOCUMENT.class, PurapRuleConstants.PURAP_VENDOR_TYPE_ALLOWED_ON_REQ_AND_PO));
if (allowedVendorTypes != null && !allowedVendorTypes.isEmpty()) {
if (ObjectUtils.isNotNull(vendorHeader) && ObjectUtils.isNotNull(vendorHeader.getVendorTypeCode()) && !allowedVendorTypes.contains(vendorHeader.getVendorTypeCode())) {
valid &= false;
errorMap.putError(VendorPropertyConstants.VENDOR_NAME, PurapKeyConstants.ERROR_INVALID_VENDOR_TYPE);
}
}
// make sure that the vendor is active
if (!vendorDetail.isActiveIndicator()) {
valid &= false;
errorMap.putError(VendorPropertyConstants.VENDOR_NAME, PurapKeyConstants.ERROR_INACTIVE_VENDOR);
}
// make sure that the vendor contract is active and not expired.
// KFSUPGRADE-266 remove kfsmi-8690/kfscntrb-929
// if (ObjectUtils.isNotNull(purDocument.getVendorContractGeneratedIdentifier())) {
// VendorContract vendorContract = SpringContext.getBean(BusinessObjectService.class).findBySinglePrimaryKey(VendorContract.class, purDocument.getVendorContractGeneratedIdentifier());
// Date currentDate = SpringContext.getBean(DateTimeService.class).getCurrentSqlDate();
//
// if (currentDate.compareTo(vendorContract.getVendorContractEndDate()) > 0 || !vendorContract.isActive()) {
// valid &= false;
// errorMap.putError(VendorPropertyConstants.VENDOR_CONTRACT_NAME, PurapKeyConstants.ERROR_INACTIVE_OR_EXPIRED_VENDOR_CONTRACT);
// }
// }
// validate vendor address
getPostalCodeValidationService().validateAddress(purDocument.getVendorCountryCode(), purDocument.getVendorStateCode(), purDocument.getVendorPostalCode(), PurapPropertyConstants.VENDOR_STATE_CODE, PurapPropertyConstants.VENDOR_POSTAL_CODE);
errorMap.clearErrorPath();
return valid;
}
Aggregations