Sha256: d0c39183fc633a98780da693944ca617e470e3670b5203b1e77c63e51636d40e

Contents?: true

Size: 796 Bytes

Versions: 1

Compression:

Stored size: 796 Bytes

Contents

require 'logger'

Spree::Refund.class_eval do
  has_one :avalara_transaction
  after_create :avalara_capture_finalize, if: :avalara_tax_enabled?

  def avalara_tax_enabled?
    Spree::AvalaraPreference.tax_calculation.is_true?
  end

  def avalara_capture_finalize
    logger.debug 'avalara capture refund avalara_capture_finalize'
    begin
      avalara_transaction_refund = self.payment.order.avalara_transaction

      @rtn_tax = avalara_transaction_refund.commit_avatax_final('ReturnInvoice', self)

      logger.info 'tax amount'
      logger.debug @rtn_tax
      @rtn_tax
    rescue => e
      logger.debug e
      logger.debug 'error in avalara capture refund finalize'
    end
  end

  def logger
    @logger ||= SolidusAvataxCertified::AvataxLog.new('refund', 'refund class')
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
solidus_avatax_certified-1.0.0 app/models/spree/refund_decorator.rb