Balance Sheet
Overview
The Balance Sheet feature in the system is designed to generate a comprehensive report of assets, liabilities, and equity for a specific month and year. This feature fetches transactions for the specified period, categorizes them into assets, liabilities, and equity, and calculates the total values for each category.
Components and Flow
-
API Endpoints:
- Fetch Balance Sheet Data:
- Retrieves balance sheet data for a specific month and year.
- Method: GET
- Endpoint:
/finance/reports/balance-sheet
- Fetch Balance Sheet Data:
-
Database Models:
- Transactions Table:
- Stores information about financial transactions, including date, amount, account, and category.
- Categories Table:
- Stores information about transaction categories, including name and type (asset, liability, equity).
- Accounts Table:
- Stores information about accounts, including names.
- Transactions Table:
-
Implementation Details:
-
fetchBalanceSheetData Function:
- Fetches all transactions for the specified period.
- Fetches categories and accounts to get names and types.
- Aggregates transactions into assets, liabilities, and equity based on categories.
- Calculates the total values for each category.
- Returns the aggregated data in a structured format.
-
BalanceSheet Component:
- Displays the balance sheet data.
- Uses React state to manage loading and data.
- Fetches balance sheet data on component mount.
-
Flow Diagram (Tree-like and Linear)
Users/Clients
|
+---> API Endpoints
|
+---> Fetch Balance Sheet Data (GET /finance/reports/balance-sheet)
|
+---> Fetch Balance Sheet Data Function
|
+---> Fetch Transactions from DB
| |
| +---> Transactions Table
|
+---> Fetch Categories from DB
| |
| +---> Categories Table
|
+---> Fetch Accounts from DB
| |
| +---> Accounts Table
|
+---> Process Transactions
| |
| +---> Aggregate by Category
| | |
| | +---> Classify as Asset, Liability, or Equity
| | |
| | +---> Update Asset Records
| | +---> Update Liability Records
| | +---> Update Equity Records
|
+---> Calculate Totals
| |
| +---> Total Assets
| +---> Total Liabilities
| +---> Total Equity
|
+---> Return Balance Sheet Data
Components
- BalanceSheet Component:
- Props: None
- State:
balanceSheetData: The balance sheet data object.loading: Boolean indicating loading state.
- Effect:
- Fetches balance sheet data on component mount.
- Render:
- Displays loading spinner while data is being fetched.
- Displays balance sheet data once fetched.