mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-19 04:49:15 +00:00
@@ -126,38 +126,14 @@ module Spree
|
||||
joins('LEFT OUTER JOIN spree_products ON (spree_products.id = spree_variants.product_id)')
|
||||
}
|
||||
|
||||
scope :not_state, lambda { |state|
|
||||
where.not(state: state)
|
||||
}
|
||||
|
||||
# All the states an order can be in after completing the checkout
|
||||
FINALIZED_STATES = %w(complete canceled resumed awaiting_return returned).freeze
|
||||
|
||||
scope :finalized, -> { where(state: FINALIZED_STATES) }
|
||||
|
||||
def self.by_number(number)
|
||||
where(number: number)
|
||||
end
|
||||
|
||||
def self.between(start_date, end_date)
|
||||
where(created_at: start_date..end_date)
|
||||
end
|
||||
|
||||
def self.by_customer(customer)
|
||||
joins(:user).where("#{Spree.user_class.table_name}.email" => customer)
|
||||
end
|
||||
|
||||
def self.by_state(state)
|
||||
where(state: state)
|
||||
end
|
||||
|
||||
def self.complete
|
||||
where('completed_at IS NOT NULL')
|
||||
end
|
||||
|
||||
def self.incomplete
|
||||
where(completed_at: nil)
|
||||
end
|
||||
scope :complete, -> { where.not(completed_at: nil) }
|
||||
scope :incomplete, -> { where(completed_at: nil) }
|
||||
scope :by_state, lambda { |state| where(state: state) }
|
||||
scope :not_state, lambda { |state| where.not(state: state) }
|
||||
|
||||
# For compatiblity with Calculator::PriceSack
|
||||
def amount
|
||||
|
||||
Reference in New Issue
Block a user