Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate overall tax cost after shipping calculator overrides #471

Open
karlitros opened this issue Feb 27, 2024 · 2 comments
Open

Calculate overall tax cost after shipping calculator overrides #471

karlitros opened this issue Feb 27, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@karlitros
Copy link

Requirement
We have a requirement to implement an external tax calculation process, but only for customers based in the United States.

Each product and shipping method has its own tax code, and tax calculation can involve adding up the sub total cost of multiple separate tax rates between US states, depending on where in the US the company ships the product.

I'd love to be able to use calculation events in this order:

  • calculate order line price sub total (already exists)
  • calculate shipping cost sub total (already exists)
  • calculate tax on all of the above using an override that implements my new external tax calculation process (new feature?)
  • head to checkout with my final cost, and separate tax value specified.

However, I can only seem to:

  • calculate cost per product with an option to override tax calculation on the product
  • calculate order line sub total with an option to override tax calculation on the order line
  • calculate a shipping cost, with an option to override tax calculation on the shipping cost

This would require multiple requests to the external tax calculator.

The OrderCalculator class doesn't permit overriding, so I don't seem to be able to do anything with that, and amending the sub total in the Order Calculation State object within the shipping override isn't doing anything, as presumably I'm doing that too late in the pipeline.

Please let me know if I can do anything to help explain!

Cheers,

Karl

@karlitros karlitros added the enhancement New feature or request label Feb 27, 2024
@karlitros karlitros changed the title OrderCalculator modification after shipping calculation Calculate overall tax cost after shipping calculator overrides Feb 27, 2024
@mattbrailsford
Copy link
Contributor

Hey Karl,

Yea, the current implementation is very European centric, assuming the tax rates are known before hand, hence why it currently does most calculations up front.

The way I have seen others in the US get around this for the time being is to effectively set the entire order to 0% tax rate, but then implement a price adjuster (see https://docs.umbraco.com/umbraco-commerce/key-concepts/price-amount-adjustments) for the order total price which then goes and does it's own calculation but returns a price with a 0 value, but a positive tax value.

If you are using some external service to calculate taxes, you'll probably want to implement a cache to ensure it doesn't get hit constantly as Umbraco Commerce does recalculate the order a lot. What I've advised in the past is to take a hash of the order items product references + quantities and used that as a cache key so it only recalculates if the order items change.

I hope this helps

Matt

PS it is something we know we need to address to allow more robust tax calculations, but hopefully this gives you a workaround in the meantime.

@karlitros
Copy link
Author

Thanks Matt, that's a super speedy response. I appreciate it a lot.

I'll give this a shot, and see how I get on!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants