- « 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>
33 lines
1.3 KiB
TypeScript
33 lines
1.3 KiB
TypeScript
import type { CartesSnapshot } from "../../../shared/types";
|
||
|
||
/**
|
||
* The note under « Solde net » (D5, #392). The card shows the net result,
|
||
* every amount of the period; beyond income − expenses, it holds the
|
||
* uncategorized line and the transfers. The note names each part that shows
|
||
* as a whole amount other than zero, as the card rounds them, and is absent
|
||
* when neither does.
|
||
*/
|
||
export function netNote(
|
||
t: (key: string, options?: Record<string, unknown>) => string,
|
||
language: string,
|
||
breakdown: CartesSnapshot["netBreakdown"],
|
||
): string | undefined {
|
||
const format = (amount: number) =>
|
||
new Intl.NumberFormat(language === "fr" ? "fr-CA" : "en-CA", {
|
||
style: "currency",
|
||
currency: "CAD",
|
||
maximumFractionDigits: 0,
|
||
}).format(amount);
|
||
const shows = (amount: number) => Math.round(amount) !== 0;
|
||
const { uncategorized, transfers } = breakdown;
|
||
|
||
if (shows(uncategorized) && shows(transfers)) {
|
||
return t("reports.cartes.netNote.both", {
|
||
uncategorized: format(uncategorized),
|
||
transfers: format(transfers),
|
||
});
|
||
}
|
||
if (shows(uncategorized)) return t("reports.cartes.netNote.uncategorized", { amount: format(uncategorized) });
|
||
if (shows(transfers)) return t("reports.cartes.netNote.transfers", { amount: format(transfers) });
|
||
return undefined;
|
||
}
|