Skip to content

fix: distinguish opposite-signed amounts during deduplication - #217

Closed
ryanduguid wants to merge 1 commit into
beancount:masterfrom
ryanduguid:fix/opposite-sign-duplicates
Closed

ryanduguid wants to merge 1 commit into
beancount:masterfrom
ryanduguid:fix/opposite-sign-duplicates

Conversation

@ryanduguid

Copy link
Copy Markdown

Fixes #162.

The heuristic comparator uses the absolute ratio of amounts, so an AUD 100 deposit and an AUD 100 withdrawal on the same account can be marked as duplicates. Keep the ratio's sign and skip negative ratios when searching for a matching account/currency pair.

Preserve the existing magnitude tolerance, zero handling, date windows and account-subset rule. Another shared account can still provide a valid match. Add tests for both comparison directions, positive and negative amounts, tolerance bounds, signed zero, incomplete postings and the default importer path. Repeated deposits are still marked as duplicates while withdrawals remain importable.

Validation on Windows with Python 3.12.10 and Beancount 3.2.3:

  • All 14 similarity/extraction tests pass. Before the fix, six opposite-sign comparison subtests and the duplicate-finder regression fail.
  • Full suite: 146 passed, 3 skipped, 16 failed. Untouched upstream: 143 passed, 3 skipped, the same 16 failed test names. Existing failures concern Windows paths, file locks, file identification and related doctests.
  • Ruff 0.12.12 lint and formatting checks pass.
  • Example CLI smoke test, 10 example unit tests, and OFX/UTrade importer tests pass.
  • Acme requires pdftotext, which is unavailable on PATH; CSV-bank reports DocumentNotIdentified. Both also fail on untouched upstream. The combined example ledger commands and Linux/Python/Beancount CI matrix have not been run locally.

No dependencies change.

@ryanduguid
ryanduguid force-pushed the fix/opposite-sign-duplicates branch from 75c7aff to f60dd36 Compare October 21, 2026 21:37
@ryanduguid ryanduguid closed this Oct 22, 2026
@ryanduguid
ryanduguid deleted the fix/opposite-sign-duplicates branch October 27, 2026 01:41
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.

Possible bug: Should heuristic_comparator consider opposite-sign transactions as similar?

1 participant