# Validation Report: URS-050

**Title:** Select Another Rep's Trunk Stock for Bill-Only Orders
**Date:** 2026-08-03T23:04:20.746Z
**Duration:** 69.7s
**Overall Status:** ✅ PASS

## User Requirement

> The system shall support the use of trunk stock within the same sales agency when submitting bill‑only orders.

*Source: `User_Requirement_Specifications_Vantis_DeviceFlow.xlsx` — the run below proves the system meets this requirement.*

## Environment

- **Inbox URL:** http://localhost:37227
- **Database:** localhost:45725/cc_repinbox_dev

## Setup

Status: ✅ PASS

## Test Steps

Each step below corresponds to one Playwright test that ran sequentially. Screenshots and video recordings provide visual evidence of the UI behaviour.

### 1. Step 1: Login and own trunk — ✅ PASS

**What this step proves:**

A sales rep logs in and navigates to their trunk stock. This establishes the baseline inventory context and confirms that a rep can view their own trunk before attempting to use another rep's trunk.

**Screenshots:**

![step 01 logged in](screenshots/step-01-logged-in.png)

![step 01 own trunk inventory](screenshots/step-01-own-trunk-inventory.png)

**Video recording:**

[▶ Watch step recording](videos/step-01-own-trunk.webm)

---

### 2. Step 2: Bill-only form start — ✅ PASS

**What this step proves:**

The sales rep begins a new bill-only order by selecting the manufacturer and a sales account. This step navigates through the first two stages of the bill-only form to reach the inventory source selection screen.

**Screenshots:**

![step 02 bill only form](screenshots/step-02-bill-only-form.png)

![step 02 account selected](screenshots/step-02-account-selected.png)

![step 02 devices step](screenshots/step-02-devices-step.png)

**Video recording:**

[▶ Watch step recording](videos/step-02-bill-only-start.webm)

---

### 3. Step 3: Other rep trunk selection — ✅ PASS

**What this step proves:**

The rep selects "Other Rep Trunk" as the inventory source and chooses a specific colleague's trunk from the dropdown. The order is completed and submitted, demonstrating that the system correctly allows a rep to draw from another rep's trunk stock when creating a bill-only order.

**Audit events generated by this step:**

*(Evidence scoped to step execution window: 2026-08-03T23:05:00.099Z → 2026-08-03T23:05:20.830Z)*

| Time | Type | Action | User | Org | Performed |
|------|------|--------|------|-----|-----------|
| 2026-08-03 23:05:17Z | decision | bill_only_order.inventory_items_decrement | blair.bennett@corvetasurgical.com | Vantis | yes |
| 2026-08-03 23:05:17Z | decision | bill_only.link_purchase_order | blair.bennett@corvetasurgical.com | Corveta Surgical Group | no |
| 2026-08-03 23:05:17Z | decision | bill_only_order.direct_po_import_on_create | blair.bennett@corvetasurgical.com | Vantis | no |
| 2026-08-03 23:05:17Z | billing_order | status_change | blair.bennett@corvetasurgical.com | Vantis | — |
| 2026-08-03 23:05:18Z | transactional_email | new_bill_only | — | Corveta Surgical Group | — |

**Emails triggered by this step:**

*(Evidence matched by declared name — step timing not available or no events fell in window)*

**Email 1: New Bill-Only Order - 8/3/2026 - Vantis BO-1**

Template: `New_Bill-Only_Order_-_8_3_2026_-_Vantis_BO-1`

![New Bill-Only Order - 8/3/2026 - Vantis BO-1](screenshots/emails/2026-08-03T23-05-18-022Z-New_Bill-Only_Order_-_8_3_2026_-_Vantis_BO-1.png)

**Screenshots:**

![step 03 other button clicked](screenshots/step-03-other-button-clicked.png)

![step 03 rep trunk dropdown](screenshots/step-03-rep-trunk-dropdown.png)

![step 03 ryan trunk selected](screenshots/step-03-ryan-trunk-selected.png)

![step 03 product from ryan](screenshots/step-03-product-from-ryan.png)

![step 03 review other rep source](screenshots/step-03-review-other-rep-source.png)

![step 03 order submitted](screenshots/step-03-order-submitted.png)

**Video recording:**

[▶ Watch step recording](videos/step-03-other-rep-trunk.webm)

---

### 4. Step 4: Database verification — ✅ PASS

**What this step proves:**

The billing list is opened to confirm the submitted order appears. This step provides screenshot evidence that the bill-only order is visible in the system after submission using another rep's trunk.

**Screenshots:**

![step 04 billing list](screenshots/step-04-billing-list.png)

**Video recording:**

[▶ Watch step recording](videos/step-04-db-verification.webm)

---

## Database Validations

The following SQL queries ran against the application database after the Playwright scenarios completed. Each query asserts a specific condition that proves the feature under test persisted its data correctly.

### Bill-only order created by Blair — ✅ PASS

**Assertion:** At least one billing order should have been created by Blair Bennett in the last 30 minutes

