Skip to content

docs: financial architecture simplification audit - #241

Merged
spizeck merged 3 commits into
mainfrom
docs/financial-architecture-audit
Oct 18, 2026
Merged

spizeck merged 3 commits into
mainfrom
docs/financial-architecture-audit

Conversation

@spizeck

@spizeck spizeck commented Oct 17, 2026 •

Copy link
Copy Markdown
Owner

Summary

Read-only audit of the Stripe / QuickBooks Online / Ollie POS payment, payout, and reconciliation infrastructure. No code changes — this adds one document:

  • docs/architecture/financial-simplification-audit.md

Closes nothing directly; tracked under #240.

Changes

  • Architecture diagram + per-flow traces (DDB card payment, Ollie POS transaction, Stripe payout, recon report)
  • Full inventory of custom infrastructure (~15.4k lib lines, ~15.8k test lines, ~4.1k admin UI)
  • Findings F1–F8 with code evidence — chiefly: the payout execution layer (decisions/executor/apply/automatic mode/cutover machinery) is a dormant write path production has never armed
  • Native alternatives evaluated (Stripe Connector by QBO — blocked by the shared account; QBO bank feed matching; Ollie's own integration; Stripe payout reports)
  • Keep/Simplify/Replace/Remove/Defer matrix + prioritized remediation sequence (P0–P5)
  • Correctness safeguards to preserve + owner/accountant decision list

Verification

  • npm run check:md-links — all links resolve
  • Docs-only change; no code paths touched. tsc/lint/test unaffected (CI will confirm).

Risk / deployment notes

None — documentation only. No env, rules, or behavior changes. Do not merge until the owner reviews findings and the #240 decision list.

Generated with Devin

Summary by Sourcery

Document the financial architecture audit and define a gated path to commission automated payout accounting while identifying dead and duplicative infrastructure for later simplification.

Enhancements:

  • Add a comprehensive audit of the Stripe, QuickBooks Online, Ollie POS, payout-accounting, and reconciliation architecture, including findings, native alternatives, simplification opportunities, and commissioning guidance for automated payout accounting.

Documentation:

  • Document the current financial flows, custom infrastructure inventory, correctness safeguards, recommended keep/simplify/remove decisions, activation sequence, and owner/accountant decisions required before enabling automation.

Summary by CodeRabbit

  • Documentation
    • Added an audit of financial flows, accounting synchronization, Stripe payouts, reconciliation, and operational infrastructure.
    • Documented the current status of payment and payout processes, along with accounting decisions, safeguards, and exception handling relevant to payout automation.
    • Recorded deferred simplification items, including reconciliation consolidation and removal of historical infrastructure.

Audit of the Stripe/QBO/Ollie payment and reconciliation stack:
inventory, flow traces, overengineering findings, native alternatives,
and a keep/simplify/replace/remove plan. Investigation only — no code
or accounting behavior changes.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@sourcery-ai

sourcery-ai Bot commented Oct 17, 2026

Copy link
Copy Markdown

Sorry @spizeck, this account has used its review budget of 1,500,000 diff characters for the last 7 days.

You can request another review in 1 hour and 59 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@vercel

vercel Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
deepdivebrewing-web Ready Ready Preview Oct 17, 2026 11:56pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 244ba3a0-4ac6-46e0-945d-66a91595aec3
📥 Commits

Reviewing files that changed from the base of the PR and between 444eff8 and ac242ac.

📒 Files selected for processing: 1
  • docs/architecture/financial-simplification-audit.md
+------------------------------------------+
| Duck and cover! I'm reviewing your code. |
+------------------------------------------+
  \
   \     /)/)
        ( '')
        /  |
      o(___)
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai

sourcery-ai Bot commented Oct 17, 2026

Copy link
Copy Markdown

Reviewer's Guide

This documentation-only PR audits the financial architecture and recommends retaining payment settlement, QBO Sales Receipt sync, and observe-mode payout reporting while retiring the dormant payout execution path and simplifying related reconciliation and matching infrastructure after owner/accountant review.

Sequence diagram for the live DDB payment settlement path

