mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-28 21:07:16 +00:00
Add Bugsnag notification if we reach tax rate refund code
The original Spree code allow for a tax adjustment to be considered a refund in a specific scenario: - instance is using inclusive tax - instance that applies different tax rate in different tax zones This scenario should not happen with how our instances are configured More info: https://github.com/openfoodfoundation/openfoodnetwork/pull/6565#discussion_r566535431
This commit is contained in:
@@ -105,6 +105,15 @@ module Spree
|
||||
if default_zone_or_zone_match?(item.order)
|
||||
calculator.compute(item)
|
||||
else
|
||||
# Tax refund should not be possible with the way our production server are configured
|
||||
Bugsnag.notify(
|
||||
"Notice: Tax refund should not be possible, please check the default zone and " \
|
||||
"the tax rate zone configuration"
|
||||
) do |payload|
|
||||
payload.add_metadata :order_tax_zone, order.tax_zone
|
||||
payload.add_metadata :tax_rate_zone, zone
|
||||
payload.add_metadata :default_zone, Zone.default_tax
|
||||
end
|
||||
# In this case, it's a refund.
|
||||
calculator.compute(item) * - 1
|
||||
end
|
||||
|
||||
@@ -386,6 +386,16 @@ module Spree
|
||||
Spree::TaxRate.adjust(order, order.line_items)
|
||||
expect(line_item.adjustments.credit.count).to eq 2
|
||||
end
|
||||
|
||||
it "notifies bugsnag" do
|
||||
# there are two tax rate
|
||||
expect(Bugsnag).to receive(:notify).with(
|
||||
"Notice: Tax refund should not be possible, please check the default zone and " \
|
||||
"the tax rate zone configuration"
|
||||
).twice
|
||||
|
||||
Spree::TaxRate.adjust(order, order.line_items)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user