<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[FrontAccounting forum — Bug Found in Invoice Creation]]></title>
	<link rel="self" href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=10163&amp;type=atom" />
	<updated>2023-01-28T04:17:21Z</updated>
	<generator>PunBB</generator>
	<id>https://frontaccounting.com/punbb/viewtopic.php?id=10163</id>
		<entry>
			<title type="html"><![CDATA[Bug Found in Invoice Creation]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=41981#p41981" />
			<content type="html"><![CDATA[<p>I have been facing this issue quite a long but couldn&#039;t find the reason becuase this is not happening always but only once in 1000 attempts may be.</p><p>While Creating Invoice From Delivery Notes a function <strong>write_customer_trans_detail_item</strong> is called from customer_invoice.php with following backtrace and function arguments</p><div class="codebox"><pre><code>Function Arguments
(
    [0] =&gt; 10
    [1] =&gt; 916
    [2] =&gt; 10036
    [3] =&gt; 50/3 Polyester Color SKY 2500
    [4] =&gt; 88
    [5] =&gt; 139
    [6] =&gt; 0
    [7] =&gt; 0
    [8] =&gt; 62.160883841992
    [9] =&gt; 9783
    [10] =&gt; 9783
)
/home/sites/22a/e/eeb3fd1d98/public_html/boxyerp/sales/includes/db/sales_invoice_db.inc:122: write_customer_trans_detail_item(&#039;10&#039;,&#039;916&#039;,&#039;10036&#039;,&#039;50/3 Polyester Color SKY 2500&#039;,&#039;88&#039;,&#039;139&#039;,&#039;0&#039;,&#039;0&#039;,&#039;62.160883841992&#039;,&#039;9783&#039;,&#039;9783&#039;)

/home/sites/22a/e/eeb3fd1d98/public_html/boxyerp/sales/includes/cart_class.inc:343: write_sales_invoice((Cart Object))

/home/sites/22a/e/eeb3fd1d98/public_html/boxyerp/sales/customer_invoice.php:396: (Cart Object)-&gt;write()&lt;/td</code></pre></div><p>I have just added following lines in the beginning of function to alert the user</p><div class="codebox"><pre><code>function write_customer_trans_detail_item($debtor_trans_type, $debtor_trans_no, $stock_id, $description,
    $quantity, $unit_price, $unit_tax, $discount_percent, $std_cost, $src_id, $line_id=0)
{
    if ($debtor_trans_type == ST_SALESINVOICE &amp;&amp; $src_id == $line_id){
        display_error (&quot;High Alert. Bug Found in Invoice Creation. Please Try Again&quot;);
        exit();
    }</code></pre></div><p>Here $line_id was supposed to be Zero but it was same as $src_id and that is creating a big database anomaly.</p><p>Still trying to investigate why this happens.<br />Just sharing here if anyone else facing same issue.</p><p>Regards.</p>]]></content>
			<author>
				<name><![CDATA[boxygen]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=20175</uri>
			</author>
			<updated>2023-01-28T04:17:21Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=41981#p41981</id>
		</entry>
</feed>
