Repository navigation
fix: review findings, ~20x faster solver, and Portuguese receipt fixes - #5
Merged
Merged
Conversation
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.
Fixes and cleanup from a full review of
src/. One concern per commit.Fixes
otherFillssources pointed at the internally joined rows instead of the caller's lines when a row was split by the recogniser. Highlights for a second fill landed on the wrong line. Test added inrows.test.ts.galmatched inside words (Portugal,Galp,Legal), so the US tenth-of-a-cent repair turned12.50 9into12.509. Now only a whole wordgal/gals/gallon(s)/ppgtriggers it;11.482GALstill does.Bulgaria has used the euro since 1 January 2026:
country: "BG"now maps to EUR. Lev receipts (лв.) still read as BGN.Currency precedence: an explicit
context.currencynow settles an ambiguous symbol ahead of the currency implied bycountry, matching howextract.tsalready picks its fallback.Other fills tolerance now uses the receipt's fallback currency instead of always the euro cent (only matters on lines with no currency mark).
Alternates were unbounded: lines were capped at 500 × 1500 chars but each line's
alternateswere not, and every number keeps a copy of its line, so memory grows with the square of the length. 50 alternates of 100k chars ran Node out of memory. Now the first 3, cut to 1500 chars. Test added inresilience.test.ts(fails without the fix).Total IVA 11,22taken as the total when the sum cannot close (litres not read): it tied withTOTAL 60,00and won by coming first. A total whose label names a tax now ranks lower unless it says the tax is included (c/IVA,inkl,TTC, …). Tests forTotal IVA,Valor IVAandTotal s/IVA … Total c/IVA.Miles & More 123456read as odometer (123456 mi). Loyalty labels are now skipped by the odometer reader. Test added.Fuel not named when printed on its own number line:
GASOLEO 40,00 L x 1,600 EUR/L 64,00gavefuelTypeId: null, and a line with no currency gave the whole line as the label. The product is now also read from the text before the first decimal number. Tests for three layouts.Added
Gasóleo EvologicandÓptima Dieselas additised diesel;Alves Bandeiraas a station. (Names taken from the brands' ranges, not from receipts — worth confirming against real paper.)Taxa OPC/Taxa EGMEas fees, so a charging receipt printing them can close. Test added.Speed
namesFuelAmount(contextFor(...))for every total inside the quantity × price loop (~8000 lexicon scans); it is now asked once per total.CI
npm ci --ignore-scripts, since it holdsid-token: write. Checked locally that lint, typecheck, coverage, build, publint, attw and smoke all work after a scripts-free install.Cleanup
currencysettles an ambiguous symbol.contextFormoved back onto it.currencyOfcomputed once; unit-kind regexes compiled once instead of per call.src/units.tsanddecimalInput/localNumber/localReceiptNumberfromsrc/format.ts: not exported, not used by the library.Checks
biome check,tsc --noEmit,vitest run --coverage(278 tests)publint,attwandnpm run smokepass locally. CHANGELOG has an Unreleased section.