Hi

It's so wonderful to see an integrated accounting system for OFBiz. 

I've done some thinking about the algorithm used to calculate the
average cost of an inventory item, and thought I'd share it again.

Rather than trying to store an "average cost" for an item, I believe we
would be much better off storing the "total investment" for each item.

Most of the time, it won't make any difference, however I have seen that
directly storing the average cost leads to all sorts of floating point
resolution and residual adjustment issues, and complications when
purchasing inventory at a varying price. Most notably that the total
investments purchasing an item sometimes won't exactly equal the total
cost of goods expensed after it is all expended.

>From http://lists.ofbiz.org/pipermail/dev/2006-March/010207.html:

For example, if you bought a million pieces for $3,889,107,143, and sold
them out of inventory one at a time for $3.89 without tracking/updating
the residual average cost..  eventually you'd have to account for
difference of more than $800,000!

The solution:

Keep a running "total investment" for each item. At 
the point that you utilize an item, calculate and subtract 
the cost of those items rounded to a penny for example. Other 
currencies will round to the degree necessary for their currency.

The effect of doing this will be that the cost of goods will 
oscillate up and down, in the above example between 3.88, and 3.89
in such a way that when you've sold your millionth item, the 
residual investment remaining is exactly 0.

Thanks

Daniel




Reply via email to