chore(sheets): consolidate currency-column detector into one shared helper - #114
Merged
Merged
Conversation
…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>
|
🔁 PR closed. Stage bot switched back to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Deferred follow-up on #112. Two parallel "which columns are currency columns" implementations existed —
isCurrencyHeaderinscripts/repair-all-sheets.tsandnonEurCurrencyColumnIndicesinsrc/services/google/sheets.ts. The PR #113 review flagged thatfillEurNativeRates(script) had no direct test because the two could drift.What
isCurrencyColumnHeader(header)insheets.ts— a[A-Z]{3} (…)header that isn'tEUR (calc)orRate (→EUR).nonEurCurrencyColumnIndicesnow builds on it (adds the!EURlayer). Byte-for-byte identical behavior.scripts/repair-all-sheets.tsimports the shared helper; its localisCurrencyHeaderdeleted; both call sites use the shared code — so the script now runs the tested code.fillEurNativeRatesneeds it);nonEurCurrencyColumnIndicesexcludes it. EUR-exclusion is a layer on top of the shared primitive, not part of it.Tests
New
isCurrencyColumnHeaderdescribe (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