# USAuto (CarParts) Monitoring Dashboard — Implementation Plan

## 1. Executive Summary

The Operations team currently monitors CarParts (USAuto/B2B) orders using a **manual, Excel-driven workflow** consisting of two spreadsheets:

1. **B2B All Order(s) 2025.xlsx** — Master order log with monthly tabs, imported CSV data, delayed-order tracking, and daily summary statistics (orders by supplier, on-time %, delay causes).
2. **CP - Feb 2026.xlsx** — Daily monitoring workbook with a tab per business day, tracking each order's shipment lifecycle (tracking number, pickup date, delivery date, status, remarks) plus a monthly REPORT summary and an Order Issues log.

The SOP (CP monitoring.docx) describes a **9-step daily loop**: pull new orders from the B2B feed → transfer to daily sheet → look up tracking in Central → copy tracking to sheet → monitor FedEx status daily → flag "Label Created" stalls → notify reps → email CarParts → follow up after ETA for replacements/refunds.

**Goal:** Replace the entire manual Excel workflow with a **USAuto Monitoring Dashboard** inside the existing Filament admin panel — no spreadsheets, no copy-paste, no manual FedEx lookups.

---

## 2. Current Manual Process (What Ops Does Today)

| Step | Manual Action | Pain Point |
|------|--------------|------------|
| 1 | Import CSV from B2B portal into "Import CSV" sheet | Manual download + paste |
| 2 | Transfer order data to monthly sheet (FEB 2026) with supplier/tracking columns | Duplicate data entry |
| 3 | Open each order in Central, find PO number | Context-switching, slow |
| 4 | Click FedEx tracking link in Central | One-by-one manual lookup |
| 5 | Copy tracking info back into daily "CP - FEB 2026" sheet | Error-prone transcription |
| 6 | Monitor FedEx status daily for each tracking number | Repetitive manual checks |
| 7 | Identify "Label Created" with no movement | Easy to miss among many orders |
| 8 | Email CarParts about stuck shipments | Manual drafting |
| 9 | Follow up after ETA; offer replacement/refund for Lost in Transit | Tracking deadlines manually |

**Key data tracked in Excel that must be replicated:**
- Order date, PO#, carrier, tracking #, state, warehouse/supplier ID, total
- Pickup date, delivery date, status (DELIVERED, LABEL CREATED, LOST IN TRANSIT, CANCELLED, BACKORDERED, RETURNED, UNSHIPPED, PENDING, DAMAGED, RECEIVED WRONG, etc.)
- Remarks, observations, rep notes
- Daily summaries: total orders, on-time %, delayed %, issues breakdown (LIT, RWP, DMG, BO/OOS, UNSHP, OTHER, PND)
- Delay analysis: cause by FedEx / CarParts / Will Call / Dropshipper
- Supplier breakdown: IN STOCK, EXPRS-MI, DEPO, TYC, PBI, CP

---

## 3. Proposed Architecture

### 3.1 Data Source — Everything Is Already In Central

The key insight is: **all the data Ops manually copies into Excel already exists in the database**. The `orders`, `orders_items`, and `shipments` tables contain:

| Excel Column | Database Source |
|-------------|---------------|
| DATE | `orders.date_placed` |
| PO# / Order # | `orders.external_order_id` |
| Carrier | `shipments.carrier` or `orders_items.carrier` |
| Tracking # | `shipments.tracking_number` or `orders_items.tracking` |
| State | `orders.shipping_state` |
| Warehouse | `shipments.warehouse_id` or `orders_items.warehouse_code` |
| Supplier ID | `orders_items.supplier_id` → `suppliers.code` |
| Total | `orders.order_total` |
| Status | `orders_items.current_status` + `shipments` data |
| Pickup / Delivery dates | `shipments.date_shipped`, `shipments.date_delivery` |

