# Validation Report: URS-027

**Title:** Auto-notify distributors on applicable order types
**Date:** 2026-04-23T03:38:59.036Z
**Duration:** 68.8s
**Overall Status:** ✅ PASS

## User Requirement

> The system shall notify distributors (e.g., Uniphar) automatically when applicable order types are submitted.

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

## Environment

- **Inbox URL:** http://localhost:63525
- **Database:** localhost:63526/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: Distributor notification recipients configured — ✅ PASS

**What this step proves:**

Confirms the notification routing configuration has distributor recipients wired to the `order_request_submitted` event type. This pre-condition check ensures the auto-notify mechanism is enabled before any orders are submitted.

**Audit events generated by this step:**

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

| Time | Type | Action | User | Org | Performed |
|------|------|--------|------|-----|-----------|
| 2026-04-23 03:39:01Z | user_log | user:login | mark.manufacturer@zurimed.com | ZuriMED | — |
| 2026-04-23 03:39:12Z | user_log | user:login | bob.kauffman@stellartech.com | StellarTech Medical Solutions | — |
| 2026-04-23 03:39:36Z | user_log | user:login | bob.kauffman@stellartech.com | StellarTech Medical Solutions | — |
| 2026-04-23 03:39:54Z | user_log | user:login | mark.manufacturer@zurimed.com | ZuriMED | — |

**Screenshots:**

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

**Video recording:**

[▶ Watch step recording](videos/step-01-recipients-config.webm)

---

### 2. Step 2: Submit dropship order — ✅ PASS

**What this step proves:**

A sales rep submits a dropship order, which is a notification-eligible order type. This triggers the `order_request_submitted` event and causes the system to automatically enqueue distributor notification emails, directly exercising the auto-notify requirement.

**Audit events generated by this step:**

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

| Time | Type | Action | User | Org | Performed |
|------|------|--------|------|-----|-----------|
| 2026-04-23 03:39:32Z | 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: New Order Request Submitted - OR-1 from StellarTech Medical Solutions**

Template: `New_Order_Request_Submitted_-_OR-1_from_StellarTech_Medical_Solutions`

![New Order Request Submitted - OR-1 from StellarTech Medical Solutions](screenshots/emails/2026-04-23T03-39-32-113Z-New_Order_Request_Submitted_-_OR-1_from_StellarTech_Medical_Solutions.png)

**Email 2: New Order Request Submitted - OR-2 from StellarTech Medical Solutions**

Template: `New_Order_Request_Submitted_-_OR-2_from_StellarTech_Medical_Solutions`

![New Order Request Submitted - OR-2 from StellarTech Medical Solutions](screenshots/emails/2026-04-23T03-39-50-103Z-New_Order_Request_Submitted_-_OR-2_from_StellarTech_Medical_Solutions.png)

**Email 3: New Order Request Submitted - OR-1 from StellarTech Medical Solutions**

Template: `order_request_submitted`

![New Order Request Submitted - OR-1 from StellarTech Medical Solutions](screenshots/emails/OR-1-inv_1gbEpmqpGBKQ5DbIYIsRkjMrtmGwAh5nlD.png)

**Email 4: New Order Request Submitted - OR-2 from StellarTech Medical Solutions**

Template: `order_request_submitted`

![New Order Request Submitted - OR-2 from StellarTech Medical Solutions](screenshots/emails/OR-2-inv_1iBkZa7JZk8q7b0iH4i0efnXCzKt15U39n.png)

**Screenshots:**

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

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

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

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

**Video recording:**

[▶ Watch step recording](videos/step-02-submit-dropship.webm)

---

### 3. Step 3: Submit consignment order — ✅ PASS

**What this step proves:**

A sales rep submits a consignment order to provide a contrast case. This verifies that the auto-notify behavior applies to multiple applicable order types and that the system processes each submission without error.

**Audit events generated by this step:**

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

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

**Emails triggered by this step:**

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

**Email 1: New Order Request Submitted - OR-1 from StellarTech Medical Solutions**

