What are the Slack Archives?
It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.
Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..
Hello, following the spryker code for tax rate calculation there is a function which will be called
Hello,
following the spryker code for tax rate calculation there is a function which will be called when adding an item via glue addItemToCart endpoint
protected function recalculateWithItemsAndShippingAddress(ArrayObject $itemTransfers, ?AddressTransfer $shippingAddressTransfer): ArrayObject { $countryIso2Code = $this->getShippingCountryIso2Code($shippingAddressTransfer); $allIdProductAbstracts = $this->getAllIdAbstractProducts($itemTransfers); $taxRates = $this->findTaxRatesByAllIdProductAbstractsAndCountryIso2Code( $allIdProductAbstracts, $countryIso2Code ); return $this->setItemsTax($itemTransfers, $taxRates); }
This will fetch the correct taxrate by looking into the country code of the provided shipment address …
First a business related question: Why the taxrate gets calculated using the shipping address? Isn’t taxrate something that is specific for a certain country? So when i order as a german customer with a de iso2code in an asian shop, i assume i should not pay german taxes, right? So why the countrycode of the shipping address is relevant here?
Second is a technical one: Where can i set the shipping address (iso2code) that the taxes are calculated correctly?
Currently the shipping address is not set because there is never a opportunity to do that in a typical glue wrokflow where you first create a cart and than add an item … non of these endpoints let me set an address
Currently the item taxrate always falls back to the default one which is 19% which is wrong in every case.
Best
Comments
-
I can suggest an answer to the second question. There is a
/checkout-data
endpoint, you can submit the shipping address to it. It does not return the quote in response, but the quote will get updated with shipping address in the process of the execution.You’ll have to see if this works though because the shipping address is not something that is being persisted with the quote, so it might get “lost” when you GET the cart after the /checkout-data.
It it does not, it’s a good candidate for a bug/feature request/FD report
0 -
Hi Eugenia, thanks for your fast response. I really wonder that I am the first who get this trouble because for me thats a very very standard use case to get correct prices in my cart when i add something to it.
I check your suggestion but i think - as you already mentioned - the shipping transfer will get lost when retrieving the cart …
So far the tax rate calculation is some really weird to me …
Best0 -
@UQKSAARKN Shouldn’t be persisted once you add the “shipping address” to \Spryker\Zed\Quote\QuoteConfig::getQuoteFieldsAllowedForSaving() ?
0 -
First a business related question
I think the US is the reason, and tax rate calculation between different states
0 -
You might need to check also the transfer QuoteUpdateRequestAttributes. As I know you’ve to have the attribute there for persisting to work correctly
0 -
as another solution I would think of providing the field you need (iso2code) directly to the quote object, specifically for tax calculation reasons and won’t stick to the shipping address, if that’s possible. The question is, can you determine that iso2code in the moment, when you create a cart (you should, otherwise, how will you calculate tax) ?
0 -
Along the cart would be absolutely fine
0 -
but i could imagine that there will be some mix … one some places, address gets considered on other the quote … so i have to overwrite the deprecated ProductItemTaxRateCalculator in any case
0 -
yes, there might be edge-cases in that solution I proposed: customer chooses another address, quote is getting merged, etc - you might also want to confirm with business if there could be simple solution to avoid tech over-complexity
0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 75 Spryker News
- 921 Developer Corner
- 781 Spryker Development
- 88 Spryker Dev Environment
- 362 Spryker Releases
- 3 Oryx frontend framework
- 34 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 25 Job Opportunities
- 3.2K 📜 Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 32 Product & Business Questions
- 70 Spryker Safari Questions
- 50 Random