Module: Ext::Integrations::Order::ClassMethods

Defined in:
app/models/ext/integrations.rb

Instance Method Summary collapse

Instance Method Details

#sale_search(search) ⇒ Object



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'app/models/ext/integrations.rb', line 106

def sale_search(search)
  standard = ::Order.includes(:items => { :show => :event })

  if search.start
    standard = standard.after(search.start)
  end

  if search.stop
    standard = standard.before(search.stop)
  end

  if search.organization
    standard = standard.where('orders.organization_id = ?', search.organization.id)
  end

  if search.show
    standard = standard.where("shows.id = ?", search.show.id)
  elsif search.event
    standard = standard.where("events.id = ?", search.event.id)
  end

  standard.all
end