{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/amberai/main/json-schema/amberai-order-detail-schema.json",
  "title": "OrderDetail",
  "x-generated": "2026-10-05",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/amberai-openapi.json#/components/schemas/OrderDetail",
  "type": "object",
  "properties": {
    "details": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "code": {
          "type": "string"
        },
        "externalOrderCode": {
          "type": [
            "string",
            "null"
          ]
        },
        "supplierId": {
          "type": "string"
        },
        "status": {
          "type": "string"
        },
        "orderPlacedDate": {
          "type": [
            "string",
            "null"
          ]
        },
        "targetExFactoryDate": {
          "type": [
            "string",
            "null"
          ]
        },
        "agreedExFactoryDate": {
          "type": [
            "string",
            "null"
          ]
        },
        "revisedExFactoryDate": {
          "type": [
            "string",
            "null"
          ]
        },
        "actualExFactoryDate": {
          "type": [
            "string",
            "null"
          ]
        },
        "targetDeliveryDate": {
          "type": [
            "string",
            "null"
          ]
        },
        "agreedDeliveryDate": {
          "type": [
            "string",
            "null"
          ]
        },
        "needByDate": {
          "type": [
            "string",
            "null"
          ]
        },
        "currency": {
          "type": [
            "string",
            "null"
          ]
        },
        "orderType": {
          "type": "string"
        },
        "priority": {
          "type": "string"
        },
        "deliveryTerms": {
          "type": [
            "string",
            "null"
          ]
        },
        "countryOfOriginCode": {
          "type": [
            "string",
            "null"
          ]
        },
        "brandOwnerId": {
          "type": [
            "string",
            "null"
          ]
        },
        "paymentTermsId": {
          "type": [
            "string",
            "null"
          ]
        },
        "notes": {
          "anyOf": [
            {
              "$ref": "#/$defs/__schema0"
            },
            {
              "type": "null"
            }
          ]
        },
        "memo": {
          "type": [
            "string",
            "null"
          ]
        },
        "customFields": {
          "anyOf": [
            {
              "$ref": "#/$defs/__schema1"
            },
            {
              "type": "null"
            }
          ]
        },
        "lastActivityAt": {
          "type": [
            "string",
            "null"
          ]
        },
        "subtotalAmount": {
          "type": [
            "string",
            "null"
          ]
        },
        "dutyAmount": {
          "type": [
            "string",
            "null"
          ]
        },
        "dutySource": {
          "type": [
            "string",
            "null"
          ]
        },
        "freightCharges": {
          "type": [
            "string",
            "null"
          ]
        },
        "otherCosts": {
          "type": [
            "string",
            "null"
          ]
        },
        "totalAmount": {
          "type": [
            "string",
            "null"
          ]
        },
        "exchangeRate": {
          "type": [
            "string",
            "null"
          ]
        },
        "subtotalAmountBase": {
          "type": [
            "string",
            "null"
          ]
        },
        "dutyAmountBase": {
          "type": [
            "string",
            "null"
          ]
        },
        "freightChargesBase": {
          "type": [
            "string",
            "null"
          ]
        },
        "otherCostsBase": {
          "type": [
            "string",
            "null"
          ]
        },
        "totalAmountBase": {
          "type": [
            "string",
            "null"
          ]
        },
        "quoteId": {
          "type": [
            "string",
            "null"
          ]
        },
        "locationId": {
          "type": [
            "string",
            "null"
          ]
        },
        "createdAt": {
          "type": "string"
        },
        "updatedAt": {
          "type": "string"
        },
        "deletedAt": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "id",
        "code",
        "externalOrderCode",
        "supplierId",
        "status",
        "orderPlacedDate",
        "targetExFactoryDate",
        "agreedExFactoryDate",
        "revisedExFactoryDate",
        "actualExFactoryDate",
        "targetDeliveryDate",
        "agreedDeliveryDate",
        "needByDate",
        "currency",
        "orderType",
        "priority",
        "deliveryTerms",
        "countryOfOriginCode",
        "brandOwnerId",
        "paymentTermsId",
        "notes",
        "memo",
        "customFields",
        "lastActivityAt",
        "subtotalAmount",
        "dutyAmount",
        "dutySource",
        "freightCharges",
        "otherCosts",
        "totalAmount",
        "exchangeRate",
        "subtotalAmountBase",
        "dutyAmountBase",
        "freightChargesBase",
        "otherCostsBase",
        "totalAmountBase",
        "quoteId",
        "locationId",
        "createdAt",
        "updatedAt",
        "deletedAt"
      ],
      "additionalProperties": false
    },
    "id": {
      "type": "string"
    },
    "orderNumber": {
      "type": "string"
    },
    "status": {
      "type": "string"
    },
    "supplier": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "name"
      ],
      "additionalProperties": false
    },
    "lineItems": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "skuId": {
            "type": [
              "string",
              "null"
            ]
          },
          "productVersionId": {
            "type": [
              "string",
              "null"
            ]
          },
          "productCode": {
            "type": "string"
          },
          "productName": {
            "type": "string"
          },
          "quantity": {
            "type": [
              "number",
              "null"
            ]
          },
          "unitPrice": {
            "type": [
              "number",
              "null"
            ]
          }
        },
        "required": [
          "productCode",
          "productName",
          "quantity",
          "unitPrice"
        ],
        "additionalProperties": false
      }
    },
    "totalAmount": {
      "type": [
        "number",
        "null"
      ]
    },
    "currency": {
      "type": "string"
    },
    "createdAt": {
      "type": "string"
    },
    "updatedAt": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "orderNumber",
    "status",
    "supplier",
    "lineItems",
    "totalAmount",
    "currency",
    "createdAt",
    "updatedAt"
  ],
  "additionalProperties": false,
  "$defs": {
    "__schema0": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "number"
        },
        {
          "type": "boolean"
        },
        {
          "type": "null"
        },
        {
          "type": "array",
          "items": {
            "$ref": "#/$defs/__schema0"
          }
        },
        {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {
            "$ref": "#/$defs/__schema0"
          }
        }
      ]
    },
    "__schema1": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "number"
        },
        {
          "type": "boolean"
        },
        {
          "type": "null"
        },
        {
          "type": "array",
          "items": {
            "$ref": "#/$defs/__schema1"
          }
        },
        {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {
            "$ref": "#/$defs/__schema1"
          }
        }
      ]
    }
  }
}