Envelope ledger: how the money side works
Event hosts who want to see whether hosting is making or losing money, and anyone auditing the books
Last updated 7 November 2026
What this is
Running events costs real money. Wines come out of your cellar, you pay for food up front, convives pay you back over weeks - sometimes in advance, sometimes after. A single "bank balance" number hides all of that. The envelope ledger splits it into four numbers that each tell a different part of the story, plus an append-only transaction log that explains how each number got to where it is.
This guide is for hosts (today, just me - but the feature is built to scale). If you just want to see whether last month's events were profitable, skip to The four numbers. If you're about to record a transaction and want to know you're doing it right, skip to Transaction kinds.
The four numbers
Every host has four numbers that together describe their position in the hobby at any point in time.
- Cash. Money you're actually holding - in your bank, in your pocket - that came from envelope activity. Grows when a convive hands you money (top-up or post-event payment). Shrinks when you pay for wine, food, or shared expenses up front.
- Cellar. What the bottles currently sitting in your cellar cost. Each bottle counts at what its purchase took from Cash, with any price correction since, on the day it was bought, so buying a bottle moves Cash and Cellar by the same amount and leaves equity alone. A wine bought on discount in November and again at full price in March contributes two different numbers, and neither moves when the exchange rate does. A bottle with no recorded purchase counts at its price; one nobody priced counts at nothing. Drops when a bottle is consumed at an event or drunk at home.
- Receivables. What convives collectively owe you (or you owe them). This is a net number with two sides broken out:
- Owed to host - sum of convives whose balance is negative (they owe you).
- Owed by host - sum of convives whose balance is positive (you're holding credit for them - money they topped up but haven't consumed yet).
- Wine-run reimbursements are deliberately not in here. Those are personal-channel charges (cash or card only, never the gateway) and are kept out of the envelope entirely, so they never touch this number or the invariant below.
- Capital. Lifetime sunk cost in the hobby - how much of your own money has been put in. Grows with explicit capital injections and gifts received; doesn't move when events happen.
On top of these, two derived numbers:
- Net equity = cash + cellar + owed-to-host - owed-by-host. "What's my position worth right now?"
- Lifetime P&L = net equity - capital. "Has this been worth it?" Positive means hosting has paid back more than you've put in; negative is the normal state for a wine enthusiast.
Why cash and receivables aren't the same as profit
The thing to understand, once, before any of this makes sense: events move equity, not cash.
When a convive who's topped up attends a 3000 UAH event:
- They paid you three months ago. Cash moved then, not tonight.
- Tonight's settlement reduces their credit by 3000. Receivables.owed-by-host drops 3000.
- The wine drunk - say 1000 UAH cost basis - leaves your cellar.
- Equity moved by +3000 (liability reduced) - 1000 (cellar drained) = +2000 profit.
- Cash didn't move at all.
So a thriving events cash pile isn't what tells you hosting is profitable - lifetime P&L does. The gap between cash and receivables.net grows with every profitable event and shrinks with every unprofitable one.
At the moment the ledger was set up (2026-04-24), by design, cash == receivables.net exactly. We defined opening cash as "the amount convives have collectively prepaid" and opening capital as "the cellar value at reset." From that starting point, every event either widens or narrows that gap, and the cumulative widening is your profit.
The transaction log
Every cash or capital movement is a row in host_transactions. Rows are append-only: a database trigger blocks UPDATE on the financial fields (amount, kind, entity links, occurred_at) after insert. If a row is wrong, you don't edit it - you post a compensating row with kind = adjustment that points at the original via corrects_transaction_id. Both rows stay visible forever; the correction is linked, not hidden. Rows are written only by the server on your behalf (the recorders on these pages, settlement, the cellar); the database accepts no row written directly by a member, and a payment can only be recorded against an event you host. Only a member who keeps the envelope (through their tier or a grant) records in it, and only in their own; a top-up or an event payment, which also lands on a member's balance, takes hosting too. An admin records for any host.
Why this matters: when you're looking at a balance that seems wrong six months from now, you want to see both the wrong entry and the fix. Traditional "edit the bad row" workflows throw away that audit trail. Envelope keeps it.
The trigger does leave the description and the metadata alone, so a typo in a description can be repaired without ceremony, but that repair is ours to make rather than yours: no page offers the edit, and the database no longer accepts one from a host directly. Settlement keeps its own bookkeeping in metadata (which batch a row belongs to), and undoing a settlement looks the rows up by it, so a row whose metadata moved underneath it would be undone wrongly.
One thing does move a row's links: merging duplicates. When an admin folds a duplicate wine into the canonical one, your rows that pointed at the duplicate point at the canonical wine afterwards. When two member records turn out to be the same person, the duplicate's rows (as the host, or as the convive a row is about) move to the record that stays. The money side stays exactly as recorded (amount, kind, dates); there are just no longer two names for one wine or one person. Nothing else can repoint a row.
Transaction kinds
Use the right kind. The projection library routes each kind to the right number (or numbers) automatically.
| Kind | When | Moves cash? | Moves capital? |
|---|---|---|---|
top_up | Convive hands you money to pre-fund future events | +cash | - |
event_payment_in | Convive pays for a specific event (usually after settlement) | +cash | - |
wine_purchase | You buy a bottle for the cellar | -cash | - |
event_expense_paid | You paid food/water/service for an event up front | -cash | - |
capital_inject | You put personal money into the hobby pot (top-up of your own side) | +cash | +capital |
capital_withdraw | You take personal money back out (rare) | -cash | -capital |
external_sale | You sold a bottle outside the platform | +cash | - |
gift_in | You received a bottle as a gift | - | +capital |
gift_out | You gave a bottle away | - | -capital |
wine_consumed_personal | You drank a bottle at home | - | - |
opening_balance | One-time seed row at ledger setup; metadata.axis routes to cash or capital | depends | depends |
adjustment | Compensating correction to an earlier row; metadata.axis tells the projection which number it corrects | depends | depends |
Two kinds - top_up and event_payment_in - are paired writes. They always create two rows atomically: one in convive_ledger (so the convive sees their balance update) and one in host_transactions (so your cash updates). A Postgres function handles the atomicity - if either row fails, neither lands.
The dashboard, and its siblings
/profile/host/envelope is the main view. The figures are summed by the API server, in your own currency, each row at the exchange rate of its own day; an amount whose day the banks haven't published rates for yet is left out and the page says how many are waiting. If the server can't be reached, the page says the figures can't be read right now: the books are kept on the server, and the site keeps no sums of its own. Four stat cards up top (cash, cellar, receivables, capital); below them the bigger numbers - net equity and lifetime P&L - with the invariant status indicator; then receivables broken out into owed-to-you and owed-by-you; then an append-only activity log, the newest 100 rows first and Show older for the rest. Corrections appear inline with a "↪ corrects #N" link, so a wrong row and its fix always show together. Rows you recorded this week but dated more than a week back are listed above the log; clicking one brings in the older pages down to it.
The log is ordered by when things happened, not by when you typed them in, so a backdated entry (say, a receipt from months ago added to the cellar today) lands deep in the list rather than on top. Those entries are not lost: a "Recorded recently" strip above the log lists anything added in the last week that is dated more than a week further back, and clicking one jumps to its place in the timeline. The row itself also carries a small "recorded N days ago" note while it is fresh.
The invariant indicator reads "holds exactly" right after setup. Once you settle an event, it starts showing a delta. That delta is good - it's the accumulated event margin showing up exactly where it should.
Just under the invariant, when you have open wine runs, a one-line heads-up shows how much wine you've planned to buy and what's left of Available after it - going negative ("more than you have free right now") if you've committed past your surplus. It deliberately stays out of the figures and the invariant: it's a forward reminder drawn from your runs (lines you're buying for others are excluded, since the buyer pays you back), not money that has moved. Manage the runs on Wine runs.
Two siblings share the same underlying data from different angles:
/profile/host/finance- long-running analytics: monthly P&L (event charges plus outside sales), revenue per event, cumulative cash flow, project expenses, cellar value over time. Wine capital splits recovery into event-cost and outside-sales channels so net wine investment lines up with cellar value. A "Wine spend" section adds the forward view: what your open wine runs commit you to (total, this month, this quarter) charted as a dashed band next to the wine you have actually bought. A correction counts as the row it corrects, on its own day: a sale you took back nets to nothing, and a purchase you repriced or removed counts at what it came to. Use it to answer "how has hosting been going over the last year" and "what am I about to spend on wine."/profile/host/receivables- per-convive balance detail, the place to edit an individual row. Use it when a convive has a question about their balance or you need to correct one specific entry. The balances and totals cover every row; the table shows the rows the window (last 90 days, last year, all time), person and type filters keep, 100 at a time with show more. The filters are in the page's address, so a filtered view can be bookmarked or shared with yourself. A row a payment landed in your envelope through is locked: its amount and type don't change and it can't be deleted, so the envelope and the balance can't come apart; put it right with a correction in the envelope.- The Ledger tab on
/eventsshows who owes you what and the totals per currency, by full name; every entry is on Receivables.
Envelope is the now view (with the audit trail). Finance is the trends view. Ledger is the rows view.
Planning vs execution
Adding wines, shared expenses, or personal orders to an event is planning, not spending. The event manager is a sandbox - you draft a menu, rough-cost a ticket price, remove a placeholder expense, add the real one. No cash moves until the event settles. That's the whole point of settlement: it's the moment you commit to the event's financial reality.
The only cellar-touching action that moves money mid-planning is buying a bottle - because that bottle is real, paid for, sitting somewhere. That's execution, not planning.
Common flows
You buy wine for the cellar. Add the bottle via /profile/cellar. Cash drops by what you paid (converted to UAH at the purchase-date rate if the bottle is in another currency); cellar grows by the bottle's cost basis. Equity unchanged - asset reshuffled. Automatic - no separate envelope entry needed.
You update a bottle's price. If you change the price on an existing bottle, a compensating adjustment lands automatically, pointing at the original wine_purchase row. The API server makes both changes in one transaction, so the bottle and the envelope cannot disagree: either the new price and its correction are both written, or neither is. The one case that waits is a purchase day whose exchange rates have not arrived yet; the bottle keeps the new price and the hourly worth job writes its dollar value and the correction together, once the rates are in.
You remove a bottle. A reversal adjustment is posted; cash returns to pre-purchase level.
Pre-settlement: planning the event. Add/edit/remove shared expenses and personal orders as much as you want. Nothing hits the envelope. Use placeholders to plan ticket price, swap them for real expenses when the event actually happens.
Event settles. confirmSettlement does two things atomically:
- Creates
convive_ledgercharge rows for every attendee (with pays_for redistribution applied) - Emits
event_expense_paidhost_transactions rows for every shared expense and personal order on the event (tagged with the settlement_batch)
Cash drops by the total event cost. Receivables move as charges land. Net equity shifts by the event margin.
If the event's price or collection mode is changed while the settlement is being made, settling refuses and writes nothing: look at the new figures and settle again. Once settled, the event stays as it was settled: shared expenses, personal orders, fees, extra-wine shares, pays-for links and the guest list can't be changed, and the event can't be moved to another state, until the settlement is undone. The admin CLI keeps the same rules.
Event unsettles. undoSettlement emits compensating adjustment rows (pointing at each of the settlement's expense rows), then deletes the convive_ledger charges. Both original + reversal rows stay in the host_transactions log; the audit trail is intact. Blocked if the host has recorded any event_payment_in rows for the event - real cash received can't be walked back by deleting charges.
Your currency. Your books are kept in one currency, hryvnias unless you pick another under Account → Currency. The envelope's figures are summed in it, each amount in another currency converted at a dated rate, and a new event you create is in it from the start, priced or not. Changing it doesn't move an event made before, or touch what anyone owes you: a balance stays in the currency it was agreed in.
Balances are per currency. Owing you 50 euros and 300 hryvnias is two balances, each settled in what was agreed, and every view of them keeps them apart: a member's ledger, your ledger and the receivables board show a line per currency. An event is settled in the currency it is priced in, hryvnias when it names none: its charges are in it, only the credit a member holds in that currency pays toward them, and the evening's expenses go into the envelope in it too. A top-up, an event payment or a hand-written ledger entry lands in the currency you record it in: a member who pays 50 euros toward a euro charge clears it, and the receivables board's Record button fills in the currency of the line it was pressed on. Any currency the banks publish a rate for is taken (the hryvnia, the euro, the dollar and about forty more); a code nobody publishes a rate for is refused, since it could never be counted in your own currency. The envelope converts every amount into your own currency at a dated rate, so the same rows give the same figure whenever they are read. A top-up through the payment gateway pays hryvnias to Barberry Garden, so the settlement notice offers one only for a hryvnia charge of Barberry Garden's. The finance board's analytics are hryvnia figures for now, and the page says how many entries and events in another currency it leaves out (the bottles poured at such an event count as drunk at home); the envelope itself sums everything in your own currency.
Charity / payment-link events never enter the envelope. An event whose collection mode is set to payment link (event settings on the manage page) settles completely outside the money system: participants pay through an external link (say, a monobank charity jar), so confirmSettlement writes no convive_ledger charges and emits no event_expense_paid rows. Balances stay untouched, the acquiring gateway is never involved, and none of the four envelope numbers move. The per-person amounts are snapshotted on the event itself, and the host ticks people off by hand as transfers land in the jar. Bottles you pour at such an event are donations - their cost never shows up as an event expense. Undo for these events is just a state flip, blocked while anyone is still marked as paid. Once an event is settled, its collection mode and price stay as they are until the settlement is undone: the settlement was computed from them, and undo takes back what the settlement actually wrote (charges and expense rows, or the per-person snapshot), not what the event says today.
A convive tops up. Record via /profile/host/receivables → Record payment (envelope-routed automatically) or /profile/host/envelope → Record → Top-up. Either way the paired convive_ledger + host_transactions rows land atomically.
A convive pays after the event. Same routing. Via /profile/host/receivables if the payment is event-linked via the entry metadata; otherwise via /profile/host/envelope → Record → Event payment.
You notice a wrong amount. Don't edit the old row - it's immutable. Record a Correction on the envelope page with a signed delta, picking the row it corrects and whether it fixes cash or capital. It is in the corrected row's currency (the form fills it in, and a correction in another currency is refused). Both rows stay; the fix is linked via corrects_transaction_id.
What the recorder checks. A wine purchase is for a bottle of your own cellar, which you find by typing a word of its wine, producer or vintage (the latest added show first); an event expense for an event you host, a correction for a row of your own envelope; anything else is refused with the reason. Every row is in a currency the banks publish a rate for. A top-up puts money on a member's balance, so it takes hosting as well as an envelope.
A project expense (hosting, glasses, a subscription) is added and removed on the finance page. For a host who keeps an envelope its cash out lands there in the same step, and removing the expense reverses that row in the same step, so the two never come apart.
Observability
The integrity script verifies the whole thing:
bun run scripts/verify-ledger-integrity.ts
Checks that paired rows actually match, adjustments point at real rows, opening invariant still holds, projections compute consistently, no NULL host_id rows. Green output means the books are internally consistent.
For a quick "what do the four numbers say right now":
bun run scripts/verify-host-envelope.ts
Both are read-only and safe to run anytime.
When the numbers don't match
If the integrity script flags drift, read the output carefully - it names the specific row or condition. The usual causes:
- Paired row missing - someone wrote to
convive_ledgerwithout the matchinghost_transactionsrow. Fix: figure out what real-world event happened, emit the missing side as anadjustment. - Adjustment without axis - a row was inserted directly (not via a builder) without
metadata.axis. The projection silently ignores it. Fix: emit a second adjustment with the right axis that nets out the first. - Cash = receivables invariant broken by more than event margins - something else moved either cash or receivables without moving the other. Most commonly, an admin-manual
convive_ledgerentry that should have been a real payment. Fix: reconcile withadjustmentrows on the cash side.
The goal isn't for every number to look clean forever - real money gets messy. The goal is that every mess is traceable to specific rows, and every fix is another row on top.