I have a shop with some taxes types configured, if I add a product to the cart and checkout to the preview page, not finishing the transaction, I can see the taxes based on my order item and that works just fine. But if I edit that tax type and uncheck the "Display taxes of this type inclusive in product prices.", when I add a product, Drupal will try to calculate the taxes since it already knows my address but it will fail with a
The website encountered an unexpected error. Please try again later.</br></br><em class="placeholder">Drupal\Core\Entity\EntityStorageException</em>: The provided number "0.08" must be a string, not a float. in <em class="placeholder">Drupal\Core\Entity\Sql\SqlContentEntityStorage->save()</em> (line <em class="placeholder">805</em> of <em class="placeholder">core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php</em>).
After that, there is nothing I can do, this error appear everytime drupal loads the order, so the cart block breaks the site, visualizing the order in a list breaks the site, trying to load it programmatically to delete breaks the site, etc...
Comments
Comment #2
jsacksick commented@Joao Sausen: I've been trying to reproduce the bug with no success so far.
Here's my test scenario:
1) After setting-up VAT, I added a product to the cart
2) I entered my billing info + shipping info on checkout, then went to the review step.
3) I opened the VAT tax type, unchecked "Display taxes of this type inclusive in product prices."
4) I added a new product to the cart, and it worked as expected...
Could you give me more details perhaps?
Comment #3
bojanz commentedComment #4
andyg5000This is happening to me on one of my TaxTypes, but not all of them. The TaxType is implementing a custom class, but it just extends the Custom class and overrides the applies method. I've included a screenshot of the exception and call stack.
Comment #5
andyg5000Comment #6
bojanz commentedBug identified.
This only happens if you extend the Custom class, but forget to add schema (which is required, but Drupal doesn't enforce it very well right now). By adding an explicit cast we can punt on this, let non-crashy bugs happen instead (such as the inability to translate).
Comment #8
bojanz commentedAdded a cast on submit as well. Thanks, Andy!