{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/asap-cool/json-schema/asap-cool-register-view-schema.json",
  "title": "RegisterView",
  "description": "The purchases register of a period.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/asap-cool-expenses-api-openapi.yml#/components/schemas/RegisterView",
  "type": "object",
  "required": [
    "from",
    "to",
    "expense_count",
    "total",
    "by_category",
    "by_rate"
  ],
  "properties": {
    "by_category": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/RegisterCategoryView"
      },
      "description": "Per category, categories without expenses left out."
    },
    "by_rate": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/RegisterRateView"
      },
      "description": "Per VAT rate, highest first."
    },
    "expense_count": {
      "type": "integer",
      "format": "int64",
      "description": "Confirmed expenses in the period."
    },
    "from": {
      "type": "string",
      "description": "First day, `YYYY-MM-DD`."
    },
    "to": {
      "type": "string",
      "description": "Last day, `YYYY-MM-DD`."
    },
    "total": {
      "$ref": "#/$defs/RegisterAmounts",
      "description": "Everything."
    },
    "vat_regime": {
      "type": [
        "string",
        "null"
      ],
      "description": "The org's VAT regime (`subject`, `franchise_base`, `real`) when known."
    }
  },
  "$defs": {
    "CategoryView": {
      "type": "string",
      "description": "Advisory expense category.",
      "enum": [
        "software",
        "hardware",
        "telecom",
        "travel",
        "meals",
        "fees",
        "insurance",
        "marketing",
        "rent",
        "training",
        "other"
      ]
    },
    "RegisterAmounts": {
      "type": "object",
      "description": "Sums, in cents.",
      "required": [
        "ht",
        "vat",
        "ttc"
      ],
      "properties": {
        "ht": {
          "type": "integer",
          "format": "int64",
          "description": "Before VAT."
        },
        "ttc": {
          "type": "integer",
          "format": "int64",
          "description": "Total paid."
        },
        "vat": {
          "type": "integer",
          "format": "int64",
          "description": "VAT paid."
        },
        "vat_deductible": {
          "type": [
            "integer",
            "null"
          ],
          "format": "int64",
          "description": "Recoverable VAT; `null` when the org is in franchise en base."
        }
      }
    },
    "RegisterCategoryView": {
      "type": "object",
      "description": "Sums for one category.",
      "required": [
        "category",
        "amounts"
      ],
      "properties": {
        "amounts": {
          "$ref": "#/$defs/RegisterAmounts",
          "description": "Its sums."
        },
        "category": {
          "$ref": "#/$defs/CategoryView",
          "description": "The category."
        }
      }
    },
    "RegisterRateView": {
      "type": "object",
      "description": "Sums for one VAT rate.",
      "required": [
        "rate",
        "amounts"
      ],
      "properties": {
        "amounts": {
          "$ref": "#/$defs/RegisterAmounts",
          "description": "Its sums."
        },
        "rate": {
          "type": "string",
          "description": "Rate in percent (`\"20\"`, `\"5.5\"`)."
        }
      }
    }
  }
}