sequenceDiagram
    actor Staff
    participant PaymentsAdmin as payments-admin.ts
    participant Stripe
    participant Webhook as Stripe webhook
    participant Firestore
    participant QBO

    Staff->>PaymentsAdmin: createAdminPayment
    PaymentsAdmin->>Firestore: Create payment and event
    PaymentsAdmin->>Stripe: Create Checkout Session
    Stripe-->>Webhook: checkout.session.completed
    Webhook->>Stripe: Canonical session re-fetch
    Webhook->>Firestore: Dedupe, settle payment, enqueue qboSyncRecords
    Webhook->>QBO: postPaidPaymentToQbo
    QBO-->>Webhook: SalesReceipt result
    Webhook->>Firestore: Record sync status
Loading

Sequence diagram for observe-only Stripe payout analysis

sequenceDiagram
    participant Stripe
    participant Webhook as Stripe webhook
    participant Ledger as processStripePayoutLedger
    participant QBO
    participant Firestore
    actor Accountant

    Stripe-->>Webhook: payout.*
    Webhook->>Stripe: Canonical payout fetch
    Webhook->>Firestore: Record stripePayouts/{id}
    Webhook->>Ledger: processStripePayoutLedger
    Ledger->>Stripe: Fetch balance transactions
    Ledger->>QBO: Scan Undeposited Funds payments
    Ledger->>Firestore: Persist accounting proposals and exceptions
    Accountant->>Firestore: Review read-only payout worklist
Loading

Flow diagram for the proposed simplified financial architecture

flowchart TD
    Payment[DDB payment] --> Receipt[QBO Sales Receipt sync]
    OllieTxn[Ollie transaction] --> UF[QBO Undeposited Funds]
    Payout[Stripe payout] --> Report[Observe-only ledger and exception report]
    Receipt --> QBO[QuickBooks Online]
    UF --> Close[Human monthly close]
    Report --> Close
    Close --> QBO
    Executor[Dormant payout executor] -.->|Retire| Removed[No app-executed payout writes]
    Removed --> Close
Loading

File-Level Changes

Change Details Files
Adds a read-only architecture audit of the Stripe, QuickBooks Online, Ollie POS, payout, and reconciliation flows.
  • Documents current payment, payout, and reconciliation data flows with diagrams and per-flow traces.
  • Inventories financial infrastructure, tests, UI, collections, and environment configuration.
  • Separates production-critical payment/QBO sync components from dormant or disproportionate payout-accounting machinery.
  • Records findings F1–F8, including the unarmed payout execution path, automatic mode, matching complexity, duplicate reconciliation surfaces, and unused QBO webhook storage.
  • Evaluates native alternatives and the accounting implications of the shared Stripe account and Ollie’s Undeposited Funds model.
  • Defines keep/simplify/remove/defer recommendations, P0–P5 remediation steps, estimated reduction, safeguards, and owner/accountant decisions.
docs/architecture/financial-simplification-audit.md

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

The owner clarified that automatic Stripe payout accounting is a
mandatory business requirement, so the original "retire the dormant
executor / manual monthly journals" recommendation is rescinded.
Sections 6-12 are revised to a commissioning plan: keep and validate the
proposal/executor machinery through an approval-mode pilot, enable
automatic mode on a cutover boundary, and simplify only what weakens
nothing (QBO webhook dead path, recon consolidation after activation).

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Exec summary, F1/F3/F4 verdicts, the bank-feed alternative, and the Ollie
UF-vs-clearing section still argued for manual posting as the target.
Reframe them under the mandatory-automation requirement: the executor and
verified-tier matching are load-bearing safety controls, bank-feed match
is the exception fallback, and UF-native is an accountant decision that
would be new build rather than simplification.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@spizeck
spizeck marked this pull request as ready for review October 18, 2026 01:11
@sourcery-ai

sourcery-ai Bot commented Oct 18, 2026

Copy link
Copy Markdown

Sorry @spizeck, this account has used its review budget of 1,500,000 diff characters for the last 7 days.

You can request another review in 1 day and 14 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-10-18T01:12:49.793310Z ac242ac Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@spizeck
spizeck merged commit 37f7b91 into main Oct 18, 2026
4 of 5 checks passed
@spizeck
spizeck deleted the docs/financial-architecture-audit branch October 18, 2026 01:15

This branch was successfully deployed

1 active deployment
Preview — ac242ac8 Deployed Oct 17, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant