{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Customer",
  "description": "Schema for customer data in Bakery-IA system",
  "type": "object",
  "required": [
    "id",
    "tenant_id",
    "customer_code",
    "name",
    "customer_type",
    "contact_person",
    "email",
    "phone",
    "address",
    "city",
    "postal_code",
    "country",
    "status",
    "created_at"
  ],
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid",
      "description": "Unique identifier for the customer"
    },
    "tenant_id": {
      "type": "string",
      "format": "uuid",
      "description": "Tenant identifier"
    },
    "customer_code": {
      "type": "string",
      "minLength": 1,
      "maxLength": 50,
      "description": "Customer code"
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 100,
      "description": "Customer name"
    },
    "customer_type": {
      "type": "string",
      "enum": ["RETAIL", "WHOLESALE", "ENTERPRISE", "ONLINE"],
      "description": "Customer type"
    },
    "contact_person": {
      "type": "string",
      "minLength": 1,
      "maxLength": 100,
      "description": "Primary contact person"
    },
    "email": {
      "type": "string",
      "format": "email",
      "description": "Contact email"
    },
    "phone": {
      "type": "string",
      "minLength": 1,
      "maxLength": 20,
      "description": "Contact phone number"
    },
    "address": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200,
      "description": "Street address"
    },
    "city": {
      "type": "string",
      "minLength": 1,
      "maxLength": 50,
      "description": "City"
    },
    "postal_code": {
      "type": "string",
      "minLength": 1,
      "maxLength": 10,
      "description": "Postal code"
    },
    "country": {
      "type": "string",
      "minLength": 1,
      "maxLength": 50,
      "description": "Country"
    },
    "status": {
      "type": "string",
      "enum": ["ACTIVE", "INACTIVE", "PENDING", "SUSPENDED"],
      "description": "Customer status"
    },
    "total_orders": {
      "type": "integer",
      "minimum": 0,
      "description": "Total orders placed"
    },
    "total_spent": {
      "type": "number",
      "minimum": 0,
      "description": "Total amount spent in EUR"
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "description": "Creation timestamp"
    },
    "notes": {
      "type": "string",
      "description": "Additional notes"
    },
    "enterprise_customer": {
      "type": "boolean",
      "description": "Enterprise-level customer"
    },
    "contract_type": {
      "type": "string",
      "description": "Contract type"
    },
    "annual_volume_commitment": {
      "type": "number",
      "minimum": 0,
      "description": "Annual volume commitment"
    },
    "delivery_locations": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Delivery locations"
    }
  },
  "additionalProperties": false
}