# Validation Report: URS-069

**Title:** Account Creation Updates (Required Fields, Pricing, Review)
**Date:** 2026-04-23T03:46:10.814Z
**Duration:** 108.0s
**Overall Status:** ✅ PASS

## User Requirement

> Account creation updates: require hospital/ASC label, require contact & invoicing details, enforce required fields, pricing logic, review screen, comment section.

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

## Environment

- **Inbox URL:** http://localhost:49396
- **Database:** localhost:49397/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 navigate — ✅ PASS

**What this step proves:**

Logs in as the distributor admin (Dan Distributor) and navigates to the new account creation wizard. Confirms the multi-step form is accessible to authorized users with the sales_accounts:create permission.

**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:46:16Z | user_log | user:login | dan.distributor@stellartech.com | StellarTech Medical Solutions | — |
| 2026-04-23 03:46:29Z | user_log | user:login | dan.distributor@stellartech.com | StellarTech Medical Solutions | — |

**Screenshots:**

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

![step 01 sales accounts list](screenshots/step-01-sales-accounts-list.png)

![step 01 creation form initial](screenshots/step-01-creation-form-initial.png)

**Video recording:**

[▶ Watch step recording](videos/step-01-login-and-navigate.webm)

---

### 2. Step 2: Manufacturer auto-selected — ✅ PASS

**What this step proves:**

Verifies that the manufacturer step is skipped and ZuriMED is auto-selected because StellarTech has only one manufacturer partner. The form advances directly to the Account Details step and displays the auto-selected manufacturer name in the navigation footer.

**Screenshots:**

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

---

### 3. Step 3: Account details required fields — ✅ PASS

**What this step proves:**

Confirms that the Account Details step enforces required fields: submitting with an empty account name and no sales representative triggers inline validation errors. After filling in the account name and selecting a sales rep the form advances normally.

**Screenshots:**

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

![step 03 required fields error](screenshots/step-03-required-fields-error.png)

![step 03 account details filled](screenshots/step-03-account-details-filled.png)

---

### 4. Step 4: Shipping required fields — ✅ PASS

**What this step proves:**

Confirms that the Shipping step enforces the required shipping address fields — line 1, city, state, and ZIP are each annotated as required in `step3Schema` via `.min(1)` (ZIP via regex). Submitting an empty form surfaces validation errors. Shipping contact name, email, and phone are optional at the schema level but are still collected on this step for downstream use, and the scenario fills them before advancing to the Billing step.

**Screenshots:**

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

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

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

---

### 5. Step 5: Billing required fields — ✅ PASS

**What this step proves:**

Confirms that the Billing step enforces required contact fields and that the "Copy from Shipping" button auto-populates the billing contact with shipping data. A success toast confirms the copy, then billing contact details are updated before the form advances to the Pricing step.

**Screenshots:**

![step 05 billing form empty](screenshots/step-05-billing-form-empty.png)

![step 05 billing validation errors](screenshots/step-05-billing-validation-errors.png)

![step 05 billing copied from shipping](screenshots/step-05-billing-copied-from-shipping.png)

![step 05 billing filled](screenshots/step-05-billing-filled.png)

---

### 6. Step 6: Pricing and notes — ✅ PASS

**What this step proves:**

Verifies that the Pricing step pre-populates product prices from MSRP defaults and that a free-text Notes field is present and editable. Screenshots capture the full pricing grid as well as the entered notes.

**Screenshots:**

![step 06 pricing with msrp](screenshots/step-06-pricing-with-msrp.png)

![step 06 notes filled](screenshots/step-06-notes-filled.png)

![step 06 pricing full view](screenshots/step-06-pricing-full-view.png)

---

### 7. Step 7: Review screen — ✅ PASS

**What this step proves:**

Verifies the Review step displays a summary of all data entered across previous steps: account name, billing and shipping contacts, notes, and "Edit" buttons for each section. Both the Previous navigation button and the Submit button are visible.

