{
  "ursId": "URS-069",
  "title": "Account Creation Updates (Required Fields, Pricing, Review)",
  "timestamp": "2026-04-23T03:46:10.814Z",
  "durationMs": 107951,
  "config": {
    "inboxUrl": "http://localhost:49396",
    "dbHost": "localhost",
    "dbPort": 49397,
    "dbName": "cc_repinbox_dev"
  },
  "setup": {
    "status": "pass"
  },
  "scenarios": [
    {
      "name": "Step 1: Login and navigate",
      "status": "pass",
      "description": "Step 1: Login and navigate",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-069-account-creation/2026-04-23T03-46-10-813Z/screenshots/step-01-logged-in.png",
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-069-account-creation/2026-04-23T03-46-10-813Z/screenshots/step-01-sales-accounts-list.png",
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-069-account-creation/2026-04-23T03-46-10-813Z/screenshots/step-01-creation-form-initial.png"
      ],
      "explanation": "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.",
      "expectedAuditActions": [
        "user_log:user:login"
      ],
      "startedAt": "2026-04-23T03:46:17.237Z",
      "finishedAt": "2026-04-23T03:46:26.339Z",
      "videoPath": "/Users/jason/projects/casecohort/code/validation_test_results/urs-069-account-creation/2026-04-23T03-46-10-813Z/videos/step-01-login-and-navigate.webm"
    },
    {
      "name": "Step 2: Manufacturer auto-selected",
      "status": "pass",
      "description": "Step 2: Manufacturer auto-selected",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-069-account-creation/2026-04-23T03-46-10-813Z/screenshots/step-02-manufacturer-auto-selected.png"
      ],
      "explanation": "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.",
      "startedAt": "2026-04-23T03:46:35.312Z",
      "finishedAt": "2026-04-23T03:46:35.312Z"
    },
    {
      "name": "Step 3: Account details required fields",
      "status": "pass",
      "description": "Step 3: Account details required fields",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-069-account-creation/2026-04-23T03-46-10-813Z/screenshots/step-03-account-details-form.png",
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-069-account-creation/2026-04-23T03-46-10-813Z/screenshots/step-03-required-fields-error.png",
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-069-account-creation/2026-04-23T03-46-10-813Z/screenshots/step-03-account-details-filled.png"
      ],
      "explanation": "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.",
      "startedAt": "2026-04-23T03:46:37.680Z",
      "finishedAt": "2026-04-23T03:46:44.699Z"
    },
    {
      "name": "Step 4: Shipping required fields",
      "status": "pass",
      "description": "Step 4: Shipping required fields",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-069-account-creation/2026-04-23T03-46-10-813Z/screenshots/step-04-shipping-form-empty.png",
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-069-account-creation/2026-04-23T03-46-10-813Z/screenshots/step-04-shipping-validation-errors.png",
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-069-account-creation/2026-04-23T03-46-10-813Z/screenshots/step-04-shipping-filled.png"
      ],
      "explanation": "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.",
      "startedAt": "2026-04-23T03:46:50.597Z",
      "finishedAt": "2026-04-23T03:47:00.648Z"
    },
    {
      "name": "Step 5: Billing required fields",
      "status": "pass",
      "description": "Step 5: Billing required fields",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-069-account-creation/2026-04-23T03-46-10-813Z/screenshots/step-05-billing-form-empty.png",
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-069-account-creation/2026-04-23T03-46-10-813Z/screenshots/step-05-billing-validation-errors.png",
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-069-account-creation/2026-04-23T03-46-10-813Z/screenshots/step-05-billing-copied-from-shipping.png",
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-069-account-creation/2026-04-23T03-46-10-813Z/screenshots/step-05-billing-filled.png"
      ],
      "explanation": "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.",
      "startedAt": "2026-04-23T03:47:09.044Z",
      "finishedAt": "2026-04-23T03:47:18.840Z"
    },
    {
      "name": "Step 6: Pricing and notes",
      "status": "pass",
      "description": "Step 6: Pricing and notes",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-069-account-creation/2026-04-23T03-46-10-813Z/screenshots/step-06-pricing-with-msrp.png",
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-069-account-creation/2026-04-23T03-46-10-813Z/screenshots/step-06-notes-filled.png",
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-069-account-creation/2026-04-23T03-46-10-813Z/screenshots/step-06-pricing-full-view.png"
      ],
      "explanation": "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.",
      "startedAt": "2026-04-23T03:47:26.706Z",
      "finishedAt": "2026-04-23T03:47:28.288Z"
    },
    {
      "name": "Step 7: Review screen",
      "status": "pass",
      "description": "Step 7: Review screen",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-069-account-creation/2026-04-23T03-46-10-813Z/screenshots/step-07-review-screen-top.png",
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-069-account-creation/2026-04-23T03-46-10-813Z/screenshots/step-07-review-screen-middle.png",
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-069-account-creation/2026-04-23T03-46-10-813Z/screenshots/step-07-review-screen-bottom.png"
      ],
      "explanation": "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.",
      "startedAt": "2026-04-23T03:47:34.187Z",
      "finishedAt": "2026-04-23T03:47:35.262Z"
    },
    {
      "name": "Step 8: Submit and verify",
      "status": "pass",
      "description": "Step 8: Submit and verify",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-069-account-creation/2026-04-23T03-46-10-813Z/screenshots/step-08-review-before-submit.png",
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-069-account-creation/2026-04-23T03-46-10-813Z/screenshots/step-08-success-page.png",
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-069-account-creation/2026-04-23T03-46-10-813Z/screenshots/step-08-success-details.png"
      ],
      "explanation": "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>\".",
      "expectedEmailTemplates": [
        "Sales Account Creation Request"
      ],
      "startedAt": "2026-04-23T03:47:38.106Z",
      "finishedAt": "2026-04-23T03:47:46.707Z"
    },
    {
      "name": "Step 9: Verify persistence",
      "status": "pass",
      "description": "Step 9: Verify persistence",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-069-account-creation/2026-04-23T03-46-10-813Z/screenshots/step-09-account-in-list.png",
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-069-account-creation/2026-04-23T03-46-10-813Z/screenshots/step-09-account-detail-top.png",
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-069-account-creation/2026-04-23T03-46-10-813Z/screenshots/step-09-account-detail-middle.png",
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-069-account-creation/2026-04-23T03-46-10-813Z/screenshots/step-09-account-detail-bottom.png"
      ],
      "explanation": "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.",
      "startedAt": "2026-04-23T03:47:52.879Z",
      "finishedAt": "2026-04-23T03:47:57.786Z"
    }
  ],
  "dbValidations": [
    {
      "name": "Sales account created",
      "query": "SELECT id, name, status, organization_id, manufacturer_organization_id,\n                      distributor_organization_id, created_at\n               FROM sales_accounts\n               WHERE name = $1\n                 AND distributor_organization_id = $2",
      "status": "pass",
      "rows": [
        {
          "id": "019db873-523e-735d-bb8c-87576f135122",
          "name": "St. Mary's Surgical Center",
          "status": "proposed",
          "organization_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
          "manufacturer_organization_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
          "distributor_organization_id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
          "created_at": "2026-04-23T03:47:38.673Z"
        }
      ],
      "assertion": "Sales account \"St. Mary's Surgical Center\" should exist in the database"
    },
    {
      "name": "Account organization relationships",
      "query": "SELECT manufacturer_organization_id, distributor_organization_id\n                 FROM sales_accounts WHERE id = $1",
      "status": "pass",
      "rows": [
        {
          "manufacturer_organization_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
          "distributor_organization_id": "b2c3d4e5-f6a7-8901-bcde-f12345678901"
        }
      ],
      "assertion": "Account should be linked to ZuriMED (manufacturer) and StellarTech (distributor)"
    },
    {
      "name": "Shipping location created with hospital facility type",
      "query": "SELECT rwl.type, rwl.street_address, rwl.city, rwl.state, rwl.zip\n                 FROM sales_accounts sa\n                 JOIN real_world_locations rwl ON rwl.id = sa.shipping_location_id\n                 WHERE sa.id = $1",
      "status": "pass",
      "rows": [
        {
          "type": "hospital",
          "street_address": "123 Medical Drive",
          "city": "Health City",
          "state": "CT",
          "zip": "06001"
        }
      ],
      "assertion": "Shipping location should be created with address details and real_world_locations.type = \"hospital\""
    },
    {
      "name": "Shipping contact created",
      "query": "SELECT c.name\n                 FROM sales_accounts sa\n                 JOIN contacts c ON c.id = sa.shipping_contact_id\n                 WHERE sa.id = $1",
      "status": "pass",
      "rows": [
        {
          "name": "Dr. Sarah Johnson"
        }
      ],
      "assertion": "Shipping contact should be created"
    },
    {
      "name": "Billing contact created",
      "query": "SELECT c.name\n                 FROM sales_accounts sa\n                 JOIN contacts c ON c.id = sa.billing_contact_id\n                 WHERE sa.id = $1",
      "status": "pass",
      "rows": [
        {
          "name": "Accounts Payable Dept"
        }
      ],
      "assertion": "Billing contact should be \"Accounts Payable Dept\""
    },
    {
      "name": "Pricing records created",
      "query": "SELECT sap.org_product_id, sap.price, sap.status\n                 FROM sales_account_approved_pricing sap\n                 WHERE sap.sales_account_id = $1",
      "status": "pass",
      "rows": [
        {
          "org_product_id": "01989ca2-6a54-7834-8376-06a0251bacd8",
          "price": "4000.00",
          "status": "pending"
        },
        {
          "org_product_id": "01989ca1-f2f8-7ab7-8269-7179342797cc",
          "price": "1000.00",
          "status": "pending"
        }
      ],
      "assertion": "At least one pricing record should be created for the account"
    },
    {
      "name": "Sales rep assigned",
      "query": "SELECT saua.user_id, u.name as user_name, saua.active\n                 FROM sales_account_user_assignments saua\n                 JOIN users u ON u.id = saua.user_id\n                 WHERE saua.sales_account_id = $1 AND saua.active = true",
      "status": "pass",
      "rows": [
        {
          "user_id": "17b8c9d0-e1f2-3456-1234-567890123456",
          "user_name": "Bob Kauffman",
          "active": true
        }
      ],
      "assertion": "At least one sales representative should be assigned to the account"
    },
    {
      "name": "Account has valid status",
      "query": "SELECT status FROM sales_accounts WHERE id = $1",
      "status": "pass",
      "rows": [
        {
          "status": "proposed"
        }
      ],
      "assertion": "Account should have status \"proposed\" or \"active\""
    }
  ],
  "overallStatus": "pass",
  "outputDir": "/Users/jason/projects/casecohort/code/validation_test_results/urs-069-account-creation/2026-04-23T03-46-10-813Z",
  "auditStartTime": "2026-04-23T03:46:08.915Z",
  "emailEvidence": [
    {
      "subject": "New Sales Account Creation Request from StellarTech Medical Solutions",
      "template": "New_Sales_Account_Creation_Request_from_StellarTech_Medical_Solutions",
      "screenshotPath": "/Users/jason/projects/casecohort/code/validation_test_results/urs-069-account-creation/2026-04-23T03-46-10-813Z/screenshots/emails/2026-04-23T03-47-38-715Z-New_Sales_Account_Creation_Request_from_StellarTech_Medical_Solutions.png"
    }
  ],
  "auditEventEvidence": [
    {
      "createdAt": "2026-04-23T03:46:16.976Z",
      "eventType": "user_log",
      "action": "user:login",
      "userEmail": "dan.distributor@stellartech.com",
      "userId": "c3d4e5f6-a7b8-9012-cdef-123456789012",
      "organizationName": "StellarTech Medical Solutions",
      "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "objectId": null,
      "secondaryObjectId": null,
      "payload": {
        "email": "dan.distributor@stellartech.com"
      },
      "route": "/login",
      "traceId": "00000000000000000000000000000000"
    },
    {
      "createdAt": "2026-04-23T03:46:29.032Z",
      "eventType": "user_log",
      "action": "user:login",
      "userEmail": "dan.distributor@stellartech.com",
      "userId": "c3d4e5f6-a7b8-9012-cdef-123456789012",
      "organizationName": "StellarTech Medical Solutions",
      "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "objectId": null,
      "secondaryObjectId": null,
      "payload": {
        "email": "dan.distributor@stellartech.com"
      },
      "route": "/login",
      "traceId": "00000000000000000000000000000000"
    },
    {
      "createdAt": "2026-04-23T03:47:38.708Z",
      "eventType": "user_log",
      "action": "sales_account:created",
      "userEmail": "dan.distributor@stellartech.com",
      "userId": "c3d4e5f6-a7b8-9012-cdef-123456789012",
      "organizationName": "StellarTech Medical Solutions",
      "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "objectId": "019db873-523e-735d-bb8c-87576f135122",
      "secondaryObjectId": null,
      "payload": {
        "status": "proposed",
        "autoApproved": false,
        "salesAccountName": "St. Mary's Surgical Center",
        "distributorOrganizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
        "manufacturerOrganizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
      },
      "route": "/sales-accounts/new",
      "traceId": "00000000000000000000000000000000"
    },
    {
      "createdAt": "2026-04-23T03:47:38.731Z",
      "eventType": "transactional_email",
      "action": "sales_account_creation_request_submitted",
      "userEmail": null,
      "userId": null,
      "organizationName": "ZuriMED",
      "organizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "objectId": "019db873-523e-735d-bb8c-87576f135122",
      "secondaryObjectId": null,
      "payload": {
        "to": [
          "URS-069 Validation Test Recipient <urs-069-zurimed@validation.example.com>",
          "URS-069 Validation Test Recipient <urs-069-stellartech@validation.example.com>"
        ],
        "s3Path": "email-audit/a1b2c3d4-e5f6-7890-abcd-ef1234567890/019db873-525f-7c96-a657-94bcbf745c6f/",
        "subject": "New Sales Account Creation Request from StellarTech Medical Solutions",
        "messageId": "dev-console-log",
        "relatedEntityType": "sales_account"
      },
      "route": null,
      "traceId": null
    }
  ],
  "auditQuery": "SELECT\n    ae.created_at,\n    ae.event_type,\n    ae.action,\n    ae.user_id,\n    u.email AS user_email,\n    ae.organization_id,\n    o.name AS organization_name,\n    ae.object_id,\n    ae.secondary_object_id,\n    ae.payload,\n    ae.route,\n    ae.trace_id\n  FROM audit_events ae\n  LEFT JOIN users u ON u.id = ae.user_id\n  LEFT JOIN organizations o ON o.id = ae.organization_id\n  WHERE ae.created_at >= $1\n    AND ae.organization_id = ANY($2::uuid[])\n  ORDER BY ae.created_at ASC",
  "auditAssertions": [
    {
      "stepName": "Step 1: Login and navigate",
      "expectedAction": "user_log:user:login",
      "found": true
    }
  ],
  "emailAssertions": [
    {
      "stepName": "Step 8: Submit and verify",
      "expectedTemplate": "Sales Account Creation Request",
      "found": true
    }
  ],
  "videoPaths": [
    "/Users/jason/projects/casecohort/code/validation_test_results/urs-069-account-creation/2026-04-23T03-46-10-813Z/videos/steps-02-09-full-creation-flow.webm"
  ]
}