feat: add initial balance support to accounts, enhancing account management and balance calculations across components
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user