{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openeik.org/schemas/0.6/project/cost-schedules.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": "project/cost-schedules.json",
  "description": "A project's cost schedules (Part XXII, 3: each a list of cost items, what is priced and how much of it, each item's quantity a quantity of Part XXI summed over a selection of elements or stated by hand, and its codes classification references of systems OpenEik does not list. No price, rate or sum of money: those are a project's own, kept apart (Part XXII, 4).",
  "type": "object",
  "properties": {
    "costSchedules": {
      "type": "array",
      "minItems": 1,
      "maxItems": 100,
      "items": {
        "$ref": "#/$defs/schedule"
      },
      "description": "The cost schedules, in the order people read them."
    }
  },
  "required": [
    "costSchedules"
  ],
  "x-eik-closed": true,
  "$defs": {
    "id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 80,
      "pattern": "^[^/\\s]+$",
      "description": "An id: a schedule's unique among the schedules, an item's among its schedule's items (Part XXII, 3.1, rule 3)."
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200,
      "description": "A name, for people: nothing is decided by it."
    },
    "schedule": {
      "type": "object",
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "name": {
          "$ref": "#/$defs/name"
        },
        "kind": {
          "enum": [
            "budget",
            "costPlan",
            "estimate",
            "tender",
            "billOfQuantities"
          ],
          "description": "What the schedule is for (Part XXII, 3.2, rule 2), as IFC's IfcCostScheduleTypeEnum names it."
        },
        "items": {
          "type": "array",
          "minItems": 1,
          "maxItems": 10000,
          "items": {
            "$ref": "#/$defs/item"
          },
          "description": "Its cost items, in the order people read them (Part XXII, 3.3); absent while it has none."
        },
        "classifications": {
          "$ref": "../classifications/classifications.schema.json"
        }
      },
      "required": [
        "id",
        "name",
        "kind"
      ],
      "x-eik-closed": true
    },
    "item": {
      "type": "object",
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "name": {
          "$ref": "#/$defs/name"
        },
        "parent": {
          "$ref": "#/$defs/id",
          "description": "The item of its schedule it is a part of (Part XXII, 3.3, rule 2): an item others name so is a group, whose amount is its parts'."
        },
        "quantity": {
          "$ref": "#/$defs/quantity"
        },
        "classifications": {
          "$ref": "../classifications/classifications.schema.json",
          "description": "Its codes: classification references of systems OpenEik does not list (Part II, 11 and 11.1), by which a rate list may price it (Part XXII, 4.4)."
        }
      },
      "required": [
        "id",
        "name"
      ],
      "x-eik-closed": true
    },
    "quantity": {
      "description": "Its quantity (Part XXII, 3.4): a quantity of Part XXI by its name, summed over the elements a selection keeps, a layer's where it names one, or count, how many elements it keeps; or a value stated by hand in a unit of Part XXI.",
      "oneOf": [
        {
          "$ref": "#/$defs/measured"
        },
        {
          "$ref": "#/$defs/stated"
        }
      ]
    },
    "measured": {
      "type": "object",
      "properties": {
        "name": {
          "enum": [
            "count",
            "area",
            "barCount",
            "castVolume",
            "cutVolume",
            "fillVolume",
            "grossArea",
            "grossExteriorArea",
            "grossInteriorArea",
            "grossPerimeter",
            "grossSideArea",
            "grossVolume",
            "grossWallArea",
            "hipLength",
            "length",
            "netArea",
            "netCeilingArea",
            "netExteriorArea",
            "netFloorArea",
            "netInteriorArea",
            "netMass",
            "netPerimeter",
            "netSideArea",
            "netVolume",
            "netWallArea",
            "openingArea",
            "perimeter",
            "pieceCount",
            "postCount",
            "projectedArea",
            "ridgeLength",
            "riserCount",
            "treadCount",
            "zoneVolume"
          ],
          "description": "A quantity Part XXI sums (Part XXI, 5), by its name, or count: how many elements the selection keeps."
        },
        "layer": {
          "type": "string",
          "minLength": 1,
          "maxLength": 1024,
          "description": "A layer's id (Part II, 5.1): the quantity of that layer of each element (Part XXI, 3, rule 5)."
        },
        "of": {
          "$ref": "../costSchedules/selection.schema.json"
        }
      },
      "required": [
        "name",
        "of"
      ],
      "if": {
        "required": [
          "layer"
        ]
      },
      "then": {
        "properties": {
          "name": {
            "enum": [
              "grossArea",
              "grossVolume",
              "netArea",
              "netMass",
              "netVolume"
            ]
          }
        }
      },
      "x-eik-closed": true
    },
    "stated": {
      "type": "object",
      "properties": {
        "value": {
          "type": "number",
          "minimum": 0,
          "maximum": 1000000000,
          "description": "Its value, in its unit."
        },
        "unit": {
          "enum": [
            "m",
            "m2",
            "m3",
            "kg",
            "count"
          ],
          "description": "A unit of Part XXI, 2, rule 2."
        }
      },
      "required": [
        "value",
        "unit"
      ],
      "x-eik-closed": true
    }
  }
}
