I’m trying to create a basic Point of Sale and Inventory management system.
Some things to take into account:
- The products are always the same (same ID) through the whole system, but inventory (available units for sale per product) is unique per location. Location Y and Z may both have for sale units of product X, but if, for example, two units are sold from location Y, location Z’s inventory should not be affected. Its stocked units are still intact.
- Selling one (1) unit of product X from location Y, means inventory of location Y should subtract one unit from its inventory.
From that, I thought of these tables:
locations
- id
- name
products
- id
- name
transactions
- id
- description
inventories_header
- id
- location_id
- product_id
inventories_detail
- inventories_id
- transaction_id
- unit_cost
- unit_price
- quantity
orders_header
- id
- date
- total (calculated from orders_detail quantity * price; just for future data validation)
orders_detail
- order_id
- transaction_id
- product_id
- quantity
- price
Okay, so, are there any questions? Of course.
- How do I keep track of changes in units cost? If some day I start paying more for a certain product, I would need to keep track of the marginal utility (
(cost*quantity) - (price*quantity) = marginal utility
) some way. I thought of inventories_detail mostly for this. I wouldn’t have cared otherwise. - Are relationships well stablished? I still have a hard time thinking if the locations have inventories, or if inventories have several locations. It’s maddening.
- How would you keep/know your current stock levels? Since I had to separate the inventory table to keep up with cost updates, I guess I would just have to add up all the quantities stated in inventories_detail.
- Any suggestions do you want to share?
I’m sure I still have some questions, but these are mostly the ones I need addressing. Also, since I’m using Ruby on Rails for the first time, actually, as a learning experience, it’s a shame to be stopped at design, not letting me punch through implementation quicker, but I guess that’s the way it should be.
Thanks in advance.