# Brix Accounting API — Features List

Overview of capabilities in the Brix Accounting System API (`brix-accounting-api`). All business endpoints live under `/api/v1` and return JSON.

For endpoint-level detail, see the [API reference](./api/) folder.

---

## Platform

| Feature | Description |
|---------|-------------|
| REST API | Versioned JSON API (`/api/v1`) built on Laravel |
| Token authentication | Laravel Sanctum personal access tokens (`Bearer` token) |
| Multi-company tenancy | Each user belongs to a company; data is scoped automatically via tenant middleware and global scopes |
| Platform administration | `PLATFORM_ADMIN` role can provision tenants via `/api/v1/platform/companies` |
| Role-based access | Four roles — `ADMIN`, `MANAGER`, `CASHIER`, `ACCOUNTANT` — enforced with Spatie Permission and route policies |
| Modular architecture | Domain modules: Auth, Core, Financials, Sales, Purchasing, Payments, Inventory |
| Double-entry ledger | Journal entries are created automatically from business transactions; debits and credits must balance |
| Transaction spine | Invoices, bills, and payments link to a shared `transactions` record for audit and journal resolution |

---

## Authentication & Users

| Feature | Description |
|---------|-------------|
| Login / logout | Issue and revoke Sanctum API tokens |
| Current user profile | `GET /me` returns authenticated user and company context |
| Company profile | View and update company details (`GET`/`PATCH /company`) |
| Platform company provisioning | Create and manage tenants (`/api/v1/platform/companies`) — `PLATFORM_ADMIN` only |
| User administration | Full CRUD for company users (ADMIN only) |
| Role listing | List available system roles (ADMIN only) |
| Active user flag | Users can be deactivated without deletion |

**API docs:** [auth-and-users.md](./api/auth-and-users.md), [company.md](./api/company.md), [platform-companies.md](./api/platform-companies.md)

---

## Chart of Accounts & General Ledger

| Feature | Description |
|---------|-------------|
| Chart of accounts | Hierarchical GL accounts with number, name, type, and sub-type |
| Account types | `ASSET`, `LIABILITY`, `EQUITY`, `INCOME`, `EXPENSE` with typed sub-types (e.g. CASH, AR, AP, INVENTORY_ASSET, SALES_REVENUE) |
| Parent accounts | Nested chart structure via `parent_account_id` |
| Account lifecycle | Create, update, soft-deactivate; delete restricted to ADMIN |
| Role-gated access | Account management limited to ADMIN and ACCOUNTANT |
| Journal entry browser | Read-only list and detail of posted GL entries |
| Auto-generated entries | Entries created when invoices post, bills receive, payments record, or documents void |
| Journal filters | Filter by date range, account, auto-generated flag, or linked transaction |
| Manual journal entries | Not supported via API (system-generated only) |

**API docs:** [accounts.md](./api/accounts.md), [journal-entries.md](./api/journal-entries.md)

---

## Sales (Accounts Receivable)

| Feature | Description |
|---------|-------------|
| Customer management | CRUD for customers with contact info, payment terms, and running balance |
| Sales quotations | Informational quotes with line items — no ledger, inventory, or invoice linkage |
| Sales invoices | Draft invoices with line items (inventory, service, or non-inventory) |
| Invoice posting | Post draft invoices to OPEN — creates AR, revenue, tax, and COGS/inventory journal entries |
| Negative stock (admin) | Optional oversell when company `allow_negative_inventory` is on; estimated COGS at sale, true-up when bills are received — see [negative-stock.md](./api/negative-stock.md) |
| Invoice voiding | ADMIN can void posted invoices with reversing entries |
| Payment status tracking | `DRAFT`, `OPEN`, `PARTIAL`, `PAID`, `VOIDED`, and overdue detection |
| Customer balance | Balance updated automatically from open invoice and payment activity |
| Sales transaction hub | Unified read-only list of invoices and customer payments with filters and Money Bar summary totals |

**API docs:** [customers.md](./api/customers.md), [quotations.md](./api/quotations.md), [invoices.md](./api/invoices.md), [sales-transactions.md](./api/sales-transactions.md)

---

## Purchasing (Accounts Payable)

