VatPriceCalculation 会在不含税市场价格之上加上增值税;运费没有任何例外。
作者: MatthewKennedy创建于 2026年9月29日更新于 2026年9月30日
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: [gb]) end it 'should charge VAT on a GBP price' do expect(Spree::Current).to receive(:market).and_return(uk_market) expect(Spree::Current).to receive(:country).and_return(gb) expect(Spree::Current).to receive(:tax_category).and_return(category) expect(Spree::Current).to receive(:price).and_return(50.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_calculation).and_return(Spree::VatPriceCalculation#gross_amount).and_return(60.0) expect(Spree::Current).to receive(:vat_price_c
内容来源: spree/spree