{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Račun native document intake",
  "description": "Closed native source contract. One obligation, or explicit statement without one. Absence is not zero, payment or write-off. Native pages use the safe JCS integer domain.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "format",
    "bill"
  ],
  "properties": {
    "format": {
      "const": "native-document"
    },
    "bill": {
      "$ref": "#/$defs/bill"
    }
  },
  "$defs": {
    "bill": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "source_document_id",
        "revision",
        "revision_kind",
        "document_number",
        "currency",
        "customer",
        "completeness",
        "document_type"
      ],
      "properties": {
        "source_document_id": {
          "$ref": "../rich-bill.schema.json#/$defs/bill/properties/source_document_id"
        },
        "revision": {
          "$ref": "../rich-bill.schema.json#/$defs/bill/properties/revision"
        },
        "revision_kind": {
          "$ref": "../rich-bill.schema.json#/$defs/bill/properties/revision_kind"
        },
        "document_number": {
          "$ref": "../rich-bill.schema.json#/$defs/bill/properties/document_number"
        },
        "issue_date": {
          "$ref": "../rich-bill.schema.json#/$defs/bill/properties/issue_date"
        },
        "period": {
          "$ref": "../rich-bill.schema.json#/$defs/bill/properties/period"
        },
        "currency": {
          "$ref": "../rich-bill.schema.json#/$defs/bill/properties/currency"
        },
        "customer": {
          "$ref": "../rich-bill.schema.json#/$defs/bill/properties/customer"
        },
        "lines": {
          "$ref": "../rich-bill.schema.json#/$defs/bill/properties/lines"
        },
        "measurements": {
          "$ref": "../rich-bill.schema.json#/$defs/bill/properties/measurements"
        },
        "vat_summary": {
          "$ref": "../rich-bill.schema.json#/$defs/bill/properties/vat_summary"
        },
        "totals": {
          "$ref": "../rich-bill.schema.json#/$defs/bill/properties/totals"
        },
        "obligation": {
          "$ref": "../rich-bill.schema.json#/$defs/bill/properties/obligation"
        },
        "payment_instruction": {
          "$ref": "../rich-bill.schema.json#/$defs/bill/properties/payment_instruction"
        },
        "document_type": {
          "$ref": "../rich-bill.schema.json#/$defs/bill/properties/document_type"
        },
        "completeness": {
          "allOf": [
            {
              "$ref": "../rich-bill.schema.json#/$defs/BillCompleteness"
            },
            {
              "properties": {
                "pages_received": {
                  "maximum": 9007199254740991
                },
                "pages_expected": {
                  "maximum": 9007199254740991
                }
              }
            }
          ]
        },
        "language": {
          "$ref": "../rich-bill.schema.json#/$defs/bill/properties/language"
        },
        "dates": {
          "$ref": "../rich-bill.schema.json#/$defs/bill/properties/dates"
        },
        "parties": {
          "$ref": "../rich-bill.schema.json#/$defs/bill/properties/parties"
        },
        "provider_accounts": {
          "$ref": "../rich-bill.schema.json#/$defs/bill/properties/provider_accounts"
        },
        "contracts": {
          "$ref": "../rich-bill.schema.json#/$defs/bill/properties/contracts"
        },
        "billing_points": {
          "$ref": "../rich-bill.schema.json#/$defs/bill/properties/billing_points"
        },
        "devices": {
          "$ref": "../rich-bill.schema.json#/$defs/bill/properties/devices"
        },
        "service_components": {
          "$ref": "../rich-bill.schema.json#/$defs/bill/properties/service_components"
        },
        "relationships": {
          "$ref": "../rich-bill.schema.json#/$defs/bill/properties/relationships"
        },
        "adjustments": {
          "$ref": "../rich-bill.schema.json#/$defs/bill/properties/adjustments"
        },
        "balance_snapshot": {
          "$ref": "../rich-bill.schema.json#/$defs/bill/properties/balance_snapshot"
        },
        "payment_instructions": {
          "$ref": "../rich-bill.schema.json#/$defs/bill/properties/payment_instructions"
        }
      },
      "allOf": [
        {
          "$ref": "../rich-bill.schema.json#/$defs/bill/allOf/0"
        },
        {
          "$ref": "../rich-bill.schema.json#/$defs/bill/allOf/1"
        },
        {
          "$ref": "../rich-bill.schema.json#/$defs/bill/allOf/2"
        },
        {
          "if": {
            "not": {
              "required": [
                "obligation"
              ]
            }
          },
          "then": {
            "properties": {
              "document_type": {
                "const": "statement"
              }
            },
            "not": {
              "anyOf": [
                {
                  "required": [
                    "payment_instruction"
                  ]
                },
                {
                  "required": [
                    "payment_instructions"
                  ]
                }
              ]
            }
          }
        }
      ]
    }
  }
}
