<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[FrontAccounting forum — retrieve tax from item]]></title>
	<link rel="self" href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=5608&amp;type=atom" />
	<updated>2015-03-13T14:43:14Z</updated>
	<generator>PunBB</generator>
	<id>https://frontaccounting.com/punbb/viewtopic.php?id=5608</id>
		<entry>
			<title type="html"><![CDATA[Re: retrieve tax from item]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=22877#p22877" />
			<content type="html"><![CDATA[<p>The SQL is:<br /></p><div class="codebox"><pre><code>SELECT tt.rate
FROM `0_stock_master` sm LEFT JOIN `0_tax_types` tt
        ON (`sm`.`tax_type_id` = `tt`.`id`)
WHERE stock_id=&quot;MY_ITEM&quot;;</code></pre></div><p>Tax rates are not that straightforward. The items may be having different tax rates depending on the actual invoice where a Customer may have tax overrides.</p><p>Attached is the ERD for the SQL provided here.</p><p>Will the <strong>function <em>get_item_tax_type_for_item($stock_id)</em></strong><br /></p><div class="codebox"><pre><code>function get_item_tax_type_for_item($stock_id)
{
    $sql = &quot;SELECT &quot;.TB_PREF.&quot;item_tax_types.* FROM &quot;.TB_PREF.&quot;item_tax_types,&quot;.TB_PREF.&quot;stock_master WHERE 
        &quot;.TB_PREF.&quot;stock_master.stock_id=&quot;.db_escape($stock_id).&quot;
        AND &quot;.TB_PREF.&quot;item_tax_types.id=&quot;.TB_PREF.&quot;stock_master.tax_type_id&quot;;
    
    $result = db_query($sql, &quot;could not get item tax type&quot;);
    
    return db_fetch($result);    
}</code></pre></div><p>in lines 61 to 70 in<strong>taxes/db/item_tax_types_db.inc</strong> suffice or would you like to clone it by replacing the sql?</p>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2015-03-13T14:43:14Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=22877#p22877</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[retrieve tax from item]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=22867#p22867" />
			<content type="html"><![CDATA[<p>Hi.</p><p>I need to create a function in PHP but I&#039;m not very familiar.<br />Can you help?</p><p>What I need is to pass to a function the stock_id (from stock_master.stock_id) and get the value of tax_types.rate associated.</p><p>I understand that for a PHP programmer is a walk in the park but I&#039;m not such a thing.</p><p>Thanks for any help you may provide.</p><p>Best,<br />Carlo</p>]]></content>
			<author>
				<name><![CDATA[carlo]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=18764</uri>
			</author>
			<updated>2015-03-11T18:42:58Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=22867#p22867</id>
		</entry>
</feed>
