# Validation Report: URS-023

**Title:** Generate Shipping Documentation Linked to Orders
**Date:** 2026-04-23T03:38:55.098Z
**Duration:** 110.3s
**Overall Status:** ✅ PASS

## User Requirement

> The system shall generate orders and link shipments to the corresponding order.

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

## Environment

- **Inbox URL:** http://localhost:63510
- **Database:** localhost:63511/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: Create order — ✅ PASS

**What this step proves:**

A sales rep creates a new order in the system. This establishes the source document that shipping documentation will later be linked to, verifying the order initiation flow.

**Audit events generated by this step:**

*(Evidence scoped to step execution window: 2026-04-23T03:39:09.627Z → 2026-04-23T03:39:27.019Z)*

| Time | Type | Action | User | Org | Performed |
|------|------|--------|------|-----|-----------|
| 2026-04-23 03:39:22Z | decision | order_request_created | bob.kauffman@stellartech.com | ZuriMED | yes |

**Emails triggered by this step:**

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

**Email 1: Consignment Order Created - OR-1-FO-1**

Template: `Consignment_Order_Created_-_OR-1-FO-1`

![Consignment Order Created - OR-1-FO-1](screenshots/emails/2026-04-23T03-39-44-137Z-Consignment_Order_Created_-_OR-1-FO-1.png)

**Screenshots:**

![step 01 location selected](screenshots/step-01-location-selected.png)

![step 01 products selected](screenshots/step-01-products-selected.png)

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

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

**Video recording:**

[▶ Watch step recording](videos/step-01-create-order.webm)

---

### 2. Step 2: Approve and find fulfillment — ✅ PASS

**What this step proves:**

A manufacturer user approves the submitted order and locates the associated fulfillment record. This verifies the order transitions to an approvable state and that the system correctly resolves the fulfillment entry for the order.

**Audit events generated by this step:**

*(Evidence scoped to step execution window: 2026-04-23T03:39:35.947Z → 2026-04-23T03:40:04.168Z)*

| Time | Type | Action | User | Org | Performed |
|------|------|--------|------|-----|-----------|
| 2026-04-23 03:39:44Z | transactional_email | order_created | — | StellarTech Medical Solutions | — |

**Screenshots:**

![step 02 order requests list](screenshots/step-02-order-requests-list.png)

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

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

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

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

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

**Video recording:**

[▶ Watch step recording](videos/step-02-approve-and-find.webm)

---

### 3. Step 3: Create shipment — ✅ PASS

**What this step proves:**

A shipping-notice CSV manifest is generated for the fulfillment order, uploaded to S3, and imported via the production Restate `Import.runImportJob` handler — the same path the UI `/packages/upload` form uses. This creates the shipping_package + items, links the package to the fulfillment order, and advances the fulfillment-order status.

**Screenshots:**

![step 03 linked packages](screenshots/step-03-linked-packages.png)

**Video recording:**

[▶ Watch step recording](videos/step-03-create-shipment.webm)

---

### 4. Step 4: Verify package — ✅ PASS

**What this step proves:**

The shipment package record is verified to be linked to the originating order. This confirms that shipping documentation is correctly associated with the source order, satisfying the traceability requirement.

**Screenshots:**

![step 04 fulfillment with package](screenshots/step-04-fulfillment-with-package.png)

![step 04 shipping documentation](screenshots/step-04-shipping-documentation.png)

**Video recording:**

[▶ Watch step recording](videos/step-04-verify-package.webm)

---

### 5. Step 5: Verify linkage — ✅ PASS

**What this step proves:**

This step proves the shipment is correctly linked to the order in the database. It provides direct evidence that the shipping record references the originating order, confirming the required order-to-shipment traceability.

**Screenshots:**

![step 05 order with shipment](screenshots/step-05-order-with-shipment.png)

![step 05 order status](screenshots/step-05-order-status.png)

**Video recording:**

