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.
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
changed title from Profit-per-item graph in the ledger Statistics tab to Cash Flow / Margin toggle on the ledger Statistics profit chart2026-07-30 11:13:40 +02:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
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:GET /ledgers/{ledgerId}/profit, mammon #91).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
ViewLedgerStatistics.vue, styled/wired like the Main/Combined ledger-type switch inEditLedgerModal.vue(plain<button>pair with.switch/.activeclasses, click handlers mutating a ref — no UI-library component).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 (bariskIn/iskOut+ cumulativeprofitline) is reused unchanged — only the data-fetching call switches.gemory/docs/mammon-api.ymlandgemory/src/generated/mammon/once mammon #113 lands.Explicitly out of scope
Acceptance criteria
EditLedgerModal.vue.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).Profit-per-item graph in the ledger Statistics tabto Cash Flow / Margin toggle on the ledger Statistics profit chart