Skip VAT price generation without a valid price - #6566
Open
jarednorman wants to merge 1 commit into
Open
Conversation
Spree::Variant::VatPriceGenerator#run calls variant.default_price.net_amount, which raises NoMethodError when the default price is missing or has a nil amount. Because the generator runs in a before_validation callback, creating a product without a price (in a store with VAT rates for other countries) raises instead of showing the price validation error.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6566 +/- ##
=======================================
Coverage 92.26% 92.26%
=======================================
Files 1037 1037
Lines 21211 21212 +1
=======================================
+ Hits 19570 19571 +1
Misses 1641 1641 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
tvdeyen
approved these changes
Sep 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Creating a product without a price in a store that has VAT rates configured raises
NoMethodErrorinstead of just showing a validation error. This makes the user sad because they don't know what's wrong. This extremely simple fix adds an early return so we don't divide by zero. Shout out to @firemind for the initial work on #5324, which this supersedes.