<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[FrontAccounting forum — need retrieving tax rate per item during invoice generation]]></title>
	<link rel="self" href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=5603&amp;type=atom" />
	<updated>2015-09-13T15:11:17Z</updated>
	<generator>PunBB</generator>
	<id>https://frontaccounting.com/punbb/viewtopic.php?id=5603</id>
		<entry>
			<title type="html"><![CDATA[Re: need retrieving tax rate per item during invoice generation]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=24267#p24267" />
			<content type="html"><![CDATA[<p>v2.4 is in beta. The stable one is v2.3.24+ snapshot?</p>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2015-09-13T15:11:17Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=24267#p24267</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: need retrieving tax rate per item during invoice generation]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=24263#p24263" />
			<content type="html"><![CDATA[<p>Just wondering if there is an update on this. I would like to implement this as well. I am using 2.4 at this point.</p>]]></content>
			<author>
				<name><![CDATA[JeremyK]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=20702</uri>
			</author>
			<updated>2015-09-12T19:13:02Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=24263#p24263</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: need retrieving tax rate per item during invoice generation]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=22984#p22984" />
			<content type="html"><![CDATA[<p>The latest is in the Official Git Repo. </p><p><a href="http://devel.frontaccounting.com/git/?p=fa-stable.git;a=summary">http://devel.frontaccounting.com/git/?p … ;a=summary</a></p><p>FA v2.3.23 has been released today.</p>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2015-03-23T20:25:49Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=22984#p22984</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: need retrieving tax rate per item during invoice generation]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=22978#p22978" />
			<content type="html"><![CDATA[<p>I am running ver. 2.3.22 (which I believed to be the last one).</p><p>I noticed some differences between the version I&#039;m running and the one you suggested to use as a comparison version.</p><p>Which of the two is the latest?</p>]]></content>
			<author>
				<name><![CDATA[carlo]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=18764</uri>
			</author>
			<updated>2015-03-22T20:11:21Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=22978#p22978</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: need retrieving tax rate per item during invoice generation]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=22975#p22975" />
			<content type="html"><![CDATA[<p>Take the latest FA snapshot from the <a href="http://devel.frontaccounting.com/git/?p=fa-stable.git;a=snapshot;h=50fc96f78cf659a8232f7dd9b45d7eb8bb95beaa;sf=tgz">official Git Repo</a>.</p>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2015-03-22T18:14:59Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=22975#p22975</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: need retrieving tax rate per item during invoice generation]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=22971#p22971" />
			<content type="html"><![CDATA[<p>working on a PDF to explain what I did so far.<br />I just need to download a &quot;virgin&quot; FA and compare files with mine since I was so stupid not to keep an efficient track of changes.<br />I may take a few days to complete the doc and then I&#039;ll post it.</p><p>I have already uploaded the code, together with a backup of the DB (under company/0/backup) named </p><p>antemovimenti.sql </p><p>(which is a today&#039;s backup).</p><p>You may download the zip file from</p><p>http://FAdev.gelatiflor.net/erp20150322.zip</p><p>Needless to say, since I am just a mere newbie with PHP, I am certain that there will be many naiveties in my code.</p><p>I&#039;m here to learn, please.</p><p>Best and thanks,</p><p>Carlo</p>]]></content>
			<author>
				<name><![CDATA[carlo]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=18764</uri>
			</author>
			<updated>2015-03-22T01:38:34Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=22971#p22971</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: need retrieving tax rate per item during invoice generation]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=22944#p22944" />
			<content type="html"><![CDATA[<p>Create a page in the wiki detailing your solution - it will be a nice resource for the community. Alternatively, prepare a PDF document about what changes need to be done, complete with code files and zip them and upload them somewhere and then post your link here.</p>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2015-03-19T15:39:19Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=22944#p22944</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: need retrieving tax rate per item during invoice generation]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=22925#p22925" />
			<content type="html"><![CDATA[<p>Hi all.<br />I actually solved the whole problem by adding a few functions (most of the credit goes to apmuthu, to be frank), although I needed to alter a few tables in the DB in order to accomodate historically the bit of info so obtained.<br />I&#039;d like to share it with the community if there is any interest.<br />I have no idea how to do that, though.<br />Any help, if interested, will be appreciated.<br />Carlo</p>]]></content>
			<author>
				<name><![CDATA[carlo]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=18764</uri>
			</author>
			<updated>2015-03-17T20:08:28Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=22925#p22925</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: need retrieving tax rate per item during invoice generation]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=22876#p22876" />
			<content type="html"><![CDATA[<p>At the moment, just increase the number of decimal places in the <strong>Setup =&gt; Display Setup</strong> and round off the field in the report to 2 decimal places.</p><p>FA v2.4 has been in the making for quite a few years now....a few more months to wait is okay perhaps....</p>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2015-03-13T14:32:25Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=22876#p22876</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: need retrieving tax rate per item during invoice generation]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=22872#p22872" />
			<content type="html"><![CDATA[<p>Hello,<br />janusz is planning to have this work in release 2.4. This is already implementid in a local Polish project.</p><p>Joe</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2015-03-12T17:30:40Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=22872#p22872</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: need retrieving tax rate per item during invoice generation]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=22871#p22871" />
			<content type="html"><![CDATA[<p>Hi dls.<br />The data you mention are those already used in the bottom summary.<br />get_trans_tax_details(ST_SALESINVOICE, $I) is already a summary and is not item related.<br />It is a summary of all items using each single $tax_item[&#039;rate&#039;].<br />That is of little use when trying to single out each item&#039;s rate and it is calculated AFTER the call for each item in a separate array.<br />I&#039;ll see if I can create a function with my little PHP knowledge.<br />In the meantime, whenever you or others have time, any hint will be more than appreciated.<br />Best,<br />Carlo</p>]]></content>
			<author>
				<name><![CDATA[carlo]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=18764</uri>
			</author>
			<updated>2015-03-12T13:46:26Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=22871#p22871</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: need retrieving tax rate per item during invoice generation]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=22868#p22868" />
			<content type="html"><![CDATA[<p>Carlo<br />I see the problem. The required data is available in the trans_tax_details table which is accessed lower down in the report -get_trans_tax_details(ST_SALESINVOICE, $I)&nbsp; &nbsp;and the data is used -(&quot;.$tax_item[&#039;rate&#039;].&quot;%) </p><p>One approach is therefore to get that data and incorporate appropriately. I am working on other things at the moment, but I would look further into that. Sorry I can&#039;t be more help at this time.</p>]]></content>
			<author>
				<name><![CDATA[dls]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=699</uri>
			</author>
			<updated>2015-03-11T23:27:52Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=22868#p22868</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: need retrieving tax rate per item during invoice generation]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=22862#p22862" />
			<content type="html"><![CDATA[<p>Thank you dls.<br />Unfortunately this is not sufficient.<br />Let me better explain:</p><p>Let&#039;s start with the result.<br />See here a new template for invoice<br />(I am sorry it&#039;s in dual language at the moment so I provide only the landscape version and I apologise using my company details on that)</p><p>http://printdemo.gelatiflor.net/wrong_invoice.pdf</p><p>Some background:<br />We have 5 VAT rates used in this invoice, specifically 22%, 10%, 4%, 0% for a reason, 0% for another reason.</p><p>The 2 zero rate items are fictionary and they refer to a sale outside EU (E1) and to a sale within EU (E2). </p><p>The items are self explanatory and, for the example, are named A22, A10, A4, E1 and E2 (incidentally they are all services so I didn&#039;t have to bother with inventory for each of the numerous tests I did)</p><p>My goal was to show the VAT rate per each item in the invoice and then, at the end of the invoice, show a summary of all VAT rates involved, with a sum of taxable amount and a total of taxes amounts.</p><p>I already managed to have the summary adjust its size according to the number of lines it contains. No big deal but I hope that the layout of the invoice is more readable and more attractive this way.</p><p>The solution you provide (which you correctly state is taken from elsewhere in the Forum) shows the VAT rate (or better say the tax rate) with a reverse calculation based on taxable amount and tax amount.</p><p>That is what I used too.</p><p>Now look at the last line of page 2.</p><p>I intentionally used a very low value as the price for a given item.<br />Specifically 1.58<br />Then I applied a discount of 25%<br />on the net price I calculated 4% of VAT.<br />These are the non rounded results:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />Net price&nbsp; &nbsp; <br />1.185<br />Tax&nbsp; &nbsp; <br />0.0474<br />Total&nbsp; &nbsp; <br />1.2324<br />Naturally, if I reverse calculate the tax, it shows 4.00%<br />If I round values to cents (as it is for the far majority of cases) these are the results:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />Net price&nbsp; &nbsp; <br />1.19<br />Tax<br />0.05&nbsp; &nbsp; <br />Total&nbsp; &nbsp; <br />1.24<br />These values are more than fine for the GL as rounding is a necessity.<br />If I now try and calculate the tax percentage with the formula that is e.g. in rep107 (untouched) which shows:<br />$DisplayTaxRate = number_format2($myrow2[&quot;unit_tax&quot;] * 100 / $myrow2[&quot;unit_price&quot;], user_percent_dec()) . &quot;%&quot;;</p><p>The result is shown there and it&#039;s obviously wrong.</p><p>At first I thought to create or use an already created function to retrieve the tax rate for each item in the invoice and use that to print the associated tax rate.</p><p>Bear in mind that this is just to show the rate on the invoice, not to change the posts on GL because they are correct and rounded as they should.</p><p>If I increase the number of decimals in my preferences I get the right result but I cannot show amounts wiht less than cents (or pence, if you like) because that would be obviously wrong for accounting and VAT reports (of whichever nature they were).<br />Using a function could be a solution if tax rates were not subjected to changes from time to time.<br />(imagine UK VAT 17.5% increased to 19%: each re-print of the invoice would show the wrong tax rates)</p><p>That means that the tax rate must be filed with the value AT THE TIME OF ORIGINAL TRANSACTION.</p><p>The simplest solution, which would NOT bother the DB but in a very minimal way, would be –to my humble opinion- to add a field, say taxrate, in debtor_trans_details.</p><p>No big deal, I guess.</p><p>Nevertheless that would be a sort of problem in future updates or versions of FA.</p><p>As you can see, my invoice template is compliant with EU vat rules and, presumably, also with the UK ones.</p><p>I am relatively new to the forum and do not even know where or to whom I should ask for these relatively small changes.</p><p>Any hint on how to solve the problem?</p><p>Sorry for the lengthy replay but I needed to fully explain the context.</p><p>Best and thanks again,</p><p>Carlo</p>]]></content>
			<author>
				<name><![CDATA[carlo]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=18764</uri>
			</author>
			<updated>2015-03-11T13:02:56Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=22862#p22862</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: need retrieving tax rate per item during invoice generation]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=22851#p22851" />
			<content type="html"><![CDATA[<p>Hi Carlo</p><p>Try the one below. From what you say I think it should fit your requirements. - It is available elsewhere on this forum. </p><br /><p>&lt;?php<br />/**********************************************************************<br />&nbsp; &nbsp; Copyright (C) FrontAccounting, LLC.<br />&nbsp; &nbsp; Released under the terms of the GNU General Public License, GPL, <br />&nbsp; &nbsp; as published by the Free Software Foundation, either version 3 <br />&nbsp; &nbsp; of the License, or (at your option) any later version.<br />&nbsp; &nbsp; This program is distributed in the hope that it will be useful,<br />&nbsp; &nbsp; but WITHOUT ANY WARRANTY; without even the implied warranty of<br />&nbsp; &nbsp; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.&nbsp; <br />&nbsp; &nbsp; See the License here &lt;http://www.gnu.org/licenses/gpl-3.0.html&gt;.<br />***********************************************************************/<br />$page_security = $_POST[&#039;PARAM_0&#039;] == $_POST[&#039;PARAM_1&#039;] ?<br />&nbsp; &nbsp; &#039;SA_SALESTRANSVIEW&#039; : &#039;SA_SALESBULKREP&#039;;<br />// ----------------------------------------------------------------<br />// $ Revision:&nbsp; &nbsp; 2.0 $<br />// Creator:&nbsp; &nbsp; Joe Hunt<br />// date_:&nbsp; &nbsp; 2005-05-19<br />// Title:&nbsp; &nbsp; Print Invoices<br />// ----------------------------------------------------------------<br />$path_to_root=&quot;..&quot;;</p><p>include_once($path_to_root . &quot;/includes/session.inc&quot;);<br />include_once($path_to_root . &quot;/includes/date_functions.inc&quot;);<br />include_once($path_to_root . &quot;/includes/data_checks.inc&quot;);<br />include_once($path_to_root . &quot;/sales/includes/sales_db.inc&quot;);</p><p>//----------------------------------------------------------------------------------------------------</p><p>print_invoices();</p><p>//----------------------------------------------------------------------------------------------------</p><p>function print_invoices()<br />{<br />&nbsp; &nbsp; global $path_to_root, $alternative_tax_include_on_docs, $suppress_tax_rates, $no_zero_lines_amount;<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; include_once($path_to_root . &quot;/reporting/includes/pdf_report.inc&quot;);</p><p>&nbsp; &nbsp; $from = $_POST[&#039;PARAM_0&#039;];<br />&nbsp; &nbsp; $to = $_POST[&#039;PARAM_1&#039;];<br />&nbsp; &nbsp; $currency = $_POST[&#039;PARAM_2&#039;];<br />&nbsp; &nbsp; $email = $_POST[&#039;PARAM_3&#039;];<br />&nbsp; &nbsp; $pay_service = $_POST[&#039;PARAM_4&#039;];<br />&nbsp; &nbsp; $comments = $_POST[&#039;PARAM_5&#039;];<br />&nbsp; &nbsp; $customer = $_POST[&#039;PARAM_6&#039;];<br />&nbsp; &nbsp; $orientation = $_POST[&#039;PARAM_7&#039;];</p><p>&nbsp; &nbsp; if (!$from || !$to) return;</p><p>&nbsp; &nbsp; $orientation = ($orientation ? &#039;L&#039; : &#039;P&#039;);<br />&nbsp; &nbsp; $dec = user_price_dec();</p><p> &nbsp; &nbsp; $fno = explode(&quot;-&quot;, $from);<br />&nbsp; &nbsp; $tno = explode(&quot;-&quot;, $to);<br />&nbsp; &nbsp; $from = min($fno[0], $tno[0]);<br />&nbsp; &nbsp; $to = max($fno[0], $tno[0]);</p><p>&nbsp; &nbsp; $cols = array(4, 60, 225, 300, 325, 375, 425, 465, 515);</p><p>&nbsp; &nbsp; // $headers in doctext.inc<br />&nbsp; &nbsp; $aligns = array(&#039;left&#039;,&nbsp; &nbsp; &#039;left&#039;,&nbsp; &nbsp; &#039;right&#039;, &#039;left&#039;, &#039;right&#039;, &#039;right&#039;, &#039;right&#039;, &#039;right&#039;);</p><p>&nbsp; &nbsp; $params = array(&#039;comments&#039; =&gt; $comments);</p><p>&nbsp; &nbsp; $cur = get_company_Pref(&#039;curr_default&#039;);</p><p>&nbsp; &nbsp; if ($email == 0)<br />&nbsp; &nbsp; &nbsp; &nbsp; $rep = new FrontReport(_(&#039;INVOICE&#039;), &quot;InvoiceBulk&quot;, user_pagesize(), 9, $orientation);<br />&nbsp; &nbsp; if ($orientation == &#039;L&#039;)<br />&nbsp; &nbsp; &nbsp; &nbsp; recalculate_cols($cols);<br />&nbsp; &nbsp; for ($i = $from; $i &lt;= $to; $i++)<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (!exists_customer_trans(ST_SALESINVOICE, $i))<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; continue;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $sign = 1;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $myrow = get_customer_trans($i, ST_SALESINVOICE);</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if($customer &amp;&amp; $myrow[&#039;debtor_no&#039;] != $customer) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; continue;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $baccount = get_default_bank_account($myrow[&#039;curr_code&#039;]);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $params[&#039;bankaccount&#039;] = $baccount[&#039;id&#039;];</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $branch = get_branch($myrow[&quot;branch_code&quot;]);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $sales_order = get_sales_order_header($myrow[&quot;order_&quot;], ST_SALESORDER);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($email == 1)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep = new FrontReport(&quot;&quot;, &quot;&quot;, user_pagesize(), 9, $orientation);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;title = _(&#039;INVOICE&#039;);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;filename = &quot;Invoice&quot; . $myrow[&#039;reference&#039;] . &quot;.pdf&quot;;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;SetHeaderType(&#039;Header2&#039;);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;currency = $cur;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;Font();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;Info($params, $cols, null, $aligns);</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $contacts = get_branch_contacts($branch[&#039;branch_code&#039;], &#039;invoice&#039;, $branch[&#039;debtor_no&#039;], true);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $baccount[&#039;payment_service&#039;] = $pay_service;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;SetCommonData($myrow, $branch, $sales_order, $baccount, ST_SALESINVOICE, $contacts);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;NewPage();<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $result = get_customer_trans_details(ST_SALESINVOICE, $i);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $SubTotal = 0;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while ($myrow2=db_fetch($result))<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($myrow2[&quot;quantity&quot;] == 0)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; continue;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $Net = round2($sign * ((1 - $myrow2[&quot;discount_percent&quot;]) * $myrow2[&quot;unit_price&quot;] * $myrow2[&quot;quantity&quot;]),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; user_price_dec());<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $SubTotal += $Net;<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; $DisplayPrice = number_format2($myrow2[&quot;unit_price&quot;],$dec);<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; $DisplayQty = number_format2($sign*$myrow2[&quot;quantity&quot;],get_qty_dec($myrow2[&#039;stock_id&#039;]));<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $DisplayTaxRate = number_format2(abs($myrow2[&quot;unit_tax&quot;]) * 100 / abs($myrow2[&quot;unit_price&quot;]),user_percent_dec()) . &quot;%&quot;;<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; $DisplayNet = number_format2($Net,$dec);<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; if ($myrow2[&quot;discount_percent&quot;]==0)<br />&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $DisplayDiscount =&quot;&quot;;<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; else<br />&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $DisplayDiscount = number_format2($myrow2[&quot;discount_percent&quot;]*100,user_percent_dec()) . &quot;%&quot;;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(0, 1,&nbsp; &nbsp; $myrow2[&#039;stock_id&#039;], -2);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $oldrow = $rep-&gt;row;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextColLines(1, 2, $myrow2[&#039;StockDescription&#039;], -2);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $newrow = $rep-&gt;row;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;row = $oldrow;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($Net != 0.0 || !is_service($myrow2[&#039;mb_flag&#039;]) || !isset($no_zero_lines_amount) || $no_zero_lines_amount == 0)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(2, 3,&nbsp; &nbsp; $DisplayQty, -2);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(3, 4,&nbsp; &nbsp; $myrow2[&#039;units&#039;], -2);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(4, 5,&nbsp; &nbsp; $DisplayPrice, -2);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(5, 6,&nbsp; &nbsp; $DisplayDiscount, -2);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(6, 7,&nbsp; &nbsp; $DisplayTaxRate, -2);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(7, 8,&nbsp; &nbsp; $DisplayNet, -2);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;row = $newrow;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //$rep-&gt;NewLine(1);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($rep-&gt;row &lt; $rep-&gt;bottomMargin + (15 * $rep-&gt;lineHeight))<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;NewPage();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $memo = get_comments_string(ST_SALESINVOICE, $i);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($memo != &quot;&quot;)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;NewLine();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextColLines(1, 5, $memo, -2);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</p><p>&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $DisplaySubTot = number_format2($SubTotal,$dec);<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $DisplayFreight = number_format2($sign*$myrow[&quot;ov_freight&quot;],$dec);</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;row = $rep-&gt;bottomMargin + (15 * $rep-&gt;lineHeight);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $doctype = ST_SALESINVOICE;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(3, 6, _(&quot;Sub-total&quot;), -2);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(7, 8,&nbsp; &nbsp; $DisplaySubTot, -2);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;NewLine();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(3, 6, _(&quot;Shipping&quot;), -2);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(7, 8,&nbsp; &nbsp; $DisplayFreight, -2);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;NewLine();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $tax_items = get_trans_tax_details(ST_SALESINVOICE, $i);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $first = true;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while ($tax_item = db_fetch($tax_items))<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($tax_item[&#039;amount&#039;] == 0)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; continue;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $DisplayTax = number_format2($sign*$tax_item[&#039;amount&#039;], $dec);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (isset($suppress_tax_rates) &amp;&amp; $suppress_tax_rates == 1)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $tax_type_name = $tax_item[&#039;tax_type_name&#039;];<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $tax_type_name = $tax_item[&#039;tax_type_name&#039;].&quot; (&quot;.$tax_item[&#039;rate&#039;].&quot;%) &quot;;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($tax_item[&#039;included_in_price&#039;])<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (isset($alternative_tax_include_on_docs) &amp;&amp; $alternative_tax_include_on_docs == 1)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($first)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(3, 6, _(&quot;Total Tax Excluded&quot;), -2);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(7, 8,&nbsp; &nbsp; number_format2($sign*$tax_item[&#039;net_amount&#039;], $dec), -2);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;NewLine();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(3, 6, $tax_type_name, -2);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(7, 8,&nbsp; &nbsp; $DisplayTax, -2);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $first = false;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(3, 7, _(&quot;Included&quot;) . &quot; &quot; . $tax_type_name . _(&quot;Amount&quot;) . &quot;: &quot; . $DisplayTax, -2);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(3, 6, $tax_type_name, -2);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(7, 8,&nbsp; &nbsp; $DisplayTax, -2);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;NewLine();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;NewLine();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $DisplayTotal = number_format2($sign*($myrow[&quot;ov_freight&quot;] + $myrow[&quot;ov_gst&quot;] +<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $myrow[&quot;ov_amount&quot;]+$myrow[&quot;ov_freight_tax&quot;]),$dec);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;Font(&#039;bold&#039;);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(3, 6, _(&quot;TOTAL INVOICE&quot;), - 2);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(7, 8, $DisplayTotal, -2);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $words = price_in_words($myrow[&#039;Total&#039;], ST_SALESINVOICE);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($words != &quot;&quot;)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;NewLine(1);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;TextCol(1, 7, $myrow[&#039;curr_code&#039;] . &quot;: &quot; . $words, - 2);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;Font();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($email == 1)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;End($email);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; if ($email == 0)<br />&nbsp; &nbsp; &nbsp; &nbsp; $rep-&gt;End();<br />}</p><p>?&gt;</p>]]></content>
			<author>
				<name><![CDATA[dls]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=699</uri>
			</author>
			<updated>2015-03-10T18:54:14Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=22851#p22851</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[need retrieving tax rate per item during invoice generation]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=22831#p22831" />
			<content type="html"><![CDATA[<p>Hi all!<br />I have been browsing forum and (with my little knowledge) the source code to understand how I could retrieve, during the generation of rep107, the tax rate per each item to include it in the invoice (that is a requirement locally).<br />I cannot &quot;guess&quot; the rate by reverse calculation due to rounding of numbers.<br />e.g. an item with VAT 4% priced 1.58 EUR with a discount of 25% will generate values that, applied to the reverse calculation of VAT, will return 3.92% (which is obviously wrong).<br />While that is correct in GL, because the needed rounding of numbers, that is of no value to print the rate used originally.<br />How can I retrieve that value?<br />Any SQL you might suggest?<br />Any help will be highly appreciated because I am totally stuck without such info.<br />Thanks a lot to all for the great job and support.<br />Carlo</p>]]></content>
			<author>
				<name><![CDATA[carlo]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=18764</uri>
			</author>
			<updated>2015-03-09T15:09:21Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=22831#p22831</id>
		</entry>
</feed>