```sql
SELECT bo.id, bo.order_number, bo.status, bo.sales_account_id,
        bo.created_at, bo.created_by_user_id
      FROM billing_orders bo
      WHERE bo.created_by_user_id = $1
        AND bo.created_at > NOW() - INTERVAL '30 minutes'
      ORDER BY bo.created_at DESC
      LIMIT 5
```

| id | order_number | status | sales_account_id | created_at | created_by_user_id |
| --- | --- | --- | --- | --- | --- |
| 019fc9df-d431-75d3-b678-4ae17a616fde | BO-1 | submitted | fea7b8c9-d0e1-2345-0123-456789012345 | 2026-08-03T23:05:17.024Z | 17b8c9d0-e1f2-3456-1234-567890123456 |

### Order items reference other rep's trunk — ✅ PASS

**Assertion:** At least one billing order item should have location_id = b7f8a9b0-c1d2-3456-1234-567890123456 (Rana's TRUNK-26)

```sql
SELECT boi.id, boi.billing_order_id, boi.location_id,
        boi.lot_number, boi.product_id, op.title as product_name,
        rwl.name as location_name, rwl.type as location_type
      FROM billing_order_items boi
      JOIN billing_orders bo ON boi.billing_order_id = bo.id
      LEFT JOIN org_products op ON boi.product_id = op.id
      LEFT JOIN real_world_locations rwl ON boi.location_id = rwl.id
      WHERE bo.created_by_user_id = $1
        AND bo.created_at > NOW() - INTERVAL '30 minutes'
      ORDER BY bo.created_at DESC
      LIMIT 10
```

| id | billing_order_id | location_id | lot_number | product_id | product_name | location_name | location_type |
| --- | --- | --- | --- | --- | --- | --- | --- |
| 019fc9df-d42d-79fd-8746-907d1906db65 | 019fc9df-d431-75d3-b678-4ae17a616fde | b7f8a9b0-c1d2-3456-1234-567890123456 | URS050-SP-001 | 01989ca2-6a54-7834-8376-06a0251bacd8 | NovaPatch® PET | TRUNK-26 | trunk_stock |

### Lot number matches test data — ✅ PASS

**Assertion:** Billing order item should have lot_number = URS050-SP-001

```sql
SELECT boi.lot_number, boi.location_id, rwl.name as location_name
      FROM billing_order_items boi
      JOIN billing_orders bo ON boi.billing_order_id = bo.id
      LEFT JOIN real_world_locations rwl ON boi.location_id = rwl.id
      WHERE bo.created_by_user_id = $1
        AND bo.created_at > NOW() - INTERVAL '30 minutes'
        AND boi.lot_number = $2
      LIMIT 5
```

| lot_number | location_id | location_name |
| --- | --- | --- |
| URS050-SP-001 | b7f8a9b0-c1d2-3456-1234-567890123456 | TRUNK-26 |

### Order linked to correct sales account — ✅ PASS

**Assertion:** The billing order should be linked to ROSS Surgical Account

```sql
SELECT bo.id, bo.sales_account_id, sa.name as account_name
      FROM billing_orders bo
      JOIN sales_accounts sa ON bo.sales_account_id = sa.id
      WHERE bo.created_by_user_id = $1
        AND bo.created_at > NOW() - INTERVAL '30 minutes'
        AND bo.sales_account_id = $2
      ORDER BY bo.created_at DESC
      LIMIT 5
```

| id | sales_account_id | account_name |
| --- | --- | --- |
| 019fc9df-d431-75d3-b678-4ae17a616fde | fea7b8c9-d0e1-2345-0123-456789012345 | ROSS Surgical Account Request |

### Inventory history records removal from other rep's trunk — ✅ PASS

**Assertion:** Inventory history should show a removal with reason=bill_only_order from TRUNK-26 (Rana)

```sql
SELECT ih.id, ih.item_id, ih.quantity, ih.status, ih.info,
        ih.created_at, ii.lot, ii.real_world_location_id, rwl.name as location_name
      FROM inventory_history ih
      JOIN inventory_items ii ON ih.item_id = ii.id
      LEFT JOIN real_world_locations rwl ON ii.real_world_location_id = rwl.id
      WHERE ii.lot = $1
        AND ii.organization_id = $2
        AND ih.created_at > NOW() - INTERVAL '30 minutes'
        AND ih.info->>'action' = 'removed'
        AND ih.info->>'reason' = 'bill_only_order'
      ORDER BY ih.created_at DESC
      LIMIT 10
```

| id | item_id | quantity | status | info | created_at | lot | real_world_location_id | location_name |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 019fc9df-d443-7f83-80a1-42975f9e2408 | fbcd85d6-d571-4857-86ed-0eb1ed7cd1fa | 1 | ready | `{"action":"removed","reason":"bill_only_order","bestEffort":true,"billingOrderId":"019fc9df-d431-75d3-b678-4ae17a616fde","shortageQuantity":0,"requestedQuantity":1}` | 2026-08-03T23:05:17.024Z | URS050-SP-001 | b7f8a9b0-c1d2-3456-1234-567890123456 | TRUNK-26 |

### Blair's own trunk was NOT decremented — ✅ PASS

**Assertion:** Blair's trunk (TRUNK-36) should not have any bill_only_order removals for the test lot

```sql
SELECT ih.id, ih.item_id, ih.info, ih.created_at, ii.lot
      FROM inventory_history ih
      JOIN inventory_items ii ON ih.item_id = ii.id
      WHERE ii.lot = $1
        AND ii.organization_id = $2
        AND ih.created_at > NOW() - INTERVAL '30 minutes'
        AND ih.info->>'action' = 'removed'
        AND ih.info->>'reason' = 'bill_only_order'
      LIMIT 5
```

*No rows returned*

## Audit & Email Assertion Ledger

Per-declaration outcome of every `expectedAuditActions` and `expectedEmailTemplates` entry written into the orchestrator. Missing evidence here is a real test failure, not a soft warning.

### Audit Action Assertions

Each row asserts that a declared `expectedAuditActions` entry produced a matching row in `audit_events`. A ❌ flips overall status to FAIL — the declaration is real proof, not just an annotation.

| Step | Expected Audit Action | Found |
|------|-----------------------|-------|
| Step 3: Other rep trunk selection | `decision:bill_only_order.inventory_items_decrement` | ✅ |

### Email Template Assertions

Each row asserts that a declared `expectedEmailTemplates` entry was matched (case-insensitive substring) by a captured email subject or template. A ❌ flips overall status to FAIL.

| Step | Expected Template | Found |
|------|-------------------|-------|
| Step 3: Other rep trunk selection | `New Bill-Only Order` | ✅ |

## Audit Log Events

Every row written to `audit_events` while this test was running (scoped to the demo organizations). Provides compliance evidence that user actions are traced end-to-end (URS-003).

**Capture window start:** 2026-08-03T23:04:18.867Z

<details><summary>Query used to capture events</summary>

```sql
SELECT
    ae.created_at,
    ae.event_type,
    ae.action,
    ae.user_id,
    u.email AS user_email,
    ae.organization_id,
    o.name AS organization_name,
    ae.object_id,
    ae.secondary_object_id,
    ae.payload,
    ae.route,
    ae.trace_id
  FROM audit_events ae
  LEFT JOIN users u ON u.id = ae.user_id
  LEFT JOIN organizations o ON o.id = ae.organization_id
  WHERE ae.created_at >= $1
    AND ae.organization_id = ANY($2::uuid[])
  ORDER BY ae.created_at ASC
```
</details>

11 event(s) captured:

| Time | Type | Action | User | Org | Object ID | Performed | Reason |
|------|------|--------|------|-----|-----------|-----------|--------|
| 2026-08-03 23:04:19Z | checklist | checklists.create | — | Corveta Surgical Group | 019fc9de-f2a3-7870-a862-af3c9b5f88bf | — |  |
| 2026-08-03 23:04:19Z | decision | ensure_lot_expiration_checklist | — | Corveta Surgical Group | b2c3d4e5-f6a7-8901-bcde-f12345678901 | yes | created_1_reopened_0_already_open_1 |
| 2026-08-03 23:04:24Z | user_log | user:login | blair.bennett@corvetasurgical.com | Corveta Surgical Group | — | — |  |
| 2026-08-03 23:04:32Z | user_log | user:login | blair.bennett@corvetasurgical.com | Corveta Surgical Group | — | — |  |
| 2026-08-03 23:04:47Z | user_log | user:login | blair.bennett@corvetasurgical.com | Corveta Surgical Group | — | — |  |
| 2026-08-03 23:05:17Z | decision | bill_only_order.inventory_items_decrement | blair.bennett@corvetasurgical.com | Vantis | 019fc9df-d431-75d3-b678-4ae17a616fde | yes | inventory_items_decremented |
| 2026-08-03 23:05:17Z | decision | bill_only.link_purchase_order | blair.bennett@corvetasurgical.com | Corveta Surgical Group | 019fc9df-d431-75d3-b678-4ae17a616fde | no | no_purchase_order_selected |
| 2026-08-03 23:05:17Z | decision | bill_only_order.direct_po_import_on_create | blair.bennett@corvetasurgical.com | Vantis | 019fc9df-d431-75d3-b678-4ae17a616fde | no | No uploaded PO documents |
| 2026-08-03 23:05:17Z | billing_order | status_change | blair.bennett@corvetasurgical.com | Vantis | 019fc9df-d431-75d3-b678-4ae17a616fde | — |  |
| 2026-08-03 23:05:18Z | transactional_email | new_bill_only | — | Corveta Surgical Group | 019fc9df-d431-75d3-b678-4ae17a616fde | — |  |
| 2026-08-03 23:05:23Z | user_log | user:login | blair.bennett@corvetasurgical.com | Corveta Surgical Group | — | — |  |

## Email Evidence

1 notification email(s) were captured during this test run. Each email is rendered as a screenshot for compliance review.

### 1. New Bill-Only Order - 8/3/2026 - Vantis BO-1

**Template:** `New_Bill-Only_Order_-_8_3_2026_-_Vantis_BO-1`

![New Bill-Only Order - 8/3/2026 - Vantis BO-1](screenshots/emails/2026-08-03T23-05-18-022Z-New_Bill-Only_Order_-_8_3_2026_-_Vantis_BO-1.png)
