# Report null-relationship error fix — 25 November 2026

## Problem

Several report screens and exports assumed that related records always existed. When a historical transaction referenced a deleted or missing product, category, unit, waiter, cashier, table, supplier, store, or user, the report could throw `Attempt to read property "name" on null`.

## Changes

- Made report relationship reads null-safe in Sales, Restaurant, Bar, Inventory, Kitchen, Audit Trail, and Purchase reports.
- Added readable fallbacks such as `Deleted Product`, `Unassigned`, `Unknown Supplier`, and `Unknown Store` where applicable.
- Made restaurant and bar report costing/value calculations tolerate missing products by treating the unavailable product amount as zero rather than crashing.
- Applied the same protection to report export document generation and Blade report tables.
- Did not delete, rewrite, or alter transaction, payment, stock, or other database records.
- No SQL migration is required for this code-only fix.

## Files changed

- `app/Http/Controllers/Reports/SalesReportController.php`
- `app/Http/Controllers/Reports/RestaurantReportController.php`
- `app/Http/Controllers/Reports/BarReportController.php`
- `app/Http/Controllers/Reports/InventoryReportController.php`
- `app/Http/Controllers/Reports/KitchenReportController.php`
- `app/Http/Controllers/Reports/AuditLogController.php`
- `resources/views/reports/inventory.blade.php`
- `resources/views/reports/bar.blade.php`
- `resources/views/reports/restaurant.blade.php`
- `resources/views/reports/audit.blade.php`
- `resources/views/reports/purchases.blade.php`

## Validation

- PHP syntax lint passed for all PHP files under `app/`.
- Runtime verification against the live database is still required after deployment. Test each report screen and its PDF/Excel/CSV export using the same date range that previously triggered the error.