**What is NOT yet in the database** and needs to be added:
- **Carrier tracking status** (e.g., "Label Created", "In Transit", "Delivered", "Exception") — currently checked manually on FedEx.com
- **Monitoring-specific remarks/observations** (free-text notes Ops adds to Excel)
- **Delay cause attribution** (FedEx, CarParts, Will Call, Dropshipper)
- **Follow-up action tracking** (emailed CarParts, follow-up due date, resolution)

**What is already in the database** — Issue types do NOT need a new field:
- Central's existing `current_status` + `current_sub_status` on `orders_items` already cover every issue type the Excel sheets track. The dashboard derives issue labels from these instead of maintaining a parallel system.

### 3.1.1 Unified Issue Type Mapping (Central Status → Dashboard Display)

The monitoring dashboard reads Central's existing statuses and displays them as the issue labels Ops is accustomed to:

| Dashboard Label | Derived From | Central Field | Central ID(s) |
|----------------|-------------|---------------|----------------|
| **Lost In Transit** (LIT) | Sub-Status: "Lost In Transit (LIT)" | `current_sub_status` | 29 |
| **Wrong Part** (RWP) | Sub-Status: "Wrong Item Sent" | `current_sub_status` | 22 |
| **Damaged** (DMG) | Sub-Status: "Damaged (Not Returned)" / "Damaged (Returned)" | `current_sub_status` | 23, 24 |
| **Backordered** (BO) | Sub-Status: "Back Ordered" / "Back Ordered - OOS" / "Out of Stock" OR Status: "Back Order" | `current_sub_status` OR `current_status` | sub: 18, 32, 38 — status: 2 |
| **Unshipped** (UNSHP) | Status: item still in pre-ship state AND past expected ship date | `current_status` | 1, 3, 4 |
| **Cancelled** | Status: "Cancelled" / "Please Cancel" / "Cancelled - Not Purchased" | `current_status` | 7, 33, 49 |
| **Pending** (PND) | Status: "Awaiting Customer Reply" / "Wants to Wait" | `current_status` | 30, 32 |
| **Other** | Sub-Status: "Other" | `current_sub_status` | 31, 35 |

**Resolution sub-statuses** (also already in Central):
- Replacement → sub_status 2
- Replacement Or Refund → sub_status 4

This means the `order_monitoring` table does **not** need an `issue_type` column. Issue classification is derived at query time from the item's existing status/sub-status, keeping a single source of truth.

### 3.2 New Database Table: `order_monitoring`

A dedicated table keeps monitoring concerns decoupled from core order processing:

```sql
CREATE TABLE order_monitoring (
    id                  BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    order_id            INT UNSIGNED NOT NULL,
    order_item_id       INT UNSIGNED NULL,
    shipment_id         INT UNSIGNED NULL,

    -- Carrier tracking (auto-populated)
    carrier_status          VARCHAR(50) NULL,      -- label_created, in_transit, out_for_delivery, delivered, exception, returned
    carrier_status_detail   VARCHAR(255) NULL,     -- Detailed status message from carrier
    carrier_pickup_at       TIMESTAMP NULL,
    carrier_delivery_at     TIMESTAMP NULL,
    carrier_eta             TIMESTAMP NULL,
    carrier_checked_at      TIMESTAMP NULL,        -- Last API check time
    days_in_transit         INT NULL,              -- Calculated

    -- Delay tracking (issue_type is NOT stored here — derived from orders_items.current_status + current_sub_status)
    delay_cause             VARCHAR(30) NULL,       -- FEDEX, CARPARTS, WILLCALL, DROPSHIPPER, WAREHOUSE, WEATHER
    delay_days              INT DEFAULT 0,

    -- Action tracking
    status                  ENUM('monitoring','flagged','action_needed','escalated','resolved','closed') DEFAULT 'monitoring',
    remarks                 TEXT NULL,
    follow_up_date          DATE NULL,
    resolution              VARCHAR(30) NULL,       -- REFUND, REPLACEMENT, RESHIPPED, RESOLVED, CLOSED
    resolution_notes        TEXT NULL,
    resolved_at             TIMESTAMP NULL,

    -- Rep assignment (leverages existing OrderAssignment + OrderAssignmentHistory for audit)
    assigned_to             INT UNSIGNED NULL,      -- FK to users.user_id
    assigned_at             TIMESTAMP NULL,

    created_at              TIMESTAMP NULL,
    updated_at              TIMESTAMP NULL,

    INDEX idx_order_id (order_id),
    INDEX idx_status (status),
    INDEX idx_carrier_status (carrier_status),
    INDEX idx_follow_up (follow_up_date),
    INDEX idx_delay_cause (delay_cause),
    FOREIGN KEY (order_id) REFERENCES orders(order_id),
    FOREIGN KEY (order_item_id) REFERENCES orders_items(order_item_id),
    FOREIGN KEY (shipment_id) REFERENCES shipments(shipment_id)
);
```

