# FunZone Accounting Backend A standalone Django REST service that powers the FunZone accounting app (`funzone-accounting`). It is **fully decoupled** from the main FunZone backend: - It keeps its own database (SQLite by default) with the chart of accounts, journal vouchers, invoices, products, parties, treasury, payroll and settings. - It does **not** have its own user table. Instead it authorizes requests statelessly by validating the **admin JWT** issued by the FunZone backend, using the shared `SECRET_KEY`. Only tokens carrying `is_staff`/`is_superuser` claims (i.e. admin logins) are accepted. Operational data (owners, customers, payments, withdrawals) still comes directly from the FunZone backend; the frontend talks to both services. ## Endpoints Base path: `/api/accounting/` | Resource | Path | Methods | | --- | --- | --- | | Chart of accounts | `accounts/` | GET, POST, PATCH, PUT, DELETE | | Parties | `parties/` | GET, POST, PATCH, PUT, DELETE | | Products | `products/` | GET, POST, PATCH, PUT, DELETE | | Journal vouchers | `vouchers/` | GET, POST, PATCH, PUT, DELETE | | Invoices | `invoices/` | GET, POST, PATCH, PUT, DELETE | | Treasury | `treasury/` | GET, POST, PATCH, PUT, DELETE | | Employees | `employees/` | GET, POST, PATCH, PUT, DELETE | | Payslips | `payslips/` | GET, POST, PATCH, PUT, DELETE | | Company settings | `settings/` | GET, PATCH | | Reset (wipe + reseed) | `reset/` | POST | All payloads use camelCase keys to match the frontend types. ## Setup ```bash cd funzone-accounting-backend python -m venv .venv .venv\Scripts\activate # Windows pip install -r requirements.txt copy .env.example .env # then set SECRET_KEY to match FunZone python manage.py migrate python manage.py runserver 8010 ``` The first `migrate` seeds a clean chart of accounts (zeroed balances) and the default company settings/account mapping. No demo business data is created. ## Auth The frontend logs in via the FunZone admin endpoint (`/api/auth/token/admin/`) and reuses the returned access token for this service. Make sure `SECRET_KEY` here is identical to the FunZone backend's.