| Feature | Description |
|---------|-------------|
| Vendor management | CRUD for vendors with contact info, payment terms, and running balance |
| Purchase orders | Informational POs with line items — no ledger, inventory, or bill linkage |
| Vendor bills | Draft bills with line items for expenses and inventory purchases |
| Bill receiving | Receive draft bills to OPEN — posts AP, expense/inventory, and tax; can receive into inventory |
| Bill voiding | ADMIN can void received bills with reversing entries |
| Payment status tracking | Same lifecycle as invoices (`DRAFT` → `OPEN` → `PARTIAL` / `PAID`, or `VOIDED`) |
| Vendor balance | Balance updated automatically from open bill and payment activity |
| Purchase transaction hub | Unified read-only list of bills and bill payments with filters and Money Bar summary totals |

**API docs:** [vendors.md](./api/vendors.md), [purchase-orders.md](./api/purchase-orders.md), [bills.md](./api/bills.md), [purchase-transactions.md](./api/purchase-transactions.md)

---

## Payments

| Feature | Description |
|---------|-------------|
| Customer payments | Record AR payments and allocate to one or more open invoices |
| Bill payments | Record AP payments and allocate to one or more open bills |
| Payment allocation | Partial and full allocations; invoice/bill status updated automatically |
| GL integration | Payment recording creates cash and AR/AP clearing journal entries |
| Read-only history | List and view customer payments and bill payments |

**API docs:** [customer-payments.md](./api/customer-payments.md), [bill-payments.md](./api/bill-payments.md)

---

## Inventory & Catalog

| Feature | Description |
|---------|-------------|
| Item catalog | Products and services with SKU, unit price, unit of measure, and tax flag |
| Item types | `INVENTORY`, `SERVICE`, `NON_INVENTORY` |
| GL account mapping | Per-item income, expense, and asset accounts for posting |
| Quantity on hand | Updated when bills are received into inventory and invoices are posted |
| Reorder points | Low-stock threshold for inventory alerts |
| Item categories | Hierarchical categories for catalog grouping (non-GL) |
| Tax codes | Company VAT rates and exemptions for invoice/bill line tax calculation |
| FIFO costing | First-in-first-out cost layers on inventory receipt |
| COGS on sale | Invoice posting consumes FIFO layers and records cost of goods sold |
| Inventory transaction hub | Unified read-only list of FIFO receipts, sales, and adjustments with running balance |
| Inventory adjustments | Create and list quantity adjustments with full FIFO + GL auto-posting |
| Inventory starting value | Set opening qty + unit cost per item; creates FIFO layer and Dr Inventory / Cr Equity |
| Low-stock report | Items at or below reorder point |
| Stock valuation report | FIFO-based inventory value with optional cost-layer detail |

**API docs:** [items.md](./api/items.md), [item-categories.md](./api/item-categories.md), [tax-codes.md](./api/tax-codes.md), [inventory-transactions.md](./api/inventory-transactions.md), [inventory-adjustments.md](./api/inventory-adjustments.md), [inventory-starting-value.md](./api/inventory-starting-value.md), [reports.md](./api/reports.md) (inventory section)

---

## Financial Reports

| Feature | Description |
|---------|-------------|
| Trial balance | Debit/credit balances per account as of a date; balanced flag |
| Balance sheet | Assets, liabilities, and equity with current-period earnings roll-up |
| Balance sheet detail | GL journal lines per balance-sheet account with running balance |
| Profit and loss | Income and expense by account for a date range |
| Profit and loss detail | GL journal lines per income/expense account with source links |
| AR aging | Customer receivables in standard aging buckets |
| AP aging | Vendor payables in standard aging buckets |
| Customer balance summary | Open A/R totals per customer with drill-down to detail |
| Customer balance detail | Open invoices per customer with link to invoice show |
| Vendor balance summary | Open A/P totals per vendor with drill-down to detail |
| Vendor balance detail | Open bills per vendor with link to bill show |
| Sales by customer summary | Invoice totals per customer for a date range with drill-down |
| Sales by customer detail | Invoices per customer with optional line items and invoice links |
| Sales by product summary | Revenue and qty per item from invoice lines with drill-down |
| Sales by product detail | Invoice lines per item with customer and invoice context |
| Expenses by vendor summary | Bill totals per vendor for a date range with drill-down |
| Expenses by vendor detail | Bills per vendor with optional line items and bill links |
| Inventory valuation summary | FIFO stock value per item with `detail_url` drill-down |
| Inventory valuation detail | FIFO cost layers per item with `source_url` (bill) and `movements_url` |
| Date filtering | Reports support `as_of` or start/end date parameters |
| Zero-balance options | Optional inclusion of accounts or items with zero balances |

