diff --git a/documentation/tutorials/get-started-with-ash-money.md b/documentation/tutorials/get-started-with-ash-money.md index 9897cd4..f4706cd 100644 --- a/documentation/tutorials/get-started-with-ash-money.md +++ b/documentation/tutorials/get-started-with-ash-money.md @@ -39,7 +39,9 @@ Thanks to `ex_money_sql`, there are excellent tools for lowering support for mon ```elixir sum :sum_of_usd_balances, :accounts, :balance do - filter expr(fragment("(?).currency_code", balance).currency_code == "USD") + filter expr( + fragment("(?).currency_code", balance) == "USD" + ) end ``` diff --git a/lib/ash_money/types/money.ex b/lib/ash_money/types/money.ex index 7f7368d..36f37e4 100644 --- a/lib/ash_money/types/money.ex +++ b/lib/ash_money/types/money.ex @@ -27,6 +27,16 @@ defmodule AshMoney.Types.Money do Keyword.get(constraints, :storage_type, :money_with_currency) == :money_with_currency end + @impl true + def composite?(constraints) do + Keyword.get(constraints, :storage_type, :money_with_currency) == :money_with_currency + end + + @impl true + def composite_types(_constraints) do + [{:currency, :string, []}, {:amount, :decimal, []}] + end + @impl Ash.Type def storage_type(constraints) do if constraints[:items] do diff --git a/mix.exs b/mix.exs index bae69f9..3173f9d 100644 --- a/mix.exs +++ b/mix.exs @@ -142,7 +142,7 @@ defmodule AshMoney.MixProject do # Run "mix help deps" to learn about dependencies. defp deps do [ - {:ash, ash_version("~> 2.0")}, + {:ash, ash_version("~> 2.0 and >= 2.17.5")}, {:ex_money, "~> 5.15"}, {:ex_money_sql, "~> 1.0"}, {:ex_doc, github: "elixir-lang/ex_doc", only: [:dev, :test], runtime: false}, diff --git a/mix.lock b/mix.lock index f2b7356..5bc3d1a 100644 --- a/mix.lock +++ b/mix.lock @@ -1,5 +1,5 @@ %{ - "ash": {:hex, :ash, "2.17.4", "b672ab9bcd7351e9adb3bf332655b6c777bab6c45e7cb88b3a89117f6a200837", [:mix], [{:comparable, "~> 1.0", [hex: :comparable, repo: "hexpm", optional: false]}, {:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:earmark, "~> 1.4", [hex: :earmark, repo: "hexpm", optional: false]}, {:ecto, "~> 3.7", [hex: :ecto, repo: "hexpm", optional: false]}, {:ets, "~> 0.8", [hex: :ets, repo: "hexpm", optional: false]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: false]}, {:picosat_elixir, "~> 0.2", [hex: :picosat_elixir, repo: "hexpm", optional: false]}, {:plug, ">= 0.0.0", [hex: :plug, repo: "hexpm", optional: true]}, {:spark, ">= 1.1.50 and < 2.0.0-0", [hex: :spark, repo: "hexpm", optional: false]}, {:stream_data, "~> 0.6", [hex: :stream_data, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.1", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "941d9edf1ba3511e3a3c40711de168ee476197fa0615f15b16548178e1d50e97"}, + "ash": {:hex, :ash, "2.17.5", "2e14392558a62e49982b66e69c5674cfc00d9ed9845fff3fdb87a52413b6d961", [:mix], [{:comparable, "~> 1.0", [hex: :comparable, repo: "hexpm", optional: false]}, {:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:earmark, "~> 1.4", [hex: :earmark, repo: "hexpm", optional: false]}, {:ecto, "~> 3.7", [hex: :ecto, repo: "hexpm", optional: false]}, {:ets, "~> 0.8", [hex: :ets, repo: "hexpm", optional: false]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: false]}, {:picosat_elixir, "~> 0.2", [hex: :picosat_elixir, repo: "hexpm", optional: false]}, {:plug, ">= 0.0.0", [hex: :plug, repo: "hexpm", optional: true]}, {:spark, ">= 1.1.50 and < 2.0.0-0", [hex: :spark, repo: "hexpm", optional: false]}, {:stream_data, "~> 0.6", [hex: :stream_data, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.1", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "102a700162dcd4aba0e7a63002e1e5f4d65463a4e8bec6507d6107b67fb7a490"}, "bunt": {:hex, :bunt, "0.2.1", "e2d4792f7bc0ced7583ab54922808919518d0e57ee162901a16a1b6664ef3b14", [:mix], [], "hexpm", "a330bfb4245239787b15005e66ae6845c9cd524a288f0d141c148b02603777a5"}, "cldr_utils": {:hex, :cldr_utils, "2.24.2", "364fa30be55d328e704629568d431eb74cd2f085752b27f8025520b566352859", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:certifi, "~> 2.5", [hex: :certifi, repo: "hexpm", optional: true]}, {:decimal, "~> 1.9 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}], "hexpm", "3362b838836a9f0fa309de09a7127e36e67310e797d556db92f71b548832c7cf"}, "comparable": {:hex, :comparable, "1.0.0", "bb669e91cedd14ae9937053e5bcbc3c52bb2f22422611f43b6e38367d94a495f", [:mix], [{:typable, "~> 0.1", [hex: :typable, repo: "hexpm", optional: false]}], "hexpm", "277c11eeb1cd726e7cd41c6c199e7e52fa16ee6830b45ad4cdc62e51f62eb60c"},