class RawgentoModels::OrderItem

Public Instance Methods

all_ordered?() click to toggle source
# File lib/rawgento_models/order_item.rb, line 17
def all_ordered?
  num_wished == num_ordered
end
not_ordered?() click to toggle source
# File lib/rawgento_models/order_item.rb, line 29
def not_ordered?
  num_ordered.nil?
end
order_item_same_product(before) click to toggle source
# File lib/rawgento_models/order_item.rb, line 37
def order_item_same_product before
  time_range = Date.civil(1970, 1, 1)..before
  OrderItem.where(local_product_id: self.local_product_id)
    .joins(:order).where(
      orders: { state: ['ordered', 'stocked'],
                updated_at: time_range })
    .order("updated_at ASC")
end
order_item_same_product_last_wished() click to toggle source
# File lib/rawgento_models/order_item.rb, line 46
def order_item_same_product_last_wished
  OrderItem.where(local_product_id: self.local_product_id).where('num_wished >= 0')
    .joins(:order).where(
      orders: { state: ['ordered', 'stocked']})
    .order("updated_at DESC").first
end
ordered?() click to toggle source
# File lib/rawgento_models/order_item.rb, line 25
def ordered?
  !not_ordered?
end
out_of_stock?() click to toggle source
# File lib/rawgento_models/order_item.rb, line 21
def out_of_stock?
  num_ordered == 0
end
remote_product_id() click to toggle source
# File lib/rawgento_models/order_item.rb, line 13
def remote_product_id
  local_product.remote_product.try(:product_id)
end
stocked?() click to toggle source
# File lib/rawgento_models/order_item.rb, line 33
def stocked?
  num_stocked.present?
end