params = %{
amount: 100,
description: "Test transaction",
date: Date.utc_today(),
category_id: context.category.id,
currency_id: context.currency.id,
method_id: context.method.id,
rate_id: context.rate.id,
type_id: context.type.id,
end_date: Timex.shift(Date.utc_today(), months: 1),
recurrence_pattern: %{
recurrence_type_id: context.recurrence_type.id,
count: 5
}
}
transaction =
AshPhoenix.Form.for_create(Transaction, :create,
api: Transactions,
forms: [auto?: true]
)
|> AshPhoenix.Form.add_form(:recurrence_pattern)
|> AshPhoenix.Form.validate(params)
|> AshPhoenix.Form.submit!()
params = %{
amount: 100,
description: "Test transaction",
date: Date.utc_today(),
category_id: context.category.id,
currency_id: context.currency.id,
method_id: context.method.id,
rate_id: context.rate.id,
type_id: context.type.id,
end_date: Timex.shift(Date.utc_today(), months: 1),
recurrence_pattern: %{
recurrence_type_id: context.recurrence_type.id,
count: 5
}
}
transaction =
AshPhoenix.Form.for_create(Transaction, :create,
api: Transactions,
forms: [auto?: true]
)
|> AshPhoenix.Form.add_form(:recurrence_pattern)
|> AshPhoenix.Form.validate(params)
|> AshPhoenix.Form.submit!()