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.
Bank Reconciliation — Research Notes
Date: 2026-07-02 · Feeds spec:
.ai/specs/2026-07-02-bank-reconciliation.md
Part 1 — Carbon codebase findings
GL accounts & the bank-account gap
accounttable (20230330024715_accounts.sql):id(xid),number,name,class(Asset/…),incomeBalance,accountTypeTEXT — bank accounts areaccountType = 'Bank'(also'Cash'), scoped bycompanyGroupId(accounts are group-shared, not per-company).- All modern FK references use
account.id, neveraccount.number(ar-ap-payments migration backfilled legacy number refs). - There is no bank-account master entity — no bank name, masked account number, per-account currency, or feed linkage.
payment.bankAccount(TEXT NOT NULL →account.id) points straight at the GL account. accountDefault(PK = companyId) hasbankCashAccount,bankLocalCurrencyAccount,bankForeignCurrencyAccountdefaults, plus (new in ar-ap-payments)realizedExchangeGainAccount/realizedExchangeLossAccount,customerWriteOffAccount/supplierWriteOffAccount— all →account.id.
AR/AP payments (20260630093809_ar-ap-payments.sql — shipped 2 days ago)
payment:idxid,paymentIdreadable (PAY-%{yyyy}-%{mm}-, size 6, viagetNextSequence(client, "payment", companyId)),paymentTypeenum Receipt|Disbursement,statusDraft|Posted|Voided, exactly-one customerId/supplierId (CHECK),paymentDate,postingDate,currencyCode,exchangeRate,totalAmount >= 0,bankAccount→ account.id,reference,memo,journalId, posted/voided audit cols,companyId,customFields. RLS usesinvoicing_*permissions.memo: credit/debit memos, same lifecycle shape.invoiceSettlement: funding source (paymentId XOR memoId) × target (salesInvoice/purchaseInvoice/memo),appliedAmount/discountAmount/writeOffAmount,sourceExchangeRate/targetExchangeRate, generatedfxGainLossAmount,appliedViaPaymentId.- Posting is base-currency:
post-paymentedge fn computespaymentTotalBase = totalAmount * exchangeRateand insertsjournalLinerows in base currency (build-payment-journal.ts). Voiding posts mirror lines (amount: -line.amount) — never deletes.
Journal structure
journal:id=id('je'),journalEntryIdreadable (JE-%{yyyy}-%{mm}-),description,postingDate,statusDraft|Posted|Reversed,sourceTypeenum (Manual, Purchase Receipt/Invoice, Sales Invoice/Shipment, Inventory Adjustment, Payment, Credit Memo, Debit Memo, …),accountingPeriodId,reversalOfId/reversedById, posted audit cols,companyId.journalLine:idxid,journalId(CASCADE),accountId→ account.id,description,amountclass-signed natural balance (Asset: positive = debit = cash inflow),journalLineReference(uuid),companyId,companyGroupId. No date on the line — joinjournal.postingDate.journalLineDimensionfor analytics tags.postJournalEntry(client, id, userId)validates Draft + balanced then flips to Posted.reverseJournalEntrycreates a mirror entry.- GL lines are stored in base currency; multi-currency documents carry
exchangeRateand post translated amounts.exchangeRateHistorytable exists ((currencyCode, effectiveDate, companyGroupId) unique).
Accounting module layout
- One service file:
apps/erp/app/modules/accounting/accounting.service.ts(~2.5k lines) — bank rec functions must go here (feedback memory: never scatter service/models files). Models →accounting.models.ts; heavy Kysely transactions →accounting.server.ts(precedent:postDepreciationRun). - Routes:
apps/erp/app/routes/x+/accounting+/— list pages (journals.tsx,charts.tsx,fixed-assets.tsx), drawer child routes (charts.$accountId.tsx,journals.new.tsx) per Drawer-overlay convention. - Sidebar:
ui/useAccountingSubmodules.tsxgroups — Reports / General Ledger / Fixed Assets / Configure; gated byaccountingEnabledsetting +accounting_view. - Periods:
accountingPeriodwithclosedAt/closedBy;getOrCreateAccountingPeriod(client, companyId, date)is the posting gate. Period-closing spec in flight (2026-07-02) addscloseStatusOpen|Locked|Closed + close-readiness checklist — bank rec should integrate (readiness warning + reconciliation vs locked periods).
Integration framework (Xero = precedent)
- Registry:
packages/ee/src/index.tsintegrationsarray; per-integrationpackages/ee/src/{id}/config.tsx(+hooks.server.tsregistered inpackages/ee/src/hooks.server.ts— onInstall/onUninstall/onHealthcheck). companyIntegrationtable: PK (id,companyId),metadataJSON (stores OAuth tokens plaintext JSONB — Xero access/refresh tokens live here),active. One row per integration per company.externalIntegrationMapping: (entityType,entityId,integration,externalId,companyId) with unique constraints — used for idempotent CSV + Xero sync.- OAuth flow:
apps/erp/app/routes/api+/integrations.xero.install.ts(redirect out) +integrations.xero.oauth.ts(callback, token exchange, upsert metadata, onInstall hook). - Webhooks:
apps/erp/app/routes/api+/webhook.xero.ts— HMAC verify against raw body, map tenant → company, fire Inngest event. Env secrets inpackages/env/src/index.tsviagetEnv(...). - Inngest:
packages/jobs/src/inngest/functions/integrations/…; event namescarbon/<task-id>; app code callstrigger("task-id", payload)mapped inpackages/lib/src/trigger.ts+ typed inpackages/lib/src/events.ts.
CSV import pipeline (precedent for statement upload)
- Client:
apps/erp/app/components/ImportCSVModal/— react-dropzone + PapaParse preview → upload toprivatebucket at${companyId}/imports/${nanoid()}.csv→ FieldMappings UI (column → field, enum mappings) → POSTx+/shared+/import.$tableId.tsx. - Mappings/permissions/schemas:
apps/erp/app/modules/shared/imports.models.ts(fieldMappings,importPermissions,importSchemas). - Edge fn
import-csv: downloads from bucket, parses (Deno std csv), classifies rows insert/update/skip, transaction-wrapped writes, idempotency viaexternalIntegrationMapping(integration = "csv"). - Storage:
privatebucket, path convention${companyId}/….
Plaid status
- Zero Plaid references in repo; no fintech SDKs in any package.json.
PLAID_CLIENT_ID/PLAID_SECRETwould follow thepackages/envgetEnvpattern (optional → integration hides itself when unset, like Xero).
Part 2 — Industry research (SAP, NetSuite, Xero/QBO, Plaid, audit practice)
Method: deep-research workflow (fan-out search → fetch → 3-vote adversarial verification). 16 claims survived verification before the session usage limit killed the Xero/Plaid verification passes and synthesis; the "verified" subsection below cites sources, the "model knowledge" subsection is unverified-but-stable public-documentation knowledge, labeled as such.
Verified claims (adversarially checked, cited)
SAP Electronic Bank Statement (EBS) — help.sap.com
- Supported statement formats: SWIFT MT940, MultiCash, BAI, XML; import requires a format code (M = MultiCash, S = MT940, X = XML).
- ISO 20022 camt mapping: camt.052 = intraday (MT942), camt.053 = end-of-day statement (MT940 equivalent), camt.054 = debit/credit notification (MT900/910). Custom/bank-specific XML needs per-format XSL transformation or BAdI
FIEB_MAPPING_X. - FF.5 (RFEBKA00) imports a single file per run; multi-file needs FEB_FILE_HANDLING (app-server only).
- Posting configuration is a fixed chain: account symbols → assign G/L accounts → posting-rule keys → posting rules → transaction types → assign external transaction codes (bank-provided) to posting rules → assign bank accounts to transaction types. I.e., SAP's "rules engine" is code-driven: the bank's transaction-type code on each statement line selects the posting rule.
NetSuite — docs.oracle.com NetSuite help, chapter_4842302228, section_159010939426
- Intelligent Transaction Matching auto-runs at bank-data import time (plus manual re-run); matches imported bank lines against account (GL) transactions; manual matching is for exceptions.
- Two rule tiers: immutable System Rules + ordered, user-editable User Rules, subdivided into Matching Rules and Auto-Create Rules.
- Auto-Create Rules (2020.2+) create-and-match transactions from unmatched bank lines — limited to deposits/charges for bank accounts (charges/refunds for credit-card accounts).
- Ambiguity refusal: if a rule finds ≥2 candidate matches for one bank line, NetSuite makes no match; user picks manually.
- Two-stage flow: Match Bank Data page (side-by-side grids; actions: match, mark cleared, exclude, review, submit) → Reconcile Account Statement page (operates only on submitted/cleared items; include/exclude → reconcile). Status progression: matched/user-cleared → submitted/cleared → reconciled.
- Bank feeds via aggregators (Salt Edge named for Europe; US/Canada partner unnamed in docs). File import supports CAMT.053, MT940, BAI2, OFX/QFX, manual or automated via SFTP.
- Hard 1:1 currency constraint: bank-feed import fails outright if the GL account currency ≠ connected bank account currency (no conversion).
Xero — central.xero.com
- Reconciliation UX is a two-sided screen: imported bank statement lines on the left, Xero account transactions on the right; reconciling = pairing them.
Model knowledge (NOT adversarially verified — usage limit killed these passes; from stable public docs)
Xero / QuickBooks Online UX (usability benchmark)
- Xero statement lines are first-class, immutable rows; per line the user can Match (to existing transactions, incl. Find & Match for one-to-many), Create (code directly to an account, optionally via bank rules), or Transfer (to another bank account). Minor difference between a match and the line can be booked inline as a bank-fee/minor adjustment.
- Xero bank rules: condition set (payee/description/amount contains-equals) → coding template (account, tax, contact); applied as suggestions on feed lines.
- QBO: "For Review / Categorized / Excluded" tabs; monthly Reconcile module requires statement ending date + ending balance and blocks completion until difference = $0; "undo reconciliation" restricted (accountant role).
- Both produce a reconciliation report: statement balance vs book balance, with outstanding (uncleared) payments and deposits listed — the artifact auditors request.
Plaid (plaid.com/docs)
- Flow: server
POST /link/token/create(products["transactions"], webhook URL) → client opens Link widget →onSuccess(public_token, metadata.accounts)→ serverPOST /item/public_token/exchange→access_token+item_id. One Item per institution login; an Item contains N accounts (account_ids). /transactions/syncis the modern cursor model (replaces/transactions/get): returnsadded/modified/removedarrays +next_cursor+has_more; loop untilhas_more=false; persist cursor per Item.- Webhooks:
SYNC_UPDATES_AVAILABLE(fire a sync),INITIAL_UPDATE/HISTORICAL_UPDATE(legacy-model progress signals),TRANSACTIONS_REMOVED(legacy removal). Item webhooks:ERRORwithITEM_LOGIN_REQUIRED→ re-auth via Link update mode (link_token created with the access_token). Webhook authenticity via JWT inPlaid-Verificationheader (/webhook_verification_key/get). - Sign convention: Plaid
amountis positive for money LEAVING the account (outflow) — must invert for a positive-=-inflow model. - Pending → posted: pending transactions arrive with
pending: true; the posted version arrives as a new transaction carryingpending_transaction_id, and the pending one appears inremoved. transaction_idis unique per Item — safe dedupe key. Sandbox:user_good/pass_good,/sandbox/item/fire_webhook. Pricing: subscription per connected Item/account per month for Transactions (order ~$0.30/connected account/mo at scale; production access requires Plaid approval).
Accounting practice / audit
- The audit artifact is the statement-based reconciliation report: statement ending balance + deposits in transit − outstanding checks = adjusted bank balance ≟ GL book balance; bank-only items (fees, interest, NSF) are posted as adjusting entries before completing.
- Continuous matching (feeds) and periodic statement tie-out are complementary: match continuously, close out per statement. Un-reconciliation should be restricted (latest-first) and audited. Reconciliation adjustments must respect period locks (post through the normal journal gates).
- Segregation of duties: ideally the reconciler is not the person who records cash transactions; at minimum the completed reconciliation records who completed it and when.
Design takeaways for Carbon
- Separate bank account master from the GL account (SAP house bank / NetSuite financial-institution connection), 1:1 with a GL account.
- Statement lines are immutable imported rows with a provider-stable external ID for idempotent re-import (OFX FITID / Plaid transaction_id / content hash for CSV).
- Match at the GL (journal line) level, not the document level — everything that touches the bank GL account is matchable regardless of source (SAP posting area 1, NetSuite "account transactions").
- Auto-match must be conservative: exact amount + date window + exactly one candidate (NetSuite ambiguity refusal); suggestions for the rest.
- Two-stage lifecycle: continuous matching + statement-based close-out with ending-balance tie-out (NetSuite Match → Reconcile; QBO difference-must-be-zero).
- Mirror NetSuite's hard currency constraint in v1: bank account currency must equal company base currency (Carbon posts GL in base currency only; journalLine has no source-currency amount).
- Plaid: store per-Item access tokens + sync cursors in
companyIntegration.metadata(Xero precedent); webhook-triggered incremental sync + scheduled catch-up; invert amount sign at ingest; keep pending lines out of matching.