Three new export formats, all reusing this pipeline's existing
transactions data with no new extraction logic:
- QBO (QuickBooks Web Connect / Quicken): qbo_service.py writes OFX 1.x
SGML directly, including <INTU.BID>3000 so it actually qualifies as a
real QBO/QFX file (corrected same day from an initial build that
produced plain generic OFX with a .qbo extension slapped on - see
CLAUDE.md for the research trail). Needs a reusable, project-scoped
bankAccountProfiles record (pb_migrations/14) so a user isn't re-typing
routing/account numbers on every export of the same real account.
- Xero (import CSV): xero_csv_service.py, no bank-account concept at all
(Xero's own CSV import has none) - genuinely simpler than QBO.
- A plain, generic transactions CSV (csv_service.py) - distinct from
Xero's import-specific shape, writes every row regardless of a missing
date/amount since a plain dump has no structural requirement to violate.
The three original separate download buttons were consolidated into one
Download trigger + hover dropdown (QuickBooks/Xero/CSV/Excel), reusing
the Results dropdown's own zero-dead-zone hover structure. Excel's and
the new CSV's single/all download logic was generalized behind one
DOWNLOAD_FORMATS lookup rather than duplicated.
Also adds a per-transaction "include in downloads" checkbox - a lighter,
reversible alternative to permanently deleting a row: excludedFromExport
lives on the document's own result, read only at download time, with
zero effect on the live review screen's own data/checks.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The first piece of a stated future billing model, scoped to exactly
this: a visible "pages this month" counter and the raw data recording
behind it - not plan enforcement, payment processing, or the described
pause/resume billing-cycle logic itself. New append-only/immutable
usageEvents collection (pb_migrations/13); one event recorded per
successfully delivered extraction (result.page_reports.length), not a
Preview click. "This period" is explicitly the calendar month - a
placeholder until a real subscription/plan record exists to anchor a
custom cycle against.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
A needs-mapping statement in a multi-file batch used to live in a
single global slot (layoutMapperStore), so mapping the first of several
such statements silently lost the rest. Each one is now a placeholder
document in extractionStore's own documents list (with a pendingMapping
field carrying its file/fingerprint/candidate data), reachable via
DocumentNavBar and a per-document "Map now" reminder in TransactionsTable,
with a clickable notice banner linking straight to each queued statement.
Also makes this survive a reload: a needs-mapping placeholder is now
saved to PocketBase (documentsService.savePendingMappingDocument,
pb_migrations/12 relaxes documents.result to optional and adds the
pending* fields) instead of living only in memory, and useDocuments.js
reconstructs it as a placeholder on load. Includes the confirm-before-
remapping step for correcting an already-successful document, and the
delete-flow guard for a placeholder with no PocketBase id yet.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
A deliberate scope expansion past this product's original "does not
categorize transactions" boundary: project-scoped categorizationRules
(PocketBase), pure-JS matching (longest-pattern-wins, case-insensitive
substring), a Categorization tab beside Transactions, and an optional
"Categorized Summary" sheet in the Excel export. Categorization is
computed live from current rules and never persisted on the document
itself - only the rules persist.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
layoutMappings/layoutMappingVersions gain valuePatterns (json, optional)
- same incremental pattern as startPage/headerBottom (migrations 7/8).
Also relaxes columnMap from required to optional on both collections:
confirmed empirically against the real running container that
PocketBase's required:true rejects an empty JSON object the same way
it rejects a missing one ("Cannot be blank"), and a value-pattern-only
mapping (no region-drawing at all) genuinely has no column positions
to store.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
New /layouts route (LayoutsView.vue, linked from AppHeader.vue): List (own + shared
mappings with usage/failure stats), Inspect (source document with each column drawn
as a labeled vertical strip), Test (an unsaved dry run against any of the user's own
documents), Version history + Roll back (append-only - a rollback creates a new
version rather than editing history), and Retire. The plan's own "Edit" (reopening
ManualMappingView pre-populated) was deliberately dropped - columnMap never persists
page/vertical position, so there's no real data to re-populate a visual editor with.
Drift detection now runs on every recheck, not just the original extraction -
useRowEditing.js and TransactionRow.vue both call the same recordUsage() useBatchExtraction.js
already used, via a newly shared layoutMappingsService.checksPassed(). Required
threading layoutMappingUsed/layoutMappingVersionUsed onto the in-memory document
object too (extractionStore/useDocuments/useBatchExtraction), not just the PocketBase
record.
Found and fixed two real bugs via this stage's own end-to-end testing, both in the
same "computed correctly this session, never persisted" category as L.6's zone-padding
fix: startPage itself was never saved, so every future auto-apply of a saved mapping
would have silently reset to page 1, reintroducing the cover-page bug L.2 already
fixed once. Worse: startPage alone only skips whole pages - it does nothing about the
real header row text still sitting on the start page itself, which would have
corrupted essentially every real manually-mapped statement. Fixed with two new
persisted fields (startPage, headerBottom) and a new header_bottom parameter in
table_extract.py, using the same zone-padding margin as a safety buffer.
Verified against the real rebuilt container: a 2-page synthetic statement confirmed
both bugs real before their fixes and confirmed both fixed together; a second,
independent upload auto-applies the saved mapping with both fields carried through;
sourceDocument backfill, version history/rollback, retire, and real three-user
promotion all confirmed against the real PocketBase; a separate test confirmed the
recheck-triggered drift detection itself, flipping a real mapping to stale after a
deliberately broken running-balance edit. measure.py byte-identical throughout; npm
run build passes.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
New layoutMappings/layoutMappingVersions collections plus documents fields
(layoutMappingUsed/layoutMappingVersionUsed/layoutApplied/layoutFingerprintHash) and
a promote_shared_layout_mapping.pb.js hook that flips a mapping to "shared" once a
second, different user independently creates one with the same fingerprintHash.
Found and fixed a real security gap by testing the live rule rather than trusting the
rule text: the original updateRule only gated WHO could update a layoutMappings
record, not WHICH fields - letting an owner trivially self-promote their own mapping
to "shared" via a plain PATCH, defeating the whole confirmation requirement. Fixed in
a follow-up migration (6_fix_layout_mapping_update_rule.js) that blocks setting status
to "shared" directly while leaving ordinary edits and self-retiring untouched.
Verified against the real rebuilt PocketBase container: both collections and all four
new documents fields confirmed via the REST API; two real signed-up users with a
matching fingerprintHash both correctly flip to shared via the hook, visible to a
third user; a still-private mapping 404s for every other user; the self-promotion
gap reproduced before the fix and confirmed blocked after it.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The actual request was simple (store exports in R2 like source files,
pending a retention-duration decision), but investigating where
exports were written surfaced something worse: /api/process built and
saved a full workbook to disk on EVERY extraction, and nothing in the
frontend ever called /api/download/<filename> to retrieve it (confirmed
by grep - no reference anywhere). Every extraction was silently
orphaning an .xlsx file for no reason; 91 had already accumulated
locally from this session's own testing alone.
Removed the dead work entirely: /api/process no longer builds or saves
a workbook at all. /api/download/<filename>, file_repository.
save_workbook/resolve_output_path, and OUTPUT_FOLDER (env var, volume,
directory) are all gone - confirmed nothing else referenced any of
them before removing. outputs/ deleted, including its 91 accumulated
files.
/api/export (the only path actually used - Download Excel/All) now
builds the workbook into an in-memory BytesIO and streams it straight
from there - never touches disk, not even temporarily. The frontend
persists it long-term instead: documentsService.saveExportFile uploads
the same Blob the browser download already used to a new exportFile
field (pb_migrations/3_add_export_file.js), stored in R2 same as
sourceFile. Overwrites the previous export rather than keeping a
history - no retention policy has been decided yet, and keeping every
version would just relocate the same unbounded-growth problem from the
VPS to R2 instead of fixing it. Best-effort from ResultCard.vue - a
save failure is reported but never blocks the browser download itself.
Verified for real: /api/process's response no longer has `filename`
(title still does); /api/export still streams a valid, correctly-typed
.xlsx; /app/outputs no longer exists in the rebuilt container; the old
/api/download URL now falls through to the ordinary SPA catch-all, not
a leftover route. documentsService.saveExportFile run against the REAL
bytes /api/export produced, fetched back through the R2-backed URL,
confirmed byte-for-byte - and confirmed a second export overwrites
rather than creating a second record. measure.py unaffected; npm run
build passes.
New documentsService.js (saveDocument/updateDocument/listDocuments/
deleteDocument/sourceFileUrl) and a minimal projectsService.js
(getDefaultProject/listProjects, extended in B.3) replace
extractionService.js's old localStorage-backed persistResult/
restoreResult/lastBatchKeys/appendToLastBatch/startNewBatch/
discardPersisted - deleted outright, not kept alongside.
extractionStore's document entries gained a pbId field (the PocketBase
record id), set from saveDocument's create response or a listed
record's own id - needed so useRowEditing's saveEdit() knows which
record to PATCH.
RestoreBanner.vue and uiStore's restoreBannerVisible/Text/show/hide
deleted outright (not repurposed) - the banner existed because a
localStorage cache's presence was ambiguous ("did a crash happen?");
PocketBase being the real backend means a logged-in user's documents
just load, same as any other app showing your own data.
useFileUpload.restoreOnLoad() renamed loadDocuments(), simplified from
the plan's own "needs a watcher" - unnecessary, since App.vue's auth
gate already means ExtractorView can't mount before authenticated.
Two real bugs caught by executing the actual services against the live
PocketBase, not just reading them: an empty-string filter is rejected
outright rather than treated as "no filter" (fixed by omitting the key
entirely); sort:'-created' referenced a field that didn't exist -
projects/documents came out of migration 1 with no created/updated
fields at all, unlike the built-in users auth collection. Fixed with a
new migration (2_add_timestamps.js, not editing the one that already
ran) adding autodate created/updated to both, field shape copied from
users' own via the REST API.
Verified end-to-end with the real, committed services run from a
plain Node script against the live container: signup -> default
project resolves -> saveDocument with a real File -> listDocuments
finds it -> sourceFileUrl fetched for real returns the exact original
bytes -> updateDocument (simulating a row edit) -> re-listDocuments
confirms the change actually persisted. npm run build passes.
measure.py unaffected; R2/Google settings confirmed to survive the
PocketBase container rebuild.
New third service alongside app/docling - a deliberate, revisited
decision from the documented "no DB" architecture, not an oversight.
pocketbase/Dockerfile - official minimal pattern (no official image
exists), pinned binary, migrations+hooks copied in and run on startup.
pb_migrations/1_create_collections.js - schema as code: users (auth,
self-registration open), projects (owner-scoped), documents (owner-
AND project-scoped - project is REQUIRED, not optional, since a
planned future per-project category-mapping feature needs every
document scoped from day one), with a sourceFile field for the
original PDF/image (stored in R2 once configured).
pb_hooks/ensure_default_project.pb.js - auto-creates each new user's
"General" project (isDefault:true) the moment their account exists -
covers password and Google signup uniformly, guarantees the required
documents.project relation always has somewhere to point.
configure-secrets.sh - the only place R2/Google secrets are handled,
reading from a gitignored .env and PATCHing PocketBase's own REST API.
Never in a migration (those are committed to git).
Frontend: pocketbaseRepository.js (the one SDK instance),
authService.js (login/signup/Google/logout), authStore.js (Pinia,
synced to the SDK's own authStore), LoginView.vue, and App.vue's new
auth gate - talks to PocketBase directly, not proxied through Flask.
Verified via real REST API calls against the running container (not
just read): migrations create the expected collections/rules; a fresh
signup gets exactly one auto-created "General" project; a second
user's token can't see the first user's data; a document created with
no project correctly fails validation (confirming the frontend must
resolve one itself); authService's actual functions exercised via a
live Node script against the real container (signup, hook-created
project visible, logout, re-login). npm run build passes. measure.py
unaffected (no backend code touched).
Not yet verified - needs real R2/Google credentials this session
doesn't have: configure-secrets.sh itself, and the Google OAuth popup
flow (needs a real browser + real Google Cloud OAuth client, both
outside this repo's control - documented as setup prerequisites in
README.md).
This is Stage B.1 of 3 (schema + auth gate). B.2 (document persistence
moves from localStorage to PocketBase) and B.3 (the project sidebar
UI) are not started yet.