<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[FrontAccounting forum — Some changes in add_supp_invoice to reduce unnecessary query run time]]></title>
		<link>https://frontaccounting.com/punbb/viewtopic.php?id=8336</link>
		<atom:link href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=8336&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Some changes in add_supp_invoice to reduce unnecessary query run time.]]></description>
		<lastBuildDate>Tue, 20 Aug 2019 14:53:51 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Some changes in add_supp_invoice to reduce unnecessary query run time]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=35750#p35750</link>
			<description><![CDATA[<p>Sure I will write my part of changes and bug fixes and ideas too.</p>]]></description>
			<author><![CDATA[null@example.com (kvvaradha)]]></author>
			<pubDate>Tue, 20 Aug 2019 14:53:51 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=35750#p35750</guid>
		</item>
		<item>
			<title><![CDATA[Re: Some changes in add_supp_invoice to reduce unnecessary query run time]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=35738#p35738</link>
			<description><![CDATA[<p>Forecasting from how many years it took to come in from FA 2.3 to FA 2.4 and the fact that the devs are much older now, take it to be atleast 5 years from when the <a href="https://github.com/FrontAccountingERP/FA/tree/unstable">initial 2.5 branch</a> began. If it is any sooner, thank the advances in coding technologies and that we are now older and wiser <img src="https://frontaccounting.com/punbb/img/smilies/wink.png" width="15" height="15" alt="wink" /></p><p>@kvvaradha: Whatever changes you have in mind to make a start, do let us know here so that it can atleast get into the codebase for those who wish to benefit from it in the meanwhile and form part of FA 2.5 if and when it appears.</p><p>Aug 17th 2019 - probably last commit to the 2.4(.7) branch.<br />Aug 19th 2019 - first commit to merge stable into unstable for 2.5 branch</p>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Mon, 19 Aug 2019 17:01:00 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=35738#p35738</guid>
		</item>
		<item>
			<title><![CDATA[Re: Some changes in add_supp_invoice to reduce unnecessary query run time]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=35736#p35736</link>
			<description><![CDATA[<p>ok.So when it will be released&nbsp; officially.</p>]]></description>
			<author><![CDATA[null@example.com (kvvaradha)]]></author>
			<pubDate>Mon, 19 Aug 2019 09:31:52 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=35736#p35736</guid>
		</item>
		<item>
			<title><![CDATA[Re: Some changes in add_supp_invoice to reduce unnecessary query run time]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=35724#p35724</link>
			<description><![CDATA[<p>Hello again.</p><p>As I feared, Janusz is about a major rewrite in 2.5 just inside this too. </p><p>He also want to wait until 2.5 implementing this.</p><p>Joe</p>]]></description>
			<author><![CDATA[null@example.com (joe)]]></author>
			<pubDate>Sun, 18 Aug 2019 11:06:39 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=35724#p35724</guid>
		</item>
		<item>
			<title><![CDATA[Re: Some changes in add_supp_invoice to reduce unnecessary query run time]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=35722#p35722</link>
			<description><![CDATA[<p>You may be right. I will just sync with Janusz regarding this.</p><p>Joe</p>]]></description>
			<author><![CDATA[null@example.com (joe)]]></author>
			<pubDate>Sun, 18 Aug 2019 07:23:43 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=35722#p35722</guid>
		</item>
		<item>
			<title><![CDATA[Re: Some changes in add_supp_invoice to reduce unnecessary query run time]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=35719#p35719</link>
			<description><![CDATA[<p>Since this does not affect the DB schema, can we not make a start here?</p>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Sun, 18 Aug 2019 06:13:44 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=35719#p35719</guid>
		</item>
		<item>
			<title><![CDATA[Re: Some changes in add_supp_invoice to reduce unnecessary query run time]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=35713#p35713</link>
			<description><![CDATA[<p>You are right guys. However this is quite a change in several files so I would like to do this in release 2.5. I will make a note about this.</p><p>/Joe</p>]]></description>
			<author><![CDATA[null@example.com (joe)]]></author>
			<pubDate>Sat, 17 Aug 2019 21:50:48 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=35713#p35713</guid>
		</item>
		<item>
			<title><![CDATA[Re: Some changes in add_supp_invoice to reduce unnecessary query run time]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=35706#p35706</link>
			<description><![CDATA[<p>Putting it in a variable and then using it everywhere will make sense.<br />@joe?</p>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Sat, 17 Aug 2019 13:33:29 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=35706#p35706</guid>
		</item>
		<item>
			<title><![CDATA[Re: Some changes in add_supp_invoice to reduce unnecessary query run time]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=35687#p35687</link>
			<description><![CDATA[<p>Even, we can pass the same currency to </p><div class="codebox"><pre><code> get_diff_in_home_currency($supp_trans-&gt;supplier_id, $old_date, $date_, $old_value,     $taxfree_line, $currency); </code></pre></div><p>this will reduce a bit more <br /></p><div class="codebox"><pre><code>function get_diff_in_home_currency($supplier, $old_date, $date, $amount1, $amount2,$currency=null)
{
    $dec = user_price_dec();
    price_decimal_format($amount2, $dec);
if($currency == null)
    $currency = get_supplier_currency($supplier);
    $ex_rate = get_exchange_rate_to_home_currency($currency, $old_date);
    $amount1 = $amount1 / $ex_rate;
    $ex_rate = get_exchange_rate_to_home_currency($currency, $date);
    $amount2 = $amount2 / $ex_rate;
    $diff = $amount2 - $amount1;
    //return round2($diff, $dec);
    return $diff;
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (kvvaradha)]]></author>
			<pubDate>Fri, 16 Aug 2019 17:08:28 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=35687#p35687</guid>
		</item>
		<item>
			<title><![CDATA[Some changes in add_supp_invoice to reduce unnecessary query run time]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=35686#p35686</link>
			<description><![CDATA[<p>As i have seen some queries which unnecesaarily runs within loops or its called multiple times to pass it to another data. There is one recent one I am bring here to update the core makes simple. </p><p>/purchasing/includes/db/invoice_db.inc</p><p>From the add_supp_invoice function, there is items line foreach which has a function inside it <br /></p><div class="codebox"><pre><code>$currency = get_supplier_currency($supp_trans-&gt;supplier_id);</code></pre></div><p> This actually no point to run within items loop, just imagine, if the user add 50 items in one invoice and tries to save. this query runs 49 times unnecessarily.&nbsp; and also one more thing with the same function.</p><p>From this function <br /></p><div class="codebox"><pre><code>function add_gl_trans_supplier($type, $type_no, $date_, $account, $dimension, $dimension2,  
    $amount, $supplier_id, $err_msg=&quot;&quot;, $rate=0, $memo=&quot;&quot;)
{
    if ($err_msg == &quot;&quot;)
        $err_msg = &quot;The supplier GL transaction could not be inserted&quot;;    
        
    return add_gl_trans($type, $type_no, $date_, $account, $dimension, $dimension2, $memo, 
        $amount, get_supplier_currency($supplier_id), 
        PT_SUPPLIER, $supplier_id, $err_msg, $rate);
}</code></pre></div><p> This is acutally calls more than once for a single item. during the same invoice process. here looks this code.&nbsp; </p><div class="codebox"><pre><code>get_supplier_currency($supplier_id), </code></pre></div><p>it runs more than 100 times as of my above example.&nbsp; So its better take out this and pass one more parameter in the </p><div class="codebox"><pre><code> add_gl_trans_supplier</code></pre></div><p> like this <br /></p><div class="codebox"><pre><code> add_gl_trans_supplier($type, $type_no, $date_, $account, $dimension, $dimension2,  
    $amount, $supplier_id, $err_msg=&quot;&quot;, $rate=0, $memo=&quot;&quot;, $currency=null){
      if ($err_msg == &quot;&quot;)
        $err_msg = &quot;The supplier GL transaction could not be inserted&quot;;    
    if($currency == null )
        $currrency = get_supplier_currency($supplier_id);
    return add_gl_trans($type, $type_no, $date_, $account, $dimension, $dimension2, $memo, 
        $amount, $currency, 
        PT_SUPPLIER, $supplier_id, $err_msg, $rate);
}</code></pre></div><p>. This will simplify more than 150 query load to server when we submit 50 items invoice. </p><p>@Joe,And @Janusz, Hope you guys get the point.</p>]]></description>
			<author><![CDATA[null@example.com (kvvaradha)]]></author>
			<pubDate>Fri, 16 Aug 2019 17:06:23 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=35686#p35686</guid>
		</item>
	</channel>
</rss>
