=== modified file 'uc_order/uc_order.install'
--- uc_order/uc_order.install	2009-01-30 15:57:34 +0000
+++ uc_order/uc_order.install	2009-02-19 21:43:11 +0000
@@ -370,6 +370,10 @@
         'not null' => TRUE,
         'default' => 0,
       ),
+      'data' => array(
+        'description' => t('Serialized array of extra data.'),
+        'type' => 'text',
+      ),
     ),
     'indexes' => array(
       'order_id' => array('order_id'),
@@ -907,3 +911,13 @@
 
   return $ret;
 }
+
+// add data field to uc_order_line_items
+function uc_order_update_6007() {
+
+  $ret = array();
+
+  db_add_field($ret, 'uc_order_line_items', 'data', array('type' => 'text'));
+
+  return $ret;
+}

=== modified file 'uc_order/uc_order.line_item.inc'
--- uc_order/uc_order.line_item.inc	2008-10-15 20:20:43 +0000
+++ uc_order/uc_order.line_item.inc	2009-02-19 16:23:32 +0000
@@ -91,12 +91,12 @@
   return TRUE;
 }
 
-function uc_order_line_item_add($order_id, $type, $title, $amount, $weight = NULL) {
+function uc_order_line_item_add($order_id, $type, $title, $amount, $weight = NULL, $data = NULL) {
   if (is_null($weight)) {
     $weight = _line_item_data($type, 'weight');
   }
 
-  db_query("INSERT INTO {uc_order_line_items} (order_id, type, title, amount, weight) VALUES (%d, '%s', '%s', %f, %d)", $order_id, $type, $title, $amount, $weight);
+  db_query("INSERT INTO {uc_order_line_items} (order_id, type, title, amount, weight, data) VALUES (%d, '%s', '%s', %f, %d, '%s')", $order_id, $type, $title, $amount, $weight, serialize( $data ));
 
   return TRUE;
 }

=== modified file 'uc_order/uc_order.module'
--- uc_order/uc_order.module	2009-02-13 15:43:12 +0000
+++ uc_order/uc_order.module	2009-02-19 16:23:32 +0000
@@ -1187,6 +1187,7 @@
         'title' => $row->title,
         'amount' => $row->amount,
         'weight' => $row->weight,
+        'data' => unserialize( $row->data ),
       );
     }
   }
@@ -1205,6 +1206,7 @@
               'title' => $line['title'],
               'amount' => $line['amount'],
               'weight' => isset($line['weight']) ? $line['weight'] : $type['weight'],
+              'data' => $line['data'],
             );
           }
         }
@@ -1443,6 +1445,7 @@
               'title' => $line['title'],
               'amount' => $line['amount'],
               'weight' => $item['weight'],
+              'data' => $item['data'],
             );
           }
         }

=== modified file 'uc_taxes/uc_taxes.ca.inc'
--- uc_taxes/uc_taxes.ca.inc	2009-02-06 18:31:47 +0000
+++ uc_taxes/uc_taxes.ca.inc	2009-02-19 16:23:32 +0000
@@ -77,13 +77,14 @@
  */
 function uc_taxes_action_apply_tax($order, $tax) {
   $amount = 0;
+  $taxable_amount = 0;
   if (is_array($order->products)) {
     foreach ($order->products as $item) {
       $node = node_load($item->nid);
       // Tax products if they are of a taxed type and if it is shippable if
       // the tax only applies to shippable products.
       if (in_array($node->type, $tax->taxed_product_types) && ($tax->shippable == 0 || $node->shippable == 1)) {
-        $amount += $item->price * $item->qty * $tax->rate;
+        $taxable_amount += $item->price * $item->qty;
       }
     }
   }
@@ -95,17 +96,23 @@
         continue;
       }
       if (in_array($line_item['type'], $taxed_line_items)) {
-        $amount += $line_item['amount'] * $tax->rate;
+        $taxable_amount += $line_item['amount'];
       }
     }
   }
   if (isset($taxed_line_items['tax'])) {
     foreach ($order->taxes as $other_tax) {
-      $amount += $other_tax->amount * $tax->rate;
+      $taxable_amount += $other_tax['amount'];
     }
   }
+  $amount = $taxable_amount * $tax->rate;
   if ($amount) {
     $line_item = (object)array('id' => $tax->id, 'name' => $tax->name, 'amount' => $amount, 'weight' => $tax->weight);
+    $line_item->data = array( 
+      'tax_rate' => $tax->rate, 
+      'taxable_amount' => $taxable_amount, 
+      'tax_jurisdiction' => $tax->name,
+    );
     return $line_item;
   }
 }

=== modified file 'uc_taxes/uc_taxes.module'
--- uc_taxes/uc_taxes.module	2008-12-17 22:37:57 +0000
+++ uc_taxes/uc_taxes.module	2009-02-19 16:23:32 +0000
@@ -134,8 +134,10 @@
         foreach ($arg1->line_items as $line) {
           if ($line['type'] == 'tax') {
             $delete = TRUE;
+            $sdata = serialize( $line['data'] );
             foreach ($line_items as $id => $new_line) {
-              if ($new_line['title'] == $line['title']) {
+              if ($new_line['title'] == $line['title'] &&
+                  serialize( $new_line['data'] ) == $sdata) {
                 if ($new_line['amount'] != $line['amount']) {
                   uc_order_update_line_item($line['line_item_id'], $new_line['title'], $new_line['amount']);
                   $changes[] = t('Changed %title to %amount.', array('%amount' => uc_currency_format($new_line['amount']), '%title' => $new_line['title']));
@@ -154,7 +156,7 @@
       }
       if (is_array($line_items)) {
         foreach ($line_items as $line) {
-          uc_order_line_item_add($arg1->order_id, $line['id'], $line['title'], $line['amount'], $line['weight']);
+          uc_order_line_item_add($arg1->order_id, $line['id'], $line['title'], $line['amount'], $line['weight'], $line['data']);
           $changes[] = t('Added %amount for %title.', array('%amount' => uc_currency_format($line['amount']), '%title' => $line['title']));
         }
       }
@@ -198,6 +200,7 @@
           'title' => $tax->name,
           'amount' => $tax->amount,
           'weight' => variable_get('uc_li_tax_weight', 9) + $tax->weight / 10,
+          'data' => $tax->data,
         );
       }
       return $lines;

