{
  "ursId": "URS-064",
  "title": "Bill-Only improvements: manufacturer, missing-PO label, PO upload, PO number",
  "timestamp": "2026-04-23T03:45:41.858Z",
  "durationMs": 63813,
  "config": {
    "inboxUrl": "http://localhost:49227",
    "dbHost": "localhost",
    "dbPort": 49228,
    "dbName": "cc_repinbox_dev"
  },
  "setup": {
    "status": "pass"
  },
  "scenarios": [
    {
      "name": "Step 1: Partner field visible on detail page",
      "status": "pass",
      "description": "Step 1: Partner field visible on detail page",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-064-bill-only-po-improvements/2026-04-23T03-45-41-856Z/screenshots/step-01-partner-field-on-detail-page.png"
      ],
      "explanation": "Confirms that the Bill-Only order detail page displays a \"Partner\" field identifying the manufacturer. Because every BO is tied to a single manufacturerOrganizationId, the field is always unambiguous — satisfying the URS-064 requirement to show the manufacturer when only one is available.",
      "startedAt": "2026-04-23T03:45:48.056Z",
      "finishedAt": "2026-04-23T03:45:48.056Z",
      "videoPath": "/Users/jason/projects/casecohort/code/validation_test_results/urs-064-bill-only-po-improvements/2026-04-23T03-45-41-856Z/videos/step-01-single-partner-on-detail-page.webm"
    },
    {
      "name": "Step 2: Manufacturer auto-populated on /billing/new",
      "status": "pass",
      "description": "Step 2: Manufacturer auto-populated on /billing/new",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-064-bill-only-po-improvements/2026-04-23T03-45-41-856Z/screenshots/step-02-manufacturer-select-prefilled.png"
      ],
      "explanation": "Confirms that the create flow (/billing/new) auto-selects the manufacturer in the \"Manufacturers\" dropdown when the user's organization has exactly one available manufacturer. The trigger shows the org name rather than the placeholder text, eliminating an unnecessary selection step for single-manufacturer users.",
      "startedAt": "2026-04-23T03:45:55.085Z",
      "finishedAt": "2026-04-23T03:45:55.085Z",
      "videoPath": "/Users/jason/projects/casecohort/code/validation_test_results/urs-064-bill-only-po-improvements/2026-04-23T03-45-41-856Z/videos/step-02-single-manufacturer-create-flow.webm"
    },
    {
      "name": "Step 3: BO before Change Status",
      "status": "pass",
      "description": "Step 3: BO before Change Status",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-064-bill-only-po-improvements/2026-04-23T03-45-41-856Z/screenshots/step-03-before-change-status.png"
      ],
      "explanation": "Baseline screenshot of the ZBO-2025-002 edit panel before any status transition, establishing the \"before\" state for the Missing-PO label workflow.",
      "startedAt": "2026-04-23T03:46:01.985Z",
      "finishedAt": "2026-04-23T03:46:01.985Z",
      "videoPath": "/Users/jason/projects/casecohort/code/validation_test_results/urs-064-bill-only-po-improvements/2026-04-23T03-45-41-856Z/videos/step-03-missing-po-label.webm"
    },
    {
      "name": "Step 3: Change Status dialog open",
      "status": "pass",
      "description": "Step 3: Change Status dialog open",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-064-bill-only-po-improvements/2026-04-23T03-45-41-856Z/screenshots/step-03-change-status-dialog.png"
      ],
      "explanation": "The \"Change Status\" dialog is open with the New Status field ready for selection. Confirms that manufacturer admins with billing:manage permission can access the status transition UI.",
      "startedAt": "2026-04-23T03:46:02.627Z",
      "finishedAt": "2026-04-23T03:46:02.627Z"
    },
    {
      "name": "Step 3: \"PO Missing\" badge on detail page",
      "status": "pass",
      "description": "Step 3: \"PO Missing\" badge on detail page",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-064-bill-only-po-improvements/2026-04-23T03-45-41-856Z/screenshots/step-03-detail-page-po-missing-badge.png"
      ],
      "explanation": "After transitioning ZBO-2025-002 to \"PO Missing\" via the dialog, the detail page displays the \"PO Missing\" badge. Proves the status transition persisted and the badge renders correctly.",
      "expectedAuditActions": [
        "decision:manual_status_change"
      ],
      "startedAt": "2026-04-23T03:46:07.580Z",
      "finishedAt": "2026-04-23T03:46:07.580Z"
    },
    {
      "name": "Step 3: BO shown under the PO Missing filter",
      "status": "pass",
      "description": "Step 3: BO shown under the PO Missing filter",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-064-bill-only-po-improvements/2026-04-23T03-45-41-856Z/screenshots/step-03-billing-list-po-missing-filter.png"
      ],
      "explanation": "The billing list filtered by \"po_missing\" shows ZBO-2025-002. Confirms the status is correctly indexed for filtering so users can find all orders awaiting a PO.",
      "startedAt": "2026-04-23T03:46:08.449Z",
      "finishedAt": "2026-04-23T03:46:08.449Z"
    },
    {
      "name": "Step 4: BO detail before opening Add PO dialog",
      "status": "pass",
      "description": "Step 4: BO detail before opening Add PO dialog",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-064-bill-only-po-improvements/2026-04-23T03-45-41-856Z/screenshots/step-04-before-opening-dialog.png"
      ],
      "explanation": "Baseline screenshot of the ZBO-2025-001 detail page before the PO upload, confirming the \"Purchase Order Documents\" section and \"Add PO\" button are present.",
      "startedAt": "2026-04-23T03:46:16.156Z",
      "finishedAt": "2026-04-23T03:46:16.156Z",
      "videoPath": "/Users/jason/projects/casecohort/code/validation_test_results/urs-064-bill-only-po-improvements/2026-04-23T03-45-41-856Z/videos/step-04-upload-po.webm"
    },
    {
      "name": "Step 4: Upload dialog open with file-picker",
      "status": "pass",
      "description": "Step 4: Upload dialog open with file-picker",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-064-bill-only-po-improvements/2026-04-23T03-45-41-856Z/screenshots/step-04-upload-dialog-open.png"
      ],
      "explanation": "The \"Add Purchase Order Documents\" dialog is open. The file picker drop-zone is visible and the \"Add Documents\" submit button is disabled until a file is selected and uploaded, enforcing a complete upload before submission.",
      "startedAt": "2026-04-23T03:46:16.797Z",
      "finishedAt": "2026-04-23T03:46:16.797Z"
    },
    {
      "name": "Step 4: PDF file selected in the upload dialog",
      "status": "pass",
      "description": "Step 4: PDF file selected in the upload dialog",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-064-bill-only-po-improvements/2026-04-23T03-45-41-856Z/screenshots/step-04-file-selected.png"
      ],
      "explanation": "The sample PO PDF has been selected and the filename appears inside the drop-zone, confirming the FileUploader accepted the file and began the three-step upload sequence (POST /api/form_uploads → PUT to MinIO → POST confirmation).",
      "startedAt": "2026-04-23T03:46:17.428Z",
      "finishedAt": "2026-04-23T03:46:17.428Z"
    },
    {
      "name": "Step 4: PO document attached to the BO",
      "status": "pass",
      "description": "Step 4: PO document attached to the BO",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-064-bill-only-po-improvements/2026-04-23T03-45-41-856Z/screenshots/step-04-po-attached.png"
      ],
      "explanation": "After submitting the dialog, the uploaded PDF filename appears in the \"Purchase Order Documents\" section on the detail page. Proves the full upload round-trip succeeded and a billing_order_files row was created with file_type=\"purchase_order\".",
      "expectedAuditActions": [
        "decision:bill_only_order.enqueue_manual_upload_classification"
      ],
      "startedAt": "2026-04-23T03:46:18.504Z",
      "finishedAt": "2026-04-23T03:46:18.504Z"
    },
    {
      "name": "Step 5: PO Number field in read mode",
      "status": "pass",
      "description": "Step 5: PO Number field in read mode",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-064-bill-only-po-improvements/2026-04-23T03-45-41-856Z/screenshots/step-05-before-edit-po-number.png"
      ],
      "explanation": "The \"PO Number\" row on the ZBO-2025-001 detail page is in read mode, showing \"Not set\" with an edit icon. Establishes the baseline state before manual entry.",
      "startedAt": "2026-04-23T03:46:26.284Z",
      "finishedAt": "2026-04-23T03:46:26.284Z",
      "videoPath": "/Users/jason/projects/casecohort/code/validation_test_results/urs-064-bill-only-po-improvements/2026-04-23T03-45-41-856Z/videos/step-05-manual-po-number.webm"
    },
    {
      "name": "Step 5: PO Number entered",
      "status": "pass",
      "description": "Step 5: PO Number entered",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-064-bill-only-po-improvements/2026-04-23T03-45-41-856Z/screenshots/step-05-po-number-filled.png"
      ],
      "explanation": "The PO Number inline editor is open and the test PO number has been typed into the input field, ready for submission.",
      "startedAt": "2026-04-23T03:46:27.397Z",
      "finishedAt": "2026-04-23T03:46:27.397Z"
    },
    {
      "name": "Step 5: PO Number saved",
      "status": "pass",
      "description": "Step 5: PO Number saved",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-064-bill-only-po-improvements/2026-04-23T03-45-41-856Z/screenshots/step-05-po-number-saved.png"
      ],
      "explanation": "After pressing Enter the form returns to read mode and displays the saved PO number. Proves the EditPoNumberForm persisted the value to the database.",
      "expectedAuditActions": [
        "decision:process_order_edit"
      ],
      "startedAt": "2026-04-23T03:46:28.091Z",
      "finishedAt": "2026-04-23T03:46:28.091Z"
    },
    {
      "name": "Step 6: PO number and document persist after reload",
      "status": "pass",
      "description": "Step 6: PO number and document persist after reload",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-064-bill-only-po-improvements/2026-04-23T03-45-41-856Z/screenshots/step-06-persistence-after-reload.png"
      ],
      "explanation": "After a hard-reload of the ZBO-2025-001 detail page, both the manually entered PO number and the uploaded PDF filename are still visible. Confirms that all data from Steps 4 and 5 was durably persisted in the database, not just held in client-side state.",
      "startedAt": "2026-04-23T03:46:35.614Z",
      "finishedAt": "2026-04-23T03:46:35.614Z",
      "videoPath": "/Users/jason/projects/casecohort/code/validation_test_results/urs-064-bill-only-po-improvements/2026-04-23T03-45-41-856Z/videos/step-06-persistence.webm"
    },
    {
      "name": "Step 7: Change Status button absent for user without billing:manage",
      "status": "pass",
      "description": "Step 7: Change Status button absent for user without billing:manage",
      "screenshots": [
        "/Users/jason/projects/casecohort/code/validation_test_results/urs-064-bill-only-po-improvements/2026-04-23T03-45-41-856Z/screenshots/step-07-change-status-button-absent.png"
      ],
      "explanation": "Negative permission check: logs in as Bob Kauffman (downgraded to the StellarTech Sales Rep role by setup.ts) and navigates to the same edit page where Step 3 exercised the Change Status dialog. The Sales Rep role grants `billing:view` (via the `bundle:sales_rep` implication) so he can load the order, but lacks `billing:manage`. The button is gated behind `canChangeStatus = hasManagePermission && isManufacturer` (apps/inbox/src/routes/billing/[orderId]/edit/queries.remote.ts:231), so the expected outcome is that no \"Change Status\" button appears in the DOM. This proves the UI enforces the permission gate and is not relying on the Change Status action alone (which also rejects on the server via `remoteGuard().anyPermission(['billing:manage'])`).",
      "startedAt": "2026-04-23T03:46:43.208Z",
      "finishedAt": "2026-04-23T03:46:43.208Z",
      "videoPath": "/Users/jason/projects/casecohort/code/validation_test_results/urs-064-bill-only-po-improvements/2026-04-23T03-45-41-856Z/videos/step-07-change-status-permission-gate.webm"
    }
  ],
  "dbValidations": [
    {
      "name": "ZBO-2025-002 is `po_missing` with po_number cleared after the Change Status step",
      "query": "\n  SELECT id, order_number, status, po_number\n    FROM billing_orders\n   WHERE id = $1",
      "status": "pass",
      "rows": [
        {
          "id": "ba000002-0000-4000-8000-000000000002",
          "order_number": "ZBO-2025-002",
          "status": "po_missing",
          "po_number": null
        }
      ],
      "assertion": "ZBO-2025-002.status must equal \"po_missing\" and .po_number must be NULL after the Change Status dialog transitions it (ChangeStatusDialog clears po_number as a side-effect of this status)."
    },
    {
      "name": "ZBO-2025-001 has po_number = \"PO-URS-064-TEST-001\" after the manual entry step",
      "query": "\n  SELECT id, order_number, status, po_number\n    FROM billing_orders\n   WHERE id = $1",
      "status": "pass",
      "rows": [
        {
          "id": "ba000001-0000-4000-8000-000000000001",
          "order_number": "ZBO-2025-001",
          "status": "draft",
          "po_number": "PO-URS-064-TEST-001"
        }
      ],
      "assertion": "ZBO-2025-001.po_number must equal the value typed into the EditPoNumberForm in Step 5."
    },
    {
      "name": "ZBO-2025-001 has a `billing_order_files` row with file_type=\"purchase_order\"",
      "query": "\n  SELECT id, billing_order_id, file_type, created_at\n    FROM billing_order_files\n   WHERE billing_order_id = $1\n     AND file_type = 'purchase_order'\n   ORDER BY created_at DESC",
      "status": "pass",
      "rows": [
        {
          "id": "019db872-17a6-7140-9d7a-5af952f839b7",
          "billing_order_id": "ba000001-0000-4000-8000-000000000001",
          "file_type": "purchase_order",
          "created_at": "2026-04-23T08:46:18.116Z"
        }
      ],
      "assertion": "ZBO-2025-001 must have at least one billing_order_files row with file_type=\"purchase_order\" after the Add PO dialog submits."
    }
  ],
  "overallStatus": "pass",
  "outputDir": "/Users/jason/projects/casecohort/code/validation_test_results/urs-064-bill-only-po-improvements/2026-04-23T03-45-41-856Z",
  "auditStartTime": "2026-04-23T03:45:39.935Z",
  "auditEventEvidence": [
    {
      "createdAt": "2026-04-23T03:45:44.019Z",
      "eventType": "user_log",
      "action": "user:login",
      "userEmail": "alex.admin@zurimed.com",
      "userId": "f6a7b8c9-d0e1-2345-f123-456789012345",
      "organizationName": "ZuriMED",
      "organizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "objectId": null,
      "secondaryObjectId": null,
      "payload": {
        "email": "alex.admin@zurimed.com"
      },
      "route": "/login",
      "traceId": "00000000000000000000000000000000"
    },
    {
      "createdAt": "2026-04-23T03:45:51.025Z",
      "eventType": "user_log",
      "action": "user:login",
      "userEmail": "alex.admin@zurimed.com",
      "userId": "f6a7b8c9-d0e1-2345-f123-456789012345",
      "organizationName": "ZuriMED",
      "organizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "objectId": null,
      "secondaryObjectId": null,
      "payload": {
        "email": "alex.admin@zurimed.com"
      },
      "route": "/login",
      "traceId": "00000000000000000000000000000000"
    },
    {
      "createdAt": "2026-04-23T03:45:58.090Z",
      "eventType": "user_log",
      "action": "user:login",
      "userEmail": "alex.admin@zurimed.com",
      "userId": "f6a7b8c9-d0e1-2345-f123-456789012345",
      "organizationName": "ZuriMED",
      "organizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "objectId": null,
      "secondaryObjectId": null,
      "payload": {
        "email": "alex.admin@zurimed.com"
      },
      "route": "/login",
      "traceId": "00000000000000000000000000000000"
    },
    {
      "createdAt": "2026-04-23T03:46:06.435Z",
      "eventType": "decision",
      "action": "manual_status_change",
      "userEmail": "alex.admin@zurimed.com",
      "userId": "f6a7b8c9-d0e1-2345-f123-456789012345",
      "organizationName": "ZuriMED",
      "organizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "objectId": "ba000002-0000-4000-8000-000000000002",
      "secondaryObjectId": null,
      "payload": {
        "reason": "Manual status change performed",
        "toStatus": "po_missing",
        "performed": true,
        "entityType": "billing_order",
        "fromStatus": "submitted"
      },
      "route": null,
      "traceId": null
    },
    {
      "createdAt": "2026-04-23T03:46:11.921Z",
      "eventType": "user_log",
      "action": "user:login",
      "userEmail": "alex.admin@zurimed.com",
      "userId": "f6a7b8c9-d0e1-2345-f123-456789012345",
      "organizationName": "ZuriMED",
      "organizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "objectId": null,
      "secondaryObjectId": null,
      "payload": {
        "email": "alex.admin@zurimed.com"
      },
      "route": "/login",
      "traceId": "00000000000000000000000000000000"
    },
    {
      "createdAt": "2026-04-23T03:46:18.116Z",
      "eventType": "decision",
      "action": "bill_only_order.enqueue_manual_upload_classification",
      "userEmail": "alex.admin@zurimed.com",
      "userId": "f6a7b8c9-d0e1-2345-f123-456789012345",
      "organizationName": "ZuriMED",
      "organizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "objectId": "ba000001-0000-4000-8000-000000000001",
      "secondaryObjectId": null,
      "payload": {
        "reason": "Purchase order documents were uploaded manually.",
        "fileType": "purchase_order",
        "performed": true,
        "entityType": "billing_order",
        "fileUploadCount": 1,
        "fileSourceOrganizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
      },
      "route": null,
      "traceId": null
    },
    {
      "createdAt": "2026-04-23T03:46:22.553Z",
      "eventType": "user_log",
      "action": "user:login",
      "userEmail": "alex.admin@zurimed.com",
      "userId": "f6a7b8c9-d0e1-2345-f123-456789012345",
      "organizationName": "ZuriMED",
      "organizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "objectId": null,
      "secondaryObjectId": null,
      "payload": {
        "email": "alex.admin@zurimed.com"
      },
      "route": "/login",
      "traceId": "00000000000000000000000000000000"
    },
    {
      "createdAt": "2026-04-23T03:46:29.875Z",
      "eventType": "decision",
      "action": "process_order_edit",
      "userEmail": null,
      "userId": null,
      "organizationName": "StellarTech Medical Solutions",
      "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "objectId": "ba000001-0000-4000-8000-000000000001",
      "secondaryObjectId": null,
      "payload": {
        "reason": "Not first PO link - user can send manually",
        "performed": false,
        "entityType": "billing_order",
        "salesOrganizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
        "manufacturerOrganizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
      },
      "route": null,
      "traceId": null
    },
    {
      "createdAt": "2026-04-23T03:46:31.155Z",
      "eventType": "user_log",
      "action": "user:login",
      "userEmail": "alex.admin@zurimed.com",
      "userId": "f6a7b8c9-d0e1-2345-f123-456789012345",
      "organizationName": "ZuriMED",
      "organizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "objectId": null,
      "secondaryObjectId": null,
      "payload": {
        "email": "alex.admin@zurimed.com"
      },
      "route": "/login",
      "traceId": "00000000000000000000000000000000"
    },
    {
      "createdAt": "2026-04-23T03:46:39.018Z",
      "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 3: \"PO Missing\" badge on detail page",
      "expectedAction": "decision:manual_status_change",
      "found": true
    },
    {
      "stepName": "Step 4: PO document attached to the BO",
      "expectedAction": "decision:bill_only_order.enqueue_manual_upload_classification",
      "found": true
    },
    {
      "stepName": "Step 5: PO Number saved",
      "expectedAction": "decision:process_order_edit",
      "found": true
    }
  ],
  "emailAssertions": [],
  "inputFiles": [
    {
      "name": "Sample Purchase Order (PO) Document",
      "description": "A sample PDF purchase order uploaded in Step 4 to demonstrate the \"Add PO\" dialog. This file is attached to the bill-only order during the test, creating a billing_order_files row with file_type=\"purchase_order\".",
      "path": "/Users/jason/projects/casecohort/code/testing/validations/urs-064-bill-only-po-improvements/fixtures/urs-064-sample-po.pdf"
    }
  ]
}