Replacement for OrderContext.GetTaxes within ITaxCalculator?

Vote:
 

Hi,

After upgrade I am getting this warning:

 'OrderContext.GetTaxes(Guid, string, string, IOrderAddress)' is obsolete: 
'This method is no longer used. Use ITaxCalculator instead. Will remain at least until December 2019.' 


ITaxCalculator exposes only two methods that aren't tagged as obsolete, GetSalesTax and GetShippingTax. None of them is doing what OrderContext.Current.GetTaxes did.

Anyone has idea how to use ITaxCalculator instead of old GetTaxes? Thanx

#208513
Oct 25, 2019 13:06
Vote:
 

Hi Milos

I don't know how you want to use the tax values.

But if you just want to get the raw tax value objects you can directly use the TaxManager.GetTaxes method, as it is still there. You will need to read the DataTable returned and map it to TaxValue objects. Also, be aware that this method does not cache those tax values, so you may need to implement that yourself.

For calculating the tax amount of products in a product listing response, I sometimes find this fix useful.

For calculating tax amounts of line items, I suggest you use the ITaxCalculator approach. This approach saves the calculated values on the line item objects (and updates when neccessary), which is quite nice.

#208552
Oct 27, 2019 8:54
Vote:
 

What I practically want to do is to get rid of that Build Warning.

Just thought if GetTaxes is getting out soon there is another on ITaxCalculator that replaced it. The warning message at least implied that. I know that TaxManager.GetTaxes is still there, but December 2019 is next month, right?

#208848
Nov 04, 2019 10:15
Vote:
 

I believe only OrderContext.GetTaxes is marked for deprecation. I didn't see this on TaxManager.GetTaxes.

And given that the new ITaxCalculator implementation uses TaxManager under-the-hood, I believe it is safe to use that one for now. I mean, they need to replace it before they remove it, right.

#208855
Nov 04, 2019 10:57
Vote:
 

Pardon, you are correct, only this is marked obsolete OrderContext.Current.GetTaxes.

Thanks for the effort!

#208856
Nov 04, 2019 11:00
Vote:
 

I think I can add a bit more context to the answer. The reason we obsoleted several methods in OrderContext was we made a review/refactor of the API. GetTaxes does not really belong there as OrderContext should really be about orders. In a larger scale the class itself will be obsoleted one day (or at least marked as internal) in favor of new abstraction APIs like IOrderRepository or IOrderSearchService

#208917
Nov 04, 2019 22:29
Vote:
 

Thanks to all who answered.

#209473
Nov 14, 2019 16:49
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.