Sha256: 2e846f95d3f77ca1aa5016a1b2afd923b1a87bb7ff5011d5ad80f3741802b27c

Contents?: true

Size: 740 Bytes

Versions: 2

Compression:

Stored size: 740 Bytes

Contents

module Workarea
  module Avatax
    class TaxInvoiceWorker
      include Sidekiq::Worker
      include Sidekiq::CallbacksWorker

      sidekiq_options(
        enqueue_on: {
          Workarea::Order => :place,
          ignore_if: -> { Avatax.config.order_handling == :none }
        }
      )

      def perform(order_id)
        order = Workarea::Order.find(order_id)
        shippings = Workarea::Shipping.where(order_id: order.id).to_a

        response = Avatax::TaxRequest.new(
          order: order,
          shippings: shippings,
          type: "SalesInvoice",
          commit: Avatax.commit?
        ).response

        raise "Failed to invoice tax for order: #{order.id}" unless response.success?
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
workarea-avatax-4.2.1 app/workers/workarea/avatax/tax_invoice_worker.rb
workarea-avatax-4.2.0 app/workers/workarea/avatax/tax_invoice_worker.rb