# Master Public Release Gate 33 - Purchase-Order Accrual Foundation

Date: 2026-06-17

Status: PASS for the local purchase-order accrual foundation.

## Scope

Gate 33 adds purchase-order accruals as an explicit cost source for local profitability reporting. It does not enable supplier invoice matching, live accounting-provider cost import, purchase-order approval workflows, stock receiving workflows, payment capture, or hosted BI worker execution. Local supplier-invoice matching is covered by Gate 34.

## What Changed

- Added tenant-scoped purchase-order read repositories for demo/session and database-backed modes.
- Added `PurchaseOrderAccrualService` to calculate committed and received PO line costs from approved, ordered, partially received, and received orders.
- Excluded draft, rejected, and cancelled purchase orders from profitability accruals.
- Added purchase-order tables and tenant-first indexes to `database/schema.sql`.
- Extended job profitability reports so purchase-order accrual is shown separately from material movements and direct costs.
- Extended contract profitability reports so explicit contract-linked and job-linked purchase orders contribute to contract cost.
- Added demo purchase-order seed data covering included and excluded accrual scenarios.
- Added demo reset cleanup for stale purchase-order session data.

## Security And Data Rules

- Purchase orders are read tenant-scoped by `tenant_id`.
- Cross-tenant purchase-order lines are ignored by the database repository.
- Reports remain read-only and do not mutate purchasing, inventory, invoicing, or accounting data.
- Purchase-order costs use line totals/subtotals as cost basis and do not claim supplier invoice reconciliation.
- Contract profitability links purchase orders only by explicit `contract_id`/agreement fields or by a job already linked to a contract. It does not infer contract costs by customer name.

## Tests Run

- `C:\xampp\php\php.exe -l` on changed PHP classes, controller, template, public entrypoint, and test file: PASS.
- `C:\composer\composer.bat test`: PASS.
- `C:\composer\composer.bat check`: PASS.
- `C:\composer\composer.bat validate --no-check-publish`: PASS.
- `C:\composer\composer.bat audit --locked`: PASS after rerun outside sandbox network restrictions.
- `C:\composer\composer.bat release-gate` with MySQL enabled: PASS.
- XAMPP served-copy `composer validate --no-check-publish`, `composer test`, `composer check`, and MySQL-enabled `composer release-gate`: PASS.
- XAMPP browser route/responsive smoke against `http://localhost/FieldOps-Cloud/public`: PASS with `failureCount: 0`.
- XAMPP role/RBAC walkthrough against `http://localhost/FieldOps-Cloud/public`: PASS with `failureCount: 0`.
- XAMPP high-risk role interaction smoke against `http://localhost/FieldOps-Cloud/public`: PASS with `failureCount: 0`.
- XAMPP accessibility smoke against `http://localhost/FieldOps-Cloud/public`: PASS across 66 page/viewport checks with zero failures or warnings.

## Remaining Blockers

- Local supplier-invoice matching is covered by Gate 34.
- Payroll/time-sheet import is covered by Gate 35.
- Live accounting-provider cost import is still not activated.
- Hosted deployment, hosted workers, hosted-scale proof, live payments, signed native app-store submission, and real hosted CI evidence still require owner infrastructure, credentials, and approval.
