RevRec brainstorm · Supporting · Use cases & flows

10 — End use cases & operational flows

Status: draft Audience: onboarding engineers/PM/finance — read this to understand what the product does for a user, end to end Stance: Product outcome first. Chargebee/Hotglue are just where data enters; the deliverable is a correct, auditable ASC 606 subledger the finance team can close and report on.

Read with: 00-product.md (why) · 11-rules-reference.md (the rules) · 03-event-catalog.md (source→event) · 04-engine-scenarios.md (numbers)


1. Who uses it (personas)

Persona Cares about Primary jobs-to-be-done
Revenue accountant Correct recognition, deferred, schedules Review contracts/POs, run recognition, explain a number
Controller / close manager A fast, clean, locked close Pre-close checks, recognize, post journals, lock period
Auditor (internal/external) Traceability + policy consistency Drill any GL number → source fact; verify policy applied
RevOps / FP&A analyst ARR/NRR, deferred waterfall, RPO Reporting, forecasting, cohort analysis
Integration/admin owner Data flowing + configured right Connect source, set policies/SSP, watch sync health
Engineer/support Determinism + replay Diagnose an event, replay, fix a mapping/policy

The product’s job: let the accountant and controller trust the numbers without touching spreadsheets.


2. Use-case catalog

Each use case maps to a domain operation (see 03/08) and a customer outcome.

ID Use case Persona Domain op(s) Outcome
UC1 Onboard a merchant + backfill history Admin extract → normalize → open/amend/bill/pay/credit Opening subledger that matches prior books
UC2 New subscription becomes a contract (automatic) open_contract PO + schedule exists, deferred/unbilled correct
UC3 Invoice/payment recorded (automatic) record_billing / record_payment AR + deferred move; recognition untouched
UC4 Mid-term upgrade/downgrade (automatic) amend_contract Remaining schedule reflows per policy
UC5 Credit note issued (automatic) record_credit Deferred/recognized adjusted per named policy
UC6 Cancellation (automatic) terminate Remaining schedule resolved per policy
UC7 Run a period close Controller recognize(period) Revenue booked, deferred waterfall produced
UC8 Post journals to GL Controller post_journals(period) Summarized Dr/Cr export; detail stays in subledger
UC9 Lock a period Controller period lock No further mutation of a closed period
UC10 Explain / audit a number Auditor drill-down read GL → journal → schedule → PO → contract → event → raw
UC11 Deferred waterfall & ARR/NRR Analyst reporting reads Board/forecast metrics from the subledger
UC12 Remaining performance obligations (RPO) Analyst/Auditor reporting reads ASC 606-10-50 disclosure
UC13 Correct a mistake (mapping/policy/late fact) Engineer/Accountant replay / re-apply / restate Deterministic fix with audit trail
UC14 AR / cash view (Accounting Premium) Accountant AR projector Invoices, payments, CNs, aging on same facts

Anti–use-cases (the user should never have to): reconstruct a contract from invoices in a spreadsheet, hand-join invoices to terms, chase which of 3 stores is "true", or re-run a whole org to fix one contract.


3. Full flow F1 — Onboarding & backfill

Goal: stand up a tenant so its subledger equals (or is reconciled to) prior books.

Connect source (Chargebee creds)
  → Extract BULK window (all history)         [Temporal backfill]
  → Raw lake (immutable payloads)
  → Configure policies + SSP + calendar        [admin, see doc 11]
  → Normalize → domain events (ordered per contract)
  → Apply: open_contract / bill / pay / credit / amend  (idempotent)
  → Opening balances: deferred, AR, unbilled, revenue-to-date
  → Validate: shadow-compare vs prior system (accounting equality, not sheet equality)
  → Sign off opening balances → go live to incremental sync

Decisions to lock before go-live (per tenant): recognition calendar (daily vs monthly), functional currency, CN policy mapping, cancellation policy, SSP source. See 11-rules-reference.md.

Done when: opening deferred + revenue-to-date reconcile to prior books within tolerance, and an auditor can trace a sample contract end to end.


4. Full flow F2 — Steady-state sync (the apply loop)

Continuous, automatic, no user action.

Chargebee changes
  → Extract INCREMENTAL (cursor by updated_at / resource_version)   [Temporal schedule]
  → Raw lake append
  → Normalize → events   (subscription_created/changed/cancelled, invoice, payment, credit_note)
  → Apply (idempotent, ordered per subscription):
        subscription_created → open_contract
        subscription_changed → amend_contract
        invoice_generated    → record_billing
        payment_succeeded    → record_payment
        credit_note_created  → record_credit
        subscription_cancelled → terminate
  → Ops DB updated; AppliedEvent recorded

Properties (from 09): idempotent on (tenant, source, event_id); parallel by tenant/subscription; no full-history reload to understand current state; policies are config.

User visibility: sync health (lag, failures by entity), and any events parked as exceptions (unmapped policy, missing link) for review — see F7.


5. Full flow F3 — Monthly (or daily) close cycle

The controller’s core ritual. Period moves through explicit states.

Period state machine:
  OPEN ──pre-close──► READY ──recognize──► RECOGNIZED ──post──► POSTED ──lock──► LOCKED
                                   ▲                                  │
                                   └───────── reopen (pre-lock) ──────┘
