{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "CustomerOrder",
  "description": "Schema for customer order data in Bakery-IA system",
  "type": "object",
  "required": [
    "id",
    "tenant_id",
    "customer_id",
    "order_number",
    "order_date",
    "delivery_date",
    "status",
    "total_amount",
    "created_at"
  ],
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid",
      "description": "Unique identifier for the customer order"
    },
    "tenant_id": {
      "type": "string",
      "format": "uuid",
      "description": "Tenant identifier"
    },
    "customer_id": {
      "type": "string",
      "format": "uuid",
      "description": "Customer identifier"
    },
    "order_number": {
      "type": "string",
      "minLength": 1,
      "maxLength": 50,
      "description": "Order number"
    },
    "order_date": {
      "type": "string",
      "format": "date-time",
      "description": "Order date"
    },
    "delivery_date": {
      "type": "string",
      "format": "date-time",
      "description": "Delivery date"
    },
    "status": {
      "type": "string",
      "enum": ["DRAFT", "PENDING", "PROCESSING", "DELIVERED", "CANCELLED", "REJECTED"],
      "description": "Order status"
    },
    "total_amount": {
      "type": "number",
      "minimum": 0,
      "description": "Total order amount in EUR"
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "description": "Creation timestamp"
    },
    "notes": {
      "type": "string",
      "description": "Additional notes"
    },
    "is_urgent": {
      "type": "boolean",
      "description": "Urgent order flag"
    },
    "enterprise_order": {
      "type": "boolean",
      "description": "Enterprise-level order"
    },
    "contract_reference": {
      "type": "string",
      "description": "Contract reference"
    },
    "delivery_locations": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "location": {
            "type": "string"
          },
          "quantity": {
            "type": "number",
            "minimum": 0
          },
          "delivery_time": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "description": "Delivery locations"
    },
    "reasoning_data": {
      "type": "object",
      "description": "Reasoning data for urgent orders",
      "properties": {
        "type": {
          "type": "string",
          "description": "Reasoning type"
        },
        "parameters": {
          "type": "object",
          "description": "Reasoning parameters"
        }
      }
    }
  },
  "additionalProperties": false
}