# `Alternera.Resources.Finance.ExchangeRate`
[🔗](https://github.com/10e-ab/alternera-finance/blob/v0.9.0/lib/alternera/resources/finance/exchange_rate.ex#L1)

An exchange rate on a day: one unit of the base currency is `rate` units
of the quote currency. A record per pair and day, so the history stays:
a new day's rates are new records.

Its calculations (`Finance.RateLookup`) read that history: `convert` an
amount from one currency to another, `rate` a pair's rate on a day, and
`history` a pair's rate on every day of a period; each finds a direct,
inverted or cross rate. Any role may run them, and they are open to the
API, MCP and pipelines.

`record_rates` stores one day's rates against one base in a single call,
creating or updating each pair's record for the day; the daily rates
pipeline the package's guide describes calls it.

# `t`

```elixir
@type t() :: %Alternera.Resources.Finance.ExchangeRate{
  __lateral_join_source__: term(),
  __meta__: term(),
  __metadata__: term(),
  __order__: term(),
  aggregates: term(),
  base_currency: term(),
  base_currency_code: term(),
  base_currency_id: term(),
  calculations: term(),
  id: term(),
  paper_trail_versions: term(),
  quote_currency: term(),
  quote_currency_code: term(),
  quote_currency_id: term(),
  rate: term(),
  rate_date: term(),
  source: term(),
  tenant_id: term()
}
```

# `default_short_name`

# `input`

```elixir
@spec input(values :: map() | Keyword.t()) :: map() | no_return()
```

Validates that the keys in the provided input are valid for at least one action on the resource.

Raises a KeyError error at compile time if not. This exists because generally a struct should only ever
be created by Ash as a result of a successful action. You should not be creating records manually in code,
e.g `%MyResource{value: 1, value: 2}`. Generally that is fine, but often with embedded resources it is nice
to be able to validate the keys that are being provided, e.g

```elixir
Resource
|> Ash.Changeset.for_create(:create, %{embedded: EmbeddedResource.input(foo: 1, bar: 2)})
|> Ash.create()
```

# `input`

```elixir
@spec input(values :: map() | Keyword.t(), action :: atom()) :: map() | no_return()
```

Same as `input/1`, except restricts the keys to values accepted by the action provided.

# `json_api_match_route`

# `primary_key_matches?`

---

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