Spec 001: Split expenses
- Status: Approved
- Track: Full
- Last updated: 2026-12-02
What you are approving
- One screen: add the housemates, record the expenses (description, amount, who paid, who shares them equally) and see at once who owes whom, with the fewest possible payments.
- You can edit or delete an expense; a person who appears in an expense cannot be removed; “reset all” deletes the data after a confirmation.
- Decisions taken for you: leftover cents go one each to the first people of the expense; limits 12 people, 500 expenses, maximum amount 99,999.99 €; deleting an expense also asks for confirmation.
- Out of the first version: unequal splits, other currencies, sharing between phones, export, offline use. Data stays only on this phone and in this browser.
- Known risk: speed on the phone is only roughly measured on the computer. Where to publish is still to be decided (D2) and is not needed for this plan.
1. Goal
Let flatmates who share costs record who paid what and see, at any time, each person’s balance and the smallest set of payments that settles everyone. It works for one group on one phone, with no account and no server, so that nobody has to keep the running totals by hand.
2. User stories
- US1. As a flatmate, I want to add and remove the people in the group so that the list matches who lives in the flat.
- US2. As a flatmate, I want to record an expense (what, how much, who paid, who shares it) so that it counts in the balances.
- US3. As a flatmate, I want to fix or delete an expense so that a typing mistake does not ruin the accounts.
- US4. As a flatmate, I want to see who owes or is owed how much, and which payments settle everything, so that we pay each other as few times as possible.
- US5. As a flatmate, I want my data kept on my phone between visits, and to clear it all when the group changes, so that I do not retype it and can start again.
3. Requirements
Terms: a balance is what a person paid minus the sum of their shares of all expenses, in cents; positive means the person is owed money, negative means the person owes money. The order of people is the order in which they were added; editing never changes it.
| ID | Requirement | Story |
|---|---|---|
| R1 | The user MUST be able to add a person by name. | US1 |
| R2 | A name, after removing spaces at its start and end, MUST be 1 to 30 characters long (each visible character counts as one). Otherwise it MUST be rejected with a message that says what to correct. | US1 |
| R3 | Two people MUST NOT have the same name, ignoring upper/lower case and accents. A duplicate MUST be rejected with a message. | US1 |
| R4 | The group MUST hold at most 12 people; adding a 13th MUST be rejected with a message. | US1 |
| R5 | A person who appears in no expense (neither as payer nor as sharer) MUST be removable. | US1 |
| R6 | A person who appears in any expense MUST NOT be removable; the app MUST say why and that the expenses must be changed or deleted first. | US1 |
| R7 | The user MUST be able to record an expense with: a description, an amount in euro, one payer (a person of the group), and one or more people who share it. | US2 |
| R8 | The description, after removing spaces at its start and end, MUST be 1 to 60 characters long; otherwise rejected with a message. | US2 |
| R9 | The amount MUST be greater than 0 and at most 99,999.99 euro, with at most two decimals; both comma and dot MUST be accepted as decimal separator. Anything else (empty, zero, negative, letters, more than two decimals, too large) MUST be rejected with a message. | US2 |
| R10 | An expense MUST have at least one sharer. The payer MAY or MAY NOT be among the sharers. | US2 |
| R11 | An expense MUST be split equally among its sharers in whole cents. If the amount does not divide exactly, the leftover cents MUST go one each to the first sharers in the order of people, so that the shares add up exactly to the amount. | US2 |
| R12 | The group MUST hold at most 500 expenses; adding a 501st MUST be rejected with a message. | US2 |
| R13 | The user MUST be able to edit all fields of an existing expense; the same rules as R8-R11 apply. | US3 |
| R14 | The user MUST be able to delete an expense, after a confirmation. | US3 |
| R15 | The app MUST show each person’s balance. The balances of all people always add up to zero. | US4 |
| R16 | The app MUST show a list of payments (“who pays whom how much”) that, when all made, bring every balance to zero, using the smallest possible number of payments. | US4 |
| R17 | When all balances are zero (including when there are no expenses), the app MUST say so in place of the payment list. | US4 |
| R18 | Balances and payments MUST update immediately after every change to people or expenses, with no separate “calculate” action. | US4 |
| R19 | People and expenses MUST be saved in the browser after every change and be present again when the page is reopened. | US5 |
| R20 | On opening, the saved data MUST be validated. If it is unreadable or breaks any rule above (limits, names, amounts, unknown people in an expense), the app MUST NOT use any of it, MUST say so, and MUST offer to start from empty. | US5 |
| R21 | If the browser does not allow saving, the app MUST say so clearly and keep working until the page is closed. | US5 |
| R22 | The user MUST be able to delete all people and expenses with one “Reset all” action, after a confirmation that says the data cannot be recovered. | US5 |
| R23 | Repeating a submit quickly (double tap, Enter pressed twice) MUST create the item once. | US1, US2 |
| R24 | After a rejected input, the app MUST keep what the user already typed. | US1, US2 |
| R25 | Names and descriptions MUST be shown as plain text, never interpreted as markup or commands, and messages MUST NOT repeat the rejected input. | US1, US2 |
| R26 | All user-facing text MUST be in Italian; amounts MUST be shown in euro in the Italian format (for example “12,50 €”). | US4 |
| R27 | Every part of the screen MUST have an empty state: no people, no expenses. Each says what to do next. | US1, US2 |
| R28 | The screen MUST be fully usable at 360 px width and meet the accessibility and design rules of the profile (Sections 4 and 7: W2, W3, W7, W8). | US1-US5 |
| R29 | No data MUST leave the device: no network request carries names or expenses. | US5 |
| R30 | An expense MUST have exactly one payer chosen from the group. Saving without a payer MUST be rejected with a message that says to choose who paid. | US2 |
4. Acceptance criteria
| ID | Criterion | Covers | Test |
|---|---|---|---|
| AC1 | Given an empty group, when the user adds “Anna”, then “Anna” is in the list. | R1 | |
| AC2 | Given the name field, when the user submits “ Anna “, then the person is stored as “Anna”; when the field is empty or only spaces, then it is rejected and nobody is added. | R2 | |
| AC3 | Given a name of 30 characters, then it is accepted; given 31, it is rejected. A name made of 30 accented letters is accepted (characters, not bytes, are counted). | R2 | |
| AC4 | Given “Anna” exists, when the user adds “anna” or “ANNA”, then it is rejected; when the user adds “Ánna” (accent) the duplicate is also rejected. | R3 | |
| AC5 | Given 12 people, when the user adds another, then it is rejected with a message and the list still has 12. | R4 | |
| AC6 | Given a person in no expense, when the user removes them, then they disappear and the balances of the others do not change. | R5 | |
| AC7 | Given a person who is the payer of an expense, or a sharer of one, when the user tries to remove them, then they stay and a message says to change or delete those expenses first. | R6 | |
| AC8 | Given Anna, Bruno and Carla, when the user records “Spesa” 30,00 paid by Anna shared by all three, then the expense appears in the list with those values. | R7 | |
| AC9 | Given the description field, then “” and “ “ are rejected, a 60-character description is accepted and a 61-character one is rejected. | R8 | |
| AC10 | Given the amount field, then “12,5”, “12.50” and “12” are accepted as 12,50 / 12,50 / 12,00; “0”, “-5”, “abc”, “”, “12,505”, “100000” and “99999,99” give: rejected, rejected, rejected, rejected, rejected, rejected, accepted. | R9 | |
| AC11 | Given an expense with no sharer selected, when the user saves, then it is rejected with a message and no expense is added. | R10 | |
| AC12 | Given Anna paid 30,00 shared only by Bruno and Carla, then Anna’s balance is +30,00 and Bruno’s and Carla’s are -15,00 each. | R10, R15 | |
| AC13 | Given people added in the order Anna, Bruno, Carla, when an expense of 10,00 is shared by all three, then the shares are 3,34 (Anna), 3,33 (Bruno), 3,33 (Carla). | R11 | |
| AC14 | Given an expense of 0,01 shared by three, then the shares are 0,01, 0,00 and 0,00 in the order of people, and the total is 0,01. | R11 | |
| AC15 | Given the order Anna, Bruno, Carla and an expense of 10,00 shared only by Bruno and Carla, then the shares are 5,00 each; given 10,01, then Bruno 5,01 and Carla 5,00. | R11 | |
| AC16 | Given 500 expenses, when the user adds one more, then it is rejected with a message and the list still has 500. | R12 | |
| AC17 | Given an existing expense, when the user changes amount, payer, sharers and description, then the list and the balances show the new values and nothing of the old ones. | R13 | |
| AC18 | Given an expense edited with an invalid amount, then the change is rejected and the expense keeps its old values. | R13 | |
| AC19 | Given an existing expense, when the user chooses delete and confirms, then it disappears and the balances update; when the user does not confirm, then nothing changes. | R14 | |
| AC20 | Given any set of expenses, then the balances shown add up to exactly 0,00. | R15 | |
| AC21 | Given Anna paid 30,00 shared by Anna, Bruno and Carla, then the payments list is: Bruno pays Anna 10,00, and Carla pays Anna 10,00. | R16 | |
| AC22 | Given balances +30,00 (A), +20,00 (B), -30,00 (C), -20,00 (D), then the list has exactly 2 payments (C pays A 30,00; D pays B 20,00), not 3. | R16 | |
| AC23 | Given any set of expenses with 12 people, when all payments of the list are applied, then every balance is exactly 0,00 and no payment is of 0,00 or less. | R16 | |
| AC24 | Given no expenses, or expenses that cancel out, then the screen shows a message that everything is even, and no payment list. | R17 | |
| AC25 | Given the result is on screen, when the user adds, edits or deletes an expense or a person, then balances and payments change at once, without reloading and without any extra action. | R18 | |
| AC26 | Given people and expenses were entered, when the page is reloaded or reopened, then they are all present, in the same order, with the same values. | R19 | |
| AC27 | Given saved data that is not readable, or an expense with an unknown payer, or 13 people, then the app shows none of it, shows a message and offers to start empty; when the user accepts, the screen is empty and works. | R20 | |
| AC28 | Given the browser refuses saving, then a message says so, and the user can still add people and expenses and see results until the page is closed. | R21 | |
| AC29 | Given data, when the user chooses “Reset all” and confirms, then no people and no expenses remain, also after reload; when the user does not confirm, then nothing changes. The confirmation says the data cannot be recovered. | R22 | |
| AC30 | Given a form, when it is submitted twice in quick succession (double tap, Enter twice), then exactly one person or one expense is created, and no error message such as “already exists” appears. | R23 | |
| AC31 | Given an invalid expense (for example amount “abc”) with description, payer and sharers filled, when the user saves, then the message is shown and description, payer and sharers still hold what was typed. | R24 | |
| AC32 | Given a name or description such as <b>x</b> or <img src=x onerror=alert(1)>, then it is shown literally as text, nothing is executed, and no error message repeats it. | R25 | |
| AC33 | Given any screen state, then every visible text is in Italian and every amount has the form “12,50 €” (two decimals, comma, euro sign). | R26 | |
| AC34 | Given no people, then the screen says to add the first person and the expense form is not offered; given people but no expenses, then it says to record the first expense. | R27 | |
| AC35 | Given a 360 px wide screen, then all actions can be done without horizontal scrolling and with controls at least 44×44 px; the automated accessibility check reports no violations; the whole flow can be done with the keyboard only. | R28 | |
| AC36 | Given a full session (add people, add expenses, edit, delete, reset), then no network request is made after the page has loaded. | R29 | |
| AC37 | Given a new expense with description, amount and sharers filled and no payer chosen, when the user saves, then it is rejected with a message to choose who paid, no expense is added, and the typed values stay; when editing an expense, the payer can be changed but not left empty. | R30 |
5. Critical flows
- F1. Add people, record expenses, read the result (R1, R7, R11, R15, R16, R18): this is the whole purpose of the product.
- F2. Fix a mistake: edit and delete an expense (R13, R14, R18): a wrong figure must be correctable without losing the group’s data.
- F3. Close and reopen the page (R19, R20): losing the accounts defeats the purpose.
- F4. Reset and start again (R22): the only way to clear data; it is destructive.
6. UI behavior
One screen with three areas, in this order: People (list, add, remove), Expenses (list, add, edit, delete), Result (balances and payments), plus “Reset all”. Detail is left to the design phase if needed.
- Empty: see R27, AC34.
- Loading: the saved data is read when the page opens; no loading state is visible (nothing is fetched). If reading fails: R20.
- Error: every rejection says what to correct (R2-R4, R6, R8-R10, R12) next to the field concerned and is available to assistive technology (W2); R20, R21 have their own notice.
- Offline: not a feature in v1 (profile Section 3). Once loaded, the page uses no network (R29); opening it without connection is not promised.
7. Security and privacy
- Access: no accounts; whoever can use the phone and browser sees and changes the data. Accepted by the human.
- Abuse limits: not applicable (no server); size limits R4, R12 keep the stored data small.
- Information leaks: none: no server and no network request (R29); no analytics or third-party scripts (profile Section 8).
- Input limits: R2, R8, R9, R4, R12. All input is untrusted, also when read back from storage (R20) and shown only as text (R25).
- Logging: no personal data in any log or error message; messages do not repeat input (R25).
- Secrets: none exist.
- Personal data: first names of flatmates, typed by the user; kept only in the user’s browser; the user can delete all (R22). No retention beyond that. The user may also clear it through the browser; it is lost then (accepted).
- Accepted risk: data lives on one phone and one browser; clearing browser data or using another phone loses it (profile Section 8).
8. Out of scope
- Unequal splits (percentages, fixed amounts), currencies other than euro.
- Several groups at once; sharing or synchronising between phones; accounts.
- Export, import, printing or sending the result.
- Recording that a payment was made, or marking payments as done.
- Dates, categories or notes on expenses; undo.
- Installing as an app and offline opening; languages other than Italian.
9. Open questions
(none)
10. Edge cases
- Payer is not among the sharers: R10, AC12.
- No payer chosen: R30, AC37.
- Amount with cents not divisible by the number of sharers: R11, AC13-AC15.
- Name with accents, upper/lower case, spaces at the ends: R2, R3, AC2-AC4.
- Name or description with markup characters: R25, AC32.
- Person in no expense is removable; in an expense is not: R5, R6, AC6, AC7.
- Limits reached (12 people, 500 expenses): R4, R12, AC5, AC16.
- Saved data broken or tampered with: R20, AC27.
- Saving not allowed (for example private browsing): R21, AC28.
- Double submit and reload after submit: R23, R19, AC30, AC26.
- Everything even / no expenses: R17, AC24.
- Expense where one person is both the only payer and the only sharer: their balance is 0,00 and no payment appears: R15, R16, AC20, AC24.
11. Success measures
N/A – no measurable target beyond the acceptance criteria and the performance target in the profile.
12. Impact on existing specs
N/A – first spec.
13. Approval
- Approved by: Luca Lanzano
- Date: 2026-12-02
Change log
- 2026-12-02: change request accepted by the human: added R30 and AC37 (payer required), found in the design phase; approval reset to Draft.