While working for Sjors, i found a bug in Artio vmInvoice code running on VM2 latest:
file:
/administrator/components/com_vminvoice/getter.php
search for:
$sql = 'SELECT item.*,item.`virtuemart_order_item_id` AS `order_item_id`,
item.`virtuemart_product_id` AS `product_id`,
item.`virtuemart_vendor_id` AS `vendor_id`,
item.product_item_price,
item.product_basePriceWithTax AS product_price_with_tax,
item.product_subtotal_discount/product_quantity AS product_price_discount,
item.product_tax/product_quantity AS product_tax,
item.product_subtotal_with_tax/product_quantity AS product_subtotal_with_tax,
lang.product_s_desc, lang.product_desc, product.product_weight, product.product_weight_uom
FROM `#__virtuemart_order_items` AS item
LEFT JOIN `#__virtuemart_products` AS product ON item.virtuemart_product_id = product.virtuemart_product_id
LEFT JOIN '.self::getVm2LanguageTable('#__virtuemart_products').' AS lang ON item.virtuemart_product_id = lang.virtuemart_product_id
WHERE '.
($orderId ? '`virtuemart_order_id` = ' . (int)$orderId : ' `virtuemart_order_item_id` IN ('.implode(',',(array)$orderItemsIds).')').
' ORDER BY item.`'.$orderCol.'` '.$orderDir;
replace with:
$sql = 'SELECT item.*,item.`virtuemart_order_item_id` AS `order_item_id`,
item.`virtuemart_product_id` AS `product_id`,
item.`virtuemart_vendor_id` AS `vendor_id`,
item.product_item_price,
item.product_basePriceWithTax AS product_price_with_tax,
item.product_subtotal_discount/product_quantity AS product_price_discount,
item.product_tax/product_quantity AS product_tax2,
item.product_subtotal_with_tax/product_quantity AS product_subtotal_with_tax,
lang.product_s_desc, lang.product_desc, product.product_weight, product.product_weight_uom
FROM `#__virtuemart_order_items` AS item
LEFT JOIN `#__virtuemart_products` AS product ON item.virtuemart_product_id = product.virtuemart_product_id
LEFT JOIN '.self::getVm2LanguageTable('#__virtuemart_products').' AS lang ON item.virtuemart_product_id = lang.virtuemart_product_id
WHERE '.
($orderId ? '`virtuemart_order_id` = ' . (int)$orderId : ' `virtuemart_order_item_id` IN ('.implode(',',(array)$orderItemsIds).')').
' ORDER BY item.`'.$orderCol.'` '.$orderDir;
As you can see the product_tax is loaded twice here and is incorrectly calculated. The VM2 (latest) stores the product tax per item not per whole product subtotal and thus dividing it with the quantity leads to incorrect results.
Best Regards,
Stan, RuposTel.com