<commit_before>require 'logger'
RETURN_AUTHORIZATION_LOGGER = AvataxHelper::AvataxLog.new("return_authorization", "return_authorization class")

Spree::ReturnAuthorization.class_eval do
  RETURN_AUTHORIZATION_LOGGER.info('start ReturnAuthorization processing')

  has_one :avalara_transaction, dependent: :destroy
  after_create :assign_avalara_transaction
  self.state_machine.after_transition :to => :received,
                                      :do => :avalara_capture_finalize,
                                      :if => :avalara_eligible

  def avalara_eligible
    Spree::Config.avatax_iseligible
  end

  def avalara_lookup
    RETURN_AUTHORIZATION_LOGGER.debug 'avalara lookup return_authorization'
    create_avalara_transaction_return_auth
    :lookup_avatax
  end

  def avalara_capture
    RETURN_AUTHORIZATION_LOGGER.debug 'avalara capture return_authorization'
    begin

      create_avalara_transaction_return_auth

      order.adjustments.avalara_tax.destroy_all

      @rtn_tax = self.avalara_transaction.commit_avatax(order.line_items, order, order.number.to_s + ":" + self.id.to_s, order.completed_at.strftime("%F"))

      RETURN_AUTHORIZATION_LOGGER.info 'tax amount'<commit_msg>brought back state machine in hopes it will work<commit_after>require 'logger'
RETURN_AUTHORIZATION_LOGGER = AvataxHelper::AvataxLog.new("return_authorization", "return_authorization class")

Spree::ReturnAuthorization.class_eval do
  RETURN_AUTHORIZATION_LOGGER.info('start ReturnAuthorization processing')

  has_one :avalara_transaction, dependent: :destroy
  after_create :assign_avalara_transaction
  self.state_machine.after_transition :to => :authorized,
                                      :do => :avalara_capture,
                                      :if => :avalara_eligible
  self.state_machine.after_transition :to => :received,
                                      :do => :avalara_capture_finalize,
                                      :if => :avalara_eligible

  def avalara_eligible
    Spree::Config.avatax_iseligible
  end

  def avalara_lookup
    RETURN_AUTHORIZATION_LOGGER.debug 'avalara lookup return_authorization'
    create_avalara_transaction_return_auth
    :lookup_avatax
  end

  def avalara_capture
    RETURN_AUTHORIZATION_LOGGER.debug 'avalara capture return_authorization'
    begin

      create_avalara_transaction_return_auth

      order.adjustments.avalara_tax.destroy_all

      @rtn_tax = self.avalara_transaction.commit_avatax(order.line_items, order, order.number.to_s + ":" + self.id.to_s, order.completed_at.strftime("%F"))

      RETURN_AUTHORIZATION_LOGGER.info 'tax amount'
{'fraction_non_alphanumeric': 0.07221588749524896, 'fraction_numerical': 0.0, 'mean_word_length': 3.6419753086419755, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5389539', 'n_tokens_mistral': 815, 'n_tokens_neox': 779, 'n_words': 124}