Template: `New_Order_Request_Submitted_-_OR-1_from_StellarTech_Medical_Solutions`

![New Order Request Submitted - OR-1 from StellarTech Medical Solutions](screenshots/emails/2026-04-23T03-39-32-113Z-New_Order_Request_Submitted_-_OR-1_from_StellarTech_Medical_Solutions.png)

**Email 2: New Order Request Submitted - OR-2 from StellarTech Medical Solutions**

Template: `New_Order_Request_Submitted_-_OR-2_from_StellarTech_Medical_Solutions`

![New Order Request Submitted - OR-2 from StellarTech Medical Solutions](screenshots/emails/2026-04-23T03-39-50-103Z-New_Order_Request_Submitted_-_OR-2_from_StellarTech_Medical_Solutions.png)

**Email 3: New Order Request Submitted - OR-1 from StellarTech Medical Solutions**

Template: `order_request_submitted`

![New Order Request Submitted - OR-1 from StellarTech Medical Solutions](screenshots/emails/OR-1-inv_1gbEpmqpGBKQ5DbIYIsRkjMrtmGwAh5nlD.png)

**Email 4: New Order Request Submitted - OR-2 from StellarTech Medical Solutions**

Template: `order_request_submitted`

![New Order Request Submitted - OR-2 from StellarTech Medical Solutions](screenshots/emails/OR-2-inv_1iBkZa7JZk8q7b0iH4i0efnXCzKt15U39n.png)

**Screenshots:**

![step 03 consignment form](screenshots/step-03-consignment-form.png)

![step 03 consignment products](screenshots/step-03-consignment-products.png)

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

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

**Video recording:**

[▶ Watch step recording](videos/step-03-submit-consignment.webm)

---

### 4. Step 4: Manufacturer sees orders — ✅ PASS

**What this step proves:**

A manufacturer admin reviews both submitted orders in the system. This confirms that both order types are visible in the manufacturer view and that each submission completed successfully end-to-end.

**Screenshots:**

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

**Video recording:**

