{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://touristtaxtools.com/schemas/resolve-response.v2.schema.json",
  "type": "object",
  "properties": {
    "schemaVersion": {
      "const": "2.0.0"
    },
    "status": {
      "enum": [
        "unknown",
        "ambiguous",
        "stale",
        "unsupported",
        "needs_input",
        "policy_ready",
        "resolved"
      ]
    },
    "countryCode": {
      "type": "string",
      "pattern": "^[A-Z]{2}$"
    },
    "snapshotId": {
      "type": ["string", "null"],
      "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,199}$"
    },
    "countrySnapshotSha256": {
      "type": ["string", "null"],
      "pattern": "^[a-f0-9]{64}$"
    },
    "artifactSha256": {
      "type": ["string", "null"],
      "pattern": "^[a-f0-9]{64}$"
    },
    "location": {
      "type": ["object", "null"],
      "properties": {
        "addressId": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,199}$"
        },
        "addressFingerprint": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "officialCode": {
          "type": "object",
          "properties": {
            "scheme": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,199}$"
            },
            "value": {
              "type": "string",
              "minLength": 1,
              "maxLength": 10000
            }
          },
          "required": ["scheme", "value"],
          "additionalProperties": false
        },
        "sourceEdition": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "scope": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,199}$"
            },
            "status": {
              "enum": ["complete", "partial"]
            },
            "levyType": {
              "const": "tourist_accommodation"
            },
            "summary": {
              "type": "string",
              "minLength": 1,
              "maxLength": 10000
            },
            "expectedAssessments": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            },
            "layerSetEvidenceIds": {
              "type": "array",
              "items": {
                "type": "string",
                "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,199}$"
              },
              "minItems": 1,
              "maxItems": 100
            },
            "assessments": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "jurisdictionId": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,199}$"
                  },
                  "membership": {
                    "enum": ["included", "excluded"]
                  },
                  "ownLevy": {
                    "enum": ["policies", "verified_none", "unknown"]
                  },
                  "policyIds": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,199}$"
                    },
                    "minItems": 0,
                    "maxItems": 100
                  },
                  "evidenceIds": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,199}$"
                    },
                    "minItems": 1,
                    "maxItems": 100
                  }
                },
                "required": [
                  "jurisdictionId",
                  "membership",
                  "ownLevy",
                  "policyIds",
                  "evidenceIds"
                ],
                "additionalProperties": false
              },
              "minItems": 1,
              "maxItems": 100
            }
          },
          "required": [
            "id",
            "status",
            "levyType",
            "summary",
            "expectedAssessments",
            "layerSetEvidenceIds",
            "assessments"
          ],
          "additionalProperties": false
        },
        "evidenceIds": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,199}$"
          },
          "minItems": 1,
          "maxItems": 100
        }
      },
      "required": [
        "addressId",
        "addressFingerprint",
        "officialCode",
        "sourceEdition",
        "scope",
        "evidenceIds"
      ],
      "additionalProperties": false
    },
    "policies": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,199}$"
          },
          "revision": {
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,199}$"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "jurisdictionId": {
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,199}$"
          },
          "sourceRuleIds": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,199}$"
            },
            "minItems": 1,
            "maxItems": 100
          },
          "qualification": {
            "type": "object",
            "properties": {
              "status": {
                "const": "qualified"
              },
              "summary": {
                "type": "string",
                "minLength": 1,
                "maxLength": 10000
              },
              "evidenceIds": {
                "type": "array",
                "items": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,199}$"
                },
                "minItems": 1,
                "maxItems": 100
              }
            },
            "required": ["status", "summary", "evidenceIds"],
            "additionalProperties": false
          },
          "effectiveFrom": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "effectiveTo": {
            "type": ["string", "null"],
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "currency": {
            "const": "EUR"
          },
          "calculation": {
            "type": "object",
            "properties": {
              "kind": {
                "const": "net_percentage"
              },
              "rate": {
                "type": "string",
                "pattern": "^(0|[1-9][0-9]{0,2})(\\.[0-9]{1,8})?$"
              },
              "rounding": {
                "enum": [
                  "half_up_per_night",
                  "half_up_per_stay",
                  "exact_integral_minor_unit"
                ]
              }
            },
            "required": ["kind", "rate", "rounding"],
            "additionalProperties": false
          },
          "conditions": {
            "type": "object",
            "properties": {
              "accommodationTypes": {
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 100
                },
                "minItems": 1,
                "maxItems": 100
              },
              "agreementFrom": {
                "type": ["string", "null"],
                "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
              },
              "agreementTo": {
                "type": ["string", "null"],
                "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
              },
              "maxStayCalendarMonths": {
                "type": ["integer", "null"],
                "minimum": 1,
                "maximum": 12
              },
              "factRequirements": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "fact": {
                      "enum": [
                        "paidAccommodation",
                        "originalContractUnderSixMonths",
                        "basicHousingNeed",
                        "schoolTrip",
                        "registeredResidence",
                        "emergencyAccommodation",
                        "platformCollected",
                        "passThroughChosen"
                      ]
                    },
                    "equals": {
                      "type": "boolean"
                    },
                    "evidenceIds": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,199}$"
                      },
                      "minItems": 1,
                      "maxItems": 100
                    }
                  },
                  "required": ["fact", "equals", "evidenceIds"],
                  "additionalProperties": false
                },
                "minItems": 0,
                "maxItems": 100
              }
            },
            "required": [
              "accommodationTypes",
              "agreementFrom",
              "agreementTo",
              "maxStayCalendarMonths",
              "factRequirements"
            ],
            "additionalProperties": false
          },
          "collection": {
            "type": "object",
            "properties": {
              "collector": {
                "const": "accommodation_operator"
              },
              "passThrough": {
                "enum": ["permitted", "required"]
              }
            },
            "required": ["collector", "passThrough"],
            "additionalProperties": false
          },
          "taxTreatment": {
            "type": "object",
            "properties": {
              "passedThroughVatBase": {
                "enum": ["accommodation", "unknown"]
              },
              "evidenceIds": {
                "type": "array",
                "items": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,199}$"
                },
                "minItems": 0,
                "maxItems": 100
              }
            },
            "required": ["passedThroughVatBase", "evidenceIds"],
            "additionalProperties": false
          },
          "evidenceIds": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,199}$"
            },
            "minItems": 1,
            "maxItems": 100
          }
        },
        "required": [
          "id",
          "revision",
          "name",
          "jurisdictionId",
          "sourceRuleIds",
          "qualification",
          "effectiveFrom",
          "effectiveTo",
          "currency",
          "calculation",
          "conditions",
          "collection",
          "taxTreatment",
          "evidenceIds"
        ],
        "additionalProperties": false
      },
      "minItems": 0,
      "maxItems": 100
    },
    "requiredInputs": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 100
      },
      "minItems": 0,
      "maxItems": 100
    },
    "missingInputs": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 100
      },
      "minItems": 0,
      "maxItems": 100
    },
    "quote": {
      "type": ["object", "null"],
      "properties": {
        "calculationVersion": {
          "enum": [
            "net-percentage.v1",
            "net-percentage.exact-integral-minor-unit.v1"
          ]
        },
        "currency": {
          "const": "EUR"
        },
        "netMinor": {
          "type": "string",
          "pattern": "^(0|[1-9][0-9]{0,17})$"
        },
        "taxMinor": {
          "type": "string",
          "pattern": "^(0|[1-9][0-9]{0,17})$"
        },
        "totalMinor": {
          "type": "string",
          "pattern": "^(0|[1-9][0-9]{0,17})$"
        },
        "inputFingerprint": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "inputEvidence": {
          "type": "object",
          "properties": {
            "source": {
              "enum": [
                "operator_confirmation",
                "booking_record",
                "property_record"
              ]
            },
            "reference": {
              "type": "string",
              "minLength": 1,
              "maxLength": 500
            },
            "recordedAt": {
              "type": "string",
              "minLength": 20,
              "maxLength": 40
            }
          },
          "required": ["source", "reference", "recordedAt"],
          "additionalProperties": false
        },
        "transaction": {
          "type": "object",
          "properties": {
            "supplyId": {
              "type": ["string", "null"],
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,63}$"
            },
            "night": {
              "type": ["string", "null"],
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
            },
            "accommodatedPersonCount": {
              "type": ["integer", "null"],
              "minimum": 0,
              "maximum": 1000
            },
            "accommodationSupplyCount": {
              "type": ["integer", "null"],
              "minimum": 0,
              "maximum": 1000
            },
            "nightCount": {
              "type": ["integer", "null"],
              "minimum": 0,
              "maximum": 366
            },
            "completeNight": {
              "type": ["boolean", "null"]
            },
            "directlyContracted": {
              "type": ["boolean", "null"]
            },
            "separatelyPriced": {
              "type": ["boolean", "null"]
            },
            "considerationComplete": {
              "type": ["boolean", "null"]
            },
            "depositReconciled": {
              "type": ["boolean", "null"]
            },
            "components": {
              "type": ["array", "null"],
              "items": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": ["string", "null"],
                    "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,63}$"
                  },
                  "kind": {
                    "type": ["string", "null"],
                    "enum": [
                      "accommodation_net",
                      "taxable_direct_ancillary_net",
                      "vat",
                      "own_tourist_levy",
                      "excluded_service",
                      "deposit_payment",
                      "unknown",
                      null
                    ]
                  },
                  "amount": {
                    "type": ["string", "null"],
                    "pattern": "^-?(0|[1-9][0-9]{0,11})(\\.[0-9]{1,2})?$"
                  },
                  "supplyId": {
                    "type": ["string", "null"],
                    "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,63}$"
                  },
                  "night": {
                    "type": ["string", "null"],
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                  },
                  "allocation": {
                    "type": ["string", "null"],
                    "enum": ["direct", "shared", "one_off", "indirect", null]
                  }
                },
                "required": [],
                "additionalProperties": false
              },
              "minItems": 0,
              "maxItems": 12
            }
          },
          "required": [],
          "additionalProperties": false
        },
        "lines": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "policyId": {
                "type": "string",
                "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,199}$"
              },
              "policyRevision": {
                "type": "string",
                "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,199}$"
              },
              "jurisdictionId": {
                "type": "string",
                "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,199}$"
              },
              "sourceRuleIds": {
                "type": "array",
                "items": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,199}$"
                },
                "minItems": 1,
                "maxItems": 100
              },
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100
              },
              "rate": {
                "type": "string",
                "pattern": "^(0|[1-9][0-9]{0,2})(\\.[0-9]{1,8})?$"
              },
              "rounding": {
                "enum": [
                  "half_up_per_night",
                  "half_up_per_stay",
                  "exact_integral_minor_unit"
                ]
              },
              "netMinor": {
                "type": "string",
                "pattern": "^(0|[1-9][0-9]{0,17})$"
              },
              "taxMinor": {
                "type": "string",
                "pattern": "^(0|[1-9][0-9]{0,17})$"
              }
            },
            "required": [
              "policyId",
              "policyRevision",
              "jurisdictionId",
              "sourceRuleIds",
              "name",
              "rate",
              "rounding",
              "netMinor",
              "taxMinor"
            ],
            "additionalProperties": false
          },
          "minItems": 1,
          "maxItems": 100
        }
      },
      "required": [
        "calculationVersion",
        "currency",
        "netMinor",
        "taxMinor",
        "totalMinor",
        "inputFingerprint",
        "inputEvidence",
        "lines"
      ],
      "additionalProperties": false
    },
    "reasons": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 200
      },
      "minItems": 0,
      "maxItems": 100
    },
    "evidence": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,199}$"
          },
          "url": {
            "type": "string",
            "minLength": 8,
            "maxLength": 4096,
            "pattern": "^https://"
          },
          "sha256": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          },
          "retrievedAt": {
            "type": "string",
            "maxLength": 40
          },
          "contentType": {
            "type": "string",
            "minLength": 1,
            "maxLength": 10000
          },
          "bytes": {
            "type": "integer",
            "minimum": 1,
            "maximum": 268435456
          }
        },
        "required": [
          "id",
          "url",
          "sha256",
          "retrievedAt",
          "contentType",
          "bytes"
        ],
        "additionalProperties": false
      },
      "minItems": 0,
      "maxItems": 10000
    }
  },
  "required": [
    "schemaVersion",
    "status",
    "countryCode",
    "snapshotId",
    "countrySnapshotSha256",
    "artifactSha256",
    "location",
    "policies",
    "requiredInputs",
    "missingInputs",
    "quote",
    "reasons",
    "evidence"
  ],
  "additionalProperties": false
}
