SUMA: from proposal to expense

Someone dictates two expenses, corrects one and confirms the proposal. If they press confirm again, will both expenses be recorded twice?

SUMA is a budgeting app for individuals and families. It runs in production, uses Elixir and has a web dashboard and apps for iPhone and Android.

SUMA groups expenses dictated by the user or submitted by an AI assistant into a proposal that can be revised, confirmed or cancelled. A proposal can contain one to ten entries. Expenses entered directly in the app are recorded without a proposal.

preparerevisePendingexpiredconfirmcancelConfirmedCancelled
A pending proposal can be revised any number of times before it is confirmed or cancelled. After 15 minutes it expires: it can no longer be revised or confirmed, but it can still be cancelled.

Which rules must a proposal follow?

At most one commit per proposal

If a proposal contains lunch and a bus fare, confirming it saves two entries. Retrying the same confirmation leaves those two entries in place.

Confirmation is final

The confirmed revision is fixed. A confirmed proposal can no longer be edited.

The fingerprint must be current

Each revision has its own fingerprint. If the proposal changes, the previous fingerprint can no longer authorise confirmation.

In the model, any entry that comes from a proposal requires that proposal to be confirmed. The model also allows entries to be created directly. In both cases the amount must fall within the valid range.

How the rules are checked

In Veil, a tool for Lean 4, we represent a batch commit as a single step that creates one abstract entry. Veil checks that a proposal can take that step at most once. It also finds two permitted sequences. A proposal can be revised and then confirmed, or cancelled after it expires.

The Elixir server writes one row per entry and marks the proposal as confirmed in the same database transaction. The model abstracts away those rows and chooses an amount within the allowed range. Checking that the amount saved matches the amount the person approved requires comparing each saved row with the confirmed revision.

Visit sumabot.online →