# Validation Report: URS-050

**Title:** Select Another Rep's Trunk Stock for Bill-Only Orders
**Date:** 2026-04-23T03:43:21.310Z
**Duration:** 71.6s
**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_ZuriMED_DeviceFlow.xlsx` — the run below proves the system meets this requirement.*

## Environment

- **Inbox URL:** http://localhost:64931
- **Database:** localhost:64932/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-04-23T03:43:59.897Z → 2026-04-23T03:44:23.150Z)*

| Time | Type | Action | User | Org | Performed |
|------|------|--------|------|-----|-----------|
| 2026-04-23 03:44:18Z | decision | bill_only_order.enqueue_upload_classification | bob.kauffman@stellartech.com | ZuriMED | no |
| 2026-04-23 03:44:19Z | transactional_email | new_bill_only | — | StellarTech Medical Solutions | — |

**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 - 4/22/2026 - ZuriMED BO-1**

Template: `New_Bill-Only_Order_-_4_22_2026_-_ZuriMED_BO-1`

![New Bill-Only Order - 4/22/2026 - ZuriMED BO-1](screenshots/emails/2026-04-23T03-44-19-116Z-New_Bill-Only_Order_-_4_22_2026_-_ZuriMED_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 Bob — ✅ PASS

**Assertion:** At least one billing order should have been created by Bob Kauffman 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 |
| --- | --- | --- | --- | --- | --- |
| 019db870-44f4-7496-a32e-e56d5f34dad2 | BO-1 | submitted | fea7b8c9-d0e1-2345-0123-456789012345 | 2026-04-23T03:44:18.654Z | 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 (Ryan'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 |
| --- | --- | --- | --- | --- | --- | --- | --- |
| 019db870-44f2-7c67-ade0-33faa1e7b3d4 | 019db870-44f4-7496-a32e-e56d5f34dad2 | b7f8a9b0-c1d2-3456-1234-567890123456 | URS050-SP-001 | 01989ca1-f2f8-7ab7-8269-7179342797cc | FiberLocker® Instrument SN | 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 BOSS 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 |
| --- | --- | --- |
| 019db870-44f4-7496-a32e-e56d5f34dad2 | fea7b8c9-d0e1-2345-0123-456789012345 | BOSS 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 (Ryan)

```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 |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 019db870-44fb-7db8-9438-86f6fc04fa09 | 019db870-44fb-7db8-9438-86f55bc9d50b | 1 | ready | `{"action":"removed","reason":"bill_only_order","bestEffort":true,"billingOrderId":"019db870-44f4-7496-a32e-e56d5f34dad2","shortageQuantity":1,"requestedQuantity":1}` | 2026-04-23T03:44:18.654Z | URS050-SP-001 | b7f8a9b0-c1d2-3456-1234-567890123456 | TRUNK-26 |

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

**Assertion:** Bob'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.enqueue_upload_classification` | ✅ |

### 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-04-23T03:43:19.403Z

<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>

6 event(s) captured:

| Time | Type | Action | User | Org | Object ID | Performed | Reason |
|------|------|--------|------|-----|-----------|-----------|--------|
| 2026-04-23 03:43:23Z | user_log | user:login | bob.kauffman@stellartech.com | StellarTech Medical Solutions | — | — |  |
| 2026-04-23 03:43:32Z | user_log | user:login | bob.kauffman@stellartech.com | StellarTech Medical Solutions | — | — |  |
| 2026-04-23 03:43:47Z | user_log | user:login | bob.kauffman@stellartech.com | StellarTech Medical Solutions | — | — |  |
| 2026-04-23 03:44:18Z | decision | bill_only_order.enqueue_upload_classification | bob.kauffman@stellartech.com | ZuriMED | 019db870-44f4-7496-a32e-e56d5f34dad2 | no | No uploaded PO documents |
| 2026-04-23 03:44:19Z | transactional_email | new_bill_only | — | StellarTech Medical Solutions | 019db870-44f4-7496-a32e-e56d5f34dad2 | — |  |
| 2026-04-23 03:44:24Z | user_log | user:login | bob.kauffman@stellartech.com | StellarTech Medical Solutions | — | — |  |

## 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 - 4/22/2026 - ZuriMED BO-1

**Template:** `New_Bill-Only_Order_-_4_22_2026_-_ZuriMED_BO-1`

![New Bill-Only Order - 4/22/2026 - ZuriMED BO-1](screenshots/emails/2026-04-23T03-44-19-116Z-New_Bill-Only_Order_-_4_22_2026_-_ZuriMED_BO-1.png)
