<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[FrontAccounting forum — Costed Inventory Movement Report is not Reconciled]]></title>
	<link rel="self" href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=6779&amp;type=atom" />
	<updated>2017-07-21T16:02:09Z</updated>
	<generator>PunBB</generator>
	<id>https://frontaccounting.com/punbb/viewtopic.php?id=6779</id>
		<entry>
			<title type="html"><![CDATA[Re: Costed Inventory Movement Report is not Reconciled]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=28223#p28223" />
			<content type="html"><![CDATA[<p>We need to set this as a comment in the config file so that it is not used.</p><p>The line numbers stated by @boxygen are for the FA 2.4 version of <strong>reporting/rep301.php</strong>. The equivalent line numbers for FA 2.3 are 187 to 196.</p>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2017-07-21T16:02:09Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=28223#p28223</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Costed Inventory Movement Report is not Reconciled]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=28221#p28221" />
			<content type="html"><![CDATA[<p>Thanks for pointing this out. <br />We are no longer supporting release 2.3, but for those still using it they could just set the value $use_costed_values to 1 instead of 0 in config.php.</p><p>For backwards compatibility in 2.4 we will just change the value $use_costed_values to 1 in config.default.php, so all new users will automatically get this option.</p><p>Should they prefer the old method for some reason, they can set this value to 0.</p><p>Thanks @boxygen for helping with this.</p><p>/Joe</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2017-07-20T19:56:41Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=28221#p28221</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Costed Inventory Movement Report is not Reconciled]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=28220#p28220" />
			<content type="html"><![CDATA[<p>A little modification to rep301 is needed.</p><p>Replace lines from 209-218 with following lines</p><p>$UnitCost = getAverageCost($trans[&#039;stock_id&#039;], $location, $date);<br />$ItemTotal = $trans[&#039;QtyOnHand&#039;] * $UnitCost;</p><p>Hence now no need of $use_costed_values in config.php</p>]]></content>
			<author>
				<name><![CDATA[boxygen]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=20175</uri>
			</author>
			<updated>2017-07-20T17:45:56Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=28220#p28220</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Costed Inventory Movement Report is not Reconciled]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=27826#p27826" />
			<content type="html"><![CDATA[<p>Its my pleasure. Thanks for giving us such a rich platform.</p>]]></content>
			<author>
				<name><![CDATA[boxygen]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=20175</uri>
			</author>
			<updated>2017-05-15T05:08:46Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=27826#p27826</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Costed Inventory Movement Report is not Reconciled]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=27825#p27825" />
			<content type="html"><![CDATA[<p>Thanks @joe, @boxygen.</p><p><a href="https://github.com/apmuthu/frontaccounting/commit/6d3e11d7e75e53609e06c2b09e30a929766b3c3d">Committed to my repo</a> after synching the whitespaces first so that the actual changes alone can be visible clearly.</p>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2017-05-14T21:31:17Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=27825#p27825</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Costed Inventory Movement Report is not Reconciled]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=27824#p27824" />
			<content type="html"><![CDATA[<p>This has now been fixed and committed to 2.3 stable and 2.4 unstable repo.</p><p>Thanks for your participation, boxygen. You have made my day <img src="https://frontaccounting.com/punbb/img/smilies/smile.png" width="15" height="15" alt="smile" /></p><p>/Joe</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2017-05-14T19:37:14Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=27824#p27824</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Costed Inventory Movement Report is not Reconciled]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=27823#p27823" />
			<content type="html"><![CDATA[<p>Thanks boxygen.</p><p>Will look into this and optimize it. Forget my earlier files. Will remove them.</p><p>/Joe</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2017-05-14T11:58:28Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=27823#p27823</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Costed Inventory Movement Report is not Reconciled]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=27822#p27822" />
			<content type="html"><![CDATA[<p>REP308</p><p>&lt;?php<br />/**********************************************************************<br />&nbsp; &nbsp; Copyright (C) FrontAccounting, LLC.<br />&nbsp; &nbsp; Released under the terms of the GNU General Public License, GPL,<br />&nbsp; &nbsp; as published by the Free Software Foundation, either version 3<br />&nbsp; &nbsp; of the License, or (at your option) any later version.<br />&nbsp; &nbsp; This program is distributed in the hope that it will be useful,<br />&nbsp; &nbsp; but WITHOUT ANY WARRANTY; without even the implied warranty of<br />&nbsp; &nbsp; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.<br />&nbsp; &nbsp; See the License here &lt;http://www.gnu.org/licenses/gpl-3.0.html&gt;.<br />***********************************************************************/<br />$page_security = &#039;SA_ITEMSVALREP&#039;;<br />// ----------------------------------------------------------------<br />// $ Revision: &nbsp; &nbsp; 2.1 $<br />// Creator:&nbsp; &nbsp; &nbsp; &nbsp; boxygen<br />// date_:&nbsp; &nbsp; &nbsp; &nbsp; 2017-05-12<br />// Title:&nbsp; &nbsp; &nbsp; &nbsp; Costed Inventory Movements<br />// ----------------------------------------------------------------<br />$path_to_root=&quot;..&quot;;</p><p>include_once($path_to_root . &quot;/includes/session.inc&quot;);<br />include_once($path_to_root . &quot;/includes/date_functions.inc&quot;);<br />include_once($path_to_root . &quot;/includes/ui/ui_input.inc&quot;);<br />include_once($path_to_root . &quot;/includes/data_checks.inc&quot;);<br />include_once($path_to_root . &quot;/gl/includes/gl_db.inc&quot;);<br />include_once($path_to_root . &quot;/sales/includes/db/sales_types_db.inc&quot;);<br />include_once($path_to_root . &quot;/inventory/includes/inventory_db.inc&quot;);</p><p>//----------------------------------------------------------------------------------------------------</p><p>inventory_movements();</p><p>function get_domestic_price($myrow, $stock_id)<br />{<br />&nbsp; &nbsp; if ($myrow[&#039;type&#039;] == ST_SUPPRECEIVE || $myrow[&#039;type&#039;] == ST_SUPPCREDIT)<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; $price = $myrow[&#039;price&#039;];<br />&nbsp; &nbsp; &nbsp; &nbsp; if ($myrow[&#039;person_id&#039;] &gt; 0)<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Do we have foreign currency?<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $supp = get_supplier($myrow[&#039;person_id&#039;]);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $currency = $supp[&#039;curr_code&#039;];<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $ex_rate = get_exchange_rate_to_home_currency($currency, sql2date($myrow[&#039;tran_date&#039;]));<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $price /= $ex_rate;<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; else<br />&nbsp; &nbsp; &nbsp; &nbsp; $price = $myrow[&#039;standard_cost&#039;]; // Item Adjustments just have the real cost<br />&nbsp; &nbsp; return $price;<br />}</p><br /><p>function fetch_items($category=0)<br />{<br />&nbsp; &nbsp; &nbsp; &nbsp; $sql = &quot;SELECT stock_id, stock.description AS name,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stock.category_id,units,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cat.description<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FROM &quot;.TB_PREF.&quot;stock_master stock LEFT JOIN &quot;.TB_PREF.&quot;stock_category cat ON stock.category_id=cat.category_id<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WHERE mb_flag &lt;&gt; &#039;D&#039;&quot;;<br />&nbsp; &nbsp; &nbsp; &nbsp; if ($category != 0)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $sql .= &quot; AND cat.category_id = &quot;.db_escape($category);<br />&nbsp; &nbsp; &nbsp; &nbsp; $sql .= &quot; ORDER BY stock.category_id, stock_id&quot;;<br />&nbsp; &nbsp; return db_query($sql,&quot;No transactions were returned&quot;);<br />}</p><p>function trans_qty($stock_id, $location=null, $from_date, $to_date, $inward = true)<br />{<br />&nbsp; &nbsp; if ($from_date == null)<br />&nbsp; &nbsp; &nbsp; &nbsp; $from_date = Today();<br />&nbsp; &nbsp; $from_date = date2sql($from_date);<br />&nbsp; &nbsp; if ($to_date == null)<br />&nbsp; &nbsp; &nbsp; &nbsp; $to_date = Today();<br />&nbsp; &nbsp; $to_date = date2sql($to_date);<br />&nbsp; &nbsp; $sql = &quot;SELECT &quot;.($inward ? &#039;&#039; : &#039;-&#039;).&quot;SUM(qty) FROM &quot;.TB_PREF.&quot;stock_moves<br />&nbsp; &nbsp; &nbsp; &nbsp; WHERE stock_id=&quot;.db_escape($stock_id).&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; AND tran_date &gt;= &#039;$from_date&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; AND tran_date &lt;= &#039;$to_date&#039; AND type &lt;&gt; &quot;.ST_LOCTRANSFER;<br />&nbsp; &nbsp; if ($location != &#039;&#039;)<br />&nbsp; &nbsp; &nbsp; &nbsp; $sql .= &quot; AND loc_code = &quot;.db_escape($location);<br />&nbsp; &nbsp; if ($inward)<br />&nbsp; &nbsp; &nbsp; &nbsp; $sql .= &quot; AND qty &gt; 0 &quot;;<br />&nbsp; &nbsp; else<br />&nbsp; &nbsp; &nbsp; &nbsp; $sql .= &quot; AND qty &lt; 0 &quot;;<br />&nbsp; &nbsp; $result = db_query($sql, &quot;QOH calculation failed&quot;);<br />&nbsp; &nbsp; $myrow = db_fetch_row($result);<br />&nbsp; &nbsp; return $myrow[0];<br />}<br />function avg_unit_cost($stock_id, $location=null, $to_date)<br />{<br />&nbsp; &nbsp; if ($to_date == null)<br />&nbsp; &nbsp; &nbsp; &nbsp; $to_date = Today();<br />&nbsp; &nbsp; $to_date = date2sql($to_date);<br />&nbsp; &nbsp; $sql = &quot;SELECT standard_cost, price, tran_date, type, trans_no, qty, person_id&nbsp; FROM &quot;.TB_PREF.&quot;stock_moves<br />&nbsp; &nbsp; &nbsp; &nbsp; WHERE stock_id=&quot;.db_escape($stock_id).&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; AND tran_date &lt; &#039;$to_date&#039; AND standard_cost &gt; 0.001 AND qty &lt;&gt; 0 AND type &lt;&gt; &quot;.ST_LOCTRANSFER;<br />&nbsp; &nbsp; if ($location != &#039;&#039;)<br />&nbsp; &nbsp; &nbsp; &nbsp; $sql .= &quot; AND loc_code = &quot;.db_escape($location);<br />&nbsp; &nbsp; $sql .= &quot; ORDER BY tran_date&quot;;<br />&nbsp; &nbsp; $result = db_query($sql, &quot;No standard cost transactions were returned&quot;);<br />&nbsp; &nbsp; if ($result == false)<br />&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />&nbsp; &nbsp; $qty = $tot_cost = 0;<br />&nbsp; &nbsp; while ($row=db_fetch($result))<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; $qty += $row[&#039;qty&#039;];<br />&nbsp; &nbsp; &nbsp; &nbsp; $price = get_domestic_price($row, $stock_id);<br />&nbsp; &nbsp; &nbsp; &nbsp; $tran_cost = $price * $row[&#039;qty&#039;];<br />&nbsp; &nbsp; &nbsp; &nbsp; $tot_cost += $tran_cost;<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; if ($qty != 0)<br />&nbsp; &nbsp; &nbsp; &nbsp; return $tot_cost/ $qty;<br />&nbsp; &nbsp; else<br />&nbsp; &nbsp; &nbsp; &nbsp; return 0; //by Faisal<br />}<br />//----------------------------------------------------------------------------------------------------<br />function trans_qty_unit_cost($stock_id, $location=null, $from_date, $to_date, $inward = true)<br />{<br />&nbsp; &nbsp; if ($from_date == null)<br />&nbsp; &nbsp; &nbsp; &nbsp; $from_date = Today();<br />&nbsp; &nbsp; $from_date = date2sql($from_date);<br />&nbsp; &nbsp; if ($to_date == null)<br />&nbsp; &nbsp; &nbsp; &nbsp; $to_date = Today();<br />&nbsp; &nbsp; $to_date = date2sql($to_date);<br />&nbsp; &nbsp; $sql = &quot;SELECT standard_cost, price, tran_date, type, trans_no, qty, person_id FROM &quot;.TB_PREF.&quot;stock_moves<br />&nbsp; &nbsp; &nbsp; &nbsp; WHERE stock_id=&quot;.db_escape($stock_id).&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; AND tran_date &lt;= &#039;$to_date&#039; AND tran_date &gt;= &#039;$from_date&#039; AND standard_cost &gt; 0.001 AND qty &lt;&gt; 0 AND type &lt;&gt; &quot;.ST_LOCTRANSFER;<br />&nbsp; &nbsp; if ($location != &#039;&#039;)<br />&nbsp; &nbsp; &nbsp; &nbsp; $sql .= &quot; AND loc_code = &quot;.db_escape($location);<br />&nbsp; &nbsp; if ($inward)<br />&nbsp; &nbsp; &nbsp; &nbsp; $sql .= &quot; AND qty &gt; 0 &quot;;<br />&nbsp; &nbsp; else<br />&nbsp; &nbsp; &nbsp; &nbsp; $sql .= &quot; AND qty &lt; 0 &quot;;<br />&nbsp; &nbsp; $sql .= &quot; ORDER BY tran_date&quot;;<br />&nbsp; &nbsp; $result = db_query($sql, &quot;No standard cost transactions were returned&quot;);<br />&nbsp; &nbsp; if ($result == false)<br />&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />&nbsp; &nbsp; $qty = $tot_cost = 0;<br />&nbsp; &nbsp; while ($row=db_fetch($result))<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; $qty += $row[&#039;qty&#039;];<br />&nbsp; &nbsp; &nbsp; &nbsp; $price = get_domestic_price($row, $stock_id); <br />&nbsp; &nbsp; &nbsp; &nbsp; $tran_cost = $row[&#039;qty&#039;] * $price;<br />&nbsp; &nbsp; &nbsp; &nbsp; $tot_cost += $tran_cost;<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; if ($qty != 0)<br />&nbsp; &nbsp; &nbsp; &nbsp; return $tot_cost/ $qty;<br />&nbsp; &nbsp; else<br />&nbsp; &nbsp; &nbsp; &nbsp; return 0; //by Faisal<br />}</p><p>//----------------------------------------------------------------------------------------------------</p><p>function inventory_movements()<br />{<br />&nbsp; &nbsp; global $path_to_root;<br />&nbsp; &nbsp; $from_date = $_POST[&#039;PARAM_0&#039;];<br />&nbsp; &nbsp; $to_date = $_POST[&#039;PARAM_1&#039;];<br />&nbsp; &nbsp; $category = $_POST[&#039;PARAM_2&#039;];<br />&nbsp; &nbsp; $location = $_POST[&#039;PARAM_3&#039;];<br />&nbsp; &nbsp; $comments = $_POST[&#039;PARAM_4&#039;];<br />&nbsp; &nbsp; $orientation = $_POST[&#039;PARAM_5&#039;];<br />&nbsp; &nbsp; $destination = $_POST[&#039;PARAM_6&#039;];<br />&nbsp; &nbsp; if ($destination)<br />&nbsp; &nbsp; &nbsp; &nbsp; include_once($path_to_root . &quot;/reporting/includes/excel_report.inc&quot;);<br />&nbsp; &nbsp; else<br />&nbsp; &nbsp; &nbsp; &nbsp; include_once($path_to_root . &quot;/reporting/includes/pdf_report.inc&quot;);<br />&nbsp; &nbsp; $orientation = ($orientation ? &#039;L&#039; : &#039;P&#039;);<br />&nbsp; &nbsp; if ($category == ALL_NUMERIC)<br />&nbsp; &nbsp; &nbsp; &nbsp; $category = 0;<br />&nbsp; &nbsp; if ($category == 0)<br />&nbsp; &nbsp; &nbsp; &nbsp; $cat = _(&#039;All&#039;);<br />&nbsp; &nbsp; else<br />&nbsp; &nbsp; &nbsp; &nbsp; $cat = get_category_name($category);<br />&nbsp; &nbsp; if ($location == &#039;&#039;)<br />&nbsp; &nbsp; &nbsp; &nbsp; $loc = _(&#039;All&#039;);<br />&nbsp; &nbsp; else<br />&nbsp; &nbsp; &nbsp; &nbsp; $loc = get_location_name($location);<br />&nbsp; &nbsp; $cols = array(0, 60, 130, 160, 185, 215, 250, 275, 305, 340, 365, 395, 430, 455, 485, 520);<br />&nbsp; &nbsp; $headers = array(_(&#039;Category&#039;), _(&#039;Description&#039;),&nbsp; &nbsp; _(&#039;UOM&#039;), &#039;&#039;, &#039;&#039;, _(&#039;OpeningStock&#039;), &#039;&#039;, &#039;&#039;,_(&#039;StockIn&#039;), &#039;&#039;, &#039;&#039;, _(&#039;Delivery&#039;), &#039;&#039;, &#039;&#039;, _(&#039;ClosingStock&#039;));<br />&nbsp; &nbsp; $headers2 = array(&quot;&quot;, &quot;&quot;, &quot;&quot;, _(&quot;QTY&quot;), _(&quot;Rate&quot;), _(&quot;Value&quot;), _(&quot;QTY&quot;), _(&quot;Rate&quot;), _(&quot;Value&quot;), _(&quot;QTY&quot;), _(&quot;Rate&quot;), _(&quot;Value&quot;), _(&quot;QTY&quot;), _(&quot;Rate&quot;), _(&quot;Value&quot;));<br />&nbsp; &nbsp; $aligns = array(&#039;left&#039;,&nbsp; &nbsp; &#039;left&#039;,&nbsp; &nbsp; &#039;left&#039;, &#039;right&#039;, &#039;right&#039;, &#039;right&#039;, &#039;right&#039;,&#039;right&#039; ,&#039;right&#039;, &#039;right&#039;, &#039;right&#039;,&#039;right&#039;, &#039;right&#039;, &#039;right&#039;, &#039;right&#039;);<br />&nbsp; &nbsp; $params =&nbsp; &nbsp;array(&nbsp; &nbsp; &nbsp;0 =&gt; $comments,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1 =&gt; array(&#039;text&#039; =&gt; _(&#039;Period&#039;), &#039;from&#039; =&gt; $from_date, &#039;to&#039; =&gt; $to_date),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2 =&gt; array(&#039;text&#039; =&gt; _(&#039;Category&#039;), &#039;from&#039; =&gt; $cat, &#039;to&#039; =&gt; &#039;&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 3 =&gt; array(&#039;text&#039; =&gt; _(&#039;Location&#039;), &#039;from&#039; =&gt; $loc, &#039;to&#039; =&gt; &#039;&#039;));<br />&nbsp; &nbsp; $rep = new FrontReport(_(&#039;Costed Inventory Movements&#039;), &quot;CostedInventoryMovements&quot;, user_pagesize(), 8, $orientation);<br />&nbsp; &nbsp; if ($orientation == &#039;L&#039;)<br />&nbsp; &nbsp; &nbsp; &nbsp; recalculate_cols($cols);<br />&nbsp; &nbsp; $rep-&gt;Font();<br />&nbsp; &nbsp; $rep-&gt;Info($params, $cols, $headers2, $aligns, $cols, $headers, $aligns);<br />&nbsp; &nbsp; $rep-&gt;NewPage();<br />&nbsp; &nbsp; $totval_open = $totval_in = $totval_out = $totval_close = 0;<br />&nbsp; &nbsp; $result = fetch_items($category);<br />&nbsp; &nbsp; $dec = user_price_dec();<br />&nbsp; &nbsp; $catgor = &#039;&#039;;<br />&nbsp; &nbsp; while ($myrow=db_fetch($result))<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; if ($catgor != $myrow[&#039;description&#039;])<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;NewLine(2);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;fontSize += 2;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(0, 3, $myrow[&#039;category_id&#039;] . &quot; - &quot; . $myrow[&#039;description&#039;]);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $catgor = $myrow[&#039;description&#039;];<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;fontSize -= 2;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;NewLine();<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; $qoh_start = get_qoh_on_date($myrow[&#039;stock_id&#039;], $location, add_days($from_date, -1));<br />&nbsp; &nbsp; &nbsp; &nbsp; $qoh_end = get_qoh_on_date($myrow[&#039;stock_id&#039;], $location, $to_date);<br />&nbsp; &nbsp; &nbsp; &nbsp; $inward = trans_qty($myrow[&#039;stock_id&#039;], $location, $from_date, $to_date);<br />&nbsp; &nbsp; &nbsp; &nbsp; $outward = trans_qty($myrow[&#039;stock_id&#039;], $location, $from_date, $to_date, false);<br />&nbsp; &nbsp; &nbsp; &nbsp; $openCost = avg_unit_cost($myrow[&#039;stock_id&#039;], $location, $from_date);<br />&nbsp; &nbsp; &nbsp; &nbsp; $unitCost = avg_unit_cost($myrow[&#039;stock_id&#039;], $location, add_days($to_date, 1));<br />&nbsp; &nbsp; &nbsp; &nbsp; if ($qoh_start == 0 &amp;&amp; $inward == 0 &amp;&amp; $outward == 0 &amp;&amp; $qoh_end == 0)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; continue;<br />&nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;NewLine();<br />&nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(0, 1,&nbsp; &nbsp; $myrow[&#039;stock_id&#039;]);<br />&nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(1, 2, $myrow[&#039;name&#039;]);<br />&nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(2, 3, $myrow[&#039;units&#039;]);<br />&nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;AmountCol(3, 4, $qoh_start, get_qty_dec($myrow[&#039;stock_id&#039;]));<br />&nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;AmountCol(4, 5, $openCost, $dec);<br />&nbsp; &nbsp; &nbsp; &nbsp; $openCost *= $qoh_start;<br />&nbsp; &nbsp; &nbsp; &nbsp; $totval_open += $openCost;<br />&nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;AmountCol(5, 6, $openCost);<br />&nbsp; &nbsp; &nbsp; &nbsp; if($inward&gt;0){<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;AmountCol(6, 7, $inward, get_qty_dec($myrow[&#039;stock_id&#039;]));<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $unitCost_in = trans_qty_unit_cost($myrow[&#039;stock_id&#039;], $location, $from_date, $to_date);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;AmountCol(7, 8, $unitCost_in,$dec);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $unitCost_in *= $inward;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $totval_in += $unitCost_in;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;AmountCol(8, 9, $unitCost_in);<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; if($outward&gt;0){<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;AmountCol(9, 10, $outward, get_qty_dec($myrow[&#039;stock_id&#039;]));<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $unitCost_out =&nbsp; &nbsp; trans_qty_unit_cost($myrow[&#039;stock_id&#039;], $location, $from_date, $to_date, false);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;AmountCol(10, 11, $unitCost_out,$dec);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $unitCost_out *= $outward;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $totval_out += $unitCost_out;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;AmountCol(11, 12, $unitCost_out);<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;AmountCol(12, 13, $qoh_end, get_qty_dec($myrow[&#039;stock_id&#039;]));<br />&nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;AmountCol(13, 14, $unitCost,$dec);<br />&nbsp; &nbsp; &nbsp; &nbsp; $unitCost *= $qoh_end;<br />&nbsp; &nbsp; &nbsp; &nbsp; $totval_close += $unitCost;<br />&nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;AmountCol(14, 15, $unitCost);<br />&nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;NewLine(0, 1);<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; $rep-&gt;Line($rep-&gt;row&nbsp; - 4);<br />&nbsp; &nbsp; $rep-&gt;NewLine(2);<br />&nbsp; &nbsp; $rep-&gt;TextCol(0, 1,&nbsp; &nbsp; _(&quot;Total&quot;));<br />&nbsp; &nbsp; $rep-&gt;AmountCol(5, 6, $totval_open);<br />&nbsp; &nbsp; $rep-&gt;AmountCol(8, 9, $totval_in);<br />&nbsp; &nbsp; $rep-&gt;AmountCol(11, 12, $totval_out);<br />&nbsp; &nbsp; $rep-&gt;AmountCol(14, 15, $totval_close);<br />&nbsp; &nbsp; $rep-&gt;Line($rep-&gt;row&nbsp; - 4);<br />&nbsp; &nbsp; $rep-&gt;End();<br />}<br />?&gt;</p>]]></content>
			<author>
				<name><![CDATA[boxygen]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=20175</uri>
			</author>
			<updated>2017-05-14T11:57:04Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=27822#p27822</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Costed Inventory Movement Report is not Reconciled]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=27821#p27821" />
			<content type="html"><![CDATA[<p>REP301</p><p>&lt;?php<br />$page_security = &#039;SA_ITEMSVALREP&#039;;<br />// ----------------------------------------------------------------<br />// $ Revision:&nbsp; &nbsp; 2.0 $<br />// Creator:&nbsp; &nbsp; Joe Hunt<br />// date_:&nbsp; &nbsp; 2005-05-19<br />// Title:&nbsp; &nbsp; Inventory Valuation<br />// ----------------------------------------------------------------<br />$path_to_root=&quot;..&quot;;</p><p>include_once($path_to_root . &quot;/includes/session.inc&quot;);<br />include_once($path_to_root . &quot;/includes/date_functions.inc&quot;);<br />include_once($path_to_root . &quot;/includes/data_checks.inc&quot;);<br />include_once($path_to_root . &quot;/gl/includes/gl_db.inc&quot;);<br />include_once($path_to_root . &quot;/inventory/includes/db/items_category_db.inc&quot;);</p><p>//----------------------------------------------------------------------------------------------------</p><p>print_inventory_valuation_report();</p><p>function get_domestic_price($myrow, $stock_id)<br />{<br />&nbsp; &nbsp; if ($myrow[&#039;type&#039;] == ST_SUPPRECEIVE || $myrow[&#039;type&#039;] == ST_SUPPCREDIT)<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; $price = $myrow[&#039;price&#039;];<br />&nbsp; &nbsp; &nbsp; &nbsp; if ($myrow[&#039;person_id&#039;] &gt; 0)<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Do we have foreign currency?<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $supp = get_supplier($myrow[&#039;person_id&#039;]);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $currency = $supp[&#039;curr_code&#039;];<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $ex_rate = get_exchange_rate_to_home_currency($currency, sql2date($myrow[&#039;tran_date&#039;]));<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $price /= $ex_rate;<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; else<br />&nbsp; &nbsp; &nbsp; &nbsp; $price = $myrow[&#039;standard_cost&#039;]; // Item Adjustments just have the real cost<br />&nbsp; &nbsp; return $price;<br />}</p><p>function getAverageCost($stock_id, $to_date)<br />{<br />&nbsp; &nbsp; if ($to_date == null)<br />&nbsp; &nbsp; &nbsp; &nbsp; $to_date = Today();</p><p>&nbsp; &nbsp; $to_date = date2sql($to_date);</p><p>&nbsp; &nbsp; $sql = &quot;SELECT standard_cost, price, tran_date, type, trans_no, qty, person_id FROM &quot;.TB_PREF.&quot;stock_moves<br />&nbsp; &nbsp; &nbsp; &nbsp; WHERE stock_id=&quot;.db_escape($stock_id).&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; AND tran_date &lt;= &#039;$to_date&#039; AND standard_cost &gt; 0.001 AND qty &lt;&gt; 0 AND type &lt;&gt; &quot;.ST_LOCTRANSFER;</p><p>&nbsp; &nbsp; $sql .= &quot; ORDER BY tran_date&quot;;</p><p>&nbsp; &nbsp; $result = db_query($sql, &quot;No standard cost transactions were returned&quot;);<br />&nbsp; &nbsp; if ($result == false)<br />&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />&nbsp; &nbsp; $qty = $old_qty = $count = $old_std_cost = $tot_cost = 0;<br />&nbsp; &nbsp; while ($row=db_fetch($result))<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; $qty += $row[&#039;qty&#039;];</p><p>&nbsp; &nbsp; &nbsp; &nbsp; $price = get_domestic_price($row, $stock_id);</p><p>&nbsp; &nbsp; &nbsp; &nbsp; //$old_std_cost = $row[&#039;standard_cost&#039;];<br />&nbsp; &nbsp; &nbsp; &nbsp; $tran_cost = $row[&#039;qty&#039;] * $price;<br />&nbsp; &nbsp; &nbsp; &nbsp; $tot_cost += $tran_cost;<br />&nbsp; &nbsp; &nbsp; &nbsp; //$count++;<br />&nbsp; &nbsp; &nbsp; &nbsp; $old_qty = $qty;<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; if ($qty == 0)<br />&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />&nbsp; &nbsp; &nbsp; &nbsp; return $tot_cost / $qty;<br />}</p><p>function getTransactions($category, $location, $date)<br />{<br />&nbsp; &nbsp; $date = date2sql($date);</p><p>&nbsp; &nbsp; $sql = &quot;SELECT &quot;.TB_PREF.&quot;stock_master.category_id,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;.TB_PREF.&quot;stock_category.description AS cat_description,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;.TB_PREF.&quot;stock_master.stock_id,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;.TB_PREF.&quot;stock_master.units,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;.TB_PREF.&quot;stock_master.description, &quot;.TB_PREF.&quot;stock_master.inactive,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;.TB_PREF.&quot;stock_moves.loc_code,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SUM(&quot;.TB_PREF.&quot;stock_moves.qty) AS QtyOnHand,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;.TB_PREF.&quot;stock_master.material_cost + &quot;.TB_PREF.&quot;stock_master.labour_cost + &quot;.TB_PREF.&quot;stock_master.overhead_cost AS UnitCost,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SUM(&quot;.TB_PREF.&quot;stock_moves.qty) *(&quot;.TB_PREF.&quot;stock_master.material_cost + &quot;.TB_PREF.&quot;stock_master.labour_cost + &quot;.TB_PREF.&quot;stock_master.overhead_cost) AS ItemTotal<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FROM &quot;.TB_PREF.&quot;stock_master,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;.TB_PREF.&quot;stock_category,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;.TB_PREF.&quot;stock_moves<br />&nbsp; &nbsp; &nbsp; &nbsp; WHERE &quot;.TB_PREF.&quot;stock_master.stock_id=&quot;.TB_PREF.&quot;stock_moves.stock_id<br />&nbsp; &nbsp; &nbsp; &nbsp; AND &quot;.TB_PREF.&quot;stock_master.category_id=&quot;.TB_PREF.&quot;stock_category.category_id<br />&nbsp; &nbsp; &nbsp; &nbsp; AND &quot;.TB_PREF.&quot;stock_master.mb_flag&lt;&gt;&#039;D&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; AND &quot;.TB_PREF.&quot;stock_moves.tran_date &lt;= &#039;$date&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; GROUP BY &quot;.TB_PREF.&quot;stock_master.category_id,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;.TB_PREF.&quot;stock_category.description, &quot;;<br />&nbsp; &nbsp; &nbsp; &nbsp; if ($location != &#039;all&#039;)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $sql .= TB_PREF.&quot;stock_moves.loc_code, &quot;;<br />&nbsp; &nbsp; &nbsp; &nbsp; $sql .= TB_PREF.&quot;stock_master.stock_id,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;.TB_PREF.&quot;stock_master.description<br />&nbsp; &nbsp; &nbsp; &nbsp; HAVING SUM(&quot;.TB_PREF.&quot;stock_moves.qty) != 0&quot;;<br />&nbsp; &nbsp; &nbsp; &nbsp; if ($category != 0)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $sql .= &quot; AND &quot;.TB_PREF.&quot;stock_master.category_id = &quot;.db_escape($category);<br />&nbsp; &nbsp; &nbsp; &nbsp; if ($location != &#039;all&#039;)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $sql .= &quot; AND &quot;.TB_PREF.&quot;stock_moves.loc_code = &quot;.db_escape($location);<br />&nbsp; &nbsp; &nbsp; &nbsp; $sql .= &quot; ORDER BY &quot;.TB_PREF.&quot;stock_master.category_id,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;.TB_PREF.&quot;stock_master.stock_id&quot;;</p><p>&nbsp; &nbsp; return db_query($sql,&quot;No transactions were returned&quot;);<br />}</p><p>//----------------------------------------------------------------------------------------------------</p><p>function print_inventory_valuation_report()<br />{<br />&nbsp; &nbsp; global $path_to_root, $use_costed_values;;</p><p>&nbsp; &nbsp; $date = $_POST[&#039;PARAM_0&#039;];<br />&nbsp; &nbsp; $category = $_POST[&#039;PARAM_1&#039;];<br />&nbsp; &nbsp; $location = $_POST[&#039;PARAM_2&#039;];<br />&nbsp; &nbsp; $detail = $_POST[&#039;PARAM_3&#039;];<br />&nbsp; &nbsp; $comments = $_POST[&#039;PARAM_4&#039;];<br />&nbsp; &nbsp; $orientation = $_POST[&#039;PARAM_5&#039;];<br />&nbsp; &nbsp; $destination = $_POST[&#039;PARAM_6&#039;];<br />&nbsp; &nbsp; if ($destination)<br />&nbsp; &nbsp; &nbsp; &nbsp; include_once($path_to_root . &quot;/reporting/includes/excel_report.inc&quot;);<br />&nbsp; &nbsp; else<br />&nbsp; &nbsp; &nbsp; &nbsp; include_once($path_to_root . &quot;/reporting/includes/pdf_report.inc&quot;);<br />&nbsp; &nbsp; $detail = !$detail;<br />&nbsp; &nbsp; $dec = user_price_dec();</p><p>&nbsp; &nbsp; $orientation = ($orientation ? &#039;L&#039; : &#039;P&#039;);<br />&nbsp; &nbsp; if ($category == ALL_NUMERIC)<br />&nbsp; &nbsp; &nbsp; &nbsp; $category = 0;<br />&nbsp; &nbsp; if ($category == 0)<br />&nbsp; &nbsp; &nbsp; &nbsp; $cat = _(&#039;All&#039;);<br />&nbsp; &nbsp; else<br />&nbsp; &nbsp; &nbsp; &nbsp; $cat = get_category_name($category);</p><p>&nbsp; &nbsp; if ($location == ALL_TEXT)<br />&nbsp; &nbsp; &nbsp; &nbsp; $location = &#039;all&#039;;<br />&nbsp; &nbsp; if ($location == &#039;all&#039;)<br />&nbsp; &nbsp; &nbsp; &nbsp; $loc = _(&#039;All&#039;);<br />&nbsp; &nbsp; else<br />&nbsp; &nbsp; &nbsp; &nbsp; $loc = get_location_name($location);</p><p>&nbsp; &nbsp; $cols = array(0, 75, 225, 250, 350, 450,&nbsp; &nbsp; 515);</p><p>&nbsp; &nbsp; $headers = array(_(&#039;Category&#039;), &#039;&#039;, _(&#039;UOM&#039;), _(&#039;Quantity&#039;), _(&#039;Unit Cost&#039;), _(&#039;Value&#039;));</p><p>&nbsp; &nbsp; $aligns = array(&#039;left&#039;,&nbsp; &nbsp; &#039;left&#039;,&nbsp; &nbsp; &#039;left&#039;, &#039;right&#039;, &#039;right&#039;, &#039;right&#039;);</p><p>&nbsp; &nbsp; $params =&nbsp; &nbsp;array( &nbsp; &nbsp; 0 =&gt; $comments,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1 =&gt; array(&#039;text&#039; =&gt; _(&#039;End Date&#039;), &#039;from&#039; =&gt; $date, &nbsp; &nbsp; &nbsp; &nbsp; &#039;to&#039; =&gt; &#039;&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;2 =&gt; array(&#039;text&#039; =&gt; _(&#039;Category&#039;), &#039;from&#039; =&gt; $cat, &#039;to&#039; =&gt; &#039;&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;3 =&gt; array(&#039;text&#039; =&gt; _(&#039;Location&#039;), &#039;from&#039; =&gt; $loc, &#039;to&#039; =&gt; &#039;&#039;));</p><p>&nbsp; &nbsp; $rep = new FrontReport(_(&#039;Inventory Valuation Report&#039;), &quot;InventoryValReport&quot;, user_pagesize(), 9, $orientation);<br />&nbsp; &nbsp; if ($orientation == &#039;L&#039;)<br />&nbsp; &nbsp; &nbsp; &nbsp; recalculate_cols($cols);<br />&nbsp; &nbsp; $rep-&gt;Font();<br />&nbsp; &nbsp; $rep-&gt;Info($params, $cols, $headers, $aligns);<br />&nbsp; &nbsp; $rep-&gt;NewPage();</p><p>&nbsp; &nbsp; $res = getTransactions($category, $location, $date);<br />&nbsp; &nbsp; $total = $grandtotal = 0.0;<br />&nbsp; &nbsp; $catt = &#039;&#039;;<br />&nbsp; &nbsp; while ($trans=db_fetch($res))<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; if ($catt != $trans[&#039;cat_description&#039;])<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($catt != &#039;&#039;)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($detail)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;NewLine(2, 3);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(0, 4, _(&#039;Total&#039;));<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;AmountCol(5, 6, $total, $dec);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($detail)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;Line($rep-&gt;row - 2);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;NewLine();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;NewLine();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $total = 0.0;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(0, 1, $trans[&#039;category_id&#039;]);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(1, 2, $trans[&#039;cat_description&#039;]);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $catt = $trans[&#039;cat_description&#039;];<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($detail)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;NewLine();<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; if (isset($use_costed_values) &amp;&amp; $use_costed_values==1)<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $UnitCost = getAverageCost($trans[&#039;stock_id&#039;], $date);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $ItemTotal = $trans[&#039;QtyOnHand&#039;] * $UnitCost;<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; else<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $UnitCost = $trans[&#039;UnitCost&#039;];<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $ItemTotal = $trans[&#039;ItemTotal&#039;];<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; if ($detail)<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;NewLine();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;fontSize -= 2;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(0, 1, $trans[&#039;stock_id&#039;]);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(1, 2, $trans[&#039;description&#039;].($trans[&#039;inactive&#039;]==1 ? &quot; (&quot;._(&quot;Inactive&quot;).&quot;)&quot; : &quot;&quot;), -1);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(2, 3, $trans[&#039;units&#039;]);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;AmountCol(3, 4, $trans[&#039;QtyOnHand&#039;], get_qty_dec($trans[&#039;stock_id&#039;]));</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $dec2 = 0;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; price_decimal_format($UnitCost, $dec2);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;AmountCol(4, 5, $UnitCost, $dec2);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;AmountCol(5, 6, $ItemTotal, $dec);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;fontSize += 2;<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; $total += $ItemTotal;<br />&nbsp; &nbsp; &nbsp; &nbsp; $grandtotal += $ItemTotal;<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; if ($detail)<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;NewLine(2, 3);<br />&nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(0, 4, _(&#039;Total&#039;));<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; $rep-&gt;Amountcol(5, 6, $total, $dec);<br />&nbsp; &nbsp; if ($detail)<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;Line($rep-&gt;row - 2);<br />&nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;NewLine();<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; $rep-&gt;NewLine(2, 1);<br />&nbsp; &nbsp; $rep-&gt;TextCol(0, 4, _(&#039;Grand Total&#039;));<br />&nbsp; &nbsp; $rep-&gt;AmountCol(5, 6, $grandtotal, $dec);<br />&nbsp; &nbsp; $rep-&gt;Line($rep-&gt;row&nbsp; - 4);<br />&nbsp; &nbsp; $rep-&gt;NewLine();<br />&nbsp; &nbsp; $rep-&gt;End();<br />}</p><p>?&gt;</p>]]></content>
			<author>
				<name><![CDATA[boxygen]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=20175</uri>
			</author>
			<updated>2017-05-14T11:54:54Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=27821#p27821</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Costed Inventory Movement Report is not Reconciled]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=27819#p27819" />
			<content type="html"><![CDATA[<p>Hurrah,</p><p>Finally got all reports reconciled with each other as well as with GL. </p><p>However I am not claiming so please have a critical look.</p><p>I edited the function get_domestic_price() in both rep301 and rep308.</p><p>Now both of them are reconciled with each other as well as GL whether you set the flag $use_costed_value to 1 or 0.</p>]]></content>
			<author>
				<name><![CDATA[boxygen]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=20175</uri>
			</author>
			<updated>2017-05-14T11:42:50Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=27819#p27819</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Costed Inventory Movement Report is not Reconciled]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=27818#p27818" />
			<content type="html"><![CDATA[<p>There is again a logical Bug in rep301. If we set $use_costed_value = 1 it will call function getAverageCost(). In this function the algorithm to calculate Average Cost is not Weighted Average.</p><p>Please change with the following Code from Line 81 to 93</p><p>$qty += $row[&#039;qty&#039;];</p><p>&nbsp; &nbsp; &nbsp; &nbsp; $price = $row[&#039;standard_cost&#039;]; //get_domestic_price($row, $stock_id, $qty, $old_std_cost, $old_qty);</p><p>&nbsp; &nbsp; &nbsp; &nbsp; //$old_std_cost = $row[&#039;standard_cost&#039;];<br />&nbsp; &nbsp; &nbsp; &nbsp; $tran_cost = $row[&#039;qty&#039;] * $price;<br />&nbsp; &nbsp; &nbsp; &nbsp; $tot_cost += $tran_cost;<br />&nbsp; &nbsp; &nbsp; &nbsp; //$count++;<br />&nbsp; &nbsp; &nbsp; &nbsp; $old_qty = $qty;<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; if ($qty == 0)<br />&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />&nbsp; &nbsp; &nbsp; &nbsp; return $tot_cost / $qty;</p><p>Here again there is no use of function get_domestic_price.</p><p>After committing this change the Costed Inventory Valuation by rep301 is same as that of rep308.</p><p>But both these Inventory Valuations are not reconciling with that of Trial Balance.</p><p>While with value of $use_costed_value = 0 the Inventory Valuation of rep301 reconciles with Trial Balance.</p><p>So now we are in a fix whether to reconcile rep301 with rep308 or with GL.</p><p>We need to further look into it minutely that these two reports shall also match with GL.</p><p>/Faisal</p>]]></content>
			<author>
				<name><![CDATA[boxygen]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=20175</uri>
			</author>
			<updated>2017-05-14T11:03:49Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=27818#p27818</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Costed Inventory Movement Report is not Reconciled]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=27816#p27816" />
			<content type="html"><![CDATA[<p>Hello boxygen,</p><p>There is a flag in config.php, called $use_costed_values that is set to 0 by default. In that case the standard cost set in the stock_master table (the last average standard cost) is used all over the period. This is only used in rep301.php</p><p>If this flag is set to 1, it will use the costed values all over the period, and the total will be the same as in the Costed Inventory Movements.</p><p>The reason for setting this variable $use_costed_values to 0 (default) is that this also can cope with manual changes in the standard costs.</p><p>I guess we use the same algorithms for Costed Values in both rep 301 and 308. Right?</p><p>/Joe</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2017-05-14T06:46:38Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=27816#p27816</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Costed Inventory Movement Report is not Reconciled]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=27815#p27815" />
			<content type="html"><![CDATA[<p>Thanks Joe,</p><p>Its a great pleasure for me that I have contributed to FA.</p><p>We can&#039;t change rep301 because it is reconciled with the Inventory Valuation given by Trial Balance.</p><p>I am looking into this report further to have it reconciled with rep301 also.</p><p>/Faisal</p>]]></content>
			<author>
				<name><![CDATA[boxygen]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=20175</uri>
			</author>
			<updated>2017-05-14T05:21:04Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=27815#p27815</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Costed Inventory Movement Report is not Reconciled]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=27812#p27812" />
			<content type="html"><![CDATA[<p>Yes, I have been looking into this also tonight and think you are right. What you mean is to&nbsp; use to the stock_moves standard_cost instead of calcutating from the purchase price, right?</p><p>I guess your idea is better. The question is if we should change rep301 too in accordance to this. What do you think?</p><p>I have changed the copyright to FrontAccounting LLC and inserted your name as the creator. I have also optimized the report. </p><p>Please rename the file to extension php.</p><p>Can I commit this report and also in 2.4?</p><p>/Joe</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2017-05-12T22:18:53Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=27812#p27812</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Costed Inventory Movement Report is not Reconciled]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=27811#p27811" />
			<content type="html"><![CDATA[<p>The Exchange Rate Factor will only affect when we pick the rate from Supplier&#039;s table. But doing that will again disturb this report. Since I am picking the rate from stock_moves table and this rate is already adjusted by the exchange rate at the time of transaction so no need to take into account the factor of exchange rate.</p>]]></content>
			<author>
				<name><![CDATA[boxygen]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=20175</uri>
			</author>
			<updated>2017-05-12T21:42:03Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=27811#p27811</id>
		</entry>
</feed>
