/engineering:saas-accounting-systemfrom engineering
Designs double-entry accounting systems for SaaS apps with automated journal postings, ledgers, controls, reconciliations, and reports. Use when building accounting features into a SaaS product.
Ships in engineering. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Acknowledgement: Shared by Peter Bamuhigire, techguypeter.com, +256 784 464178.
| Input | Required | Use |
|---|---|---|
| Tenant, product, and lifecycle scope | yes | Bound the SaaS decision |
| Current architecture, plans, policies, and constraints | yes | Preserve enforceable behaviour |
| Production data or verified evidence | conditional | Validate thresholds and migrations |
Default to read-only analysis. Change configuration, billing, identity, tenant data, infrastructure, or customer communications only with explicit authority, least-privilege credentials, tenant scope, rollback, and auditable approval. Never expose secrets or cross tenant boundaries.
If production access, policy, telemetry, or authoritative records are unavailable, produce a labelled design or dry-run plan. Do not claim deployment, reconciliation, deletion, delivery, or measured outcomes; list missing evidence and verification.
| Condition | Action | Stop condition |
|---|---|---|
| Tenant isolation, money, identity, or deletion is affected | Require approval and rollback evidence | Scope or authority is ambiguous |
| Evidence supports a reversible change | Stage, test, and record it | Acceptance checks fail |
| Only partial context is available | Return assumptions and validation | A production claim cannot be verified |
| Category | Artifact | Format | Example |
|---|---|---|---|
| Correctness | Double-entry accounting test plan | Markdown doc covering journal balance, period close, and reconciliation scenarios | docs/accounting/double-entry-tests.md |
| Data safety | Chart of accounts and posting rules register | Markdown doc per skill-composition-standards/references/entity-model-template.md covering accounts, posting rules, and audit-trail requirements | docs/accounting/coa-register.md |
references/ directory for deep detail after reading the core workflow below.accounting-finance-controller when the implementation also needs IFRS-aware reporting, management accounting, cost accounting, financial controls, projections, or CFO-grade review beyond the core double-entry engine.For new products that handle money, prefer the stricter companion skill accounting-engine. This file remains useful as legacy implementation detail, but any guidance here must be read subject to these hard rules:
LedgerPostingService.This skill implements a hidden accounting engine inside business applications. End users never see debits, credits, or journal entries — they enter sales, record payments, move inventory. Under the hood, every transaction auto-posts balanced journal entries that accountants and auditors can query at any time.
Philosophy: Users think in business terms. The system thinks in double-entry.
┌─────────────────────────────────────────────────┐
│ USER LAYER (Friendly) │
│ Sales, Purchases, Payments, Inventory, Expenses│
│ → User sees: "Sale #1042 to Customer X: $500" │
└──────────────────────┬──────────────────────────┘
│ auto-posts
┌──────────────────────▼──────────────────────────┐
│ ACCOUNTING ENGINE (Hidden) │
│ Journal Entries, Ledger Postings, Trial Balance│
│ → Engine posts: DR Accounts Receivable $500 │
│ CR Sales Revenue $500 │
└──────────────────────┬──────────────────────────┘
│ aggregates
┌──────────────────────▼──────────────────────────┐
│ REPORTING LAYER (Dual) │
│ User Reports: Sales Summary, Aging, P&L Simple │
│ Accountant Reports: Trial Balance, BS, IS, CF │
└─────────────────────────────────────────────────┘
Every transaction MUST produce balanced journal entries. No exceptions.
SUM(debits) = SUM(credits) — ALWAYS
This is enforced at the database level via stored procedure or trigger. If entries don't balance, the entire transaction rolls back.
The COA is the backbone. Every account has a type that determines its normal balance.
| Type | Code Range | Normal Balance | Examples |
|---|---|---|---|
| Asset | 1000-1999 | Debit | Cash, Bank, AR, Inventory, Equipment |
| Liability | 2000-2999 | Credit | AP, Loans, Tax Payable, Unearned Revenue |
| Equity | 3000-3999 | Credit | Owner's Equity, Retained Earnings |
| Revenue | 4000-4999 | Credit | Sales, Service Income, Interest Income |
| COGS | 5000-5999 | Debit | Cost of Goods Sold, Direct Materials |
| Expense | 6000-6999 | Debit | Rent, Salaries, Utilities, Marketing |
Setup rules:
franchise_id)See: references/chart-of-accounts.md and references/accounting-bookkeeping-erp-patterns.md.
Users never create journal entries manually. Every business transaction has a posting rule.
| User Action | Debit Account | Credit Account |
|---|---|---|
| Record Sale (Invoice) | Accounts Receivable | Sales Revenue |
| Record Sale + Tax | AR + Tax Receivable | Sales Revenue + Tax Payable |
| Receive Payment (Cash) | Cash/Bank | Accounts Receivable |
| Record Purchase | Inventory/Expense | Accounts Payable |
| Pay Supplier | Accounts Payable | Cash/Bank |
| Record Expense | Expense Account | Cash/Bank or AP |
| Inventory Sale (COGS) | Cost of Goods Sold | Inventory |
| Stock Adjustment (+) | Inventory | Inventory Adjustment (Income) |
| Stock Adjustment (-) | Inventory Adjustment (Expense) | Inventory |
| Salary Payment | Salary Expense | Cash/Bank |
| Loan Received | Cash/Bank | Loan Payable |
| Loan Repayment | Loan Payable + Interest Exp | Cash/Bank |
| Depreciation | Depreciation Expense | Accumulated Depreciation |
| Customer Refund | Sales Returns | Cash/Bank or AR |
Multi-line entries: A single sale with tax and discount creates 3+ journal lines, all in one entry. The entry MUST balance.
See: references/journal-posting-rules.md and references/accounting-bookkeeping-erp-patterns.md.
Rule: Never delete a posted journal entry. Always create a reversing entry.
1. User clicks "Void" on a transaction (e.g., Sale Invoice #1042)
2. System marks the original transaction as VOIDED (status change)
3. System auto-creates a REVERSING journal entry:
- Same accounts, opposite directions
- Reference: "REVERSAL of JE-00001042" (the original entry_number, never its id);
the reversal takes the next contiguous number (see `tenant-document-numbering`)
- Same date OR current date (configurable)
4. Original entry + reversal entry net to ZERO
5. All sub-ledger balances update automatically
Original (Sale Invoice #1042):
DR Accounts Receivable 500.00
CR Sales Revenue 500.00
Reversal (Void of #1042):
DR Sales Revenue 500.00
CR Accounts Receivable 500.00
Net effect: ZERO
See: references/void-reversal-patterns.md
-- Chart of Accounts
accounts (id, franchise_id, code, name, type, parent_id,
is_active, normal_balance, created_at)
-- Journal Entries (Header)
journal_entries (id, franchise_id, entry_date, reference_type,
reference_id, narration, is_reversal, reversed_entry_id,
posted_by, status, created_at)
-- Journal Entry Lines (Detail)
journal_entry_lines (id, journal_entry_id, account_id,
debit_amount, credit_amount, narration,
franchise_id, created_at)
-- Fiscal Periods
fiscal_periods (id, franchise_id, period_name, start_date,
end_date, status, closed_by, closed_at)
-- Account Balances (Materialized for performance)
account_balances (id, franchise_id, account_id, period_id,
opening_balance, debit_total, credit_total,
closing_balance, updated_at)
Integrity constraints:
journal_entry_lines.debit_amount and credit_amount are DECIMAL(15,2)franchise_id on every table (multi-tenant isolation)status enum: DRAFT, POSTED, VOIDEDSee: references/schema-design.md
Every finance module must reconcile to the general ledger through control accounts:
Do not let users post directly to control accounts except through controlled adjustment workflows with reason, approval, and audit trail.
When the system supports manufacturing, services, projects, schools, clinics, retail, or ERP management reporting, add cost-centre, profit-centre, project, branch, department, and product dimensions to postings. Use these dimensions for budgets, flexible budget reports, standard-cost variance, contribution margin, activity-based costing, and management packs without corrupting statutory GL structure.
| Report | What User Sees | Data Source |
|---|---|---|
| Sales Summary | Total sales by period, customer, product | Sales transactions |
| Outstanding Invoices | Who owes what, how old | AR sub-ledger |
| Expense Report | Spending by category | Expense transactions |
| Profit & Loss (Simple) | Revenue minus expenses | Income/expense accounts |
| Cash Position | Money in bank/cash | Cash/bank accounts |
| Inventory Value | Stock on hand with cost | Inventory sub-ledger |
| Report | What It Shows | Source |
|---|---|---|
| Trial Balance | All account balances (DR/CR columns) | General Ledger |
| Balance Sheet | Assets = Liabilities + Equity | GL (type 1-3) |
| Income Statement | Revenue - COGS - Expenses = Net Income | GL (type 4-6) |
| Cash Flow Statement | Operating + Investing + Financing | Cash account entries |
| General Ledger Detail | Every entry per account | Journal entries |
| Journal Register | All journal entries chronologically | Journal entries |
| Aged Receivables | AR aging (30/60/90/120 days) | AR sub-ledger |
| Aged Payables | AP aging | AP sub-ledger |
| Audit Trail | Who posted what, when | Journal entries + audit log |
See: references/financial-statements.md
accounts table with COA seed datajournal_entries and journal_entry_lines tablesfiscal_periods tablepostJournalEntry() service function| Area | Skill | How It Applies |
|---|---|---|
| Database schema | mysql-best-practices | DECIMAL(15,2), indexes, FK constraints |
| API endpoints | api-error-handling | Consistent error responses for failed postings |
| Multi-tenancy | multi-tenant-saas-architecture | franchise_id on all tables |
| UI reports | webapp-gui-design | DataTables for ledger, charts for P&L |
| Mobile reports | jetpack-compose-ui | Report screens with tables |
| PDF export | android-pdf-export, report-print-pdf | Financial statement PDFs |
| Security | vibe-security-skill | Protect financial data, audit trail |
| Auth | vibe-security-skill | Permission: who can post/void/view reports |
| Inventory link | inventory-costing-and-stock-accounting (chwezi-accounting-doctrine) | COGS posting on stock movements |
| Testing | sdlc-testing | Test every posting rule, every reversal |
| Implementation | implementation-status-auditor (../../sdlc-meta/implementation-status-auditor/references/plan-implementation.md) | Execute accounting phases with TDD |
| Audit | implementation-status-auditor | Verify accounting system completeness |
| Don't | Do Instead |
|---|---|
| Let users enter journal entries directly | Auto-post from business transactions |
| Use FLOAT for money | Use DECIMAL(15,2) always |
| Delete journal entries | Create reversing entries (void) |
| Skip balance validation | Enforce DR=CR in stored procedure |
| Store calculated balances only | Store individual entries, calculate on demand |
| Mix accounting with business logic | Separate accounting engine as its own service layer |
| Hard-code account codes | Use configurable COA with tenant-specific accounts |
| Skip audit trail | Log every posting with user, timestamp, IP |
| Allow posting to closed periods | Enforce period status check before posting |
| Show debits/credits to end users | Show friendly labels (Income, Payment, etc.) |
Every implementation MUST pass these tests:
SELECT SUM(debit) - SUM(credit) FROM journal_entry_lines = 0.00references/chart-of-accounts.md — COA templates and setupreferences/journal-posting-rules.md — Complete posting rules per transactionreferences/void-reversal-patterns.md — Void mechanics and edge casesreferences/financial-statements.md — Report SQL queries and formatsreferences/schema-design.md — Complete database schema with constraintsreferences/accounting-bookkeeping-erp-patterns.md — bookkeeping, subledger control, ERP finance configuration, cost accounting, management reporting, and acceptance testsNo posting design passes unless entries balance, source events are idempotent, periods and tenants are isolated, reversals preserve history, and control evidence reconciles to reports.
| Artefact | Consumer | Acceptance condition |
|---|---|---|
| SaaS accounting architecture and posting contract | Finance controller and engineering team | Every business event maps to balanced entries, tenant and period controls are enforced, reversals are traceable, and reconciliation evidence is defined |
references/accounting-bookkeeping-erp-patterns.md (opens in a new tab)references/chart-of-accounts.md (opens in a new tab)references/financial-statements.md (opens in a new tab)references/journal-posting-rules.md (opens in a new tab)references/schema-design.md (opens in a new tab)references/void-reversal-patterns.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
double-entry, accounting, ledger, saas-finance, journal-entries
npx claudepluginhub peterbamuhigire/chwezi-dev-engine --plugin engineering169 skills in this plugin
/accounting-engineUse when designing or implementing double-entry accounting policy and an embedded ledger engine for invoices, payments, stock, balanced postings, mapped accounts, idempotency, reversals, period locks, audit trails, and financial statements./accounting-finance-controllerUse when coordinating accounting and finance implementation reviews, doctrine routing, control evidence, remediation priorities, and release decisions across a software system./advanced-testing-strategyUse when designing or reviewing test strategy for production systems, APIs, mobile apps, SaaS platforms, ERP workflows, and AI-enabled systems. Covers unit, integration, contract, end-to-end, regression, release-gate, and risk-based testing decisions.Other plugins' skills for the same job