**API docs:** [reports.md](./api/reports.md)

---

## Role Permissions Summary

| Area | ADMIN | ACCOUNTANT | MANAGER | CASHIER |
|------|-------|------------|---------|---------|
| User management | ✓ | — | — | — |
| Company profile (update) | ✓ | — | — | — |
| Chart of accounts | ✓ | ✓ (no delete) | — | — |
| Journal entries (read) | ✓ | ✓ | ✓ | ✓ |
| Financial reports | ✓ | ✓ | ✓ | ✓ |
| Customers / vendors (read) | ✓ | ✓ | ✓ | ✓ |
| Customers / vendors (write) | ✓ | ✓ | — | — |
| Invoices / bills (read) | ✓ | ✓ | ✓ | ✓ |
| Invoices / bills (create, edit, post/receive) | ✓ | ✓ | — | ✓ (create/post only) |
| Invoices / bills (void, delete) | ✓ | — | — | — |
| Payments (create) | ✓ | ✓ | — | ✓ |
| Items / categories (read) | ✓ | ✓ | ✓ | ✓ |
| Items / categories (write) | ✓ | ✓ | — | — |
| Tax codes (read) | ✓ | ✓ | ✓ | ✓ |
| Tax codes (write) | ✓ | ✓ | — | — |
| Inventory transactions hub (read) | ✓ | ✓ | ✓ | ✓ |
| Transaction hubs (read) | ✓ | ✓ | ✓ | ✓ |

Row-level `available_actions` on transaction hub responses further reflect per-document policies.

---

## API Reference Index

| Module | Documentation |
|--------|---------------|
| Auth & users | [auth-and-users.md](./api/auth-and-users.md) |
| Company profile | [company.md](./api/company.md) |
| Accounts | [accounts.md](./api/accounts.md) |
| Journal entries | [journal-entries.md](./api/journal-entries.md) |
| Reports | [reports.md](./api/reports.md) |
| Customers | [customers.md](./api/customers.md) |
| Quotations | [quotations.md](./api/quotations.md) |
| Invoices | [invoices.md](./api/invoices.md) |
| Sales transactions hub | [sales-transactions.md](./api/sales-transactions.md) |
| Customer payments | [customer-payments.md](./api/customer-payments.md) |
| Vendors | [vendors.md](./api/vendors.md) |
| Purchase orders | [purchase-orders.md](./api/purchase-orders.md) |
| Bills | [bills.md](./api/bills.md) |
| Purchase transactions hub | [purchase-transactions.md](./api/purchase-transactions.md) |
| Bill payments | [bill-payments.md](./api/bill-payments.md) |
| Items | [items.md](./api/items.md) |
| Item categories | [item-categories.md](./api/item-categories.md) |
| Tax codes | [tax-codes.md](./api/tax-codes.md) |
| Inventory transactions hub | [inventory-transactions.md](./api/inventory-transactions.md), [inventory-adjustments.md](./api/inventory-adjustments.md) |
| Inventory adjustments | [inventory-adjustments.md](./api/inventory-adjustments.md) |
| Inventory starting value | [inventory-starting-value.md](./api/inventory-starting-value.md) |

---

## Tech Stack

- **Framework:** Laravel (PHP)
- **Auth:** Laravel Sanctum
- **Authorization:** Spatie Laravel Permission + Laravel Policies
- **Database:** Relational DB with migrations and seeders (demo company and admin user)
- **Testing:** Feature tests covering API modules, reports, balances, and inventory guards

---

## Local Development

After `php artisan migrate --seed`:

| Field | Value |
|-------|-------|
| Email | `admin@brixdemo.com` |
| Password | `password` |
| Role | `ADMIN` |
| Base URL | `http://127.0.0.1:8000/api/v1` |
