# Accounting Service

> Status: **Active** — Phases 5.1 through 5.11 implemented (v0.5.11.0).

## Responsibilities

- حسابداری ۴ سطحی، موتور ثبت مرکزی (ADR-010)
- دفتر کل، خزانه، AR/AP، یکپارچه‌سازی فروش/خرید/موجودی
- دارایی ثابت، حقوق و دستمزد
- گزارش‌گیری مالی، انطباق و حاکمیت

## API Groups

| Prefix | Phase |
| --- | --- |
| `/api/v1/accounts` | 5.1 |
| `/api/v1/fiscal` | 5.1, 5.3 |
| `/api/v1/posting` | 5.2 |
| `/api/v1/ledger` | 5.3 |
| `/api/v1/treasury` | 5.4 |
| `/api/v1/ar-ap` | 5.5 |
| `/api/v1/sales-accounting` | 5.6 |
| `/api/v1/purchase-inventory` | 5.7 |
| `/api/v1/assets` | 5.8 |
| `/api/v1/payroll` | 5.9 |
| `/api/v1/reporting` | 5.10 |
| `/api/v1/compliance` | 5.11 |

## Key Engines

| Engine | Phase | Rule |
| --- | --- | --- |
| PostingEngine | 5.2 | Sole creator of JournalEntry |
| BalanceEngine | 5.3 | Ledger balances |
| InventoryValuationEngine | 5.7 | Valuation separated from posting |
| DepreciationEngine | 5.8 | Asset depreciation |
| PayrollEngine | 5.9 | Salary calculation |
| FinancialReportEngine | 5.10 | Reports from posted data only |
| AuditFramework | 5.11 | Immutable audit trail |

## Run

```bash
cd backend/services/accounting
pytest -q   # 21 tests
uvicorn app.main:app --port 8002 --reload
```

## Related Documents

- [Phases 5.1–5.11](../../../docs/phases/Accounting/README.md)
- [ADR-010](../../../docs/architecture/adr/ADR-010.md)
