ash_double_entry/lib/account/calculations/balance_as_of.ex

13 lines
395 B
Elixir
Raw Normal View History

defmodule AshDoubleEntry.Account.Calculations.BalanceAsOf do
2023-09-27 02:46:07 +13:00
# Calculates the balance as of a given datetime. See the getting started guide for more.
@moduledoc false
use Ash.Calculation
require Ash.Expr
def expression(opts, context) do
ulid = AshDoubleEntry.ULID.generate(context.timestamp)
2023-12-06 13:49:23 +13:00
Ash.Expr.expr(balance_as_of_ulid(ulid: ulid, resource: opts[:resource]))
end
end