GET /:id/sales
- query based on #sold_at
-
POST /api/stock_items/serialized/:serialized_id/sold
- sold_at is param
- passed into stock_item.sell!
-
POST /api/stock_items/fcu/:fc_upc/sold
- sold_at is param
- CAN BE DELETED
-
#product_inventory
- query for product.stock_items with sold: false
-
#product_sales_history
- using product.sold_stock_items
- helper_method :sold_stock_items
- user.stock_items.sold
- query based on
#sold_at
#sold_at
-> stock_item.sold_at
- expose
#sold_at
#sizes_with_owned_count
- user.portfolio_items.unsold
- query for stock items where('sold_at ...')
- expose sold_at
- expose sold_price_cents
- expose income
- record.sold_price_cents
- export sold (2x; 1 can be deleted)
- export sold_at
#move_to_sold
- External API calls
#create_ledger!
- stock_item.sold! + sold_at
-
#bestsellers
- query based on stock_items.sold + sold_at
-
#highest_grossing
- query based on stock_items.sold + sold_at
-
#average_age_days
- stock_items.sold + sold_stock_items
-
#sold_stock_items
- stock_items.where(sold: true).reorder(sold_at: :desc)
#selling_volume
- bestseller.stock_items.sold.where(sold_at
- stock_items.sold.where(sold_at
-
scope :sold (based on sold and sold_at
-
scope :in_stock
- sold: false, hidden: false.where withdrawn is false or null
-
scope :hidden
- where(hidden: true, sold: false, withdrawn: false)
-
scope :sold_today
- where(sold_at
-
#sold!
- sold_at
- mark_as_sold!(sold_at)
- save!
-
#sell!
- sold!(sold_at
-
#mark_as_sold!
- sold=true
- sold_at
- save!
-
.sold_yesterday
- where(sold_at:
-
#age_in_secs
- sold + sold_at
-
#shelf_life_days
- sold_at
-
#status
- sold?
-
#editable?
- sold? || withdrawn?
-
.with_sales
- stock_items.where(stock_items.sold).where(sold_at
-
#order_available_stock_items_by_age
- select(sold_at
-
#last_sale
- stock_items.sold.order(sold_at
-
#first_sale
- sold.order(sold_at
-
#sold!
- stock_item.sold!
- Event type (probably ignorable)
- item.sold_at (could refactor how its formatting)
- product.sold_stock_items
- stock_item.sold_at
- sold_stock_items (check controller)
#perform
- stock_item.sold
POST api/stock_items/serialized/:id/withdraw
- withdraw_at param
- stock_item.withdraw!(withdraw_at)
#product_inventory
- product.stock_items.where(withdrawn: true)
- product.stock_items.where(hidden: true, sold: false, withdrawn: false)
#update_params
- :withdrawn, :withdrawn_at
- tricky logic around withdrawn status
-
#withdrawn_stock_items
- tabs...maybe ignore?
-
#withdrawn_stock_items
- user.stock_items.withdrawn
#sizes_with_owned_count
- not_withdrawn (part of larger query)
- expose withdrawn
.update_variant_message
- query where(withdrawn = true)
-
scope: :withdrawn
-
scope: :not_withdrawn
-
scope: :older_than
-
scope: :hidden
-
scope: :in_stock
-
scope: :not_withdrawn_pending
-
#mark_withdraw_pending!
- update(withdraw_pending: true, withdraw_pending_at: )
-
`#withdraw!(withdrawn_at)
- withdrawn = true
- withdrawn_at
- deducts quantity (SIDE EFFECT)
-
#status
-
#magento_sync_this
- checks if !withdrawn
-
#editable?
- !withdrawn
#reject
- stock_items.each(&:mark_withdraw_pending!)
#stock_items
- .not_withdraw_pending (part of larger query)
-
#withdraw
- stock_item.update(withdraw_pending: false)
- stock_item.withdraw!
-
#withdraw_pending_status
- stock_item.withdraw_pending?
- check_box :withdrawn
#perform
- StockItem.not_withdrawn
#update_params
- take_back
- query for stock_items.where(take_back = true) & false
-
scope: :not_take_back
-
.add_stock!
- StockItem.create!(take_back: params[:take_back]) <-- is this ever passed in?
-
mark_taken_back!
- update!(take_back: true)
- can probably remove it
-
#status
-
#magento_sync_this
#stock_items
- not_take_back (part of larger query)
- check_box :take_back
- hidden_field :take_back if !editable
-
GET api/v1/returnables
- where(withdraw_pending: true)
-
PATCH api/v1/returnables
- using service object (Returns::StockItemWithdraw)
.update_variant_message
- query where(withdraw_pending = true)
Hidden
POST api/stock_items/reserve
- StockItem.hidden.where(
- stock_item.hidden =
- stock_item.hidden_reason
#product_inventory
- product.stock_items.where(hidden: true, sold: false, withdrawn: false)
-
#update_params
- hidden
-
#create_params
- hidden
-
#create
- StockItem.from_submission!(hidden: create_params[:hidden])
-
helper_methods
- hidden_stock_items
-
#hidden_stock_items
- user.stock_items.hidden
#sizes_with_owned_count
- StockItem.where().not_hidden (part of larger query)
- expose :hidden
- expose :hidden
.update_variant_message
- stock_items.where(hidden: true OR...)
- stock_items.where(hidden: false AND ...)
- delete message if stock_item.hidden_reason
-
scope: :hidden
-
scope: :in_stock
-
scope: :not_hidden
-
#.from_submission
- hidden: params[:hidden]
-
.add_stock!
- hidden: params[:hidden] || false
- hidden_reason: params[:hidden] || false
-
#status
- hidden_reason
- hidden_field :hidden
- hidden_stock_items
#update_params
- missing
#update_variant_message
- stock_items.where(missing = true OR ...)
- stock_items.where(missing = false AND ...)
-
.add_stock!
- missing: params[:missing] || false
-
#status
- check_box :missing
- hidden_field :missing
#status