Ignore potential error where default tax rate is nil

If the current tax rates are badly *misconfigured*, and an included-tax rate is being applied but a *default* rate does not exist (there are validations to stop this case from occurring, see DefaultTaxZoneValidator), this line can throw an error. This situation will not actually arise in production, but can happen fairly easily in dev or with staging data when switching datasets, and when it does it's kind of annoying.

Note: the logic in the check here is still good; if there's no default tax rate we check if the order's tax zone matches the zone for the current tax rate, which is correct.
This commit is contained in:
Matt-Yorkley
2021-06-17 12:46:08 +01:00
parent a8efbffca6
commit 148349f0f3

View File

@@ -114,7 +114,7 @@ module Spree
end
def default_zone_or_zone_match?(order)
Zone.default_tax.contains?(order.tax_zone) || order.tax_zone == zone
Zone.default_tax&.contains?(order.tax_zone) || order.tax_zone == zone
end
# Manually apply a TaxRate to a particular amount. TaxRates normally compute against