Question

This is more of an abstract architectural question.

I'm working on an Inventory management system for pharmacy related area. I have all the usual components such as Product Definition(Product type, Category, etc.) Warehouse, Purchase Order, Goods Received Note, Sales Order, Product Pricing etc.

For each purchase, the product may carry a different costs (purchase cost + freight + additional cost) and should be able configure the selling price for each "batch" of purchase. When selling it should be possible to pick the BATCH based on FIFO or LIFO (it is configured in product definition)

How best we can accomplish this requirement? What are the properties of a "price"? Any general best practices are most welcome regarding this topic.

Was it helpful?

Solution

I'm not sure what the "best" practice is, but I've created this kind of inventory system before. You pretty much have the answer in your question - you need to track purchases by batch #.

So your inventory master would look like:

Primary_Inventory_Key
Description
LIFO_FIFO_FLAG          // if this is set at the inventory item level
...

And your Inventory Batch table would be:

 Primary_Inventory_Key
 Batch #                  // autoincrement
 // maybe PO # or something rather than these fields, depends on rest of schema
 Purchase Date            //
 Purchase Price           //
 Purchase Qty             // quantity originally purchased 
 VendorID                 

 InventoryLevel           // quantity remaining from this batch
 ...

 PRIMARYKEY(Primary_Inventory_Key,Batch#)

Then when you go to do a sale, just:

SELECT MAX(Batch#) WHERE InventoryKey = 'Mykey' AND InventoryLevel > 0

for LIFO and:

SELECT MIN(Batch#) WHERE InventoryKey = 'Mykey' AND InventoryLevel > 0

for FIFO.

You could also pull up a list and let the user select a batch with this schema.

Remember to decrement your inventory level when the transaction is committed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top