Skip to content

Skip VAT price generation without a valid price - #6566

Open
jarednorman wants to merge 1 commit into
solidusio:mainfrom
SuperGoodSoft:fix/vat-price-generator-nil-amount
Open

Skip VAT price generation without a valid price#6566
jarednorman wants to merge 1 commit into
solidusio:mainfrom
SuperGoodSoft:fix/vat-price-generator-nil-amount

Conversation

@jarednorman

@jarednorman jarednorman commented Sep 1, 2026

Copy link
Copy Markdown
Member

Creating a product without a price in a store that has VAT rates configured raises NoMethodError instead 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.

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

codecov Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.26%. Comparing base (a301093) to head (6e09de4).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:solidus_core Changes to the solidus_core gem

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants