#### Topic: Update material cost when quantity on hand is zero

If we make purchase or produce a work order for an items while quantity on hand of this items is zero then item's material cost will be replaced by last transaction's price.
This is not causing overall problems but makes  a small issue which can be seen in Inventory Dashboard:
-Top 10 sold Items shows sold item's cost but in the mentioning case this cost is being constituted by the last items cost that have not been sold.

Why is this important ? In single unit production the price (material cost) of products is rarely the same, even change with large amplitude between orders

I would like to propose new calculation that calculates a more realistic costs for manufacturing items:

lines 106 - 107 of work_order_costing_db.inc should be :

``````if (\$qty > 0 && (\$qoh != -\$qty)) {
if(\$qoh == 0 && \$avg_cost != 0)
\$avg_cost = (\$avg_cost + (\$unit_cost*\$qty_new)/(\$qoh+\$qty))/2;
else
\$avg_cost = (\$avg_cost*(\$qoh+\$qty_delayed)+\$unit_cost*\$qty_new)/(\$qoh+\$qty);
}``````
Phuong

#### Re: Update material cost when quantity on hand is zero

@joe, did you check this post.

I think its good to adapt the calculation,

#### Re: Update material cost when quantity on hand is zero

Will have a look later.

Joe

#### Re: Update material cost when quantity on hand is zero

If you need to implement it this way, then the following should suffice as \$qoh=0 for the first computation:

``````if (\$qty > 0 && (\$qoh != -\$qty)) {
if(\$qoh == 0 && \$avg_cost != 0)
\$avg_cost = (\$avg_cost + (\$unit_cost*\$qty_new)/\$qty)/2;
else
\$avg_cost = (\$avg_cost*(\$qoh+\$qty_delayed)+\$unit_cost*\$qty_new)/(\$qoh+\$qty);
}``````

Hope the first computation too will remain a weighted average cost.

#### Re: Update material cost when quantity on hand is zero

This has been updated. Will be committed in a while.

/Joe

Committed