{
  "ursId": "URS-019",
  "title": "Bill-Only without PO for Approved Accounts",
  "timestamp": "2026-04-23T03:37:40.853Z",
  "durationMs": 61978,
  "config": {
    "inboxUrl": "http://localhost:63054",
    "dbHost": "localhost",
    "dbPort": 63055,
    "dbName": "cc_repinbox_dev"
  },
  "setup": {
    "status": "pass"
  },
  "scenarios": [
    {
      "name": "Step 1: Login",
      "status": "pass",
      "description": "Step 1: Login",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-019-bill-only-without-po/2026-04-23T03-37-40-851Z/screenshots/step-01-logged-in.png"
      ],
      "explanation": "Proves that Bob Kauffman (StellarTech Sales Rep) can authenticate and reach the application. Establishes the user context for all subsequent steps.",
      "expectedAuditActions": [
        "user_log:user:login"
      ],
      "startedAt": "2026-04-23T03:37:49.440Z",
      "finishedAt": "2026-04-23T03:37:49.440Z",
      "videoPath": "/Users/jason/projects/casecohort/code/validation_test_results/urs-019-bill-only-without-po/2026-04-23T03-37-40-851Z/videos/step-01-login.webm"
    },
    {
      "name": "Step 2: Billing form",
      "status": "pass",
      "description": "Step 2: Billing form",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-019-bill-only-without-po/2026-04-23T03-37-40-851Z/screenshots/step-02-account-selection-page.png"
      ],
      "explanation": "Confirms Bob can navigate to the new bill-only order creation form and reach the account selection step (Step 2). Verifies the billing feature is accessible to the sales rep role.",
      "startedAt": "2026-04-23T03:37:56.004Z",
      "finishedAt": "2026-04-23T03:37:56.004Z",
      "videoPath": "/Users/jason/projects/casecohort/code/validation_test_results/urs-019-bill-only-without-po/2026-04-23T03-37-40-851Z/videos/step-02-billing-form.webm"
    },
    {
      "name": "Step 3: Unapproved account hidden",
      "status": "pass",
      "description": "Step 3: Unapproved account hidden",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-019-bill-only-without-po/2026-04-23T03-37-40-851Z/screenshots/step-03-account-dropdown-open.png",
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-019-bill-only-without-po/2026-04-23T03-37-40-851Z/screenshots/step-03-search-copley-no-results.png",
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-019-bill-only-without-po/2026-04-23T03-37-40-851Z/screenshots/step-03-search-boss-found.png"
      ],
      "explanation": "The system enforces the approval gate at the UI level: the account selector only shows accounts with status=\"active\" (approved by ZuriMED). Copley Hospital Account Request, which is set to status=\"proposed\" (unapproved) by the test setup, does not appear as a selectable option. BOSS Surgical Account Request (active/approved) is visible, confirming the selector works correctly. This is the negative test — it proves the approval gate is enforced.",
      "startedAt": "2026-04-23T03:38:02.560Z",
      "finishedAt": "2026-04-23T03:38:08.000Z",
      "videoPath": "/Users/jason/projects/casecohort/code/validation_test_results/urs-019-bill-only-without-po/2026-04-23T03-37-40-851Z/videos/step-03-unapproved-account.webm"
    },
    {
      "name": "Step 4: Create order",
      "status": "pass",
      "description": "Step 4: Create order",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-019-bill-only-without-po/2026-04-23T03-37-40-851Z/screenshots/step-04-boss-account-selected.png",
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-019-bill-only-without-po/2026-04-23T03-37-40-851Z/screenshots/step-04-products-added.png",
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-019-bill-only-without-po/2026-04-23T03-37-40-851Z/screenshots/step-04-no-po-entered.png",
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-019-bill-only-without-po/2026-04-23T03-37-40-851Z/screenshots/step-04-review-before-submit.png",
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-019-bill-only-without-po/2026-04-23T03-37-40-851Z/screenshots/step-04-order-submitted.png"
      ],
      "explanation": "An approved account (BOSS Surgical Account Request, status=\"active\") can successfully complete the full bill-only order submission flow — including leaving the PO field empty. The order is accepted and a BO-XXXX order number is assigned. This is the positive test proving that approved accounts can submit Bill-Only without PO.",
      "expectedEmailTemplates": [
        "bill-only"
      ],
      "expectedAuditActions": [
        "decision:bill_only_order.enqueue_upload_classification"
      ],
      "startedAt": "2026-04-23T03:38:17.304Z",
      "finishedAt": "2026-04-23T03:38:30.412Z",
      "videoPath": "/Users/jason/projects/casecohort/code/validation_test_results/urs-019-bill-only-without-po/2026-04-23T03-37-40-851Z/videos/step-04-create-order.webm"
    },
    {
      "name": "Step 5: Verify order",
      "status": "pass",
      "description": "Step 5: Verify order",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-019-bill-only-without-po/2026-04-23T03-37-40-851Z/screenshots/step-05-billing-list.png",
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-019-bill-only-without-po/2026-04-23T03-37-40-851Z/screenshots/step-05-new-order-found.png"
      ],
      "explanation": "The newly created bill-only order appears on the billing list, confirming it was persisted correctly. The specific order number captured in Step 4 is visible, providing end-to-end traceability from form submission to database record.",
      "startedAt": "2026-04-23T03:38:39.512Z",
      "finishedAt": "2026-04-23T03:38:39.568Z",
      "videoPath": "/Users/jason/projects/casecohort/code/validation_test_results/urs-019-bill-only-without-po/2026-04-23T03-37-40-851Z/videos/step-05-verify-order.webm"
    }
  ],
  "dbValidations": [
    {
      "name": "Approved account has active status",
      "query": "SELECT id, name, status FROM sales_accounts WHERE id = ANY($1) ORDER BY name",
      "status": "pass",
      "rows": [
        {
          "id": "fea7b8c9-d0e1-2345-0123-456789012345",
          "name": "BOSS Surgical Account Request",
          "status": "active"
        },
        {
          "id": "1fb8c9d0-e1f2-3456-1234-567890123456",
          "name": "Copley Hospital Account Request",
          "status": "proposed"
        }
      ],
      "assertion": "BOSS Hospital should have status='active' (approved)"
    },
    {
      "name": "Unapproved account has proposed status",
      "query": "SELECT id, name, status FROM sales_accounts WHERE id = ANY($1) ORDER BY name",
      "status": "pass",
      "rows": [
        {
          "id": "fea7b8c9-d0e1-2345-0123-456789012345",
          "name": "BOSS Surgical Account Request",
          "status": "active"
        },
        {
          "id": "1fb8c9d0-e1f2-3456-1234-567890123456",
          "name": "Copley Hospital Account Request",
          "status": "proposed"
        }
      ],
      "assertion": "Copley Healthcare should have status='proposed' (unapproved)"
    },
    {
      "name": "New billing order BO-1 exists for approved account",
      "query": "SELECT id, order_number, status, sales_account_id, created_at\n        FROM billing_orders\n        WHERE sales_account_id = 'fea7b8c9-d0e1-2345-0123-456789012345' AND order_number = 'BO-1'",
      "status": "pass",
      "rows": [
        {
          "id": "019db86a-f348-7b04-a15e-1d1c3d78889a",
          "order_number": "BO-1",
          "status": "submitted",
          "sales_account_id": "fea7b8c9-d0e1-2345-0123-456789012345",
          "created_at": "2026-04-23T03:38:30.026Z"
        }
      ],
      "assertion": "Order BO-1 should exist for BOSS Hospital (approved account)"
    },
    {
      "name": "No new billing orders for unapproved account",
      "query": "SELECT id, order_number, status, created_at\n      FROM billing_orders\n      WHERE sales_account_id = '1fb8c9d0-e1f2-3456-1234-567890123456' AND created_at > NOW() - INTERVAL '10 minutes'\n      ORDER BY created_at DESC",
      "status": "pass",
      "rows": [],
      "assertion": "No billing orders should have been created for Copley Healthcare (unapproved account) during the test"
    }
  ],
  "overallStatus": "pass",
  "outputDir": "/Users/jason/projects/casecohort/code/validation_test_results/urs-019-bill-only-without-po/2026-04-23T03-37-40-851Z",
  "auditStartTime": "2026-04-23T03:37:38.919Z",
  "emailEvidence": [
    {
      "subject": "New Bill-Only Order - 1/15/2025 - ZuriMED BO-1",
      "template": "New_Bill-Only_Order_-_1_15_2025_-_ZuriMED_BO-1",
      "screenshotPath": "/Users/jason/projects/casecohort/code/validation_test_results/urs-019-bill-only-without-po/2026-04-23T03-37-40-851Z/screenshots/emails/2026-04-23T03-38-32-186Z-New_Bill-Only_Order_-_1_15_2025_-_ZuriMED_BO-1.png"
    }
  ],
  "auditEventEvidence": [
    {
      "createdAt": "2026-04-23T03:37:47.449Z",
      "eventType": "user_log",
      "action": "user:login",
      "userEmail": "bob.kauffman@stellartech.com",
      "userId": "17b8c9d0-e1f2-3456-1234-567890123456",
      "organizationName": "StellarTech Medical Solutions",
      "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "objectId": null,
      "secondaryObjectId": null,
      "payload": {
        "email": "bob.kauffman@stellartech.com"
      },
      "route": "/login",
      "traceId": "00000000000000000000000000000000"
    },
    {
      "createdAt": "2026-04-23T03:37:52.324Z",
      "eventType": "user_log",
      "action": "user:login",
      "userEmail": "bob.kauffman@stellartech.com",
      "userId": "17b8c9d0-e1f2-3456-1234-567890123456",
      "organizationName": "StellarTech Medical Solutions",
      "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "objectId": null,
      "secondaryObjectId": null,
      "payload": {
        "email": "bob.kauffman@stellartech.com"
      },
      "route": "/login",
      "traceId": "00000000000000000000000000000000"
    },
    {
      "createdAt": "2026-04-23T03:37:58.730Z",
      "eventType": "user_log",
      "action": "user:login",
      "userEmail": "bob.kauffman@stellartech.com",
      "userId": "17b8c9d0-e1f2-3456-1234-567890123456",
      "organizationName": "StellarTech Medical Solutions",
      "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "objectId": null,
      "secondaryObjectId": null,
      "payload": {
        "email": "bob.kauffman@stellartech.com"
      },
      "route": "/login",
      "traceId": "00000000000000000000000000000000"
    },
    {
      "createdAt": "2026-04-23T03:38:10.836Z",
      "eventType": "user_log",
      "action": "user:login",
      "userEmail": "bob.kauffman@stellartech.com",
      "userId": "17b8c9d0-e1f2-3456-1234-567890123456",
      "organizationName": "StellarTech Medical Solutions",
      "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "objectId": null,
      "secondaryObjectId": null,
      "payload": {
        "email": "bob.kauffman@stellartech.com"
      },
      "route": "/login",
      "traceId": "00000000000000000000000000000000"
    },
    {
      "createdAt": "2026-04-23T03:38:30.026Z",
      "eventType": "decision",
      "action": "bill_only_order.enqueue_upload_classification",
      "userEmail": "bob.kauffman@stellartech.com",
      "userId": "17b8c9d0-e1f2-3456-1234-567890123456",
      "organizationName": "ZuriMED",
      "organizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "objectId": "019db86a-f348-7b04-a15e-1d1c3d78889a",
      "secondaryObjectId": null,
      "payload": {
        "reason": "No uploaded PO documents",
        "performed": false,
        "entityType": "billing_order",
        "fileSourceOrganizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
        "hasSelectedPurchaseOrderId": false,
        "purchaseOrderDocumentCount": 0
      },
      "route": null,
      "traceId": null
    },
    {
      "createdAt": "2026-04-23T03:38:32.251Z",
      "eventType": "transactional_email",
      "action": "new_bill_only",
      "userEmail": null,
      "userId": null,
      "organizationName": "StellarTech Medical Solutions",
      "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "objectId": "019db86a-f348-7b04-a15e-1d1c3d78889a",
      "secondaryObjectId": null,
      "payload": {
        "to": [
          "bob.kauffman@stellartech.com"
        ],
        "s3Path": "email-audit/b2c3d4e5-f6a7-8901-bcde-f12345678901/019db86a-fb8d-7f44-a69c-7c7d7e667855/",
        "subject": "New Bill-Only Order - 1/15/2025 - ZuriMED BO-1",
        "messageId": "dev-console-log",
        "relatedEntityType": "billing_order"
      },
      "route": null,
      "traceId": null
    },
    {
      "createdAt": "2026-04-23T03:38:33.197Z",
      "eventType": "user_log",
      "action": "user:login",
      "userEmail": "bob.kauffman@stellartech.com",
      "userId": "17b8c9d0-e1f2-3456-1234-567890123456",
      "organizationName": "StellarTech Medical Solutions",
      "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "objectId": null,
      "secondaryObjectId": null,
      "payload": {
        "email": "bob.kauffman@stellartech.com"
      },
      "route": "/login",
      "traceId": "00000000000000000000000000000000"
    }
  ],
  "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",
      "expectedAction": "user_log:user:login",
      "found": true
    },
    {
      "stepName": "Step 4: Create order",
      "expectedAction": "decision:bill_only_order.enqueue_upload_classification",
      "found": true
    }
  ],
  "emailAssertions": [
    {
      "stepName": "Step 4: Create order",
      "expectedTemplate": "bill-only",
      "found": true
    }
  ]
}