Repository navigation
fix(payables): ignore fava's ^dok-<date> links when keying bills - #14
Merged
Merged
Conversation
`fava.plugins.link_documents`, which `quints init` scaffolds into
main.bean, adds `^dok-<date>` to every transaction with a `document:`.
Bills get it and payments don't, and `payables.bill_id` took a
transaction's only link as the bill id, so each bill split from its
payment:
- with `dok-` as the only link, it became the bill's key while the
payment, linkless, fell back to `<payee> · <amount>`;
- with a real supplier link next to it, the two links pushed the bill
onto the fallback key while the payment was keyed by the real link.
On a real ledger `quints payables` listed every bill as open plus a
negative row for each payment, though Payable:Trade netted to 0.
`bill_id` now ignores links matching `^dok-\d{4}-\d{2}-\d{2}$`. Every
caller goes through it (`_key_for`, `booked_bill`, `compute_from_entries`,
`match.bill_reference_index`). Receivables were already unaffected:
`_INVOICE_ID` rejects `dok-`.
In importing.py, a payment draft matched to a bill keyed by the
payee/amount fallback now carries the key only as `bill:` metadata, not
as a `^link`. `Google · 24.13` is not a valid beancount link, and fallback
keys are now common.
Claude-Session: https://claude.ai/code/session_01Ji4UEwyzrv6U1Qf531NFyo
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.
Problem
fava.plugins.link_documents, whichquints initscaffolds intomain.bean, adds^dok-<date>to every transaction with adocument:. Bills carry it and payments don't.payables.bill_idtook a transaction's only link as the bill id, so each bill split from its payment:dok-was the only link, it became the bill's key. The payment has no link and fell back to<payee> · <amount>, so the two never matched.On a real ledger,
quints payablesshowed every bill as open plus a negative row for each payment, even thoughPayable:Tradenetted to 0.Fix
payables.bill_idignores links matching^dok-\d{4}-\d{2}-\d{2}$. Every caller goes through it (_key_for,booked_bill,compute_from_entries,match.bill_reference_index), so one guard covers them all. Receivables were already unaffected because_INVOICE_IDrejectsdok-.importing.match_payables: when a payment draft is matched to a bill keyed by the payee/amount fallback, the key is set only asbill:metadata, not as a^link. A key likeGoogle · 24.13isn't a valid beancount link, and this fix makes fallback-keyed bills common.Test
test_fava_document_links_are_not_bill_idsintest_payables.pycovers both shapes (lonedok-link, anddok-next to a real link). It fails without the fix and passes with it.Full suite: 351 passed, 1 skipped.
ruff checkandruff formatare clean. Against a real ledger,quints payablesnow reports "Nothing open".🤖 Generated with Claude Code
https://claude.ai/code/session_01Ji4UEwyzrv6U1Qf531NFyo