Tax rates in Shipping method orderLines - Afterpay/Riverty integration VM 4.0.12

Started by idealcheckout, January 19, 2023, 10:44:01 AM

Previous topic - Next topic

idealcheckout

Hey Ladies/Gentlemen,

We are working on a new integration for Afterpay/Riverty.
Its done on a default installation of Joomla 3.10.11 and VirtueMart 4.0.12 10777.
We have set the default tax rate in the store to 21%.

Other payment methods work like a charm (iDEAL, Bancontact, Sofort, Creditcard etc).
For Afterpay/Riverty however we need to include orderLines, thats where our problem began.
The problem is specific to the tax rates for the shipping method in Virtuemart.

When reading the order object you can find the shipping cost and taxes;


$order['details']['ST']->order_shipment
$order['details']['ST']->order_shipment_tax


In our example we have the default method Self pick-up active, with a tax rate of 21% and a price of € 3,99.
When we look at the order object, it states the following:


    [order_shipment] => 3.99000
    [order_shipment_tax] => 0.83790


So this means the following;

Price incl:
3,99

Tax:
0,84 (rounded, also shown in cart)

So price excl:
3,99 - 0,84 = 3,15


Now we have to calculate the tax rate, to pass onto the afterpay object

taxRate = (0,84 / 3,15) * 100

This shows 27%, instead of the expected 21%.

If I dont round anything in the entire orderLine, it shows the following;


[2] => Array
        (
            [id] => shipping
            [code] => shipping
            [name] => Shipment cost
            [description] => Shipment cost
            [quantity] => 1
            [price_incl] => 3.99000
            [price_excl] => 3.1521
            [vat_amount] => 0.83790
            [vat] => 26.5822784810127
        )


The same calculation is done on the product lines, these all show correct values, but the shipping method does not.
For example;


[0] => Array
        (
            [id] => 161
            [code] => PRCB
            [name] => Cap 34Baseball34
            [description] => Need something genuine for your freetime?
            [quantity] => 1
            [price_incl] => 19.16
            [price_excl] => 15.83
            [vat_amount] => 3.33
            [vat] => 21
        )

    [1] => Array
        (
            [id] => 162
            [code] => TPCM
            [name] => Cowboy Hat
            [description] => Classic pattern, durable stiff brim resists sun & moisture.
            [quantity] => 1
            [price_incl] => 12.1
            [price_excl] => 10
            [vat_amount] => 2.1
            [vat] => 21
        )



Am i making a calculation error somewhere, or lies the problem elsewhere?


Jörgen

Yes, you are a bit off

21 % = 0.8379 / 3.99

Try that calculation instead.

Jörgen
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

idealcheckout

Hello Jörgen,

If we know what the percentage was, i didnt have to make the calculation.
However, we only know what the price incl is and the tax amount.

This same calculation is done on the product lines and its correct there, just the shipping method shows a wrong percentage.

Jörgen

That iis the point, you have to know what you are charging. The total exclusive 21 % tax addon is 3,99. That makes AFAIK total shipment cost 3.99 *1,21 = 4,8279.
I do not think I am wrong here, you set shipment_cost in shipment option and then vat is added...

Jörgen
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

idealcheckout

Hello Jörgen,


I think you might be right here, the entered price is not including tax but its without.
I'll continue with the plug-in today and see if thats the solution i have been looking for.

Thanks in advance!