{
  "ursId": "URS-075",
  "title": "Per-account product availability via enablement flag",
  "timestamp": "2026-08-03T23:05:41.140Z",
  "durationMs": 100386,
  "config": {
    "inboxUrl": "http://localhost:37051",
    "dbHost": "localhost",
    "dbPort": 40461,
    "dbName": "cc_repinbox_dev"
  },
  "setup": {
    "status": "pass"
  },
  "scenarios": [
    {
      "name": "Step 1: Disabled by default",
      "status": "pass",
      "description": "Step 1: Disabled by default",
      "screenshots": [
        "/home/runner/_work/code/code/validation_test_results/urs-075-account-product-enablement/2026-08-03T23-05-41-140Z/screenshots/step-01-product-settings.png",
        "/home/runner/_work/code/code/validation_test_results/urs-075-account-product-enablement/2026-08-03T23-05-41-140Z/screenshots/step-01-disabled-on-account.png",
        "/home/runner/_work/code/code/validation_test_results/urs-075-account-product-enablement/2026-08-03T23-05-41-140Z/screenshots/step-01-product-absent-from-picker.png"
      ],
      "explanation": "Documents that LL516RE (LiraLock® RE Series) is configured with requires_account_enablement=true on its catalog entry, and that its pricing row on the ROSS account starts with enabled=false. The product is absent from the bill-only product picker while disabled, proving that the enablement gate is active.",
      "startedAt": "2026-08-03T23:05:47.520Z",
      "finishedAt": "2026-08-03T23:06:06.292Z",
      "videoPath": "/home/runner/_work/code/code/validation_test_results/urs-075-account-product-enablement/2026-08-03T23-05-41-140Z/videos/step-01-absent-from-picker.webm"
    },
    {
      "name": "Step 2: Standard product baseline",
      "status": "pass",
      "description": "Step 2: Standard product baseline",
      "screenshots": [
        "/home/runner/_work/code/code/validation_test_results/urs-075-account-product-enablement/2026-08-03T23-05-41-140Z/screenshots/step-02-standard-products-in-picker.png"
      ],
      "explanation": "Shows that standard products (requires_account_enablement=false, e.g. IK2025LL) appear in the bill-only product picker without any explicit enable action. This proves that the enabled=true default is intact for products that do not require per-account enablement.",
      "startedAt": "2026-08-03T23:06:22.306Z",
      "finishedAt": "2026-08-03T23:06:22.306Z",
      "videoPath": "/home/runner/_work/code/code/validation_test_results/urs-075-account-product-enablement/2026-08-03T23-05-41-140Z/videos/step-02-standard-product-baseline.webm"
    },
    {
      "name": "Step 3: Enable product",
      "status": "pass",
      "description": "Step 3: Enable product",
      "screenshots": [
        "/home/runner/_work/code/code/validation_test_results/urs-075-account-product-enablement/2026-08-03T23-05-41-140Z/screenshots/step-03-before-enable.png",
        "/home/runner/_work/code/code/validation_test_results/urs-075-account-product-enablement/2026-08-03T23-05-41-140Z/screenshots/step-03-after-enable.png"
      ],
      "explanation": "An administrator enables LL516RE on the ROSS account using the pricing page toggle. The pricing row flips to enabled=true immediately. The database check in Phase 3 confirms the toggle persisted correctly.",
      "startedAt": "2026-08-03T23:06:28.419Z",
      "finishedAt": "2026-08-03T23:06:31.712Z",
      "videoPath": "/home/runner/_work/code/code/validation_test_results/urs-075-account-product-enablement/2026-08-03T23-05-41-140Z/videos/step-03-enable-product.webm"
    },
    {
      "name": "Step 4: Bill enabled product",
      "status": "pass",
      "description": "Step 4: Bill enabled product",
      "screenshots": [
        "/home/runner/_work/code/code/validation_test_results/urs-075-account-product-enablement/2026-08-03T23-05-41-140Z/screenshots/step-04-product-in-picker.png",
        "/home/runner/_work/code/code/validation_test_results/urs-075-account-product-enablement/2026-08-03T23-05-41-140Z/screenshots/step-04-product-selected.png",
        "/home/runner/_work/code/code/validation_test_results/urs-075-account-product-enablement/2026-08-03T23-05-41-140Z/screenshots/step-04-review.png",
        "/home/runner/_work/code/code/validation_test_results/urs-075-account-product-enablement/2026-08-03T23-05-41-140Z/screenshots/step-04-submitted.png"
      ],
      "explanation": "After being enabled, LL516RE appears in the bill-only product picker and a bill-only order is submitted successfully. The billing order item records the stored approved price, proving that the product is fully billable once enabled.",
      "startedAt": "2026-08-03T23:06:47.703Z",
      "finishedAt": "2026-08-03T23:06:53.768Z",
      "videoPath": "/home/runner/_work/code/code/validation_test_results/urs-075-account-product-enablement/2026-08-03T23-05-41-140Z/videos/step-04-bill-enabled-product.webm"
    },
    {
      "name": "Step 5: Disable product",
      "status": "pass",
      "description": "Step 5: Disable product",
      "screenshots": [
        "/home/runner/_work/code/code/validation_test_results/urs-075-account-product-enablement/2026-08-03T23-05-41-140Z/screenshots/step-05-before-disable.png",
        "/home/runner/_work/code/code/validation_test_results/urs-075-account-product-enablement/2026-08-03T23-05-41-140Z/screenshots/step-05-after-disable.png",
        "/home/runner/_work/code/code/validation_test_results/urs-075-account-product-enablement/2026-08-03T23-05-41-140Z/screenshots/step-05-product-absent-after-disable.png"
      ],
      "explanation": "An administrator disables LL516RE on the ROSS account using the same toggle. The pricing row flips to enabled=false immediately. LL516RE disappears from the bill-only product picker, proving that the gate can be re-activated after enablement.",
      "startedAt": "2026-08-03T23:06:59.808Z",
      "finishedAt": "2026-08-03T23:07:19.985Z",
      "videoPath": "/home/runner/_work/code/code/validation_test_results/urs-075-account-product-enablement/2026-08-03T23-05-41-140Z/videos/step-05-absent-after-disable.webm"
    }
  ],
  "dbValidations": [
    {
      "name": "LL516RE catalog entry has requires_account_enablement=true",
      "query": "SELECT p.sku, p.active AS product_active,\n            pci.requires_account_enablement, pci.allow_billing, pci.active AS catalog_active\n     FROM org_products p\n     JOIN product_catalog_items pci ON pci.product_id = p.id AND pci.active = true\n     WHERE p.id = $1 AND p.active = true",
      "status": "pass",
      "rows": [
        {
          "sku": "LL516RE",
          "product_active": true,
          "requires_account_enablement": true,
          "allow_billing": true,
          "catalog_active": true
        }
      ],
      "assertion": "LL516RE has requires_account_enablement=true and allow_billing=true"
    },
    {
      "name": "LL516RE has an active pricing row on ROSS",
      "query": "SELECT id, price, status, active, enabled\n     FROM sales_account_approved_pricing\n     WHERE org_product_id = $1 AND sales_account_id = $2 AND active = true",
      "status": "pass",
      "rows": [
        {
          "id": "019fc9e1-6792-7187-844f-2aee65e31cff",
          "price": "750.00",
          "status": "effective",
          "active": true,
          "enabled": false
        }
      ],
      "assertion": "LL516RE pricing row exists on ROSS with status=effective"
    },
    {
      "name": "Bill-only order was created for LL516RE while it was enabled",
      "query": "SELECT bo.id, boi.unit_price, bo.status\n     FROM billing_orders bo\n     JOIN billing_order_items boi ON boi.billing_order_id = bo.id\n     WHERE boi.product_id = $1 AND bo.notes LIKE $2",
      "status": "pass",
      "rows": [
        {
          "id": "019fc9e1-4469-7fa1-a203-f8aa46a4cfc8",
          "unit_price": "750.00",
          "status": "submitted"
        }
      ],
      "assertion": "At least one billing order item for LL516RE exists with a positive unit_price"
    },
    {
      "name": "LL516RE active pricing row on ROSS is enabled=false after re-disabling via the UI",
      "query": "SELECT enabled FROM sales_account_approved_pricing\n     WHERE org_product_id = $1 AND sales_account_id = $2 AND active = true",
      "status": "pass",
      "rows": [
        {
          "enabled": false
        }
      ],
      "assertion": "enabled=false (the UI disable toggle set it; billing is now blocked)"
    }
  ],
  "overallStatus": "pass",
  "outputDir": "/home/runner/_work/code/code/validation_test_results/urs-075-account-product-enablement/2026-08-03T23-05-41-140Z",
  "auditStartTime": "2026-08-03T23:05:39.172Z",
  "auditEventEvidence": [
    {
      "createdAt": "2026-08-03T23:05:40.308Z",
      "eventType": "checklist",
      "action": "checklists.create",
      "userEmail": null,
      "userId": null,
      "organizationName": "Corveta Surgical Group",
      "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "objectId": "019fc9e0-2ed6-7f93-8a08-ee93f35193b9",
      "secondaryObjectId": null,
      "payload": {
        "title": "Lot expiration review (1 location need attention)",
        "source": {
          "type": "lot_expiration",
          "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901"
        }
      },
      "route": null,
      "traceId": null
    },
    {
      "createdAt": "2026-08-03T23:05:40.417Z",
      "eventType": "decision",
      "action": "ensure_lot_expiration_checklist",
      "userEmail": null,
      "userId": null,
      "organizationName": "Corveta Surgical Group",
      "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "objectId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "secondaryObjectId": null,
      "payload": {
        "reason": "created_1_reopened_0_already_open_1",
        "performed": true,
        "entityType": "organization"
      },
      "route": null,
      "traceId": null
    },
    {
      "createdAt": "2026-08-03T23:05:44.430Z",
      "eventType": "user_log",
      "action": "user:login",
      "userEmail": "alex.admin@vantismedical.com",
      "userId": "f6a7b8c9-d0e1-2345-f123-456789012345",
      "organizationName": "Vantis",
      "organizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "objectId": null,
      "secondaryObjectId": null,
      "payload": {
        "email": "alex.admin@vantismedical.com"
      },
      "route": "/login",
      "traceId": "00000000000000000000000000000000"
    },
    {
      "createdAt": "2026-08-03T23:05:52.723Z",
      "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:06:09.275Z",
      "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:06:25.215Z",
      "eventType": "user_log",
      "action": "user:login",
      "userEmail": "alex.admin@vantismedical.com",
      "userId": "f6a7b8c9-d0e1-2345-f123-456789012345",
      "organizationName": "Vantis",
      "organizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "objectId": null,
      "secondaryObjectId": null,
      "payload": {
        "email": "alex.admin@vantismedical.com"
      },
      "route": "/login",
      "traceId": "00000000000000000000000000000000"
    },
    {
      "createdAt": "2026-08-03T23:06:34.636Z",
      "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:06:51.328Z",
      "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": "019fc9e1-4469-7fa1-a203-f8aa46a4cfc8",
      "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:06:51.328Z",
      "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": "019fc9e1-4469-7fa1-a203-f8aa46a4cfc8",
      "secondaryObjectId": null,
      "payload": {
        "reason": "inventory_items_decremented",
        "itemCount": 1,
        "performed": true,
        "entityType": "billing_order",
        "inventorySource": "inventory_items"
      },
      "route": null,
      "traceId": null
    },
    {
      "createdAt": "2026-08-03T23:06:51.328Z",
      "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": "019fc9e1-4469-7fa1-a203-f8aa46a4cfc8",
      "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:06:51.328Z",
      "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": "019fc9e1-4469-7fa1-a203-f8aa46a4cfc8",
      "secondaryObjectId": null,
      "payload": {
        "reason": null,
        "toStatus": "submitted",
        "fromStatus": null,
        "automatedAction": false
      },
      "route": null,
      "traceId": null
    },
    {
      "createdAt": "2026-08-03T23:06:52.922Z",
      "eventType": "transactional_email",
      "action": "new_bill_only",
      "userEmail": null,
      "userId": null,
      "organizationName": "Corveta Surgical Group",
      "organizationId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "objectId": "019fc9e1-4469-7fa1-a203-f8aa46a4cfc8",
      "secondaryObjectId": null,
      "payload": {
        "to": [
          "blair.bennett@corvetasurgical.com"
        ],
        "s3Path": "email-audit/b2c3d4e5-f6a7-8901-bcde-f12345678901/019fc9e1-4a6b-7ee3-9d34-288e25ce148f/",
        "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:06:56.629Z",
      "eventType": "user_log",
      "action": "user:login",
      "userEmail": "alex.admin@vantismedical.com",
      "userId": "f6a7b8c9-d0e1-2345-f123-456789012345",
      "organizationName": "Vantis",
      "organizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "objectId": null,
      "secondaryObjectId": null,
      "payload": {
        "email": "alex.admin@vantismedical.com"
      },
      "route": "/login",
      "traceId": "00000000000000000000000000000000"
    },
    {
      "createdAt": "2026-08-03T23:07:05.947Z",
      "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"
    }
  ],
  "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": [],
  "emailAssertions": [],
  "videoPaths": [
    "/home/runner/_work/code/code/validation_test_results/urs-075-account-product-enablement/2026-08-03T23-05-41-140Z/videos/step-01-disabled-by-default.webm",
    "/home/runner/_work/code/code/validation_test_results/urs-075-account-product-enablement/2026-08-03T23-05-41-140Z/videos/step-05-disable-product.webm"
  ]
}