Class: SolidusBacktracs::Shipment::ExportableQuery

Inherits:
Object
  • Object
show all
Defined in:
app/queries/solidus_backtracs/shipment/exportable_query.rb

Class Method Summary collapse

Class Method Details

.apply(scope) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/queries/solidus_backtracs/shipment/exportable_query.rb', line 6

def self.apply(scope)
  scope = scope
          .order(:updated_at)
          .joins(:order)
          .merge(::Spree::Order.complete)

  unless SolidusBacktracs.configuration.capture_at_notification
    scope = scope.where(spree_shipments: { state: ['ready', 'canceled'] })
  end

  unless SolidusBacktracs.configuration.export_canceled_shipments
    scope = scope.where.not(spree_shipments: { state: 'canceled' })
  end

  scope
end