1 (edited by yubrajkafle99 04/09/2023 05:07:51 am)

Topic: Bug in Inventory valuation Report or standard cost

Dear Developers of Front Accounting,

I am writing to inquire about the calculation of unit cost in the inventory valuation report of Front Accounting for a particular item in my inventory. The item in question is 105aps, and I have the following information:

Opening stock of 15 pieces purchased at a rate of 1,637.16
Purchase of 65 pieces at a rate of 1,708.85 in the last tax period
Purchase of 25 pieces at a rate of 2,034.51 in the last tax period
Currently, there are 9 pieces left in stock
I have noticed that the inventory valuation report in Front Accounting shows a unit cost of 1,776.15 for this item. However, I would like to understand how this unit cost is being calculated, including the purchasing prices, opening stock price, and inventory price, as well as the final unit value price.

Could you please provide me with a detailed explanation of the calculation method used to determine the unit cost in the inventory valuation report? I would greatly appreciate it if you could also provide a breakdown of the purchasing prices, opening stock price, and inventory price that contribute to the final unit value price.

Thank you for your time and assistance in this matter. I look forward to your response."

Re: Bug in Inventory valuation Report or standard cost

Opening stock of 15 pieces purchased at a rate of 1,637.16
Purchase of 10pieces at a rate of 1,708.85 in the last tax period
sales of 2 piece at a rate of 1712.38 in the last tax period
after sales purchase of 5 piece at a rate of 1708.85 in the last tax period
Currently, there are 28 pieces left in stock



Solution


alculate the unit cost of the item using the Weighted Average method:

Step 1: Calculate the total cost of the opening stock
Total cost of opening stock = 15 x 1,637.16 = 24,557.40

Step 2: Calculate the total cost of the purchases made in the last tax period
Total cost of purchases = (10 - 2 + 5) x 1,708.85 = 20,351.25

Step 3: Calculate the total cost of goods available for sale
Total cost of goods available for sale = Total cost of opening stock + Total cost of purchases = 24,557.40 + 20,351.25 = 44,908.65

Step 4: Calculate the weighted average cost per unit
Total units available for sale = Opening stock + Purchases - Sales = 15 + 10 - 2 + 5 = 28
Weighted average cost per unit = Total cost of goods available for sale / Total units available for sale = 44,908.65 / 28 = 1,603.16


as per my calculation unit price is 1603.16

but in front accounting 1776.1466666667

Re: Bug in Inventory valuation Report or standard cost

FA is using average material cost on stock items.

The operation can be seen in /purchasing/includes/db/grn_db.inc in the first function update_average_material_cost($supplier, $stock_id, $price, $qty, $date, $adj_only=false).

On line 66 you will see

$material_cost = ($qoh * $material_cost + $qty * $price_in_home_currency) /    ($qoh + $qty);

$material_cost will be current material cost multiplied by current qoh + transaction qty multiplied by price in home currency. This will then be divided by qoh + qty.
These operations will be new average material cost.
So the calculations are correctly done.

All stock transactions are going through this routine.

Joe

Re: Bug in Inventory valuation Report or standard cost

@Joe

I feel to show you something on this today. Actually i told you i cant give the issue without right decimals and values in my other post on other standard cost problem with a topic.  But i have a sample data to try this for you now.

$qoh = 0.08000000000000007; 

$qty = -0.08; 
$material_cost = 879.75;
$price_in_home_currency = 879.74550490191;

$material_cost = ($qoh * $material_cost + $qty * $price_in_home_currency) /    ($qoh + $qty);

//5182495254323.2 

if you applied get_qty_dec on $qoh, you will get only, 0.08 as stock, not with decimals.   and also for the price in home currency you dont get more than users preferred decimal. 


I told you to apply get_qty_dec and user_price_dec . run the above code and find the difference in it.

Subscription service based on FA
HRM CRM POS batch Themes

Re: Bug in Inventory valuation Report or standard cost

$kvvaradha

yes, if the ($qoh + $qty) is less than 1, there will be strange results. Before calculating this new material_cost, maybe we should first test if the (qoh + qty) >= 1. what do you think?

The routine get_unic_dec() will sometimes return -1. If the return value is -1, then the UOM is using the user defined decimals on the UOM. And should be tested by user_qty_dec(). I will check if all calls to get_unic_dec() is testing for this.
I am aware of the user_price_dec problem with material price. Maybe a standard flag on the home_currency function. to return the value without rounding. I am jsut afraid of ev. side effects. What do you think?

Joe

Re: Bug in Inventory valuation Report or standard cost

@Joe we can't check some  >= 1 . sometimes quantity can be saleable when its 0.5.  So the limit can be like you told get_unit_dec,

When it comes -1 than go with user_qty_dec and than if the rounded value is less than 0, we shouldnt update the material cost.

Also lets hear from other developer suggestion to make it better fix for this.

Subscription service based on FA
HRM CRM POS batch Themes

Re: Bug in Inventory valuation Report or standard cost

@kvvaradha

To use our weighted average material cost, we must use the same decimals in the items qty. It is this that causes our miss calculation. F.i. if you start with qoh with 0.09 our algorithm is just fine. If we use the qoh of 0.08 we will get a zero value and nothing is calculated. Just fine.

So I see no problems here.

Joe

Re: Bug in Inventory valuation Report or standard cost

That's right. So lets condition it with 

$qoh+$qty >= 1 and make the calculation call on

Subscription service based on FA
HRM CRM POS batch Themes

Re: Bug in Inventory valuation Report or standard cost

After having tested this weighted average material cost, I have found that the test for qoh > 0 and for qoh+qty > 0 will fail for very small values under 0.0000000001, so the test will be changed to test for this value instead to avoid these fails.

Joe

Post's attachments

grn_db.inc 17.1 kb, 2 downloads since 2023-04-16 

You don't have the permssions to download the attachments of this post.

Re: Bug in Inventory valuation Report or standard cost

Seems like i told before. there is chance of having inventory less than unit one full unit is also possible.  But you mentioned that, it will lead mis calculation. So lets get opinion from others and finalize it.

Subscription service based on FA
HRM CRM POS batch Themes

Re: Bug in Inventory valuation Report or standard cost

As you can only have 10 decimals (6 in UOM) in User Preference dialog the test for qoh or qoh+qty > 0.0000000001 will handle all situations now. I have made rigorious tests and it seems to handle all situations now.
All values less than 0.0000000001 will not be possible in the algorithm and no calculation will be executed.

Joe

Re: Bug in Inventory valuation Report or standard cost

I have checked. It works. You can update it .

Subscription service based on FA
HRM CRM POS batch Themes

Re: Bug in Inventory valuation Report or standard cost

Thanks @kvvaradha for participating in this discussion.

Joe

Re: Bug in Inventory valuation Report or standard cost

Hello All,

I discovered that when I use Standard Cost as my basis of Costing in FrontAccounting, there is still automatic cost update which changes the Standard Cost at interval. Is that standard Cost not working? Please advice.

Popsicles12