Class: SuperGood::SolidusTaxjar::BackfillTransactionSyncBatchJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
app/jobs/super_good/solidus_taxjar/backfill_transaction_sync_batch_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(transaction_sync_batch) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/jobs/super_good/solidus_taxjar/backfill_transaction_sync_batch_job.rb', line 8

def perform(transaction_sync_batch)
  complete_orders = ::Spree::Order.complete.where(shipment_state: 'shipped')
  if transaction_sync_batch.start_date
    complete_orders = complete_orders.where("completed_at >= ?", transaction_sync_batch.start_date.beginning_of_day)
  end
  if transaction_sync_batch.end_date
    complete_orders = complete_orders.where("completed_at <= ?", transaction_sync_batch.end_date.end_of_day)
  end
  complete_orders.find_each do |order|
    next if order.taxjar_order_transactions.any?
    SuperGood::SolidusTaxjar::ReportTransactionJob.perform_later(order, transaction_sync_batch)
  end
end