Overview
The trial balance is a fundamental accounting report that lists all accounts with their debit and credit balances at a specific point in time. It verifies that the accounting equation holds (debits equal credits) and serves as the foundation for other financial statements.The trial balance is generated from the
TrialBalanceService in packages/core/src/accounting/TrialBalanceService.ts.Report Structure
A trial balance report contains:Metadata
- Company ID: The company for which the report is generated
- As-of Date: The point-in-time date for the report
- Period Start Date (optional): For period-based trial balances showing activity during a specific period
- Currency: The functional currency used for the report
- Generated At: Timestamp when the report was created
- Account Count: Total number of accounts with balances
- Is Balanced: Boolean indicating if debits equal credits
Line Items
Each line item in the trial balance includes:Per accounting convention, each account appears in only one column:
- Debit-balance accounts (Assets, Expenses) show amounts in the debit column
- Credit-balance accounts (Liabilities, Equity, Revenue) show amounts in the credit column
Totals
- Total Debits: Sum of all debit balances
- Total Credits: Sum of all credit balances
Generating a Trial Balance
Select the company and date range
Choose the company and the as-of date for the trial balance. Optionally specify a period start date for period-based reports.
Configure display options
Decide whether to include zero-balance accounts. By default, accounts with zero balances are excluded for cleaner reports.
Generate the report
The service fetches all accounts and posted journal entries, then calculates debit and credit totals for each account using
calculateDebitCreditTotals or calculatePeriodDebitCreditTotals.Service Methods
generateTrialBalance
Generates a complete trial balance report for a company.TrialBalanceReport with metadata, line items, and totals
Errors:
CompanyNotFoundError: Company does not existTrialBalanceNotBalancedError: Debits do not equal credits (data integrity issue)
Report Features
Balance Validation
The trial balance automatically validates the fundamental accounting equation:- Missing journal entry lines
- Incorrect posting logic
- Data corruption
Filtering by Account Type
The report provides helper methods to filter accounts:getLineItemsByType(type): Filter by specific account typebalanceSheetItems: Get all Asset, Liability, and Equity accountsincomeStatementItems: Get all Revenue and Expense accounts
Net Balance Calculation
Each line item can calculate its net balance in the normal direction:- Debit accounts:
debitBalance - creditBalance - Credit accounts:
creditBalance - debitBalance
UI Workflow
- Cumulative Report
- Period Report
- Navigate to Reports → Trial Balance
- Select the company from the dropdown
- Choose the as-of date using the date picker
- Toggle Show zero balances if you want to include accounts with no activity
- Click Generate Report
- Review the report showing all accounts with debit/credit columns
- Verify that Total Debits equals Total Credits at the bottom
Export Options
Trial balance reports can be exported in multiple formats:- PDF: Formatted report suitable for printing
- Excel: Spreadsheet format with debit/credit columns
- CSV: Raw data export for custom analysis
The trial balance serves as the starting point for generating other financial statements including the balance sheet and income statement.
Error Handling
When generating trial balances, the following errors may occur:| Error | Cause | Resolution |
|---|---|---|
CompanyNotFoundError | Invalid company ID | Verify the company exists and is active |
TrialBalanceNotBalancedError | Debits ≠ Credits | Review journal entries for missing lines or incorrect amounts |
Best Practices
- Regular Validation: Generate trial balances regularly (monthly, quarterly) to catch accounting errors early
- Period-Based Reports: Use period-based trial balances to analyze activity within specific date ranges
- Zero Balance Exclusion: Exclude zero balances for cleaner reports when reviewing active accounts
- Multi-Currency: For multi-currency companies, the trial balance uses the functional currency with all transactions translated