---
tags: [accounting, model]
module: Accounting
---

# Account

## Connections
[[_Accounting]] · [[[Model]JournalRecord]] · [[AccountingTree]] · [[[Model]User]] · [[[Repo]Repositories]] · [[[Observer]Observers]] · [[[Controller]AccountController]] · [[[Service]AccountServices]] · [[[DB]DatabaseTables]] · [[[Cross]CrossModuleDependencies]]

## Source
```
Modules/Accounting/Models/Account.php
Modules/Accounting/Models/AccountingCategory.php
Modules/Accounting/Models/AccountingSubCategory.php
Modules/Accounting/Models/AccountingTree.php
Modules/Accounting/Models/AccountFiscalYearBalance.php
Modules/Accounting/Models/AccountCustomer.php   ← pivot: Account ↔ Customer
Modules/Accounting/Models/AccountSupplier.php   ← pivot: Account ↔ Supplier
Modules/Accounting/Models/AccountIntegration.php
```

## Responsibilities
- Represents a node in the chart of accounts (debit/credit/balance tracking)
- Organised into a 3-level hierarchy: `AccountingCategory → AccountingSubCategory → Account`
- `AccountingTree` stores the parent–child tree (self-referential via `parent_id`)
- `AccountFiscalYearBalance` stores opening/closing balances per fiscal year
- `AccountCustomer` / `AccountSupplier` are pivot tables linking accounts to Partners module entities

## Key Relationships

| Relation | Type | Target |
|---|---|---|
| subcategory | belongsTo | AccountingSubCategory |
| journalRecords | hasMany | [[[Model]JournalRecord]] |
| tree | hasOne | AccountingTree |
| parentTree | hasOne | AccountingTree |
| fiscalYearBalances | hasMany | AccountFiscalYearBalance |
| customers | via AccountCustomer pivot | [[[Cross]CrossModuleDependencies#Sales]] |
| suppliers | via AccountSupplier pivot | [[[Cross]CrossModuleDependencies#Purchases]] |

## Traits
`AuditableTrait` · `CascadeSoftDeletes` · `HasTranslatableFields` · `SoftDeletes` · `UsesTenantConnection`

## Observer
`AccountObserver` → on `created`: creates `AccountFiscalYearBalance` for current fiscal year; on `updated`: handles status changes → dispatches [[[Job]Jobs#FillOpeningClosingBalance]]

## Category Hierarchy
```
AccountingCategory  (Assets / Liabilities / Equity / Revenue / Expense)
  └─ AccountingSubCategory  (Current Assets / Fixed Assets / …)
       └─ Account  (Cash / AR / AP / …)
            └─ AccountingTree  (parent_id self-reference for nested accounts)
```
