Device Invoices
:::info Status
Implemented. Source: fastapi-backend/api/v1/endpoints/device_invoices.py.
:::
Sales invoicing for sold device hardware (transmitters, stream players) —
Super Admin only. An invoice bills to exactly one of a mosque (for
transmitters) or a member (for stream players) — enforced by a database
constraint (device_invoices_bill_to_xor). Line items resolve through the
unified device registry, not the legacy
mosque_devices table, and snapshot each device's serial and kind so an
invoice survives the device later being decommissioned.
Lifecycle
Totals (subtotal, discount, tax, total) are computed server-side, never trusted from the client.
API
| Method | Path | Purpose |
|---|---|---|
GET | /api/v1/device-invoices | List invoices |
POST | /api/v1/device-invoices | Create a draft invoice |
GET | /api/v1/device-invoices/{id} | Invoice detail |
PATCH | /api/v1/device-invoices/{id} | Edit a draft |
POST | /api/v1/device-invoices/{id}/issue | draft → issued, assigns invoice number |
POST | /api/v1/device-invoices/{id}/mark-paid | issued → paid |
POST | /api/v1/device-invoices/{id}/cancel | draft/issued → cancelled |
DELETE | /api/v1/device-invoices/{id} | Remove an invoice |
GET | /api/v1/device-invoices/{id}/print | Printable invoice |
GET/PUT | /api/v1/device-invoices/auto-draft-settings | Auto-draft configuration |
Full request/response schemas: API Reference.