문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top