Search in sources :

Example 41 with PurchasingDocument

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;
}
Also used : PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) PurchasingDocument(org.kuali.kfs.module.purap.document.PurchasingDocument) MessageMap(org.kuali.kfs.krad.util.MessageMap)

Example 42 with PurchasingDocument

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;
}
Also used : VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) VendorHeader(org.kuali.kfs.vnd.businessobject.VendorHeader) ArrayList(java.util.ArrayList) PurchasingDocument(org.kuali.kfs.module.purap.document.PurchasingDocument) MessageMap(org.kuali.kfs.krad.util.MessageMap)

Aggregations

PurchasingDocument (org.kuali.kfs.module.purap.document.PurchasingDocument)42 CapitalAssetSystem (org.kuali.kfs.integration.purap.CapitalAssetSystem)14 PurchasingCapitalAssetItem (org.kuali.kfs.module.purap.businessobject.PurchasingCapitalAssetItem)10 KualiRuleService (org.kuali.kfs.krad.service.KualiRuleService)7 PurapService (org.kuali.kfs.module.purap.document.service.PurapService)6 PurchasingService (org.kuali.kfs.module.purap.document.service.PurchasingService)5 ItemCapitalAsset (org.kuali.kfs.integration.purap.ItemCapitalAsset)4 MessageMap (org.kuali.kfs.krad.util.MessageMap)4 PurApItem (org.kuali.kfs.module.purap.businessobject.PurApItem)4 ActionForward (org.apache.struts.action.ActionForward)3 Map (java.util.Map)2 CapitalAssetLocation (org.kuali.kfs.integration.purap.CapitalAssetLocation)2 BusinessObjectService (org.kuali.kfs.krad.service.BusinessObjectService)2 PurchasingCapitalAssetSystemBase (org.kuali.kfs.module.purap.businessobject.PurchasingCapitalAssetSystemBase)2 PurchaseOrderAmendmentDocument (org.kuali.kfs.module.purap.document.PurchaseOrderAmendmentDocument)2 PurchaseOrderDocument (org.kuali.kfs.module.purap.document.PurchaseOrderDocument)2 PurchasingDocumentBase (org.kuali.kfs.module.purap.document.PurchasingDocumentBase)2 AttributedAddPurchasingAccountsPayableItemEvent (org.kuali.kfs.module.purap.document.validation.event.AttributedAddPurchasingAccountsPayableItemEvent)2 AttributedAddPurchasingCapitalAssetLocationEvent (org.kuali.kfs.module.purap.document.validation.event.AttributedAddPurchasingCapitalAssetLocationEvent)2 AttributedAddPurchasingItemCapitalAssetEvent (org.kuali.kfs.module.purap.document.validation.event.AttributedAddPurchasingItemCapitalAssetEvent)2