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

@@ -4,6 +4,7 @@ import { useState } from "react";
import { DraggableFolderItem } from "./draggable-folder-item";
import { DraggableAccountItem } from "./draggable-account-item";
import type { Folder as FolderType, Account } from "@/lib/types";
import { getAccountBalance } from "@/lib/account-utils";
interface FolderTreeItemProps {
folder: FolderType;
@@ -35,7 +36,10 @@ export function FolderTreeItem({
(folder.id === "folder-root" && a.folderId === null)
);
const childFolders = allFolders.filter((f) => f.parentId === folder.id);
const folderTotal = folderAccounts.reduce((sum, a) => sum + a.balance, 0);
const folderTotal = folderAccounts.reduce(
(sum, a) => sum + getAccountBalance(a),
0,
);
return (
<div>