fix: show expenses as absolute value and add balance card to transaction summary
Expenses were displayed as negative values, making it hard to reconcile with individual transactions. Now shown as absolute value since the label and color already convey the sign. Added a Balance card showing the net total. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
a2beb583d1
commit
2e7beea673
4 changed files with 18 additions and 4 deletions
|
|
@ -1,14 +1,16 @@
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Hash, TrendingUp, TrendingDown } from "lucide-react";
|
import { Hash, TrendingUp, TrendingDown, Scale } from "lucide-react";
|
||||||
|
|
||||||
interface TransactionSummaryBarProps {
|
interface TransactionSummaryBarProps {
|
||||||
totalCount: number;
|
totalCount: number;
|
||||||
|
totalAmount: number;
|
||||||
incomeTotal: number;
|
incomeTotal: number;
|
||||||
expenseTotal: number;
|
expenseTotal: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function TransactionSummaryBar({
|
export default function TransactionSummaryBar({
|
||||||
totalCount,
|
totalCount,
|
||||||
|
totalAmount,
|
||||||
incomeTotal,
|
incomeTotal,
|
||||||
expenseTotal,
|
expenseTotal,
|
||||||
}: TransactionSummaryBarProps) {
|
}: TransactionSummaryBarProps) {
|
||||||
|
|
@ -33,12 +35,21 @@ export default function TransactionSummaryBar({
|
||||||
{
|
{
|
||||||
icon: TrendingDown,
|
icon: TrendingDown,
|
||||||
label: t("transactions.summary.expenses"),
|
label: t("transactions.summary.expenses"),
|
||||||
value: expenseTotal.toLocaleString(undefined, {
|
value: Math.abs(expenseTotal).toLocaleString(undefined, {
|
||||||
minimumFractionDigits: 2,
|
minimumFractionDigits: 2,
|
||||||
maximumFractionDigits: 2,
|
maximumFractionDigits: 2,
|
||||||
}),
|
}),
|
||||||
color: "text-[var(--negative)]",
|
color: "text-[var(--negative)]",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
icon: Scale,
|
||||||
|
label: t("transactions.summary.balance"),
|
||||||
|
value: totalAmount.toLocaleString(undefined, {
|
||||||
|
minimumFractionDigits: 2,
|
||||||
|
maximumFractionDigits: 2,
|
||||||
|
}),
|
||||||
|
color: totalAmount >= 0 ? "text-[var(--positive)]" : "text-[var(--negative)]",
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,8 @@
|
||||||
"summary": {
|
"summary": {
|
||||||
"count": "Transactions",
|
"count": "Transactions",
|
||||||
"income": "Income",
|
"income": "Income",
|
||||||
"expenses": "Expenses"
|
"expenses": "Expenses",
|
||||||
|
"balance": "Balance"
|
||||||
},
|
},
|
||||||
"table": {
|
"table": {
|
||||||
"noCategory": "— No category —"
|
"noCategory": "— No category —"
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,8 @@
|
||||||
"summary": {
|
"summary": {
|
||||||
"count": "Transactions",
|
"count": "Transactions",
|
||||||
"income": "Revenus",
|
"income": "Revenus",
|
||||||
"expenses": "Dépenses"
|
"expenses": "Dépenses",
|
||||||
|
"balance": "Solde"
|
||||||
},
|
},
|
||||||
"table": {
|
"table": {
|
||||||
"noCategory": "— Sans catégorie —"
|
"noCategory": "— Sans catégorie —"
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ export default function TransactionsPage() {
|
||||||
|
|
||||||
<TransactionSummaryBar
|
<TransactionSummaryBar
|
||||||
totalCount={state.totalCount}
|
totalCount={state.totalCount}
|
||||||
|
totalAmount={state.totalAmount}
|
||||||
incomeTotal={state.incomeTotal}
|
incomeTotal={state.incomeTotal}
|
||||||
expenseTotal={state.expenseTotal}
|
expenseTotal={state.expenseTotal}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue