Simpl-Resultat/src/components/reports/donutParts.ts
le king fu 66c53e69c0 feat(reports): show signed amounts, the net note and money in/out (#392)
- « Solde net » on the Dashboard and Cartes carries a note giving the
  uncategorized and transfer parts of the net result when they are not zero
  (D5): KpiCard takes an optional note, written by the pure netNote.
- Trends' global-flow table gains « Non classé » and « Transferts » columns,
  and its « Net » is the net result of the month.
- A negative amount stays signed in the charts (D7): the stacked bars and
  areas of CategoryOverTimeChart stack it below zero (stackOffset="sign"),
  and its uncategorized series takes its label from i18n; the zoom's donut
  draws the positive parts only and says how many negative ones it leaves out
  (donutParts), the no-data state included.
- The Transactions summary bar reads « Entrées / Sorties / Solde » (D8): its
  sums by sign are a view of the list, not an income statement.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 22:32:46 -05:00

18 lines
686 B
TypeScript

import type { CategoryZoomChild } from "../../shared/types";
/**
* The parts the zoom's donut can draw (D7, #392): the subcategories that show
* a positive amount. A pie cannot draw a negative part — a subcategory whose
* refunds exceed its purchases — so the donut leaves the negative ones out and
* says how many; a zero part never had a visible slice. The figures stay
* signed in the total at the centre and in the table.
*/
export function donutParts(byChild: CategoryZoomChild[]): {
parts: CategoryZoomChild[];
negativeCount: number;
} {
return {
parts: byChild.filter((c) => c.total > 0),
negativeCount: byChild.filter((c) => c.total < 0).length,
};
}