I’m trying to create a basic Point of Sale and Inventory management system.
Some things to take into account:
From that, I thought of these tables:
locations
products
transactions
inventories_header
inventories_detail
orders_header
orders_detail
Okay, so, are there any questions? Of course.
(cost*quantity) - (price*quantity) = marginal utility
) some way. I thought of inventories_detail mostly for this. I wouldn’t have cared otherwise.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.
POS solutions fall in to two main architectural categories. A "Database" POS has its own database in a closed and proprietary platform. Generally, these POS solutions work just fine until you start to scale your business and the complexities and risks of integration arise.
In MySQL, schema is synonymous with database. You can substitute the keyword SCHEMA for DATABASE in MySQL SQL syntax. Some other database products draw a distinction. For example, in the Oracle Database product, a schema represents only a part of a database: the tables and other objects are owned by a single user.
Inventory database is a centralized repository for all inventory data in an organization. Database for inventory management software allows balancing inventory costs and risks against the desired inventory performance metrics.
The inventory table describes the inventory based on a product ID. The inventory table is created with the following CREATE TABLE statement: CREATE TABLE INVENTORY ( PID VARCHAR(10) NOT NULL, QUANTITY INTEGER, LOCATION VARCHAR(128), PRIMARY KEY (PID) )
The tricky part here is that you're really doing more than a POS solution. You're also doing an inventory management & basic cost accounting system.
The first scenario you need to address is what accounting method you'll use to determine the cost of any item sold. The most common options would be FIFO, LIFO, or Specific Identification (all terms that can be Googled).
In all 3 scenarios, you should record your purchases of your goods in a data structure (typically called PurchaseOrder, but in this case I'll call it SourcingOrder to differentiate from your orders tables in the original question).
The structure below assumes that each sourcing order line will be for one location (otherwise things get even more complex). In other words, if I buy 2 widgets for store A and 2 for store B, I'd add 2 lines to the order with quantity 2 for each, not one line with quantity 4.
SourcingOrder
- order_number
- order_date
SourcingOrderLine
- product_id
- unit_cost
- quantity
- location_id
Inventory can be one level...
InventoryTransaction
- product_id
- quantity
- sourcing_order_line_id
- order_line_id
- location_id
- source_inventory_transaction_id
Each time a SourcingOrderLine is received at a store, you'll create an InventoryTransaction with a positive quantity and FK references to the sourcing_order_line_id
, product_id
and location_id
.
Each time a sale is made, you'll create an InventoryTransaction with a negative quantity and FK references to the order_line_id
, product_id
and location_id
, source_inventory_transaction_id
.
The source_inventory_transaction_id
would be a link from the negative quantity InventoryTransaction back to the postiive quantity InventoryTransaction calculated using whichever accounting method you choose.
Current inventory for a location would be SELECT sum(quantity) FROM inventory_transactions WHERE product_id = ? and location_id = ?
GROUP BY product_id, location_id
.
Marginal cost would be calculated by tracing back from the sale, through the 2 related inventory transactions to the SourcingOrder line.
NOTE: You have to handle the case where you allocate one order line across 2 inventory transactions because the ordered quantity was larger that what was left in the next inventory transaction to be allocated. This data structure will handle this, but you'll need to work the logic and query yourself.
Brian is correct. Just to add additional info. If you are working into a complete system for your business or client. I would suggest that you start working on the organizational level down to process of POS and accounting. That would make your database experience more extensive... :P In my experience in system development, Inventory modules always start with the stock taking+(purchases-purchase returns)=SKU available for sales. POS is not directly attached to Inventory module but rather will be reconciled daily by the sales supervisor. Total Daily Sales quantities will then be deducted to SKU available for sales. you will work out also the costing and pricing modules. Correct normalization of database is always a must.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With