{
  "$defs": {
    "BankReconcStatus": {
      "description": "Reconciliation status of a bank transaction.",
      "enum": [
        "unreconciled",
        "partially_reconciled",
        "reconciled",
        "disputed"
      ],
      "type": "string"
    },
    "ImportSource": {
      "description": "Where the bank transaction came from.",
      "oneOf": [
        {
          "enum": [
            "manual",
            "csv",
            "finapi",
            "gocardless",
            "stripe",
            "bank_api"
          ],
          "type": "string"
        },
        {
          "const": "hbci",
          "description": "HBCI / FinTS protocol (DE).",
          "type": "string"
        },
        {
          "const": "ebics",
          "description": "EBICS (corporate banking standard).",
          "type": "string"
        }
      ]
    },
    "IsoCurrency": {
      "description": "ISO 4217 currency code.",
      "pattern": "^[A-Z]{3}$",
      "type": "string"
    },
    "IsoDate": {
      "description": "ISO 8601 date (YYYY-MM-DD).",
      "format": "date",
      "type": "string"
    },
    "PathRef": {
      "description": "Path-based cross-reference relative to .corpospec/ root.\nPattern: `^[a-z0-9_-]+(/[a-z0-9_.-]+)+$`",
      "pattern": "^[a-z0-9_-]+(/[a-z0-9_.-]+)+$",
      "type": "string"
    }
  },
  "$id": "https://corpospec.com/schemas/v0.16.0/bank-transaction.schema.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "description": "One bank-statement line.",
  "properties": {
    "amount": {
      "description": "Signed amount (positive = inflow, negative = outflow).",
      "format": "double",
      "type": "number"
    },
    "bank_account": {
      "$ref": "#/$defs/PathRef"
    },
    "bank_statement_id": {
      "description": "Bank-statement identifier (required for HBCI / EBICS imports).",
      "type": [
        "string",
        "null"
      ]
    },
    "booking_date": {
      "$ref": "#/$defs/IsoDate",
      "description": "When the bank posted the transaction."
    },
    "counterparty": {
      "anyOf": [
        {
          "$ref": "#/$defs/PathRef"
        },
        {
          "type": "null"
        }
      ],
      "description": "PathRef into the counterparty's `legal/parties/<slug>` when\nidentifiable."
    },
    "currency": {
      "$ref": "#/$defs/IsoCurrency"
    },
    "description": {
      "type": "string"
    },
    "id": {
      "$ref": "#/$defs/PathRef"
    },
    "import_source": {
      "$ref": "#/$defs/ImportSource"
    },
    "reconciled_to": {
      "description": "Invoice / journal PathRefs this transaction matches against.",
      "items": {
        "$ref": "#/$defs/PathRef"
      },
      "type": "array"
    },
    "reconciliation_status": {
      "$ref": "#/$defs/BankReconcStatus"
    },
    "reference": {
      "description": "SEPA reference (EREF / KREF / SVWZ / Mandate ID).",
      "type": [
        "string",
        "null"
      ]
    },
    "value_date": {
      "$ref": "#/$defs/IsoDate",
      "description": "When the transaction cleared."
    }
  },
  "required": [
    "id",
    "bank_account",
    "booking_date",
    "value_date",
    "amount",
    "currency",
    "description",
    "import_source",
    "reconciliation_status"
  ],
  "title": "BankTransaction",
  "type": "object",
  "x-corpospec-pillar": "financials"
}