{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/cosuno/json-schema/cosuno-cost-analysis-response-schema.json",
  "title": "CostAnalysisResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/cosuno-project-costs-api-openapi.yml#/components/schemas/CostAnalysisResponse",
  "properties": {
    "groups": {
      "items": {
        "$ref": "#/$defs/CostAnalysisCostGroup"
      },
      "type": "array",
      "description": "Top-level groups of the cost analysis. Each group contains nested children representing the breakdown of costs within that group."
    },
    "currency": {
      "$ref": "#/$defs/CURRENCY",
      "description": "Currency in which all monetary values in this response are expressed."
    },
    "bidPackagesTotalCount": {
      "type": "number",
      "format": "double",
      "description": "Total number of bid packages in the project."
    },
    "bidPackagesWithBoQCount": {
      "type": "number",
      "format": "double",
      "description": "Number of bid packages in the project that have a bill of quantities attached."
    }
  },
  "required": [
    "groups",
    "currency",
    "bidPackagesTotalCount",
    "bidPackagesWithBoQCount"
  ],
  "type": "object",
  "additionalProperties": false,
  "$defs": {
    "COST_CATALOG_TYPE": {
      "type": "string",
      "enum": [
        "custom",
        "din276",
        "oenorm",
        "bidPackage",
        "stlbWorkCategory"
      ]
    },
    "CURRENCY": {
      "type": "string",
      "enum": [
        "EUR",
        "ALL",
        "AMD",
        "AZN",
        "BYN",
        "BAM",
        "BGN",
        "HRK",
        "CZK",
        "DKK",
        "GEL",
        "HUF",
        "ISK",
        "CHF",
        "MDL",
        "MKD",
        "NOK",
        "PLN",
        "RON",
        "RUB",
        "RSD",
        "SEK",
        "TRY",
        "UAH",
        "GBP"
      ]
    },
    "CostAnalysisCostGroup": {
      "properties": {
        "id": {
          "type": "string"
        },
        "parentId": {
          "type": [
            "string",
            "null"
          ]
        },
        "designation": {
          "type": [
            "string",
            "null"
          ]
        },
        "catalogType": {
          "allOf": [
            {
              "$ref": "#/$defs/COST_CATALOG_TYPE"
            }
          ]
        },
        "localId": {
          "type": "string"
        },
        "parentLocalId": {
          "type": [
            "string",
            "null"
          ]
        },
        "costItemId": {
          "type": [
            "string",
            "null"
          ]
        },
        "costItem": {
          "$ref": "#/$defs/CostItem"
        },
        "estimatedBudgetNet": {
          "type": [
            "number",
            "null"
          ],
          "format": "double"
        },
        "costEstimateCost": {
          "allOf": [
            {
              "$ref": "#/$defs/CostAnalysisTotals"
            }
          ]
        },
        "bidPackageCost": {
          "allOf": [
            {
              "$ref": "#/$defs/CostAnalysisTotals"
            }
          ]
        },
        "invoiceCost": {
          "allOf": [
            {
              "$ref": "#/$defs/CostAnalysisTotals"
            }
          ]
        },
        "priceBenchmarkNet": {
          "type": [
            "number",
            "null"
          ],
          "format": "double"
        },
        "projectedCost": {
          "allOf": [
            {
              "$ref": "#/$defs/CostAnalysisTotals"
            }
          ]
        },
        "awardedBidCost": {
          "allOf": [
            {
              "$ref": "#/$defs/CostAnalysisTotals"
            }
          ]
        },
        "addendumCost": {
          "allOf": [
            {
              "$ref": "#/$defs/CostAnalysisTotals"
            }
          ]
        },
        "actualCost": {
          "allOf": [
            {
              "$ref": "#/$defs/CostAnalysisTotals"
            }
          ]
        },
        "children": {
          "items": {
            "$ref": "#/$defs/CostAnalysisCostGroup"
          },
          "type": "array"
        }
      },
      "required": [
        "id",
        "parentId",
        "localId",
        "parentLocalId",
        "costItemId",
        "costItem",
        "estimatedBudgetNet",
        "costEstimateCost",
        "bidPackageCost",
        "invoiceCost",
        "priceBenchmarkNet",
        "projectedCost",
        "awardedBidCost",
        "addendumCost",
        "actualCost",
        "children"
      ],
      "type": "object",
      "additionalProperties": false
    },
    "CostAnalysisTotals": {
      "properties": {
        "totalNet": {
          "type": "number",
          "format": "double"
        },
        "totalGross": {
          "type": "number",
          "format": "double"
        }
      },
      "required": [
        "totalNet",
        "totalGross"
      ],
      "type": "object",
      "additionalProperties": false
    },
    "CostItem": {
      "properties": {
        "id": {
          "type": "string"
        },
        "factor": {
          "type": [
            "number",
            "null"
          ],
          "format": "double"
        },
        "quantity": {
          "type": [
            "number",
            "null"
          ],
          "format": "double"
        },
        "unit": {
          "type": [
            "string",
            "null"
          ]
        },
        "unitPrice": {
          "type": [
            "number",
            "null"
          ],
          "format": "double"
        },
        "taxRate": {
          "type": [
            "number",
            "null"
          ],
          "format": "double"
        }
      },
      "required": [
        "id",
        "factor",
        "quantity",
        "unit",
        "unitPrice",
        "taxRate"
      ],
      "type": "object",
      "additionalProperties": false
    }
  }
}