{
  "ursId": "URS-029",
  "title": "Collect Return Information per Individual Item",
  "timestamp": "2026-08-03T23:09:29.894Z",
  "durationMs": 60616,
  "config": {
    "inboxUrl": "http://localhost:38465",
    "dbHost": "localhost",
    "dbPort": 46031,
    "dbName": "cc_repinbox_dev"
  },
  "setup": {
    "status": "pass"
  },
  "scenarios": [
    {
      "name": "Login",
      "status": "pass",
      "description": "Login",
      "screenshots": [
        "/home/runner/_work/code/code/validation_test_results/urs-029-return-per-item-information/2026-08-03T23-09-29-893Z/screenshots/01-logged-in.png"
      ],
      "explanation": "Authenticates as Blair Bennett (Corveta sales rep) to establish the user identity that will be associated with the return submission.",
      "expectedAuditActions": [
        "user_log:user:login"
      ],
      "startedAt": "2026-08-03T23:09:35.784Z",
      "finishedAt": "2026-08-03T23:09:35.784Z"
    },
    {
      "name": "New Return opened",
      "status": "pass",
      "description": "New Return opened",
      "screenshots": [
        "/home/runner/_work/code/code/validation_test_results/urs-029-return-per-item-information/2026-08-03T23-09-29-893Z/screenshots/02-new-return-form.png"
      ],
      "explanation": "Navigates to the new return form, confirming the multi-step return workflow is accessible.",
      "startedAt": "2026-08-03T23:09:39.982Z",
      "finishedAt": "2026-08-03T23:09:39.982Z"
    },
    {
      "name": "Account selected",
      "status": "pass",
      "description": "Account selected",
      "screenshots": [
        "/home/runner/_work/code/code/validation_test_results/urs-029-return-per-item-information/2026-08-03T23-09-29-893Z/screenshots/03-account-selected.png"
      ],
      "explanation": "Selects the sales account to associate with the return, establishing the account-level context for per-item traceability.",
      "startedAt": "2026-08-03T23:09:44.049Z",
      "finishedAt": "2026-08-03T23:09:44.049Z"
    },
    {
      "name": "Event details",
      "status": "pass",
      "description": "Event details",
      "screenshots": [
        "/home/runner/_work/code/code/validation_test_results/urs-029-return-per-item-information/2026-08-03T23-09-29-893Z/screenshots/04-event-details.png"
      ],
      "explanation": "Records the reporting user, event date, and a unique run marker in the notes field so the database validation step can locate this specific return.",
      "startedAt": "2026-08-03T23:09:49.106Z",
      "finishedAt": "2026-08-03T23:09:49.106Z"
    },
    {
      "name": "Quantities filled",
      "status": "pass",
      "description": "Quantities filled",
      "screenshots": [
        "/home/runner/_work/code/code/validation_test_results/urs-029-return-per-item-information/2026-08-03T23-09-29-893Z/screenshots/05-product-quantities-set.png"
      ],
      "explanation": "Sets return quantities for three products (2 NovaPatch, 3 LiraLock, 1 Medical Gelatin = 6 total units), enabling per-unit item card generation.",
      "startedAt": "2026-08-03T23:09:55.889Z",
      "finishedAt": "2026-08-03T23:09:55.889Z"
    },
    {
      "name": "Lots filled",
      "status": "pass",
      "description": "Lots filled",
      "screenshots": [
        "/home/runner/_work/code/code/validation_test_results/urs-029-return-per-item-information/2026-08-03T23-09-29-893Z/screenshots/06-product-lots-filled.png"
      ],
      "explanation": "Assigns distinct lot numbers to each individual unit, demonstrating that the form supports per-unit lot tracking rather than a single shared lot.",
      "startedAt": "2026-08-03T23:10:09.955Z",
      "finishedAt": "2026-08-03T23:10:09.955Z"
    },
    {
      "name": "All 6 item cards rendered",
      "status": "pass",
      "description": "All 6 item cards rendered",
      "screenshots": [
        "/home/runner/_work/code/code/validation_test_results/urs-029-return-per-item-information/2026-08-03T23-09-29-893Z/screenshots/07-per-item-cards-rendered.png"
      ],
      "explanation": "Verifies that the form renders one item card per unit (6 total), each with product-specific question fields — the prerequisite for per-item data capture.",
      "startedAt": "2026-08-03T23:10:12.035Z",
      "finishedAt": "2026-08-03T23:10:12.035Z"
    },
    {
      "name": "All per-item questions filled",
      "status": "pass",
      "description": "All per-item questions filled",
      "screenshots": [
        "/home/runner/_work/code/code/validation_test_results/urs-029-return-per-item-information/2026-08-03T23-09-29-893Z/screenshots/08-per-item-questions-filled.png"
      ],
      "explanation": "Fills distinct answers for every unit's product-specific questions, proving that each unit's response is captured independently rather than shared across units.",
      "startedAt": "2026-08-03T23:10:17.069Z",
      "finishedAt": "2026-08-03T23:10:17.069Z"
    },
    {
      "name": "Locations selected",
      "status": "pass",
      "description": "Locations selected",
      "screenshots": [
        "/home/runner/_work/code/code/validation_test_results/urs-029-return-per-item-information/2026-08-03T23-09-29-893Z/screenshots/09-locations-selected.png"
      ],
      "explanation": "Selects return and replacement shipping locations to complete the return request before the review step.",
      "startedAt": "2026-08-03T23:10:24.318Z",
      "finishedAt": "2026-08-03T23:10:24.318Z"
    },
    {
      "name": "Review summary",
      "status": "pass",
      "description": "Review summary",
      "screenshots": [
        "/home/runner/_work/code/code/validation_test_results/urs-029-return-per-item-information/2026-08-03T23-09-29-893Z/screenshots/10-review-summary.png"
      ],
      "explanation": "Displays the full summary of all 6 units with their individual lot numbers and answers, confirming per-item data is preserved through to the review step.",
      "startedAt": "2026-08-03T23:10:26.323Z",
      "finishedAt": "2026-08-03T23:10:26.323Z"
    },
    {
      "name": "Submission success",
      "status": "pass",
      "description": "Submission success",
      "screenshots": [
        "/home/runner/_work/code/code/validation_test_results/urs-029-return-per-item-information/2026-08-03T23-09-29-893Z/screenshots/11-submission-success.png"
      ],
      "explanation": "Confirms the return was submitted successfully, triggering back-end persistence of return_items and per-item question responses for each unit.",
      "expectedAuditActions": [
        "return_request:created"
      ],
      "startedAt": "2026-08-03T23:10:28.315Z",
      "finishedAt": "2026-08-03T23:10:28.315Z"
    }
  ],
  "dbValidations": [
    {
      "name": "Return created for Corveta → Vantis",
      "query": "SELECT id, return_number, status, date_of_event, notes, created_at\n    FROM returns\n    WHERE sales_organization_id = $1\n      AND manufacturer_organization_id = $2\n      AND notes LIKE 'URS-029%'\n      AND created_at > NOW() - INTERVAL '2 hours'\n    ORDER BY created_at DESC",
      "status": "pass",
      "rows": [
        {
          "id": "019fc9e4-938a-74a3-bc58-89808805c221",
          "return_number": "RET-1",
          "status": "submitted",
          "date_of_event": "2026-08-03T00:00:00.000Z",
          "notes": "URS-029 validation run 2026-08-03T23:09:31.011Z",
          "created_at": "2026-08-03T23:10:28.206Z"
        }
      ],
      "assertion": "Exactly one return with status=submitted should exist, created in the last 2 hours."
    },
    {
      "name": "Per-item return_items rows",
      "query": "SELECT ri.id, ri.product_id, op.sku, op.title, ri.lot_number,\n      ri.return_item_number, ri.created_at\n    FROM return_items ri\n    JOIN org_products op ON op.id = ri.product_id\n    WHERE ri.return_id = $1\n    ORDER BY op.sku, ri.lot_number",
      "status": "pass",
      "rows": [
        {
          "id": "019fc9e4-938d-7af4-9b34-05547272d311",
          "product_id": "66a80423-2315-4d10-8ecf-238b3058528b",
          "sku": "DB2025G",
          "title": "Medical gelatin (For demonstration purpose)",
          "lot_number": "URS029-MG-001",
          "return_item_number": "RET-1-DB2025G-1",
          "created_at": "2026-08-03T23:10:28.206Z"
        },
        {
          "id": "019fc9e4-938d-7af4-9b34-0551baf4429f",
          "product_id": "01989ca1-f2f8-7ab7-8269-7179342797cc",
          "sku": "LL516SNA",
          "title": "LiraLock® Instrument SN",
          "lot_number": "URS029-FL-001",
          "return_item_number": "RET-1-LL516SNA-1",
          "created_at": "2026-08-03T23:10:28.206Z"
        },
        {
          "id": "019fc9e4-938d-7af4-9b34-055230f35bc4",
          "product_id": "01989ca1-f2f8-7ab7-8269-7179342797cc",
          "sku": "LL516SNA",
          "title": "LiraLock® Instrument SN",
          "lot_number": "URS029-FL-002",
          "return_item_number": "RET-1-LL516SNA-2",
          "created_at": "2026-08-03T23:10:28.206Z"
        },
        {
          "id": "019fc9e4-938d-7af4-9b34-0553780fc602",
          "product_id": "01989ca1-f2f8-7ab7-8269-7179342797cc",
          "sku": "LL516SNA",
          "title": "LiraLock® Instrument SN",
          "lot_number": "URS029-FL-003",
          "return_item_number": "RET-1-LL516SNA-3",
          "created_at": "2026-08-03T23:10:28.206Z"
        },
        {
          "id": "019fc9e4-938d-7af4-9b34-054fb39b9905",
          "product_id": "01989ca2-6a54-7834-8376-06a0251bacd8",
          "sku": "NP019N1A",
          "title": "NovaPatch® PET",
          "lot_number": "URS029-SP-001",
          "return_item_number": "RET-1-NP019N1A-1",
          "created_at": "2026-08-03T23:10:28.206Z"
        },
        {
          "id": "019fc9e4-938d-7af4-9b34-0550b4359457",
          "product_id": "01989ca2-6a54-7834-8376-06a0251bacd8",
          "sku": "NP019N1A",
          "title": "NovaPatch® PET",
          "lot_number": "URS029-SP-002",
          "return_item_number": "RET-1-NP019N1A-2",
          "created_at": "2026-08-03T23:10:28.206Z"
        }
      ],
      "assertion": "Each individual unit should have its own return_items row. Expected 6."
    },
    {
      "name": "Each unit has its own distinct lot number",
      "query": "-- Expected lot numbers: URS029-SP-001, URS029-SP-002, URS029-FL-001, URS029-FL-002, URS029-FL-003, URS029-MG-001",
      "status": "pass",
      "rows": [
        {
          "lot_number": "URS029-MG-001",
          "sku": "DB2025G"
        },
        {
          "lot_number": "URS029-FL-001",
          "sku": "LL516SNA"
        },
        {
          "lot_number": "URS029-FL-002",
          "sku": "LL516SNA"
        },
        {
          "lot_number": "URS029-FL-003",
          "sku": "LL516SNA"
        },
        {
          "lot_number": "URS029-SP-001",
          "sku": "NP019N1A"
        },
        {
          "lot_number": "URS029-SP-002",
          "sku": "NP019N1A"
        }
      ],
      "assertion": "All expected per-unit lot numbers should appear exactly once, proving per-item data was stored."
    },
    {
      "name": "Each returned unit has per-item question responses",
      "query": "SELECT riqr.id, riqr.return_item_id, riqr.question_version_id,\n      riqr.response_text, riqr.response_values::text AS response_values_json,\n      ri.lot_number, rpqv.question_type, rpqv.is_required, rpqv.question_text\n    FROM return_item_question_responses riqr\n    JOIN return_items ri ON ri.id = riqr.return_item_id\n    JOIN return_product_question_versions rpqv ON rpqv.id = riqr.question_version_id\n    JOIN return_product_questions rpq ON rpq.id = rpqv.question_id\n    WHERE ri.return_id = $1\n    ORDER BY ri.lot_number, rpq.display_order NULLS LAST, rpqv.version_number",
      "status": "pass",
      "rows": [
        {
          "id": "019fc9e4-9390-7b63-9f78-59ad099ac232",
          "return_item_id": "019fc9e4-938d-7af4-9b34-0551baf4429f",
          "question_version_id": "0c020902-aaaa-4002-9002-000000000002",
          "response_text": null,
          "response_values_json": "[\"opened\"]",
          "lot_number": "URS029-FL-001",
          "question_type": "single_select",
          "is_required": true,
          "question_text": "Condition at return"
        },
        {
          "id": "019fc9e4-9390-7b63-9f78-59b15337367f",
          "return_item_id": "019fc9e4-938d-7af4-9b34-0551baf4429f",
          "question_version_id": "0c020902-aaaa-4002-9002-000000000004",
          "response_text": "Customer confirmed seal integrity at receipt.",
          "response_values_json": null,
          "lot_number": "URS029-FL-001",
          "question_type": "text",
          "is_required": false,
          "question_text": "Additional notes (optional)"
        },
        {
          "id": "019fc9e4-9390-7b63-9f78-59ae2591cb71",
          "return_item_id": "019fc9e4-938d-7af4-9b34-055230f35bc4",
          "question_version_id": "0c020902-aaaa-4002-9002-000000000002",
          "response_text": null,
          "response_values_json": "[\"unopened\"]",
          "lot_number": "URS029-FL-002",
          "question_type": "single_select",
          "is_required": true,
          "question_text": "Condition at return"
        },
        {
          "id": "019fc9e4-9390-7b63-9f78-59afaa131095",
          "return_item_id": "019fc9e4-938d-7af4-9b34-0553780fc602",
          "question_version_id": "0c020902-aaaa-4002-9002-000000000002",
          "response_text": null,
          "response_values_json": "[\"defective\"]",
          "lot_number": "URS029-FL-003",
          "question_type": "single_select",
          "is_required": true,
          "question_text": "Condition at return"
        },
        {
          "id": "019fc9e4-9390-7b63-9f78-59b0c2661c0a",
          "return_item_id": "019fc9e4-938d-7af4-9b34-05547272d311",
          "question_version_id": "0c020903-aaaa-4003-9002-000000000002",
          "response_text": "URS029 MG unit 1: hydraulic seal failure observed.",
          "response_values_json": null,
          "lot_number": "URS029-MG-001",
          "question_type": "text",
          "is_required": true,
          "question_text": "Unit inspection note"
        },
        {
          "id": "019fc9e4-9390-7b63-9f78-59a9dbb1f1ac",
          "return_item_id": "019fc9e4-938d-7af4-9b34-054fb39b9905",
          "question_version_id": "0c020901-aaaa-4001-9002-000000000002",
          "response_text": null,
          "response_values_json": "[\"damaged\"]",
          "lot_number": "URS029-SP-001",
          "question_type": "single_select",
          "is_required": true,
          "question_text": "Return reason"
        },
        {
          "id": "019fc9e4-9390-7b63-9f78-59aa05c83fa9",
          "return_item_id": "019fc9e4-938d-7af4-9b34-054fb39b9905",
          "question_version_id": "0c020901-aaaa-4001-9002-000000000004",
          "response_text": "URS029 unit 1: screen cracked during shipping, non-functional.",
          "response_values_json": null,
          "lot_number": "URS029-SP-001",
          "question_type": "text",
          "is_required": true,
          "question_text": "Per-unit notes"
        },
        {
          "id": "019fc9e4-9390-7b63-9f78-59abcb7b7306",
          "return_item_id": "019fc9e4-938d-7af4-9b34-0550b4359457",
          "question_version_id": "0c020901-aaaa-4001-9002-000000000002",
          "response_text": null,
          "response_values_json": "[\"unused\"]",
          "lot_number": "URS029-SP-002",
          "question_type": "single_select",
          "is_required": true,
          "question_text": "Return reason"
        },
        {
          "id": "019fc9e4-9390-7b63-9f78-59acbb7f0a4d",
          "return_item_id": "019fc9e4-938d-7af4-9b34-0550b4359457",
          "question_version_id": "0c020901-aaaa-4001-9002-000000000004",
          "response_text": "URS029 unit 2: never opened, preventative return.",
          "response_values_json": null,
          "lot_number": "URS029-SP-002",
          "question_type": "text",
          "is_required": true,
          "question_text": "Per-unit notes"
        }
      ],
      "assertion": "Every return_item should have at least one associated return_item_question_response row."
    },
    {
      "name": "Required per-item question responses present",
      "query": "-- Filter to versions: 0c020901-aaaa-4001-9002-000000000002, 0c020901-aaaa-4001-9002-000000000004, 0c020902-aaaa-4002-9002-000000000002, 0c020903-aaaa-4003-9002-000000000002",
      "status": "pass",
      "rows": [
        {
          "lot_number": "URS029-FL-001",
          "question_text": "Condition at return",
          "response_text": null,
          "response_values": "[\"opened\"]"
        },
        {
          "lot_number": "URS029-FL-002",
          "question_text": "Condition at return",
          "response_text": null,
          "response_values": "[\"unopened\"]"
        },
        {
          "lot_number": "URS029-FL-003",
          "question_text": "Condition at return",
          "response_text": null,
          "response_values": "[\"defective\"]"
        },
        {
          "lot_number": "URS029-MG-001",
          "question_text": "Unit inspection note",
          "response_text": "URS029 MG unit 1: hydraulic seal failure observed.",
          "response_values": null
        },
        {
          "lot_number": "URS029-SP-001",
          "question_text": "Return reason",
          "response_text": null,
          "response_values": "[\"damaged\"]"
        },
        {
          "lot_number": "URS029-SP-001",
          "question_text": "Per-unit notes",
          "response_text": "URS029 unit 1: screen cracked during shipping, non-functional.",
          "response_values": null
        },
        {
          "lot_number": "URS029-SP-002",
          "question_text": "Return reason",
          "response_text": null,
          "response_values": "[\"unused\"]"
        },
        {
          "lot_number": "URS029-SP-002",
          "question_text": "Per-unit notes",
          "response_text": "URS029 unit 2: never opened, preventative return.",
          "response_values": null
        }
      ],
      "assertion": "Expected 8 required-question responses across all items."
    },
    {
      "name": "NovaPatch per-unit free-text answers are distinct",
      "query": "-- Filter to novaPatchNotesVersion = 0c020901-aaaa-4001-9002-000000000004",
      "status": "pass",
      "rows": [
        {
          "lot_number": "URS029-SP-001",
          "response_text": "URS029 unit 1: screen cracked during shipping, non-functional."
        },
        {
          "lot_number": "URS029-SP-002",
          "response_text": "URS029 unit 2: never opened, preventative return."
        }
      ],
      "assertion": "Each NovaPatch unit should have a distinct per-unit note, proving per-item data is collected independently."
    }
  ],
  "overallStatus": "pass",
  "outputDir": "/home/runner/_work/code/code/validation_test_results/urs-029-return-per-item-information/2026-08-03T23-09-29-893Z",
  "auditStartTime": "2026-08-03T23:09:27.971Z",
  "emailEvidence": [
    {
      "subject": "Return Submitted - RET-1",
      "template": "Return_Submitted_-_RET-1",
      "screenshotPath": "/home/runner/_work/code/code/validation_test_results/urs-029-return-per-item-information/2026-08-03T23-09-29-893Z/screenshots/emails/2026-08-03T23-10-29-477Z-Return_Submitted_-_RET-1.png"
    }
  ],
  "auditEventEvidence": [
    {
      "createdAt": "2026-08-03T23:09:35.483Z",
      "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:10:28.206Z",
      "eventType": "decision",
      "action": "create_replacement_order_on_return",
      "userEmail": "blair.bennett@corvetasurgical.com",
      "userId": "17b8c9d0-e1f2-3456-1234-567890123456",
      "organizationName": "Vantis",
      "organizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "objectId": "019fc9e4-938a-74a3-bc58-89808805c221",
      "secondaryObjectId": null,
      "payload": {
        "reason": "manufacturer_setting_disabled",
        "performed": false,
        "entityType": "return"
      },
      "route": null,
      "traceId": null
    },
    {
      "createdAt": "2026-08-03T23:10:28.206Z",
      "eventType": "return_request",
      "action": "created",
      "userEmail": "blair.bennett@corvetasurgical.com",
      "userId": "17b8c9d0-e1f2-3456-1234-567890123456",
      "organizationName": "Vantis",
      "organizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "objectId": "019fc9e4-938a-74a3-bc58-89808805c221",
      "secondaryObjectId": null,
      "payload": {
        "itemCount": 6,
        "returnNumber": "RET-1",
        "salesOrganizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
        "manufacturerOrganizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
      },
      "route": null,
      "traceId": null
    },
    {
      "createdAt": "2026-08-03T23:10:29.497Z",
      "eventType": "transactional_email",
      "action": "return_submitted",
      "userEmail": null,
      "userId": null,
      "organizationName": "Corveta Surgical Group",
      "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "objectId": "019fc9e4-938a-74a3-bc58-89808805c221",
      "secondaryObjectId": null,
      "payload": {
        "to": [
          "blair.bennett@corvetasurgical.com"
        ],
        "s3Path": "email-audit/b2c3d4e5-f6a7-8901-bcde-f12345678901/019fc9e4-986e-731e-8c38-09cf14a31a41/",
        "subject": "Return Submitted - RET-1",
        "messageId": "dev-console-log",
        "attachmentFiles": [
          {
            "s3Key": "email-audit/b2c3d4e5-f6a7-8901-bcde-f12345678901/019fc9e4-986e-731e-8c38-09cf14a31a41/attachments/1-RET-1-return-form-2026-08-03.pdf",
            "filename": "RET-1-return-form-2026-08-03.pdf"
          }
        ],
        "relatedEntityType": "return"
      },
      "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": "Login",
      "expectedAction": "user_log:user:login",
      "found": true
    },
    {
      "stepName": "Submission success",
      "expectedAction": "return_request:created",
      "found": true
    }
  ],
  "emailAssertions": [],
  "videoPaths": [
    "/home/runner/_work/code/code/validation_test_results/urs-029-return-per-item-information/2026-08-03T23-09-29-893Z/videos/step-01-full-run.webm"
  ]
}