salvador72 Posted June 14, 2009 Share Posted June 14, 2009 this is what happend, first i had 1 zone, 1 tax rate.it worked fine. but than i needed 2 more zones (internatinal orders), and i had to aplie 2 more tax zones. it was working fine till i descover that at the categories.php file it was calculating price not with 1 tax rate but with 3 taxes rates.(vat taxe). its funny althought that at my store it shows prices ok. I think i had to change this php code: var tax_rates = new Array(); <?php for ($i=0, $n=sizeof($tax_class_array); $i<$n; $i++) { if ($tax_class_array[$i]['id'] > 0) { echo 'tax_rates["' . $tax_class_array[$i]['id'] . '"] = ' . tep_get_tax_rate_value($tax_class_array[$i]['id']) . ';' . "\n"; } } ?> function doRound(x, places) { return Math.round(x * Math.pow(10, places)) / Math.pow(10, places); } function getTaxRate() { var selected_value = document.forms["new_product"].products_tax_class_id.selectedIndex; var parameterVal = document.forms["new_product"].products_tax_class_id[selected_value].value; if ( (parameterVal > 0) && (tax_rates[parameterVal] > 0) ) { return tax_rates[parameterVal]; } else { return 0; } } function updateGross() { var taxRate = getTaxRate(); var grossValue = document.forms["new_product"].products_price.value; if (taxRate > 0) { grossValue = grossValue * ((taxRate / 100) + 1); } document.forms["new_product"].products_price_gross.value = doRound(grossValue, 4); } function updateNet() { var taxRate = getTaxRate(); var netValue = document.forms["new_product"].products_price_gross.value; if (taxRate > 0) { netValue = netValue / ((taxRate / 100) + 1); } document.forms["new_product"].products_price.value = doRound(netValue, 4); } can somebody help me? Link to comment Share on other sites More sharing options...
♥geoffreywalton Posted June 14, 2009 Share Posted June 14, 2009 Did you try making each tax rate apply to the appropriate county rather than assuming osc doesn't work? If so what did you have set up? Need help installing add ons/contributions, cleaning a hacked site or a bespoke development, check my profile Virus Threat Scanner My Contributions Basic install answers. Click here for Contributions / Add Ons. UK your site. Site Move. Basic design info. For links mentioned in old answers that are no longer here follow this link Useful Threads. If this post was useful, click the Like This button over there ======>>>>>. Link to comment Share on other sites More sharing options...
salvador72 Posted June 14, 2009 Author Share Posted June 14, 2009 Did you try making each tax rate apply to the appropriate county rather than assuming osc doesn't work? If so what did you have set up? Hi Jeff yes, at the admin/taxe_rate you got table: priority tax class zone tax rate at the beguining i had only 1 contry,whre i applyed 20% tax rate but when i change the shipping modulo(zones.php), i put 2 more and then i had to also insert the same data at tax_rate table.(priority,tax classe,zone,taxe rate(20% for each)) so insted of only 20% (tax rate) its assuming 60% strange however, at my store prices look correct (assuming only 20%) the difference is ocorring at the category file, where it puts price (with no tax correctly) but at the field "textgrossValue " its puting 60% tax Link to comment Share on other sites More sharing options...
salvador72 Posted June 14, 2009 Author Share Posted June 14, 2009 Did you try making each tax rate apply to the appropriate county rather than assuming osc doesn't work? If so what did you have set up? By the way geoffrey, this is the page code at category page(in admin) var dateAvailable = new ctlSpiffyCalendarBox("dateAvailable", "new_product", "products_date_available","btnDate1","",scBTNMODE_CUSTOMBLUE); //--></script> <script language="javascript"><!-- var tax_rates = new Array(); tax_rates["1"] = 60; function doRound(x, places) { return Math.round(x * Math.pow(10, places)) / Math.pow(10, places); } function getTaxRate() { var selected_value = document.forms["new_product"].products_tax_class_id.selectedIndex; var parameterVal = document.forms["new_product"].products_tax_class_id[selected_value].value; if ( (parameterVal > 0) && (tax_rates[parameterVal] > 0) ) { return tax_rates[parameterVal]; } else { return 0; } } function updateGross() { var taxRate = getTaxRate(); var grossValue = document.forms["new_product"].products_price.value; if (taxRate > 0) { grossValue = grossValue * ((taxRate / 100) + 1); } document.forms["new_product"].products_price_gross.value = doRound(grossValue, 4); } function updateNet() { var taxRate = getTaxRate(); var netValue = document.forms["new_product"].products_price_gross.value; if (taxRate > 0) { netValue = netValue / ((taxRate / 100) + 1); } document.forms["new_product"].products_price.value = doRound(netValue, 4); As you can see in the beguin its assuming - 60 :tax_rates["1"] = 60; no waht can i do to change this detail? 'cause im having problems in putting right prices at shop Link to comment Share on other sites More sharing options...
♥geoffreywalton Posted June 14, 2009 Share Posted June 14, 2009 What version are you using? Need help installing add ons/contributions, cleaning a hacked site or a bespoke development, check my profile Virus Threat Scanner My Contributions Basic install answers. Click here for Contributions / Add Ons. UK your site. Site Move. Basic design info. For links mentioned in old answers that are no longer here follow this link Useful Threads. If this post was useful, click the Like This button over there ======>>>>>. Link to comment Share on other sites More sharing options...
salvador72 Posted June 14, 2009 Author Share Posted June 14, 2009 What version are you using? well dont know exectely but does this means something 2 you: E-Commerce Engine Copyright © 2003 Moderotika.net osCommerce provides no warranty and is redistributable under the GNU General Public License this is the code page for tax rates at my admin page, so you may understans better: <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr class="dataTableHeadingRow"> <td class="dataTableHeadingContent">Priority</td> <td class="dataTableHeadingContent">Tax Class</td> <td class="dataTableHeadingContent">Zone</td> <td class="dataTableHeadingContent">Tax Rate</td> <td class="dataTableHeadingContent" align="right">Action </td> </tr> <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href='http://www.moderotika.net//loja/admin/tax_rates.php?page=1&tID=1&action=edit&osCAdminID=330eeff1c26d69c73057d0c44cba9aff'"> <td class="dataTableContent">1</td> <td class="dataTableContent">IVA</td> <td class="dataTableContent">Portugal</td> <td class="dataTableContent">20%</td> <td class="dataTableContent" align="right"><img src="images/icon_arrow_right.gif" border="0" alt=""> </td> </tr> <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href='http://www.moderotika.net//loja/admin/tax_rates.php?page=1&tID=5&osCAdminID=330eeff1c26d69c73057d0c44cba9aff'"> <td class="dataTableContent">3</td> <td class="dataTableContent">IVA</td> <td class="dataTableContent">Resto do Mundo</td> <td class="dataTableContent">20%</td> <td class="dataTableContent" align="right"><a href="http://www.moderotika.net//loja/admin/tax_rates.php?page=1&tID=5&osCAdminID=330eeff1c26d69c73057d0c44cba9aff"><img src="images/icon_info.gif" border="0" alt="Informação" title=" Informação "></a> </td> </tr> <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href='http://www.moderotika.net//loja/admin/tax_rates.php?page=1&tID=4&osCAdminID=330eeff1c26d69c73057d0c44cba9aff'"> <td class="dataTableContent">2</td> <td class="dataTableContent">IVA</td> <td class="dataTableContent">Europa</td> <td class="dataTableContent">20%</td> <td class="dataTableContent" align="right"><a href="http://www.moderotika.net//loja/admin/tax_rates.php?page=1&tID=4&osCAdminID=330eeff1c26d69c73057d0c44cba9aff"><img src="images/icon_info.gif" border="0" alt="Informação" title=" Informação "></a> </td> </tr> Link to comment Share on other sites More sharing options...
♥geoffreywalton Posted June 14, 2009 Share Posted June 14, 2009 What countries are in "Europa" and "Resto do Mundo"? Need help installing add ons/contributions, cleaning a hacked site or a bespoke development, check my profile Virus Threat Scanner My Contributions Basic install answers. Click here for Contributions / Add Ons. UK your site. Site Move. Basic design info. For links mentioned in old answers that are no longer here follow this link Useful Threads. If this post was useful, click the Like This button over there ======>>>>>. Link to comment Share on other sites More sharing options...
salvador72 Posted June 15, 2009 Author Share Posted June 15, 2009 What countries are in "Europa" and "Resto do Mundo"? Europe..everycountry in Europe Resto do Mundo..World wide does it makes difference? I made it like, Europe was a country, & resto do mundo also Link to comment Share on other sites More sharing options...
salvador72 Posted June 16, 2009 Author Share Posted June 16, 2009 Europe..everycountry in EuropeResto do Mundo..World wide does it makes difference? I made it like, Europe was a country, & resto do mundo also So can you help me with this problem? Link to comment Share on other sites More sharing options...
stecale Posted July 10, 2009 Share Posted July 10, 2009 So can you help me with this problem? Hello salvador, Did you find a fix for your probem ? I meet exactly the same problem. When we add a tax rate for a different zone, the tax rates are added in the admin/categories.php file. I suspected that it was due to different priorities in my tax rate table. But I didn't find anywhere some explanation about how to use this tax rate priority value. Is there someone who knows how to use that ? Link to comment Share on other sites More sharing options...
salvador72 Posted July 10, 2009 Author Share Posted July 10, 2009 Hello salvador,Did you find a fix for your probem ? I meet exactly the same problem. When we add a tax rate for a different zone, the tax rates are added in the admin/categories.php file. I suspected that it was due to different priorities in my tax rate table. But I didn't find anywhere some explanation about how to use this tax rate priority value. Is there someone who knows how to use that ? Well no, the problem remains, I dont have PHP knowlege to change it, the more taxes you apply, more the code goes to add. happily the price displayed in the store does not modify, and therefore the only work you'll have is to calculate the value without the tax, in the case of being 20%, the equation will be, price (with tax) /120*100= price without tax. Link to comment Share on other sites More sharing options...
Code Red Posted August 18, 2009 Share Posted August 18, 2009 Hi, You'll be gratified to hear that you're not the only ones experiencing this problem - I run over ten different OS Commerce sites and they all have the same problem - I think most people, myself included never bothered looking at the gross calculation in categories.php, after all it's just for visual reference. The fault lies in the tep_get_tax_rate_value function in admin/includes/functions/general.php, it just looks up all the tax rates in the store and adds them together. I've made a quick and dirty fix that works for me, probably the more experience OSC coders will find issue with it, but as it stands this is the only solution until something better comes along. The problem the site has is which tax rate should it use (there could be dozens, after all). As a solution I made the function reference the tax code for the country and zone associated with the store itself, as set in admin/configurations/my store : Find these lines - function tep_get_tax_rate_value($class_id) { $tax_query = tep_db_query("select SUM(tax_rate) as tax_rate from " . TABLE_TAX_RATES . " where tax_class_id = '" . (int)$class_id . "' group by tax_priority"); change it to this - function tep_get_tax_rate_value($class_id) { // $tax_query = tep_db_query("select SUM(tax_rate) as tax_rate from " . TABLE_TAX_RATES . " where tax_class_id = '" . (int)$class_id . "' group by tax_priority"); $tax_query = tep_db_query("select SUM(tr.tax_rate) as tax_rate from " . TABLE_TAX_RATES . " tr, " . TABLE_ZONES_TO_GEO_ZONES . " z2gz where tr.tax_class_id = '" . (int)$class_id . "' and tr.tax_zone_id = z2gz.geo_zone_id and z2gz.zone_country_id = '" . STORE_COUNTRY . "' and z2gz.zone_id = '" . STORE_ZONE . "' group by tr.tax_priority"); Link to comment Share on other sites More sharing options...
tmc4444 Posted September 1, 2009 Share Posted September 1, 2009 I am also having problems with the taxes. For those in my province & country, things are fine. For others outside of the country, however, they're being charged a Canadian tax of 5%. I tried setting the 'other country' zone tax setting to 0%, but it didn't matter. It just added 0% tax rate to all taxes. How do I fix this? Tara Forsythe Link to comment Share on other sites More sharing options...
nuskati Posted October 27, 2010 Share Posted October 27, 2010 Thanks Code Red. For me your changed SQL query was almost exactly the solution to the problem. As my store zone is set but as tax zones only countries are set but no zones (no states within the country), I added a 0-option for z2gz.zone_id. And as I am not sure where else the function tep_get_tax_rate_value in /admin/includes/functions/general.php is used and if changes would lead to errors elsewhere I duplicated the function, made the changes, and renamed it: function tep_get_tax_rate_value_shop_default($class_id) { //$tax_query = tep_db_query("select SUM(tax_rate) as tax_rate from " . TABLE_TAX_RATES . " where tax_class_id = '" . (int)$class_id . "' group by tax_priority"); //$tax_query = tep_db_query("select SUM(tr.tax_rate) as tax_rate from " . TABLE_TAX_RATES . " tr, " . TABLE_ZONES_TO_GEO_ZONES . " z2gz where tr.tax_class_id = '" . (int)$class_id . "' and tr.tax_zone_id = z2gz.geo_zone_id and z2gz.zone_country_id = '" . STORE_COUNTRY . "' and z2gz.zone_id = '" . STORE_ZONE . "' group by tr.tax_priority"); $tax_query = tep_db_query("select SUM(tr.tax_rate) as tax_rate from " . TABLE_TAX_RATES . " tr, " . TABLE_ZONES_TO_GEO_ZONES . " z2gz where tr.tax_class_id = '" . (int)$class_id . "' and tr.tax_zone_id = z2gz.geo_zone_id and z2gz.zone_country_id = '" . STORE_COUNTRY . "' and (z2gz.zone_id = '" . STORE_ZONE . "' OR z2gz.zone_id = '0') group by tr.tax_priority"); if (tep_db_num_rows($tax_query)) { $tax_multiplier = 0; while ($tax = tep_db_fetch_array($tax_query)) { $tax_multiplier += $tax['tax_rate']; } return $tax_multiplier; } else { return 0; } } In admin/categories.php I changed the name of the taxe rate function called accordingly: <?php for ($i=0, $n=sizeof($tax_class_array); $i<$n; $i++) { if ($tax_class_array[$i]['id'] > 0) { //echo 'tax_rates["' . $tax_class_array[$i]['id'] . '"] = ' . tep_get_tax_rate_value($tax_class_array[$i]['id']) . ';' . "\n"; echo 'tax_rates["' . $tax_class_array[$i]['id'] . '"] = ' . tep_get_tax_rate_value_shop_default($tax_class_array[$i]['id']) . ';' . "\n"; } } ?> Now net/gross tax is calculated correctly in admin/categories.php even with no country zones set in tax zones. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.