Inventory management database

I am working on an inventory management application. Here is the scenario:

- the user enters items purchased with the following information (product identifier, quantity purchased, purchase price, minimum wind price, purchase date)

each operation, the user enters items sold with the following information (Product identifier, quantity sold, final wind price, transaction date), and each operation I warned the user if the final wind price is less than the minimum wind price

every operation, wind, I recorded the benefits of the transaction (the final price wind is the purchase price)

The problem is this: you can buy the same product at a different time at a different price, then we can calculate the total benefit,

for example, if I have the following case

purchased items (t-shirt), 10, £ 20, £ 23, 08/10/2012 purchased items (t-shirt), 10, £ 22, £ 25, 08/19/2012

In this case, the wind operation, what should I do to restore the article with the correct purchase price and calculate the profit and record good information in the sales table?

+5
source share
1 answer

In finance, profit / loss is always (mostly) calculated using the FIFO rule.

That is: BUY 10 for $ 20, SELL 5 @ $ 22, BUY 5 for 21 dollars, SELL 10 @ 23, you need to write down as

BUY 10 for $20 date1
BUY 5 for $21 date3

and separately

SELL 5 @ $22 date2
SELL 10 @ $23 date4

Now you need to set the pair according to the FIFO rule and write the intermediate portfolios to the database:

portfolios AFTER date
date1  10  profit/loss $0     avg-open $20
date2  5   profit/loss +$10   avg-open $20
date3  10  protit/loss +$10   avg-open $20.50
date4  0   profit/loss +$35   avg-open $0

: date1 $20. date1 date2 , 5 * ($22 - $20 <- avg-open) = $10, 5 $20.

date2 date3 5 , / , $20,50 (5 $20 + 5 $21).

, , 10 * ($23 - $20.50) = $25 10 , 35 .

, (BUY/SELL), , / " ".

/ .

( ), , . , () .

.

+6

All Articles