# Phase 9 — Expenses, vendors, and approvals

Phase 9 adds airline-scoped vendor management, operational expenses, allocations, private receipts, configurable multi-level approvals, vendor invoices, immutable payment records, controlled reversals and adjustments, payables dashboards, and expense analysis.

## Expense controls

Expense drafts retain category and subcategory, vendor and invoice, flight, aircraft, route, work order, airline base, department, original-currency values, fixed-scale exchange rate and base-currency value, payment details, due date, notes, evidence, and user attribution. Money is stored in `DECIMAL` columns and calculated with fixed-scale integer arithmetic. Duplicate invoice numbers are rejected per airline and vendor. Inactive vendors cannot be selected, and category-specific receipt thresholds are enforced on submission.

Approved financial records cannot be edited or silently overwritten. Corrections are linked Reversal or Adjustment expense records that follow the approval workflow independently. Draft/rejected records may be explicitly cancelled. Expense allocations cannot exceed the expense's base-currency value.

## Approval engine

Rules may match category, department, base-currency amount range, airline base, and requester role. Every level identifies an approver role and optional approval limit. Submission requires consecutive levels beginning at one and snapshots the matched rules into expense approval records, so subsequent rule changes cannot rewrite an active or completed chain.

Only a user who has both `expenses.approve` and the current step's approver role can decide that level. Approval limits are checked server-side. Requests progress one level at a time, and all submissions, approvals, rejections, actors, comments, timestamps, and levels remain in immutable action history.

## Payables and reporting

Approved expenses can be scheduled for payment. Partial and full payments append vendor-payment records and reconcile invoice and expense payment states atomically. Reports cover awaiting approvals, upcoming and overdue payables, and expenses grouped by category, aircraft, flight, route, department, and vendor.

## Security

Routes and services enforce distinct vendor, expense create/edit/manage/submit/approve/reverse/pay/report, and approval-rule permissions. Mutations require CSRF protection. Queries use prepared statements and airline ownership checks. Output is escaped, evidence is stored outside the public directory, timestamps are UTC, and material actions are audited.

This is operational expense and payable control, not a general ledger.
