Skip to content

Commit

Permalink
fix: do negation manually instead of in expression
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Nov 1, 2024
1 parent e35a474 commit 5335726
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/balance/changes/adjust_balance.ex
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ defmodule AshDoubleEntry.Balance.Changes.AdjustBalance do
end

if opts[:can_add_money?] do
negative_amount_delta = Money.mult!(amount_delta, -1)

{:atomic,
%{
balance:
expr(
if account_id == ^changeset.arguments.from_account_id do
^atomic_ref(:balance) + -(^amount_delta)
^atomic_ref(:balance) + ^negative_amount_delta
else
^atomic_ref(:balance) + ^amount_delta
end
Expand Down

0 comments on commit 5335726

Please sign in to comment.