Add a Statistics tab to the ledger view #39

Closed
opened 2026-07-24 14:42:22 +02:00 by Sirttas · 0 comments
Owner

Summary

Add a Statistics tab alongside the existing per-ledger tabs (Balance, Transactions, Acquisitions) in ViewLedger.vue. Its initial content is a daily profit view for the ledger, backed by mammon's existing GET /ledgers/{ledgerId}/profit endpoint (DailyProfitResponse[] = { date, iskIn, iskOut, profit }, one entry per day with ISK activity, ascending by date). The tab is framed as a general "Statistics" home so further per-ledger stats can be added later without another tab.

Note: this reframes the original issue. The endpoint that actually exists returns a per-day cash-flow series (profit = iskIn − iskOut), not the FIFO cost-basis / per-item realized-profit view the issue was originally written against. There is no FIFO cost-basis endpoint; that idea is dropped here.

Scope

  • New Statistics tab + route in ViewLedger.vue and routes.ts, next to the Acquisitions tab:
    • route name viewLedgerStatistics, path statistics, page ViewLedgerStatistics.vue under pages/ledger/.
    • Balance stays the default redirect target; no change to existing tabs' order beyond appending Statistics.
  • Data source: the generated mammon client's GET /ledgers/{ledgerId}/profit. Prerequisite: regenerate gemory/docs/mammon-api.yml and gemory/src/generated/mammon/ from the backend — the endpoint is present in mammon but not yet in the checked-in spec/client. (These are generated files; regenerate, do not hand-edit.)
  • Render a line chart of profit per day (single series, profit over date), fetched via useLedgerParam + useProcessedResource like the other tabs.
  • Chart library: introduce Chart.js via vue-chartjs (new npm dependency) — smallest footprint for a single time series.
  • Show a total profit figure (sum of daily profit) above/beside the chart, using the existing IskLabel.
  • Combined ledgers: the endpoint returns 400 for combined ledgers ("not supported yet"). Only show the Statistics tab when ledger.type === 'MAIN'; combined ledgers never render the tab and the endpoint is never called for them.
  • Empty state: when the endpoint returns an empty list (a ledger with no ISK activity), show a "No trade profit recorded for this ledger" message instead of an empty chart; the total shows 0 ISK.

Out of scope

  • Account-wide (all-ledgers) statistics/profit view — per-ledger tab only.
  • Any FIFO / cost-basis / per-item realized-profit computation or endpoint.
  • ISK-in / ISK-out or cumulative-equity series, and any per-day data table — profit-per-day line + total only for now.
  • Additional statistics beyond daily profit (the tab is named to allow them later, but none are built here).
  • Combined-ledger profit support (blocked on the backend lifting its 400).

Acceptance criteria

  • A Statistics tab appears in the ledger view for main ledgers and routes to viewLedgerStatistics (statistics); it is absent for combined ledgers.
  • The tab renders a Chart.js line chart of daily profit for the selected ledger, sourced from GET /ledgers/{ledgerId}/profit via the regenerated mammon client.
  • A total-profit figure (summed daily profit) is shown via IskLabel.
  • Empty response renders the empty-state message and a 0 ISK total; combined ledgers never trigger the endpoint.
  • Component/test coverage consistent with the other ledger tabs.

Related

  • Backend endpoint already exists: TransactionController#profitPerDayInLedgerGET /ledgers/{ledgerId}/profit in the transaction slice.
  • Follows the per-ledger Acquisitions tab work (gemory #10).
  • Same ledger page as gemory #40 (appraised item value on the balance label).
## Summary Add a **Statistics** tab alongside the existing per-ledger tabs (Balance, Transactions, Acquisitions) in `ViewLedger.vue`. Its initial content is a **daily profit** view for the ledger, backed by mammon's existing `GET /ledgers/{ledgerId}/profit` endpoint (`DailyProfitResponse[]` = `{ date, iskIn, iskOut, profit }`, one entry per day with ISK activity, ascending by date). The tab is framed as a general "Statistics" home so further per-ledger stats can be added later without another tab. Note: this reframes the original issue. The endpoint that actually exists returns a **per-day cash-flow series** (`profit = iskIn − iskOut`), **not** the FIFO cost-basis / per-item realized-profit view the issue was originally written against. There is no FIFO cost-basis endpoint; that idea is dropped here. ## Scope - New `Statistics` tab + route in `ViewLedger.vue` and `routes.ts`, next to the Acquisitions tab: - route name `viewLedgerStatistics`, path `statistics`, page `ViewLedgerStatistics.vue` under `pages/ledger/`. - Balance stays the default redirect target; no change to existing tabs' order beyond appending Statistics. - Data source: the generated mammon client's `GET /ledgers/{ledgerId}/profit`. **Prerequisite:** regenerate `gemory/docs/mammon-api.yml` and `gemory/src/generated/mammon/` from the backend — the endpoint is present in mammon but not yet in the checked-in spec/client. (These are generated files; regenerate, do not hand-edit.) - Render a **line chart of profit per day** (single series, `profit` over `date`), fetched via `useLedgerParam` + `useProcessedResource` like the other tabs. - Chart library: introduce **Chart.js** via **vue-chartjs** (new npm dependency) — smallest footprint for a single time series. - Show a **total profit** figure (sum of daily `profit`) above/beside the chart, using the existing `IskLabel`. - **Combined ledgers:** the endpoint returns 400 for combined ledgers ("not supported yet"). Only show the Statistics tab when `ledger.type === 'MAIN'`; combined ledgers never render the tab and the endpoint is never called for them. - **Empty state:** when the endpoint returns an empty list (a ledger with no ISK activity), show a "No trade profit recorded for this ledger" message instead of an empty chart; the total shows 0 ISK. ## Out of scope - Account-wide (all-ledgers) statistics/profit view — per-ledger tab only. - Any FIFO / cost-basis / per-item realized-profit computation or endpoint. - ISK-in / ISK-out or cumulative-equity series, and any per-day data table — profit-per-day line + total only for now. - Additional statistics beyond daily profit (the tab is named to allow them later, but none are built here). - Combined-ledger profit support (blocked on the backend lifting its 400). ## Acceptance criteria - [x] A `Statistics` tab appears in the ledger view for **main** ledgers and routes to `viewLedgerStatistics` (`statistics`); it is absent for combined ledgers. - [x] The tab renders a Chart.js line chart of daily profit for the selected ledger, sourced from `GET /ledgers/{ledgerId}/profit` via the regenerated mammon client. - [x] A total-profit figure (summed daily profit) is shown via `IskLabel`. - [x] Empty response renders the empty-state message and a 0 ISK total; combined ledgers never trigger the endpoint. - [x] Component/test coverage consistent with the other ledger tabs. ## Related - Backend endpoint already exists: `TransactionController#profitPerDayInLedger` — `GET /ledgers/{ledgerId}/profit` in the `transaction` slice. - Follows the per-ledger Acquisitions tab work (gemory #10). - Same ledger page as gemory #40 (appraised item value on the balance label).
Sirttas added the Kind/Feature
Priority
High
2
Status
To Refine
labels 2026-07-24 14:42:22 +02:00
Sirttas changed title from Add a Trade Profit tab to the ledger view to Add a Statistics tab to the ledger view 2026-07-25 14:43:12 +02:00
Sirttas removed the
Status
To Refine
label 2026-07-25 14:43:13 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: eveal/gemory#39