{
  "ursId": "URS-031",
  "title": "Record all transactions with timestamps and user IDs",
  "timestamp": "2026-08-03T23:03:21.163Z",
  "durationMs": 107344,
  "config": {
    "inboxUrl": "http://localhost:38165",
    "dbHost": "localhost",
    "dbPort": 44481,
    "dbName": "cc_repinbox_dev"
  },
  "setup": {
    "status": "pass"
  },
  "scenarios": [
    {
      "name": "Step 1: Logged in as Blair Bennett",
      "status": "pass",
      "description": "Step 1: Logged in as Blair Bennett",
      "screenshots": [
        "/home/runner/_work/code/code/validation_test_results/urs-031-record-transactions-timestamps-userids/2026-08-03T23-03-21-163Z/screenshots/step-01-logged-in.png"
      ],
      "explanation": "Authenticates as Blair Bennett (Corveta sales rep), establishing the user identity that will be recorded against subsequent transactions.",
      "expectedAuditActions": [
        "user_log:user:login"
      ],
      "startedAt": "2026-08-03T23:03:26.337Z",
      "finishedAt": "2026-08-03T23:03:26.337Z",
      "videoPath": "/home/runner/_work/code/code/validation_test_results/urs-031-record-transactions-timestamps-userids/2026-08-03T23-03-21-163Z/videos/step-01-login-bob.webm"
    },
    {
      "name": "Step 2: First order",
      "status": "pass",
      "description": "Step 2: First order",
      "screenshots": [
        "/home/runner/_work/code/code/validation_test_results/urs-031-record-transactions-timestamps-userids/2026-08-03T23-03-21-163Z/screenshots/step-02-account-selected.png",
        "/home/runner/_work/code/code/validation_test_results/urs-031-record-transactions-timestamps-userids/2026-08-03T23-03-21-163Z/screenshots/step-02-devices-selected.png",
        "/home/runner/_work/code/code/validation_test_results/urs-031-record-transactions-timestamps-userids/2026-08-03T23-03-21-163Z/screenshots/step-02-documents.png",
        "/home/runner/_work/code/code/validation_test_results/urs-031-record-transactions-timestamps-userids/2026-08-03T23-03-21-163Z/screenshots/step-02-review.png",
        "/home/runner/_work/code/code/validation_test_results/urs-031-record-transactions-timestamps-userids/2026-08-03T23-03-21-163Z/screenshots/step-02-order-submitted.png"
      ],
      "explanation": "Submits the first bill-only order as Blair Bennett. The system records the order in billing_orders with created_by_user_id and a server-side created_at timestamp.",
      "expectedEmailTemplates": [
        "New Bill-Only Order"
      ],
      "expectedAuditActions": [
        "decision:bill_only_order.inventory_items_decrement",
        "billing_order:status_change"
      ],
      "startedAt": "2026-08-03T23:03:38.104Z",
      "finishedAt": "2026-08-03T23:03:59.189Z",
      "videoPath": "/home/runner/_work/code/code/validation_test_results/urs-031-record-transactions-timestamps-userids/2026-08-03T23-03-21-163Z/videos/step-02-first-order.webm"
    },
    {
      "name": "Step 3: Second order",
      "status": "pass",
      "description": "Step 3: Second order",
      "screenshots": [
        "/home/runner/_work/code/code/validation_test_results/urs-031-record-transactions-timestamps-userids/2026-08-03T23-03-21-163Z/screenshots/step-03-second-order-submitted.png"
      ],
      "explanation": "Submits a second bill-only order, demonstrating that each transaction is recorded independently with its own user ID and a distinct timestamp.",
      "expectedEmailTemplates": [
        "New Bill-Only Order"
      ],
      "expectedAuditActions": [
        "decision:bill_only_order.inventory_items_decrement",
        "billing_order:status_change"
      ],
      "startedAt": "2026-08-03T23:04:36.053Z",
      "finishedAt": "2026-08-03T23:04:36.053Z",
      "videoPath": "/home/runner/_work/code/code/validation_test_results/urs-031-record-transactions-timestamps-userids/2026-08-03T23-03-21-163Z/videos/step-03-second-order.webm"
    },
    {
      "name": "Step 4: Billing list with recorded transactions",
      "status": "pass",
      "description": "Step 4: Billing list with recorded transactions",
      "screenshots": [
        "/home/runner/_work/code/code/validation_test_results/urs-031-record-transactions-timestamps-userids/2026-08-03T23-03-21-163Z/screenshots/step-04-billing-list.png"
      ],
      "explanation": "Views the billing list as Blair, confirming that the Submitter and Created columns expose the recorded user and timestamp for each transaction in the UI.",
      "startedAt": "2026-08-03T23:04:43.837Z",
      "finishedAt": "2026-08-03T23:04:43.837Z",
      "videoPath": "/home/runner/_work/code/code/validation_test_results/urs-031-record-transactions-timestamps-userids/2026-08-03T23-03-21-163Z/videos/step-04-billing-list.webm"
    },
    {
      "name": "Step 5: Returns list",
      "status": "pass",
      "description": "Step 5: Returns list",
      "screenshots": [
        "/home/runner/_work/code/code/validation_test_results/urs-031-record-transactions-timestamps-userids/2026-08-03T23-03-21-163Z/screenshots/step-05-returns-list.png"
      ],
      "explanation": "Views the returns list, confirming that the Created By and Created columns expose user and timestamp attribution for return transactions.",
      "startedAt": "2026-08-03T23:04:51.818Z",
      "finishedAt": "2026-08-03T23:04:51.818Z",
      "videoPath": "/home/runner/_work/code/code/validation_test_results/urs-031-record-transactions-timestamps-userids/2026-08-03T23-03-21-163Z/videos/step-05-returns-list.webm"
    },
    {
      "name": "Step 6: Cross-user billing view",
      "status": "pass",
      "description": "Step 6: Cross-user billing view",
      "screenshots": [
        "/home/runner/_work/code/code/validation_test_results/urs-031-record-transactions-timestamps-userids/2026-08-03T23-03-21-163Z/screenshots/step-06-cross-user-billing.png"
      ],
      "explanation": "Logs in as Mark Manufacturer to verify that Blair's order transactions are visible to a different authorized user with the original user attribution intact.",
      "expectedAuditActions": [
        "user_log:user:login"
      ],
      "startedAt": "2026-08-03T23:04:59.824Z",
      "finishedAt": "2026-08-03T23:04:59.824Z",
      "videoPath": "/home/runner/_work/code/code/validation_test_results/urs-031-record-transactions-timestamps-userids/2026-08-03T23-03-21-163Z/videos/step-06-cross-user.webm"
    },
    {
      "name": "Step 6: Cross-user returns view",
      "status": "pass",
      "description": "Step 6: Cross-user returns view",
      "screenshots": [
        "/home/runner/_work/code/code/validation_test_results/urs-031-record-transactions-timestamps-userids/2026-08-03T23-03-21-163Z/screenshots/step-06-cross-user-returns.png"
      ],
      "explanation": "As Mark Manufacturer, verifies that return transactions are also visible cross-user with Created By and Created columns showing the original submitter.",
      "startedAt": "2026-08-03T23:05:02.649Z",
      "finishedAt": "2026-08-03T23:05:02.649Z"
    },
    {
      "name": "Step 7: Combined transaction log",
      "status": "pass",
      "description": "Step 7: Combined transaction log",
      "screenshots": [
        "/home/runner/_work/code/code/validation_test_results/urs-031-record-transactions-timestamps-userids/2026-08-03T23-03-21-163Z/screenshots/step-07-transaction-log.png"
      ],
      "explanation": "Renders a live query from billing_orders, inventory_transactions, audit_events, and returns tables, proving every recorded transaction has a user and timestamp.",
      "startedAt": "2026-08-03T23:05:05.550Z",
      "finishedAt": "2026-08-03T23:05:05.550Z",
      "videoPath": "/home/runner/_work/code/code/validation_test_results/urs-031-record-transactions-timestamps-userids/2026-08-03T23-03-21-163Z/videos/step-07-transaction-log.webm"
    }
  ],
  "dbValidations": [
    {
      "name": "Bill-only orders recorded with user ID + timestamp",
      "query": "\n      SELECT id, order_number, status, created_by_user_id, created_at\n        FROM billing_orders\n       WHERE created_by_user_id = $1\n         AND created_at > NOW() - INTERVAL '30 minutes'\n       ORDER BY created_at ASC",
      "status": "pass",
      "rows": [
        {
          "id": "019fc9de-9a8b-7494-90d5-c5a7cff862fa",
          "order_number": "BO-1",
          "status": "submitted",
          "created_by_user_id": "17b8c9d0-e1f2-3456-1234-567890123456",
          "created_at": "2026-08-03T23:03:56.721Z"
        },
        {
          "id": "019fc9df-2a5c-7c7a-80a6-1809f426e4fe",
          "order_number": "BO-2",
          "status": "submitted",
          "created_by_user_id": "17b8c9d0-e1f2-3456-1234-567890123456",
          "created_at": "2026-08-03T23:04:33.587Z"
        }
      ],
      "assertion": "At least two billing_orders created by Blair in the test window, each with created_by_user_id and created_at populated"
    },
    {
      "name": "Inventory transactions recorded with timestamp",
      "query": "\n      SELECT id, source_type, source_id, created_at,\n             distributor_organization_id, manufacturer_organization_id\n        FROM inventory_transactions\n       WHERE source_type = 'bill_only_order'\n         AND created_at > NOW() - INTERVAL '30 minutes'\n         AND (distributor_organization_id = $1 OR manufacturer_organization_id = $1)\n       ORDER BY created_at ASC",
      "status": "pass",
      "rows": [
        {
          "id": "019fc9de-9a9c-70be-be04-42519b0cc8d8",
          "source_type": "bill_only_order",
          "source_id": "019fc9de-9a8b-7494-90d5-c5a7cff862fa",
          "created_at": "2026-08-03T23:03:56.721Z",
          "distributor_organization_id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
          "manufacturer_organization_id": null
        },
        {
          "id": "019fc9df-2a65-7357-920e-e0117fab83ca",
          "source_type": "bill_only_order",
          "source_id": "019fc9df-2a5c-7c7a-80a6-1809f426e4fe",
          "created_at": "2026-08-03T23:04:33.587Z",
          "distributor_organization_id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
          "manufacturer_organization_id": null
        }
      ],
      "assertion": "inventory_transactions rows exist for the bill-only orders, each with a non-null created_at"
    },
    {
      "name": "Inventory history records each change with a timestamp",
      "query": "\n      SELECT ih.id, ih.item_id, ih.quantity, ih.info, ih.created_at\n        FROM inventory_history ih\n       WHERE ih.created_at > NOW() - INTERVAL '30 minutes'\n         AND ih.info->>'reason' = 'bill_only_order'\n       ORDER BY ih.created_at ASC\n       LIMIT 20",
      "status": "pass",
      "rows": [
        {
          "id": "019fc9de-9aa3-7c23-8536-d26b4ce9fcdf",
          "item_id": "42426acb-4574-4227-a715-c017f489f23a",
          "quantity": 2,
          "info": {
            "action": "removed",
            "reason": "bill_only_order",
            "bestEffort": true,
            "billingOrderId": "019fc9de-9a8b-7494-90d5-c5a7cff862fa",
            "shortageQuantity": 0,
            "requestedQuantity": 2
          },
          "created_at": "2026-08-03T23:03:56.721Z"
        },
        {
          "id": "019fc9de-9aa3-7c23-8536-d26c4a6b82eb",
          "item_id": "b165230e-afae-4bc0-a96d-93085f92a5a4",
          "quantity": 3,
          "info": {
            "action": "removed",
            "reason": "bill_only_order",
            "bestEffort": true,
            "billingOrderId": "019fc9de-9a8b-7494-90d5-c5a7cff862fa",
            "shortageQuantity": 0,
            "requestedQuantity": 3
          },
          "created_at": "2026-08-03T23:03:56.721Z"
        },
        {
          "id": "019fc9df-2a70-7d4a-871b-0217603852b7",
          "item_id": "42426acb-4574-4227-a715-c017f489f23a",
          "quantity": 1,
          "info": {
            "action": "removed",
            "reason": "bill_only_order",
            "bestEffort": true,
            "billingOrderId": "019fc9df-2a5c-7c7a-80a6-1809f426e4fe",
            "shortageQuantity": 0,
            "requestedQuantity": 1
          },
          "created_at": "2026-08-03T23:04:33.587Z"
        },
        {
          "id": "019fc9df-2a70-7d4a-871b-02186e6823ed",
          "item_id": "b165230e-afae-4bc0-a96d-93085f92a5a4",
          "quantity": 1,
          "info": {
            "action": "removed",
            "reason": "bill_only_order",
            "bestEffort": true,
            "billingOrderId": "019fc9df-2a5c-7c7a-80a6-1809f426e4fe",
            "shortageQuantity": 0,
            "requestedQuantity": 1
          },
          "created_at": "2026-08-03T23:04:33.587Z"
        }
      ],
      "assertion": "inventory_history contains bill_only_order rows in the test window, each with created_at populated"
    },
    {
      "name": "Audit events recorded with user ID + timestamp",
      "query": "\n      SELECT id, organization_id, user_id, event_type, action,\n             object_id, created_at\n        FROM audit_events\n       WHERE created_at > NOW() - INTERVAL '30 minutes'\n         AND organization_id IN ($1, $2)\n       ORDER BY created_at ASC\n       LIMIT 50",
      "status": "pass",
      "rows": [
        {
          "id": "019fc9de-06a2-77d5-aa48-da75ab48306e",
          "organization_id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
          "user_id": null,
          "event_type": "checklist",
          "action": "checklists.create",
          "object_id": "019fc9de-069b-7ae8-802a-1548f45b11c5",
          "created_at": "2026-08-03T23:03:18.935Z"
        },
        {
          "id": "019fc9de-0714-704f-baa4-00700769a895",
          "organization_id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
          "user_id": null,
          "event_type": "decision",
          "action": "ensure_lot_expiration_checklist",
          "object_id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
          "created_at": "2026-08-03T23:03:19.061Z"
        },
        {
          "id": "019fc9de-1cf0-71a0-a1c5-8339e3c61fb7",
          "organization_id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
          "user_id": "17b8c9d0-e1f2-3456-1234-567890123456",
          "event_type": "user_log",
          "action": "user:login",
          "object_id": null,
          "created_at": "2026-08-03T23:03:24.673Z"
        },
        {
          "id": "019fc9de-2a45-7e93-9702-f539bf27ab90",
          "organization_id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
          "user_id": "17b8c9d0-e1f2-3456-1234-567890123456",
          "event_type": "user_log",
          "action": "user:login",
          "object_id": null,
          "created_at": "2026-08-03T23:03:28.081Z"
        },
        {
          "id": "019fc9de-9a90-78e8-bdaa-6cfa59db0065",
          "organization_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
          "user_id": "17b8c9d0-e1f2-3456-1234-567890123456",
          "event_type": "decision",
          "action": "bill_only_order.inventory_items_decrement",
          "object_id": "019fc9de-9a8b-7494-90d5-c5a7cff862fa",
          "created_at": "2026-08-03T23:03:56.721Z"
        },
        {
          "id": "019fc9de-9aaa-78cd-a84a-08b3698b4815",
          "organization_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
          "user_id": "17b8c9d0-e1f2-3456-1234-567890123456",
          "event_type": "decision",
          "action": "bill_only_order.direct_po_import_on_create",
          "object_id": "019fc9de-9a8b-7494-90d5-c5a7cff862fa",
          "created_at": "2026-08-03T23:03:56.721Z"
        },
        {
          "id": "019fc9de-9aae-7b67-9113-f1f5704830d2",
          "organization_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
          "user_id": "17b8c9d0-e1f2-3456-1234-567890123456",
          "event_type": "billing_order",
          "action": "status_change",
          "object_id": "019fc9de-9a8b-7494-90d5-c5a7cff862fa",
          "created_at": "2026-08-03T23:03:56.721Z"
        },
        {
          "id": "019fc9de-9ab4-7cce-84f9-84b3ead1513e",
          "organization_id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
          "user_id": "17b8c9d0-e1f2-3456-1234-567890123456",
          "event_type": "decision",
          "action": "bill_only.link_purchase_order",
          "object_id": "019fc9de-9a8b-7494-90d5-c5a7cff862fa",
          "created_at": "2026-08-03T23:03:56.721Z"
        },
        {
          "id": "019fc9de-9d9f-7c33-9270-6e47b100b926",
          "organization_id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
          "user_id": null,
          "event_type": "transactional_email",
          "action": "new_bill_only",
          "object_id": "019fc9de-9a8b-7494-90d5-c5a7cff862fa",
          "created_at": "2026-08-03T23:03:57.627Z"
        },
        {
          "id": "019fc9de-aff0-76ba-b9fd-36375904db1f",
          "organization_id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
          "user_id": "17b8c9d0-e1f2-3456-1234-567890123456",
          "event_type": "user_log",
          "action": "user:login",
          "object_id": null,
          "created_at": "2026-08-03T23:04:02.324Z"
        },
        {
          "id": "019fc9df-2a60-7c72-b0be-bf5f8caed54a",
          "organization_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
          "user_id": "17b8c9d0-e1f2-3456-1234-567890123456",
          "event_type": "decision",
          "action": "bill_only_order.inventory_items_decrement",
          "object_id": "019fc9df-2a5c-7c7a-80a6-1809f426e4fe",
          "created_at": "2026-08-03T23:04:33.587Z"
        },
        {
          "id": "019fc9df-2a74-7a0f-b073-eab387870969",
          "organization_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
          "user_id": "17b8c9d0-e1f2-3456-1234-567890123456",
          "event_type": "decision",
          "action": "bill_only_order.direct_po_import_on_create",
          "object_id": "019fc9df-2a5c-7c7a-80a6-1809f426e4fe",
          "created_at": "2026-08-03T23:04:33.587Z"
        },
        {
          "id": "019fc9df-2a76-79fb-8020-9bd5f21d0f3b",
          "organization_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
          "user_id": "17b8c9d0-e1f2-3456-1234-567890123456",
          "event_type": "billing_order",
          "action": "status_change",
          "object_id": "019fc9df-2a5c-7c7a-80a6-1809f426e4fe",
          "created_at": "2026-08-03T23:04:33.587Z"
        },
        {
          "id": "019fc9df-2a79-765a-9f66-629a4ac066ce",
          "organization_id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
          "user_id": "17b8c9d0-e1f2-3456-1234-567890123456",
          "event_type": "decision",
          "action": "bill_only.link_purchase_order",
          "object_id": "019fc9df-2a5c-7c7a-80a6-1809f426e4fe",
          "created_at": "2026-08-03T23:04:33.587Z"
        },
        {
          "id": "019fc9df-2ec5-7488-b452-686564f3168f",
          "organization_id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
          "user_id": null,
          "event_type": "transactional_email",
          "action": "new_bill_only",
          "object_id": "019fc9df-2a5c-7c7a-80a6-1809f426e4fe",
          "created_at": "2026-08-03T23:04:34.781Z"
        },
        {
          "id": "019fc9df-401f-7f16-84f3-032adaa4bc34",
          "organization_id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
          "user_id": "17b8c9d0-e1f2-3456-1234-567890123456",
          "event_type": "user_log",
          "action": "user:login",
          "object_id": null,
          "created_at": "2026-08-03T23:04:39.206Z"
        },
        {
          "id": "019fc9df-5f89-71da-893a-a9430787d2a3",
          "organization_id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
          "user_id": "17b8c9d0-e1f2-3456-1234-567890123456",
          "event_type": "user_log",
          "action": "user:login",
          "object_id": null,
          "created_at": "2026-08-03T23:04:47.250Z"
        },
        {
          "id": "019fc9df-7ee5-7f98-a1fd-e1d1a0a647ec",
          "organization_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
          "user_id": "d4e5f6a7-b8c9-0123-def1-234567890123",
          "event_type": "user_log",
          "action": "user:login",
          "object_id": null,
          "created_at": "2026-08-03T23:04:55.279Z"
        }
      ],
      "assertion": "At least one audit_events row in the test window has both user_id and created_at populated, and no row is missing created_at"
    },
    {
      "name": "Returns have created_by_user_id + created_at populated",
      "query": "\n      SELECT r.id, r.return_number, r.status, r.created_by_user_id,\n             r.created_at, u.email AS created_by_email\n        FROM returns r\n        LEFT JOIN users u ON u.id = r.created_by_user_id\n       WHERE r.return_number = ANY($1)\n          OR r.created_at > NOW() - INTERVAL '30 minutes'\n       ORDER BY r.created_at ASC",
      "status": "pass",
      "rows": [
        {
          "id": "ca000003-0000-4000-8000-000000000003",
          "return_number": "VRI-RET-2025-003",
          "status": "submitted",
          "created_by_user_id": "17b8c9d0-e1f2-3456-1234-567890123456",
          "created_at": "2026-07-04T22:58:16.230Z",
          "created_by_email": "blair.bennett@corvetasurgical.com"
        },
        {
          "id": "ca000002-0000-4000-8000-000000000002",
          "return_number": "VRI-RET-2025-002",
          "status": "submitted",
          "created_by_user_id": "28c9d0e1-f2a3-4567-2345-678901234567",
          "created_at": "2026-07-20T22:58:16.230Z",
          "created_by_email": "rana.reyes@corvetasurgical.com"
        },
        {
          "id": "ca000001-0000-4000-8000-000000000001",
          "return_number": "VRI-RET-2025-001",
          "status": "submitted",
          "created_by_user_id": "17b8c9d0-e1f2-3456-1234-567890123456",
          "created_at": "2026-07-31T22:58:16.230Z",
          "created_by_email": "blair.bennett@corvetasurgical.com"
        }
      ],
      "assertion": "All pre-seeded returns (and any created during the test) have non-null created_by_user_id and created_at"
    },
    {
      "name": "Inventory transactions timestamped at or after their triggering order",
      "query": "\n      SELECT bo.order_number,\n             bo.created_at             AS order_created_at,\n             MIN(it.created_at)        AS first_txn_created_at\n        FROM billing_orders bo\n        JOIN inventory_transactions it\n          ON it.source_type = 'bill_only_order'\n         AND it.source_id = bo.id\n       WHERE bo.created_by_user_id = $1\n         AND bo.created_at > NOW() - INTERVAL '30 minutes'\n       GROUP BY bo.id, bo.order_number, bo.created_at",
      "status": "pass",
      "rows": [
        {
          "order_number": "BO-1",
          "order_created_at": "2026-08-03T23:03:56.721Z",
          "first_txn_created_at": "2026-08-03T23:03:56.721Z"
        },
        {
          "order_number": "BO-2",
          "order_created_at": "2026-08-03T23:04:33.587Z",
          "first_txn_created_at": "2026-08-03T23:04:33.587Z"
        }
      ],
      "assertion": "For every bill-only order in the test window, the earliest inventory_transaction linked to it has created_at >= billing_order.created_at"
    },
    {
      "name": "Multiple distinct users represented across transactions",
      "query": "\n      SELECT DISTINCT user_id FROM (\n        SELECT created_by_user_id AS user_id FROM billing_orders\n         WHERE created_at > NOW() - INTERVAL '30 minutes'\n           AND created_by_user_id IS NOT NULL\n        UNION\n        SELECT created_by_user_id AS user_id FROM returns\n         WHERE return_number = ANY($1)\n        UNION\n        SELECT user_id FROM audit_events\n         WHERE created_at > NOW() - INTERVAL '30 minutes'\n           AND user_id IS NOT NULL\n      ) u\n       ORDER BY user_id",
      "status": "pass",
      "rows": [
        {
          "user_id": "17b8c9d0-e1f2-3456-1234-567890123456"
        },
        {
          "user_id": "28c9d0e1-f2a3-4567-2345-678901234567"
        },
        {
          "user_id": "d4e5f6a7-b8c9-0123-def1-234567890123"
        }
      ],
      "assertion": "The combined transaction set (orders, returns, audit events) contains at least two distinct user IDs"
    }
  ],
  "overallStatus": "pass",
  "outputDir": "/home/runner/_work/code/code/validation_test_results/urs-031-record-transactions-timestamps-userids/2026-08-03T23-03-21-163Z",
  "auditStartTime": "2026-08-03T23:03:19.281Z",
  "emailEvidence": [
    {
      "subject": "New Bill-Only Order - 8/3/2026 - Vantis BO-1",
      "template": "New_Bill-Only_Order_-_8_3_2026_-_Vantis_BO-1",
      "screenshotPath": "/home/runner/_work/code/code/validation_test_results/urs-031-record-transactions-timestamps-userids/2026-08-03T23-03-21-163Z/screenshots/emails/2026-08-03T23-03-57-589Z-New_Bill-Only_Order_-_8_3_2026_-_Vantis_BO-1.png"
    },
    {
      "subject": "New Bill-Only Order - 8/3/2026 - Vantis BO-2",
      "template": "New_Bill-Only_Order_-_8_3_2026_-_Vantis_BO-2",
      "screenshotPath": "/home/runner/_work/code/code/validation_test_results/urs-031-record-transactions-timestamps-userids/2026-08-03T23-03-21-163Z/screenshots/emails/2026-08-03T23-04-34-744Z-New_Bill-Only_Order_-_8_3_2026_-_Vantis_BO-2.png"
    }
  ],
  "auditEventEvidence": [
    {
      "createdAt": "2026-08-03T23:03:24.673Z",
      "eventType": "user_log",
      "action": "user:login",
      "userEmail": "blair.bennett@corvetasurgical.com",
      "userId": "17b8c9d0-e1f2-3456-1234-567890123456",
      "organizationName": "Corveta Surgical Group",
      "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "objectId": null,
      "secondaryObjectId": null,
      "payload": {
        "email": "blair.bennett@corvetasurgical.com"
      },
      "route": "/login",
      "traceId": "00000000000000000000000000000000"
    },
    {
      "createdAt": "2026-08-03T23:03:28.081Z",
      "eventType": "user_log",
      "action": "user:login",
      "userEmail": "blair.bennett@corvetasurgical.com",
      "userId": "17b8c9d0-e1f2-3456-1234-567890123456",
      "organizationName": "Corveta Surgical Group",
      "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "objectId": null,
      "secondaryObjectId": null,
      "payload": {
        "email": "blair.bennett@corvetasurgical.com"
      },
      "route": "/login",
      "traceId": "00000000000000000000000000000000"
    },
    {
      "createdAt": "2026-08-03T23:03:56.721Z",
      "eventType": "billing_order",
      "action": "status_change",
      "userEmail": "blair.bennett@corvetasurgical.com",
      "userId": "17b8c9d0-e1f2-3456-1234-567890123456",
      "organizationName": "Vantis",
      "organizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "objectId": "019fc9de-9a8b-7494-90d5-c5a7cff862fa",
      "secondaryObjectId": null,
      "payload": {
        "reason": null,
        "toStatus": "submitted",
        "fromStatus": null,
        "automatedAction": false
      },
      "route": null,
      "traceId": null
    },
    {
      "createdAt": "2026-08-03T23:03:56.721Z",
      "eventType": "decision",
      "action": "bill_only.link_purchase_order",
      "userEmail": "blair.bennett@corvetasurgical.com",
      "userId": "17b8c9d0-e1f2-3456-1234-567890123456",
      "organizationName": "Corveta Surgical Group",
      "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "objectId": "019fc9de-9a8b-7494-90d5-c5a7cff862fa",
      "secondaryObjectId": null,
      "payload": {
        "reason": "no_purchase_order_selected",
        "performed": false,
        "entityType": "billing_order",
        "salesOrganizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
        "manufacturerOrganizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
      },
      "route": null,
      "traceId": null
    },
    {
      "createdAt": "2026-08-03T23:03:56.721Z",
      "eventType": "decision",
      "action": "bill_only_order.inventory_items_decrement",
      "userEmail": "blair.bennett@corvetasurgical.com",
      "userId": "17b8c9d0-e1f2-3456-1234-567890123456",
      "organizationName": "Vantis",
      "organizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "objectId": "019fc9de-9a8b-7494-90d5-c5a7cff862fa",
      "secondaryObjectId": null,
      "payload": {
        "reason": "inventory_items_decremented",
        "itemCount": 5,
        "performed": true,
        "entityType": "billing_order",
        "inventorySource": "inventory_items"
      },
      "route": null,
      "traceId": null
    },
    {
      "createdAt": "2026-08-03T23:03:56.721Z",
      "eventType": "decision",
      "action": "bill_only_order.direct_po_import_on_create",
      "userEmail": "blair.bennett@corvetasurgical.com",
      "userId": "17b8c9d0-e1f2-3456-1234-567890123456",
      "organizationName": "Vantis",
      "organizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "objectId": "019fc9de-9a8b-7494-90d5-c5a7cff862fa",
      "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-08-03T23:03:57.627Z",
      "eventType": "transactional_email",
      "action": "new_bill_only",
      "userEmail": null,
      "userId": null,
      "organizationName": "Corveta Surgical Group",
      "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "objectId": "019fc9de-9a8b-7494-90d5-c5a7cff862fa",
      "secondaryObjectId": null,
      "payload": {
        "to": [
          "blair.bennett@corvetasurgical.com"
        ],
        "s3Path": "email-audit/b2c3d4e5-f6a7-8901-bcde-f12345678901/019fc9de-9d9f-7c33-9270-6e47b100b926/",
        "subject": "New Bill-Only Order - 8/3/2026 - Vantis BO-1",
        "messageId": "dev-console-log",
        "relatedEntityType": "billing_order"
      },
      "route": null,
      "traceId": null
    },
    {
      "createdAt": "2026-08-03T23:04:02.324Z",
      "eventType": "user_log",
      "action": "user:login",
      "userEmail": "blair.bennett@corvetasurgical.com",
      "userId": "17b8c9d0-e1f2-3456-1234-567890123456",
      "organizationName": "Corveta Surgical Group",
      "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "objectId": null,
      "secondaryObjectId": null,
      "payload": {
        "email": "blair.bennett@corvetasurgical.com"
      },
      "route": "/login",
      "traceId": "00000000000000000000000000000000"
    },
    {
      "createdAt": "2026-08-03T23:04:33.587Z",
      "eventType": "decision",
      "action": "bill_only_order.inventory_items_decrement",
      "userEmail": "blair.bennett@corvetasurgical.com",
      "userId": "17b8c9d0-e1f2-3456-1234-567890123456",
      "organizationName": "Vantis",
      "organizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "objectId": "019fc9df-2a5c-7c7a-80a6-1809f426e4fe",
      "secondaryObjectId": null,
      "payload": {
        "reason": "inventory_items_decremented",
        "itemCount": 2,
        "performed": true,
        "entityType": "billing_order",
        "inventorySource": "inventory_items"
      },
      "route": null,
      "traceId": null
    },
    {
      "createdAt": "2026-08-03T23:04:33.587Z",
      "eventType": "decision",
      "action": "bill_only.link_purchase_order",
      "userEmail": "blair.bennett@corvetasurgical.com",
      "userId": "17b8c9d0-e1f2-3456-1234-567890123456",
      "organizationName": "Corveta Surgical Group",
      "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "objectId": "019fc9df-2a5c-7c7a-80a6-1809f426e4fe",
      "secondaryObjectId": null,
      "payload": {
        "reason": "no_purchase_order_selected",
        "performed": false,
        "entityType": "billing_order",
        "salesOrganizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
        "manufacturerOrganizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
      },
      "route": null,
      "traceId": null
    },
    {
      "createdAt": "2026-08-03T23:04:33.587Z",
      "eventType": "billing_order",
      "action": "status_change",
      "userEmail": "blair.bennett@corvetasurgical.com",
      "userId": "17b8c9d0-e1f2-3456-1234-567890123456",
      "organizationName": "Vantis",
      "organizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "objectId": "019fc9df-2a5c-7c7a-80a6-1809f426e4fe",
      "secondaryObjectId": null,
      "payload": {
        "reason": null,
        "toStatus": "submitted",
        "fromStatus": null,
        "automatedAction": false
      },
      "route": null,
      "traceId": null
    },
    {
      "createdAt": "2026-08-03T23:04:33.587Z",
      "eventType": "decision",
      "action": "bill_only_order.direct_po_import_on_create",
      "userEmail": "blair.bennett@corvetasurgical.com",
      "userId": "17b8c9d0-e1f2-3456-1234-567890123456",
      "organizationName": "Vantis",
      "organizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "objectId": "019fc9df-2a5c-7c7a-80a6-1809f426e4fe",
      "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-08-03T23:04:34.781Z",
      "eventType": "transactional_email",
      "action": "new_bill_only",
      "userEmail": null,
      "userId": null,
      "organizationName": "Corveta Surgical Group",
      "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "objectId": "019fc9df-2a5c-7c7a-80a6-1809f426e4fe",
      "secondaryObjectId": null,
      "payload": {
        "to": [
          "blair.bennett@corvetasurgical.com"
        ],
        "s3Path": "email-audit/b2c3d4e5-f6a7-8901-bcde-f12345678901/019fc9df-2ec5-7488-b452-686564f3168f/",
        "subject": "New Bill-Only Order - 8/3/2026 - Vantis BO-2",
        "messageId": "dev-console-log",
        "relatedEntityType": "billing_order"
      },
      "route": null,
      "traceId": null
    },
    {
      "createdAt": "2026-08-03T23:04:39.206Z",
      "eventType": "user_log",
      "action": "user:login",
      "userEmail": "blair.bennett@corvetasurgical.com",
      "userId": "17b8c9d0-e1f2-3456-1234-567890123456",
      "organizationName": "Corveta Surgical Group",
      "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "objectId": null,
      "secondaryObjectId": null,
      "payload": {
        "email": "blair.bennett@corvetasurgical.com"
      },
      "route": "/login",
      "traceId": "00000000000000000000000000000000"
    },
    {
      "createdAt": "2026-08-03T23:04:47.250Z",
      "eventType": "user_log",
      "action": "user:login",
      "userEmail": "blair.bennett@corvetasurgical.com",
      "userId": "17b8c9d0-e1f2-3456-1234-567890123456",
      "organizationName": "Corveta Surgical Group",
      "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "objectId": null,
      "secondaryObjectId": null,
      "payload": {
        "email": "blair.bennett@corvetasurgical.com"
      },
      "route": "/login",
      "traceId": "00000000000000000000000000000000"
    },
    {
      "createdAt": "2026-08-03T23:04:55.279Z",
      "eventType": "user_log",
      "action": "user:login",
      "userEmail": "mark.manufacturer@vantismedical.com",
      "userId": "d4e5f6a7-b8c9-0123-def1-234567890123",
      "organizationName": "Vantis",
      "organizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "objectId": null,
      "secondaryObjectId": null,
      "payload": {
        "email": "mark.manufacturer@vantismedical.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: Logged in as Blair Bennett",
      "expectedAction": "user_log:user:login",
      "found": true
    },
    {
      "stepName": "Step 2: First order",
      "expectedAction": "decision:bill_only_order.inventory_items_decrement",
      "found": true
    },
    {
      "stepName": "Step 2: First order",
      "expectedAction": "billing_order:status_change",
      "found": true
    },
    {
      "stepName": "Step 3: Second order",
      "expectedAction": "decision:bill_only_order.inventory_items_decrement",
      "found": true
    },
    {
      "stepName": "Step 3: Second order",
      "expectedAction": "billing_order:status_change",
      "found": true
    },
    {
      "stepName": "Step 6: Cross-user billing view",
      "expectedAction": "user_log:user:login",
      "found": true
    }
  ],
  "emailAssertions": [
    {
      "stepName": "Step 2: First order",
      "expectedTemplate": "New Bill-Only Order",
      "found": true
    },
    {
      "stepName": "Step 3: Second order",
      "expectedTemplate": "New Bill-Only Order",
      "found": true
    }
  ]
}