1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  session[:cart] << inventory_item << inventory_item << inventory_item

  customer adds inventory to cart. Calculate total price taking into account volume discounts on the fly. When they checkout, formalize this on the order and line item tables:

  line_items table:
  order_id,inventory_id,qty,price_plan_id,customer_price,ready_to_ship_at,shipped_at,package_id
  
  one line item per unique inventory item. package_id if you're going to part-ship orders... then you could have order has_many :packages but that's getting a bit complex.

  orders table:
  created_at,updated_at,user_id,payment_status,fulfillment_status,fulfilled_at


  line_items_orders table:
  line_item_id,order_id

Order
  has_and_belongs_to_many :line_items
  belongs_to :user

LineItem
  has_and_belongs_to_many :orders 
  belongs_to :inventory