# Degabriele Kitchens CRM — New Modules Install Guide

## What's included in this update

- **Warehouse PO Receiving** — Create purchase orders, receive stock against them, auto-updates inventory
- **Job PO Allocation** — Allocate PO costs directly to jobs, feeds into Gross Profit Report
- **Inventory Section** — Full stock management with PO receipt history, reorder alerts, manual adjustments
- **Job Variants** — Track quote variants presented to clients, accept/reject with quote status update
- **Enhanced Gross Profit Report** — Full per-job breakdown (materials, labour, PO costs) with PDF export
- **Delivery Date on Check Measure** — New field on both Create and Edit forms

---

## Step 1 — Run the new migrations

```bash
php artisan migrate
```

This will create the following tables:
- `purchase_orders`, `purchase_order_items`
- `po_receipts`, `po_receipt_items`
- `stocks`, `stock_movements`
- `job_po_allocations`
- `job_variants`
- Adds `delivery_date` column to `check_measures`

---

## Step 2 — Verify composer dependencies

DomPDF is already in your `composer.json`. If you get a class not found error, run:

```bash
composer install
```

---

## Step 3 — Clear caches

```bash
php artisan config:clear
php artisan route:clear
php artisan view:clear
php artisan cache:clear
```

---

## Files changed / added

### New migrations
- `database/migrations/2025_06_01_000001_create_purchase_orders_table.php`
- `database/migrations/2025_06_01_000002_create_stocks_table.php`
- `database/migrations/2025_06_01_000003_create_job_po_allocations_table.php`
- `database/migrations/2025_06_01_000004_create_job_variants_table.php`
- `database/migrations/2025_06_01_000005_add_delivery_date_to_check_measures.php`

### New models
- `app/Models/PurchaseOrder.php`
- `app/Models/PurchaseOrderItem.php`
- `app/Models/PoReceipt.php`
- `app/Models/PoReceiptItem.php`
- `app/Models/Stock.php`
- `app/Models/StockMovement.php`
- `app/Models/JobPoAllocation.php`
- `app/Models/JobVariant.php`

### New controllers
- `app/Http/Controllers/PurchaseOrderController.php`
- `app/Http/Controllers/InventoryController.php`
- `app/Http/Controllers/JobVariantController.php`
- `app/Http/Controllers/GrossProfitDetailController.php`

### New views
- `resources/views/purchase-orders/index.blade.php`
- `resources/views/purchase-orders/create.blade.php`
- `resources/views/purchase-orders/show.blade.php`
- `resources/views/purchase-orders/receive.blade.php`
- `resources/views/inventory/index.blade.php`
- `resources/views/inventory/show.blade.php`
- `resources/views/variants/index.blade.php`
- `resources/views/gross-profit/show.blade.php`
- `resources/views/gross-profit/pdf.blade.php`

### Updated files
- `routes/web.php` — new routes added for all modules
- `app/Models/Job.php` — added `variants()`, `poAllocations()` relationships
- `app/Models/CheckMeasure.php` — added `delivery_date` to `$fillable` and `$casts`
- `resources/views/check-measure/create.blade.php` — delivery date field added
- `resources/views/check-measure/edit.blade.php` — delivery date field added
- `resources/views/reports/gross_profit.blade.php` — detail and PDF links added per job row

---

## Navigation

Add links to the sidebar in `resources/views/layouts/app.blade.php` for:

```html
<!-- Purchase Orders -->
<a href="/purchase-orders" class="nav-item"><i class="fas fa-file-invoice"></i><span>Purchase Orders</span></a>

<!-- Inventory -->
<a href="/inventory" class="nav-item"><i class="fas fa-boxes"></i><span>Inventory</span></a>
```

Job Variants are accessed from each job's detail page via `/jobs/{id}/variants`.