[▶ Watch step recording](videos/step-04-orders-list.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.

### Both URS-027 order_requests exist — ✅ PASS

**Assertion:** Both the dropship and consignment URS-027 test orders should exist

```sql
SELECT id, request_number, order_type, status, notes,
      receiving_rep_user_id, fulfilling_organization_id, requesting_organization_id
    FROM order_requests
    WHERE requested_by_user_id = $1
      AND notes LIKE $2
    ORDER BY created_at DESC
```

| id | request_number | order_type | status | notes | receiving_rep_user_id | fulfilling_organization_id | requesting_organization_id |
| --- | --- | --- | --- | --- | --- | --- | --- |
| 019db86c-2b98-7b66-aef8-1a4710cf7244 | OR-2 | consignment | submitted | URS-027 consignment contrast order | NULL | a1b2c3d4-e5f6-7890-abcd-ef1234567890 | b2c3d4e5-f6a7-8901-bcde-f12345678901 |
| 019db86b-e554-77a2-93af-0193daf5393d | OR-1 | dropship | submitted | URS-027 dropship distributor-applicable order | NULL | a1b2c3d4-e5f6-7890-abcd-ef1234567890 | b2c3d4e5-f6a7-8901-bcde-f12345678901 |

### Both order types (dropship + consignment) successfully submitted — ✅ PASS

**Assertion:** Both a dropship and a consignment URS-027 order should exist (each must trigger distributor notifications independent of order_type).

```sql
SELECT id, request_number, order_type, status, notes,
      receiving_rep_user_id, fulfilling_organization_id, requesting_organization_id
    FROM order_requests
    WHERE requested_by_user_id = $1
      AND notes LIKE $2
    ORDER BY created_at DESC
```

| id | request_number | order_type | status | notes | receiving_rep_user_id | fulfilling_organization_id | requesting_organization_id |
| --- | --- | --- | --- | --- | --- | --- | --- |
| 019db86b-e554-77a2-93af-0193daf5393d | OR-1 | dropship | submitted | URS-027 dropship distributor-applicable order | NULL | a1b2c3d4-e5f6-7890-abcd-ef1234567890 | b2c3d4e5-f6a7-8901-bcde-f12345678901 |
| 019db86c-2b98-7b66-aef8-1a4710cf7244 | OR-2 | consignment | submitted | URS-027 consignment contrast order | NULL | a1b2c3d4-e5f6-7890-abcd-ef1234567890 | b2c3d4e5-f6a7-8901-bcde-f12345678901 |

### Distributor + manufacturer notification recipients are configured — ✅ PASS

**Assertion:** Both ZuriMED and StellarTech must have at least one CC recipient for order_request_submitted notifications

```sql
SELECT organization_id, notification_type, email_address, name,
      recipient_purpose
    FROM organization_notification_recipients
    WHERE notification_type = 'order_request_submitted'
      AND organization_id = ANY($1)
      AND recipient_purpose = 'cc'
      AND email_address IS NOT NULL
    ORDER BY organization_id, email_address
```

| organization_id | notification_type | email_address | name | recipient_purpose |
| --- | --- | --- | --- | --- |
| a1b2c3d4-e5f6-7890-abcd-ef1234567890 | order_request_submitted | urs027-distributor-test@zurimed-fulfillment.example.com | URS-027 distributor recipient | cc |
| b2c3d4e5-f6a7-8901-bcde-f12345678901 | order_request_submitted | urs027-distributor-test@stellartech-distributor.example.com | URS-027 distributor recipient | cc |

### order_request_submitted notification was enqueued/sent for the dropship order — ✅ PASS

**Assertion:** There should be an email row tied to the dropship order in restate_outbox, restate_outbox_dlq, audit_events, or the spec-captured snapshot dir

```sql
restate_outbox + restate_outbox_dlq + audit_events + spec snapshots
```

| source | related_entity_id | to_addresses | cc_addresses | subject | has_html |
| --- | --- | --- | --- | --- | --- |
| snapshot | 019db86b-e554-77a2-93af-0193daf5393d | `["URS-027 distributor recipient <urs027-distributor-test@zurimed-fulfillment.example.com>","URS-027 distributor recipient <urs027-distributor-test@stellartech-distributor.example.com>"]` | `[]` | New Order Request Submitted - OR-1 from StellarTech Medical Solutions | true |
| audit_events | 019db86b-e554-77a2-93af-0193daf5393d | `["URS-027 distributor recipient <urs027-distributor-test@zurimed-fulfillment.example.com>","URS-027 distributor recipient <urs027-distributor-test@stellartech-distributor.example.com>"]` | `[]` | New Order Request Submitted - OR-1 from StellarTech Medical Solutions | false |

### order_request_submitted notification was enqueued/sent for the consignment order — ✅ PASS

**Assertion:** There should be an email row tied to the consignment order in restate_outbox, restate_outbox_dlq, audit_events, or the spec-captured snapshot dir

```sql
restate_outbox + restate_outbox_dlq + audit_events + spec snapshots
```

| source | related_entity_id | to_addresses | cc_addresses | subject | has_html |
| --- | --- | --- | --- | --- | --- |
| snapshot | 019db86c-2b98-7b66-aef8-1a4710cf7244 | `["URS-027 distributor recipient <urs027-distributor-test@zurimed-fulfillment.example.com>","URS-027 distributor recipient <urs027-distributor-test@stellartech-distributor.example.com>"]` | `[]` | New Order Request Submitted - OR-2 from StellarTech Medical Solutions | true |
| audit_events | 019db86c-2b98-7b66-aef8-1a4710cf7244 | `["URS-027 distributor recipient <urs027-distributor-test@zurimed-fulfillment.example.com>","URS-027 distributor recipient <urs027-distributor-test@stellartech-distributor.example.com>"]` | `[]` | New Order Request Submitted - OR-2 from StellarTech Medical Solutions | false |

### Dropship email recipients include BOTH the URS-027 distributor + manufacturer marker emails — ✅ PASS

**Assertion:** The dropship order's notification(s) must address both the ZuriMED and the StellarTech URS-027 marker recipients (on `to` or `cc`) — proves distributor wiring fired.

```sql
evidence rows aggregated
```

| source | related_entity_id | to_addresses | cc_addresses | subject | has_html |
| --- | --- | --- | --- | --- | --- |
| snapshot | 019db86b-e554-77a2-93af-0193daf5393d | `["URS-027 distributor recipient <urs027-distributor-test@zurimed-fulfillment.example.com>","URS-027 distributor recipient <urs027-distributor-test@stellartech-distributor.example.com>"]` | `[]` | New Order Request Submitted - OR-1 from StellarTech Medical Solutions | true |
| audit_events | 019db86b-e554-77a2-93af-0193daf5393d | `["URS-027 distributor recipient <urs027-distributor-test@zurimed-fulfillment.example.com>","URS-027 distributor recipient <urs027-distributor-test@stellartech-distributor.example.com>"]` | `[]` | New Order Request Submitted - OR-1 from StellarTech Medical Solutions | false |

### Consignment email recipients include BOTH the URS-027 distributor + manufacturer marker emails — ✅ PASS

**Assertion:** The consignment order's notification(s) must address both the ZuriMED and the StellarTech URS-027 marker recipients (on `to` or `cc`).

```sql
evidence rows aggregated
```

| source | related_entity_id | to_addresses | cc_addresses | subject | has_html |
| --- | --- | --- | --- | --- | --- |
| snapshot | 019db86c-2b98-7b66-aef8-1a4710cf7244 | `["URS-027 distributor recipient <urs027-distributor-test@zurimed-fulfillment.example.com>","URS-027 distributor recipient <urs027-distributor-test@stellartech-distributor.example.com>"]` | `[]` | New Order Request Submitted - OR-2 from StellarTech Medical Solutions | true |
| audit_events | 019db86c-2b98-7b66-aef8-1a4710cf7244 | `["URS-027 distributor recipient <urs027-distributor-test@zurimed-fulfillment.example.com>","URS-027 distributor recipient <urs027-distributor-test@stellartech-distributor.example.com>"]` | `[]` | New Order Request Submitted - OR-2 from StellarTech Medical Solutions | false |

### At least one dropship-email subject references the dropship request_number — ✅ PASS

**Assertion:** At least one notification email for the dropship order must have a subject that references the dropship order's request_number

```sql
evidence rows aggregated
```

| source | related_entity_id | to_addresses | cc_addresses | subject | has_html |
| --- | --- | --- | --- | --- | --- |
| snapshot | 019db86b-e554-77a2-93af-0193daf5393d | `["URS-027 distributor recipient <urs027-distributor-test@zurimed-fulfillment.example.com>","URS-027 distributor recipient <urs027-distributor-test@stellartech-distributor.example.com>"]` | `[]` | New Order Request Submitted - OR-1 from StellarTech Medical Solutions | true |
| audit_events | 019db86b-e554-77a2-93af-0193daf5393d | `["URS-027 distributor recipient <urs027-distributor-test@zurimed-fulfillment.example.com>","URS-027 distributor recipient <urs027-distributor-test@stellartech-distributor.example.com>"]` | `[]` | New Order Request Submitted - OR-1 from StellarTech Medical Solutions | false |

### At least one consignment-email subject references the consignment request_number — ✅ PASS

**Assertion:** At least one notification email for the consignment order must have a subject that references the consignment order's request_number

```sql
evidence rows aggregated
```

| source | related_entity_id | to_addresses | cc_addresses | subject | has_html |
| --- | --- | --- | --- | --- | --- |
| snapshot | 019db86c-2b98-7b66-aef8-1a4710cf7244 | `["URS-027 distributor recipient <urs027-distributor-test@zurimed-fulfillment.example.com>","URS-027 distributor recipient <urs027-distributor-test@stellartech-distributor.example.com>"]` | `[]` | New Order Request Submitted - OR-2 from StellarTech Medical Solutions | true |
| audit_events | 019db86c-2b98-7b66-aef8-1a4710cf7244 | `["URS-027 distributor recipient <urs027-distributor-test@zurimed-fulfillment.example.com>","URS-027 distributor recipient <urs027-distributor-test@stellartech-distributor.example.com>"]` | `[]` | New Order Request Submitted - OR-2 from StellarTech Medical Solutions | false |

## 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: Distributor notification recipients configured | `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 2: Submit dropship order | `order_request_submitted` | ✅ |
| Step 3: Submit consignment order | `order_request_submitted` | ✅ |

## 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:57.156Z

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

8 event(s) captured:

| Time | Type | Action | User | Org | Object ID | Performed | Reason |
|------|------|--------|------|-----|-----------|-----------|--------|
| 2026-04-23 03:39:01Z | user_log | user:login | mark.manufacturer@zurimed.com | ZuriMED | — | — |  |
| 2026-04-23 03:39:12Z | user_log | user:login | bob.kauffman@stellartech.com | StellarTech Medical Solutions | — | — |  |
| 2026-04-23 03:39:32Z | decision | order_request_created | bob.kauffman@stellartech.com | ZuriMED | 019db86b-e554-77a2-93af-0193daf5393d | yes | Order request OR-1 created (importSource=manual) |
| 2026-04-23 03:39:32Z | transactional_email | order_request_submitted | — | ZuriMED | 019db86b-e554-77a2-93af-0193daf5393d | — |  |
| 2026-04-23 03:39:36Z | user_log | user:login | bob.kauffman@stellartech.com | StellarTech Medical Solutions | — | — |  |
| 2026-04-23 03:39:50Z | decision | order_request_created | bob.kauffman@stellartech.com | ZuriMED | 019db86c-2b98-7b66-aef8-1a4710cf7244 | yes | Order request OR-2 created (importSource=manual) |
| 2026-04-23 03:39:50Z | transactional_email | order_request_submitted | — | ZuriMED | 019db86c-2b98-7b66-aef8-1a4710cf7244 | — |  |
| 2026-04-23 03:39:54Z | user_log | user:login | mark.manufacturer@zurimed.com | ZuriMED | — | — |  |

## Email Evidence

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

### 1. New Order Request Submitted - OR-1 from StellarTech Medical Solutions

**Template:** `New_Order_Request_Submitted_-_OR-1_from_StellarTech_Medical_Solutions`

![New Order Request Submitted - OR-1 from StellarTech Medical Solutions](screenshots/emails/2026-04-23T03-39-32-113Z-New_Order_Request_Submitted_-_OR-1_from_StellarTech_Medical_Solutions.png)

### 2. New Order Request Submitted - OR-2 from StellarTech Medical Solutions

**Template:** `New_Order_Request_Submitted_-_OR-2_from_StellarTech_Medical_Solutions`

![New Order Request Submitted - OR-2 from StellarTech Medical Solutions](screenshots/emails/2026-04-23T03-39-50-103Z-New_Order_Request_Submitted_-_OR-2_from_StellarTech_Medical_Solutions.png)

### 3. New Order Request Submitted - OR-1 from StellarTech Medical Solutions

**Template:** `order_request_submitted`

![New Order Request Submitted - OR-1 from StellarTech Medical Solutions](screenshots/emails/OR-1-inv_1gbEpmqpGBKQ5DbIYIsRkjMrtmGwAh5nlD.png)

### 4. New Order Request Submitted - OR-2 from StellarTech Medical Solutions

**Template:** `order_request_submitted`

![New Order Request Submitted - OR-2 from StellarTech Medical Solutions](screenshots/emails/OR-2-inv_1iBkZa7JZk8q7b0iH4i0efnXCzKt15U39n.png)
