Class: ViewExpandedLineItem

Inherits:
ApplicationViewRecord show all
Includes:
Models::SearchableView
Defined in:
app/models/view_expanded_line_item.rb

Overview

== Schema Information

Table name: view_expanded_line_items
Database name: primary

id :integer primary key
amazon_bulk_buy_ca :decimal(, )
amazon_bulk_buy_us :decimal(, )
amazon_ca :decimal(, )
amazon_us :decimal(, )
costco_ca :decimal(, )
costco_promotion_ca :decimal(, )
costco_promotion_us :decimal(, )
costco_us :decimal(, )
customer_group :text
future_release_date :date
home_depot_ca :decimal(, )
home_depot_promotion_ca :decimal(, )
home_depot_promotion_us :decimal(, )
home_depot_us :decimal(, )
order_created_at :datetime
order_shipped_date :date
order_state :string(255)
quantity :decimal(, )
quantity_ca :decimal(, )
quantity_us :decimal(, )
resource_type :string(255)
created_at :datetime
updated_at :datetime
item_id :integer
kit_id :integer
order_id :integer
resource_id :integer
store_id :integer

Class Method Summary collapse

Methods included from Models::SearchableView

#crm_link, #crm_link_subtitle, #has_columns?, #main_resource, #readonly?

Methods inherited from ApplicationViewRecord

create, create!, #readonly?

Methods inherited from ApplicationRecord

ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation

Methods included from Models::EventPublishable

#publish_event

Class Method Details

.item_demand_by_week(date_range: 6.months.ago..Date.current, order_state: 'invoiced') ⇒ Object



39
40
41
42
43
# File 'app/models/view_expanded_line_item.rb', line 39

def self.item_demand_by_week(date_range: 6.months.ago..Date.current, order_state: 'invoiced')
  where(order_state: order_state).
  group(:item_id).
  group_by_week(:created_at, range: date_range, series: false).count
end