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

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

Instance Method Summary collapse

Instance Method Details

#sale_search(search) ⇒ Object



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'app/models/ext/integrations.rb', line 88

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