# CLAUDE.md This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. ## Project Overview This is a Python-based financial accounting tool that processes CSV data files to generate balance sheets for small businesses or personal accounts. The application reads money flow data (income/expenses) from CSV files and produces formatted balance sheet reports. ## Development Environment - **Python Version**: Python 3.13 - **Virtual Environment**: Located in `venv/` directory - **Dependencies**: pandas, numpy, python-dateutil (managed via pip) ## Key Commands ### Environment Setup ```bash # Activate virtual environment source venv/bin/activate # Install dependencies (if needed) pip install pandas numpy python-dateutil ``` ### Running the Application ```bash # Run the main balance sheet generator python generate_accounts.py # Run with virtual environment activated source venv/bin/activate && python generate_accounts.py ``` ## Code Architecture ### Core Components **`generate_accounts.py`** - Single-file application with these key functions: - `parse_amount()` - Converts currency strings (£X,XXX.XX) to Decimal objects - `load_csv_data()` - Loads and filters CSV files by date range and file pattern - `calculate_balance_sheet()` - Main business logic that processes financial data - `format_currency()` - Formats Decimal values as currency strings - `print_balance_sheet()` - Generates formatted console output - `main()` - Entry point with hardcoded date range (2024-01-06 to 2025-01-15) ### Data Processing Flow 1. **Input Files**: Expects CSV files with specific naming patterns: - `MONEY_IN*.csv` - Income transactions - `MONEY_OUT*.csv` - Expense transactions - `NET_PROFIT*.csv` - Net profit calculations 2. **Processing**: - Parses dates and amounts from CSV data - Filters transactions by date range - Calculates totals and balance sheet line items - Uses Decimal arithmetic for financial precision 3. **Output**: - Formatted balance sheet printed to console - Summary data exported to `balance_sheet_summary.csv` ### File Structure ``` / ├── generate_accounts.py # Main application ├── venv/ # Python virtual environment ├── *.csv # Input CSV files (MONEY_IN*, MONEY_OUT*, NET_PROFIT*) └── balance_sheet_summary.csv # Generated output ``` ## Data Format CSV files should contain: - `Date` column with parseable dates - `Actual Money In`/`Actual Money Out` columns with currency amounts (£X,XXX.XX format) - Files may contain totals/summary rows that are automatically filtered out ## Financial Logic The balance sheet follows basic accounting principles: - Assets = Current Assets (Cash at Bank) - Liabilities = Current + Long-term liabilities (currently zero) - Net Assets = Total Assets - Total Liabilities - Members' Interest = Net Assets - Net Profit = Total Income - Total Expenses