コード例 #1
0
 protected boolean isVendorQuoteActiveNotDebarredVendor(
     Integer vendorHeaderGeneratedIdentifier, Integer vendorDetailAssignedIdentifer) {
   VendorDetail vendorDetail =
       vendorService.getVendorDetail(
           vendorHeaderGeneratedIdentifier, vendorDetailAssignedIdentifer);
   if (vendorDetail != null) {
     if (!vendorDetail.isActiveIndicator()) {
       GlobalVariables.getMessageMap()
           .putError(
               PurapPropertyConstants.NEW_PURCHASE_ORDER_VENDOR_QUOTE_VENDOR_NAME,
               PurapKeyConstants.ERROR_PURCHASE_ORDER_QUOTE_INACTIVE_VENDOR);
       return false;
     } else if (vendorDetail.isVendorDebarred()) {
       GlobalVariables.getMessageMap()
           .putError(
               PurapPropertyConstants.NEW_PURCHASE_ORDER_VENDOR_QUOTE_VENDOR_NAME,
               PurapKeyConstants.ERROR_PURCHASE_ORDER_QUOTE_DEBARRED_VENDOR);
       return false;
     }
   }
   return true;
 }
コード例 #2
0
  /**
   * Validation for the Stipulation tab.
   *
   * @param poDocument the purchase order document to be validated
   * @return boolean false if the vendor stipulation description is blank.
   */
  @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.
    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;
  }