Feat/portfolio value helper#434
Merged
Chucks1093 merged 3 commits intoJun 23, 2026
Merged
Conversation
Pure helper that accepts an array of holding entries (balance + currentPrice) and returns the summed total portfolio value as a string. Designed for reuse across the holdings endpoint and any future summary endpoints.
- Add HoldingItemSchema and HoldingsResponseSchema to ownership schemas - Update controller to transform records, inject currentPrice, and include total_portfolio_value in the response
Covers single entry, multiple holdings, zero prices, zero balances, and empty array edge cases.
3 tasks
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.
closes #430
Here's a summary of the 3 commits:
Commit 1 (
8217b02) —ownership.utils.tswithcalculateTotalPortfolioValue(entries)— pure function that sumsbalance × currentPriceacross entries and returns a string.Commit 2 (
58f8384) — Updatedownership.schemas.ts(addedHoldingItemSchema,HoldingsResponseSchema) andownership.controllers.ts(transforms records, uses helper, wraps response withholdings+total_portfolio_value).Commit 3 (
76a74b2) —ownership.utils.test.tswith 5 test cases: single entry, multiple holdings, all zero prices, all zero balances, empty array.Acceptance criteria verified:
total_portfolio_valuefield