{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/altoviz-com/json-schema/altoviz-com-payment-delay-result-schema.json",
  "title": "PaymentDelayResult",
  "description": "How long payments actually take over a period.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/altoviz-com-statistics-api-openapi.yml#/components/schemas/PaymentDelayResult",
  "type": "object",
  "properties": {
    "daysLate": {
      "$ref": "#/$defs/TurnoverEvolutionResult"
    },
    "daysToPayment": {
      "$ref": "#/$defs/TurnoverEvolutionResult"
    },
    "lateShare": {
      "type": "number",
      "description": "Share of the settled amount paid after its due date, 0..1",
      "format": "double"
    },
    "medianDaysLate": {
      "type": [
        "number",
        "null"
      ],
      "description": "Median days from due date to payment. Null when nothing settled",
      "format": "double"
    },
    "medianDaysToPayment": {
      "type": [
        "number",
        "null"
      ],
      "description": "Median days from document date to payment. Null when nothing settled",
      "format": "double"
    },
    "settled": {
      "$ref": "#/$defs/TurnoverEvolutionResult"
    },
    "settledAmount": {
      "type": "number",
      "description": "Total settled over the period",
      "format": "double"
    }
  },
  "additionalProperties": false,
  "$defs": {
    "DateRangeModel": {
      "type": "object",
      "properties": {
        "from": {
          "type": "string",
          "description": "First day of the period",
          "format": "date"
        },
        "to": {
          "type": "string",
          "description": "Last day of the period, included",
          "format": "date"
        }
      },
      "additionalProperties": false,
      "description": "An inclusive date range"
    },
    "PeriodBucketModel": {
      "type": "object",
      "properties": {
        "partial": {
          "type": "boolean",
          "description": "True when the calendar period was clipped by the requested range, so the bucket holds\nless than a full month/quarter/week of activity and must not be compared at face value."
        },
        "range": {
          "$ref": "#/$defs/DateRangeModel"
        },
        "value": {
          "type": "number",
          "description": "Amount (tax excluded)",
          "format": "double"
        }
      },
      "additionalProperties": false,
      "description": "One point of a series, covering a single bucket of the period"
    },
    "PeriodSeriesModel": {
      "type": "object",
      "properties": {
        "buckets": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "$ref": "#/$defs/PeriodBucketModel"
          },
          "description": "Values, one per bucket"
        },
        "label": {
          "type": [
            "string",
            "null"
          ],
          "description": "Display label: the year for a whole calendar year, otherwise the bounds"
        },
        "offset": {
          "type": "integer",
          "description": "0 for the requested period, 1 for one calendar year earlier, and so on",
          "format": "int32"
        },
        "range": {
          "$ref": "#/$defs/DateRangeModel"
        }
      },
      "additionalProperties": false,
      "description": "The requested period, or the same period in an earlier year"
    },
    "Periodicity": {
      "enum": [
        "Daily",
        "Weekly",
        "Monthly",
        "Quarterly",
        "Annually"
      ],
      "type": "string"
    },
    "TurnoverEvolutionResult": {
      "type": "object",
      "properties": {
        "periodicity": {
          "$ref": "#/$defs/Periodicity"
        },
        "range": {
          "$ref": "#/$defs/DateRangeModel"
        },
        "series": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "$ref": "#/$defs/PeriodSeriesModel"
          },
          "description": "The requested period first, then any comparison periods"
        }
      },
      "additionalProperties": false,
      "description": "Turnover bucketed over a period. Every series holds the same number of buckets and bucket\nN of each series covers the same period shifted by its `offset` in years, so series can\nbe compared index by index."
    }
  }
}