{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Supplier",
  "description": "Schema for supplier data in Bakery-IA system",
  "type": "object",
  "required": [
    "id",
    "tenant_id",
    "name",
    "supplier_code",
    "business_name",
    "tax_id",
    "contact_person",
    "email",
    "phone",
    "address",
    "city",
    "postal_code",
    "country",
    "status",
    "rating",
    "payment_terms",
    "minimum_order_amount",
    "lead_time_days",
    "contract_start_date",
    "contract_end_date",
    "created_at"
  ],
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid",
      "description": "Unique identifier for the supplier"
    },
    "tenant_id": {
      "type": "string",
      "format": "uuid",
      "description": "Tenant identifier"
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 100,
      "description": "Supplier name"
    },
    "supplier_code": {
      "type": "string",
      "minLength": 1,
      "maxLength": 50,
      "description": "Supplier code"
    },
    "business_name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 100,
      "description": "Legal business name"
    },
    "tax_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 20,
      "description": "Tax identification number"
    },
    "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": "Supplier status"
    },
    "rating": {
      "type": "number",
      "minimum": 0,
      "maximum": 5,
      "description": "Supplier rating (0-5)"
    },
    "payment_terms": {
      "type": "string",
      "enum": ["7_DAYS", "15_DAYS", "30_DAYS", "60_DAYS", "90_DAYS"],
      "description": "Payment terms"
    },
    "minimum_order_amount": {
      "type": "number",
      "minimum": 0,
      "description": "Minimum order amount in EUR"
    },
    "lead_time_days": {
      "type": "integer",
      "minimum": 0,
      "description": "Lead time in days"
    },
    "contract_start_date": {
      "type": "string",
      "format": "date-time",
      "description": "Contract start date"
    },
    "contract_end_date": {
      "type": "string",
      "format": "date-time",
      "description": "Contract end date"
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "description": "Creation timestamp"
    },
    "specialties": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Product specialties"
    },
    "delivery_areas": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Delivery areas"
    },
    "enterprise_contract": {
      "type": "boolean",
      "description": "Enterprise-level contract"
    },
    "contract_type": {
      "type": "string",
      "description": "Type of contract"
    },
    "annual_volume_commitment": {
      "type": "number",
      "minimum": 0,
      "description": "Annual volume commitment"
    },
    "preferred_supplier": {
      "type": "boolean",
      "description": "Preferred supplier status"
    },
    "organic_certified": {
      "type": "boolean",
      "description": "Organic certification"
    }
  },
  "additionalProperties": false
}