<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[FrontAccounting forum — Error while trying to edit batched invoice]]></title>
	<link rel="self" href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=4441&amp;type=atom" />
	<updated>2014-06-30T01:54:12Z</updated>
	<generator>PunBB</generator>
	<id>https://frontaccounting.com/punbb/viewtopic.php?id=4441</id>
		<entry>
			<title type="html"><![CDATA[Re: Error while trying to edit batched invoice]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=20307#p20307" />
			<content type="html"><![CDATA[<p>Hi, </p><p>I have a gotten a similar error message but under different circumstances.</p><p>I &#039;transferred&#039; information from my old software and this error happened when:</p><p>sales_order_details.id does not match up with debtor_trans_details.src_id (which i initially left as 0).</p><p>After I adjusted the src_id, eveything was fine and dandy again</p>]]></content>
			<author>
				<name><![CDATA[rave88729]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=18342</uri>
			</author>
			<updated>2014-06-30T01:54:12Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=20307#p20307</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Error while trying to edit batched invoice]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=18169#p18169" />
			<content type="html"><![CDATA[<p>Sorry, still cannot reproduce the problem. Replying the scenario does not give any errors. I think you have somewhat broken FA database. You can eventually post the bug report to mantis providing SQL dump from your database (unless it contains any confidentaila data).<br />Janusz</p>]]></content>
			<author>
				<name><![CDATA[itronics]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=89</uri>
			</author>
			<updated>2013-10-21T11:52:19Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=18169#p18169</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Error while trying to edit batched invoice]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=18087#p18087" />
			<content type="html"><![CDATA[<p>The said function that does the job is in <strong>sales/includes/db/cust_trans_db.inc</strong><br /></p><div class="codebox"><pre><code>function get_customer_trans_version($type, $trans_no) {
    if (!is_array($trans_no))
        $trans_no = array( $trans_no );

    $sql= &#039;SELECT trans_no, version FROM &#039;.TB_PREF. &#039;debtor_trans
            WHERE type=&#039;.db_escape($type).&#039; AND (&#039;;

    foreach ($trans_no as $key=&gt;$trans)
        $trans_no[$key] =     &#039;trans_no=&#039;.db_escape($trans_no[$key]);

    $sql .= implode(&#039; OR &#039;, $trans_no) . &#039;)&#039;;

    $res = db_query($sql, &#039;document version retreival&#039;);
    
    $vers = array();
    while($mysql=db_fetch($res)) {
        $vers[$mysql[&#039;trans_no&#039;]] = $mysql[&#039;version&#039;];
    }
    return $vers;
}</code></pre></div><p>If there are no transaction or just one transaction only then what would happen to the orphaned <strong>OR</strong>?</p><p>Also, there may be a typo in the field name &#039;type&#039; being &#039;tpe&#039; since both exist. The table definition is:<br /></p><div class="codebox"><pre><code>CREATE TABLE IF NOT EXISTS `0_debtor_trans` (
  `trans_no` int(11) unsigned NOT NULL default &#039;0&#039;,
  `type` smallint(6) unsigned NOT NULL default &#039;0&#039;,
  `version` tinyint(1) unsigned NOT NULL default &#039;0&#039;,
  `debtor_no` int(11) unsigned default NULL,
  `branch_code` int(11) NOT NULL default &#039;-1&#039;,
  `tran_date` date NOT NULL default &#039;0000-00-00&#039;,
  `due_date` date NOT NULL default &#039;0000-00-00&#039;,
  `reference` varchar(60) NOT NULL default &#039;&#039;,
  `tpe` int(11) NOT NULL default &#039;0&#039;,
  `order_` int(11) NOT NULL default &#039;0&#039;,
  `ov_amount` double NOT NULL default &#039;0&#039;,
  `ov_gst` double NOT NULL default &#039;0&#039;,
  `ov_freight` double NOT NULL default &#039;0&#039;,
  `ov_freight_tax` double NOT NULL default &#039;0&#039;,
  `ov_discount` double NOT NULL default &#039;0&#039;,
  `alloc` double NOT NULL default &#039;0&#039;,
  `rate` double NOT NULL default &#039;1&#039;,
  `ship_via` int(11) default NULL,
  `dimension_id` int(11) NOT NULL default &#039;0&#039;,
  `dimension2_id` int(11) NOT NULL default &#039;0&#039;,
  `payment_terms` int(11) default NULL,
  PRIMARY KEY  (`type`,`trans_no`),
  KEY `debtor_no` (`debtor_no`,`branch_code`),
  KEY `tran_date` (`tran_date`)
) ENGINE=InnoDB;</code></pre></div><p>Should the line:<br /></p><div class="codebox"><pre><code>        $trans_no[$key] =     &#039;trans_no=&#039;.db_escape($trans_no[$key]);</code></pre></div><p>be<br /></p><div class="codebox"><pre><code>        $trans_no[$key] =     &#039;trans_no=&#039;.db_escape($value);</code></pre></div><p>?</p>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2013-10-11T03:08:48Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=18087#p18087</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Error while trying to edit batched invoice]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=18042#p18042" />
			<content type="html"><![CDATA[<p>Ok so here was the process:</p><p>1) I created three delivery notes <br />2) I created a batch invoice for these three notes.</p><p>I realized that I made a mistake at this point and wanted to edit the text of the invoice so I went to &quot;Customer Transactions&quot; found the transaction and then hit the edit button. This was when I got the error. I feel like it has to do with the fact that the invoice covered multiple delivery notes, as I&#039;m able to edit other invoices.</p>]]></content>
			<author>
				<name><![CDATA[bkoncomps]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=18578</uri>
			</author>
			<updated>2013-10-04T21:02:55Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=18042#p18042</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Error while trying to edit batched invoice]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=18038#p18038" />
			<content type="html"><![CDATA[<p>I cannot reproduce the problem. What was exact order of operations resulting in this error?<br />Janusz</p>]]></content>
			<author>
				<name><![CDATA[itronics]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=89</uri>
			</author>
			<updated>2013-10-04T20:39:49Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=18038#p18038</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Error while trying to edit batched invoice]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=18026#p18026" />
			<content type="html"><![CDATA[<p>I&#039;m receiving the following error when going to */sales/customer_invoice.php?ModifyInvoice=2</p><p>DATABASE ERROR : document version retreival<br />error code : 1064<br />error message : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near &#039;)&#039; at line 2<br />sql that failed was : SELECT trans_no, version FROM 0_debtor_trans WHERE type=&#039;13&#039; AND ()</p><p>Seems like the error is in the () at the end, since that isn&#039;t good SQL but not sure how to go about fixing this.</p><p>My Setup:<br />FrontAccounting 2.3.18<br />MySQL&nbsp; 5.0.8<br />PHP 5.3.27<br />Apache 2.2.25</p>]]></content>
			<author>
				<name><![CDATA[bkoncomps]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=18578</uri>
			</author>
			<updated>2013-10-04T02:30:10Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=18026#p18026</id>
		</entry>
</feed>
