Class: Spree::Commissions::ResolveTaxRate

Inherits:
Object
  • Object
show all
Includes:
ServiceModule::Base
Defined in:
app/services/spree/commissions/resolve_tax_rate.rb

Overview

How a commission is taxed — the rate, and the treatment behind it.

This is tax on the marketplace's own service to the seller, not on the goods the customer bought — a separate supply with its own place of taxation, which is why it is asked against the seller's billing address rather than wherever the parcel went.

Precedence: an explicit override on the rate, else the sale's tax engine, else the store's default. A provider with no opinion returns nil rather than zero, so silence falls through to the default instead of being read as "this fee is untaxed".

The treatment is only as good as its source: an operator override or a store default is a number someone typed, so it is recorded as standard rated without inventing a jurisdiction for it. Only the tax engine knows where it taxed the fee.

Swap through Spree.commissions_resolve_tax_rate_service.

Instance Method Summary collapse

Methods included from ServiceModule::Base

prepended

Instance Method Details

#call(rate:, seller:, order:) ⇒ Spree::CommissionTax

Parameters:

Returns:



30
31
32
33
34
35
36
37
# File 'app/services/spree/commissions/resolve_tax_rate.rb', line 30

def call(rate:, seller:, order:)
  return success(configured(rate.commission_tax_rate)) if rate.commission_tax_rate.present?

  from_provider = provider_tax(seller: seller, order: order)
  return success(from_provider) if from_provider

  success(configured(order.store.preferred_default_commission_tax_rate))
end