---
name: core-general-accounts
description: The CORE / general system default-account settings already shown on the first-run /setup "Default Accounts" page (Step 5) — cash, bank, receivable, payable, expense, revenue, notes. Their setting keys, COA code mappings, where they are defined, and where they are consumed when posting. This is the baseline the owner wants to EXTEND with LAB/MFG/HR defaults.
updated: 2026-06-18
---

# Default Accounts — Core / General (the /setup baseline)

> Part of the **default-accounts** KB area. A "default account" = a company setting whose
> stored value is a **GL account id** that the system uses automatically when building
> journal-entry lines. This topic documents ONLY the **7 core/general defaults already on the
> `/setup` page** (Step 5). LAB (LIS), MANUFACTURING (Production) and HR defaults are separate
> topics in this same folder.

## TL;DR

- The `/setup` wizard **Step 5 "Default Accounts"** (i18n `SETUP.DEFAULTS_TITLE` = "الحسابات الافتراضية" / "Default Accounts") writes **7 settings**, all under the `accounting.` namespace, **without** an `_id` suffix:
  `accounting.default_cash_account`, `default_bank_account`, `default_client_account`, `default_supplier_account`, `default_expense_account`, `default_revenue_account`, `default_check_account`.
- ⚠️ **GOTCHA — these 7 keys are NOT in `SettingDefinitionSeeder.php`.** They are stored as **free-form key/value settings** (created on first write). The seeder instead defines a *parallel, different* family of accounting keys (`*_parent_account` codes + `*_account_id` integers) — see [Related-but-distinct](#related-but-distinct-keys).
- ⚠️ **GOTCHA — these 7 defaults are consumed almost entirely on the FRONTEND**, where they **pre-fill the GL-account dropdown** in vouchers / expenses / revenues / invoices / payments / bills / partners. The **backend posting logic does NOT read them** — every voucher/expense/invoice request already carries the chosen `account_id` (e.g. `receiving_account_id`) and the BE posts against that. The only BE reference to anything close is `DoctorCommissionService` reading a *different* key `accounting.default_cash_account_id` (with `_id`) — see below.

---

## The 7 settings on the /setup page

Defined (as constants written by the wizard) in
`/home/moonui/public_html/moon-erp/src/app/features/setup/setup-wizard.component.ts`
— `saveDefaults()` at **lines 674–739**, auto-selected from COA codes in `autoSelectDefaults()` at **lines 656–672**.

| # | Setting key (stored) | AR label (setup page) | EN label | COA code auto-mapped | Purpose |
|---|----------------------|------------------------|----------|----------------------|---------|
| 1 | `accounting.default_cash_account` | حساب الصندوق | Cash Account | `1101` | Default cash / treasury (الصندوق) GL account. Pre-fills the account picker when payment method = cash in expenses, revenues, vouchers, sales/purchase payments. |
| 2 | `accounting.default_bank_account` | حساب البنك | Bank Account | `1102` | Default bank (البنك) GL account. Pre-fills when payment method = bank transfer. |
| 3 | `accounting.default_client_account` | حساب العملاء (المدينون) | Accounts Receivable | `1103` | Default customers / receivables (المدينون) GL account. Pre-fills the receivable side for partner/customer entries. |
| 4 | `accounting.default_supplier_account` | حساب الموردين (الدائنون) | Accounts Payable | `2101` | Default suppliers / payables (الدائنون) GL account. Pre-fills the payable side for partner/supplier entries. |
| 5 | `accounting.default_expense_account` | حساب المصروفات | Expense Account | `5201` (fallback `5101`) | Default parent for the expense-categories tree; pre-fills expense entries when no account is chosen. |
| 6 | `accounting.default_revenue_account` | حساب الإيرادات | Revenue Account | `41` | Default parent for the revenue-categories tree; pre-fills revenue entries when no account is chosen. |
| 7 | `accounting.default_check_account` | حساب أوراق القبض/الدفع | Notes Receivable/Payable | `1104` | Default "notes" / cheques (أوراق القبض والدفع) GL account. Pre-fills when payment method = check. |

> Wizard signal fields: `defaultCash` / `defaultBank` / `defaultReceivable` / `defaultPayable` /
> `defaultExpense` / `defaultRevenue` / `defaultCheckAccount`
> (`setup-wizard.component.ts` **lines 135–141**).
> The dropdown only lists **detail** accounts (`account_type === 'detail'`) — see
> `loadDetailAccounts()` **lines 616–654**.

### i18n keys (setup page labels)
`SETUP.*` block in `src/assets/i18n/{en,ar}.json`:

| Key | en.json line | en text | ar.json line | ar text |
|-----|--------------|---------|--------------|---------|
| `SETUP.STEP_DEFAULTS` | 522 | Defaults | 522 | الافتراضيات |
| `SETUP.DEFAULTS_TITLE` | 556 | Default Accounts | 556 | الحسابات الافتراضية |
| `SETUP.DEFAULTS_DESC` | 557 | Set the default accounting accounts… | 557 | حدد الحسابات المحاسبية الافتراضية… |
| `SETUP.DEFAULT_CASH` | 558 | Cash Account | 558 | حساب الصندوق |
| `SETUP.DEFAULT_BANK` | 559 | Bank Account | 559 | حساب البنك |
| `SETUP.DEFAULT_RECEIVABLE` | 560 | Accounts Receivable | 560 | حساب العملاء (المدينون) |
| `SETUP.DEFAULT_PAYABLE` | 561 | Accounts Payable | 561 | حساب الموردين (الدائنون) |
| `SETUP.DEFAULT_EXPENSE` | 562 | Expense Account | 562 | حساب المصروفات |
| `SETUP.DEFAULT_REVENUE` | 563 | Revenue Account | 563 | حساب الإيرادات |
| `SETUP.DEFAULT_CHECK` | 564 | Notes Receivable/Payable | 564 | حساب أوراق القبض/الدفع |

> Note: the `/setup` step uses the short `SETUP.DEFAULT_*` keys. The standalone **Settings page**
> (`/settings`) re-edits the SAME 7 keys but renders them with longer `SETTINGS.DEFAULT_*_ACCOUNT`
> labels (en.json **lines 1075–1092**, e.g. `DEFAULT_CASH_ACCOUNT` = "حساب النقدية الافتراضي (الخزنة)").

---

## Where the 7 defaults are CONSUMED (mostly FRONTEND)

These keys are read via `SettingService.getByKey('accounting.default_*')` and used to
**pre-select** the GL account in a form — they do not themselves drive a server-side posting.

| Consumer (FE component) | File:line | Keys read | What it pre-fills |
|-------------------------|-----------|-----------|--------------------|
| Settings page (edit all 7) | `features/settings/settings.component.ts:520–554` | all 7 | `loadDefaultAccounts()` reads; `saveDefaultAccount()` writes |
| Setup wizard (first-run) | `features/setup/setup-wizard.component.ts:674–739` | all 7 | writes them on Step 5 |
| Receipt vouchers | `features/receipt-vouchers/receipt-vouchers.component.ts:143,147,151` | cash, bank, check | receiving account by payment method |
| Payment vouchers | `features/payment-vouchers/payment-vouchers.component.ts:137,141,145` | cash, bank, check | paying account by payment method |
| Expenses | `features/expenses/expenses.component.ts:118,122,126` | cash, bank, check | credit/payment account |
| Revenues | `features/revenues/revenues.component.ts:118,122,126` | cash, bank, check | debit/receiving account |
| Expense categories | `features/expense-categories/expense-categories.component.ts:89` | expense | default parent account for the tree |
| Revenue categories | `features/revenue-categories/revenue-categories.component.ts:88` | revenue | default parent account for the tree |
| Partners | `features/partners/partners.component.ts:147,151` | client, supplier | default AR/AP account on a new partner |
| Sales invoices | `features/sales/invoices/invoices.component.ts:373,383,393` | cash, bank, check | payment-on-invoice account |
| Sales payments | `features/sales/payments/payments.component.ts:178,184,190` | cash, bank, check | receiving account |
| Purchase bills | `features/purchases/bills/bills.component.ts:393,403,413` | cash, bank, check | paying account |
| Purchase payments | `features/purchases/payments/payments.component.ts:154,160,166` | cash, bank, check | paying account |

### Backend consumption
- **None of the 7 no-`_id` keys are read by the backend posting code.** A repo-wide grep over
  `Modules/` for `default_cash_account`, `default_bank_account`, `default_client_account`,
  `default_supplier_account`, `default_expense_account`, `default_revenue_account`,
  `default_check_account` returns **zero** server-side hits. Vouchers/expenses/invoices receive an
  explicit `account_id` / `receiving_account_id` in the request body and post against that
  (e.g. `ReceiptVoucherController` eager-loads `receivingAccount` / `bankAccount` —
  `Modules/Accounting/app/Http/Controllers/ReceiptVoucherController.php:54,110,128…`).
- **One near-miss:** `Modules/LIS/app/Services/DoctorCommissionService.php:385` reads
  `accounting.default_cash_account_id` — note the **`_id` suffix**, a *different* key that the
  `/setup` page never writes. This is a latent mismatch (LIS expects `_id`, setup writes
  no-`_id`); flag it if extending the page.

---

## Related-but-distinct keys (defined in the seeder, NOT on /setup)

`SettingDefinitionSeeder` (`Modules/Core/database/seeders/SettingDefinitionSeeder.php`) defines a
**different** accounting family. These DO drive backend posting (partner sub-account creation,
cheques, zakat, WHT) but are **not** the 7 /setup defaults and are **not** on the page:

| Setting key | Def file:line | value_type | Default | Role (BE) |
|-------------|---------------|-----------|---------|-----------|
| `accounting.auto_create_partner_account` | `:197` | boolean | true | auto-create GL sub-account when a partner is created |
| `accounting.ar_parent_account` | `:213` | string (code) | `1103` | parent under which **customer AR sub-accounts** are created (المدينون). The real receivable driver. |
| `accounting.ap_parent_account` | `:229` | string (code) | `2101` | parent for **supplier AP sub-accounts** (الدائنون) |
| `accounting.bank_parent_account` | `:245` | string (code) | `1102` | parent for bank GL sub-accounts |
| `accounting.cash_parent_account` | `:261` | string (code) | `1101` | parent for petty-cash GL sub-accounts |
| `accounting.checks_issued_account_id` | `:309` | integer | null | liability account for issued cheques (≈2103) |
| `accounting.checks_received_account_id` | `:325` | integer | null | asset account for received cheques (≈1103) |
| `accounting.zakat.expense_account_id` | `:341` | integer | null | zakat expense |
| `accounting.zakat.payable_account_id` | `:357` | integer | null | zakat payable |
| `accounting.wht_payable_account_id` | `:373` | integer | null | withholding-tax payable |

> **Naming convention to keep when extending /setup:** the seeder's *true* default-account
> settings use the `*_account_id` (integer) suffix and are registered in the seeder so they appear
> in the Settings UI. The `/setup` page's 7 keys break that convention (no `_id`, not seeded).
> If the owner wants the new LAB/MFG/HR defaults to behave consistently and post on the BE, they
> should follow the **`module.something_account_id` + seeder definition** pattern (as LIS/HRM/Sales/
> Purchases already do) — covered in the sibling topics.

---

## COA codes referenced (standard template)
From `autoSelectDefaults()` (`setup-wizard.component.ts:656–672`), matched against the imported
chart-of-accounts template (`features/accounts/account-templates.ts`):

| Code | Account (AR) | Used for default |
|------|--------------|------------------|
| `1101` | الصندوق / النقدية | cash |
| `1102` | البنك | bank |
| `1103` | الذمم المدينة / العملاء | receivable (client) |
| `1104` | أوراق القبض | notes / check |
| `2101` | الذمم الدائنة / الموردون | payable (supplier) |
| `41`   | الإيرادات | revenue (parent) |
| `5201` / `5101` | المصروفات | expense (parent) |

> ⚠️ Per project memory `[[lis-receivable-header-account-trap]]`: a receivable default must point at
> a **detail leaf** account, never an AR *header*/parent — a JE line cannot post to a header
> account. The /setup picker already filters to `account_type === 'detail'`, but auto-select by
> code (`1103`) can still land on a header if the template made `1103` a parent. Keep this in mind
> when wiring the extended page.

## Quick reference — file map
- FE setup wizard: `/home/moonui/public_html/moon-erp/src/app/features/setup/setup-wizard.component.ts` (Step 5 = lines 131–141, 614–739)
- FE settings page (re-edit): `…/src/app/features/settings/settings.component.ts:520–554`
- i18n: `…/src/assets/i18n/en.json` + `ar.json` (SETUP.* lines 556–564; SETTINGS.DEFAULT_*_ACCOUNT lines 1075–1092)
- BE seeder (distinct keys): `/home/moonui/moon-erp-be/Modules/Core/database/seeders/SettingDefinitionSeeder.php` (accounting block lines 196–384)
- BE near-miss consumer: `/home/moonui/moon-erp-be/Modules/LIS/app/Services/DoctorCommissionService.php:385`
