Developer forum

Forum » Development » Vat Calculation

Vat Calculation

Umar Farooq
Reply

Hi,

we are using VAT Groups for VAT calculation. We are using Price Matrix and all the prices are Excluding VAT. In Some Special scenarios we have to change the oderline price in cart  and  i am setting the price like this 

orderLineService.SetUnitPrice(orderLine, prodprice.Price);

it sets the order line price Correctly but then cart doesn't calculate the VAT  and its always 0%. Is this Behavious is intented Or i am missing something and how can i solve this? 

Best Regards,

Umar


Replies

 
Nicolai Pedersen
Reply

Hi Umar

Can you share some more code? The entire method and the context of where it is called. And please also specify which version.

Thanks for clarifying!

BR Nicolai

 
Umar Farooq
Reply

Hi Nicolai,

Thansks your your Quick response. We are using Dynamicweb 9.5.3 and i have added the complete code file Please find the attachment

BR Umar

 
Nicolai Pedersen
Reply

Hi Umar

Can you try to update your local development to latest 9.6 or 9.7 and run the code again?

 
Umar Farooq
Reply

Hi Nicolai,

Yes, I can update to the latest DW version and see if it resolve the issue and then write back to you 

/umar  

 
Umar Farooq
Reply

Hi Nicolai,

So As per your suggestion I have updated to 9.6.15 but still got the same issue it doesn't calculate the VAT when you set the orderline unit price.

BR Umar

 
Nicolai Pedersen
Reply

Thanks for trying.

In this scenario, on 9.6, when you call set unit price with a double, Dynamicweb will encapsulate that value first in a priceraw and then in a PriceCalculated. PriceCalculated is the one holding the VAT - the PriceCalculated instance that is created when calling this overload will be using Common.Context.Currency and Common.Context.Country - holding the information on currency and country which controls the VAT. So you need to ensure that those 2 are correct - try to add a debugger and see if especially that the country is correct.

The orderlineservice also has an overload SetUnitPrice(orderLine As OrderLine, priceInfo As PriceInfo, forcePriceRecalculation As Boolean) where you can pass a PriceInfo - and the priceinfo will hold the amount with and without vat and vat percentage. A somewhat more complicated object, but gives you full control. This can be an alternative.

Usually when overriding prices in Dynamicweb, you would implement a priceprovider instead - that is meant for this scenario - and will be called all the right places. See an example here: https://doc.dynamicweb.com/api/html/46b0e0a8-5a77-3712-038d-c7fbc4e96346.htm. You have access to all the same information, so it is also worth considering.

We are changing quite a bit in this area (prices, currencies and countries) to make things like this more explicit.

In 9.8 we are changing these things quite dramatically to not rely that much on the context - but on the order instance instead. That should simplify manipulations like the one you have here.

BR Nicolai

 

You must be logged in to post in the forum