<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[FrontAccounting forum — Update Material Cost Function]]></title>
		<link>https://frontaccounting.com/punbb/viewtopic.php?id=7929</link>
		<atom:link href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=7929&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Update Material Cost Function.]]></description>
		<lastBuildDate>Mon, 15 Jul 2019 12:16:54 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Update Material Cost Function]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=35447#p35447</link>
			<description><![CDATA[<p>Following may sounds silly but I hope you can help clarify how FA costing works since this thread just found an issue with weighted average cost </p><p>Ok everyone, in attempt to understand how FA costing and profit/sales recognition method works let&#039;s consider following 3 consecutive work orders dated 8, 9, and 10 July 2019 ( Monday to Wednesday )</p><p>date 2019/07/08 is the very first day doughnut production hence there will be no previous average_cost </p><p>date&nbsp; &nbsp; item-name&nbsp; &nbsp; qty_in&nbsp; &nbsp; price&nbsp; &nbsp; &nbsp; &nbsp; stock&nbsp; &nbsp; stock_value&nbsp; &nbsp; average_cost<br />2019/07/08&nbsp; &nbsp; doughnut&nbsp; &nbsp; 50&nbsp; &nbsp; 1.23&nbsp; &nbsp; &nbsp; &nbsp; 50&nbsp; &nbsp; 61.50&nbsp; &nbsp; 1.23<br />2019/07/09&nbsp; &nbsp; doughnut&nbsp; &nbsp; 50&nbsp; &nbsp; 1.25&nbsp; &nbsp; &nbsp; &nbsp; 100&nbsp; &nbsp; 124.00&nbsp; &nbsp; 1.24<br />2019/07/10&nbsp; &nbsp; doughnut&nbsp; &nbsp; 50&nbsp; &nbsp; 1.27&nbsp; &nbsp; &nbsp; &nbsp; 150&nbsp; &nbsp; 187.50&nbsp; &nbsp; 1.25</p><p>In my case, my admin John is responsible to enter WO transactions and Mary is responsible to enter SalesOrder transactions. John usually enters and completes WO transactions day by day while Mary only works on weekend and complete all pending SO by weekend </p><p>My question is </p><p>A. If the first SO dated 2019/07/09 for 50 item. <br />&nbsp; &nbsp; these 50 item&#039;s cost would be 50*1.23 or 50*1.25 ( latest entry average_cost ) ? </p><p>B. If the first SO dated 2019/07/12 for 50 item. <br />&nbsp; &nbsp; these 50 item&#039;s cost would be 50*1.23 or 50*1.25 ( latest entry average_cost ) ? </p><br /><p>For A and B, I believe the answer supposed to be 50*1.23 isn&#039;t it ? </p><p>But if anytime you need to do Inventory Adjustment for 50 item on or before 2019/07/10, the value would have been 50*1.25 ( by the latest entry average_cost ), is it not ? </p><br /><p>Thanks for your time</p>]]></description>
			<author><![CDATA[null@example.com (aleifuuwork)]]></author>
			<pubDate>Mon, 15 Jul 2019 12:16:54 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=35447#p35447</guid>
		</item>
		<item>
			<title><![CDATA[Re: Update Material Cost Function]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=33930#p33930</link>
			<description><![CDATA[<p>Committed and new file <a href="https://sourceforge.net/p/frontaccounting/git/ci/master/tree/manufacturing/includes/db/work_order_costing_db.inc">here</a>.</p><p>Joe</p>]]></description>
			<author><![CDATA[null@example.com (joe)]]></author>
			<pubDate>Fri, 11 Jan 2019 07:34:55 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=33930#p33930</guid>
		</item>
		<item>
			<title><![CDATA[Re: Update Material Cost Function]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=33929#p33929</link>
			<description><![CDATA[<p>@joe<br />Nothing changed in the rollback</p><p>code block from line 106 - 111 needs to be replaced with:<br /></p><div class="codebox"><pre><code>if ($qty &gt; 0 &amp;&amp; ($qoh != -$qty))
        $avg_cost = ($avg_cost*($qoh+$qty_delayed)+$unit_cost*$qty_new)/($qoh+$qty);</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (notrinos)]]></author>
			<pubDate>Thu, 10 Jan 2019 16:23:50 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=33929#p33929</guid>
		</item>
		<item>
			<title><![CDATA[Re: Update Material Cost Function]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=33927#p33927</link>
			<description><![CDATA[<p>Fixed and rolled back to repo.</p><p>New file can be downloaded <a href="https://sourceforge.net/p/frontaccounting/git/ci/master/tree/manufacturing/includes/db/work_order_costing_db.inc">here</a>.</p><p>/Joe</p>]]></description>
			<author><![CDATA[null@example.com (joe)]]></author>
			<pubDate>Wed, 09 Jan 2019 22:25:42 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=33927#p33927</guid>
		</item>
		<item>
			<title><![CDATA[Re: Update Material Cost Function]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=33926#p33926</link>
			<description><![CDATA[<p>Ok I will roll it back in a while.</p><p>Joe</p>]]></description>
			<author><![CDATA[null@example.com (joe)]]></author>
			<pubDate>Wed, 09 Jan 2019 17:15:27 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=33926#p33926</guid>
		</item>
		<item>
			<title><![CDATA[Re: Update Material Cost Function]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=33925#p33925</link>
			<description><![CDATA[<p>My pleasure. It&#039;s our product <img src="https://frontaccounting.com/punbb/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[null@example.com (boxygen)]]></author>
			<pubDate>Wed, 09 Jan 2019 17:05:17 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=33925#p33925</guid>
		</item>
		<item>
			<title><![CDATA[Re: Update Material Cost Function]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=33924#p33924</link>
			<description><![CDATA[<p>Yes @boxygen<br />Problem is not solved with new method applying to grn_db.inc<br />Thank you for correcting my serious mistake.<br />I have to find another way to get this cost value.</p><p>@joe <a href="https://sourceforge.net/p/frontaccounting/git/ci/b72c2a0476688017a61969cbc35dd7cffb4ed78e/">THIS COMMIT</a><br />needs to be rolled back.</p>]]></description>
			<author><![CDATA[null@example.com (notrinos)]]></author>
			<pubDate>Wed, 09 Jan 2019 16:44:14 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=33924#p33924</guid>
		</item>
		<item>
			<title><![CDATA[Re: Update Material Cost Function]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=33907#p33907</link>
			<description><![CDATA[<p>@notrinos please do have a closer look.</p><p>Your First para in the above post means that 55 is more accurate cost of the Item A than 60. Where will you then place the wrong Reflections in GL Transactions and Inventory Account. as shown in this <a href="http://prntscr.com/m4kt0g">image</a></p><p>I am unable to understand that why there is a special handling for a condition <strong>$qoh==0</strong> in both files <strong>grn_db.inc</strong> and <strong>work_order_costing_db.inc</strong>. This special handling is not necessary at all.</p><p>For this special condition we are taking a <strong>Non Weighted Average</strong> while if $qoh is either +ve or -ve we are taking <strong>Weighted Average</strong>.</p><p>For Calculating Average Material Cost using Non Weighted Average formula is a violation of Cost Accounting Practices irrespective of $qoh value.</p><p>I hope my explanation will help you to investigate it correctly.</p>]]></description>
			<author><![CDATA[null@example.com (boxygen)]]></author>
			<pubDate>Tue, 08 Jan 2019 18:59:55 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=33907#p33907</guid>
		</item>
		<item>
			<title><![CDATA[Re: Update Material Cost Function]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=33906#p33906</link>
			<description><![CDATA[<p>Hello @boxygen</p><p>I found the cause of this issue is not the new calculating method, it gives more accurate average cost than the old method.<br />The problem is when updated this new method for manufactured items cost we did not update the same method for component/purchased items cost so that system calculates wrong inventory values.</p><p>I guess the solution would be: lines 66, 67 of grn_db.inc needs to be replaced with<br /></p><div class="codebox"><pre><code>if ($qoh + $qty &gt; 0) {
            if($qoh == 0 &amp;&amp; $material_cost != 0)
                $material_cost = ($material_cost + $price_in_home_currency)/2;
            else
                $material_cost = ($qoh * $material_cost + $qty * $price_in_home_currency) /    ($qoh + $qty);
        }</code></pre></div><p>Will take a closer investigate tomorrow</p>]]></description>
			<author><![CDATA[null@example.com (notrinos)]]></author>
			<pubDate>Tue, 08 Jan 2019 16:47:05 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=33906#p33906</guid>
		</item>
		<item>
			<title><![CDATA[Re: Update Material Cost Function]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=33900#p33900</link>
			<description><![CDATA[<p>Yes, serious problem! will check right now</p>]]></description>
			<author><![CDATA[null@example.com (notrinos)]]></author>
			<pubDate>Tue, 08 Jan 2019 13:14:29 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=33900#p33900</guid>
		</item>
		<item>
			<title><![CDATA[Re: Update Material Cost Function]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=33899#p33899</link>
			<description><![CDATA[<p>Not at all @notrinos</p><p>I have gone through though the above post. I don&#039;t know how to fix the&nbsp; dashboard issue but this is violating standard Accounting Principles</p><p>The material cost shows the per unit average cost of the item A at any given point in time in the system. </p><p>After the step 3 the system will pass gl transaction as below </p><p>Inventory.&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 24000<br />&nbsp; &nbsp; &nbsp; &nbsp; Wip.&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 24000</p><p>While inventory valuation report will show the value of stock as 22000</p><p>Secondly if we sell all 400 in Step 4 the gl transaction will record as below </p><p>Cost of Goods Sold.&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 22000<br />&nbsp; &nbsp; &nbsp; &nbsp; Inventory.&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;22000</p><p>Hence the inventory ledger will be left with 2000 not legitimate, the profits are over valued. </p><p>@joe, @itronics, @notrinos please think over it and get it rolled back to original one.</p>]]></description>
			<author><![CDATA[null@example.com (boxygen)]]></author>
			<pubDate>Tue, 08 Jan 2019 12:53:42 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=33899#p33899</guid>
		</item>
		<item>
			<title><![CDATA[Re: Update Material Cost Function]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=33898#p33898</link>
			<description><![CDATA[<p>Yes, isn&#039;t avg cost 55 more accurate ?<br />Things are explained here: <a href="https://frontaccounting.com/punbb/viewtopic.php?id=7568">https://frontaccounting.com/punbb/viewtopic.php?id=7568</a></p>]]></description>
			<author><![CDATA[null@example.com (notrinos)]]></author>
			<pubDate>Tue, 08 Jan 2019 12:15:34 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=33898#p33898</guid>
		</item>
		<item>
			<title><![CDATA[Re: Update Material Cost Function]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=33896#p33896</link>
			<description><![CDATA[<p>@notrinos</p><p>yes I just checked the history of this file. I found that earlier it was</p><div class="codebox"><pre><code>if ($qty &gt; 0 &amp;&amp; ($qoh != -$qty))
        $avg_cost = ($avg_cost*($qoh+$qty_delayed)+$unit_cost*$qty_new)/($qoh+$qty);</code></pre></div><p>And I think this was perfect because this was taking the Weighted Average of the Item Produced</p><p>Later this was changed to</p><div class="codebox"><pre><code>if ($qty &gt; 0 &amp;&amp; ($qoh != -$qty)) {
        if ($qoh == 0 &amp;&amp; $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);
    }</code></pre></div><p>Here I am unable to understand that why we need to take Simple Average for condition<br /></p><div class="codebox"><pre><code>if ($qoh == 0 &amp;&amp; $avg_cost != 0)</code></pre></div><p>Assume following transactions<br />1. Item A was produced qty=300 with cost allocated after WO process = 50<br />2. Item A was sold qty = 300 @ 200 price<br />3. Item A was again produced qty = 400 and cost allocated after WO Process = 60</p><p>Now as per your revised condition the Average Material Cost calculation is taking the weightage of Cost 50 (Existing Avg Cost)</p><p>hence New $avg_cost will be calculated as 55</p><p>While the Old working will calculate the Weighted Average, that will Nullify the Weightage of 50 (Existing Avg Cost) and New $avg_cost will be calculated as 60, that is required.</p>]]></description>
			<author><![CDATA[null@example.com (boxygen)]]></author>
			<pubDate>Tue, 08 Jan 2019 10:26:07 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=33896#p33896</guid>
		</item>
		<item>
			<title><![CDATA[Re: Update Material Cost Function]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=33891#p33891</link>
			<description><![CDATA[<p>How wrong it was $boxygen ?<br />I&#039;m the one who created these lines</p>]]></description>
			<author><![CDATA[null@example.com (notrinos)]]></author>
			<pubDate>Tue, 08 Jan 2019 06:03:59 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=33891#p33891</guid>
		</item>
		<item>
			<title><![CDATA[Update Material Cost Function]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=33890#p33890</link>
			<description><![CDATA[<p>I have a suggestion that the function <strong>update_material_cost</strong> in manufacturing/includes/db/work_order_costing_db.inc shall be optimized or replaced with the function <strong>update_average_material_cost</strong> in purchasing/includes/db/grn_db.inc.</p><p>The former function is not calculating correct average cost with the logic defined at Line # 107</p><div class="codebox"><pre><code>if ($qoh == 0 &amp;&amp; $avg_cost != 0)
            $avg_cost = ($avg_cost + ($unit_cost*$qty_new)/$qty)/2;</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (boxygen)]]></author>
			<pubDate>Tue, 08 Jan 2019 05:03:52 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=33890#p33890</guid>
		</item>
	</channel>
</rss>
