<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[FrontAccounting forum — Entering invoice for tax exempt supplier results in db error?]]></title>
		<link>https://frontaccounting.com/punbb/viewtopic.php?id=7965</link>
		<atom:link href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=7965&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Entering invoice for tax exempt supplier results in db error?.]]></description>
		<lastBuildDate>Fri, 25 Jan 2019 20:47:34 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Entering invoice for tax exempt supplier results in db error?]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=34092#p34092</link>
			<description><![CDATA[<p>Ok, I have <a href="https://sourceforge.net/p/frontaccounting/git/ci/beb0a3172f74e1b02104e31a79e34a779d9ca011">fixed</a> the issue introducing direct string to numeric&nbsp; data conversion in sql query. This should fix also any problems which could arise in other places where the add_trans_tax_details is called.</p><p>Janusz</p>]]></description>
			<author><![CDATA[null@example.com (itronics)]]></author>
			<pubDate>Fri, 25 Jan 2019 20:47:34 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=34092#p34092</guid>
		</item>
		<item>
			<title><![CDATA[Re: Entering invoice for tax exempt supplier results in db error?]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=34081#p34081</link>
			<description><![CDATA[<p>You are right that my suggestion does not work, it caused sales order entry to completely fail. </p><p>The problem is not just limited to tax exempt suppliers.&nbsp; STRICT_ALL_TABLES for also caused sales order entry for an order with a tax exempt item to fail as well:</p><p>Cannot save trans tax details<br />error code : 1366<br />error message : Incorrect integer value: &#039;&#039; for column &#039;tax_type_id&#039; at row 1<br />sql that failed was : INSERT INTO 1_trans_tax_details (trans_type, trans_no, tran_date, tax_type_id, rate, ex_rate, included_in_price, net_amount, amount, memo, reg_type) VALUES (&#039;13&#039;,&#039;6083&#039;,&#039;2019-01-24&#039;,&#039;&#039;,&#039;&#039;,&#039;1&#039;,1,&#039;3.15&#039;,&#039;0&#039;,&#039;auto&#039;,NULL)</p><p>The sql failure is the same as the tax exempt supplier problem:</p><p>DATABASE ERROR : Cannot save trans tax details<br />error code : 1366<br />error message : Incorrect integer value: &#039;&#039; for column &#039;tax_type_id&#039; at row 1<br />sql that failed was : INSERT INTO 0_trans_tax_details (trans_type, trans_no, tran_date, tax_type_id, rate, ex_rate, included_in_price, net_amount, amount, memo, reg_type) VALUES (&#039;20&#039;,&#039;5&#039;,&#039;2018-12-31&#039;,&#039;&#039;,&#039;&#039;,&#039;1&#039;,0,&#039;10&#039;,&#039;0&#039;,&#039;rr8&#039;,&#039;1&#039;)</p><p>On my site, these errors are easy to reproduce.&nbsp; On the demo database, I changed DinoSaurius to Tax Exempt.&nbsp; Then I tried to create a direct supplier invoice with a single item.</p>]]></description>
			<author><![CDATA[null@example.com (Braath Waate)]]></author>
			<pubDate>Fri, 25 Jan 2019 13:23:05 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=34081#p34081</guid>
		</item>
		<item>
			<title><![CDATA[Re: Entering invoice for tax exempt supplier results in db error?]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=34079#p34079</link>
			<description><![CDATA[<p>Yes, this seems to be side effect of just introduced strict mode. But the proposed patch can have side effect too. In some countries there is existing tax rate 0% which is not the same as null tax (i.e. tax not applicable).<br />Where you encountered the problem, and which was the SQL query triggering the error?<br />Janusz</p>]]></description>
			<author><![CDATA[null@example.com (itronics)]]></author>
			<pubDate>Fri, 25 Jan 2019 09:22:56 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=34079#p34079</guid>
		</item>
		<item>
			<title><![CDATA[Re: Entering invoice for tax exempt supplier results in db error?]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=34076#p34076</link>
			<description><![CDATA[<p>Ok, but the &#039;STRICT_ALL_TABLES,NO_ZERO_IN_DATE&#039; was implemented by Janusz to prevent SQL Injections. As I told we fixed a lot of sideeffect errors, but your error was another one.</p><p>I will ask Janusz to do something about this.</p><p>/Joe</p>]]></description>
			<author><![CDATA[null@example.com (joe)]]></author>
			<pubDate>Fri, 25 Jan 2019 00:02:29 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=34076#p34076</guid>
		</item>
		<item>
			<title><![CDATA[Re: Entering invoice for tax exempt supplier results in db error?]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=34075#p34075</link>
			<description><![CDATA[<p>Modifying <strong>connect_db_mysqli.inc</strong> as notrinos suggests also fixes the problem.</p><p>My core is synced to apmuthus latest code.&nbsp; Thus it has the recent commit with SQL_MODE set to STRICT_ALL_TABLES.&nbsp; Thus it appears that this commit causes the problem.</p><p>I am using php 5.x on ubuntu 16 and php 7.2 on ubuntu 18.</p>]]></description>
			<author><![CDATA[null@example.com (Braath Waate)]]></author>
			<pubDate>Thu, 24 Jan 2019 23:20:18 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=34075#p34075</guid>
		</item>
		<item>
			<title><![CDATA[Re: Entering invoice for tax exempt supplier results in db error?]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=34074#p34074</link>
			<description><![CDATA[<p>@Braaht Waate.</p><p>Which version of PHP do you use? And did it fix the problem? </p><p>Janusz did a security update due to some report of SQL Injections. We have taken most sideeffect errors but you might have run into another one.</p><p>Joe</p>]]></description>
			<author><![CDATA[null@example.com (joe)]]></author>
			<pubDate>Thu, 24 Jan 2019 22:40:01 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=34074#p34074</guid>
		</item>
		<item>
			<title><![CDATA[Re: Entering invoice for tax exempt supplier results in db error?]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=34069#p34069</link>
			<description><![CDATA[<p>Hello Braath Waate</p><p>I have have not investigate to functions but based on your describe blank value passed to an interger column I guess this is a violation with SQL strict mode.<br />Try to change line 13 of <strong>connect_db_mysqli.inc</strong> with the following<br /></p><div class="codebox"><pre><code>define(&#039;SQL_MODE&#039;, &#039;&#039;); // STRICT_ALL_TABLES,NO_ZERO_IN_DATE ?</code></pre></div><p>and test again to see if the problem disappeared or not.</p>]]></description>
			<author><![CDATA[null@example.com (notrinos)]]></author>
			<pubDate>Thu, 24 Jan 2019 18:01:02 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=34069#p34069</guid>
		</item>
		<item>
			<title><![CDATA[Entering invoice for tax exempt supplier results in db error?]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=34068#p34068</link>
			<description><![CDATA[<p>I think it happened after I installed os updates with a mysql update on both Ubuntu 16 and 18, because it used to work fine, but I do muck with my core so maybe it is my own fault, but I couldn&#039;t see how I could have caused it.&nbsp; I will try to reproduce this on standard FA when I have a chance.&nbsp; If I can&#039;t, then I will delete this post.</p><p>Anyway, mysql failed on an insert to trans_tax_details because tax_type_id is blank and tax_type_id is defined as an integer in the table.&nbsp; It also didn&#039;t like rate set to null, which is defined as not null in the table.</p><p>I fixed the problem in my core:</p><div class="codebox"><pre><code>+++ b/core/taxes/tax_calc.inc
@@ -161,7 +161,7 @@ function get_tax_for_items($items, $prices, $shipping_cost, $tax_group, $tax_inc
                $ret_tax_array[$k][&#039;Net&#039;] = 0;
        }
        
-       $ret_tax_array[&#039;exempt&#039;] = array(&#039;Value&#039;=&gt;0, &#039;Net&#039;=&gt;0, &#039;rate&#039; =&gt; null, &#039;tax_type_id&#039; =&gt; &#039;&#039;, &#039;sales_gl_code&#039; =&gt; &#039;&#039;);
+       $ret_tax_array[&#039;exempt&#039;] = array(&#039;Value&#039;=&gt;0, &#039;Net&#039;=&gt;0, &#039;rate&#039; =&gt; 0, &#039;tax_type_id&#039; =&gt; 0, &#039;sales_gl_code&#039; =&gt; &#039;&#039;);
        $dec = user_price_dec();
        // loop for all items</code></pre></div><p>I wonder if this is some new feature of mysql and if there is some strictness configuration setting for it?&nbsp; If so, I am sure someone can enlighten me.</p>]]></description>
			<author><![CDATA[null@example.com (Braath Waate)]]></author>
			<pubDate>Thu, 24 Jan 2019 17:42:55 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=34068#p34068</guid>
		</item>
	</channel>
</rss>
