Search in sources :

Example 51 with PurchaseOrderDocument

use of org.kuali.kfs.module.purap.document.PurchaseOrderDocument in project cu-kfs by CU-CommunityApps.

the class CuPurchaseOrderAmendmentAccountValidation method validate.

/**
 * Overridden to allow POAs to use expired accounts.
 *
 * @see org.kuali.kfs.module.purap.document.validation.impl.PurchaseOrderAmendmentAccountValidation#validate(
 * org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent)
 */
@Override
public boolean validate(AttributedDocumentEvent event) {
    boolean valid = true;
    PurchaseOrderDocument poaDocument = (PurchaseOrderDocument) event.getDocument();
    List<PurApItem> items = poaDocument.getItemsActiveOnly();
    PurchaseOrderDocument po = SpringContext.getBean(PurchaseOrderService.class).getCurrentPurchaseOrder(poaDocument.getPurapDocumentIdentifier());
    List<PurApItem> poItems = po.getItems();
    for (PurApItem item : items) {
        String identifierString = item.getItemIdentifierString();
        if (item.getItemTypeCode().equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_ITEM_CODE) && item.getSourceAccountingLines() != null && item.getSourceAccountingLines().size() > 0) {
            if (isItemChanged(item, poItems)) {
                List<PurApAccountingLine> accountingLines = item.getSourceAccountingLines();
                for (PurApAccountingLine accountingLine : accountingLines) {
                    if (!accountingLine.getAccount().isActive()) {
                        valid = false;
                        GlobalVariables.getMessageMap().putError(PurapConstants.ITEM_TAB_ERROR_PROPERTY, PurapKeyConstants.ERROR_ITEM_ACCOUNT_INACTIVE, accountingLine.getAccount().getAccountNumber());
                        break;
                    }
                }
            }
        }
    }
    return valid;
}
Also used : PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) PurchaseOrderService(org.kuali.kfs.module.purap.document.service.PurchaseOrderService) PurApAccountingLine(org.kuali.kfs.module.purap.businessobject.PurApAccountingLine) PurchaseOrderDocument(org.kuali.kfs.module.purap.document.PurchaseOrderDocument)

Example 52 with PurchaseOrderDocument

use of org.kuali.kfs.module.purap.document.PurchaseOrderDocument in project cu-kfs by CU-CommunityApps.

the class CuPurchaseOrderProcessVendorValidation method validate.

