Tax line is not deleted in checkout page

Project:Ubercart Contributions
Component:Code
Category:
Priority:normal
Assigned:Unassigned
Status:active
Description
Project: 
Ubercart

When the checkout page is loaded, taxes are calcualted correctly.

If there exist a tax line at this phase, it will not be deleted.

Then I change something that do not have a tax inovlved (e.g. I change to a different country, for which there are no tax rules). I click on 'calculate shipping' and taxes are left as they were - the tax line does not get deleted, although the taxes do not apply to this new country.

I have made a TEMPORAL ugly patch, that solves it in my case. I provide it here for the developer to understand where the problem lies, but this is not a solution, as you can see from the code.

--- uc_taxes.orig.js    2007-10-17 10:24:25.000000000 +0200
+++ uc_taxes.js 2007-10-17 10:26:27.000000000 +0200
@@ -15,7 +15,7 @@ $(document).ready(function(){
});

function getTax(){
-  var zone = $("select[@name*=" + pane + "_zone] option:selected").val();
+  var zone = $("select[@name*=" + pane + "_zone]").val();
   if (!zone){
     zone = "0";
   }
@@ -23,7 +23,7 @@ function getTax(){
   if (!code){
     code = '';
   }
-  var country = $("select[@name*=" + pane + "_country] option:selected").val();
+  var country = $("select[@name*=" + pane + "_country]").val();
   if (!country){
     country = "0";
   }
@@ -51,8 +51,13 @@ function getTax(){
     success: function(taxes){
     //if (taxes.constructor == Array){
       var j;
+     var has_tax=false;
       for (j in taxes){
         set_line_item("tax_" + taxes[j].id, taxes[j].name, taxes[j].amount, tax_weight + taxes[j].weight / 10);
+        has_tax=true;
+      }
+      if (!has_tax) {
+        set_line_item("tax_1", 'Tax', 0, 8);
       }
     //}
     }

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Tax line is not deleted in checkout page

I haven't toyed w/ the tax stuff enough to know how the rates are being returned, but I'm curious how this solution works if there are more than one taxes. For example, what if there are 2 taxes? If no taxes were returned then it ought to take into account any number of taxes, right?

yhager's picture
Offline
Joined: 10/01/2007
Juice: 59
Hint: it won't work As I
Assigned to:Ryan» yhager

Hint: it won't work Smiling

As I wrote above, this is just a pointer to where the bug is, not a patch that fixes it. I have only one kind of tax, so it works for me, but I see it as a temporal fix, until someone will come and fix it properly.

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6846
Re: Tax line is not deleted in checkout page
Assigned to:yhager» Lyle

Between Übercart upgrades and Workflow-ng integration, this has been fixed.

See http://www.ubercart.org/issue/1560/texes_line_items_are_not_cleared_afte...