solidus
solidus copied to clipboard
Prevent hard-errors when VatPriceGenerator is invoked without a defau…
Guard against exceptions when calling Price#net_amount without a price.
Skip trying to calculate foreign prices in VatPriceGenerator when the default_price does not have an amount set.
Because the VatPriceGenerator is invoked in a before_validate hook when creating a product, this can lead to exceptions when an admin tries to create a product without specifying a price (and there are non-default countries for which a price needs to be calculated).
This PR allows the validations to run without raising exceptions so the admin can see the validation errors.
Codecov Report
Merging #5324 (94820f8) into v3.4 (3ef8231) will increase coverage by
0.00%. The diff coverage is100.00%.
@@ Coverage Diff @@
## v3.4 #5324 +/- ##
=======================================
Coverage 86.64% 86.64%
=======================================
Files 580 580
Lines 14741 14743 +2
=======================================
+ Hits 12772 12774 +2
Misses 1969 1969
| Files Changed | Coverage Δ | |
|---|---|---|
| core/app/models/spree/price.rb | 97.72% <100.00%> (+0.05%) |
:arrow_up: |
| ...re/app/models/spree/variant/vat_price_generator.rb | 100.00% <100.00%> (ø) |
:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more
I labeled the PR as a breaking change, as it's changing a behavior some people could be relying on. It'll be merged in the next major.