feat: add initial balance support to accounts, enhancing account management and balance calculations across components

This commit is contained in:
Julien Froidefond
2025-11-30 12:13:02 +01:00
parent c26ba9ddc6
commit 184a073bb1
13 changed files with 117 additions and 30 deletions

View File

@@ -7,6 +7,7 @@ import { Building2, GripVertical, Pencil } from "lucide-react";
import { cn } from "@/lib/utils";
import Link from "next/link";
import type { Account } from "@/lib/types";
import { getAccountBalance } from "@/lib/account-utils";
interface DraggableAccountItemProps {
account: Account;
@@ -19,6 +20,7 @@ export function DraggableAccountItem({
onEditAccount,
formatCurrency,
}: DraggableAccountItemProps) {
const realBalance = getAccountBalance(account);
const {
attributes,
listeners,
@@ -71,10 +73,10 @@ export function DraggableAccountItem({
<span
className={cn(
"text-sm tabular-nums",
account.balance >= 0 ? "text-emerald-600" : "text-red-600"
realBalance >= 0 ? "text-emerald-600" : "text-red-600"
)}
>
{formatCurrency(account.balance)}
{formatCurrency(realBalance)}
</span>
<Button
variant="ghost"