**Screenshots:**

![step 07 review screen top](screenshots/step-07-review-screen-top.png)

![step 07 review screen middle](screenshots/step-07-review-screen-middle.png)

![step 07 review screen bottom](screenshots/step-07-review-screen-bottom.png)

---

### 8. Step 8: Submit and verify — ✅ PASS

**What this step proves:**

Clicks the "Submit Request" button and waits for the success confirmation. Confirms the success page displays the new account name, indicating the account was persisted to the database, and that the `sales_account_creation_request_submitted` notification fires to the manufacturer + distributor recipient lists (setup pre-seeds a marker recipient row on each org so the notification has a destination to deliver to). The captured email subject is "New Sales Account Creation Request from <distributor>".

**Audit events generated by this step:**

*(Evidence scoped to step execution window: 2026-04-23T03:47:38.106Z → 2026-04-23T03:47:46.707Z)*

| Time | Type | Action | User | Org | Performed |
|------|------|--------|------|-----|-----------|
| 2026-04-23 03:47:38Z | user_log | sales_account:created | dan.distributor@stellartech.com | StellarTech Medical Solutions | — |
| 2026-04-23 03:47:38Z | transactional_email | sales_account_creation_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 Sales Account Creation Request from StellarTech Medical Solutions**

Template: `New_Sales_Account_Creation_Request_from_StellarTech_Medical_Solutions`

![New Sales Account Creation Request from StellarTech Medical Solutions](screenshots/emails/2026-04-23T03-47-38-715Z-New_Sales_Account_Creation_Request_from_StellarTech_Medical_Solutions.png)

**Screenshots:**

![step 08 review before submit](screenshots/step-08-review-before-submit.png)

![step 08 success page](screenshots/step-08-success-page.png)

![step 08 success details](screenshots/step-08-success-details.png)

---

### 9. Step 9: Verify persistence — ✅ PASS

**What this step proves:**

Navigates to the sales accounts list and verifies the newly created account appears in the list. Opens the account detail page and confirms key information is visible, completing the end-to-end verification that the account was durably stored.

**Screenshots:**

![step 09 account in list](screenshots/step-09-account-in-list.png)

![step 09 account detail top](screenshots/step-09-account-detail-top.png)

![step 09 account detail middle](screenshots/step-09-account-detail-middle.png)

![step 09 account detail bottom](screenshots/step-09-account-detail-bottom.png)

---

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

### Sales account created — ✅ PASS

**Assertion:** Sales account "St. Mary's Surgical Center" should exist in the database

```sql
SELECT id, name, status, organization_id, manufacturer_organization_id,
                      distributor_organization_id, created_at
               FROM sales_accounts
               WHERE name = $1
                 AND distributor_organization_id = $2
```

| id | name | status | organization_id | manufacturer_organization_id | distributor_organization_id | created_at |
| --- | --- | --- | --- | --- | --- | --- |
| 019db873-523e-735d-bb8c-87576f135122 | St. Mary's Surgical Center | proposed | a1b2c3d4-e5f6-7890-abcd-ef1234567890 | a1b2c3d4-e5f6-7890-abcd-ef1234567890 | b2c3d4e5-f6a7-8901-bcde-f12345678901 | 2026-04-23T03:47:38.673Z |

### Account organization relationships — ✅ PASS

**Assertion:** Account should be linked to ZuriMED (manufacturer) and StellarTech (distributor)

```sql
SELECT manufacturer_organization_id, distributor_organization_id
                 FROM sales_accounts WHERE id = $1
```

| manufacturer_organization_id | distributor_organization_id |
| --- | --- |
| a1b2c3d4-e5f6-7890-abcd-ef1234567890 | b2c3d4e5-f6a7-8901-bcde-f12345678901 |

### Shipping location created with hospital facility type — ✅ PASS

**Assertion:** Shipping location should be created with address details and real_world_locations.type = "hospital"