Step What happens Guardrail
1. Pre-close checks All source events for period applied; no unresolved exceptions; FX rates loaded Block close if extract lag or parked events
2. recognize(period) Sum open schedule lines due in period → revenue; deferred ↓ Idempotent while unlocked
3. Deferred waterfall Snapshot deferred rollforward (open + additions − recognized − adjustments = close) Must tie out
4. Review Accountant reviews flux vs prior period, large contracts, new/cancelled Drill-down available (F5)
5. post_journals(period) Summarized Dr/Cr batch to GL export Detail stays in subledger
6. Lock Period frozen; later facts for that period go to next open period as catch-up/adjustment Reopen only pre-lock or via controlled restatement

Outcome: revenue + deferred + journals for the period, reconciled and auditable. This replaces "Camunda sync job finished loading Excel" with a real close workflow.


6. Full flow F4 — Mid-period change handling

Shows how UC4/UC5/UC6 travel through apply and surface in close. (Numbers: 04 S03/S04/S05.)

Change fact (upgrade / credit / cancel)
  → event → apply with NAMED POLICY (doc 11)
  → ops DB: remaining schedule reflows
        upgrade prospective : Jan–Jun untouched; Jul–Dec new amount
        CN refund_unrecog   : deferred ↓; recognized untouched
        cancel term.cancel  : remaining deferred resolved per policy
  → next recognize(period) uses the new schedule
  → audit trail links the change event → schedule delta

Key rule: past locked periods are never silently restated. A change effective in a closed period follows the modification/restatement rule in 11, not an in-place rewrite.


7. Full flow F5 — Audit & drill-down

The traceability chain that makes the product auditable (UC10).

GL journal line (period)
   ▼  post_journals
Subledger balance (revenue / deferred / AR)
   ▼
RecognitionScheduleLine (period, amount, status)
   ▼
PerformanceObligation (method, service window, allocated amount)
   ▼
Contract (customer, term, source_ref)
   ▼
AppliedEvent (type, policy applied, source_event_id)
   ▼
Raw payload in lake (verbatim Chargebee fact)

Every arrow is a stored link, not a re-computation. An auditor can pick any number and walk down to the original Chargebee JSON, and see which policy produced each treatment.


8. Full flow F6 — Reporting & disclosures

Served from projections (ClickHouse/analytics) off the subledger — reads never mutate state.

Report Question Source
Deferred waterfall / rollforward How did deferred move this period? schedule lines + adjustments
Revenue by contract/product/period Where is revenue coming from? recognition entries
ARR / MRR / NRR Growth + retention active POs / schedules
RPO (remaining performance obligations) Contracted-but-unrecognized (ASC 606-10-50-13) open schedule totals
Unbilled / contract asset & liability Balance-sheet presentation recognized vs billed
AR aging (Accounting Premium) Collections AR projector

9. Full flow F7 — Exceptions & corrections

What happens when reality is messy (UC13).

Situation Handling Principle
Event has no mapped policy (e.g. unknown CN reason) Park as exception, notify admin, apply after mapping Never guess silently
Out-of-order / late fact (pre-lock period) Re-apply; recompute remaining schedule Idempotent apply makes this safe
Late fact for locked period Route to next open period as catch-up/adjustment per policy No silent restatement
Bad mapping/policy discovered Fix config → replay affected events from lake Deterministic rebuild
Data correction in Chargebee New event supersedes; audit keeps both Raw lake is immutable history
Full projection rebuild Rebuild ClickHouse/read models from ops/events Analytics are disposable

Corrections are replay + policy, not manual spreadsheet edits. This is the payoff of event-sourced apply.


10. Use case → operation → entity quick map

Use case Operation Touches entities
UC2 new contract open_contract Contract, PO, RecognitionScheduleLine
UC3 billing/payment record_billing / record_payment BillingDocument, BillingLine, CashApplication
UC4 amend amend_contract PO, RecognitionScheduleLine
UC5 credit record_credit BillingDocument(credit), schedule adj
UC6 cancel terminate PO, RecognitionScheduleLine
UC7 recognize recognize(period) RecognitionScheduleLine, revenue/deferred balances
UC8 journals post_journals(period) JournalBatch
UC10 audit reads all + AppliedEvent + raw lake

Entity definitions: 08-mvp-spec.md §3.


11. Today vs Next (user-visible)

User action Today (revanu + Hotglue) RevRec Next
Onboard Configure tap + Hotglue + sheets Connect source + set policies; backfill
Close Sync job loads Excel → warehouse processing recognize(period) workflow + waterfall
Explain a number Open spreadsheets / warehouse queries Drill GL → … → raw payload
Fix a mistake Re-run org job; snapshot archaeology Fix policy → replay events
Report MSTR API + analytics projections

12. Open questions (track in decisions/)

  1. Recognition calendar default: daily vs monthly (affects proration + schedule granularity).
  2. Balance-sheet presentation: contract asset/liability labels required at MVP?
  3. Restatement policy for facts landing in a locked period (catch-up vs prior-period adjustment).
  4. RPO/disclosure scope for v1 (which ASC 606-10-50 disclosures are in scope).
  5. Close cadence per tenant (monthly standard; any daily/continuous close demand?).