Commit Graph

6 Commits

Author SHA1 Message Date
JasonFraser 8a99254d28 Add QBO/Xero/CSV exports, consolidated Download dropdown, per-row exclude checkbox
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>
2026-11-24 08:16:17 -04:00
JasonFraser 92ba5f4386 Wire frontend fingerprint-lookup orchestration for the layout mapper (L.4)
useBatchExtraction.js now reacts to a needs_mapping:true response: looks up an
exact or near-match layout mapping (layoutMappingsService.js), applies it silently
on an exact match, asks for confirmation on a stale exact match or a near match via
a real ConfirmModal wired through ExtractorView.vue (not a placeholder), and falls
through to reason:'no_match' when nothing matches (the manual mapping screen's own
entry point, not built yet). A used mapping's usage is recorded for drift detection
and persisted onto the saved document record.

Found and fixed two real bugs in the near-match comparator by testing it against
the spec's own documented example (Debit/Credit renamed to Withdrawals/Deposits):
compute_fingerprint was building header_labels from whole header LINES instead of
per-field label text, making a two-word rename indistinguishable from a totally
different layout; added a field_labels map so the comparison is per-field. Even
after that, the first 70% overlap threshold still failed the documented example
itself (a 4-field rename of 2 fields is exactly 50%) - corrected to 50%, derived
from the example's own real numbers.

Verified: 18 assertions against the real layoutMappingsService/useLayoutMapping
(hard gates, the corrected per-field overlap, real PocketBase ownership/sharing
rules, stale-mapping decline/accept, no-match reporting); the real rebuilt
container's /api/process response now carries the fixed field_labels shape;
measure.py byte-identical throughout; npm run build passes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-14 19:51:42 -04:00
JasonFraser 6913d45d20 Add review screen R.5: edit log, acknowledge/accept workflow, Excel Edits sheet
Completes the R.1-R.5 review screen plan. editLog/acknowledgedFlags/accepted all
live on the existing result JSON blob, no new PocketBase migration needed. Every
row mutation (manual edit, suggested-fix apply, structural edits) now logs a
field-level edit log entry; flags can be individually acknowledged; a document
can be Accepted once Verified or fully acknowledged; exports gain an optional
Edits sheet when edit_log is non-empty.

Verified: measure.py byte-identical to the pre-R.5 baseline, real curl round trip
through the rebuilt container confirming the Edits sheet appears/omits correctly,
extractionStore's new getters/actions run directly against real Pinia, and
useRowEditing's edit-log capture confirmed against a document actually persisted
on the live PocketBase container.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-13 20:41:13 -04:00
JasonFraser e59013cdcb Move document persistence from localStorage to PocketBase (Stage B.2)
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.
2026-10-13 06:41:51 -04:00
JasonFraser 2081bc574b Multi-file upload, sequential extraction, prev/next navigation, Download All
extractionStore restructured from a single currentResult into a list
of documents + activeIndex, so a batch of files can be extracted
sequentially (useBatchExtraction.js replaces useExtraction.js) with
"Extracting N/M: filename" progress, and browsed afterward via
DocumentNavBar's prev/next. currentResult/currentDocKey/
flaggedIndexes/effectiveOpeningBalance/effectiveClosingBalance stay
getters with their exact old names (now derived from activeDocument),
so ResultCard.vue and most of TransactionsTable.vue needed no changes
beyond the balance-input v-model bindings.

Two choices from the plan were revised after user review before any
code was written: focus never moves on its own except to show the
very first result (a later file finishing mid-batch never yanks the
user away from whatever they're reviewing or editing), and a Download
All button sits beside Download Excel, shown once a multi-file batch
has actually finished.

Restore-on-reload generalized from one document to a whole batch
(lastBatchKeys/appendToLastBatch replace lastDocKey; persistResult now
saves {fileName, result} with a backward-compatible fallback for the
old bare-result shape).

Two real bugs caught in review before ever reaching a browser:
TransactionRow was keyed only by row index (could reuse a stale
component's draft across documents sharing an index - fixed by keying
on docKey+index too), and addDocument called recomputeFlags() which
only ever targets the active document (a document added while focus
stayed elsewhere would never get its own flaggedIndexes computed -
fixed by computing flags directly for whichever document was just
added, not just the active one).

Verified: npm run build; every new/changed store action and getter
executed directly against real Pinia with synthetic multi-document
scenarios; the real Docker container rebuilt and hit with sequential
/api/process calls confirming identical results to the pre-change
baseline; measure.py unaffected (no backend code touched). No backend
changes anywhere - /api/process|recheck|export already each take
exactly one file/document per call.
2026-10-12 21:00:07 -04:00
JasonFraser 6e4da3f385 Restructure frontend to Vue 3 + Vite (Stage 2 of 2)
Rebuilds templates/index.html (896 lines of vanilla JS, no framework, no
build step) as frontend/, a Vue 3 app per ENTERPRISE_STANDARDS.md's
frontend layering (views -> components -> composables -> services ->
repositories, Pinia for stores) - same agreed scope as Stage 1 (backend):
structure + commenting, not the full SaaS-shaped doc.

The full original file was read in full before starting (every function
enumerated against the plan, not re-derived from memory) to make sure
nothing documented in CLAUDE.md's "Frontend / UI state" section got
simplified away: sticky side-by-side layout with a draggable resizer,
Hide/Show Source Doc, collapsible Result card, per-row pencil-to-edit,
comma-formatted numbers, localStorage persistence with a restore banner,
image zoom controls, the pencil-icon-color and description-autogrow
fixes from earlier this session.

The original ask that started this whole detour - processing-phase text
with an animated ellipsis during /api/process - lands here as the one
genuinely new feature (useProcessingPhases.js + ProcessingIndicator.vue),
honestly simulated rather than claiming real progress (the backend is
one synchronous request with no streaming signal).

backend/app.py now serves frontend/dist (built via a new Dockerfile
multi-stage build: a node stage runs npm ci && npm run build, the Python
stage copies backend/ + that dist/ output) instead of rendering a Jinja
template - a manual SPA-fallback route serves a real static asset if one
exists at the requested path, else index.html. One real bug caught and
fixed before this ever ran: the first version also left Flask's own
automatic static route enabled, registering a duplicate/conflicting rule
against the same /<path:...> pattern as the manual catch-all - fixed by
disabling Flask's own static handling (static_folder=None) entirely.

Verified without a browser (the extension could not connect, tried
repeatedly): npm run build succeeds, formatService.js's pure functions
tested directly in Node, every prop/emit/store reference cross-checked
by hand across all ~20 new files, and full regression through the real
Docker container (SPA serving, static assets, /health, /api/* routing,
dual-engine extraction, measure.py - all unaffected or identical to
baseline). Actual interactive behavior - upload, drag/drop, the
processing-phase animation, editing, zoom, the resizer, persistence/
restore, download - was verified by the user in their own browser, not
by Claude. templates/index.html was kept in place as a fallback until
that confirmation came back, then deleted.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-12 06:32:49 -04:00