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).
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
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 toDailyBalance, andViewLedgerStatistics.vuehides 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}/profitand/ledgers/{ledgerId}/margin.mammon #101(closed) lifted that restriction:FindDailyTradeProfit/FindDailyMarginnow serve combined ledgers by merging per-date rows across the combined ledger's covered main ledgers, the same patternFindDailyValuation/DbDailyBalanceRepositoryalready use for daily balance. gemory should stop excluding combined ledgers from these charts.Scope
gemory/docs/mammon-api.ymlandgemory/src/generated/mammon/from the updated mammon backend as a prerequisite — the checked-in spec still documents a400 "The ledger is the system ledger or a combined ledger"response for/profitand/margin, which is stale relative to #101.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.ViewLedgerStatistics.vue, including thev-if="isMain(ledger)"gate on the mode-switch buttons — all 3 modes become available unconditionally, for both main and combined ledgers.statistics.spec.tsthat assert combined ledgers fall back toDailyBalanceforCashFlow/Marginmodes.ProfitChart.vueneeds no changes — it already callsprofitApi.profitPerDayInLedger(ledgerId)/marginPerDayInLedger(ledgerId)with no ledger-type gating; the restriction was purely upstream.Out of scope
DailyBalancechart convention of rendering the merged series with no special treatment.Acceptance criteria
mammon-api.yml/generated client regenerated and no longer document the old combined-ledger restriction.statistics.spec.tsupdated to reflect that all modes are available for all ledger types.Related
mammon #101(closed).