# `MishkaPay.TaxSettings.Registration`
[🔗](https://github.com/mishka-group/mishka_pay/blob/v0.0.1/nofile#L1)

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

# `t`

```elixir
@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.

| Field | Type | Required | Default | Description | Derives |
| --- | --- | --- | --- | --- | --- |
| `:provider` | `String.t()` | yes |  |  | `sanitize(trim) validate(not_nil_value, string, not_empty)` |
| `:tenant` | `term()` \| `nil` | no |  |  |  |
| `:id` | `String.t()` \| `nil` | no |  |  | `validate(string)` |
| `:country` | `String.t()` \| `nil` | no |  |  | `sanitize(trim, upcase) validate(string, regex=^[A-Z]{2}$)` |
| `:type` | `String.t()` \| `nil` | no |  |  | `sanitize(trim, downcase) validate(string, not_empty, max_len=50, regex=^[a-z][a-z_]*$)` |
| `:state` | `String.t()` \| `nil` | no |  |  | `sanitize(trim, upcase) validate(string, regex=^[A-Z]{2}$)` |
| `:place_of_supply_scheme` | `:inbound_goods` \| `:small_seller` \| `:standard` \| `nil` | no |  |  | `validate(enum=Atom[inbound_goods::small_seller::standard])`<br>validator `{MishkaPay.TaxSettings, :place_of_supply_scheme}` |
| `:active_from` | `DateTime.t()` \| `nil` | no |  |  | `validate(struct)` |
| `:expires_at` | `DateTime.t()` \| `nil` | no |  |  | `validate(struct)` |
| `:status` | `:active` \| `:scheduled` \| `:expired` \| `nil` | no |  |  | `validate(enum=Atom[active::scheduled::expired])` |
| `:created_at` | `DateTime.t()` \| `nil` | no |  |  | `validate(struct)` |

# `builder`

# `enforce_keys`

# `enforce_keys`

# `example`

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

# `keys`

# `keys`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
