November Happy Hour will be moved to Thursday December 5th.

Setting Tax Values

Vote:
 

Commerce 11.8.2

We use serialised carts and currently are unable to set the tax value on the cart.

We can get the tax value using the taxcalculator, but it looks like setting the tax value isn't exposed on the new seralised carts/orderforms/ordergroups.

Documentation here: https://world.episerver.com/documentation/developer-guides/archive/commerce/orders/10-11/ shows how to get the tax but not set the tax.

Any assistance or direction to documentation would be great.

#195359
Edited, Jul 20, 2018 17:33
Vote:
 

You would need to implement ITaxCalculator to return the tax value you would want to, and they will be set for you.

Also, in Commerce 11 or before the tax is calculated every time IOrderGroup is loaded. I would suggest to upgrade go later version (Commerce 12) for better performance.

#195361
Jul 20, 2018 17:54
Vote:
 

Thanks Quan. 

Would this allow us to dynamically set the tax total ourselves...lets say we've already precalculated the tax at £100 and we just want to set this tax on the cart how is this possible?

#195362
Jul 20, 2018 18:14
Vote:
 

In Commerce 12 you have PricesIncludeTax property in IMarket. That indicates your prices already have precalculated taxes (like in EU). i guess that is what you want

#195363
Jul 20, 2018 18:25
Vote:
 

Hi Quan, 

What I want to do is to be able to set TaxTotal on the serialised cart and subsequent orderforms/ordergroup/purchaseorder. This property isn't exposed in the current interfaces and I cannot see how to set it anywhere else.

Unfortunatly while commerce 12 is on the road map to upgrade it currently isn't possible and so we have to develop this on 11.8.2

#195364
Jul 20, 2018 18:54
Vote:
 

I don't know a guaranteed workaround, but you should be able to cast the instance to the concrete implementation and set it. of course that's an ugly way to do so.

What prevents you from upgrading to Commerce 12?

#195366
Jul 20, 2018 19:58
Vote:
 

Hi Quan,

Time frames prevent the upgrade to Commerce 12, as I said it is on the roadmap but for later down the line.

I have tried to use the concrete implementations:

((PurchaseOrder)purchaseOrder).TaxTotal = 100.0M; // Not hard coded just as an example
purchaseOrder.GetTotal(_orderGroupCalculator);
_orderRepository.Save(purchaseOrder);

In doing the above I can see TaxTotal on the PurchaseOrder, but, as soon as we save it the TaxTotal is zero'd

#195391
Jul 23, 2018 12:52
Vote:
 

Did you try this? 

#195392
Jul 23, 2018 13:00
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.