If a product with VAT is removed from the system after an order with the product has been created, the VAT will not show up when looking at the order. What I have seen is that the order product line is not considered for VAT recalculation and I guess that is because there is no node matching the nid of the order product item.

My view on this is that the VAT of the ordered product and the ordreed product should be stored together for the receipt somehow. My knowledge on the VAT module is not good enough to determine how this could be done, but I hope to be able to investigate this more in the near future.

Comments

longwave’s picture

Yes, we need the original product node so we know what product class it was and hence which tax rules to apply to recalculate the price. Ubercart should probably just have fixed the altered price into the order here so it doesn't matter if the node is deleted or even if uc_vat is disabled, but we just have to live with that for now. A workaround for now is to unpublish product nodes rather than deleting them, fixing this otherwise is going to require extra data storage to handle this case.

ndmaque’s picture

i needed a very URGENT fix to this and slapped a quick hack in.
The problem is in the uc_taxes.module uc_taxes_apply_item_tax()

It attempts to load the node, if it fails it treats everything as an admin added 'blank-line' item which is not a taxable type.
We can detect if it is a deleted node because it will have a $item->nid and can do some logic.
In my case we had the csv uploads and did a lookup to get the node->type.
NB: Refresh the order from the admin screen (submit to save) and on re-load the tax comes back.



function uc_taxes_apply_item_tax($item, $tax) {
  $node = node_load($item->nid);
  

  // Special handling for manually added "Blank line" products.
  if (!$node) {
    $node = new stdClass();
    // START HACK - if the item has a nid but failed to load it's a deleted node
    // The problem is the node type. If no node exists it will be treated as $node->type = 'blank-line' item and not taxable
    // implement some logic / call a custom function to get the type from csv/elsewhere, 
    // NB: $item still has the initial sku and title etc you may be able to work out it's $node->type 
    if($item->nid) {
      $node->type = _get_type_from_csv($item->nid);
      $node->shippable = $item->data['shippable'];
    }
    else {
      $node->type = 'blank-line' ;
      $node->shippable = $item->weight > 0;
    }
    // STOP HACK 
  }