VirtueMart Forum

VirtueMart 2 + 3 + 4 => Product pricing => Topic started by: peterf on October 19, 2018, 05:00:11 AM

Title: Tax calculation now wrong after upgrading to Virtuemart 3.4.2 and Joomla 3.8.13
Post by: peterf on October 19, 2018, 05:00:11 AM
Hi,

After upgrading to Joomla 3.8.13 and Virtuemart 3.4.2 a couple of days ago I am now getting an incorrect Tax calculation at checkout when a discount coupon is applied. The system is now calculating the Tax on the item price before the discount is applied rather than after, as it used to. In the example attached the GST should be 15% of $240 ($300 - $60) = $36 and not $45 which is 15% of $300. Anyone have any ideas? Many thanks for any help.
Title: Re: Tax calculation now wrong after upgrading to Virtuemart 3.4.2 and Joomla 3.8.13
Post by: GJC Web Design on October 19, 2018, 11:22:28 AM
can you show exactly what your set up is re tax and discount rules

I just tried this -> I get (10 - 10%) x 1.2 = 10.80

this is using 20% vat tax

Title: Re: Tax calculation now wrong after upgrading to Virtuemart 3.4.2 and Joomla 3.8.13
Post by: GJC Web Design on October 19, 2018, 11:29:07 AM
r u using tax per bill? -- just tried that and yes - coupon comes off after tax

Title: Re: Tax calculation now wrong after upgrading to Virtuemart 3.4.2 and Joomla 3.8.13
Post by: peterf on October 22, 2018, 05:18:00 AM
Hi GJC Web Design,

Thanks for your reply. Yes I am using Tax Per Bill but up to quite recently it worked exactly the way i wanted taking the discount off first and then adding the Tax. You can see from the 2 images below (both using Tax Per Bill) the difference started after Virtuemart 3.4 and now the Tax is added before discount (i.e. on the full price). Does anyone know if this is now permanent or a bug? Many thanks for your help.
Title: Re: Tax calculation now wrong after upgrading to Virtuemart 3.4.2 and Joomla 3.8.13
Post by: GJC Web Design on October 22, 2018, 11:08:45 AM
I assume it will be a change in administrator\components\com_virtuemart\helpers\calculationh.php

did a quick diff between 3.2.x and 3.4.x and there are some substantial changes in that file

if u diff the two versions around lines 800 and again 890 you can see changes to discounts and taxperbill there

Is there any reason you don't use Vat Tax?
Title: Re: Tax calculation now wrong after upgrading to Virtuemart 3.4.2 and Joomla 3.8.13
Post by: peterf on October 23, 2018, 23:45:21 PM
Thanks for your reply. I guess if I change anything in administrator\components\com_virtuemart\helpers\calculationh.php then it may be overwritten in a future update? So it looks like I will have to use VAT Tax. The reason I don't use it at present are small things like when an item is added to the basket Tax is added straight away. The site deals mainly with trades people who are used to seeing prices excl. Tax. With VAT Tax the price on the page is different to the price in the basket - see image below, because Tax has been added to the price in the basket whereas this didn't happen with Tax per Bill.
Title: Re: Tax calculation now wrong after upgrading to Virtuemart 3.4.2 and Joomla 3.8.13
Post by: GJC Web Design on October 23, 2018, 23:51:32 PM
You can over ride the cart listings to display what ever prices you would like to show -- all prices are available there

Title: Re: Tax calculation now wrong after upgrading to Virtuemart 3.4.2 and Joomla 3.8.13
Post by: peterf on October 24, 2018, 00:23:26 AM
Sorry to sound dumb. But where can I find those options? Thanks
Title: Re: Tax calculation now wrong after upgrading to Virtuemart 3.4.2 and Joomla 3.8.13
Post by: GJC Web Design on October 24, 2018, 12:33:06 PM
its not options but just over ride and adapt the code to show what prices u want to see in

templates\xxx\html\com_virtuemart\cart\default_pricelist.php

if in the loop u add

print 'Debug Line '.__LINE__.' $prow->prices <pre>'; print_r ($prow->prices); print "</pre><br />\n";

you can see all available prices

e.g.

Array
(
    [virtuemart_product_price_id] => 1193
    [virtuemart_product_id] => 1152
    [virtuemart_shoppergroup_id] => 0
    [product_price] => 81.72
    [override] => 0
    [product_override_price] => 0
    [product_tax_id] => 1
    [product_discount_id] => 0
    [product_currency] => 9
    [product_price_publish_up] => 0000-00-00 00:00:00
    [product_price_publish_down] => 0000-00-00 00:00:00
    [price_quantity_start] => 0
    [price_quantity_end] => 0
    [created_on] => 2017-07-26 03:18:18
    [created_by] => 2489
    [modified_on] => 2018-10-16 04:56:16
    [modified_by] => 62
    [locked_on] => 0000-00-00 00:00:00
    [locked_by] => 0
    [costPrice] => 81.72
    [basePrice] => 81.72
    [basePriceVariant] => 81.72
    [basePriceWithTax] => 89.892
    [discountedPriceWithoutTax] => 81.72
    [priceBeforeTax] => 81.72
    [salesPrice] => 89.892
    [taxAmount] => 8.172
    [salesPriceWithDiscount] => 0
    [salesPriceTemp] => 89.892
    [unitPrice] => 0
    [priceWithoutTax] => 81.72
    [discountAmount] => -0
    [variantModification] => 0
    [DBTax] => Array
        (
        )

    [Tax] => Array
        (
        )

    [VatTax] => Array
        (
            [1] => Array
                (
                    [0] => GST
                    [1] => 10.0000
                    [2] => +%
                    [3] => 0
                    [4] => 9
                    [5] =>
                    [6] => 1
                    [7] => 1
                )

        )

    [DATax] => Array
        (
        )

    [Marge] => Array
        (
        )

    [salesPriceTt] => 89.892
    [discountedPriceWithoutTaxTt] => 81.72
    [priceWithoutTaxTt] => 81.72
    [discountAmountTt] => -0
    [taxAmountTt] => 8.172
    [subtotal_with_tax] => 89.892
    [subtotal_tax_amount] => 8.172
    [subtotal_discount] => 0
    [subtotal] => 81.72
)
Title: Re: Tax calculation now wrong after upgrading to Virtuemart 3.4.2 and Joomla 3.8.13
Post by: peterf on October 28, 2018, 05:20:43 AM
Thank you