AshMoney.Types.Money (ash_money v0.2.4)
View SourceA money type for Ash that uses the ex_money library.
When constructing a composite type, use a tuple in the following structure:
composite_type(%{currency: "USD", amount: Decimal.new("0")}}, AshMoney.Types.Money)
If you've added a custom type, like :money:
composite_type(%{currency: "USD", amount: Decimal.new("0")}, :money)Constraints Options
:storage_type(atom/0) - The storage type for the money value. Can be:money_with_currencyor:map. There is no difference between the two unlessex_money_sqlis installed. The default value is:money_with_currency.:ex_money_opts(keyword/0) -ex_moneyMoney.new/3 Options - https://hexdocs.pm/ex_money/Money.html#new/3-options
Example
attribute :charge, :money do
constraints: [
ex_money_opts: [
no_fraction_if_integer: true,
format: :short
]
]
end