Split calculator
Built in - no setupDeterministic group-money math: equal expense splits, settlement deltas, and balance rebuilds in exact integer cents with a hard sum-to-zero invariant. Use it for EVERY money figure a group ledger stores - never compute cents yourself.
Publisher: Amistio (built-in) - version 1.0.0 - Apache-2.0
Operations (1)
Compute a split
split.computeCompute exact-cents money figures for one group action. kind=expense splits an amount equally across sharedBy (everyone when empty): share = floor(cents/n), the remainder goes +1 cent to the earliest sharers in ROSTER order, and the payer's delta is their own share minus the full amount. kind=settlement moves cents between two people: from gets -amount, to gets +amount. kind=rebuild folds the deltas of the given ledger entries per name. deltas and netCents ALWAYS sum to exactly 0; positive netCents owes the group. Unknown names, malformed amounts (over 2 decimals, non-positive, over 1000000), and malformed JSON are rejected - the op never guesses.
Inputs
kind* (string) - What to compute: expense, settlement, or rebuild.participants* (string) - The FULL group roster, 2-12 unique names in canonical order: a JSON array like ["Alex","Sam","Riley"] or a comma-separated list. Remainder cents go to the earliest names on this list.amount(string) - expense/settlement: the decimal amount exactly as entered, 0.01 to 1000000 with at most 2 decimal places, e.g. "45.50". Parsed as an exact decimal - never floating-point math.paidBy(string) - expense: who paid - one roster name.sharedBy(string) - expense: who shares the cost - a JSON array or comma-separated roster names. Empty splits among everyone. "X covered Y" = sharedBy ["Y"].from(string) - settlement: who paid money back - one roster name.to(string) - settlement: who received it - one roster name, different from `from`.currentBalances(string) - Optional JSON object of name -> integer cents from the current snapshot (positive owes the group). Absent or empty means all zeros. Copy it from the snapshot verbatim - never adjust it.entries(string) - rebuild: a JSON array of the ledger entries' deltas objects (full entries carrying a deltas object also work). Order does not matter; the fold is per name.
Returns
amountCents(number) - The parsed amount in integer cents (0 for rebuild).deltas(object) - name -> cents this action changes each balance by, for every roster name; sums to exactly 0. Copy VERBATIM into the ledger entry.netCents(object) - name -> cents balances after this action; sums to exactly 0; positive owes the group. Copy VERBATIM into the snapshot.summary(string) - A short human-readable line describing the computation.
Safety rules
- Copy deltas and netCents into stored records VERBATIM - never recompute, round, or adjust any figure yourself.
- Fail-closed: unknown names, duplicate roster names, malformed amounts, and malformed JSON are rejected rather than guessed - fix the input and call again, or refuse.
Use Split calculator from the agent builder - add the block, and reviewed operations run with your own connected account.
Open the builder