Nasaq

Accounting Ledger

A chart of accounts, a balanced journal-entry editor, a trial balance and an account statement, in exact integer money.

PreviewOpen ↗

Code

<JournalEntryEditor  accounts={accounts}  currency="SAR"  number="JE-0009"  onPost={async (entry) => api.postEntry(entry)}/><TrialBalance accounts={accounts} entries={entries} currency="SAR" />

Billing · beta

Live examples and controls: Accounting Ledger in the lab.

Install

npx shadcn@latest add https://docs.nasaqui.com/r/accounting-ledger.json

Four views over the same data. ChartOfAccounts is the tree with balances, JournalEntryEditor writes a balanced entry, TrialBalance proves the books agree and AccountStatement lists one account with a running balance. Only posted entries count. Every amount is an integer in minor units, so a balanced entry is exactly equal.

When to use

  • Bookkeeping screens: charts, manual journals, month-end checks.

When not to use

Import

import { ChartOfAccounts, JournalEntryEditor, TrialBalance, AccountStatement } from "@fadymondy/nasaq/web";

Quick start

<JournalEntryEditor
  accounts={accounts}
  currency="SAR"
  number="JE-0009"
  onPost={async (entry) => api.postEntry(entry)}
/>
<TrialBalance accounts={accounts} entries={entries} currency="SAR" />

API

ChartOfAccounts

PropTypeDefaultDescription
accountsAccountingAccount[]required{ id, code, name, type, parentId?, archived? }.
entriesAccountingEntry[][]Posted ones give each row a balance; a group shows its whole branch.
currencystring"USD" ("SAR" in Arabic)ISO 4217 code.
selectedIdstring | nullnoneHighlighted row.
onSelectAccount(account) => voidnoneOpen the statement.
onAddChild(parent) => voidnoneAdds the "Add sub-account" action.
onArchiveChange(account, archived) => voidnoneAdds archive and restore.
labelsAccountingLedgerLabelsnoneOverrides for the built-in strings.

JournalEntryEditor

PropTypeDefaultDescription
accountsAccountingAccount[]requiredOnly active leaf accounts can be picked.
value / defaultValueJournalEntryEditorValuejournalEntryDraft(){ date, memo, lines }, amounts in minor units.
onValueChange(value) => voidnoneEvery edit.
currencystring"USD" ("SAR" in Arabic)ISO 4217 code.
numberstringnoneShown as the entry number.
onPost(value) => void | Promise<void>noneCalled only for a balanced entry. Throw to keep the editor.
onSaveDraft(value) => void | Promise<void>noneSaves without posting.
readOnlybooleanfalseLocks the fields.
labelsAccountingLedgerLabelsnoneString overrides.

Typing a debit clears the credit on the same line and the other way round. "Balance with this line" fills the amount that makes the entry equal. Post stays disabled and the reasons are listed until the entry has no problems.

TrialBalance and AccountStatement

TrialBalance takes accounts, entries, currency, asOf, includeZero, onSelectAccount. AccountStatement takes account, entries, currency and opening (the balance before the first row).

Maths

accountingNormalSide, accountingSignedBalance, accountingEntryTotals, accountingEntryProblems, accountingBalances({ asOf, rollup }), accountingTrialBalance, accountingStatement and accountingTree are exported and pure, so you can run them on the server too. Assets and expenses grow on the debit side, the rest on the credit side.

Examples

asOf="2026-09-30" cuts the trial balance at a date. includeZero lists idle accounts too.

Accessibility

KeyAction
TabMove across fields, line menus and buttons.
Arrow keysMove in the account picker list.
EnterChoose the highlighted account.
Shift+F10 / MenuOpen the row or line menu (same actions as the ⋯ button).
  • Tables use real th headers. The balanced state is text as well as colour.

RTL & i18n

Built-in English and Arabic. Debit and credit columns swap sides in RTL. Numbers, codes and entry numbers stay left to right, and each figure column is aligned on its decimals.

Styling & tokens

Semantic tokens only. Entry lines are cards below 42rem and a grid above. Target [data-slot="chart-of-accounts"], [data-slot="journal-entry-editor"], [data-slot="trial-balance"], [data-slot="account-statement"].

Do / Don't

  • Do post through your server and re-check the balance there: the maths is exported for that.
  • Do void and re-enter a wrong entry instead of editing a posted one.
  • Don't post to a group account: post to its leaves.

Lab

https://docs.nasaqui.com/?path=/docs/components-billing-accounting-ledger--docs

On this page