Skip to content

chore(sheets): consolidate currency-column detector into one shared helper - #114

Merged
alex-mextner merged 1 commit into
mainfrom
chore/consolidate-currency-detector
Jul 1, 2026
Merged

chore(sheets): consolidate currency-column detector into one shared helper#114
alex-mextner merged 1 commit into
mainfrom
chore/consolidate-currency-detector

Conversation

@alex-mextner

Copy link
Copy Markdown
Owner

Why

Deferred follow-up on #112. Two parallel "which columns are currency columns" implementations existed — isCurrencyHeader in scripts/repair-all-sheets.ts and nonEurCurrencyColumnIndices in src/services/google/sheets.ts. The PR #113 review flagged that fillEurNativeRates (script) had no direct test because the two could drift.

What

  • New shared primitive isCurrencyColumnHeader(header) in sheets.ts — a [A-Z]{3} (…) header that isn't EUR (calc) or Rate (→EUR).
  • nonEurCurrencyColumnIndices now builds on it (adds the !EUR layer). Byte-for-byte identical behavior.
  • scripts/repair-all-sheets.ts imports the shared helper; its local isCurrencyHeader deleted; both call sites use the shared code — so the script now runs the tested code.
  • Preserved a real asymmetry (deliberately, not a behavior change): the script's currency-column set INCLUDES the EUR currency column (fillEurNativeRates needs it); nonEurCurrencyColumnIndices excludes it. EUR-exclusion is a layer on top of the shared primitive, not part of it.

Tests

New isCurrencyColumnHeader describe (TDD red-first): EUR (calc)→false (the guarantee that a non-EUR row can't get Rate=1), Rate/Дата/Категория/Комментарий→false, USD/RSD/EUR currency headers→true. Full suite 3620/3620, type-check + biome lint clean, codex review: no blocking issues.

Refs #112

🤖 Generated with Claude Code

https://claude.ai/code/session_01Rq7c53bgYsq6uZ9hmdhXu9

…elper

Extract isCurrencyColumnHeader in src/services/google/sheets.ts as the single
source of truth for "which sheet columns are currency amount columns"
(excluding EUR (calc) and Rate (→EUR)). scripts/repair-all-sheets.ts now
consumes it instead of its own isCurrencyHeader copy, and
nonEurCurrencyColumnIndices layers the EUR exclusion on top.

This makes the tested helper the exact code the untestable repair script runs,
so the guarantee that EUR (calc) is never classified as a currency column
(and thus fillEurNativeRates never sets Rate=1 on a non-EUR row) is now
directly covered by unit tests.

Refs #112

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

🔁 PR closed. Stage bot switched back to main.

@alex-mextner
alex-mextner merged commit f863030 into main Jul 1, 2026
12 checks passed
@alex-mextner
alex-mextner deleted the chore/consolidate-currency-detector branch July 1, 2026 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant