Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
Feature run: Opening Balances tool (accounting)
- Date: 2026-09-01
- Mode: fully-autonomous
- Request: Add a tool for adding opening balances to Carbon accounts. New screen under Accounting → General Ledger → Opening Balances; set initial GL balance per posting (leaf) account as of a cutover date; on save post one balanced journal entry with a new
'Opening Balance'journalEntrySourceType, auto-plugging the difference to Retained Earnings (accountDefault.retainedEarningsAccount). Reuse getNextSequence → createJournalEntry → saveJournalEntryWithLines → postJournalEntry. Sign conventions via toStoredAmount/toDisplayDebit/toDisplayCredit. Detect existing posted Opening Balance entry and require reversal first (pre-fill from existing). Base currency only. Then use /ui for a Vercel aesthetic. - Phase plan: research [skip — well-understood accounting concept; design already grounded against code + confirmed with user this turn] · spec [skip — design confirmed with user, captured in plan] · plan [run] · execute [run] · ui-polish [run — user explicitly requested /ui with Vercel aesthetic] · test [run — user-facing posting flow] · self-review [run]
Decisions
- Balancing account: Retained Earnings (accountDefault.retainedEarningsAccount) — confirmed with user; matches fixed-asset mid-life registration precedent — 2026-09-01
- Re-run guard: detect existing posted 'Opening Balance' JE, require reversal first, pre-fill form from it — confirmed with user — 2026-09-01
- Currency: base currency only (matches journal editor) — confirmed with user — 2026-09-01
Decisions (cont.)
- 🛑 Plan-approval gate (autonomous): auto-approved plan .ai/plans/2026-09-01-opening-balances.md — 9 tasks, grounded against verified service signatures (createJournalEntry/saveJournalEntryWithLines/postJournalEntry, getNextSequence "journalEntry", getDefaultAccounts.retainedEarningsAccount). Rationale: design pre-confirmed with user; plan only mechanizes it — 2026-09-01
Phase log
- plan: done — .ai/plans/2026-09-01-opening-balances.md
- execute: Tasks 1–8 done. Booted mbabane stack via
crbn up(crbn migrate's postgres-only stack fails on storage.buckets — env limitation). Migration applied + enum verified in DB. Forced POSTING_POLICY entry in @carbon/ee (mirrors Manual, syncable:false). Gates green: typecheck erp+ee, biome lint (7 files), lingui:extract. - DEVIATION: not auto-committing per task — standing user preference "never auto-commit unless explicitly asked" (memory feedback_no_auto_commit) overrides the execute/feature skills' per-task commit. Work left uncommitted for user review.
- ui-polish: done — /ui skill (uidotsh design guidelines: tables/surfaces/typography/colors/shadows). Rewrote OpeningBalancesForm with class-grouped sections (Assets/Liabilities/Equity/Revenue/Expenses), heading-group header w/ inline As-of date + Post, hover rows, Dr/Cr status pills, and a 3-cell divider stat strip (Total debits / Total credits / Retained Earnings plug) with Balanced status. tabular-nums throughout, /60-/40 opacity dividers, rounded-xl bordered surfaces, no shadow+border. Behavior preserved (hidden lines JSON, totals/plug memo, existing-entry branch). Gates green: typecheck erp, biome lint, lingui:extract.
- test: PASS 9/9 (/test skill, agent-browser on erp.mbabane.dev, company "Carbon Development"). Login → preconditions (accounting on, RE default 3100) → nav entry present → empty state renders (class sections + summary strip) → entered $10,000 debit on Bank-Cash (Dr pill, plug $10,000 credit, "Balancing to Retained Earnings") → Post → redirected to JE-2026-09-000001, source "Opening Balance", POSTED, Bank-Cash Dr $10,000 + auto Retained Earnings Cr $10,000, BALANCED → guard banner on re-entry (no editable form) → reversed JE re-enables the form. Screenshots in .ai/scratch/e2e/. Playbook cached at .ai/playbooks/opening-balances.md. Also fixed a copy nit (Plural: "1 account with a balance"); re-verified typecheck+lint+extract green.
- self-review: done. Must-fix caught + fixed:
.pocatalogs had 12.7k-line origin-ref churn (extract didn't run lingui:clean) → ranpnpm lingui:clean, now 961 insertions (new strings only, erp-only). Verified sync-policy enforcement (posting.ts:193syncable===false, models.ts:625, defaultEnabled:false) — Opening Balance never syncs, correct. Sign/plug logic in service matches form preview. Guard is Posted-only + re-checked in action. Docs updated: accounting AGENTS.md (Key Service Functions) + accounting-sync-handlers.md rule. Residual low-sev risks noted (non-atomic create→save→post can orphan a Draft on post failure; plug carries raw float within tolerance) — not blocking, mirror existing manual-JE behavior.
UX pivot (2026-09-01, user feedback: standalone page "really ugly")
- Removed the standalone /x/accounting/opening-balances page, its ui/OpeningBalances/ dir, the path.ts entry, and the nav item (path.ts + useAccountingSubmodules reverted to original — no longer in the diff).
- Reimplemented INLINE on the Chart of Accounts page: a primary "Opening Balances" button (ChartOfAccountsTableFilters) toggles
openingBalanceMode(state lifted into charts.tsx). In mode: each leaf account's balance cell becomes a numeric input (ChartOfAccountsTree), group rows show none; Add Group/Add Account + per-row menus hidden; Cancel + Post shown. Post opens OpeningBalancePostModal (centered ModalDrawer type=modal) collecting the as-of date, submitting to the charts.tsx action. Service/validator/migration/POSTING_POLICY unchanged. Guard: charts loader hides the button when a posted entry exists; action re-checks. - Re-verified in browser: enter mode → 80 inputs, Add buttons gone, Cancel+Post present → entered $25,000 on Bank-Cash → Post modal (date default today) → posted JE (Opening Balance, POSTED, BALANCED) → guard hides button → reversal re-enables → Cancel exits cleanly. Screenshots: .ai/scratch/e2e/coa-*.png. Playbook updated to the inline flow. Docs (AGENTS.md) updated. Copy plural fixed. Gates green: typecheck erp, biome lint, lingui extract+clean.
Outcome
- COMPLETE (uncommitted, per user's no-auto-commit preference). Final surface = inline on Chart of Accounts (no standalone page). All gates green. Ready for the user to review + commit.