@Override
public boolean validate(AttributedDocumentEvent event) {
    boolean valid = super.validate(event);
    PurchasingAccountsPayableDocument purapDocument = (PurchasingAccountsPayableDocument) event.getDocument();
    PurchaseOrderDocument poDocument = (PurchaseOrderDocument) purapDocument;
    MessageMap errorMap = GlobalVariables.getMessageMap();
    errorMap.clearErrorPath();
    errorMap.addToErrorPath(PurapConstants.VENDOR_ERRORS);
    // check to see if the vendor exists in the database, i.e. its ID is not null
    Integer vendorHeaderID = poDocument.getVendorHeaderGeneratedIdentifier();
    if (ObjectUtils.isNull(vendorHeaderID)) {
        valid = false;
        errorMap.putError(VendorPropertyConstants.VENDOR_NAME, PurapKeyConstants.ERROR_NONEXIST_VENDOR);
    }
    // vendor active validation...
    VendorDetail vendorDetail = super.getVendorService().getVendorDetail(poDocument.getVendorHeaderGeneratedIdentifier(), poDocument.getVendorDetailAssignedIdentifier());
    if (ObjectUtils.isNull(vendorDetail)) {
        return valid;
    }
    // make sure that the vendor is active
    if (!vendorDetail.isActiveIndicator()) {
        valid &= false;
        errorMap.putError(VendorPropertyConstants.VENDOR_NAME, PurapKeyConstants.ERROR_INACTIVE_VENDOR);
    }
    // validate vendor address
    super.getPostalCodeValidationService().validateAddress(poDocument.getVendorCountryCode(), poDocument.getVendorStateCode(), poDocument.getVendorPostalCode(), PurapPropertyConstants.VENDOR_STATE_CODE, PurapPropertyConstants.VENDOR_POSTAL_CODE);
    // Do checks for alternate payee vendor.
    Integer alternateVendorHdrGeneratedId = poDocument.getAlternateVendorHeaderGeneratedIdentifier();
    Integer alternateVendorHdrDetailAssignedId = poDocument.getAlternateVendorDetailAssignedIdentifier();
    VendorDetail alternateVendor = super.getVendorService().getVendorDetail(alternateVendorHdrGeneratedId, alternateVendorHdrDetailAssignedId);
    if (alternateVendor != null) {
        if (alternateVendor.isVendorDebarred()) {
            errorMap.putError(PurapPropertyConstants.ALTERNATE_VENDOR_NAME, PurapKeyConstants.ERROR_PURCHASE_ORDER_ALTERNATE_VENDOR_DEBARRED);
            valid &= false;
        }
        if (StringUtils.equals(alternateVendor.getVendorHeader().getVendorTypeCode(), VendorTypes.DISBURSEMENT_VOUCHER)) {
            errorMap.putError(PurapPropertyConstants.ALTERNATE_VENDOR_NAME, PurapKeyConstants.ERROR_PURCHASE_ORDER_ALTERNATE_VENDOR_DV_TYPE);
            valid &= false;
        }
        if (!alternateVendor.isActiveIndicator()) {
            errorMap.putError(PurapPropertyConstants.ALTERNATE_VENDOR_NAME, PurapKeyConstants.ERROR_PURCHASE_ORDER_ALTERNATE_VENDOR_INACTIVE, PODocumentsStrings.ALTERNATE_PAYEE_VENDOR);
            valid &= false;
        }
    }
    // make sure that the vendor contract expiration date and not marked inactive.
    // KFSUPGRADE-266 remove kfsmi-8690/kfscntrb-929
    // if (StringUtils.isNotBlank(poDocument.getVendorContractName())) {
    // if (super.getVendorService().isVendorContractExpired(poDocument, poDocument.getVendorContractGeneratedIdentifier(), vendorDetail)) {
    // errorMap.putError(VendorPropertyConstants.VENDOR_CONTRACT_END_DATE, PurapKeyConstants.ERROR_EXPIRED_CONTRACT_END_DATE);
    // valid &= false;
    // }
    // }
    errorMap.clearErrorPath();
    return valid;
}
Also used : VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) PurchaseOrderDocument(org.kuali.kfs.module.purap.document.PurchaseOrderDocument) PurchasingAccountsPayableDocument(org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument) MessageMap(org.kuali.kfs.krad.util.MessageMap)

Aggregations

PurchaseOrderDocument (org.kuali.kfs.module.purap.document.PurchaseOrderDocument)52 CuPaymentRequestDocument (edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument)17 DocumentService (org.kuali.kfs.krad.service.DocumentService)16 PaymentRequestDocument (org.kuali.kfs.module.purap.document.PaymentRequestDocument)14 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)12 PaymentRequestItem (org.kuali.kfs.module.purap.businessobject.PaymentRequestItem)9 ArrayList (java.util.ArrayList)6 PurchaseOrderItem (org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem)6 RequisitionDocument (org.kuali.kfs.module.purap.document.RequisitionDocument)5 PurchaseOrderService (org.kuali.kfs.module.purap.document.service.PurchaseOrderService)5 HashMap (java.util.HashMap)4 List (java.util.List)4 Map (java.util.Map)4 BusinessObjectService (org.kuali.kfs.krad.service.BusinessObjectService)4 MessageMap (org.kuali.kfs.krad.util.MessageMap)4 PurchaseOrderAmendmentDocument (org.kuali.kfs.module.purap.document.PurchaseOrderAmendmentDocument)4 PurapService (org.kuali.kfs.module.purap.document.service.PurapService)4 File (java.io.File)3 BigDecimal (java.math.BigDecimal)3 Iterator (java.util.Iterator)3