{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/asap-cool/json-schema/asap-cool-fiscal-cashflow-view-schema.json",
  "title": "FiscalCashflowView",
  "description": "Response body of `GET /v1/fiscal/cashflow`.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/asap-cool-fiscal-api-openapi.yml#/components/schemas/FiscalCashflowView",
  "type": "object",
  "required": [
    "collected_cents",
    "vat_collected_cents",
    "expenses_cents",
    "payments",
    "estimate"
  ],
  "properties": {
    "available_cents": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int64",
      "description": "Collected minus provision minus VAT minus expenses (centimes), before\nbank data; `None` when the rate is unknown. May be negative. The VAT\nrecoverable on expenses is not given back, so a VAT-registered org\nmay have slightly more than this."
    },
    "collected_cents": {
      "type": "integer",
      "format": "int64",
      "description": "Cash collected (centimes)."
    },
    "estimate": {
      "type": "boolean",
      "description": "Always `true`: an estimate, never an official declaration."
    },
    "expenses_cents": {
      "type": "integer",
      "format": "int64",
      "description": "Confirmed expenses incurred over the window (centimes, VAT included);\n`0` for a document-only request, which has no window."
    },
    "payments": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/CashflowPaymentView"
      },
      "description": "The payments, oldest first."
    },
    "period": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "$ref": "#/$defs/FiscalPeriodView",
          "description": "The window, `None` when only a document was requested."
        }
      ]
    },
    "provision_cents": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int64",
      "description": "Sum of the per-payment provisions (centimes); `None` when the rate is\nunknown."
    },
    "vat_collected_cents": {
      "type": "integer",
      "format": "int64",
      "description": "VAT included in the cash collected (centimes), owed to the State."
    }
  },
  "$defs": {
    "CashflowPaymentView": {
      "type": "object",
      "description": "One payment with its share of social charges and VAT.",
      "required": [
        "payment_id",
        "document_id",
        "paid_on",
        "amount_cents",
        "vat_cents"
      ],
      "properties": {
        "amount_cents": {
          "type": "integer",
          "format": "int64",
          "description": "Amount received (centimes, VAT included)."
        },
        "contact_name": {
          "type": [
            "string",
            "null"
          ],
          "description": "Displayable client name, `None` when it can't be resolved."
        },
        "document_id": {
          "type": "string",
          "format": "uuid",
          "description": "Document the payment settles."
        },
        "document_number": {
          "type": [
            "string",
            "null"
          ],
          "description": "Document number, `None` for an un-numbered draft."
        },
        "paid_on": {
          "type": "string",
          "description": "Day the payment was received (`YYYY-MM-DD`, UTC)."
        },
        "payment_id": {
          "type": "string",
          "format": "uuid",
          "description": "The payment itself."
        },
        "provision_cents": {
          "type": [
            "integer",
            "null"
          ],
          "format": "int64",
          "description": "Social charges to set aside, at the rate in force on `paid_on`; `None`\nwhen the rate is unknown, never a silent zero."
        },
        "vat_cents": {
          "type": "integer",
          "format": "int64",
          "description": "VAT included in the payment (centimes); `0` without VAT."
        }
      }
    },
    "FiscalPeriodView": {
      "type": "object",
      "description": "The window the collected cash is summed over.",
      "required": [
        "from",
        "to"
      ],
      "properties": {
        "from": {
          "type": "string",
          "description": "Inclusive lower bound (`YYYY-MM-DD`)."
        },
        "to": {
          "type": "string",
          "description": "Inclusive upper bound (`YYYY-MM-DD`)."
        }
      }
    }
  }
}