From 15e163267e52e3deec0a9fe1e2db53d3de946905 Mon Sep 17 00:00:00 2001 From: JasonFraser Date: Mon, 12 Oct 2026 07:17:51 -0400 Subject: [PATCH] Add explicit Recheck Balance button for post-extraction balance entry Typing opening/closing balance AFTER extraction (e.g. the user forgot to fill it in before clicking Extract) never did anything on its own - the fields were only ever read by some OTHER trigger (a row Save, or Download). Confirmed this gap predates the Vue rewrite - the original vanilla-JS version had the identical behavior. Adds a "Recheck Balance" button (TransactionsTable.vue) that re-runs the same recheck-only (no re-extraction) call a row Save already makes, using whatever's currently in the balance fields - an explicit, deliberate trigger rather than auto-firing on blur, matching the existing per-row Save pattern (edits/entries only take effect when confirmed). Positioned at the row's own right edge, aligned under the Hide/Show Source Doc toggle above it; drops below the closing-balance field at mobile widths (a new 640px breakpoint, separate from the 860px one the overall layout already used). Verified end-to-end against the real backend: uploaded a statement with no balance supplied (statement_balance: not_available), then called /api/recheck with balances added afterward - the check correctly recalculated and reported the result, the same request shape and endpoint the new button uses. Co-Authored-By: Claude Sonnet 5 --- frontend/src/assets/main.css | 18 +++++- frontend/src/components/TransactionsTable.vue | 58 +++++++++++++++---- 2 files changed, 64 insertions(+), 12 deletions(-) diff --git a/frontend/src/assets/main.css b/frontend/src/assets/main.css index a605262..2ae101a 100644 --- a/frontend/src/assets/main.css +++ b/frontend/src/assets/main.css @@ -68,7 +68,15 @@ h1{ font-family:var(--fd); font-weight:800; font-size:30px; letter-spacing:-.01e .file-zone-sub{ font-size:11.5px; color:var(--t4); margin-top:5px; } .file-zone-sub.file-chosen-name{ font-family:var(--fm); font-size:12px; color:var(--blue); margin-top:5px; } -.fields{ display:flex; flex-wrap:wrap; gap:16px; margin-bottom:16px; } +/* .fields-row pairs the balance inputs with the Recheck Balance button - + the button sits at the row's own right edge, lining up under the + Hide/Show Source Doc toggle above it (txn-col-head is also a full-width + row with its own button at the right). Drops below the closing-balance + field on narrow viewports - see the mobile breakpoint below. */ +.fields-row{ display:flex; align-items:flex-start; gap:16px; margin-bottom:16px; } +.fields-row .fields{ flex:1 1 auto; min-width:0; margin-bottom:0; } +.btn-recheck{ flex-shrink:0; white-space:nowrap; } +.fields{ display:flex; flex-wrap:wrap; gap:16px; } .fields > div{ flex:1 1 180px; min-width:160px; } .fields label{ font-size:11.5px; color:var(--t3); display:block; margin-bottom:6px; white-space:normal; } .fields input{ @@ -306,3 +314,11 @@ tr.editing td{ background:rgba(37,99,235,.03); } .resizer{ display:none; } .txn-col{ width:100%; } } +/* Mobile: the Recheck Balance button drops below the closing-balance + field instead of sitting beside the fields at the row's right edge - + 860px (the breakpoint above) still has plenty of width for both side + by side, so this is its own, narrower cutoff. */ +@media (max-width: 640px){ + .fields-row{ flex-direction:column; align-items:stretch; } + .btn-recheck{ align-self:flex-end; } +} diff --git a/frontend/src/components/TransactionsTable.vue b/frontend/src/components/TransactionsTable.vue index 4df5857..87f42ff 100644 --- a/frontend/src/components/TransactionsTable.vue +++ b/frontend/src/components/TransactionsTable.vue @@ -19,10 +19,11 @@ * again by applyCheckResults, while closingCalc's text IS recomputed on * every recheck). */ -import { computed } from 'vue' +import { ref, computed } from 'vue' import { useExtractionStore } from '../stores/extractionStore' import { useUiStore } from '../stores/uiStore' import { fmtMoney } from '../services/formatService' +import * as extractionService from '../services/extractionService' import TransactionRow from './TransactionRow.vue' const extractionStore = useExtractionStore() @@ -42,6 +43,36 @@ const closingCalcText = computed(() => { }) const toggleLabel = computed(() => (uiStore.pdfColHidden ? 'Show Source Doc' : 'Hide Source Doc')) + +// ── Balance recheck ────────────────────────────────────────────────── +// Entering opening/closing balance AFTER extraction (e.g. the user +// forgot to type it before clicking Extract) doesn't update anything on +// its own - typing alone was never wired to a recheck, same as the +// original vanilla-JS version (it only rechecked on a row save or a +// download). This button is the explicit, deliberate trigger - same +// recheck-only (no re-extraction) call a row Save already makes. +const rechecking = ref(false) + +async function handleRecheck() { + if (!result.value || rechecking.value) return + rechecking.value = true + extractionStore.clearError() + try { + const checkResult = await extractionService.recheck( + result.value, + extractionStore.effectiveOpeningBalance, + extractionStore.effectiveClosingBalance, + ) + if (checkResult.error) { + extractionStore.setError(checkResult.error) + } else { + extractionStore.applyCheckResults(checkResult) + } + } catch (e) { + extractionStore.setError('Network error: ' + e.message) + } + rechecking.value = false +}