Skip to content

feat(addon-sdk): expose net worth, the one read that includes credit cards - #1797

Open
Bubbles840 wants to merge 1 commit into
wealthfolio:mainfrom
Bubbles840:fix/sdk-account-balance
Open

Bubbles840 wants to merge 1 commit into
wealthfolio:mainfrom
Bubbles840:fix/sdk-account-balance

Conversation

@Bubbles840

Copy link
Copy Markdown
Contributor

Problem

An addon cannot read a credit card's balance.

  • ctx.api.portfolio.getLatestValuations() covers holdings accounts only (holdings_account_ids), and CREDIT_CARD does not support the Holdings purpose. A card is silently absent from the result.
  • Account.balance looks like the answer, but the backend Account model has no balance field. It is typed number in the SDK and is always undefined at runtime.

A budgeting addon that checks balances against a bank feed therefore cannot check cards at all. The workaround is summing the ledger outside the SDK.

Change

  • PortfolioAPI.getNetWorth(date?) forwards the existing net worth read, GET /net-worth, which the app already uses. Its balance sheet itemises every account, including CREDIT_CARD:<accountId> liabilities, and a card in credit appears as CASH:<accountId>. No backend change.
    • It is added to the portfolio permission category, the bridge, the iframe ALLOWED_API_METHODS, and the permission descriptions users see.
    • It is covered by a bridge test that forwards through the permission guard, and by the existing drift test that every bridge method is allow-listed.
  • Account.balance is now optional and @deprecated in the SDK and frontend types, with a pointer to valuations or net worth. Nothing in the app reads it as a real value: two synthetic account objects set it to 0, and the edit modal already defaults it with ?? 0.
  • Docs: a net-worth entry in the addon API reference, with the card-balance recipe, plus changelog entries under Added and Deprecated.

Validation

  • The SDK builds, and tsc --noEmit passes for both the SDK and the frontend.
  • vitest passes for src/addons, src/pages/settings/addons and src/adapters (246 tests).
  • Prettier is clean. ESLint shows no errors on the changed files; the one warning is on an existing line.

I have read and agree to the CLA.

🤖 Generated with Claude Code

…cards

Addons had no way to read a credit card's balance. `getLatestValuations()`
covers holdings accounts only, and CREDIT_CARD is not a holdings account type.
`Account.balance` looked like the answer but is never populated: the backend
account model has no balance field, so it was always undefined while typed
`number`.

- `PortfolioAPI.getNetWorth(date?)` forwards the existing net worth read
  (`GET /net-worth`), whose balance sheet itemises every account, including
  `CREDIT_CARD:<accountId>` liabilities. Wired through the permission list
  (`portfolio` category), the bridge, the iframe allow-list, and the permission
  descriptions shown to users.
- `Account.balance` is optional and deprecated in the SDK and frontend types,
  pointing to valuations or net worth.
- Docs: a Portfolio API net-worth entry with the card-balance recipe.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Helgust added a commit to Helgust/wealthfolio-plus that referenced this pull request Sep 27, 2026
projectionlab-gaps.md compares the addon with ProjectionLab down to
form fields and lists overlaps with Wealthfolio and its open PRs
(wealthfolio#1687 loan terms, wealthfolio#1261 ownership, wealthfolio#1797 getNetWorth).
wealthfolio-plan.md adds phase 5 (gates, five slices, what stays out)
and its progress: the decisions per slice, sources checked against
BOE, the ledger snapshot kept for plans of phases 1-4.

user-guide.md covers amounts per month, other income, one-time
events, loan terms, variable rates and prepayments, lettings and the
IRPF paid the next year.

This branch has not been deployed

No deployments
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