Show combined-ledger daily trade profit and margin #53

Closed
opened 2026-09-05 10:15:20 +02:00 by Sirttas · 0 comments
Owner

Summary

The ledger Statistics profit/margin charts currently only work for main (single) ledgers — resolveStatisticsMode (src/ledger/statistics.ts) forces any non-main ledger's mode down to DailyBalance, and ViewLedgerStatistics.vue hides the mode-switch buttons entirely for non-main ledgers (v-if="isMain(ledger)"). This was a workaround for mammon rejecting combined ledgers on /ledgers/{ledgerId}/profit and /ledgers/{ledgerId}/margin.

mammon #101 (closed) lifted that restriction: FindDailyTradeProfit/FindDailyMargin now serve combined ledgers by merging per-date rows across the combined ledger's covered main ledgers, the same pattern FindDailyValuation/DbDailyBalanceRepository already use for daily balance. gemory should stop excluding combined ledgers from these charts.

Scope

  • Regenerate gemory/docs/mammon-api.yml and gemory/src/generated/mammon/ from the updated mammon backend as a prerequisite — the checked-in spec still documents a 400 "The ledger is the system ledger or a combined ledger" response for /profit and /margin, which is stale relative to #101.
  • Remove resolveStatisticsMode (src/ledger/statistics.ts) entirely — there are only 3 statistics modes (CashFlow, Margin, DailyBalance) and all 3 are now valid for every ledger type, so the forcing logic has no remaining case to handle.
  • Remove its call sites in ViewLedgerStatistics.vue, including the v-if="isMain(ledger)" gate on the mode-switch buttons — all 3 modes become available unconditionally, for both main and combined ledgers.
  • Update/remove the now-invalid tests in statistics.spec.ts that assert combined ledgers fall back to DailyBalance for CashFlow/Margin modes.
  • ProfitChart.vue needs no changes — it already calls profitApi.profitPerDayInLedger(ledgerId) / marginPerDayInLedger(ledgerId) with no ledger-type gating; the restriction was purely upstream.

Out of scope

  • Any special UI treatment (indicator, tooltip, etc.) noting that combined-ledger values are aggregated across covered ledgers — follow the existing DailyBalance chart convention of rendering the merged series with no special treatment.

Acceptance criteria

  • Combined ledgers can be selected and switched to Margin or CashFlow (trade profit) mode without falling back to DailyBalance.
  • Values shown for a combined ledger match the sum across its covered main ledgers.
  • mammon-api.yml/generated client regenerated and no longer document the old combined-ledger restriction.
  • statistics.spec.ts updated to reflect that all modes are available for all ledger types.

Related

  • Depended on mammon #101 (closed).
## Summary The ledger Statistics profit/margin charts currently only work for main (single) ledgers — `resolveStatisticsMode` (`src/ledger/statistics.ts`) forces any non-main ledger's mode down to `DailyBalance`, and `ViewLedgerStatistics.vue` hides the mode-switch buttons entirely for non-main ledgers (`v-if="isMain(ledger)"`). This was a workaround for mammon rejecting combined ledgers on `/ledgers/{ledgerId}/profit` and `/ledgers/{ledgerId}/margin`. `mammon #101` (closed) lifted that restriction: `FindDailyTradeProfit`/`FindDailyMargin` now serve combined ledgers by merging per-date rows across the combined ledger's covered main ledgers, the same pattern `FindDailyValuation`/`DbDailyBalanceRepository` already use for daily balance. gemory should stop excluding combined ledgers from these charts. ## Scope - Regenerate `gemory/docs/mammon-api.yml` and `gemory/src/generated/mammon/` from the updated mammon backend as a prerequisite — the checked-in spec still documents a `400 "The ledger is the system ledger or a combined ledger"` response for `/profit` and `/margin`, which is stale relative to #101. - Remove `resolveStatisticsMode` (`src/ledger/statistics.ts`) entirely — there are only 3 statistics modes (`CashFlow`, `Margin`, `DailyBalance`) and all 3 are now valid for every ledger type, so the forcing logic has no remaining case to handle. - Remove its call sites in `ViewLedgerStatistics.vue`, including the `v-if="isMain(ledger)"` gate on the mode-switch buttons — all 3 modes become available unconditionally, for both main and combined ledgers. - Update/remove the now-invalid tests in `statistics.spec.ts` that assert combined ledgers fall back to `DailyBalance` for `CashFlow`/`Margin` modes. - `ProfitChart.vue` needs no changes — it already calls `profitApi.profitPerDayInLedger(ledgerId)` / `marginPerDayInLedger(ledgerId)` with no ledger-type gating; the restriction was purely upstream. ## Out of scope - Any special UI treatment (indicator, tooltip, etc.) noting that combined-ledger values are aggregated across covered ledgers — follow the existing `DailyBalance` chart convention of rendering the merged series with no special treatment. ## Acceptance criteria - [x] Combined ledgers can be selected and switched to Margin or CashFlow (trade profit) mode without falling back to DailyBalance. - [x] Values shown for a combined ledger match the sum across its covered main ledgers. - [x] `mammon-api.yml`/generated client regenerated and no longer document the old combined-ledger restriction. - [x] `statistics.spec.ts` updated to reflect that all modes are available for all ledger types. ## Related - Depended on `mammon #101` (closed).
Sirttas added the
Priority
Low
4
Kind/Feature
Status
To Refine
labels 2026-09-05 10:15:20 +02:00
Sirttas removed the
Status
To Refine
label 2026-09-05 12:26:56 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: eveal/gemory#53