{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/portravo-com/json-schema/portravo-com-owned-takeoff-schema.json",
  "title": "OwnedTakeoff",
  "x-generated": "2026-11-21",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/portravo-com-openapi.json#/components/schemas/OwnedTakeoff",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "project": {
      "$ref": "#/$defs/ProjectDetail"
    },
    "lines": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/TakeoffLine"
      }
    },
    "files": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/PlanFileMetadata"
      }
    },
    "metro": {
      "anyOf": [
        {
          "$ref": "#/$defs/Metro"
        },
        {
          "type": "null"
        }
      ]
    },
    "reviewRequired": {
      "type": "boolean",
      "description": "True when at least one takeoff line is pending. False alone does not establish pricing readiness or permit export."
    },
    "reviewUrl": {
      "type": "string",
      "format": "uri"
    }
  },
  "required": [
    "project",
    "lines",
    "files",
    "metro",
    "reviewRequired",
    "reviewUrl"
  ],
  "$defs": {
    "Metro": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "code": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "state": {
          "type": "string"
        },
        "costIndex": {
          "type": "number"
        },
        "hasDirectPrices": {
          "type": "boolean"
        },
        "createdAt": {
          "type": "string",
          "format": "date-time"
        }
      },
      "required": [
        "code",
        "name",
        "state",
        "costIndex",
        "hasDirectPrices",
        "createdAt"
      ]
    },
    "PlanFileMetadata": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string"
        },
        "filename": {
          "type": "string"
        },
        "sizeBytes": {
          "type": "integer"
        },
        "contentType": {
          "type": "string"
        },
        "pageCount": {
          "type": [
            "integer",
            "null"
          ]
        }
      },
      "required": [
        "id",
        "filename",
        "sizeBytes",
        "contentType",
        "pageCount"
      ]
    },
    "ProjectDetail": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "description": "Owned project ID. Use this value in subsequent project routes."
        },
        "name": {
          "type": "string"
        },
        "address": {
          "type": [
            "string",
            "null"
          ]
        },
        "status": {
          "type": "string",
          "enum": [
            "draft",
            "extracting",
            "review",
            "priced",
            "final",
            "failed"
          ]
        },
        "metroCode": {
          "type": "string"
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "chargedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "When this project consumed an estimate credit; null before a successful charge."
        }
      },
      "required": [
        "id",
        "name",
        "address",
        "status",
        "metroCode",
        "updatedAt",
        "chargedAt"
      ]
    },
    "TakeoffLine": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string"
        },
        "page": {
          "type": [
            "integer",
            "null"
          ]
        },
        "trade": {
          "type": "string"
        },
        "category": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "qty": {
          "type": "number"
        },
        "unit": {
          "type": "string"
        },
        "confidence": {
          "type": "number"
        },
        "status": {
          "type": "string",
          "enum": [
            "pending",
            "confirmed",
            "edited",
            "rejected"
          ]
        },
        "assemblyId": {
          "type": [
            "string",
            "null"
          ]
        },
        "notes": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "id",
        "page",
        "trade",
        "category",
        "description",
        "qty",
        "unit",
        "confidence",
        "status",
        "assemblyId",
        "notes"
      ]
    }
  }
}