# Accounting

> Double-entry books: a chart of accounts with account roles, journals, fiscal years of periods, balanced journal entries numbered per journal and year, dimensions, exchange rates, tax codes, the trial balance, profit and loss, balance sheet and general ledger, and the period and year-end close.

- Category: Billing & commerce
- Module: `accounting`
- Modes: `managed`, `custom`
- Docs: https://bettersupabase.com/docs/blocks/accounting
- Page: https://bettersupabase.com/blocks/accounting

## Install

```bash
npx better-supabase add accounting
```

The command also installs `updated-at`, `memberships`, `permissions`.

## Configure

Add the block to `better-supabase.config.ts`:

```ts
import { defineConfig } from "better-supabase/config";

export default defineConfig({
  blocks: {
    // Required by accounting; add installs them too.
    "updated-at": {},
    memberships: {},
    permissions: {},
    // Modes: "managed", "custom". The default is "managed".
    accounting: { mode: "managed" },
  },
});
```

## Client

The block has no React entry yet. Its server-side TypeScript is in `better-supabase/blocks/accounting`.

## Events

- `accounting_entry.posted`
- `accounting_entry.reversed`
- `accounting_period.closed`
- `accounting_period.reopened`
- `fiscal_year.closed`

## Related blocks

Requires: [memberships](https://bettersupabase.com/blocks/memberships.md), [permissions](https://bettersupabase.com/blocks/permissions.md)

Works with: [outbox](https://bettersupabase.com/blocks/outbox.md), [audit](https://bettersupabase.com/blocks/audit.md), [data-lifecycle](https://bettersupabase.com/blocks/data-lifecycle.md)

## Recipes

- [Trial balance](https://bettersupabase.com/recipes/trial-balance.md): Total assets, liabilities and equity and this year's net income, then each account's debit, credit and balance with the totals.
