Cash Flow / Margin toggle on the ledger Statistics profit chart #47

Closed
opened 2026-07-30 07:13:03 +02:00 by Sirttas · 0 comments
Owner

Summary

Add a "Cash Flow" / "Margin" toggle switch to the existing daily-profit chart in the ledger Statistics tab (ViewLedgerStatistics.vue, gemory #39), switching the chart's data source between the two mammon daily-profit endpoints instead of adding a separate chart:

  • Cash Flow — the existing raw ISK-in/ISK-out series (GET /ledgers/{ledgerId}/profit, mammon #91).
  • Margin — the new FIFO-realized-profit series (GET /ledgers/{ledgerId}/margin, mammon #113): profit booked on the sale's date using the price of the specific earlier buy lot(s) it consumes, rather than raw ISK in/out that day.

Both endpoints return the same response shape ({ date, iskIn, iskOut, profit }), so the toggle is purely a data-source swap — no per-mode field mapping needed.

Depends on mammon #113.

Scope

  • Add a two-button toggle switch to ViewLedgerStatistics.vue, styled/wired like the Main/Combined ledger-type switch in EditLedgerModal.vue (plain <button> pair with .switch/.active classes, click handlers mutating a ref — no UI-library component).
  • Toggle drives which mammon client method backs the existing chart: transactionApi.profitPerDayInLedger (Cash Flow, current behavior) vs. the new margin client method generated from mammon #113. Since both return the same DTO shape, the existing chart config (bar iskIn/iskOut + cumulative profit line) is reused unchanged — only the data-fetching call switches.
  • Data source: the generated mammon client's new margin endpoint. Prerequisite: regenerate gemory/docs/mammon-api.yml and gemory/src/generated/mammon/ once mammon #113 lands.
  • Same main-ledger-only gating as today (combined ledgers never call either endpoint).
  • Empty state consistent with the existing empty state, for either mode.
  • Default toggle position: Cash Flow (matches current/existing behavior, no surprise on first load).

Explicitly out of scope

  • Per-item/typeId breakdown — mammon #113 no longer exposes one; this is a same-shape daily series, just a different profit definition.
  • Account-wide (all-ledgers) view.
  • Combined-ledger support (blocked on the backend for both endpoints).
  • Unrealized profit on held stock (already covered by gemory #40's appraised balance).
  • Persisting the toggle choice across sessions/reloads (in-memory component state is enough unless requested later).

Acceptance criteria

  • Statistics tab shows a Cash Flow / Margin toggle next to (or above) the existing daily-profit chart, styled consistently with the Main/Combined switch in EditLedgerModal.vue.
  • Switching the toggle re-renders the chart from the corresponding endpoint's data, for main ledgers, reusing the existing chart config unchanged (no field remapping).
  • Combined ledgers never trigger either endpoint.
  • Empty response renders the existing empty-state message, for either mode.
  • Component/test coverage for both toggle states.

Related

Depends on mammon #113 (Realized profit per day (FIFO) for a single ledger, GET /ledgers/{ledgerId}/margin, same response shape as #91). Extends gemory #39 (Statistics tab).

## Summary Add a "Cash Flow" / "Margin" toggle switch to the existing daily-profit chart in the ledger Statistics tab (`ViewLedgerStatistics.vue`, gemory #39), switching the chart's data source between the two mammon daily-profit endpoints instead of adding a separate chart: - **Cash Flow** — the existing raw ISK-in/ISK-out series (`GET /ledgers/{ledgerId}/profit`, mammon #91). - **Margin** — the new FIFO-realized-profit series (`GET /ledgers/{ledgerId}/margin`, mammon #113): profit booked on the sale's date using the price of the specific earlier buy lot(s) it consumes, rather than raw ISK in/out that day. Both endpoints return the same response shape (`{ date, iskIn, iskOut, profit }`), so the toggle is purely a data-source swap — no per-mode field mapping needed. Depends on mammon #113. ## Scope - Add a two-button toggle switch to `ViewLedgerStatistics.vue`, styled/wired like the Main/Combined ledger-type switch in `EditLedgerModal.vue` (plain `<button>` pair with `.switch`/`.active` classes, click handlers mutating a ref — no UI-library component). - Toggle drives which mammon client method backs the existing chart: `transactionApi.profitPerDayInLedger` (Cash Flow, current behavior) vs. the new margin client method generated from mammon #113. Since both return the same DTO shape, the existing chart config (bar `iskIn`/`iskOut` + cumulative `profit` line) is reused unchanged — only the data-fetching call switches. - Data source: the generated mammon client's new margin endpoint. Prerequisite: regenerate `gemory/docs/mammon-api.yml` and `gemory/src/generated/mammon/` once mammon #113 lands. - Same main-ledger-only gating as today (combined ledgers never call either endpoint). - Empty state consistent with the existing empty state, for either mode. - Default toggle position: Cash Flow (matches current/existing behavior, no surprise on first load). ## Explicitly out of scope - Per-item/typeId breakdown — mammon #113 no longer exposes one; this is a same-shape daily series, just a different profit definition. - Account-wide (all-ledgers) view. - Combined-ledger support (blocked on the backend for both endpoints). - Unrealized profit on held stock (already covered by gemory #40's appraised balance). - Persisting the toggle choice across sessions/reloads (in-memory component state is enough unless requested later). ## Acceptance criteria - [x] Statistics tab shows a Cash Flow / Margin toggle next to (or above) the existing daily-profit chart, styled consistently with the Main/Combined switch in `EditLedgerModal.vue`. - [x] Switching the toggle re-renders the chart from the corresponding endpoint's data, for main ledgers, reusing the existing chart config unchanged (no field remapping). - [x] Combined ledgers never trigger either endpoint. - [x] Empty response renders the existing empty-state message, for either mode. - [x] Component/test coverage for both toggle states. ## Related Depends on mammon #113 (`Realized profit per day (FIFO) for a single ledger`, `GET /ledgers/{ledgerId}/margin`, same response shape as #91). Extends gemory #39 (Statistics tab).
Sirttas added the
Priority
Medium
3
Status
To Refine
Kind/Feature
labels 2026-07-30 07:13:03 +02:00
Sirttas changed title from Profit-per-item graph in the ledger Statistics tab to Cash Flow / Margin toggle on the ledger Statistics profit chart 2026-07-30 11:13:40 +02:00
Sirttas removed the
Status
To Refine
label 2026-07-30 11:13:44 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: eveal/gemory#47