<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[FrontAccounting forum — Report: Supplier Balances - buggy]]></title>
	<link rel="self" href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=144&amp;type=atom" />
	<updated>2008-03-09T07:56:27Z</updated>
	<generator>PunBB</generator>
	<id>https://frontaccounting.com/punbb/viewtopic.php?id=144</id>
		<entry>
			<title type="html"><![CDATA[Re: Report: Supplier Balances - buggy]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=401#p401" />
			<content type="html"><![CDATA[<p>Hello again,<br />Yes it is possible to update from 1.xx to 2.0. We have prepared SQL scripts to do so, and instructions will be available.<br />Please monitor the Mailing List at <a href="http://https:/sourceforge.net/projects/frontaccounting">SourceForge</a> either by subscribing or looking at SourceForge.</p><p>/Joe</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2008-03-09T07:56:27Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=401#p401</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Report: Supplier Balances - buggy]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=400#p400" />
			<content type="html"><![CDATA[<p>Yeah i just found out, this fixes it... </p><p>By the way... is 1.16 upgradeable to 2.0?</p><p>KEEP UP THE GOOD WORK !! If i can help in anyway, e-mail me!</p><p>----- code:</p><p>&lt;?php</p><p>$page_security = 2;<br />// ----------------------------------------------------------------<br />// $ Revision:&nbsp; &nbsp; 2.0 $<br />// Creator:&nbsp; &nbsp; Joe Hunt<br />// date_:&nbsp; &nbsp; 2005-05-19<br />// Title:&nbsp; &nbsp; Supplier Balances<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;);</p><p>//----------------------------------------------------------------------------------------------------</p><p>// trial_inquiry_controls();<br />print_supplier_balances();</p><p>function getTransactions($supplier_id, $date)<br />{<br />&nbsp; &nbsp; $date = date2sql($date);<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; $sql = &quot;SELECT &quot;.TB_PREF.&quot;supp_trans.*, &quot;.TB_PREF.&quot;sys_types.type_name, <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (&quot;.TB_PREF.&quot;supp_trans.ov_amount + &quot;.TB_PREF.&quot;supp_trans.ov_gst + &quot;.TB_PREF.&quot;supp_trans.ov_discount)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AS TotalAmount, &quot;.TB_PREF.&quot;supp_trans.alloc AS Allocated,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ((&quot;.TB_PREF.&quot;supp_trans.type = 20)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AND &quot;.TB_PREF.&quot;supp_trans.due_date &lt; &#039;$date&#039;) AS OverDue<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FROM &quot;.TB_PREF.&quot;supp_trans, &quot;.TB_PREF.&quot;sys_types<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WHERE &quot;.TB_PREF.&quot;supp_trans.tran_date &lt;= &#039;$date&#039; AND &quot;.TB_PREF.&quot;supp_trans.supplier_id = &#039;$supplier_id&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AND &quot;.TB_PREF.&quot;supp_trans.type = &quot;.TB_PREF.&quot;sys_types.type_id<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ORDER BY &quot;.TB_PREF.&quot;supp_trans.tran_date&quot;;</p><p>&nbsp; &nbsp; $TransResult = db_query($sql,&quot;No transactions were returned&quot;);</p><p>&nbsp; &nbsp; return $TransResult;<br />}</p><p>//----------------------------------------------------------------------------------------------------</p><p>function print_supplier_balances()<br />{<br />&nbsp; &nbsp; global $path_to_root;</p><p>&nbsp; &nbsp; include_once($path_to_root . &quot;reporting/includes/pdf_report.inc&quot;);</p><p>&nbsp; &nbsp; $to = $_POST[&#039;PARAM_0&#039;];<br />&nbsp; &nbsp; $fromsupp = $_POST[&#039;PARAM_1&#039;];<br />&nbsp; &nbsp; $currency = $_POST[&#039;PARAM_2&#039;];<br />&nbsp; &nbsp; $comments = $_POST[&#039;PARAM_3&#039;];<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; if ($fromsupp == reserved_words::get_all_numeric())<br />&nbsp; &nbsp; &nbsp; &nbsp; $from = _(&#039;All&#039;);<br />&nbsp; &nbsp; else<br />&nbsp; &nbsp; &nbsp; &nbsp; $from = get_supplier_name($fromsupp);<br />&nbsp; &nbsp; $dec = user_price_dec();</p><p>&nbsp; &nbsp; if ($currency == reserved_words::get_all())<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; $convert = true;<br />&nbsp; &nbsp; &nbsp; &nbsp; $currency = _(&#039;Balances in Home currency&#039;);<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; else<br />&nbsp; &nbsp; &nbsp; &nbsp; $convert = false;</p><p>&nbsp; &nbsp; $cols = array(0, 100, 130, 190,&nbsp; &nbsp; 250, 320, 385, 450,&nbsp; &nbsp; 515);</p><p>&nbsp; &nbsp; $headers = array(_(&#039;Trans Type&#039;), _(&#039;#&#039;), _(&#039;Date&#039;), _(&#039;Due Date&#039;), _(&#039;Charges&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; _(&#039;Credits&#039;), _(&#039;Allocated&#039;), _(&#039;Outstanding&#039;));</p><p>&nbsp; &nbsp; $aligns = array(&#039;left&#039;,&nbsp; &nbsp; &#039;left&#039;,&nbsp; &nbsp; &#039;left&#039;,&nbsp; &nbsp; &#039;left&#039;,&nbsp; &nbsp; &#039;right&#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; &nbsp;1 =&gt; array(&#039;text&#039; =&gt; _(&#039;End Date&#039;), &#039;from&#039; =&gt; $to, &#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;Supplier&#039;), &#039;from&#039; =&gt; $from, &#039;to&#039; =&gt; &#039;&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;3 =&gt; array(&nbsp; &#039;text&#039; =&gt; _(&#039;Currency&#039;),&#039;from&#039; =&gt; $currency, &#039;to&#039; =&gt; &#039;&#039;));</p><p>&nbsp; &nbsp; $rep = new FrontReport(_(&#039;Supplier Balances&#039;), &quot;SupplierBalances.pdf&quot;, user_pagesize());</p><p>&nbsp; &nbsp; $rep-&gt;Font();<br />&nbsp; &nbsp; $rep-&gt;Info($params, $cols, $headers, $aligns);<br />&nbsp; &nbsp; $rep-&gt;Header();</p><p>&nbsp; &nbsp; $total = array();<br />&nbsp; &nbsp; $grandtotal = array();</p><p>&nbsp; &nbsp; $sql = &quot;SELECT supplier_id, supp_name AS name, curr_code FROM &quot;.TB_PREF.&quot;suppliers &quot;;<br />&nbsp; &nbsp; if ($fromsupp != reserved_words::get_all_numeric())<br />&nbsp; &nbsp; &nbsp; &nbsp; $sql .= &quot;WHERE supplier_id=$fromsupp &quot;;<br />&nbsp; &nbsp; $sql .= &quot;ORDER BY supp_name&quot;;<br />&nbsp; &nbsp; $result = db_query($sql, &quot;The customers could not be retrieved&quot;);<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; while ($myrow=db_fetch($result)) <br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; if (!$convert &amp;&amp; $currency != $myrow[&#039;curr_code&#039;])<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; continue;<br />&nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;fontSize += 2;<br />&nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(0, 3, $myrow[&#039;name&#039;]);<br />&nbsp; &nbsp; &nbsp; &nbsp; if ($convert)<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rate = get_exchange_rate_from_home_currency($myrow[&#039;curr_code&#039;], $to);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(3, 4,&nbsp; &nbsp; $myrow[&#039;curr_code&#039;]);<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; else<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rate = 1.0;<br />&nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;fontSize -= 2;<br />&nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;NewLine(1, 2);<br />&nbsp; &nbsp; &nbsp; &nbsp; $res = getTransactions($myrow[&#039;supplier_id&#039;], $to);<br />&nbsp; &nbsp; &nbsp; &nbsp; if (db_num_rows($res)==0)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; continue;<br />&nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;Line($rep-&gt;row + 4);<br />&nbsp; &nbsp; &nbsp; &nbsp; $total[0] = $total[1] = $total[2] = $total[3] = 0.0; <br />&nbsp; &nbsp; &nbsp; &nbsp; while ($trans=db_fetch($res))<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rate = get_exchange_rate_from_home_currency($myrow[&#039;curr_code&#039;], sql2date($trans[&#039;tran_date&#039;]));<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;NewLine(1, 2);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(0, 1,&nbsp; &nbsp; $trans[&#039;type_name&#039;]);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(1, 2,&nbsp; &nbsp; $trans[&#039;reference&#039;]);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(2, 3,&nbsp; &nbsp; sql2date($trans[&#039;tran_date&#039;]));<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($trans[&#039;type&#039;] == 20)&nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(3, 4,&nbsp; &nbsp; sql2date($trans[&#039;due_date&#039;]));<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $item[0] = $item[1] = 0.0;&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($trans[&#039;TotalAmount&#039;] &gt; 0.0)&nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $item[0] = Abs($trans[&#039;TotalAmount&#039;]) * $rate; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(4, 5,&nbsp; &nbsp; number_format2($item[0], $dec));<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else&nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $item[1] = Abs($trans[&#039;TotalAmount&#039;]) * $rate; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(5, 6,&nbsp; &nbsp; number_format2($item[1], $dec));<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $item[2] = $trans[&#039;Allocated&#039;] * $rate;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(6, 7,&nbsp; &nbsp; number_format2($item[2], $dec));<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($trans[&#039;type&#039;] == 20)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $item[3] = ($trans[&#039;TotalAmount&#039;] - $trans[&#039;Allocated&#039;]) * $rate; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else&nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $item[3] = ($trans[&#039;TotalAmount&#039;] + $trans[&#039;Allocated&#039;]) * $rate; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(7, 8,&nbsp; &nbsp; number_format2($item[3], $dec));<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for ($i = 0; $i &lt; 4; $i++)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $total[$i] += $item[$i];<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $grandtotal[$i] += $item[$i];<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;Line($rep-&gt;row - 8);<br />&nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;NewLine(2);<br />&nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(0, 3,&nbsp; &nbsp; _(&#039;Total&#039;));<br />&nbsp; &nbsp; &nbsp; &nbsp; for ($i = 0; $i &lt; 4; $i++)<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol($i + 4, $i + 5, number_format2($total[$i], $dec));<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $total[$i] = 0.0;<br />&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;Line($rep-&gt;row&nbsp; - 4);<br />&nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;NewLine(2);<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; $rep-&gt;fontSize += 2;<br />&nbsp; &nbsp; $rep-&gt;TextCol(0, 3,&nbsp; &nbsp; _(&#039;Grand Total&#039;));<br />&nbsp; &nbsp; $rep-&gt;fontSize -= 2;<br />&nbsp; &nbsp; for ($i = 0; $i &lt; 4; $i++)<br />&nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol($i + 4, $i + 5,number_format2($grandtotal[$i], $dec));<br />&nbsp; &nbsp; $rep-&gt;Line($rep-&gt;row&nbsp; - 4);<br />&nbsp; &nbsp; $rep-&gt;End();<br />}</p><p>?&gt;</p>]]></content>
			<author>
				<name><![CDATA[dcheng]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=148</uri>
			</author>
			<updated>2008-03-08T23:59:13Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=400#p400</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Report: Supplier Balances - buggy]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=399#p399" />
			<content type="html"><![CDATA[<p>Hello,<br />I guess you are right. The exchange rates are all calculated from the selected end date. It should be by document date.<br />We are heavily working on the release 2.0 of FrontAccounting. We will fix this in the unstable branch of the CVS repository. Later we will merge it back to release 1.16.<br />If you want to fix it now, you can move the rate calculation in rep201.php down to the record loop.</p><p>/Joe</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2008-03-08T22:45:23Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=399#p399</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Report: Supplier Balances - buggy]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=398#p398" />
			<content type="html"><![CDATA[<p>The report &quot;Supplier Balances&quot; has a bug, when you got more then one record with &quot;Supplier Invoice&quot; which in the same time has two different dates and different currency from the &quot;local&quot; one.</p><p>And yes i have set both dates ind the 0_exchange_rates... its like both records uses the same rate.. which it SHOULD NOT.</p><p>I can also program PHP and i may be able to fix this error, but i don&#039;t want to do it now bacause i want to be able to update, so i decided not to edit the code.</p><p>If you (FrontAccounting team) want my help, i will try to fix the error and contribute the change, but i just need to be sure that it will be released, so that i can follow the updates in the future without problems.</p><p>e-mail me at this address:<br />danycheng at gmail dot com</p>]]></content>
			<author>
				<name><![CDATA[dcheng]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=148</uri>
			</author>
			<updated>2008-03-08T22:02:01Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=398#p398</id>
		</entry>
</feed>