[▶ Watch step recording](videos/step-05-verify-linkage.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.

### Order request created — ✅ PASS

**Assertion:** At least one order request should have been created by Bob Kauffman recently

```sql
SELECT orq.id, orq.request_number, orq.status, orq.shipping_status,
        orq.created_at, orq.requested_by_user_id
      FROM order_requests orq
      WHERE orq.requested_by_user_id = $1
        AND orq.created_at > NOW() - INTERVAL '30 minutes'
      ORDER BY orq.created_at DESC
      LIMIT 5
```

| id | request_number | status | shipping_status | created_at | requested_by_user_id |
| --- | --- | --- | --- | --- | --- |
| 019db86b-be52-7d41-9abc-970d5aa82787 | OR-1 | approved | NULL | 2026-04-23T03:39:22.030Z | 17b8c9d0-e1f2-3456-1234-567890123456 |

### Fulfillment order created and linked to order request — ✅ PASS

**Assertion:** A fulfillment order should exist linked to the order request

```sql
SELECT fo.id, fo.order_number, fo.status, fo.order_request_id,
        fo.fulfilling_organization_id, fo.requesting_organization_id,
        fo.shipping_street_address, fo.shipping_city, fo.shipping_state, fo.shipping_zip,
        fo.created_at
      FROM fulfillment_orders fo
      JOIN order_requests orq ON fo.order_request_id = orq.id
      WHERE orq.requested_by_user_id = $1
        AND orq.created_at > NOW() - INTERVAL '30 minutes'
      ORDER BY fo.created_at DESC
      LIMIT 5
```

| id | order_number | status | order_request_id | fulfilling_organization_id | requesting_organization_id | shipping_street_address | shipping_city | shipping_state | shipping_zip | created_at |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 019db86c-1473-796a-82f2-9db373a39f2e | OR-1-FO-1 | shipped | 019db86b-be52-7d41-9abc-970d5aa82787 | a1b2c3d4-e5f6-7890-abcd-ef1234567890 | b2c3d4e5-f6a7-8901-bcde-f12345678901 | 100 Charles River Plaza, Suite 300 | Boston | MA | 02114 | 2026-04-23T03:39:44.064Z |

### Fulfillment order items match ordered products — ✅ PASS

**Assertion:** Fulfillment order should contain both SpeedPatch and FiberLocker products

```sql
SELECT foi.id, foi.fulfillment_order_id, foi.product_id, foi.description, foi.quantity,
        op.title as product_name, op.sku
      FROM fulfillment_order_items foi
      JOIN org_products op ON foi.product_id = op.id
      JOIN fulfillment_orders fo ON foi.fulfillment_order_id = fo.id
      JOIN order_requests orq ON fo.order_request_id = orq.id
      WHERE orq.requested_by_user_id = $1
        AND orq.created_at > NOW() - INTERVAL '30 minutes'
      ORDER BY op.title
```

| id | fulfillment_order_id | product_id | description | quantity | product_name | sku |
| --- | --- | --- | --- | --- | --- | --- |
| 019db86c-1474-7f51-9808-33f92938c760 | 019db86c-1473-796a-82f2-9db373a39f2e | 01978a05-ba4c-7f6d-91c8-bac1498e9bbe | FiberLocker® Instrument (For Cadaver lab use) | 2 | FiberLocker® Instrument (For Cadaver lab use) | FL2025CL |
| 019db86c-1474-7f51-9808-33fac4dd6b0c | 019db86c-1473-796a-82f2-9db373a39f2e | 01989ca2-6a54-7834-8376-06a0251bacd8 | SpeedPatch® PET | 3 | SpeedPatch® PET | SP019N1A |

### Shipping package created with correct tracking — ✅ PASS

**Assertion:** Shipping package should exist with tracking prefix URS023-TEST- and carrier UPS

```sql
SELECT sp.id, sp.tracking_number, sp.carrier, sp.status,
        sp.organization_id, sp.created_at
      FROM shipping_packages sp
      WHERE sp.tracking_number LIKE $1
        AND sp.organization_id IN ($2, $3)
        AND sp.created_at > NOW() - INTERVAL '30 minutes'
      ORDER BY sp.created_at DESC
      LIMIT 1
```

| id | tracking_number | carrier | status | organization_id | created_at |
| --- | --- | --- | --- | --- | --- |
| 019db86c-7e55-7a5b-88f3-65d08521b59f | URS023-TEST-1776915536723 | ups | unknown | a1b2c3d4-e5f6-7890-abcd-ef1234567890 | 2026-04-23T03:40:11.226Z |

### Shipping package linked to fulfillment order — ✅ PASS

**Assertion:** The shipping_package_fulfillment_orders join table should link the package to the fulfillment order

```sql
SELECT spfo.id, spfo.shipping_package_id, spfo.fulfillment_order_id,
        sp.tracking_number, fo.order_number
      FROM shipping_package_fulfillment_orders spfo
      JOIN shipping_packages sp ON spfo.shipping_package_id = sp.id
      JOIN fulfillment_orders fo ON spfo.fulfillment_order_id = fo.id
      WHERE sp.tracking_number LIKE $1
        AND sp.organization_id IN ($2, $3)
        AND sp.created_at > NOW() - INTERVAL '30 minutes'
```

| id | shipping_package_id | fulfillment_order_id | tracking_number | order_number |
| --- | --- | --- | --- | --- |
| 019db86c-7e5c-7c79-89db-e3e8515d224c | 019db86c-7e55-7a5b-88f3-65d08521b59f | 019db86c-1473-796a-82f2-9db373a39f2e | URS023-TEST-1776915536723 | OR-1-FO-1 |

### Shipping package items contain correct products with order linkage — ✅ PASS

**Assertion:** Shipping package items should reference the ordered products with correct quantities AND populate order_number + order_line_number for traceability

```sql
SELECT spi.id, spi.package_id, spi.quantity, spi.order_number, spi.order_line_number,
        spi.info->>'sku' as sku, spi.info->>'productId' as product_id
      FROM shipping_package_items spi
      JOIN shipping_packages sp ON spi.package_id = sp.id
      WHERE sp.tracking_number LIKE $1
        AND sp.organization_id IN ($2, $3)
        AND sp.created_at > NOW() - INTERVAL '30 minutes'
      ORDER BY spi.id
```

| id | package_id | quantity | order_number | order_line_number | sku | product_id |
| --- | --- | --- | --- | --- | --- | --- |
| 019db86c-7e5b-784b-aa2b-0a9996303bf1 | 019db86c-7e55-7a5b-88f3-65d08521b59f | 3 | OR-1-FO-1 | 1 | SP019N1A | NULL |
| 019db86c-7e5b-784b-aa2b-0a9ae2b4ad81 | 019db86c-7e55-7a5b-88f3-65d08521b59f | 2 | OR-1-FO-1 | 2 | FL516SNA | NULL |

### Fulfillment order status advanced after shipment creation — ✅ PASS

**Assertion:** Fulfillment order status should be one of [partially_fulfilled, fulfilled, partially_shipped, shipped, delivered, partially_delivered, completed] once a shipment exists

```sql
SELECT fo.id, fo.order_number, fo.status
      FROM fulfillment_orders fo
      JOIN order_requests orq ON fo.order_request_id = orq.id
      WHERE orq.requested_by_user_id = $1
        AND orq.created_at > NOW() - INTERVAL '30 minutes'
      ORDER BY fo.created_at DESC
      LIMIT 1
```

| id | order_number | status |
| --- | --- | --- |
| 019db86c-1473-796a-82f2-9db373a39f2e | OR-1-FO-1 | shipped |

## 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 1: Create order | `user_log:user:login` | ✅ |
| Step 2: Approve and find fulfillment | `user_log:user:login` | ✅ |

### 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 1: Create order | `Consignment Order Created` | ✅ |

## 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:38:53.225Z

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

7 event(s) captured:

| Time | Type | Action | User | Org | Object ID | Performed | Reason |
|------|------|--------|------|-----|-----------|-----------|--------|
| 2026-04-23 03:38:58Z | user_log | user:login | bob.kauffman@stellartech.com | StellarTech Medical Solutions | — | — |  |
| 2026-04-23 03:39:22Z | decision | order_request_created | bob.kauffman@stellartech.com | ZuriMED | 019db86b-be52-7d41-9abc-970d5aa82787 | yes | Order request OR-1 created (importSource=manual) |
| 2026-04-23 03:39:30Z | user_log | user:login | mark.manufacturer@zurimed.com | ZuriMED | — | — |  |
| 2026-04-23 03:39:44Z | transactional_email | order_created | — | StellarTech Medical Solutions | 019db86c-1473-796a-82f2-9db373a39f2e | — |  |
| 2026-04-23 03:40:07Z | user_log | user:login | mark.manufacturer@zurimed.com | ZuriMED | — | — |  |
| 2026-04-23 03:40:23Z | user_log | user:login | mark.manufacturer@zurimed.com | ZuriMED | — | — |  |
| 2026-04-23 03:40:35Z | user_log | user:login | mark.manufacturer@zurimed.com | ZuriMED | — | — |  |

## Email Evidence

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

### 1. Consignment Order Created - OR-1-FO-1

**Template:** `Consignment_Order_Created_-_OR-1-FO-1`

![Consignment Order Created - OR-1-FO-1](screenshots/emails/2026-04-23T03-39-44-137Z-Consignment_Order_Created_-_OR-1-FO-1.png)
