mirror of
https://github.com/ash-project/ash_double_entry.git
synced 2024-09-20 21:43:16 +12:00
19 lines
521 B
Elixir
19 lines
521 B
Elixir
|
defmodule AshDoubleEntry.Transfer.Transformers.AddStructure do
|
||
|
use Spark.Dsl.Transformer
|
||
|
|
||
|
def transform(dsl) do
|
||
|
dsl
|
||
|
|> Ash.Resource.Builder.add_attribute(:amount, :decimal,
|
||
|
allow_nil?: false,
|
||
|
default: Decimal.new(0),
|
||
|
writable?: false
|
||
|
)
|
||
|
|> Ash.Resource.Builder.add_attribute(:converted_amount, :decimal, writable?: true)
|
||
|
|> Ash.Resource.Builder.add_relationship(
|
||
|
:belongs_to,
|
||
|
:account,
|
||
|
AshDoubleEntry.Transfer.Info.transfer_account_resource(dsl)
|
||
|
)
|
||
|
end
|
||
|
end
|