<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[FrontAccounting forum — Planned changes in stock_moves table structure in FA 2.5]]></title>
		<link>https://frontaccounting.com/punbb/viewtopic.php?id=8238</link>
		<atom:link href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=8238&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Planned changes in stock_moves table structure in FA 2.5.]]></description>
		<lastBuildDate>Thu, 04 Jul 2019 08:23:42 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Planned changes in stock_moves table structure in FA 2.5]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=35376#p35376</link>
			<description><![CDATA[<p>The said <strong>function update_stock_move()</strong> in Post #3 above is not used in any of the known extensions either now.</p>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Thu, 04 Jul 2019 08:23:42 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=35376#p35376</guid>
		</item>
		<item>
			<title><![CDATA[Re: Planned changes in stock_moves table structure in FA 2.5]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=35369#p35369</link>
			<description><![CDATA[<p>If you agree with my post#5 then</p><p>This condition<br /></p><div class="codebox"><pre><code>$types = array(ST_SUPPCREDIT, ST_SUPPRECEIVE);
            if (in_array($type, $types))
                $unit_cost = $row[&quot;price&quot;];
            else
                $unit_cost = $row[&quot;standard_cost&quot;];</code></pre></div><p>in function <strong>void_stock_move</strong> in <strong>includes/db/inventory_db.inc</strong> will be changed to</p><div class="codebox"><pre><code>$unit_cost = $row[&quot;price&quot;];</code></pre></div><p>Because now this will work for all transaction types to fetch the unit_cost affecting avg_cost.</p>]]></description>
			<author><![CDATA[null@example.com (boxygen)]]></author>
			<pubDate>Wed, 03 Jul 2019 17:46:33 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=35369#p35369</guid>
		</item>
		<item>
			<title><![CDATA[Re: Planned changes in stock_moves table structure in FA 2.5]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=35368#p35368</link>
			<description><![CDATA[<p>@itronics I have once again gone through your post#1. If I am not mistaken you are planning to use</p><p>1. avg_cost (old standard_cost) as storage for material cost before transaction and<br />2. unit_cost (old price) as storage for material_cost after transaction</p><p>??.</p><p>If yes, then this would not be OK. Although we can retrieve price from related tables for Sale and Purchase transactions but this is not true for Stock Adjustment Transactions.</p><p>So whether or not you change the name of price column, it shall contain the <strong>unit_cost</strong> that is affecting the <strong>avg_cost</strong>. So If an Item A is purchase @ $20 then supp_invoice_items.unit_price will contain $20 as well as <strong>unit_cost</strong> column in stock_moves will also contain $20.</p><p>I hope I have clarified my view point.</p>]]></description>
			<author><![CDATA[null@example.com (boxygen)]]></author>
			<pubDate>Wed, 03 Jul 2019 17:40:26 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=35368#p35368</guid>
		</item>
		<item>
			<title><![CDATA[Re: Planned changes in stock_moves table structure in FA 2.5]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=35367#p35367</link>
			<description><![CDATA[<p>on <strong>includes/db/inventory_db.inc</strong> at line # 475 we shall add this condition</p><div class="codebox"><pre><code>if ($type!=ST_LOCTRANSFER) </code></pre></div><p>before the following function call</p><div class="codebox"><pre><code>update_average_material_cost($row[&quot;supplier_id&quot;], $row[&quot;stock_id&quot;],
                    $unit_cost, -$row[&quot;qty&quot;], sql2date($row[&quot;tran_date&quot;]), false, &quot;Void Stock Move # $type_no and type = $type_no&quot;);</code></pre></div><p><strong>Rationale</strong></p><p>There is no reason for updating average cost while Voiding Stock Move due to Location Transfer. The inventory is neither gaining not loosing here.</p><p>If we don&#039;t do this then Avg Unit Cost is adversely affected. Because the stock_moves table doesn&#039;t contain any price for Location Transfer hence $unit_cost parameter passed to update_average_material_cost is ZERO so the resulting weighted average is not correct at the end of transaction.</p>]]></description>
			<author><![CDATA[null@example.com (boxygen)]]></author>
			<pubDate>Wed, 03 Jul 2019 11:31:02 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=35367#p35367</guid>
		</item>
		<item>
			<title><![CDATA[Re: Planned changes in stock_moves table structure in FA 2.5]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=35366#p35366</link>
			<description><![CDATA[<div class="codebox"><pre><code>function update_stock_move($type, $trans_no, $stock_id, $cost)
{
    $sql = &quot;UPDATE &quot;.TB_PREF.&quot;stock_moves SET standard_cost=&quot;.db_escape($cost)
            .&quot; WHERE type=&quot;.db_escape($type)
            .&quot;    AND trans_no=&quot;.db_escape($trans_no)
            .&quot;    AND stock_id=&quot;.db_escape($stock_id);
    db_query($sql, &quot;The stock movement standard_cost cannot be updated&quot;);
}</code></pre></div><p>This function on includes/db/inventory_db.inc is not called from anywhere</p>]]></description>
			<author><![CDATA[null@example.com (boxygen)]]></author>
			<pubDate>Wed, 03 Jul 2019 10:54:29 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=35366#p35366</guid>
		</item>
		<item>
			<title><![CDATA[Re: Planned changes in stock_moves table structure in FA 2.5]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=35301#p35301</link>
			<description><![CDATA[<div class="codebox"><pre><code>`standard_cost` changed to `avg_cost` - store for item average cost (stock_master.material_cost)  before transaction</code></pre></div><p>I think is the store of average cost <strong>after transaction</strong>. the resulting average cost of the item due the unit_cost being used in the transaction.</p>]]></description>
			<author><![CDATA[null@example.com (boxygen)]]></author>
			<pubDate>Sun, 23 Jun 2019 13:05:40 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=35301#p35301</guid>
		</item>
		<item>
			<title><![CDATA[Planned changes in stock_moves table structure in FA 2.5]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=35294#p35294</link>
			<description><![CDATA[<p>In FA 2.4 table stock_moves was designed as log of changes in inventory, but due to some inconsistencies in table&#039;s fields usage in the code, when some costing problem appears it is not easy to track where the problem arose. Therefore we plan to change stock_moves structure in next major release, to make it better also for inventory cost tracking purposes.</p><p>Following changes are planned:<br />1. &#039;reference&#039; field removed<br /> Rationale: this field is both not used and double redundant to refs table and reference fields in respective transaction tables.<br />2. `standard_cost` changed to `avg_cost` - store for item average cost (stock_master.material_cost)&nbsp; before transaction<br /> Rationale: while this field is not strictly necessary, it make tracking average cost changes easier. BTW the standard_cost name is just historical artefact not&nbsp; related to what is stored here now;<br />3. `price` superseded by `unit_cost` - store for unit_cost in transaction<br />Rationale: currently price field is used for cost calculations, while this is the cost which is needed finally. Price is stored in transaction lines records, and always can be retrieved if needed.</p><p>Finally planned stock_moves table structure in FA 2.5:<br /></p><div class="codebox"><pre><code>CREATE TABLE `0_stock_moves` (
  `trans_id` int(11) NOT NULL AUTO_INCREMENT,
  `type` smallint(6) NOT NULL DEFAULT &#039;0&#039;,
  `trans_no` int(11) NOT NULL DEFAULT &#039;0&#039;,
  `stock_id` char(20) NOT NULL DEFAULT &#039;&#039;,
  `loc_code` char(5) NOT NULL DEFAULT &#039;&#039;,
  `tran_date` date NOT NULL DEFAULT &#039;0000-00-00&#039;,
  `qty` double NOT NULL DEFAULT &#039;1&#039;,
  `unit_cost` double NOT NULL DEFAULT &#039;0&#039;,
  `avg_cost` double NOT NULL DEFAULT &#039;0&#039;, 
  
  PRIMARY KEY (`trans_id`),
  KEY `type` (`type`,`trans_no`),
  KEY `Move` (`stock_id`,`loc_code`,`tran_date`)
) ENGINE=InnoDB;</code></pre></div><p>All comments are welcome.<br />J.</p>]]></description>
			<author><![CDATA[null@example.com (itronics)]]></author>
			<pubDate>Sun, 23 Jun 2019 11:16:25 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=35294#p35294</guid>
		</item>
	</channel>
</rss>
