Compare commits

...
Sign in to create a new pull request.

9 commits

Author SHA1 Message Date
6e6b06b399 Merge pull request 'Several payers: clearer on phones, plus tests' (#10) from feat/multi-payer-polish into main
Reviewed-on: #10
2026-11-19 15:52:19 +01:00
9981cf9a9a Several payers: clearer on phones, plus tests
The editor already supported several payers ("Several people" in Paid by);
this polishes it after checking it at 390x844 and 360x780 (Czech):

- Expense list: "Paid by 3 people" was truncated on phones; now "3 payers"
  (proper Czech plurals: plátce / plátci / plátců).
- Empty payer boxes show the unassigned remainder as a placeholder.
- A green "Adds up to the total" line confirms when the payers match.
- Tests: core balance + settle-up for a car bought by three people, a
  foreign-currency multi-payer case, and an e2e flow (remaining, over,
  validation error, save, balances).
- SPEC: describe the actual several-payers UI (no "add payer" button).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HA82gX9UJk6BEyaJJwiWPc
2026-11-18 19:23:19 +00:00
61f4e42846 Merge pull request 'Gestures (pull up to add, swipe tabs) and shorter group settings' (#9) from feat/add-gesture into main
Reviewed-on: #9
2026-11-07 01:15:54 +01:00
3d2f87c967 Pull up to add, swipe between tabs; shorter group settings
Gestures (GroupGestures.svelte replaces PullToAdd.svelte):
- Pull-to-add moves to the bottom: pulling up past the end of the
  Expenses or Balances tab raises a pill from behind the tab bar. The
  top is left to the browser's pull-to-refresh.
- Swiping left/right switches between Expenses, Balances, Stats and
  Activity; the list follows the finger and the new tab slides in.
  Touches within 24px of the screen edge (OS back gesture), in form
  controls or in sideways-scrolling elements are ignored.

Group settings, same features in less space:
- Share: one row (Copy link, Share icon, QR); shorter intro.
- Group: currency and default category side by side; Save appears
  only when something changed; hints trimmed.
- Members: "You are" picker merged in; rename/archive as icon buttons;
  add member is the last row.
- Notifications: a single switch. Repeating expenses: hidden when none.
- Danger zone: two rows; the delete confirmation opens on tap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HA82gVKYyo9BHLHPW4qr4x
2026-11-06 23:59:44 +00:00
ce1b207906 Pull down to add an expense
On touch screens, dragging the Expenses or Balances tab down from the top
slides a "Pull to add expense" pill out from under the header; releasing
once it reads "Release to add" opens the add sheet. Sideways swipes,
upward scrolls and touches on form controls are left alone, and the
browser's pull-to-refresh is suppressed only while a pull is in progress.
The visible Add buttons stay; the pill is aria-hidden.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HA82gVKYyo9BHLHPW4qr4x
2026-11-06 21:27:53 +00:00
a10ec3c3b3 Merge pull request 'Expense editor: one-screen layout and balanced category tiles' (#8) from feat/editor-layout into main
Reviewed-on: #8
2026-11-06 22:12:06 +01:00
5f40882cd5 Expense editor: compact one-screen layout, balanced category tiles
The add sheet was ~1,400px tall on a 390×844 phone and the 12 category
chips wrapped into ragged rows. Now it fits one screen with three members:

- currency is a pill beside the amount (native select laid over it)
- categories are 12 equal tinted icon tiles, 6 × 2 (12 × 1 when wider),
  with the chosen name next to the label
- date and payer share a row; "Several people" is the last payer option
  instead of a separate checkbox
- photo, note and repeat are folded behind small buttons
- Save is pinned to the bottom; Cancel dropped (the X closes)
- sheet header is opaque and sheets get scroll-padding so focused
  fields aren't hidden under the header or the Save bar

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HA82gVKYyo9BHLHPW4qr4x
2026-11-06 21:10:17 +00:00
271d3e8a66 Merge pull request 'Group page redesign, per-group default category, visual bug fixes' (#7) from feat/redesign into main
Reviewed-on: #7
2026-11-06 21:42:53 +01:00
88024b4702 Merge pull request 'Neutral Dark, Black and Light themes with a modern look' (#6) from feat/themes into main
Reviewed-on: #6
2026-11-06 21:42:44 +01:00
11 changed files with 666 additions and 185 deletions

30
SPEC.md
View file

@ -180,8 +180,11 @@ Split `value` meaning per mode:
| `exact` | amount in minor units | sum == amount | | `exact` | amount in minor units | sum == amount |
| `percent` | basis points (100 % = 10000) | sum == 10000 | | `percent` | basis points (100 % = 10000) | sum == 10000 |
Multiple payers are supported (`payers` list); the default UI shows a single Multiple payers are supported (`payers` list) — e.g. several people chipping
payer with an "add payer" option. in for a car. The editor shows a single payer by default; choosing "Several
people" in *Paid by* lists every member with an amount box. Empty boxes show
the unassigned remainder as a placeholder, a live line reads "Remaining" /
"Over by" / "Adds up to the total", and the expense list shows "N payers".
--- ---
@ -278,6 +281,18 @@ the minimum in practice, and is easy to reason about.
the daily rate for the expense date and is editable. the daily rate for the expense date and is editable.
- Split editor: equal / shares / exact / percent tabs; tap to exclude people; - Split editor: equal / shares / exact / percent tabs; tap to exclude people;
live "remaining to assign" indicator for exact and percent modes. live "remaining to assign" indicator for exact and percent modes.
- The add sheet fits one phone screen (390×844, three members): currency as a
pill beside the amount; categories as 12 equal icon tiles (6 × 2 on phones,
one row of 12 when wider) with the chosen name beside the label; date and
payer side by side ("Several people" is the last payer option); photo, note
and repeat stay folded behind small buttons; Save is pinned to the bottom.
- Touch gestures on the group page (shortcuts; every action also has a
button): pull up past the end of the Expenses or Balances tab to add an
expense (a "Pull up to add expense" pill rises from behind the tab bar and
reads "Release to add" once far enough; at the bottom so the browser's
pull-to-refresh still works), and swipe left/right to move between the
Expenses, Balances, Stats and Activity tabs. Swipes starting within 24px
of the screen edge are left to the OS back gesture.
- **One photo per expense** (receipt), see 9. - **One photo per expense** (receipt), see 9.
- Category, date, note. - Category, date, note.
- Comments thread on each expense. - Comments thread on each expense.
@ -446,10 +461,17 @@ which group ids exist.
"who am I" isn't set), the group's total spent, and round quick actions: "who am I" isn't set), the group's total spent, and round quick actions:
Add · Payment · Settle up · Share. Tabs: Expenses · Balances (settle up) · Add · Payment · Settle up · Share. Tabs: Expenses · Balances (settle up) ·
Stats · Activity. A floating "+" appears only once the quick actions have Stats · Activity. A floating "+" appears only once the quick actions have
scrolled off screen. scrolled off screen. Touch gestures: pull up at the end of the page to
add, swipe sideways to change tab (see 7.2).
3. **Expense editor** (sheet on mobile, dialog on desktop). 3. **Expense editor** (sheet on mobile, dialog on desktop).
4. **Expense detail**: photo, split breakdown, comments, history. 4. **Expense detail**: photo, split breakdown, comments, history.
5. **Group settings**. 5. **Group settings**, kept short: Share (copy link, native share, QR),
Group (icon, name, main currency and default category side by side; Save
appears only when something changed), Members ("You are" picker on top;
rename/archive as icon buttons; add member as the last row),
Notifications (one switch; hidden where push isn't available), Repeating
expenses (only when there are any), Export, Danger zone (delete asks for
the group name only after it is tapped).
6. **App settings**: language, theme, notifications. 6. **App settings**: language, theme, notifications.
### 10.3 Language ### 10.3 Language

View file

@ -232,6 +232,10 @@ dialog.sheet {
width: 100%; max-width: 100%; height: 100%; max-height: 100%; margin: 0; width: 100%; max-width: 100%; height: 100%; max-height: 100%; margin: 0;
} }
dialog.sheet:focus { outline: none; } dialog.sheet:focus { outline: none; }
/* Sheets scroll under an opaque header (and, in the editor, a pinned Save bar):
keep focused fields clear of both. */
dialog.sheet { scroll-padding: 72px 0 96px; }
dialog.sheet .topbar { background: var(--bg); }
dialog.sheet::backdrop { background: rgb(0 0 0 / 0.5); } dialog.sheet::backdrop { background: rgb(0 0 0 / 0.5); }
@media (min-width: 760px) { @media (min-width: 760px) {
dialog.sheet { dialog.sheet {

View file

@ -1,12 +1,12 @@
<script lang="ts"> <script lang="ts">
import { untrack } from 'svelte'; import { tick, untrack } from 'svelte';
import { import {
CATEGORIES, exponent, isValidRate, owedOriginal, parseAmount, validateExpense, CATEGORIES, exponent, isValidRate, owedOriginal, parseAmount, validateExpense,
type Category, type Expense, type Freq, type Photo, type SplitMode, type Category, type Expense, type Freq, type Photo, type SplitMode,
} from '@oweme/core'; } from '@oweme/core';
import { serverConfig } from '../lib/api.ts'; import { serverConfig } from '../lib/api.ts';
import { randomId } from '../lib/crypto.ts'; import { randomId } from '../lib/crypto.ts';
import { amountInput, CATEGORY_ICONS, fmtDate, money, today } from '../lib/format.ts'; import { amountInput, CATEGORY_COLORS, CATEGORY_ICONS, fmtDate, money, today } from '../lib/format.ts';
import { processPhoto, type ProcessedPhoto } from '../lib/photo.ts'; import { processPhoto, type ProcessedPhoto } from '../lib/photo.ts';
import { suggestRate } from '../lib/rates.ts'; import { suggestRate } from '../lib/rates.ts';
import { router } from '../lib/router.svelte.ts'; import { router } from '../lib/router.svelte.ts';
@ -15,6 +15,7 @@
import type { MsgKey } from '../lib/i18n.ts'; import type { MsgKey } from '../lib/i18n.ts';
import Avatar from './Avatar.svelte'; import Avatar from './Avatar.svelte';
import CurrencySelect from './CurrencySelect.svelte'; import CurrencySelect from './CurrencySelect.svelte';
import Icon from './Icon.svelte';
import PhotoView from './PhotoView.svelte'; import PhotoView from './PhotoView.svelte';
import Sheet from './Sheet.svelte'; import Sheet from './Sheet.svelte';
@ -78,6 +79,12 @@
let newPhotoUrl = $state<string | null>(null); let newPhotoUrl = $state<string | null>(null);
let photoBusy = $state(false); let photoBusy = $state(false);
let repeat = $state<'none' | Freq>('none'); let repeat = $state<'none' | Freq>('none');
// Note and repeat are folded into small buttons until used.
let showNote = $state(!!existing?.note);
let showRepeat = $state(false);
let noteEl = $state<HTMLTextAreaElement>();
/** "Paid by" value that switches to the several-payers list. */
const SEVERAL = '*several';
let error = $state(''); let error = $state('');
let saving = $state(false); let saving = $state(false);
@ -193,6 +200,12 @@
} }
} }
async function openNote() {
showNote = true;
await tick();
noteEl?.focus();
}
function removePhoto() { function removePhoto() {
photo = null; photo = null;
newPhoto = null; newPhoto = null;
@ -252,117 +265,133 @@
</script> </script>
<Sheet title={heading} onclose={close}> <Sheet title={heading} onclose={close}>
<form class="stack" onsubmit={save} novalidate> <form class="editor" onsubmit={save} novalidate>
{#if !existing} {#if !existing}
<div class="seg" role="group"> <div class="seg kind" role="group">
<button type="button" aria-pressed={kind === 'expense'} onclick={() => (kind = 'expense')}>{t('kind_expense')}</button> <button type="button" aria-pressed={kind === 'expense'} onclick={() => (kind = 'expense')}>{t('kind_expense')}</button>
<button type="button" aria-pressed={kind === 'transfer'} onclick={() => (kind = 'transfer')}>{t('kind_transfer')}</button> <button type="button" aria-pressed={kind === 'transfer'} onclick={() => (kind = 'transfer')}>{t('kind_transfer')}</button>
</div> </div>
{/if} {/if}
<div class="card stack" style:gap="4px"> <!-- amount, with the currency as a pill; the real <select> sits invisibly on top of it -->
<label class="sr-only" for="amount">{t('amount')}</label> <div class="card amount-card">
<input id="amount" class="amount-input num" bind:value={amountText} inputmode="decimal" placeholder={exp === 0 ? '0' : `0${settings.lang === 'cs' ? ',' : '.'}${'0'.repeat(exp)}`} autocomplete="off" /> <div class="amount-row">
<div class="row" style:justify-content="center"> <span class="cur-pill">
<label class="sr-only" for="currency">{t('currency')}</label> <span aria-hidden="true">{currency}</span><Icon name="down" size={16} />
<div style:max-width="260px" style:width="100%"><CurrencySelect id="currency" bind:value={currency} /></div> <label class="sr-only" for="currency">{t('currency')}</label>
<CurrencySelect id="currency" bind:value={currency} />
</span>
<label class="sr-only" for="amount">{t('amount')}</label>
<input id="amount" class="amount-input num" bind:value={amountText} inputmode="decimal" placeholder={exp === 0 ? '0' : `0${settings.lang === 'cs' ? ',' : '.'}${'0'.repeat(exp)}`} autocomplete="off" />
</div> </div>
{#if currency !== base} {#if currency !== base}
<div class="row small" style:justify-content="center" style:margin-top="6px"> <div class="rate">
<label for="rate" class="muted">1 {currency} =</label> <span class="row small">
<input id="rate" class="num" style:width="120px" style:min-height="36px" inputmode="decimal" bind:value={rateText} <label for="rate" class="muted">1 {currency} =</label>
oninput={() => (rateSource = 'manual')} /> <input id="rate" class="num" inputmode="decimal" bind:value={rateText} oninput={() => (rateSource = 'manual')} />
<span class="muted">{base}</span> <span class="muted">{base}</span>
</span>
<!-- xr: rates come from ExchangeRate-API's free tier, which requires the attribution link. -->
<span class="small muted">
{#if rateMissing && rateSource !== 'manual'}{t('rate_unavailable')}
{:else if rateSource.startsWith('ecb:')}{t('rate_source_ecb', { date: fmtDate(rateSource.slice(4)) })}
{:else if rateSource.startsWith('xr:')}<a href="https://www.exchangerate-api.com" target="_blank" rel="noopener noreferrer">{t('rate_source_xr', { date: fmtDate(rateSource.slice(3)) })}</a>
{:else}{t('rate_source_manual')}{/if}
{#if amount && isValidRate(rateText.trim().replace(',', '.'))} · ≈ {money(Math.round(amount * Number(rateText.replace(',', '.')) * 10 ** (exponent(base) - exp)), base)}{/if}
</span>
</div> </div>
<!-- xr: rates come from ExchangeRate-API's free tier, which requires the attribution link. -->
<p class="small muted" style:text-align="center">
{#if rateMissing && rateSource !== 'manual'}{t('rate_unavailable')}
{:else if rateSource.startsWith('ecb:')}{t('rate_source_ecb', { date: fmtDate(rateSource.slice(4)) })}
{:else if rateSource.startsWith('xr:')}<a href="https://www.exchangerate-api.com" target="_blank" rel="noopener noreferrer">{t('rate_source_xr', { date: fmtDate(rateSource.slice(3)) })}</a>
{:else}{t('rate_source_manual')}{/if}
{#if amount && isValidRate(rateText.trim().replace(',', '.'))} · ≈ {money(Math.round(amount * Number(rateText.replace(',', '.')) * 10 ** (exponent(base) - exp)), base)}{/if}
</p>
{/if} {/if}
</div> </div>
{#if kind === 'expense'} {#if kind === 'expense'}
<label class="field">{t('title')}<input bind:value={title} placeholder={t('title_ph')} maxlength="200" /></label> <label class="sr-only" for="title">{t('title')}</label>
<input id="title" bind:value={title} placeholder={t('title')} maxlength="200" />
<!-- 12 equal tiles: 6 × 2 on phones, one row of 12 on wider screens -->
<div class="field"> <div class="field">
<span class="small muted">{t('category')}</span> <span class="lbl">{t('category')} · <span class="cat-name">{t(`cat_${category}` as MsgKey)}</span></span>
<div class="chips"> <div class="cats" role="group" aria-label={t('category')}>
{#each CATEGORIES as c} {#each CATEGORIES as c}
<button type="button" class="chip" aria-pressed={category === c} onclick={() => (category = c)}> <button type="button" class="cat" style:--cat={CATEGORY_COLORS[c]} aria-pressed={category === c}
<span aria-hidden="true">{CATEGORY_ICONS[c]}</span> {t(`cat_${c}` as MsgKey)} aria-label={t(`cat_${c}` as MsgKey)} title={t(`cat_${c}` as MsgKey)} onclick={() => (category = c)}>
<span aria-hidden="true">{CATEGORY_ICONS[c]}</span>
</button> </button>
{/each} {/each}
</div> </div>
</div> </div>
{/if} {/if}
<label class="field">{t('date')}<input type="date" bind:value={date} required /></label>
<!-- who paid -->
{#if kind === 'transfer'} {#if kind === 'transfer'}
<div class="row"> <div class="pair">
<label class="field" style:flex="1">{t('from_label')} <label class="field">{t('from_label')}
<select bind:value={payer}>{#each members as m}<option value={m.id}>{m.name}</option>{/each}</select> <select bind:value={payer}>{#each members as m}<option value={m.id}>{m.name}</option>{/each}</select>
</label> </label>
<label class="field" style:flex="1">{t('to_label')} <label class="field">{t('to_label')}
<select bind:value={transferTo}>{#each members.filter((m) => m.id !== payer) as m}<option value={m.id}>{m.name}</option>{/each}</select> <select bind:value={transferTo}>{#each members.filter((m) => m.id !== payer) as m}<option value={m.id}>{m.name}</option>{/each}</select>
</label> </label>
</div> </div>
<label class="field">{t('date')}<input type="date" bind:value={date} required /></label>
{:else} {:else}
<div class="field"> <div class="pair">
<span class="row small muted"> <label class="field">{t('date')}<input type="date" bind:value={date} required /></label>
<span class="grow" style:flex="1">{t('paid_by_label')}</span> <label class="field">{t('paid_by_label')}
<label class="row" style:gap="6px"><input type="checkbox" bind:checked={multiPayer} /> {t('multiple_payers')}</label> <select aria-label={t('paid_by_label')} bind:value={() => (multiPayer ? SEVERAL : payer), (v) => { multiPayer = v === SEVERAL; if (v !== SEVERAL) payer = v; }}>
</span> {#each members as m}<option value={m.id}>{m.name}{m.id === me ? ` (${t('you')})` : ''}</option>{/each}
{#if multiPayer} {#if members.length > 1}<option value={SEVERAL}>{t('multiple_payers')}</option>{/if}
</select>
</label>
</div>
{#if multiPayer}
<div class="field">
<div class="list"> <div class="list">
{#each members as m (m.id)} {#each members as m (m.id)}
<div class="item"> <div class="item member">
<Avatar member={m} index={memberIndex(m.id)} size={30} /> <Avatar member={m} index={memberIndex(m.id)} size={28} />
<span class="grow">{m.name}</span> <span class="grow name">{m.name}</span>
<input class="num" style:width="120px" inputmode="decimal" bind:value={payerAmounts[m.id]} aria-label="{t('paid_by_label')}: {m.name}" /> <!-- empty boxes hint at what's still unassigned -->
<input class="num value" inputmode="decimal" bind:value={payerAmounts[m.id]} aria-label="{t('paid_by_label')}: {m.name}"
placeholder={payersRemaining > 0 ? amountInput(payersRemaining, currency) : ''} />
</div> </div>
{/each} {/each}
</div> </div>
{#if payersRemaining !== 0 && amount} {#if amount && payersRemaining !== 0}
<span class="small {payersRemaining < 0 ? 'neg' : 'muted'}"> <span class="small {payersRemaining < 0 ? 'neg' : 'muted'}">
{payersRemaining > 0 ? t('remaining', { amount: money(payersRemaining, currency) }) : t('over_by', { amount: money(-payersRemaining, currency) })} {payersRemaining > 0 ? t('remaining', { amount: money(payersRemaining, currency) }) : t('over_by', { amount: money(-payersRemaining, currency) })}
</span> </span>
{:else if amount && payers.length > 1}
<span class="small pos row adds-up"><Icon name="check" size={14} />{t('adds_up')}</span>
{/if} {/if}
{:else} </div>
<select bind:value={payer} aria-label={t('paid_by_label')}> {/if}
{#each members as m}<option value={m.id}>{m.name}{m.id === me ? ` (${t('you')})` : ''}</option>{/each}
</select>
{/if}
</div>
<!-- split --> <!-- split -->
<div class="field"> <div class="field">
<span class="small muted">{t('split')}</span> <div class="lbl-row">
<div class="seg" role="group" aria-label={t('split')}> <span class="lbl">{t('split')}</span>
<button type="button" class="link" onclick={() => members.forEach((m) => (included[m.id] = true))}>{t('select_all')}</button>
<button type="button" class="link" onclick={() => members.forEach((m) => (included[m.id] = false))}>{t('select_none')}</button>
</div>
<div class="seg modes" role="group" aria-label={t('split')}>
{#each [['equal', 'split_equal'], ['shares', 'split_shares'], ['exact', 'split_exact'], ['percent', 'split_percent']] as const as [m, label]} {#each [['equal', 'split_equal'], ['shares', 'split_shares'], ['exact', 'split_exact'], ['percent', 'split_percent']] as const as [m, label]}
<button type="button" aria-pressed={mode === m} onclick={() => setMode(m)}>{t(label)}</button> <button type="button" aria-pressed={mode === m} onclick={() => setMode(m)}>{t(label)}</button>
{/each} {/each}
</div> </div>
<div class="row small" style:justify-content="flex-end">
<button type="button" class="btn ghost small" onclick={() => members.forEach((m) => (included[m.id] = true))}>{t('select_all')}</button>
<button type="button" class="btn ghost small" onclick={() => members.forEach((m) => (included[m.id] = false))}>{t('select_none')}</button>
</div>
<div class="list"> <div class="list">
{#each members as m (m.id)} {#each members as m (m.id)}
<div class="item"> <div class="item member" class:off={!included[m.id]}>
<input type="checkbox" bind:checked={included[m.id]} aria-label={m.name} /> <input id="inc-{m.id}" type="checkbox" bind:checked={included[m.id]} aria-label={m.name} />
<Avatar member={m} index={memberIndex(m.id)} size={30} /> <label for="inc-{m.id}" class="grow who">
<span class="grow"> <Avatar member={m} index={memberIndex(m.id)} size={28} />
<span style:display="block">{m.name}</span> <span class="name">{m.name}</span>
{#if preview[m.id]}<span class="small muted num">{money(preview[m.id], currency)}</span>{/if} </label>
</span> <!-- what each person owes; in "Amounts" mode the input already says it -->
{#if mode !== 'exact' && preview[m.id]}
<span class="num share" class:small={mode !== 'equal'} class:muted={mode !== 'equal'}>{money(preview[m.id], currency)}</span>
{/if}
{#if mode !== 'equal'} {#if mode !== 'equal'}
<span class="row" style:gap="4px"> <span class="row value-wrap">
<input class="num" style:width={mode === 'exact' ? '110px' : '72px'} inputmode={mode === 'shares' ? 'numeric' : 'decimal'} <input class="num value" class:narrow={mode !== 'exact'} inputmode={mode === 'shares' ? 'numeric' : 'decimal'}
bind:value={values[m.id]} disabled={!included[m.id]} aria-label="{t('split')}: {m.name}" /> bind:value={values[m.id]} disabled={!included[m.id]} aria-label="{t('split')}: {m.name}" />
{#if mode === 'percent'}<span class="muted">%</span>{/if} {#if mode === 'percent'}<span class="muted">%</span>{/if}
</span> </span>
@ -382,29 +411,38 @@
</div> </div>
{/if} {/if}
<!-- photo --> <!-- extras: photo, note and repeat stay folded away until wanted -->
{#if repeat === 'none'} <div class="extras">
<div class="field"> {#if repeat === 'none'}
<span class="small muted">{t('photo')}</span> <label class="btn small">
<Icon name="camera" size={16} />{photo || newPhoto ? t('replace_photo') : t('photo')}
<input class="sr-only" type="file" accept="image/*" onchange={pickPhoto} disabled={photoBusy} />
</label>
{/if}
{#if !showNote}
<button type="button" class="btn small" onclick={openNote}><Icon name="edit" size={16} />{t('note')}</button>
{/if}
{#if !existing && kind === 'expense' && !showRepeat}
<button type="button" class="btn small" onclick={() => (showRepeat = true)}><Icon name="repeat" size={16} />{t('repeat')}</button>
{/if}
</div>
{#if repeat === 'none' && (photo || newPhoto || photoBusy)}
<div class="photo">
{#if newPhotoUrl} {#if newPhotoUrl}
<img class="photo-thumb" src={newPhotoUrl} alt={t('photo')} /> <img class="photo-thumb" src={newPhotoUrl} alt={t('photo')} />
{:else if photo} {:else if photo}
<PhotoView {session} {photo} /> <PhotoView {session} {photo} />
{/if} {/if}
<div class="row"> <div class="row">
<label class="btn small">
{photo || newPhoto ? t('replace_photo') : t('add_photo')}
<input class="sr-only" type="file" accept="image/*" onchange={pickPhoto} disabled={photoBusy} />
</label>
{#if photo || newPhoto}<button type="button" class="btn small ghost" onclick={removePhoto}>{t('remove_photo')}</button>{/if} {#if photo || newPhoto}<button type="button" class="btn small ghost" onclick={removePhoto}>{t('remove_photo')}</button>{/if}
{#if photoBusy}<span class="small muted">{t('processing_photo')}</span>{/if} {#if photoBusy}<span class="small muted">{t('processing_photo')}</span>{/if}
</div> </div>
</div> </div>
{/if} {/if}
{#if showNote}
<label class="field">{t('note')}<textarea bind:value={note} maxlength="2000"></textarea></label> <label class="field">{t('note')}<textarea bind:this={noteEl} bind:value={note} maxlength="2000" rows="2"></textarea></label>
{/if}
{#if !existing && kind === 'expense'} {#if showRepeat && !existing && kind === 'expense'}
<label class="field">{t('repeat')} <label class="field">{t('repeat')}
<select bind:value={repeat}> <select bind:value={repeat}>
<option value="none">{t('repeat_none')}</option> <option value="none">{t('repeat_none')}</option>
@ -415,10 +453,77 @@
</label> </label>
{/if} {/if}
{#if error}<p class="neg" role="alert">{error}</p>{/if} <div class="save-bar">
<div class="row"> {#if error}<p class="neg" role="alert">{error}</p>{/if}
<button type="button" class="btn" style:flex="1" onclick={close}>{t('cancel')}</button> <button type="submit" class="btn primary" disabled={saving || photoBusy}>{t('save')}</button>
<button type="submit" class="btn primary" style:flex="2" disabled={saving || photoBusy}>{t('save')}</button>
</div> </div>
</form> </form>
</Sheet> </Sheet>
<style>
.editor { display: flex; flex-direction: column; gap: 12px; }
/* On phones the sheet is full screen: keep Save at the bottom edge. */
@media (max-width: 759px) {
.editor { min-height: calc(100dvh - 88px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
}
.seg.kind button, .seg.modes button { min-height: 32px; }
.seg.modes button { font-size: 0.86rem; padding: 0 6px; }
.lbl { font-size: 0.85rem; color: var(--muted); }
.cat-name { color: var(--text); font-weight: 600; }
.field { display: flex; flex-direction: column; gap: 6px; }
.amount-card { display: flex; flex-direction: column; gap: 8px; padding: 8px 12px; }
.amount-row { display: flex; align-items: center; gap: 12px; }
.amount-row .amount-input { flex: 1; min-width: 0; text-align: right; font-size: 2.2rem; min-height: 50px; padding: 0; }
.cur-pill {
position: relative; flex-shrink: 0; display: inline-flex; align-items: center; gap: 4px;
height: 40px; padding: 0 10px 0 14px; border-radius: 999px; background: var(--surface-2); font-weight: 700;
}
.cur-pill:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.cur-pill :global(select) { position: absolute; inset: 0; opacity: 0; min-height: 0; height: 100%; cursor: pointer; }
.rate { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; }
.rate input { width: 110px; min-height: 34px; padding: 4px 10px; }
.cats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 600px) { .cats { grid-template-columns: repeat(12, minmax(0, 1fr)); } }
.cat {
aspect-ratio: 1; max-height: 56px; display: grid; place-items: center; padding: 0;
border: 2px solid transparent; border-radius: 16px; font-size: 1.35rem; cursor: pointer;
background: color-mix(in srgb, var(--cat) 14%, var(--surface));
transition: background-color 0.12s, border-color 0.12s, transform 0.12s;
}
.cat span { filter: saturate(0.85); }
.cat[aria-pressed='true'] { border-color: var(--cat); background: color-mix(in srgb, var(--cat) 34%, var(--surface)); transform: scale(1.04); }
.cat[aria-pressed='true'] span { filter: none; }
.cat:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.lbl-row { display: flex; align-items: center; gap: 4px; }
.lbl-row .lbl { flex: 1; }
.link { border: 0; background: none; color: var(--accent); font: inherit; font-size: 0.85rem; font-weight: 600; padding: 0 8px; cursor: pointer; }
.member { gap: 10px; padding: 6px 12px; min-height: 46px; }
.member.off .who, .member.off .share { opacity: 0.45; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; cursor: pointer; }
.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share { flex-shrink: 0; }
.value-wrap { gap: 4px; flex-shrink: 0; }
.value { width: 104px; min-height: 36px; padding: 4px 10px; text-align: right; }
.value.narrow { width: 64px; }
.value::placeholder { color: var(--muted); opacity: 0.6; }
.adds-up { gap: 4px; }
.extras { display: flex; flex-wrap: wrap; gap: 8px; }
.extras .btn { flex: 1 1 auto; gap: 6px; padding: 0 12px; }
.photo { display: flex; flex-direction: column; gap: 8px; }
.photo .photo-thumb { max-height: 160px; }
.save-bar {
position: sticky; bottom: 0; margin-top: auto; display: flex; flex-direction: column; gap: 8px;
padding: 10px 0 calc(2px + env(safe-area-inset-bottom));
background: linear-gradient(to bottom, transparent, var(--bg) 14px);
}
.save-bar .btn { width: 100%; }
.save-bar p { margin: 0; }
</style>

View file

@ -0,0 +1,215 @@
<script lang="ts">
// Touch gestures on the group page (shortcuts; every action also has a button):
// - Pull up past the end of the page: a pill rises from behind the tab bar;
// letting go once it reads "Release to add" opens the add-expense sheet.
// Bottom rather than top, so the browser's pull-to-refresh keeps working.
// - Swipe sideways: previous / next tab. Touches near the screen edges are
// left to the OS back/forward gestures.
import { t } from '../lib/settings.svelte.ts';
import Icon from './Icon.svelte';
const {
enabled,
addEnabled,
tabs,
current,
onadd,
ontab,
}: {
/** Gestures at all (off while a sheet or the identity picker is open). */
enabled: boolean;
/** Pull-up-to-add on this tab. */
addEnabled: boolean;
tabs: readonly string[];
current: string;
onadd: () => void;
ontab: (key: string, dir: 1 | -1) => void;
} = $props();
/** How far the pill must rise (after resistance) before a release adds. */
const THRESHOLD = 72;
const MAX = 110;
/** Finger movement before we decide which gesture this is. */
const SLOP = 10;
/** Touches starting this close to the left/right edge belong to the OS. */
const EDGE = 24;
let pull = $state(0);
let bottom = $state(0);
let releasing = $state(false);
const armed = $derived(pull >= THRESHOLD);
const atBottom = () => window.scrollY + window.innerHeight >= document.documentElement.scrollHeight - 2;
/** True if the touch starts inside something that scrolls sideways itself. */
function inHorizontalScroller(el: Element | null): boolean {
for (; el && el !== document.body; el = el.parentElement) {
const ox = getComputedStyle(el).overflowX;
if ((ox === 'auto' || ox === 'scroll') && el.scrollWidth > el.clientWidth) return true;
}
return false;
}
$effect(() => {
if (!enabled) return;
// Read props through closures so the listeners always see current values
// without being re-attached on every tab change.
const add = () => addEnabled;
const tabList = () => tabs;
const cur = () => current;
type Track = { x: number; y: number; t: number; mode: 'undecided' | 'add' | 'swipe'; canAdd: boolean; canSwipe: boolean };
let tr: Track | null = null;
let wasArmed = false;
const page = () => document.querySelector<HTMLElement>('.layout');
function neighbour(dir: 1 | -1): string | undefined {
const list = tabList();
return list[list.indexOf(cur()) + dir];
}
function resetPull() {
releasing = true;
pull = 0;
wasArmed = false;
}
function resetSwipe(el: HTMLElement | null) {
if (!el) return;
el.style.transition = 'transform 0.2s ease';
el.style.transform = '';
el.addEventListener('transitionend', () => (el.style.transition = ''), { once: true });
}
const onStart = (e: TouchEvent) => {
tr = null;
if (e.touches.length !== 1) return;
const target = e.target as Element | null;
if (target?.closest('input, textarea, select, dialog')) return;
const tch = e.touches[0];
const nearEdge = tch.clientX < EDGE || tch.clientX > window.innerWidth - EDGE;
tr = {
x: tch.clientX, y: tch.clientY, t: e.timeStamp, mode: 'undecided',
canAdd: add() && atBottom(),
canSwipe: !nearEdge && !inHorizontalScroller(target),
};
if (tr.canAdd) {
const bar = document.querySelector('.tabbar')?.getBoundingClientRect();
// The tab bar floats at the bottom on phones; the pill hides behind it.
bottom = bar && getComputedStyle(document.querySelector('.tabbar')!).position === 'fixed'
? window.innerHeight - bar.top + 8 : 16;
}
};
const onMove = (e: TouchEvent) => {
if (!tr) return;
const tch = e.touches[0];
const dx = tch.clientX - tr.x;
const dy = tch.clientY - tr.y;
if (tr.mode === 'undecided') {
if (Math.abs(dx) < SLOP && Math.abs(dy) < SLOP) return;
if (tr.canSwipe && Math.abs(dx) > Math.abs(dy) * 1.2) tr.mode = 'swipe';
else if (tr.canAdd && dy < 0 && Math.abs(dy) > Math.abs(dx) && atBottom()) {
tr.mode = 'add';
releasing = false;
} else {
tr = null; // ordinary scrolling
return;
}
}
if (e.cancelable) e.preventDefault();
if (tr.mode === 'add') {
pull = Math.min(MAX, Math.max(0, -dy - SLOP) * 0.55);
const nowArmed = pull >= THRESHOLD;
if (nowArmed && !wasArmed) navigator.vibrate?.(10);
wasArmed = nowArmed;
} else {
const el = page();
if (!el) return;
// Rubber-band at the first and last tab.
const free = neighbour(dx < 0 ? 1 : -1) !== undefined;
const shift = free ? dx * 0.6 : dx * 0.15;
el.style.transition = '';
el.style.transform = `translateX(${shift}px)`;
}
};
const onEnd = (e: TouchEvent) => {
if (!tr) return;
const t0 = tr;
tr = null;
if (t0.mode === 'add') {
const go = pull >= THRESHOLD;
resetPull();
if (go) onadd();
} else if (t0.mode === 'swipe') {
const tch = e.changedTouches[0];
const dx = tch.clientX - t0.x;
const speed = Math.abs(dx) / Math.max(1, e.timeStamp - t0.t);
const dir: 1 | -1 = dx < 0 ? 1 : -1;
const next = neighbour(dir);
const el = page();
if (next && (Math.abs(dx) > window.innerWidth * 0.25 || (Math.abs(dx) > 40 && speed > 0.4))) {
if (el) { el.style.transition = ''; el.style.transform = ''; }
ontab(next, dir);
} else {
resetSwipe(el);
}
}
};
const onCancel = () => {
if (tr?.mode === 'add') resetPull();
if (tr?.mode === 'swipe') resetSwipe(page());
tr = null;
};
window.addEventListener('touchstart', onStart, { passive: true });
window.addEventListener('touchmove', onMove, { passive: false });
window.addEventListener('touchend', onEnd);
window.addEventListener('touchcancel', onCancel);
return () => {
window.removeEventListener('touchstart', onStart);
window.removeEventListener('touchmove', onMove);
window.removeEventListener('touchend', onEnd);
window.removeEventListener('touchcancel', onCancel);
const el = page();
if (el) el.style.transform = '';
pull = 0;
};
});
</script>
<div
class="pull"
class:armed
class:releasing
aria-hidden="true"
style:bottom="{bottom}px"
style:transform="translate(-50%, {48 - pull}px)"
style:opacity={Math.min(1, pull / 32)}
>
<span class="c"><Icon name={armed ? 'plus' : 'up'} size={18} /></span>
{armed ? t('release_to_add') : t('pull_to_add')}
</div>
<style>
.pull {
position: fixed; left: 50%; z-index: 19; pointer-events: none;
display: flex; align-items: center; gap: 8px;
padding: 6px 14px 6px 6px; border-radius: 999px;
background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
color: var(--muted); font-size: 0.88rem; font-weight: 600; white-space: nowrap;
opacity: 0;
}
.c {
display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
background: var(--surface-2); color: var(--text);
}
.armed { color: var(--text); }
.armed .c { background: var(--accent); color: var(--accent-ink); }
.releasing { transition: transform 0.2s ease, opacity 0.2s ease; }
@media (prefers-reduced-motion: reduce) {
.releasing { transition: none; }
}
</style>

View file

@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { onDestroy, untrack } from 'svelte'; import { onDestroy, tick, untrack } from 'svelte';
import { forgetGroup } from '../lib/idb.ts'; import { forgetGroup } from '../lib/idb.ts';
import { router } from '../lib/router.svelte.ts'; import { router } from '../lib/router.svelte.ts';
import { closeSession, openSession, type GroupSession } from '../lib/session.svelte.ts'; import { closeSession, openSession, type GroupSession } from '../lib/session.svelte.ts';
@ -13,6 +13,7 @@
import GroupSettings from './GroupSettings.svelte'; import GroupSettings from './GroupSettings.svelte';
import Icon from './Icon.svelte'; import Icon from './Icon.svelte';
import IdentityPicker from './IdentityPicker.svelte'; import IdentityPicker from './IdentityPicker.svelte';
import GroupGestures from './GroupGestures.svelte';
import Stats from './Stats.svelte'; import Stats from './Stats.svelte';
// Keyed by group id in App.svelte, so reading it once is enough. // Keyed by group id in App.svelte, so reading it once is enough.
@ -47,6 +48,18 @@
!!session && session.status !== 'loading' && session.state.members.length > 0 && !session.me && !skippedIdentity, !!session && session.status !== 'loading' && session.state.members.length > 0 && !session.me && !skippedIdentity,
); );
/** Tab change from a swipe: the new tab slides in from the side it came from. */
async function switchTab(key: string, dir: 1 | -1) {
const path = tabs.find((x) => x.key === key)!.path;
router.go(path, { replace: true });
await tick();
if (matchMedia('(prefers-reduced-motion: reduce)').matches) return;
document.querySelector('.layout')?.animate(
[{ transform: `translateX(${dir * 48}px)`, opacity: 0.4 }, { transform: 'none', opacity: 1 }],
{ duration: 180, easing: 'ease-out' },
);
}
async function remove() { async function remove() {
await forgetGroup(id); await forgetGroup(id);
router.go('/', { replace: true }); router.go('/', { replace: true });
@ -121,6 +134,15 @@
<a class="fab" href="{base}/e/new" onclick={(e) => nav(e, `${base}/e/new`)} aria-label={t('add_expense')}><Icon name="plus" size={28} /></a> <a class="fab" href="{base}/e/new" onclick={(e) => nav(e, `${base}/e/new`)} aria-label={t('add_expense')}><Icon name="plus" size={28} /></a>
{/if} {/if}
<GroupGestures
enabled={route.name === 'group' && s.status !== 'gone' && !needsIdentity}
addEnabled={withHeader}
tabs={tabs.map((x) => x.key)}
current={tab}
onadd={() => router.go(`${base}/e/new`)}
ontab={switchTab}
/>
{#if route.name === 'expense'} {#if route.name === 'expense'}
<ExpenseDetail session={s} eid={route.eid} /> <ExpenseDetail session={s} eid={route.eid} />
{:else if route.name === 'expense-edit'} {:else if route.name === 'expense-edit'}
@ -133,6 +155,8 @@
{/if} {/if}
<style> <style>
/* A tab being swiped sideways must not widen the page. */
main { overflow-x: clip; }
.group-icon { .group-icon {
display: grid; place-items: center; flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%;
background: var(--surface-2); font-size: 1.1rem; background: var(--surface-2); font-size: 1.1rem;

View file

@ -31,6 +31,7 @@
let defaultCategory = $state<string>(s.state.group?.defaultCategory ?? 'other'); let defaultCategory = $state<string>(s.state.group?.defaultCategory ?? 'other');
let newMember = $state(''); let newMember = $state('');
let deleteConfirm = $state(''); let deleteConfirm = $state('');
let deleteOpen = $state(false);
let push = $state<PushSupport | null>(null); let push = $state<PushSupport | null>(null);
let pushBusy = $state(false); let pushBusy = $state(false);
pushSupport().then((p) => (push = p)); pushSupport().then((p) => (push = p));
@ -123,10 +124,12 @@
<div class="card stack"> <div class="card stack">
{#if justCreated}<p class="banner warn">{t('save_link_warning')}</p>{/if} {#if justCreated}<p class="banner warn">{t('save_link_warning')}</p>{/if}
<p class="small muted">{t('share_intro')}</p> <p class="small muted">{t('share_intro')}</p>
<div class="row wrap"> <div class="row">
<button class="btn primary" onclick={copy}><Icon name="copy" size={18} /> {t('copy_link')}</button> <button class="btn primary grow" onclick={copy}><Icon name="copy" size={18} /> {t('copy_link')}</button>
{#if 'share' in navigator}<button class="btn" onclick={nativeShare}><Icon name="share" size={18} /> {t('share')}</button>{/if} {#if 'share' in navigator}
<button class="btn ghost" onclick={() => (showQr = !showQr)}>QR</button> <button class="btn square" onclick={nativeShare} aria-label={t('share')} title={t('share')}><Icon name="share" size={18} /></button>
{/if}
<button class="btn square" aria-pressed={showQr} aria-label={t('qr_code')} title={t('qr_code')} onclick={() => (showQr = !showQr)}>QR</button>
</div> </div>
{#if showQr} {#if showQr}
<div class="qr">{@html qr}</div> <div class="qr">{@html qr}</div>
@ -136,90 +139,82 @@
<!-- group --> <!-- group -->
<section class="section"> <section class="section">
<h3>{t('group_settings')}</h3> <h3>{t('group')}</h3>
<form class="card stack" onsubmit={saveGroup}> <form class="card stack" onsubmit={saveGroup}>
<div class="row"> <div class="row">
<label class="field" style:width="80px">{t('icon')}<input bind:value={icon} maxlength="8" /></label> <label class="field" style:width="72px">{t('icon')}<input bind:value={icon} maxlength="8" /></label>
<label class="field" style:flex="1">{t('group_name')}<input bind:value={name} maxlength="100" required /></label> <label class="field" style:flex="1">{t('group_name')}<input bind:value={name} maxlength="100" required /></label>
</div> </div>
<label class="field"> <div class="pair">
{t('base_currency')} <label class="field">
<CurrencySelect bind:value={baseCurrency} disabled={locked} /> {t('base_currency')}
<span class="small">{locked ? t('base_currency_locked') : t('base_currency_hint')}</span> <CurrencySelect bind:value={baseCurrency} disabled={locked} />
</label> </label>
<label class="field"> <label class="field">
{t('default_category')} {t('default_category')}
<select bind:value={defaultCategory}> <select bind:value={defaultCategory}>
{#each CATEGORIES as c}<option value={c}>{CATEGORY_ICONS[c]} {t(`cat_${c}` as MsgKey)}</option>{/each} {#each CATEGORIES as c}<option value={c}>{CATEGORY_ICONS[c]} {t(`cat_${c}` as MsgKey)}</option>{/each}
</select> </select>
<span class="small">{t('default_category_hint')}</span> </label>
</label> </div>
<button class="btn primary" type="submit" disabled={!dirty || !name.trim()}>{t('save')}</button> {#if locked}<p class="small muted">{t('base_currency_locked')}</p>{/if}
{#if dirty}<button class="btn primary" type="submit" disabled={!name.trim()}>{t('save')}</button>{/if}
</form> </form>
</section> </section>
<!-- identity --> <!-- members, with "you are" on top -->
<section class="section">
<h3>{t('identity')}</h3>
<select value={s.me ?? ''} onchange={(e) => s.setMe((e.target as HTMLSelectElement).value || null)} aria-label={t('identity')}>
<option value="">{t('not_set')}</option>
{#each s.state.members.filter((m) => !m.archived) as m}<option value={m.id}>{m.name}</option>{/each}
</select>
</section>
<!-- members -->
<section class="section"> <section class="section">
<h3>{t('members')}</h3> <h3>{t('members')}</h3>
<div class="list"> <div class="list">
<div class="item">
<span class="grow">{t('identity')}</span>
<select class="me" value={s.me ?? ''} onchange={(e) => s.setMe((e.target as HTMLSelectElement).value || null)} aria-label={t('identity')}>
<option value="">{t('not_set')}</option>
{#each s.state.members.filter((m) => !m.archived) as m}<option value={m.id}>{m.name}</option>{/each}
</select>
</div>
{#each s.state.members as m, i (m.id)} {#each s.state.members as m, i (m.id)}
{@const bal = s.balances[m.id] ?? 0} {@const bal = s.balances[m.id] ?? 0}
<div class="item"> <div class="item" class:archived={m.archived}>
<Avatar member={m} index={i} size={32} /> <Avatar member={m} index={i} size={32} />
<span class="grow"> <span class="grow">
<span class="title" style:display="block">{m.name}{m.archived ? ` · ${t('archived')}` : ''}</span> <span class="title" style:display="block">{m.name}{m.id === s.me ? ` (${t('you')})` : ''}{m.archived ? ` · ${t('archived')}` : ''}</span>
<span class="sub num {bal > 0 ? 'pos' : bal < 0 ? 'neg' : ''}">{bal === 0 ? t('settled') : money(bal, s.base, { sign: true })}</span> <span class="sub num {bal > 0 ? 'pos' : bal < 0 ? 'neg' : ''}">{bal === 0 ? t('settled') : money(bal, s.base, { sign: true })}</span>
</span> </span>
<button class="btn small ghost" onclick={() => rename(m.id, m.name)}>{t('rename')}</button> <button class="icon-btn" onclick={() => rename(m.id, m.name)} aria-label="{t('rename')}: {m.name}" title={t('rename')}><Icon name="edit" size={18} /></button>
{#if m.archived} {#if m.archived}
<button class="btn small ghost" onclick={() => s.emit({ type: 'member.restored', data: { id: m.id } })}>{t('unarchive')}</button> <button class="icon-btn" onclick={() => s.emit({ type: 'member.restored', data: { id: m.id } })} aria-label="{t('unarchive')}: {m.name}" title={t('unarchive')}><Icon name="undo" size={18} /></button>
{:else} {:else}
<button class="btn small ghost" disabled={bal !== 0} title={bal !== 0 ? t('archive_needs_zero') : ''} <button class="icon-btn" disabled={bal !== 0} aria-label="{t('archive')}: {m.name}" title={bal !== 0 ? t('archive_needs_zero') : t('archive')}
onclick={() => s.emit({ type: 'member.archived', data: { id: m.id } })}>{t('archive')}</button> onclick={() => s.emit({ type: 'member.archived', data: { id: m.id } })}><Icon name="archive" size={18} /></button>
{/if} {/if}
</div> </div>
{/each} {/each}
</div> <form class="item" onsubmit={addMember}>
<form class="row" onsubmit={addMember}> <input class="bare" bind:value={newMember} placeholder={t('member_name')} maxlength="60" aria-label={t('member_name')} />
<input bind:value={newMember} placeholder={t('member_name')} maxlength="60" aria-label={t('member_name')} /> <button class="btn small" type="submit" disabled={!newMember.trim()}><Icon name="plus" size={16} /> {t('add_member')}</button>
<button class="btn" type="submit" disabled={!newMember.trim()}><Icon name="plus" size={18} /> {t('add_member')}</button> </form>
</form>
</section>
<!-- notifications -->
<section class="section">
<h3>{t('notifications')}</h3>
<div class="card stack">
{#if push === 'ok' || s.local.push}
<label class="row">
<input type="checkbox" checked={s.local.push} disabled={pushBusy} onchange={togglePush} />
<span>{t('notifications_hint')}</span>
</label>
{:else if push === 'needs-install'}
<p class="small">{t('notifications_ios')}</p>
{:else if push === 'denied'}
<p class="small">{t('notifications_denied')}</p>
{:else if push}
<p class="small muted">{t('notifications_unavailable')}</p>
{/if}
</div> </div>
</section> </section>
<!-- recurring --> {#if push === 'ok' || s.local.push}
<section class="section"> <section class="section">
<h3>{t('recurring')}</h3> <h3>{t('notifications')}</h3>
{#if Object.keys(s.state.recurring).length === 0} <label class="list item">
<p class="card small muted">{t('no_recurring')}</p> <span class="grow">{t('notifications_hint')}</span>
{:else} <input class="switch" type="checkbox" checked={s.local.push} disabled={pushBusy} onchange={togglePush} />
</label>
</section>
{:else if push === 'needs-install' || push === 'denied'}
<section class="section">
<h3>{t('notifications')}</h3>
<p class="small muted">{push === 'denied' ? t('notifications_denied') : t('notifications_ios')}</p>
</section>
{/if}
{#if Object.keys(s.state.recurring).length}
<section class="section">
<h3>{t('recurring')}</h3>
<div class="list"> <div class="list">
{#each Object.values(s.state.recurring) as r (r.id)} {#each Object.values(s.state.recurring) as r (r.id)}
{@const next = nextOccurrence(r.rule, today())} {@const next = nextOccurrence(r.rule, today())}
@ -233,16 +228,16 @@
</div> </div>
{/each} {/each}
</div> </div>
{/if} </section>
</section> {/if}
<!-- export --> <!-- export -->
<section class="section"> <section class="section">
<h3>{t('export')}</h3> <h3>{t('export')}</h3>
<div class="row wrap"> <div class="row wrap exports">
<button class="btn" onclick={() => download(`${fileBase()}-expenses.csv`, '' + expensesCsv(s.state), 'text/csv')}>{t('export_expenses')}</button> <button class="btn small" onclick={() => download(`${fileBase()}-expenses.csv`, '' + expensesCsv(s.state), 'text/csv')}>{t('export_expenses')}</button>
<button class="btn" onclick={() => download(`${fileBase()}-balances.csv`, '' + balancesCsv(s.state), 'text/csv')}>{t('export_balances')}</button> <button class="btn small" onclick={() => download(`${fileBase()}-balances.csv`, '' + balancesCsv(s.state), 'text/csv')}>{t('export_balances')}</button>
<button class="btn" onclick={backup}>{t('backup')}</button> <button class="btn small" onclick={backup}>{t('backup')}</button>
</div> </div>
<p class="small muted">{t('backup_hint')}</p> <p class="small muted">{t('backup_hint')}</p>
</section> </section>
@ -250,21 +245,63 @@
<!-- danger --> <!-- danger -->
<section class="section"> <section class="section">
<h3>{t('danger_zone')}</h3> <h3>{t('danger_zone')}</h3>
<div class="card stack"> <div class="list">
<p class="small muted">{t('remove_from_device_hint')}</p> <button class="item" onclick={removeFromDevice}>
<button class="btn" onclick={removeFromDevice}>{t('remove_from_device')}</button> <Icon name="close" size={18} />
</div> <span class="grow">
<div class="card stack"> <span class="title" style:display="block">{t('remove_from_device')}</span>
<p class="small muted">{t('delete_group_hint')}</p> <span class="sub">{t('remove_from_device_hint')}</span>
<input bind:value={deleteConfirm} placeholder={s.state.group?.name} aria-label={t('group_name')} /> </span>
<button class="btn danger" disabled={deleteConfirm.trim() !== s.state.group?.name} onclick={deleteGroup}>
<Icon name="trash" size={18} /> {t('delete_group')}
</button> </button>
<button class="item danger" aria-expanded={deleteOpen} onclick={() => (deleteOpen = !deleteOpen)}>
<Icon name="trash" size={18} />
<span class="grow">
<span class="title" style:display="block">{t('delete_group')}</span>
<span class="sub">{t('delete_group_hint')}</span>
</span>
</button>
{#if deleteOpen}
<div class="confirm stack">
<label class="field">
{t('type_name_to_confirm')}
<input bind:value={deleteConfirm} placeholder={s.state.group?.name} />
</label>
<button class="btn danger" disabled={deleteConfirm.trim() !== s.state.group?.name} onclick={deleteGroup}>
<Icon name="trash" size={18} /> {t('delete_group')}
</button>
</div>
{/if}
</div> </div>
</section> </section>
</main> </main>
<style> <style>
.qr { width: min(260px, 100%); margin: 0 auto; background: #fff; border-radius: 12px; padding: 8px; } .qr { width: min(240px, 100%); margin: 0 auto; background: #fff; border-radius: 12px; padding: 8px; }
.qr :global(svg) { width: 100%; height: auto; display: block; } .qr :global(svg) { width: 100%; height: auto; display: block; }
.grow { flex: 1; }
.btn.square { width: 48px; padding: 0; flex-shrink: 0; font-weight: 700; }
.btn.square[aria-pressed='true'] { background: var(--surface-2); }
.pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.item select.me { width: auto; max-width: 55%; min-height: 36px; padding: 4px 10px; }
.item .icon-btn { width: 36px; height: 36px; color: var(--muted); }
.item .icon-btn:disabled { opacity: 0.35; }
.item.archived .title { color: var(--muted); }
.item input.bare { border: 0; background: none; padding: 0; min-height: 36px; min-width: 0; flex: 1; }
.item.danger, .item.danger .sub { color: var(--danger); }
.item .sub { white-space: normal; }
.exports .btn { flex: 1 1 auto; }
.confirm { padding: 12px 14px 14px; }
.switch {
appearance: none; -webkit-appearance: none; flex-shrink: 0; cursor: pointer;
width: 46px; height: 28px; min-height: 0; padding: 0; border-radius: 999px; position: relative;
background: var(--surface-2); border: 1px solid var(--line); transition: background 0.15s;
}
.switch::after {
content: ''; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%;
background: var(--text); transition: transform 0.15s;
}
.switch:checked { background: var(--accent); border-color: transparent; }
.switch:checked::after { transform: translateX(18px); background: var(--accent-ink); }
.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .switch, .switch::after { transition: none; } }
</style> </style>

View file

@ -20,6 +20,10 @@
undo: 'M3 7v6h6M21 17a9 9 0 0 0-15-6.7L3 13', undo: 'M3 7v6h6M21 17a9 9 0 0 0-15-6.7L3 13',
link: 'M10 13a5 5 0 0 0 7.5.5l3-3a5 5 0 0 0-7-7l-1.7 1.7M14 11a5 5 0 0 0-7.5-.5l-3 3a5 5 0 0 0 7 7l1.7-1.7', link: 'M10 13a5 5 0 0 0 7.5.5l3-3a5 5 0 0 0-7-7l-1.7 1.7M14 11a5 5 0 0 0-7.5-.5l-3 3a5 5 0 0 0 7 7l1.7-1.7',
upload: 'M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M17 8l-5-5-5 5M12 3v12', upload: 'M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M17 8l-5-5-5 5M12 3v12',
down: 'M6 9l6 6 6-6',
up: 'M6 15l6-6 6 6',
check: 'M20 6L9 17l-5-5',
archive: 'M3 4h18v5H3zM5 9v11h14V9M10 13h4',
} as const; } as const;
let { name, size = 22 }: { name: keyof typeof paths; size?: number } = $props(); let { name, size = 22 }: { name: keyof typeof paths; size?: number } = $props();

View file

@ -43,7 +43,7 @@ const cs: Messages = {
creating: 'Vytvářím…', creating: 'Vytvářím…',
share_group: 'Sdílet skupinu', share_group: 'Sdílet skupinu',
share_intro: 'Kdokoli s tímto odkazem může skupinu vidět i upravovat. Posílejte ho jen členům.', share_intro: 'Kdo má odkaz, může skupinu vidět i upravovat.',
save_link_warning: 'Uložte si tento odkaz na bezpečné místo. Pokud se ztratí všechny kopie, skupinu nepůjde obnovit.', save_link_warning: 'Uložte si tento odkaz na bezpečné místo. Pokud se ztratí všechny kopie, skupinu nepůjde obnovit.',
copy_link: 'Kopírovat odkaz', copy_link: 'Kopírovat odkaz',
copied: 'Zkopírováno', copied: 'Zkopírováno',
@ -62,6 +62,8 @@ const cs: Messages = {
stats: 'Statistiky', stats: 'Statistiky',
activity: 'Aktivita', activity: 'Aktivita',
add_expense: 'Přidat výdaj', add_expense: 'Přidat výdaj',
pull_to_add: 'Táhněte nahoru pro nový výdaj',
release_to_add: 'Pusťte a přidejte',
no_expenses: 'Zatím žádné výdaje. Klepněte na + a přidejte první.', no_expenses: 'Zatím žádné výdaje. Klepněte na + a přidejte první.',
total_spent: 'Celkem utraceno', total_spent: 'Celkem utraceno',
summary: 'Přehled', summary: 'Přehled',
@ -74,7 +76,7 @@ const cs: Messages = {
payment_short: 'Platba', payment_short: 'Platba',
add_payment: 'Zaznamenat platbu', add_payment: 'Zaznamenat platbu',
paid_by: 'Platil(a) {name}', paid_by: 'Platil(a) {name}',
paid_by_many: 'Platilo {n} lidí', paid_by_many: { one: '{n} plátce', few: '{n} plátci', other: '{n} plátců' },
your_share: 'váš podíl {amount}', your_share: 'váš podíl {amount}',
you_lent: 'půjčili jste {amount}', you_lent: 'půjčili jste {amount}',
you_borrowed: 'dlužíte {amount}', you_borrowed: 'dlužíte {amount}',
@ -107,7 +109,6 @@ const cs: Messages = {
title_ph: 'Večeře', title_ph: 'Večeře',
category: 'Kategorie', category: 'Kategorie',
default_category: 'Výchozí kategorie', default_category: 'Výchozí kategorie',
default_category_hint: 'Nové výdaje začnou v této kategorii.',
date: 'Datum', date: 'Datum',
currency: 'Měna', currency: 'Měna',
rate: 'Směnný kurz', rate: 'Směnný kurz',
@ -118,7 +119,7 @@ const cs: Messages = {
currencies_manual: 'Kurz zadáte ručně', currencies_manual: 'Kurz zadáte ručně',
rate_unavailable: 'Pro tuto měnu není kurz k dispozici, zadejte ho prosím.', rate_unavailable: 'Pro tuto měnu není kurz k dispozici, zadejte ho prosím.',
paid_by_label: 'Platil(a)', paid_by_label: 'Platil(a)',
multiple_payers: 'Platilo více lidí', multiple_payers: 'Více lidí',
from_label: 'Od', from_label: 'Od',
to_label: 'Komu', to_label: 'Komu',
split: 'Rozdělení', split: 'Rozdělení',
@ -128,11 +129,11 @@ const cs: Messages = {
split_percent: 'Procenta', split_percent: 'Procenta',
remaining: 'Zbývá: {amount}', remaining: 'Zbývá: {amount}',
over_by: 'Přebývá: {amount}', over_by: 'Přebývá: {amount}',
adds_up: 'Součet sedí',
select_all: 'Všichni', select_all: 'Všichni',
select_none: 'Nikdo', select_none: 'Nikdo',
note: 'Poznámka', note: 'Poznámka',
photo: 'Fotka', photo: 'Fotka',
add_photo: 'Přidat fotku',
replace_photo: 'Vyměnit', replace_photo: 'Vyměnit',
remove_photo: 'Odebrat', remove_photo: 'Odebrat',
processing_photo: 'Zpracovávám fotku…', processing_photo: 'Zpracovávám fotku…',
@ -213,7 +214,7 @@ const cs: Messages = {
not_set: 'Nenastaveno', not_set: 'Nenastaveno',
change: 'Změnit', change: 'Změnit',
notifications: 'Oznámení', notifications: 'Oznámení',
notifications_hint: 'Dostanete oznámení, když skupinu změní někdo jiný.', notifications_hint: 'Upozornit mě, když skupinu změní ostatní',
notifications_ios: 'Na iPhonu a iPadu nejdřív přidejte OweMe na plochu (Sdílet → Přidat na plochu).', notifications_ios: 'Na iPhonu a iPadu nejdřív přidejte OweMe na plochu (Sdílet → Přidat na plochu).',
notifications_denied: 'Oznámení jsou pro tento web zablokovaná v nastavení prohlížeče.', notifications_denied: 'Oznámení jsou pro tento web zablokovaná v nastavení prohlížeče.',
notifications_unavailable: 'Oznámení nejsou na tomto serveru nebo v tomto prohlížeči k dispozici.', notifications_unavailable: 'Oznámení nejsou na tomto serveru nebo v tomto prohlížeči k dispozici.',
@ -225,11 +226,14 @@ const cs: Messages = {
export_expenses: 'Výdaje (CSV)', export_expenses: 'Výdaje (CSV)',
export_balances: 'Zůstatky (CSV)', export_balances: 'Zůstatky (CSV)',
backup: 'Soubor se zálohou', backup: 'Soubor se zálohou',
backup_hint: 'Obsahuje klíč skupiny: kdokoli se souborem skupinu otevře. Uložte ho bezpečně.', backup_hint: 'Záloha obsahuje klíč skupiny. Uložte ji bezpečně.',
danger_zone: 'Nebezpečná zóna', danger_zone: 'Nebezpečná zóna',
remove_from_device_hint: 'Skupina zůstane na serveru i v ostatních zařízeních.', remove_from_device_hint: 'Zůstane na serveru i v ostatních zařízeních.',
delete_group: 'Smazat skupinu pro všechny', delete_group: 'Smazat skupinu pro všechny',
delete_group_hint: 'Smaže ze serveru všechny výdaje a fotky. Pro potvrzení napište název skupiny.', delete_group_hint: 'Všem smaže všechny výdaje a fotky.',
type_name_to_confirm: 'Pro potvrzení napište název skupiny',
qr_code: 'QR kód',
group: 'Skupina',
confirm: 'Potvrdit', confirm: 'Potvrdit',
saved: 'Uloženo', saved: 'Uloženo',

View file

@ -47,7 +47,7 @@ const en = {
// share // share
share_group: 'Share group', share_group: 'Share group',
share_intro: 'Anyone with this link can see and edit the group. Send it only to group members.', share_intro: 'Anyone with the link can view and edit this group.',
save_link_warning: 'Save this link somewhere safe. If every copy is lost, the group can’t be recovered.', save_link_warning: 'Save this link somewhere safe. If every copy is lost, the group can’t be recovered.',
copy_link: 'Copy link', copy_link: 'Copy link',
copied: 'Copied', copied: 'Copied',
@ -68,6 +68,8 @@ const en = {
stats: 'Stats', stats: 'Stats',
activity: 'Activity', activity: 'Activity',
add_expense: 'Add expense', add_expense: 'Add expense',
pull_to_add: 'Pull up to add expense',
release_to_add: 'Release to add',
no_expenses: 'No expenses yet. Tap + to add the first one.', no_expenses: 'No expenses yet. Tap + to add the first one.',
total_spent: 'Total spent', total_spent: 'Total spent',
summary: 'Summary', summary: 'Summary',
@ -80,7 +82,7 @@ const en = {
payment_short: 'Payment', payment_short: 'Payment',
add_payment: 'Record a payment', add_payment: 'Record a payment',
paid_by: 'Paid by {name}', paid_by: 'Paid by {name}',
paid_by_many: 'Paid by {n} people', paid_by_many: { one: '{n} payer', few: '{n} payers', other: '{n} payers' },
your_share: 'your share {amount}', your_share: 'your share {amount}',
you_lent: 'you lent {amount}', you_lent: 'you lent {amount}',
you_borrowed: 'you borrowed {amount}', you_borrowed: 'you borrowed {amount}',
@ -115,7 +117,6 @@ const en = {
title_ph: 'Dinner', title_ph: 'Dinner',
category: 'Category', category: 'Category',
default_category: 'Default category', default_category: 'Default category',
default_category_hint: 'New expenses start in this category.',
date: 'Date', date: 'Date',
currency: 'Currency', currency: 'Currency',
rate: 'Exchange rate', rate: 'Exchange rate',
@ -126,7 +127,7 @@ const en = {
currencies_manual: 'Enter rate manually', currencies_manual: 'Enter rate manually',
rate_unavailable: 'No rate available for this currency, please enter it.', rate_unavailable: 'No rate available for this currency, please enter it.',
paid_by_label: 'Paid by', paid_by_label: 'Paid by',
multiple_payers: 'Several people paid', multiple_payers: 'Several people',
from_label: 'From', from_label: 'From',
to_label: 'To', to_label: 'To',
split: 'Split', split: 'Split',
@ -136,11 +137,11 @@ const en = {
split_percent: 'Percent', split_percent: 'Percent',
remaining: 'Remaining: {amount}', remaining: 'Remaining: {amount}',
over_by: 'Over by: {amount}', over_by: 'Over by: {amount}',
adds_up: 'Adds up to the total',
select_all: 'All', select_all: 'All',
select_none: 'None', select_none: 'None',
note: 'Note', note: 'Note',
photo: 'Photo', photo: 'Photo',
add_photo: 'Add photo',
replace_photo: 'Replace', replace_photo: 'Replace',
remove_photo: 'Remove', remove_photo: 'Remove',
processing_photo: 'Processing photo…', processing_photo: 'Processing photo…',
@ -225,7 +226,7 @@ const en = {
not_set: 'Not set', not_set: 'Not set',
change: 'Change', change: 'Change',
notifications: 'Notifications', notifications: 'Notifications',
notifications_hint: 'Get a notification when someone else changes this group.', notifications_hint: 'Notify me when others change the group',
notifications_ios: 'On iPhone and iPad, add OweMe to your home screen first (Share → Add to Home Screen).', notifications_ios: 'On iPhone and iPad, add OweMe to your home screen first (Share → Add to Home Screen).',
notifications_denied: 'Notifications are blocked for this site in your browser settings.', notifications_denied: 'Notifications are blocked for this site in your browser settings.',
notifications_unavailable: 'Notifications aren’t available on this server or in this browser.', notifications_unavailable: 'Notifications aren’t available on this server or in this browser.',
@ -237,11 +238,14 @@ const en = {
export_expenses: 'Expenses (CSV)', export_expenses: 'Expenses (CSV)',
export_balances: 'Balances (CSV)', export_balances: 'Balances (CSV)',
backup: 'Backup file', backup: 'Backup file',
backup_hint: 'Contains the group key: anyone with the file can open the group. Store it safely.', backup_hint: 'The backup file contains the group key. Store it safely.',
danger_zone: 'Danger zone', danger_zone: 'Danger zone',
remove_from_device_hint: 'The group stays on the server and on other devices.', remove_from_device_hint: 'Stays on the server and other devices.',
delete_group: 'Delete group for everyone', delete_group: 'Delete group for everyone',
delete_group_hint: 'Deletes all expenses and photos from the server. Type the group name to confirm.', delete_group_hint: 'Removes all expenses and photos for everyone.',
type_name_to_confirm: 'Type the group name to confirm',
qr_code: 'QR code',
group: 'Group',
confirm: 'Confirm', confirm: 'Confirm',
saved: 'Saved', saved: 'Saved',

View file

@ -143,3 +143,40 @@ test('two devices share a group end to end', async ({ browser }) => {
await expect(anna.getByRole('heading', { name: 'By category' })).toBeVisible(); await expect(anna.getByRole('heading', { name: 'By category' })).toBeVisible();
await expect(anna.getByRole('heading', { name: 'Paid vs. share' })).toBeVisible(); await expect(anna.getByRole('heading', { name: 'Paid vs. share' })).toBeVisible();
}); });
test('several people pay for one expense', async ({ browser }) => {
const p = await device(browser, 'en-US');
await p.goto('/');
await p.getByRole('link', { name: 'New group' }).click();
await p.getByLabel('Group name').fill('Shared car');
await p.getByLabel('Main currency').selectOption('CZK');
await p.getByLabel('Your name').fill('Anna');
await p.getByPlaceholder('Name').fill('Petr');
await p.getByRole('button', { name: 'Add member' }).click();
await p.getByPlaceholder('Name').nth(1).fill('Jana');
await p.getByRole('button', { name: 'Create group' }).click();
await p.getByRole('button', { name: 'Back', exact: true }).click();
await p.getByRole('link', { name: 'Add expense' }).click();
await p.getByLabel('Amount').fill('300000');
await p.getByLabel('What was it for?').fill('Car');
await p.getByLabel('Paid by', { exact: true }).selectOption({ label: 'Several people' });
await p.getByLabel('Paid by: Anna').fill('100000');
await p.getByLabel('Paid by: Petr').fill('150000');
await expect(p.getByText('Remaining: CZK 50,000.00')).toBeVisible();
// The empty box suggests what's left.
await expect(p.getByLabel('Paid by: Jana')).toHaveAttribute('placeholder', '50000.00');
await p.getByLabel('Paid by: Jana').fill('80000');
await expect(p.getByText('Over by: CZK 30,000.00')).toBeVisible();
await p.getByRole('button', { name: 'Save', exact: true }).click();
await expect(p.getByRole('alert')).toHaveText('The payers don’t add up to the amount.');
await p.getByLabel('Paid by: Jana').fill('50000');
await expect(p.getByText('Adds up to the total')).toBeVisible();
await p.getByRole('button', { name: 'Save', exact: true }).click();
await expect(p.getByRole('link', { name: /Car/ })).toContainText('3 payers');
await p.getByRole('link', { name: 'Balances' }).click();
await expect(p.getByText('+CZK 50,000.00')).toBeVisible();
await expect(p.getByText('−CZK 50,000.00')).toBeVisible();
await expect(p.getByText('Jana → Petr')).toBeVisible();
});

View file

@ -110,6 +110,31 @@ describe('replay', () => {
expect(Object.values(bal).reduce((x, y) => x + y)).toBe(0); expect(Object.values(bal).reduce((x, y) => x + y)).toBe(0);
}); });
it('credits each of several payers (three people buy a car together)', () => {
const car = expense({
amount: 30000000,
payers: [{ member: 'a', amount: 10000000 }, { member: 'b', amount: 15000000 }, { member: 'c', amount: 5000000 }],
});
const { state } = replay([...baseGroup(), ev({ type: 'expense.created', data: car })]);
const bal = balances(state);
expect(bal).toEqual({ a: 0, b: 5000000, c: -5000000 });
expect(settleUp(bal, ['a', 'b', 'c'])).toEqual([{ from: 'c', to: 'b', amount: 5000000 }]);
});
it('credits several payers in a foreign currency, summing exactly to the base total', () => {
// €100.01 at 25.1 = 2510.251 Kč → 2510.25; payer and share vectors must each sum to it.
const e = expense({
currency: 'EUR', amount: 10001, rate: '25.1',
payers: [{ member: 'a', amount: 5001 }, { member: 'b', amount: 5000 }],
});
const { state } = replay([...baseGroup(), ev({ type: 'expense.created', data: e })]);
const bal = balances(state);
expect(Object.values(bal).reduce((x, y) => x + y)).toBe(0);
expect(bal.a).toBeGreaterThan(0);
expect(bal.b).toBeGreaterThan(0);
expect(bal.c).toBeLessThan(0);
});
it('ignores invalid expenses (bad sums, unknown members)', () => { it('ignores invalid expenses (bad sums, unknown members)', () => {
const bad1 = expense({ id: 'x2', payers: [{ member: 'a', amount: 1 }] }); const bad1 = expense({ id: 'x2', payers: [{ member: 'a', amount: 1 }] });
const bad2 = expense({ id: 'x3', split: { mode: 'equal', entries: [{ member: 'zzz', value: 1 }] } }); const bad2 = expense({ id: 'x3', split: { mode: 'equal', entries: [{ member: 'zzz', value: 1 }] } });