public boolean validate(AttributedDocumentEvent event) {
    boolean valid = true;
    PurApAccountingLine account =
        (PurApAccountingLine) ((AddAccountingLineEvent) event).getAccountingLine();
    ObjectCode objectCode = account.getObjectCode();

    ParameterEvaluator parameterEvaluator = /*REFACTORME*/
        SpringContext.getBean(ParameterEvaluatorService.class)
            .getParameterEvaluator(
                VendorCreditMemoDocument.class,
                PurapRuleConstants.VALID_OBJECT_LEVELS_BY_OBJECT_TYPE_PARM_NM,
                PurapRuleConstants.INVALID_OBJECT_LEVELS_BY_OBJECT_TYPE_PARM_NM,
                objectCode.getFinancialObjectTypeCode(),
                objectCode.getFinancialObjectLevelCode());
    return parameterEvaluator.evaluateAndAddError(
        SourceAccountingLine.class,
        "objectCode.financialObjectLevelCode",
        KFSPropertyConstants.FINANCIAL_OBJECT_CODE);
  }
  /**
   * This method checks to see if this doctype needs sales tax If it does then it checks to see if
   * the account and object code require sales tax If it does then it returns true. Note - this is
   * hackish as we shouldn't have to call rules directly from the action class But we need to in
   * this instance because we are copying the lines before calling rules and need a way to modify
   * them before they go on
   *
   * @param accountingLine
   * @return true if sales tax check is needed, false otherwise
   */
  protected boolean isSalesTaxRequired(
      AccountingDocument financialDocument, AccountingLine accountingLine) {
    boolean required = false;
    String docType =
        SpringContext.getBean(DataDictionaryService.class)
            .getDocumentTypeNameByClass(financialDocument.getClass());
    // first we need to check just the doctype to see if it needs the sales tax check
    ParameterService parameterService = SpringContext.getBean(ParameterService.class);
    // apply the rule, see if it fails
    ParameterEvaluator docTypeSalesTaxCheckEvaluator = /*REFACTORME*/
        SpringContext.getBean(ParameterEvaluatorService.class)
            .getParameterEvaluator(
                KfsParameterConstants.FINANCIAL_PROCESSING_DOCUMENT.class,
                APPLICATION_PARAMETER.DOCTYPE_SALES_TAX_CHECK,
                docType);
    if (docTypeSalesTaxCheckEvaluator.evaluationSucceeds()) {
      required = true;
    }

    // second we need to check the account and object code combination to see if it needs sales tax
    if (required) {
      // get the object code and account
      String objCd = accountingLine.getFinancialObjectCode();
      String account = accountingLine.getAccountNumber();
      if (!StringUtils.isEmpty(objCd) && !StringUtils.isEmpty(account)) {
        String compare = account + ":" + objCd;
        ParameterEvaluator salesTaxApplicableAcctAndObjectEvaluator = /*REFACTORME*/
            SpringContext.getBean(ParameterEvaluatorService.class)
                .getParameterEvaluator(
                    KfsParameterConstants.FINANCIAL_PROCESSING_DOCUMENT.class,
                    APPLICATION_PARAMETER.SALES_TAX_APPLICABLE_ACCOUNTS_AND_OBJECT_CODES,
                    compare);
        if (!salesTaxApplicableAcctAndObjectEvaluator.evaluationSucceeds()) {
          required = false;
        }
      } else {
        // the two fields are currently empty and we don't need to check yet
        required = false;
      }
    }
    return required;
  }
  /**
   * determines if object code sub types are valid with the object type code. <strong>Expects an
   * accounting line as the first a parameter</strong>
   *
   * @see org.kuali.kfs.sys.document.validation.Validation#validate(java.lang.Object[])
   */
  public boolean validate(AttributedDocumentEvent event) {
    accountingLineForValidation.refreshReferenceObject("objectCode");
    ObjectCode code = accountingLineForValidation.getObjectCode();
    boolean retVal = true;

    if (!ObjectUtils.isNull(code)) {
      ParameterEvaluator parameterEvaluator = /*REFACTORME*/
          SpringContext.getBean(ParameterEvaluatorService.class)
              .getParameterEvaluator(
                  GeneralErrorCorrectionDocument.class,
                  VALID_OBJECT_SUB_TYPES_BY_OBJECT_TYPE,
                  INVALID_OBJECT_SUB_TYPES_BY_OBJECT_TYPE,
                  code.getFinancialObjectTypeCode(),
                  code.getFinancialObjectSubTypeCode());

      retVal =
          parameterEvaluator.evaluateAndAddError(
              SourceAccountingLine.class,
              "objectCode.financialObjectSubTypeCode",
              KFSPropertyConstants.FINANCIAL_OBJECT_CODE);
    }
    return retVal;
  }