Per-wallet application: draft integration from upstream PR #138#1
Merged
Conversation
…tead of timestamp)
…ransaction_descriptors()
Extracts the missing-accounts set to a local variable so the error message fits under 160 chars (the project's line-length cap). Behavior is unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Wires the PR's bottom-up per-wallet pieces (transfer_analyzer, global_allocation) into rp2_main by introducing the integration layer eprbell sketched in the design doc and in issue eprbell#135: - AbstractCountry gains get_default_application_method / get_application_methods and the parallel pair for transfer_methods. US opts in to {"universal", "per_wallet"}; all other countries stay universal-only, preserving behavior. - Configuration parses two new INI sections, [application_methods] and [transfer_methods], reusing the year->method shape of [accounting_methods]. - New per_wallet_tax_engine.compute_tax_per_wallet partitions the universal InputData via TransferAnalyzer, runs compute_tax once per wallet with a fresh AccountingEngine, and merges the per-wallet TransactionSets and GainLossSet back into a single ComputedData so report generators run unchanged (matches the wiki: "easy to join before they are passed to generators"). - rp2_main routes to the per-wallet path when [application_methods] selects per_wallet for any year; transfer semantics falls back to the accounting method of the earliest configured year when the user doesn't specify [transfer_methods] (eprbell's option 2). - Smoke tests: per-wallet == universal when there are no transfers; per-wallet runs end-to-end with transfers and preserves every original out/intra transaction in the merged output. Not included (still requires maintainer design input): - GlobalAllocator is not wired in. It belongs at the universal->per_wallet boundary year (e.g. US 2024 -> 2025), which needs a year-aware switch that this draft does not implement. - Transfer semantics is a single method for the whole run. Per-year transfer semantics and strict country-enforced year constraints are deferred. - Fee-split TODOs in transfer_analyzer.py remain untouched; the spot_price=1 TODO in global_allocation.py remains untouched. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
# Conflicts: # src/rp2/accounting_engine.py
tobomobo
added a commit
that referenced
this pull request
Apr 21, 2026
README's per-wallet warnings were verbatim upstream and didn't mention this fork's draft PR eprbell#138 integration or Austrian support. CHANGELOG tracked phases 1-9 but not the (non-phase) per-wallet work from PR #1. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Pulls eprbell's bottom-up per-wallet pieces from upstream PR #138 (transfer_analyzer, global_allocation) and adds the integration layer the maintainer sketched in the design doc and in issue #135. Upstream's author paused the PR in Feb 2026 citing workload. This branch:
eprbell/maininto the PR branch (clean).global_allocation.pylong line).[application_methods]/[transfer_methods], parallel to[accounting_methods]).per_wallet_tax_engine.compute_tax_per_walletthat partitions universalInputDataviaTransferAnalyzer, runscompute_taxper wallet with a freshAccountingEngine, and merges the per-walletTransactionSets andGainLossSetback into a singleComputedDataso report generators run unchanged.rp2_mainto route to the per-wallet path when[application_methods]selectsper_walletfor any year. Transfer semantics falls back to the accounting method of the earliest configured year (eprbell's "option 2" from USA to drop universal application: implement per-wallet application eprbell/rp2#135).bitcoinaustria/main(Austrian fork phases 1-8). One conflict inaccounting_engine.pywhere upstream's per-wallet refactor addedget_acquired_lot_for_timestampand the Austrian fork addedunit_cost_basis_override/taxable_eventkwarg plumbing for pool-based methods; resolved by keeping both —get_acquired_lot_for_taxable_eventforwards the pool override,get_acquired_lot_for_timestampstays taxable-event-free forglobal_allocation.Default behavior is unchanged: if the config omits
[application_methods],Application method: universalis logged and the universal path runs exactly as before.What is not in this PR
These still need upstream maintainer design input before being safe to implement:
GlobalAllocatoris not wired in. It belongs at the universal → per_wallet boundary year (e.g. US 2024 → 2025); that needs a year-scoped switch and a call on how the allocation folds into 2025's opening lots.[transfer_methods]is parsed butTransferAnalyzertakes a single method today.transfer_analyzer.py:117,119,190andspot_price=1inglobal_allocation.py:117are untouched — these are eprbell's own# TODOs flagging open design questions.Test plan
pytest— 200 passed, 108 subtests passed (previously 165, +35 from Austrian phases, +2 new per-wallet smoke tests)mypy src/ tests/— no issues in 96 source filespylint -r n src tests/*.py— 9.99/10 (only pre-existingfixmeTODOs)bandit -r src/— cleanrp2_uswith[application_methods] 2020 = per_walletagainsttest_data.odsemits all 3 reports and logsApplication method: per_wallet (transfer semantics: fifo)[application_methods]logsApplication method: universal🤖 Generated with Claude Code