Is it possible to run a calculation on a calculation in another resource?
# resource user
attributes do
attribute :type, :atom do
constraints [one_of: [:m, :f, :mf]]
end
calculations do
calculate :nr_of_people, :integer, expr(if sex == :mf do 2 else 1 end)
end
end
# resource reservation
relationships do
belongs_to :event, TimeTracer.Events.Event, allow_nil?: false, attribute_writable?: true
belongs_to :user, TimeTracer.Accounts.User, allow_nil?: false
end
calculations do
calculate :nr_of_guests, :integer do
load :user
calculation expr(user.nr_of_people)
end
end
# in event resource
relationships do
has_many :reservations, TimeTracer.Events.Reservation
end
calculations do
calculate :nr_of_guests, :integer do
# no idea? should be something like sum(reservations, :nr_of_guests) but that doesnt work
end
end