# Afton Electric QBO Cleanup — Canonical State
**Last updated:** 2026-05-22 evening session
**Pilot client:** Afton Electric, LLC (Sole Proprietor, QBO Advanced, Realm via "afton" client slug)

This is the canonical state file. Update it (don't append) when something changes.

---

## TL;DR

| Problem area | $ impact | State | Next action owner |
|---|---|---|---|
| Customer master data (null names, dups) | — | 58/61 nulls fixed; 3 failed (Amy Turner, Nelle, Afton LLC); 24 phone-in-name + 15 merge pairs pending | Jimmie (UI merges) + Ledger (3 failed) |
| 11 Track A unapplied payments | $5,935 | **DONE 2026-05-22 PM** — all 11 payments applied to recovery invoices, verified UnappliedAmt=0 across the board | n/a |
| Duplicate invoice/payment pairs (35 total) | $22,063 phantom revenue across 35 pairs | **DONE 2026-05-22 PM** — JE 27061 executed via worker. UF −$21,688.24, RBFCU −$375 (Amy Erwin), Income −$22,063 in current period | n/a |
| Undeposited Funds mess | $60,566 (down from $285K) | **DONE 2026-05-23** — proportional Income-routed JE 27062 cleared 156 of 179 no-method entries ($203K); 23 heavily-backdated entries held for separate review | Ledger (held 23) |
| 2024 over-cleanup PPA correction | -$114,939 reversal | **DONE 2026-05-23** — JE 27064 Dr Retained Earnings / Cr Income (proportional) restored 2026 P&L to in-scope only ($110K cleanup vs original $225K). 2024 books unchanged. | n/a |
| Worker double-fire (Sheets 429) | infra bug | **CONFIRMED reproducible 2026-05-23** — JE 27062+27063 (1s apart), JE 27064+27065 (19s apart). Both duplicates DELETED via direct API. **Workaround pattern: always check QBO for duplicate JE immediately after worker fires.** | Riv (Pri #10) |
| **Mystery $800K "forced rec adjustments" — RESOLVED 2026-05-23** | $800,070.47 | Not 5 JEs touching UF. It's account 162 "Reconciliation Adjustments" (Equity, AccumulatedAdjustment subtype) with $800,070.47 balance. Historical reconciliation plug bucket. Needs investigation to understand what populated it. | Ledger (next session) |
| Systemic deposit-methodology issue (BIG finding) | $2.54M historical | **IDENTIFIED 2026-05-23, OUT OF SCOPE per Jimmie 2026-05-23** — every RBFCU Deposit ever (1,331 of 1,893) recorded as direct Dr Bank / Cr Income. Years of double-counting. Scope locked to 2025/2026 only. | (no action) |
| $800K forced rec adjustments | $800,070 across 5 JEs | Staged, blocked on UF cleanup | Ledger |
| AR aging — true delinquent | ~$45-55K | 3 priority collection cases identified, no calls made | Jimmie (relationship work) |
| Books audit cleanliness | — | Slightly noisier than 2026-05-20 (11 customers have voided recovery-invoice clutter, fully documented in PrivateNotes) | n/a — acceptable cost |

**Overall progress vs "perfect close": ~15%** (up from 5-10% pre-session, once row #109 executes).

---

## What happened 2026-05-22 PM session (Ledger)

### Pri #1 — Apply 11 unapplied payments — DONE
- Jimmie applied all 11 unapplied payments to their recovery invoices via QBO UI
- Verified via API: every payment shows `UnappliedAmt: 0`, all link to expected recovery invoice
- LastUpdatedTime timestamps all between 12:23-12:50 PT 2026-05-22 (confirms work was actually done)
- **Bonus discovery:** Ralph Marcantonio's $1,199 payment split $982.20 to recovery inv 27040 + $216.80 to an older open invoice (18929 #274). Ralph is fully reconciled — actually cleaned an extra small open item in the process.

### Pri #2/#3 redesign — Pivoted from Credit Memo to Journal Entry
**Original plan:** Credit Memos against dup invoices (was Pri #3 in prior checkpoint).
**Problem:** Credit Memos create customer-ledger credits requiring follow-up application/refund — adds moving parts without buying financial-accuracy benefit.
**Pivot decision:** Jimmie explicitly said "not worried about tax treatment right now, just accurate financials." Tax-conversation-with-Rex (prior Pri #2) thus DROPPED — current-period treatment is fine. JE approach is mechanically simpler:
- One JE per pair (or one mega-JE with multi-line)
- Dr {target invoice's income acct} / Cr {dup payment's deposit acct}
- Customer ledger unaffected (no AR touched)
- Books accurate cumulatively, current-period takes the hit

### Topology survey — 35 pairs (not 32)
Script: `Team Inbox/Afton Electric/afton_je_topology_survey.py`

Discovered the prior "32 dup pairs" was missing the 3 "originally-pending" Track A pairs from yesterday (Linda Hughes, Joyce Yannuzzi, Bena Videsa). True universe is **35 pairs**: 24 untouched 2024 originals + 11 Track A recovery invoices.

**Survey findings:**
- **No sales tax** on any dup pair → JE has no Sales Tax Payable leg
- **Income split:** 24 pairs hit acct 132 Thryv Transactions ($12,303.24); 11 pairs hit acct 118 QuickBooks Payments Sales ($9,760)
- **Deposit split:** 34 pairs deposited to acct 4 Undeposited Funds ($21,688.24); 1 pair (Amy Erwin) deposited to acct 61 RBFCU Checking ($375)
- **Duplication source is structural:** Thryv (Afton's job-management CRM) pushes job transactions into QBO that overlap with QBO Payments' own auto-created sales entries for the same job. **Still happening** — needs upstream remediation (separate Riv/Loom workstream)

### Amy Erwin special case — confirmed accounting duplicate
Investigation pulled both payments:
- PMT 22213 (keep): created 2025-04-11 17:08:17
- PMT 22214 (dup):  created 2025-04-11 17:08:46 (29 seconds later)
- Same customer, same amount ($375), same deposit acct (RBFCU 61), same method (2), sequential doc numbers (#368 / #369)

Verdict: classic Thryv/QBO sync glitch, not real customer double-pay. Treat same as the other 34 — JE Dr Income $375 / Cr RBFCU $375. Book RBFCU correctly drops by $375; the gap gets absorbed when the $800K forced rec JEs reverse in Pri #4.

### JE batch — STAGED to queue
Script: `Team Inbox/Afton Electric/afton_je_stage_dup_cleanup.py`

**Single mega-JE, queue row #109:**
- TxnDate: 2026-05-22
- DocNumber: `AFTON-DUP-CLEAN` (15 chars, under QBO's 21-char limit — the prior TOB JEs that failed all had DocNumber >21 chars)
- Adjustment: True
- 70 lines, balanced Dr=Cr=$22,063.24
- Each line tagged with customer + target invoice ID + dup payment ID in Description
- Full per-pair audit trail in PrivateNote (3,971 chars)

**Account split (after execution):**
| Side | Account | Amount |
|---|---|---|
| Dr | 132 Thryv Transactions | $12,303.24 |
| Dr | 118 QuickBooks Payments Sales | $9,760.00 |
| Cr | 4 Undeposited Funds | $21,688.24 |
| Cr | 61 RBFCU Checking 9015 | $375.00 |

**Execution path:** Jimmie opens QBO Write Queue Sheet → `afton` tab → finds row 109 → drops Y in Approve col → worker fires (next pass or via desktop shortcut).

---

## Open items needing Jimmie's attention

1. **Process 24 unbooked bank-feed transactions** in QBO Banking → For Review for RBFCU 9015 (Feb-Apr 2026 gap). See `afton_transfers_audit_report.md`.
2. **Thryv → QBO sync** is the systemic duplication source. Still active. Worth routing to Riv/Loom as a separate workstream — current cleanup is treating symptoms, not cause.

---

## Critical learnings (captured in auto-memory)

- `reference-qbo-dup-payment-invoice-pattern` — always pull linked invoices before voiding a "dup payment"
- `reference-qbo-void-api-limitations` — CC and deposited payments unvoidable via API; void approach creates orphan-credit trap
- `reference-qbo-autoreminder-empirical-check` — check DeliveryInfo timestamps, not Preferences API
- `feedback_one_question_at_a_time` — confirmed correct, surface ONE decision at a time
- **NEW (this session):** QBO JE `DocNumber` is hard-capped at 21 chars; QBO returns a misleading "failed to parse json object" error for longer values. All 11 TOB JEs on 2026-05-21 failed for this reason.

---

## Open work — prioritized

| Pri | Item | $ leverage | Effort | Owner | Blocked by |
|---|---|---|---|---|---|
| ~~1~~ | ~~Approve queue row #109 (35-pair JE)~~ | ~~$22,063 cleanup~~ | ✓ **DONE 2026-05-22 — JE 27061** | — | — |
| 1 | Make Deposits — match remaining UF ($263,617.24) to RBFCU statements | unblocks $800K reversal | Multi-hour UI | Jimmie | — |
| 3 | Reverse $800K forced rec adjustments | $800,070 | 5 JEs via queue | Ledger | #2 done |
| 4 | Confirm UF $285K balance source (was $562K) | accuracy of #2 math | quick check | Jimmie | — |
| 5 | Thryv→QBO duplication root-cause fix | stops leak | Riv/Loom workstream | Riv + Loom | — |
| 6 | Resolve 3 failed Step 1 cleanups (Amy Turner, Nelle, Afton LLC) | tiny | ~10 min | Ledger | — |
| 7 | 15 manual customer merges (Step 3) + 24 phone-in-name dups | cosmetic | 30-60 min UI | Jimmie | — |
| 8 | Review 3 mis-flagged "dup" pairs (Mike Fischer, Jean Autrey, Mark Braunstein 19511) | $1-2K | small | Ledger | — |
| 9 | 3 priority collection calls (Corbin, Jimmy Martinson, La Golondrina) + Jake's $2,240 apply | $30K+ AR | calls | Jimmie | — |
| 10 | Riv: fix worker double-fire on Sheets 429 quota errors | infra debt | Riv work | Riv | — |
| 11 | Riv: fix worker void path for JournalEntries (silently no-ops; use DELETE instead) | infra debt | Riv work | Riv | — |
| 12 | Larger scope: $2.54M of historical Income double-counting across 1,331 direct-cash RBFCU deposits — needs Rex conversation about whether/how to address | $$ TBD | TBD | Jimmie + Rex | — |

---

## Source files

| Path | Purpose |
|---|---|
| `Team/Riv/j2_qbo_mcp/server.py` | j2-qbo MCP server (20 read + 8 write tools) |
| `Team/Riv/j2_qbo_mcp/worker.py` | Queue worker (supports `--once --row-id N` for single-row mode) |
| `Team/Riv/j2_qbo_mcp/write_queue.json` | Queue state (entries up to id 109 as of 2026-05-22 PM) |
| `Team/Riv/j2_qbo_mcp/afton_customer_cleanup.py` | Step 1 script — 61 null-name updates |
| `Team/Riv/j2_qbo_mcp/afton_payment_voids.py` | Step 4 ORIGINAL plan — pmt-only voids (now superseded) |
| `Team/Riv/j2_qbo_mcp/afton_open_period_pair_voids.py` | Step 4 Track A — pmt+inv voids (failed, kept for audit) |
| `Team/Riv/j2_qbo_mcp/afton_recover_orphan_credits.py` | Recovery script — recreated 11 invoices |
| `Team Inbox/Afton Electric/afton_je_topology_survey.py` | **NEW** Topology survey for the JE batch — read-only, outputs JSON + MD |
| `Team Inbox/Afton Electric/afton_je_topology_survey.json` | **NEW** Survey output — 35-pair per-line breakdown (income acct, deposit acct, amounts) |
| `Team Inbox/Afton Electric/afton_je_topology_survey.md` | **NEW** Human-readable survey summary |
| `Team Inbox/Afton Electric/afton_je_stage_dup_cleanup.py` | **NEW** JE batch builder — stages the $22K cleanup JE to queue row #109 |
| `Owner Inbox/afton_customer_cleanup_report.md` | Step 1 results report |
| `Owner Inbox/afton_payment_voids_report.md` | Step 4 original-plan dry-run report |
| `Owner Inbox/afton_open_period_pair_voids_report.md` | Track A queue report |
| `Team Inbox/Afton Electric/afton_payment_pairs_invoice_analysis.json` | **CANONICAL** — full pmt+inv topology analysis for all 35 original pairs |
| `Owner Inbox/afton_session_2026-05-22_summary.md` | Owner-facing summary of yesterday's session |
