{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/asap-cool/json-schema/asap-cool-inbound-view-schema.json",
  "title": "InboundView",
  "description": "Public projection of an [`InboundRecord`].\n\nLight by design: the structured CII XML and the integrity digest are not\nsurfaced; the readable PDF is referenced by its object-store key.",
  "x-generated": "2026-11-01",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/asap-cool-openapi.json#/components/schemas/InboundView",
  "type": "object",
  "required": [
    "id",
    "transmission_id",
    "pdf_origin",
    "created_at",
    "parse_status",
    "received_lifecycle",
    "submission_state"
  ],
  "properties": {
    "byte_size": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int64",
      "description": "Size in bytes of the stored object, when known."
    },
    "created_at": {
      "type": "string",
      "description": "RFC3339 creation timestamp."
    },
    "currency": {
      "type": [
        "string",
        "null"
      ],
      "description": "Invoice currency code (BT-5), when parsed."
    },
    "due_date": {
      "type": [
        "string",
        "null"
      ],
      "description": "Payment due date as ISO `YYYY-MM-DD` (BT-9), when parsed."
    },
    "id": {
      "type": "string",
      "format": "uuid",
      "description": "Stable identifier."
    },
    "imported_at": {
      "type": [
        "string",
        "null"
      ],
      "description": "RFC3339 import timestamp, when set."
    },
    "invoice_number": {
      "type": [
        "string",
        "null"
      ],
      "description": "Invoice number extracted from the CII (BT-1), when parsed."
    },
    "issue_date": {
      "type": [
        "string",
        "null"
      ],
      "description": "Issue date as ISO `YYYY-MM-DD` (BT-2), when parsed."
    },
    "parse_status": {
      "type": "string",
      "description": "CII parse outcome: `'parsed'`, `'parse_failed'`, `'pdf_only'` (a PDF\nwith no embedded CII) or `'pending'`."
    },
    "pdf_origin": {
      "$ref": "#/$defs/PdfOriginView",
      "description": "Origin of the PDF the `/pdf` route serves."
    },
    "pdf_storage_key": {
      "type": [
        "string",
        "null"
      ],
      "description": "Object-store key of the readable PDF, when stored."
    },
    "received_at": {
      "type": [
        "string",
        "null"
      ],
      "description": "RFC3339 reception timestamp (as reported by the PA), when known."
    },
    "received_lifecycle": {
      "$ref": "#/$defs/ReceivedLifecycleView",
      "description": "What the org decided about the invoice."
    },
    "refusal_reason": {
      "type": [
        "string",
        "null"
      ],
      "description": "Motive of a refusal or dispute."
    },
    "refusal_reason_code": {
      "type": [
        "string",
        "null"
      ],
      "description": "Coded motive (MDT-113, AFNOR XP Z12-012) of a refusal or dispute;\nabsent on decisions taken before the code was required."
    },
    "seller_name": {
      "type": [
        "string",
        "null"
      ],
      "description": "Seller name extracted from the CII (BT-27), when parsed."
    },
    "sender_siren": {
      "type": [
        "string",
        "null"
      ],
      "description": "SIREN of the sender, when provided."
    },
    "submission_error": {
      "type": [
        "string",
        "null"
      ],
      "description": "Failure code when `submission_state` is `error`: `not_connected`,\n`rejected` or `enqueue_failed`."
    },
    "submission_state": {
      "$ref": "#/$defs/SubmissionStateView",
      "description": "Whether the decision has reached the platform."
    },
    "submitted_at": {
      "type": [
        "string",
        "null"
      ],
      "description": "RFC3339 time the platform accepted the decision."
    },
    "total_ht": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int64",
      "description": "Total amount without VAT in cents (BT-109), when parsed."
    },
    "total_ttc": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int64",
      "description": "Grand total with VAT in cents (BT-112), when parsed."
    },
    "total_vat": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int64",
      "description": "Total VAT amount in cents (BT-110), when parsed."
    },
    "transmission_id": {
      "type": "string",
      "description": "PA-assigned transmission id."
    }
  },
  "$defs": {
    "PdfOriginView": {
      "type": "string",
      "description": "Where the PDF served by `GET .../pdf` comes from.",
      "enum": [
        "received",
        "rendered",
        "none"
      ]
    },
    "ReceivedLifecycleView": {
      "type": "string",
      "description": "What the org decided about a received invoice.",
      "enum": [
        "received",
        "approved",
        "refused",
        "disputed",
        "paid"
      ]
    },
    "SubmissionStateView": {
      "type": "string",
      "description": "Whether the decision has reached the platform.",
      "enum": [
        "none",
        "pending",
        "sent",
        "error"
      ]
    }
  }
}