For app owners

Credit, wallets and passes

Keep a balance as a series of movements and never let credit drop below zero.

When it helps

Prepaid credit, loyalty points, a pass for ten entries, a gift voucher or stock levels. They share one thing: a balance that changes and must not drop below zero.

The balance is not stored as one number that gets overwritten. Every change is a new row in a table of movements: a top-up with a positive amount, a spending with a negative one. The balance is their sum. You get a record of who changed what and when, and nothing is overwritten without a trace.

How it works

  1. Every movement is a row

    A top-up of 500 is a row with plus 500, spending 120 is a row with minus 120. Movements are only added.

  2. The app watches zero

    A movement that would take the balance below zero is refused and nothing is saved. If you want, you can allow a short overdraft, say down to minus 200.

  3. Simultaneous spending is safe

    When two people spend the last credit at once, only one goes through. The other gets a message that the credit is not enough.

  4. Changes in hindsight are watched

    An earlier top-up that has already been spent cannot be deleted, nor its amount changed so that the balance would drop below zero.

Ask your assistant

Say what is tracked (credit, points, entries), who holds the balance (a customer, a member, a product) and whether the balance may go negative.

Prepaid customer credit
In my app [name or address] I want prepaid customer credit. Add a table of movements with an amount (plus for a top-up, minus for spending), a customer and a note. A customer’s balance should be the sum of their movements and must never drop below zero. Movements are only added. Add buttons Top up and Spend and show the balance on the customer’s detail.
A pass for ten entries
I want passes for ten entries. Each purchase is a movement of plus ten, each entry minus one. When the entries run out, an entry is refused. Show the balance on the member.

When it does not work

A movement is refused although the balance looks big enough

The balance is the sum of all movements, including those colleagues just entered. Refresh the page and check the customer’s movements. For a newly created customer make sure they already exist; a movement has to have its holder.

I want to correct a wrongly entered amount

Do not overwrite the movement. Add a correcting movement of the opposite sign with a note. The balance and the history then agree and you can see what happened.

I want to allow the balance to go negative

Ask your assistant for an overdraft and give the limit, say minus 200. It applies to all customers alike.

What next

Who entered a movement and when is shown by the change history, if you turn it on. For credit paid by card use card payments and add the top-up movement once it is paid.

Accept card paymentsWork with records