Skip to content

feat: add import/write capabilities and transaction management tools#45

Open
dgehriger wants to merge 3 commits intoma4nn:masterfrom
dgehriger:feat/import-transactions
Open

feat: add import/write capabilities and transaction management tools#45
dgehriger wants to merge 3 commits intoma4nn:masterfrom
dgehriger:feat/import-transactions

Conversation

@dgehriger
Copy link
Copy Markdown
Contributor

@dgehriger dgehriger commented Apr 14, 2026

Summary

This PR adds write/import capabilities to pp-terminal, enabling programmatic creation of transactions, securities, and events in Portfolio Performance XML files — both via MCP tools and the CLI.

Note

This is a substantial feature addition that may be out of scope for the upstream project. I built this for my own use and am sharing it in case it is useful. No hard feelings if it is not accepted — I am happy to maintain it on my fork.

Changes

Commit 1: fix: handle null property values in PP XML v69+ (PR #44)

  • Fix crash when PP XML contains null property values (already merged separately)

Commit 2: feat: add import/write capabilities

  • PpXmlWriter — new module that writes transactions and securities into PP XML files via lxml, preserving existing structure and XStream id/reference semantics
  • Transaction types: BUY, SELL, DIVIDEND, DEPOSIT, WITHDRAWAL, DELIVERY_INBOUND, DELIVERY_OUTBOUND, INTEREST, FEES, TAXES, ACCOUNT_TRANSFER, STOCK_SPLIT
  • Security definitions: add new securities with ISIN, WKN, ticker, price feed
  • Delete: remove transactions by UUID with cross-entry cleanup for transfers
  • 11 MCP tools: import_security, import_buy, import_sell, import_dividend, import_deposit, import_withdrawal, import_delivery_inbound, import_delivery_outbound, import_interest, import_account_transfer, import_stock_split, plus import_fees, import_taxes, delete_transaction
  • CLI import command group with matching subcommands
  • Automatic .bak backup before every write
  • 18+ tests covering all transaction types, backup behaviour, error handling, and full write-parse-query roundtrips

Commit 3: feat: add fees/taxes/delete tools, fix transfer structure

  • Fix add_account_transfer to produce PP-native XStream structure (canonical TRANSFER_IN in destination account, transactionFrom nested in crossEntry)
  • Smart BUY/SELL crossEntry placement based on account/portfolio nesting to satisfy XStream document-order id/reference constraints
  • Cross-currency transfer support (to_amount/to_currency)
  • portfolio_id parameter for multi-currency BUY/SELL setups

Testing

All 251 tests pass. The one pre-existing failure (test_cache_fallback_on_io_error) is unrelated to these changes.

… events

Add PpXmlWriter class for direct XML manipulation of Portfolio Performance files:
- BUY/SELL with cross-linked portfolio + account transactions
- DIVIDENDS, INTEREST, DEPOSIT, WITHDRAWAL (simple account txns)
- DELIVERY_INBOUND/OUTBOUND (portfolio txns without cash leg)
- ACCOUNT_TRANSFER with cross-entry references
- Security definitions and STOCK_SPLIT events
- Automatic .bak backup before writes

Add 11 MCP import tools (import_security, import_buy, import_sell, etc.)
Add CLI 'import' command group with matching subcommands
Add 18 tests covering all transaction types, backup, errors, and roundtrip
- Add import_fees, import_taxes MCP tools and PpXmlWriter methods
- Add delete_transaction MCP tool with cross-entry cleanup
- Fix add_account_transfer to use PP-native XStream structure:
  canonical TRANSFER_IN in destination, transactionFrom in crossEntry
- Add cross-currency transfer support (to_amount/to_currency params)
- Add portfolio_id parameter to add_buy/add_sell for multi-currency
- Smart BUY/SELL crossEntry placement based on account/portfolio
  nesting to satisfy XStream document-order id/reference constraint
- Update tests for new transfer and crossEntry patterns
@dgehriger dgehriger force-pushed the feat/import-transactions branch from 229c9b1 to 0e9dd30 Compare April 14, 2026 17:27
@dgehriger dgehriger marked this pull request as draft April 14, 2026 17:40
@sonarqubecloud
Copy link
Copy Markdown

@dgehriger dgehriger marked this pull request as ready for review April 14, 2026 18:26
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.

1 participant