```sql
SELECT rwl.type, rwl.street_address, rwl.city, rwl.state, rwl.zip
                 FROM sales_accounts sa
                 JOIN real_world_locations rwl ON rwl.id = sa.shipping_location_id
                 WHERE sa.id = $1
```

| type | street_address | city | state | zip |
| --- | --- | --- | --- | --- |
| hospital | 123 Medical Drive | Health City | CT | 06001 |

### Shipping contact created — ✅ PASS

**Assertion:** Shipping contact should be created

```sql
SELECT c.name
                 FROM sales_accounts sa
                 JOIN contacts c ON c.id = sa.shipping_contact_id
                 WHERE sa.id = $1
```

| name |
| --- |
| Dr. Sarah Johnson |

### Billing contact created — ✅ PASS

**Assertion:** Billing contact should be "Accounts Payable Dept"

```sql
SELECT c.name
                 FROM sales_accounts sa
                 JOIN contacts c ON c.id = sa.billing_contact_id
                 WHERE sa.id = $1
```

| name |
| --- |
| Accounts Payable Dept |

### Pricing records created — ✅ PASS

**Assertion:** At least one pricing record should be created for the account

```sql
SELECT sap.org_product_id, sap.price, sap.status
                 FROM sales_account_approved_pricing sap
                 WHERE sap.sales_account_id = $1
```

| org_product_id | price | status |
| --- | --- | --- |
| 01989ca2-6a54-7834-8376-06a0251bacd8 | 4000.00 | pending |
| 01989ca1-f2f8-7ab7-8269-7179342797cc | 1000.00 | pending |

### Sales rep assigned — ✅ PASS

**Assertion:** At least one sales representative should be assigned to the account

```sql
SELECT saua.user_id, u.name as user_name, saua.active
                 FROM sales_account_user_assignments saua
                 JOIN users u ON u.id = saua.user_id
                 WHERE saua.sales_account_id = $1 AND saua.active = true
```

| user_id | user_name | active |
| --- | --- | --- |
| 17b8c9d0-e1f2-3456-1234-567890123456 | Bob Kauffman | true |

### Account has valid status — ✅ PASS

**Assertion:** Account should have status "proposed" or "active"

```sql
SELECT status FROM sales_accounts WHERE id = $1
```

| status |
| --- |
| proposed |

## 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: Login and navigate | `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 8: Submit and verify | `Sales Account Creation Request` | ✅ |

## 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:46:08.915Z

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

4 event(s) captured:

| Time | Type | Action | User | Org | Object ID | Performed | Reason |
|------|------|--------|------|-----|-----------|-----------|--------|
| 2026-04-23 03:46:16Z | user_log | user:login | dan.distributor@stellartech.com | StellarTech Medical Solutions | — | — |  |
| 2026-04-23 03:46:29Z | user_log | user:login | dan.distributor@stellartech.com | StellarTech Medical Solutions | — | — |  |
| 2026-04-23 03:47:38Z | user_log | sales_account:created | dan.distributor@stellartech.com | StellarTech Medical Solutions | 019db873-523e-735d-bb8c-87576f135122 | — |  |
| 2026-04-23 03:47:38Z | transactional_email | sales_account_creation_request_submitted | — | ZuriMED | 019db873-523e-735d-bb8c-87576f135122 | — |  |

## Email Evidence

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

### 1. New Sales Account Creation Request from StellarTech Medical Solutions

**Template:** `New_Sales_Account_Creation_Request_from_StellarTech_Medical_Solutions`

![New Sales Account Creation Request from StellarTech Medical Solutions](screenshots/emails/2026-04-23T03-47-38-715Z-New_Sales_Account_Creation_Request_from_StellarTech_Medical_Solutions.png)

## Additional Video Evidence

The following screencast recordings were captured but could not be matched to a specific test step. Step-matched recordings appear inline in their respective step sections above.

- [videos/steps-02-09-full-creation-flow.webm](videos/steps-02-09-full-creation-flow.webm)