This keeps monitoring data separate, allows multiple monitoring entries per order (one per shipment/item), and doesn't bloat the hot `orders_items` table.

### 3.3 Automated Carrier Tracking (Replacing Steps 4-7)

Instead of Ops manually visiting FedEx.com for each tracking number:

**Approach: ShipStation/ShipEngine Tracking API**
- ShipStation already provides tracking webhooks and status APIs
- When shipments are created via ShipStation, tracking updates can be pulled via `GET /shipments/{id}` or webhooks
- Alternatively, ShipEngine (which ShipStation uses under the hood) has a dedicated Tracking API

**Implementation:**
1. **Scheduled Command** (`php artisan usauto:sync-tracking`) runs every 2 hours during business hours
2. For each B2B order with an active (non-delivered, non-cancelled) shipment:
   - Call ShipStation API `GET /shipments?orderNumber={po}` or track via tracking number
   - Update `order_monitoring.carrier_status`, `carrier_pickup_at`, `carrier_delivery_at`, `carrier_eta`
3. **Auto-flag logic:**
   - If `carrier_status = 'label_created'` AND `carrier_checked_at - shipment.date_submitted > 48 hours` → set `status = 'flagged'`
   - If `carrier_status = 'exception'` → set `status = 'action_needed'`
   - If delivery date exceeds ETA → set `delay_days`, compute `delay_cause`

**Fallback:** If ShipStation tracking API is insufficient, use FedEx Track API directly (FedEx provides a REST API with free tier for account holders).

### 3.4 Filament Dashboard Page

A new Filament page: **`USAutoMonitoring`** at route `/usauto-monitoring`.

#### Tab 1: Live Order Monitor (replaces daily "CP - FEB 2026" sheets)

A filterable table showing all B2B orders, default-filtered to today:

| Column | Source |
|--------|--------|
| Date | `orders.date_placed` |
| Order # | `orders.external_order_id` (linked to order detail) |
| Customer | `orders.shipping_company` / `orders.shipping_first_name` |
| Carrier | `shipments.carrier` |
| Tracking # | `shipments.tracking_number` (linked to carrier tracking page) |
| State | `orders.shipping_state` |
| Warehouse | `shipments.warehouse_id` |
| Supplier | `orders_items.supplier_id` |
| Total | `orders.order_total` |
| Pickup Date | `order_monitoring.carrier_pickup_at` |
| Delivery Date | `order_monitoring.carrier_delivery_at` |
| Carrier Status | `order_monitoring.carrier_status` (color-coded badge) |
| Monitor Status | `order_monitoring.status` (badge) |
| Remarks | `order_monitoring.remarks` (inline-editable) |

