{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/asap-cool/json-schema/asap-cool-expense-view-schema.json",
  "title": "ExpenseView",
  "description": "An expense.",
  "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/ExpenseView",
  "type": "object",
  "required": [
    "id",
    "status",
    "category",
    "currency",
    "total_ht",
    "total_vat",
    "vat_deductible",
    "vat_lines",
    "extraction_status",
    "created_at",
    "updated_at"
  ],
  "properties": {
    "category": {
      "$ref": "#/$defs/CategoryView",
      "description": "Advisory category."
    },
    "confirmed_at": {
      "type": [
        "string",
        "null"
      ],
      "description": "RFC 3339 UTC, set once confirmed."
    },
    "created_at": {
      "type": "string",
      "description": "RFC 3339 UTC."
    },
    "currency": {
      "type": "string",
      "description": "Lower-case ISO currency code; only `eur` can be confirmed."
    },
    "extraction_status": {
      "type": "string",
      "description": "`none`, `read` (prefilled by AI) or `failed` (the read failed; fill it by hand)."
    },
    "file_id": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid",
      "description": "Receipt in the file library."
    },
    "id": {
      "type": "string",
      "format": "uuid",
      "description": "Expense identifier."
    },
    "inbound_invoice_id": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid",
      "description": "Received e-invoice this expense was recorded from."
    },
    "incurred_on": {
      "type": [
        "string",
        "null"
      ],
      "description": "Day the expense was incurred, `YYYY-MM-DD`."
    },
    "reference": {
      "type": [
        "string",
        "null"
      ],
      "description": "The supplier's invoice or ticket number."
    },
    "status": {
      "$ref": "#/$defs/StatusView",
      "description": "`draft` or `confirmed`."
    },
    "supplier_name": {
      "type": [
        "string",
        "null"
      ],
      "description": "Who was paid."
    },
    "total_ht": {
      "type": "integer",
      "format": "int64",
      "description": "Sum of the lines' bases, in cents."
    },
    "total_ttc": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int64",
      "description": "Total paid, in cents."
    },
    "total_vat": {
      "type": "integer",
      "format": "int64",
      "description": "Sum of the lines' VAT, in cents."
    },
    "updated_at": {
      "type": "string",
      "description": "RFC 3339 UTC."
    },
    "vat_deductible": {
      "type": "integer",
      "format": "int64",
      "description": "Sum of the lines' recoverable VAT, in cents."
    },
    "vat_lines": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/VatLineView"
      },
      "description": "VAT per rate."
    }
  },
  "$defs": {
    "CategoryView": {
      "type": "string",
      "description": "Advisory expense category.",
      "enum": [
        "software",
        "hardware",
        "telecom",
        "travel",
        "meals",
        "fees",
        "insurance",
        "marketing",
        "rent",
        "training",
        "other"
      ]
    },
    "StatusView": {
      "type": "string",
      "description": "Expense lifecycle.",
      "enum": [
        "draft",
        "confirmed"
      ]
    },
    "VatLineView": {
      "type": "object",
      "description": "One VAT rate of an expense.",
      "required": [
        "rate",
        "base_cents",
        "vat_cents",
        "deductible_cents"
      ],
      "properties": {
        "base_cents": {
          "type": "integer",
          "format": "int64",
          "description": "Amount before VAT, in cents."
        },
        "deductible_cents": {
          "type": "integer",
          "format": "int64",
          "description": "Recoverable part of the VAT, in cents."
        },
        "rate": {
          "type": "string",
          "description": "Rate in percent (`\"20\"`, `\"5.5\"`)."
        },
        "vat_cents": {
          "type": "integer",
          "format": "int64",
          "description": "VAT amount, in cents."
        }
      }
    }
  }
}