Commerce General Ledger
Double-entry accounting with chart of accounts, journal entries, period management, and financial statement generation.
How It Works
- Set up the chart of accounts with account hierarchy.
- Open accounting periods (monthly, quarterly, yearly).
- Post journal entries with balanced debits and credits.
- Configure auto-posting rules for commerce transactions.
- Generate trial balance, balance sheet, and income statement.
- Close periods to lock posted entries.
Usage
- CLI:
stateset gl ... or stateset "trial balance for Q1 2025"
- Writes require
--apply.
- MCP tools:
list_gl_accounts, create_gl_account, update_gl_account, list_gl_periods, create_gl_period, close_gl_period, create_journal_entry, post_journal_entry, void_journal_entry, get_trial_balance, get_balance_sheet, get_income_statement, configure_auto_posting.
Permissions
- Read:
list_gl_accounts, list_gl_periods, get_trial_balance, get_balance_sheet, get_income_statement — no --apply needed.
- Write:
create_gl_account, create_journal_entry, post_journal_entry, void_journal_entry, close_gl_period — requires --apply.
Examples
stateset --db ./store.db "list gl accounts type=Expense"
stateset --db ./store.db "create journal entry period=2026-03 debit=5100:1500 credit=1000:1500" --apply
stateset --db ./store.db "get trial balance period=2026-03"
stateset --db ./store.db "close gl period period=2026-02" --apply
Account Types
- Asset (normal debit), Liability (normal credit), Equity (normal credit), Revenue (normal credit), Expense (normal debit)
- 25+ subtypes: Cash, AccountsReceivable, Inventory, FixedAssets, AccountsPayable, SalesRevenue, COGS, etc.
Status Flows
Period: Future -> Open -> Closed -> Locked
Journal Entry: Draft -> Pending -> Posted (or Voided/Reversed)
Journal Entry Sources
- Manual, AutoInvoice, AutoPayment, AutoBill, AutoBillPayment, AutoInventory, AutoWriteOff, SystemClosing, Import
Output
{"status":"posted","journal_entry_id":"JE-2025-0100","period":"2025-01","total_debits":1500.00,"total_credits":1500.00,"amount":1500.00}
Present Results to User
- Journal entry number and posting status.
- Debit/credit totals (must balance).
- Affected accounts and running balances.
- Period status and closing readiness.
Troubleshooting
- Entry won't post: verify debits equal credits.
- Period locked: cannot post to a locked period; use adjusting entries in the next open period.
- Account inactive: reactivate account or use a different posting account.
- Trial balance out of balance: check for unposted draft entries or partial reversals.
Error Codes
GL_UNBALANCED_ENTRY: Journal entry debits and credits do not balance.
GL_PERIOD_LOCKED: Cannot post to a locked accounting period; use the next open period.
GL_ACCOUNT_INACTIVE: Target GL account is inactive; reactivate or choose a different account.
Related Skills
- commerce-accounts-receivable: AR transactions auto-post to revenue and receivable accounts.
- commerce-accounts-payable: AP transactions auto-post to expense and payable accounts.
- commerce-credit: Write-offs post to bad debt expense accounts in GL.
References
- references/gl-accounts.md
- /home/dom/stateset-icommerce/crates/stateset-core/src/models/general_ledger.rs
- /home/dom/stateset-icommerce/crates/stateset-embedded/src/general_ledger.rs
1---2name: commerce-general-ledger3description: Manage the general ledger, chart of accounts, journal entries, and financial statements. Use when posting transactions, closing periods, or generating trial balance and financial reports.4---56# Commerce General Ledger78Double-entry accounting with chart of accounts, journal entries, period management, and financial statement generation.910## How It Works11121. Set up the chart of accounts with account hierarchy.132. Open accounting periods (monthly, quarterly, yearly).143. Post journal entries with balanced debits and credits.154. Configure auto-posting rules for commerce transactions.165. Generate trial balance, balance sheet, and income statement.176. Close periods to lock posted entries.1819## Usage2021- CLI: `stateset gl ...` or `stateset "trial balance for Q1 2025"`22- Writes require `--apply`.23- MCP tools: `list_gl_accounts`, `create_gl_account`, `update_gl_account`, `list_gl_periods`, `create_gl_period`, `close_gl_period`, `create_journal_entry`, `post_journal_entry`, `void_journal_entry`, `get_trial_balance`, `get_balance_sheet`, `get_income_statement`, `configure_auto_posting`.2425## Permissions2627- Read: `list_gl_accounts`, `list_gl_periods`, `get_trial_balance`, `get_balance_sheet`, `get_income_statement` — no `--apply` needed.28- Write: `create_gl_account`, `create_journal_entry`, `post_journal_entry`, `void_journal_entry`, `close_gl_period` — requires `--apply`.2930## Examples3132```bash33stateset --db ./store.db "list gl accounts type=Expense"34stateset --db ./store.db "create journal entry period=2026-03 debit=5100:1500 credit=1000:1500" --apply35stateset --db ./store.db "get trial balance period=2026-03"36stateset --db ./store.db "close gl period period=2026-02" --apply37```3839## Account Types4041- Asset (normal debit), Liability (normal credit), Equity (normal credit), Revenue (normal credit), Expense (normal debit)42- 25+ subtypes: Cash, AccountsReceivable, Inventory, FixedAssets, AccountsPayable, SalesRevenue, COGS, etc.4344## Status Flows4546**Period:** Future -> Open -> Closed -> Locked47**Journal Entry:** Draft -> Pending -> Posted (or Voided/Reversed)4849## Journal Entry Sources5051- Manual, AutoInvoice, AutoPayment, AutoBill, AutoBillPayment, AutoInventory, AutoWriteOff, SystemClosing, Import5253## Output5455```json56{"status":"posted","journal_entry_id":"JE-2025-0100","period":"2025-01","total_debits":1500.00,"total_credits":1500.00,"amount":1500.00}57```5859## Present Results to User6061- Journal entry number and posting status.62- Debit/credit totals (must balance).63- Affected accounts and running balances.64- Period status and closing readiness.6566## Troubleshooting6768- Entry won't post: verify debits equal credits.69- Period locked: cannot post to a locked period; use adjusting entries in the next open period.70- Account inactive: reactivate account or use a different posting account.71- Trial balance out of balance: check for unposted draft entries or partial reversals.7273## Error Codes7475- `GL_UNBALANCED_ENTRY`: Journal entry debits and credits do not balance.76- `GL_PERIOD_LOCKED`: Cannot post to a locked accounting period; use the next open period.77- `GL_ACCOUNT_INACTIVE`: Target GL account is inactive; reactivate or choose a different account.7879## Related Skills8081- **commerce-accounts-receivable**: AR transactions auto-post to revenue and receivable accounts.82- **commerce-accounts-payable**: AP transactions auto-post to expense and payable accounts.83- **commerce-credit**: Write-offs post to bad debt expense accounts in GL.8485## References86- references/gl-accounts.md87- /home/dom/stateset-icommerce/crates/stateset-core/src/models/general_ledger.rs88- /home/dom/stateset-icommerce/crates/stateset-embedded/src/general_ledger.rs