#14767·spree

VatPriceCalculation adds VAT on top of tax_inclusive market prices; delivery rates have no escape

Author: MatthewKennedyCreated Sep 29, 2026Updated Sep 30, 2026

Context

Take a store whose markets each carry their own currency price, entered as the shelf price for that market. For example:

Market Currency tax_inclusive Countries
Default USD false US, …
United Kingdom GBP true GB

A £50 GBP price means a UK customer pays £50, VAT included. Spree::VatPriceCalculation instead treats every price as including the VAT of the store's home country (store.default_country, i.e. the default market's first country). Since the default market is the tax-exclusive USD one, every UK price is treated as net and gets 20% added.

Customer-visible result: £50 becomes £60 as soon as a GB address is on the order, and £5 shipping becomes £6. Present in 5.6.1 (default-tax-zone based) and reproduced on main (53d9925, 6.0.0.beta4), where the home country now comes from store.default_country. Market#tax_inclusive isn't read by the restatement at all.

Expected Behavior

A price in a tax_inclusive market's currency, charged to a buyer in that market, is charged as entered. The 20% UK VAT is included (£8.33 of £50), not added on top. The same goes for delivery rates.

Actual Behavior

  • Product: price_including_vat_for(country: GB, market: uk_market) on a £50 GBP base price returns 60.0.
  • Shipping: gross_amount(5, tax_category:, country: GB, market: uk_market) (the options Stock::Estimator#taxation_options_for passes) returns 6.0.

For products there's a workaround on main: putting the GBP price in a price list with a Spree::PriceRules::MarketRule makes Price#final_for_destination? true, and the price is charged as entered (50.0 in the spec below). Delivery rates have no equivalent. Stock::Estimator#rate_cost always calls gross_amount, so a tax-inclusive market can't quote a VAT-inclusive shipping price unless its country is the store's default country.

Possible Fix

Treat an amount priced in a tax_inclusive market's currency, for that market, as already destination-inclusive, so it isn't restated. For example, in VatPriceCalculation#gross_amount:

ruby
market = price_options[:market] || Spree::Current.market
return amount if market&.tax_inclusive? && market.countries.include?(country_from(price_options))

At minimum, give delivery rates the same "final for destination" escape that prices get from geographic price lists.

Steps to Reproduce

Spec, runnable in spree/core on main:

ruby
require 'spec_helper'

describe 'VAT restatement with a per-market tax-inclusive currency price', type: :model do
  let(:store) { @default_store }
  let(:gb) { Spree::Country.by_iso('GB') }
  let(:category) { create(:tax_category) }
  let(:row_market) { store.default_market }
  let!(:uk_market) do
    create(:market, store: store, name: 'United Kingdom', currency: 'GBP',
                    tax_inclusive: true, country_codes: %w[GB])
  end

  before do
    row_market.update!(countries: [Spree::Country.by_iso('US')], currency: 'USD', tax_inclusive: false)
    store.update!(supported_currencies: 'USD,GBP')
    create(:tax_rate, name: 'UK VAT 20% incl', amount: 0.20, tax_category: category,
                      country_code: 'GB', included_in_price: true, store: store)
  end

  let(:variant) { create(:variant, price: 100, product: create(:product, tax_category: category)) }

  it 'charges a UK buyer the entered GBP price' do
    price = variant.prices.create!(currency: 'GBP', amount: 50)
    expect(price.price_including_vat_for(country: gb, market: uk_market)).to eq(50) # got 60.0
  end

  it 'charges a UK buyer the entered shipping rate' do
    calc = Class.new { include Spree::VatPriceCalculation; public :gross_amount }.new
    expect(calc.gross_amount(BigDecimal('5'), tax_category: category, country: gb, market: uk_market))
      .to eq(5) # got 6.0
  end

  it 'price-list workaround (products only)' do
    list = create(:price_list, store: store)
    Spree::PriceRules::MarketRule.create!(price_list: list, preferred_market_ids: [uk_market.id])
    price = variant.prices.create!(currency: 'GBP', amount: 50, price_list: list)
    expect(price.reload.price_including_vat_for(country: gb, market: uk_market)).to eq(50) # passes
  end
end

Your Environment

  • Version used: main @ 53d9925 (6.0.0.beta4); also present in 5.6.1
  • Ruby 4.0.1, Rails dummy app (SQLite), built-in Spree::TaxProvider::Internal
  • Workaround: prepend a module that makes gross_amount return amount on Spree::Price and Spree::Stock::Estimator. That only works when every market prices in its own currency, so it isn't a general fix.