Skip to content

Commit

Permalink
Prevent hard-errors when VatPriceGenerator is invoked without a defau…
Browse files Browse the repository at this point in the history
…lt price
  • Loading branch information
firemind committed Aug 9, 2023
1 parent 3ef8231 commit 94820f8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/app/models/spree/price.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ def price=(price)
end

def net_amount
return nil unless amount

amount / (1 + sum_of_vat_amounts)
end

Expand Down
1 change: 1 addition & 0 deletions core/app/models/spree/variant/vat_price_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def initialize(variant)
def run
# Early return if there is no VAT rates in the current store.
return if !variant.tax_category || variant_vat_rates.empty?
return unless variant.default_price.net_amount

country_isos_requiring_price.each do |country_iso|
# Don't re-create the default price
Expand Down

0 comments on commit 94820f8

Please sign in to comment.