Money - How to (just) change sign?

For a database operation like the following I need to change the sign for a Money struct (because I need a decrement I need a negative value):

from(c in Customer,
  where: c.id == ^customer.id,
  update: [
    inc: [
      balance: ^Money.sub!(Money.zero(:EUR), order.total)
    ],
    set: [updated_at: ^inserted_at]
  ]
)

Right now I am doing it like this:
Money.sub!(Money.zero(:EUR), order.total)

Is there any function do do this I might have missed?

Money.neg?

3 Likes

I swear that function was not there while I was reading the documentation…

:joy:

2 Likes