Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Declare that the internal provider cannot apportion delivery tax

Łukasz Adamczyk69a407efd86e
diff --git a/docs/plans/6.0-tax-provider.md b/docs/plans/6.0-tax-provider.md
index 30f94dfd35..e767cb0b0e 100644
--- a/docs/plans/6.0-tax-provider.md
+++ b/docs/plans/6.0-tax-provider.md
@@ -541,7 +541,8 @@ module Spree
class Base
# Domains this provider cannot handle, so the Market admin can warn a
# merchant instead of letting it under-collect silently. Internal declares
- # :us_local_tax, :reverse_charge, :oss_thresholds.
+ # :us_local_tax, :reverse_charge, :oss_thresholds,
+ # :proportional_delivery_tax.
#
# @return [Array<Symbol>]
def self.unsupported_capabilities
@@ -883,6 +884,7 @@ Computes tax directly from TaxRate configuration — rate × discounted base, wi
- Stamp `taxability_reason` (`standard_rated` for a positive rate, `zero_rated` for a matched zero rate — finer distinctions such as `reduced_rated` are a rate-configuration concern, not something to infer) and the jurisdiction snapshot: from the matched rate's country/state after Phase 5, from the tax zone's country until then.
- Honor the `exemptions:` input — entries covering an item produce `amount: 0` rows with `customer_exempt` for the jurisdictions they scope to.
- Ignore `tax_identifier:` entirely; reverse charge is on the unsupported list, so a buyer registration changes nothing here.
+- Tax delivery at the one rate its delivery method names, never apportioned across the rates of the goods being delivered. Under EU VAT the delivery charge belongs to the same supply as the goods, so a basket mixing rates needs a weighted blend on delivery, and US states apportion by their own varying rules. Declared as `:proportional_delivery_tax` rather than approximated: a blend invented in core would be wrong in a different way in each jurisdiction, and an external provider is where that judgement belongs.
- Its limits are declared as capabilities and warned about when a market is paired, not reported per calculation — "no rate matched" is a legitimate answer for a merchant with no tax configured in the destination, and simply produces no row.
```ruby
@@ -890,7 +892,7 @@ module Spree
module TaxProvider
class Internal < Base
def self.unsupported_capabilities
- %i[us_local_tax reverse_charge oss_thresholds]
+ %i[us_local_tax reverse_charge oss_thresholds proportional_delivery_tax]
end
private
diff --git a/spree/api/spec/controllers/spree/api/v3/admin/tax_providers_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/admin/tax_providers_controller_spec.rb
index 664e6b9927..751e8a4c8e 100644
--- a/spree/api/spec/controllers/spree/api/v3/admin/tax_providers_controller_spec.rb
+++ b/spree/api/spec/controllers/spree/api/v3/admin/tax_providers_controller_spec.rb
@@ -17,7 +17,7 @@ RSpec.describe Spree::Api::V3::Admin::TaxProvidersController, type: :controller
expect(internal['available']).to be(true)
expect(internal['default']).to be(true)
expect(internal['unsupported_capabilities'].map { |capability| capability['key'] }).to(
- contain_exactly('us_local_tax', 'reverse_charge', 'oss_thresholds')
+ contain_exactly('us_local_tax', 'reverse_charge', 'oss_thresholds', 'proportional_delivery_tax')
)
end
diff --git a/spree/core/app/models/spree/tax_provider/internal.rb b/spree/core/app/models/spree/tax_provider/internal.rb
index 6c5f947fce..6ef12fa699 100644
--- a/spree/core/app/models/spree/tax_provider/internal.rb
+++ b/spree/core/app/models/spree/tax_provider/internal.rb
@@ -7,11 +7,12 @@ module Spree
# default tax category's rates.
class Internal < Base
# Rates are configured per country or state with no local-tax breakdown, no buyer
- # registration handling and no distance-selling thresholds. Declared so a
- # merchant pairing this with a market is told, rather than discovering it
- # in a return.
+ # registration handling, no distance-selling thresholds, and delivery taxed
+ # at its own method's rate rather than apportioned across the rates of the
+ # goods it carries. Declared so a merchant pairing this with a market is
+ # told, rather than discovering it in a return.
def self.unsupported_capabilities
- %i[us_local_tax reverse_charge oss_thresholds]
+ %i[us_local_tax reverse_charge oss_thresholds proportional_delivery_tax]
end
# +tax_date+ is accepted and ignored: TaxRate rows carry no validity
diff --git a/spree/core/config/locales/en.yml b/spree/core/config/locales/en.yml
index 476fb6c2fe..e97dcba604 100644
--- a/spree/core/config/locales/en.yml
+++ b/spree/core/config/locales/en.yml
@@ -1517,6 +1517,9 @@ en:
oss_thresholds:
description: Crossing the EU-wide cross-border threshold does not switch to destination-country rates automatically, because it depends on annual turnover across every destination rather than on any single order.
label: Distance-selling thresholds
+ proportional_delivery_tax:
+ description: Delivery is taxed at the single rate its delivery method names, not split across the rates of the goods being delivered. A basket mixing tax rates collects the wrong amount on delivery.
+ label: Proportional delivery tax
reverse_charge:
description: A VAT-registered business buyer is charged tax instead of receiving a zero-rated invoice. Their registration number is recorded but does not change the tax.
label: EU reverse charge
diff --git a/spree/core/spec/models/spree/tax_provider/base_spec.rb b/spree/core/spec/models/spree/tax_provider/base_spec.rb
index c1f96001b1..5604232ce3 100644
--- a/spree/core/spec/models/spree/tax_provider/base_spec.rb
+++ b/spree/core/spec/models/spree/tax_provider/base_spec.rb
@@ -51,7 +51,7 @@ describe Spree::TaxProvider::Base, type: :model do
expect(hash[:available]).to be(true)
expect(hash[:default]).to be(true)
expect(hash[:unsupported_capabilities].map { |capability| capability[:key] }).to eq(
- %w[us_local_tax reverse_charge oss_thresholds]
+ %w[us_local_tax reverse_charge oss_thresholds proportional_delivery_tax]
)
end
@@ -111,7 +111,7 @@ describe Spree::TaxProvider::Base, type: :model do
describe 'the internal provider' do
it 'declares the domains rate configuration cannot express' do
expect(Spree::TaxProvider::Internal.unsupported_capabilities).to(
- contain_exactly(:us_local_tax, :reverse_charge, :oss_thresholds)
+ contain_exactly(:us_local_tax, :reverse_charge, :oss_thresholds, :proportional_delivery_tax)
)
end