<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[FrontAccounting forum — Invoice not converting from DN due to float bug]]></title>
		<link>https://frontaccounting.com/punbb/viewtopic.php?id=9900</link>
		<atom:link href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=9900&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Invoice not converting from DN due to float bug.]]></description>
		<lastBuildDate>Tue, 26 Jul 2022 14:59:55 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Invoice not converting from DN due to float bug]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=41295#p41295</link>
			<description><![CDATA[<p>ok great !<br />let me check, thanks again <img src="https://frontaccounting.com/punbb/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[null@example.com (dz)]]></author>
			<pubDate>Tue, 26 Jul 2022 14:59:55 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=41295#p41295</guid>
		</item>
		<item>
			<title><![CDATA[Re: Invoice not converting from DN due to float bug]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=41262#p41262</link>
			<description><![CDATA[<p>Hello again,</p><p>I found the problem. It was not inside function check_num, but from function check_quantities in customer_invoice.php and customer_delivery.php.<br />Inside these functions the $max value was calculated and due to a floating bug in PHP got a very small overlay.<br />This has been fixed in these two functions, check_quantities. </p><p>/sales/customer_delivery.php can be downloaded <a href="https://sourceforge.net/p/frontaccounting/git/ci/master/tree/sales/customer_delivery.php">here</a>.<br />/sales/customer_invoice.php can be downloaded <a href="https://sourceforge.net/p/frontaccounting/git/ci/master/tree/sales/customer_invoice.php">here</a>.</p><p>Joe</p>]]></description>
			<author><![CDATA[null@example.com (joe)]]></author>
			<pubDate>Sun, 17 Jul 2022 10:03:10 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=41262#p41262</guid>
		</item>
		<item>
			<title><![CDATA[Re: Invoice not converting from DN due to float bug]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=41261#p41261</link>
			<description><![CDATA[<p>ok Thanks joe, let me check that <img src="https://frontaccounting.com/punbb/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[null@example.com (dz)]]></author>
			<pubDate>Fri, 15 Jul 2022 20:17:29 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=41261#p41261</guid>
		</item>
		<item>
			<title><![CDATA[Re: Invoice not converting from DN due to float bug]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=41257#p41257</link>
			<description><![CDATA[<p>Hello @dz. <br />Yes I will be glad to assist, had I have a clue about this. We are working otherwise with a DELTA value in current_user.inc (about line 540), can this be used? <br />Does any expert on this have a good solution?</p><p>Joe</p>]]></description>
			<author><![CDATA[null@example.com (joe)]]></author>
			<pubDate>Fri, 15 Jul 2022 14:23:23 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=41257#p41257</guid>
		</item>
		<item>
			<title><![CDATA[Re: Invoice not converting from DN due to float bug]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=41254#p41254</link>
			<description><![CDATA[<p>@joe Kindly advise</p>]]></description>
			<author><![CDATA[null@example.com (dz)]]></author>
			<pubDate>Fri, 15 Jul 2022 09:14:20 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=41254#p41254</guid>
		</item>
		<item>
			<title><![CDATA[Invoice not converting from DN due to float bug]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=41235#p41235</link>
			<description><![CDATA[<p>While converting the delivery note to the invoice the system is showing the following error:</p><p>Selected quantity cannot be less than quantity credited nor more than quantity not invoiced yet.</p><p>To re-produce <br />1 i created an SO and DN of 28 pieces.<br />2. Invoiced 19.60 pcs<br />3. and now while invoicing the remaining 8.40 pcs i get the above error.</p><p>I have checked the above in FA&#039;s latest build as well.</p><p>While investigating i found that in the following function in data_checks.inc, the $num&gt;$max is going true. please note that both $num and $max are both 8.4, and $num can not be greater than $max.</p><p> But if i subtract $num-$max it gives me 1.7763568394003E-15(which should be zero). I googled it and found out that this is due to the shortcoming of floating point arithmetic.</p><p>Reference Function<br />function check_num($postname, $min=null, $max=null, $dflt=0) {<br />&nbsp; &nbsp; if(!isset($_POST[$postname]))<br />&nbsp; &nbsp;&nbsp; &nbsp;return 0;<br />&nbsp; &nbsp; $num = input_num($postname, $dflt);<br />&nbsp; &nbsp; if ($num === false || $num === null) <br />&nbsp; &nbsp;&nbsp; &nbsp;return 0;<br />&nbsp; &nbsp; if (isset($min) &amp;&amp; ($num&lt;$min)) <br />&nbsp; &nbsp;&nbsp; &nbsp;return 0;<br />&nbsp; &nbsp; if (isset($max) &amp;&amp; ($num&gt;$max)) <br />&nbsp; &nbsp;&nbsp; &nbsp;return 0;<br />&nbsp; &nbsp; return 1;<br />}</p><p>Should i add a rounding value like 0.00001 in $num for comparing it with $min and $max?</p><p>Kindly advise.</p>]]></description>
			<author><![CDATA[null@example.com (dz)]]></author>
			<pubDate>Wed, 06 Jul 2022 17:26:03 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=41235#p41235</guid>
		</item>
	</channel>
</rss>
