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 <noreply@anthropic.com>
This commit is contained in:
JasonFraser 2026-10-12 07:17:51 -04:00
parent 1ab3d1bb42
commit 15e163267e
2 changed files with 64 additions and 12 deletions

View File

@ -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; }
}

View File

@ -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
}
</script>
<template>
@ -49,17 +80,22 @@ const toggleLabel = computed(() => (uiStore.pdfColHidden ? 'Show Source Doc' : '
<h2>Transactions</h2>
<button class="btn-toggle" type="button" @click="uiStore.togglePdfCol">{{ toggleLabel }}</button>
</div>
<div class="fields">
<div>
<label>Opening balance (optional)</label>
<input v-model="extractionStore.openingBalanceInput" type="text" inputmode="decimal" placeholder="e.g. 90,569.13">
<div class="calc-readout" :class="{ match: balanceMatches }">{{ openingCalcText }}</div>
</div>
<div>
<label>Closing balance (optional)</label>
<input v-model="extractionStore.closingBalanceInput" type="text" inputmode="decimal" placeholder="e.g. 88,479.50">
<div class="calc-readout" :class="{ match: balanceMatches }">{{ closingCalcText }}</div>
<div class="fields-row">
<div class="fields">
<div>
<label>Opening balance (optional)</label>
<input v-model="extractionStore.openingBalanceInput" type="text" inputmode="decimal" placeholder="e.g. 90,569.13">
<div class="calc-readout" :class="{ match: balanceMatches }">{{ openingCalcText }}</div>
</div>
<div>
<label>Closing balance (optional)</label>
<input v-model="extractionStore.closingBalanceInput" type="text" inputmode="decimal" placeholder="e.g. 88,479.50">
<div class="calc-readout" :class="{ match: balanceMatches }">{{ closingCalcText }}</div>
</div>
</div>
<button class="btn-toggle btn-recheck" type="button" :disabled="!result || rechecking" @click="handleRecheck">
{{ rechecking ? 'Checking…' : 'Recheck Balance' }}
</button>
</div>
<div class="note">This statement format may not print a clean opening/closing balance — enter them here to run the full statement balance check; otherwise it's marked "not available" rather than guessed.</div>
<div v-if="result" class="note">Click the pencil on a row to edit it, then Save to commit - edits are saved to this browser as you confirm them, row by row.</div>