Several things happen when you fulfill an order.
Also many times a user will make an order then call customer service to change their address. Fulfillments allow a CS user to change the address before the item ships.
Inventory is a table that needs to have pestimistic locking. This requires the SQL to be very fast in order to ensure the table is not locked. Please keep the table free from extra data that might cause locking to become an issue.
# Table name: inventories # # id :integer not null, primary key # count_on_hand :integer default(0) # count_pending_to_customer :integer default(0) # count_pending_from_supplier :integer default(0)
The inventories table has three key fields.
count_on_hand Is just the number of items in the warehouse. This value would indicate the quantity of items as if you would to count the items in the warehouse. So of these items might be purchased by the customers already but they have not been shipped. This is the number a person in the warehouse would use to determine if the stock numbers are correct.
count_pending_to_customer Is just the number of items on the shelf in the warehouse that have been purchased but not shipped. Thus the quantity_available for sale is:
Many shops also have an out of stock quantity larger than zero. This can be helpful for returns or quality purposes. ence the quantity_purchaseable is:
quantity_available = count_on_hand - count_pending_to_customer
quantity_purchaseable = quantity_available - OUT_OF_STOCK_QTY
count_pending_from_supplier is the amount of items you are expecting to receive from a supplier. It does not effect stock. If the supply of product arrives and the quality is too low you would not want to reverse all the orders. That said ror_ecommerce should be changed by you to fit your exact business model.