{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openeik.org/schemas/0.6/costSchedules/rates.schema.json",
  "$comment": "OpenEik 0.6: folded by tools/fold-schemas-0.6.mjs from the proposal costSchedules, which 0.6 makes a rule (open questions, 151). Written by hand, not generated.",
  "title": "A rate list",
  "description": "A project's own rates (Part XXII, 4.2), by which a reader prices a cost schedule: each rate a sum of money per unit of an item's quantity, for one item of one schedule or for every item that carries a code, in the list's currency. Never part of a model (Part XXII, 4.1).",
  "type": "object",
  "properties": {
    "format": {
      "const": "openeik-rates/0.1"
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200,
      "description": "What the list is, for people: nothing is decided by it."
    },
    "currency": {
      "type": "string",
      "pattern": "^[A-Z]{3}$",
      "description": "The currency every rate is in, by its code of ISO 4217 (EUR, SEK, GBP …)."
    },
    "rates": {
      "type": "array",
      "minItems": 1,
      "maxItems": 100000,
      "items": {
        "$ref": "#/$defs/rate"
      }
    }
  },
  "required": [
    "format",
    "currency",
    "rates"
  ],
  "x-eik-closed": true,
  "$defs": {
    "rate": {
      "type": "object",
      "properties": {
        "rate": {
          "type": "number",
          "minimum": 0,
          "maximum": 1000000000000,
          "description": "The sum of money per unit of the item's quantity, in the list's currency: never rounded by a reader."
        },
        "unit": {
          "enum": [
            "m",
            "m2",
            "m3",
            "kg",
            "count"
          ],
          "description": "The unit the rate is per: a unit of Part XXI, 2, rule 2. Required with code; with item, the item's quantity must be in it."
        },
        "schedule": {
          "type": "string",
          "minLength": 1,
          "maxLength": 80,
          "description": "The cost schedule of the item the rate prices, by its id."
        },
        "item": {
          "type": "string",
          "minLength": 1,
          "maxLength": 80,
          "description": "The item of that schedule the rate prices, by its id."
        },
        "code": {
          "type": "object",
          "properties": {
            "system": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "code": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100
            },
            "edition": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100
            }
          },
          "required": [
            "system",
            "code"
          ],
          "x-eik-closed": true,
          "description": "A code: the rate prices every item that carries a classification reference of this system and code (and edition, where the code gives one) and whose quantity is in its unit."
        },
        "note": {
          "type": "string",
          "minLength": 1,
          "maxLength": 1000,
          "description": "A note, for people."
        }
      },
      "required": [
        "rate"
      ],
      "oneOf": [
        {
          "required": [
            "schedule",
            "item"
          ],
          "not": {
            "required": [
              "code"
            ]
          }
        },
        {
          "required": [
            "code",
            "unit"
          ],
          "not": {
            "anyOf": [
              {
                "required": [
                  "schedule"
                ]
              },
              {
                "required": [
                  "item"
                ]
              }
            ]
          }
        }
      ],
      "x-eik-closed": true
    }
  }
}