**Key features:**
- **Date range filter** (default: today, presets: yesterday, this week, this month)
- **Status filter** (All, Needs Attention, Label Created, In Transit, Delivered, Exception, Unshipped)
- **Color coding:** Green = Delivered, Yellow = In Transit, Orange = Label Created > 24h, Red = Exception/Flagged
- **Bulk actions:** Mark as Resolved, Assign to Rep, Flag for Follow-up
- **Inline edit** for remarks, delay cause (issue type is set via Central's existing status/sub-status workflow)
- **Quick action buttons:** "Email CarParts", "Update Status" (opens Central status picker), "Request Replacement/Refund"
- **Row expansion** to show all tracking numbers for multi-shipment orders (like the Excel shows duplicate rows for same order with different tracking)

#### Tab 2: Flagged / Action Needed (replaces manual "Label Created" monitoring)

Auto-filtered view of orders that need attention:
- **Label Created > 48 hours** with no movement
- **Exceptions** reported by carrier
- **Past ETA** with no delivery
- **Pending follow-ups** where `follow_up_date <= today`

Each row shows the escalation timeline and has action buttons to:
- Send notification to B2B Rep
- Log "Emailed CarParts" with timestamp
- Set follow-up date (default: +2 days as per SOP)
- Mark resolution (Replacement/Refund offered)

#### Tab 3: Issues Log (replaces "Order Issues" sheet)

Structured issue tracker — derived from Central's `current_status` + `current_sub_status`:
- All order items where status/sub-status maps to an issue (see Unified Issue Type Mapping in 3.1.1)
- Columns: Date, Order #, Tracking #, Rep In-Charge, Central Status, Issue Label (derived), Resolution
- Filters by issue label (LIT, RWP, DMG, BO, UNSHP, etc.) — each filter queries the corresponding status/sub-status IDs

#### Tab 4: Daily Report (replaces "REPORT (CP)" sheet and "JAN - Total #s" sheet)

Auto-generated daily summary dashboard with:

**Stats Widgets (top row):**
- Total Orders Today
- On-Time Deliveries (count + %)
- Delayed Deliveries (count + %)
- Open Issues (count)
- Unshipped (count)

**Daily Breakdown Table** (replaces "JAN - Total #s"):

| Date | In Stock | EXPRS-MI | DEPO | TYC | PBI | CP | Total | On Time | Delayed | Undelivered | Unshipped | On Time % | Delayed % |
|------|----------|----------|------|-----|-----|----|-------|---------|---------|-------------|-----------|-----------|-----------|

This is auto-calculated from:
- `orders_items.supplier_id` → grouped supplier counts (IN STOCK = USANV/USATX/USAIL/USAFL/USAVA, EXPRS-MI, DEPO, TYC, PBI, CP/KEY)
- On-time = delivered within ETA window
- Delayed = delivered after ETA or still undelivered past ETA

**Delay Cause Breakdown:**
| Period | FedEx | CarParts | Will Call | Dropshipper |
|--------|-------|----------|-----------|-------------|

**Issues Summary (matches REPORT sheet):**
| Date | # Orders | On Time | Delayed | Cancelled | LIT | RWP | DMG | BO/OOS | UNSHP | OTHER | PND | Total Issues |
|------|----------|---------|---------|-----------|-----|-----|-----|--------|-------|-------|-----|-------------|

**Monthly Rollup** (matches quarterly summary):
- Total Orders, On Time %, Delayed %, Issue %, Cancelled Orders

#### Tab 5: Delayed Orders (replaces "Delayed (Feb)", "Delayed (Jan)", "All States Delayed" sheets)

Detailed view of all delayed orders with:
- Order ID, Shop Name, Tracking #, Warehouse
- Order Date, Shipment Info Sent Date, Pickup Date, Delivery Date
- Number of Days (transit time)
- ETA Provided to Shop
- Observation/Root Cause analysis (editable text field)
- Delay cause attribution

Filters: by month, by state, by warehouse, by delay cause.

---

### 3.5 Assignment System

#### Existing Infrastructure We Reuse
The codebase already has a full order assignment system:
- **`OrderAssignment`** model — links `order_id` to `user_id` with `assigned_by` tracking
- **`OrderAssignmentHistory`** model — audit trail with `action` (assigned/unassigned) timestamps
- **`OrderDepartmentAssignment`** model — assigns orders to entire departments
- **`Department`** model — groups users into teams via `department_users` pivot
- **User model** has `assignedOrders()` and `ordersAssignedByMe()` relationships

#### How It Works in the Monitoring Dashboard

**Assigning:** When a monitoring entry is flagged/action_needed, a supervisor (or auto-flag logic) assigns it to a specific user:
1. From the Flagged/Action Needed tab (or any table row), click "Assign" button
2. Select a user from dropdown (filtered to relevant department members)
3. This creates an `OrderAssignment` record AND sets `order_monitoring.assigned_to` = user_id
4. An `OrderAssignmentHistory` record is logged for audit

**Viewing Assigned Orders:** The assigned person sees their work at the top:
1. When a user opens the USAuto Monitoring dashboard, the **Live Monitor** and **Flagged** tabs query with:
   ```
   ORDER BY (order_monitoring.assigned_to = {current_user_id}) DESC, ...
   ```
2. A visual separator or "Assigned to You" section appears at the top of the table
3. An **"My Assignments"** filter toggle is available to show only their assigned orders
4. Badge count in the tab header shows the number of items assigned to the current user

**Department-Level Assignment:**
- Orders can also be assigned to a department (e.g., "B2B Ops Team") using `OrderDepartmentAssignment`
- All users in that department see the order surfaced in their view
- Useful for morning alert distribution (see below)

**Auto-Assignment Rules** (optional, can be enabled later):
- Orders from specific supplier groups can auto-assign to the responsible rep
- Escalation: if a flagged order has no assignment after 4 hours, auto-assign to supervisor

#### Changes to `order_monitoring` Table
The `assigned_to` column already exists in the schema (Section 3.2). We add:
```sql
    assigned_at             TIMESTAMP NULL,         -- When assignment was made
```
The full assignment history lives in the existing `order_assignment_history` table — no new history table needed.

---

### 3.6 Morning Alert System

#### Purpose
Every morning, key people receive an email digest summarizing orders that need attention. The alert is **split by channel** because B2B and B2C have separate ops teams.

#### Alert Recipients Configuration

A new config file `config/monitoring-alerts.php` defines who gets what:

```php
return [
    'timezone' => 'America/Los_Angeles',  // PST
    'send_at'  => '07:00',               // 7:00 AM PST daily

    'channels' => [
        'b2b' => [
            'label'      => 'B2B (CarParts/USAuto)',
            'filter'     => ['source' => 500],  // Order::SOURCE_B2B
            'recipients' => [
                // Populated by user — list of email addresses or user_ids
                // e.g., 'john@goparts.com', 'jane@goparts.com'
            ],
        ],
        'b2c' => [
            'label'      => 'B2C (Website/Marketplace)',
            'filter'     => ['source_not' => 500],  // Everything except B2B
            'recipients' => [
                // Populated by user — separate team
            ],
        ],
    ],
];
```

**Why a config file vs database table:** Simple to start, easy to update via deployment. Can be migrated to a Filament settings page later if recipient management needs to be self-service.

#### What the Morning Alert Contains

Each channel's email includes these sections:

**1. Summary Header**
```
USAuto Monitoring — Morning Alert (B2B)
Date: March 4, 2026 | Generated: 7:00 AM PST
```

**2. Urgent: Action Needed** (Red section)
- Orders flagged > 48h with no assignment or resolution
- Carrier exceptions
- Overdue follow-ups (follow_up_date < today, still unresolved)

| Order # | Status | Issue | Days Stuck | Tracking # | Assigned To |
|---------|--------|-------|------------|------------|-------------|

**3. New Flags Since Yesterday** (Orange section)
- Orders auto-flagged in the last 24 hours (Label Created stalls, exceptions)
- Not yet assigned to anyone

| Order # | Flag Reason | Flagged At | Carrier Status | State |
|---------|------------|------------|----------------|-------|

**4. Unshipped Orders** (Yellow section)
- B2B orders placed > 24h ago still in status 1 (Needs Order), 3 (Ordered), or 4 (Sent to SS) with no shipment
- Sorted oldest first

| Order # | Date Placed | Hours Since Order | Supplier | State |
|---------|------------|-------------------|----------|-------|

**5. Daily Snapshot** (Gray section)
- Yesterday's totals: orders received, shipped, delivered, delayed, cancelled
- Open monitoring items count
- On-time delivery % for the trailing 7 days

**6. Quick Link**
```
View full dashboard: https://central.go-parts.com/usauto-monitoring
```

#### Implementation

**Scheduled Command:** `php artisan monitoring:send-morning-alerts`
- Registered in `app/Console/Kernel.php`
- Runs daily at 7:00 AM PST: `->dailyAt('07:00')->timezone('America/Los_Angeles')`
- Queries `order_monitoring` + `orders` + `orders_items` for each channel
- Builds the digest, sends via Laravel Mail

**Mailable Class:** `app/Mail/MonitoringMorningAlert.php`
- Accepts: channel label, recipient, digest data (urgent, new flags, unshipped, snapshot)
- Blade template: `resources/views/emails/monitoring-morning-alert.blade.php`
- Clean HTML email with color-coded sections, sortable tables, and direct links to orders in Central

**Skipping Weekends/Holidays (optional):**
- Config flag `skip_weekends => true` to only send on business days
- On Mondays, the alert covers Saturday + Sunday activity

---

## 4. Implementation Phases

### Phase 1: Database & Model Foundation
1. Create migration for `order_monitoring` table
2. Create `OrderMonitoring` Eloquent model with relationships
3. Add `isB2BSupplier()` helper mapping supplier codes to categories (IN STOCK, EXPRS-MI, DEPO, TYC, PBI, CP)
4. Seed historical data from existing orders (backfill delivered/shipped statuses)

### Phase 2: Carrier Tracking Automation
1. Investigate ShipStation tracking API capabilities (or ShipEngine/FedEx Track API)
2. Create `USAutoTrackingService` to fetch tracking status updates
3. Create Artisan command `usauto:sync-tracking`
4. Schedule command to run every 2 hours (8am-6pm business hours)
5. Implement auto-flag logic (Label Created > 48h, exceptions, past ETA)

### Phase 3: Dashboard — Live Monitor Tab
1. Create `USAutoMonitoring` Filament page
2. Build main order table with all columns from daily sheets
3. Add date/status/supplier filters
4. Implement color-coded status badges
5. Add inline editing for remarks, delay cause (issue type derived from Central status)
6. Add row expansion for multi-shipment orders

### Phase 4: Dashboard — Flagged & Issues Tabs
1. Build "Flagged / Action Needed" tab with auto-filtered problem orders
2. Build action buttons (Email CarParts, Set Follow-up, Mark Resolution)
3. Build "Issues Log" tab matching Excel "Order Issues" sheet
4. Implement follow-up date reminders

### Phase 5: Dashboard — Reports & Delayed Tabs
1. Build daily report view with stats widgets
2. Build daily breakdown table (auto-calculated from DB)
3. Build issues summary table
4. Build monthly rollup
5. Build "Delayed Orders" tab with full delay analysis
6. Add export-to-CSV capability (for cases where Ops still needs spreadsheet output)

### Phase 6: Assignment System
1. Add "Assign" action button to monitoring table rows (user dropdown, filtered by department)
2. Create `OrderAssignment` + `OrderAssignmentHistory` records on assign
3. Implement "Assigned to You" sort-to-top logic and "My Assignments" filter toggle
4. Add assignment badge count in tab headers
5. Support department-level assignment via `OrderDepartmentAssignment`

### Phase 7: Morning Alert System
1. Create `config/monitoring-alerts.php` with channel definitions and recipient lists
2. Create `MonitoringMorningAlert` Mailable with Blade email template
3. Create Artisan command `monitoring:send-morning-alerts`
4. Register in scheduler at 7:00 AM PST daily
5. Build digest query logic (urgent/action needed, new flags, unshipped, daily snapshot)
6. Test with mailpit locally, configure production SMTP
7. Optional: add "Email CarParts" template auto-generation for Label Created issues

---

## 5. Technical Notes

### Identifying B2B/CarParts Orders
B2B orders are identified by `orders.source = 500` (Order::SOURCE_B2B). The dashboard filters on this. All supplier breakdowns use `orders_items.supplier_id`:
- **In Stock** = supplier codes starting with `USA` (USANV, USATX, USAIL, USAFL, USAVA)
- **EXPRS-MI** = Express supplier
- **DEPO** = DEPO-EC, DEPO-WC, DEPO WILL CALL
- **TYC** = TYC-EC
- **PBI** = PBIVA
- **CP** = KEY, KSI, MEYER, OCT (external/CarParts dropship suppliers)

### Tracking Number Patterns
From the data:
- FedEx tracking numbers: 12-digit (e.g., `889171449380`) or 16-digit (e.g., `1938574633287524`)
- Special values: `Processing` (not yet shipped), `WFPI` (Waiting For Pricing Info), `MEYER` (dropship to Meyer), `BO` (backordered), `CANCELLED`

### ETA Calculation
The "ETA Days" in Import CSV shows the expected delivery date. For on-time/delayed classification:
- **On Time** = `carrier_delivery_at <= expected_eta`
- **Delayed** = `carrier_delivery_at > expected_eta` OR still in transit past ETA
- ETA is typically 3-6 business days from order date depending on destination state

### File Placement
```
app/
  Filament/
    Pages/
      USAutoMonitoring.php              -- Main dashboard page (tabbed)
  Models/
    OrderMonitoring.php                 -- Eloquent model
  Services/
    USAutoTrackingService.php           -- Carrier tracking API integration
  Mail/
    MonitoringMorningAlert.php          -- Morning alert Mailable
  Console/
    Commands/
      SyncUSAutoTracking.php            -- Scheduled tracking sync command
      SendMonitoringMorningAlerts.php   -- Morning alert email command
config/
  monitoring-alerts.php                 -- Alert recipients & channel config
database/
  migrations/
    2026_03_XX_create_order_monitoring_table.php
resources/
  views/
    filament/
      pages/
        usauto-monitoring.blade.php     -- Custom Blade view (if needed)
    emails/
      monitoring-morning-alert.blade.php -- Morning alert email template
```

---

## 6. What This Eliminates

| Manual Process | Automated Replacement |
|---------------|----------------------|
| Download CSV from B2B portal | Orders already flow into `orders` table automatically |
| Copy data between Excel sheets | Single source of truth in database |
| Open each order in Central to find tracking | Tracking auto-synced from ShipStation/carrier API |
| Visit FedEx.com for each tracking number | Carrier status auto-updated every 2 hours |
| Identify "Label Created" stalls manually | Auto-flagged after 48 hours |
| Maintain daily Excel sheets per date | Live filterable table, filter by any date range |
| Build monthly report manually | Auto-calculated from real data |
| Track delayed orders in separate sheets | Dedicated "Delayed" tab with filters |
| Track issues in separate sheet | Integrated issues log |
| Calculate on-time/delayed percentages manually | Real-time computed metrics |
| Count orders by supplier manually | Auto-grouped supplier breakdown |
| Verbally telling reps "check this order" | Assign directly in dashboard, assigned orders surface at top |
| No proactive alerting — issues found when already late | Morning email digest at 7 AM PST with urgent/flagged/unshipped orders |
| Same process for B2B and B2C despite different teams | Alerts split by channel, each team gets only their relevant orders |

**Net result:** The entire 9-step SOP collapses to: **Open the USAuto Monitoring Dashboard → Review flagged items → Take action.** Assignments ensure accountability. Morning alerts ensure nothing is missed overnight. Everything else is automated.
