uc_taxes hook_order does not take into account the new 'tax_included' tax type.

If the line item is not summed(not added to the total), it receives the "tax_included" type.

function uc_line_item_tax($op, $order) {
  switch ($op) {
    case 'load':
      $lines = array();
      $taxes = uc_taxes_calculate($order);
      foreach ($taxes as $tax) {
        $lines[] = array(
          'id' => (isset($tax->summed) ? 'tax' : 'tax_included'),
          'title' => $tax->name,
          'type' => (isset($tax->summed) ? 'tax' : 'tax_included'),
          'amount' => $tax->amount,
          'weight' => variable_get('uc_li_tax_weight', 9) + $tax->weight / 10,
          'data' => $tax->data,
        );
      }
      return $lines;
  }
}

However, hook order checks for new/existing taxes based on the following

          if ($line['type'] == 'tax') {

Because of this, a new line item is added to the order every time the order is saved, if the tax is a non-summed tax(VAT).

Attached is a patch to resolve the issue.

CommentFileSizeAuthor
#1 uc_taxes_summed_taxes.diff650 bytesmikejoconnor

Comments

mikejoconnor’s picture

Status: Active » Needs review
StatusFileSize
new650 bytes

ok, lets try to attach that patch again.

tr’s picture

Status: Needs review » Needs work

This all looks and sounds reasonable. Is no-one else seeing this problem? I don't know anything about the "tax_included" type - in the current versions of Ubercart (2.2+) it's only mentioned in one line of code in uc_line_item_tax(), not the two lines you show above, so it's unclear to me where this comes from and how it's intended to be used. uc_vat doesn't use it, for example - is there a contributed module or some other piece of code you have that needs to use this? I don't see any place in the UI where you can designate a price or a tax as tax_included, and it doesn't seem to be documented anywhere either. Is this "tax_included" type even relevant anymore now that we have the uc_vat module, or is the use case something different?

tr’s picture

Issue summary: View changes
Status: Needs work » Closed (cannot reproduce)