MishkaPay.TaxSettings (Mishka Pay v0.0.1)

Copy Markdown View Source

A site's tax settings at a provider that counts the tax (Stripe Tax): where the business is and what a price without its own tax fields counts as. A guarded_struct, read with MishkaPay.fetch_tax_settings/2 and changed with MishkaPay.update_tax_settings/1, which sends only the fields given.

  • :provider, :tenant: which provider, with whose keys.
  • :head_office: where the business is located for tax, a MishkaPay.Address (its :country at least; a US address needs its :state and :postal_code).
  • :tax_code: the tax category of a product that names none (Stripe's "txcd_10000000", general electronic services).
  • :tax_behavior: what a price that says neither counts as: :exclusive, :inclusive, or :inferred_by_currency (inclusive in currencies where prices usually hold the tax).

What the provider fills in: :status, :active once the provider can count the tax, else :pending with the :missing_fields it still needs ("head_office"...).

Summary

Types

t()

The struct that builder/1 returns.

Functions

A sample %MishkaPay.TaxSettings{} populated from defaults + type-based fallbacks.

Types

t()

@type t() :: %MishkaPay.TaxSettings{
  head_office: MishkaPay.Address.t() | nil,
  missing_fields: list() | nil,
  provider: String.t(),
  registration: MishkaPay.TaxSettings.Registration.t() | nil,
  status: (:active | :pending) | nil,
  tax_behavior: (:inclusive | :exclusive | :inferred_by_currency) | nil,
  tax_code: String.t() | nil,
  tenant: term() | nil
}

The struct that builder/1 returns.

FieldTypeRequiredDefaultDescriptionDerives
:providerString.t()yessanitize(trim) validate(not_nil_value, string, not_empty)
:tenantterm() | nilno
:head_officeMishkaPay.Address.t() | nilno
:tax_codeString.t() | nilnosanitize(trim) validate(string, not_empty, max_len=100)
:tax_behavior:inclusive | :exclusive | :inferred_by_currency | nilnovalidate(enum=Atom[inclusive::exclusive::inferred_by_currency])<br>validator {MishkaPay.TaxSettings, :tax_behavior}
:status:active | :pending | nilnovalidate(enum=Atom[active::pending])
:missing_fieldslist() | nilnovalidate(list)
:registrationMishkaPay.TaxSettings.Registration.t() | nilnoWhere the seller is registered to collect tax (taxreg_... at Stripe Tax): a provider that counts the tax (automatic tax, MishkaPay.calculate_tax/1) charges it only where the seller is registered. A guarded_struct, added with MishkaPay.create_tax_registration/1, listed with MishkaPay.list_tax_registrations/3 and ended with MishkaPay.expire_tax_registration/4. A provider never deletes one.

Functions

builder(attrs_or_input, error \\ false)

enforce_keys()

enforce_keys(field)

example()

A sample %MishkaPay.TaxSettings{} populated from defaults + type-based fallbacks.

keys()

keys(field)