{
  "id": "ORD-GATE-006",
  "name": "Order create: REJECT 400 when the Quote has no AccountId",
  "description": "Regression for PR #1198 \u2014 the Accepted Quote has AccountId=NULL, so the gate cannot look up Account contracts. Must fail closed with the 'Quote has no Account' message, not the generic CSA/MA error.",
  "object": "Order",
  "method": "POST",
  "endpoint": "/services/data/v63.0/sobjects/Order",
  "setup": [
    {
      "type": "sql",
      "name": "Create a placeholder Account for the Order payload's required AccountId (seed PLG_BD_Pool__c so Order create can reach the Quote gate)",
      "sql": "INSERT INTO Account (Id, Name, PLG_BD_Pool__c, IsDeleted, SystemModstamp) VALUES (%s, %s, %s, %s, %s)",
      "params": [
        "ordgate6-acc-01",
        "ORD-GATE-006 Account (for Order payload only)",
        true,
        0,
        "{db_timestamp}"
      ]
    },
    {
      "type": "sql",
      "name": "Create Accepted Quote with AccountId=NULL",
      "sql": "INSERT INTO Quote (Id, Name, Status, AccountId, IsDeleted, SystemModstamp) VALUES (%s, %s, %s, %s, %s, %s)",
      "params": [
        "ordgate6-qte-01",
        "ORD-GATE-006 Quote",
        "Accepted",
        null,
        0,
        "{db_timestamp}"
      ]
    }
  ],
  "payload": {
    "QuoteId": "ordgate6-qte-01",
    "AccountId": "ordgate6-acc-01",
    "EffectiveDate": "2026-04-19",
    "Name": "ORD-GATE-006 Order",
    "Status": "Draft",
    "StatusCode": "Draft",
    "OwnerId": "0055g000001i4R9AAI",
    "PLG_BD_Pool__c": false,
    "TotalAmount": 0
  },
  "expects": {
    "status_code": 400
  },
  "case_timeout_seconds": 240,
  "response_assertions": [
    {
      "field": "0.message",
      "operator": "contains",
      "value": "Quote has no Account"
    }
  ],
  "teardown": [
    {
      "type": "sql",
      "sql": "DELETE FROM Quote WHERE Id = %s",
      "params": [
        "ordgate6-qte-01"
      ]
    },
    {
      "type": "sql",
      "sql": "DELETE FROM Account WHERE Id = %s",
      "params": [
        "ordgate6-acc-01"
      ]
    }
  ],
  "priority": "P1",
  "bug_ref": "#1198",
  "scene": "order"
}
