add manual reversal credit flow

Merged
ST
11d ago
+740-5

Adds an undo-flow on the backend to reverse manually granted credits

What can be reversed

  • Only manual credits, benefit credits are managed by the benefit system.
  • Within 7 days. A bit arbitrary, but reason is for one-time products that have no billing cycle to limit them.
  • Current billing period only and not if already invoiced
  • Once per credit, so that retries can't take more than was granted etc

How much is reversed

  • Only the unused part. A reversal must never put the customer into an unexpected overage.
  • The balance is recalculated: the stored balance can be stale.

The reversal event

  • A new negative meter.credited event
  • The reason stays "manual", with reversed_event_id pointing to the credit
  • The rollover flag is copied, units come out of the same place they went into.
  • Own event instead of parent event, since its a system event and only user events have parent events