MishkaPay.TaxSettings.Registration (Mishka Pay v0.0.1)

Copy Markdown View Source

Where 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.

What the caller gives:

  • :provider, :tenant: which provider, with whose keys.
  • :country (required): the two-letter country.
  • :type (required): the kind of registration, in the provider's words. At Stripe: "standard" in most countries, "simplified" for a seller from abroad where only that exists; in the EU also "oss_union", "oss_non_union" or "ioss"; in the US "state_sales_tax" and the other state kinds; in Canada "province_standard" too.
  • :state: the US state or the Canadian province (two letters), where the kind needs one.
  • :place_of_supply_scheme: for a "standard" registration, which place of supply scheme it follows: :standard, :inbound_goods, or in an EU country also :small_seller (a seller under the EU's yearly threshold for selling across borders). Stripe takes it in the EU and in the other countries whose standard registration has one (MishkaPay.Providers.Stripe.place_of_supply_schemes/2 says which); a registration of any other kind or country refuses it.
  • :active_from: when it starts; left out, at once.
  • :expires_at: when it ends; left out, never.

What the provider fills in: :id, :status (:active, :scheduled or :expired) and :created_at.

Summary

Types

t()

The struct that builder/1 returns.

Functions

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

Types

t()

@type t() :: %MishkaPay.TaxSettings.Registration{
  active_from: DateTime.t() | nil,
  country: String.t() | nil,
  created_at: DateTime.t() | nil,
  expires_at: DateTime.t() | nil,
  id: String.t() | nil,
  place_of_supply_scheme: (:inbound_goods | :small_seller | :standard) | nil,
  provider: String.t(),
  state: String.t() | nil,
  status: (:active | :scheduled | :expired) | nil,
  tenant: term() | nil,
  type: String.t() | nil
}

The struct that builder/1 returns.

FieldTypeRequiredDefaultDescriptionDerives
:providerString.t()yessanitize(trim) validate(not_nil_value, string, not_empty)
:tenantterm() | nilno
:idString.t() | nilnovalidate(string)
:countryString.t() | nilnosanitize(trim, upcase) validate(string, regex=^[A-Z]{2}$)
:typeString.t() | nilnosanitize(trim, downcase) validate(string, not_empty, max_len=50, regex=^[a-z][a-z_]*$)
:stateString.t() | nilnosanitize(trim, upcase) validate(string, regex=^[A-Z]{2}$)
:place_of_supply_scheme:inbound_goods | :small_seller | :standard | nilnovalidate(enum=Atom[inbound_goods::small_seller::standard])<br>validator {MishkaPay.TaxSettings, :place_of_supply_scheme}
:active_fromDateTime.t() | nilnovalidate(struct)
:expires_atDateTime.t() | nilnovalidate(struct)
:status:active | :scheduled | :expired | nilnovalidate(enum=Atom[active::scheduled::expired])
:created_atDateTime.t() | nilnovalidate(struct)

Functions

builder(attrs_or_input, error \\ false)

enforce_keys()

enforce_keys(field)

example()

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

keys()

keys(field)