{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/lumabill-ch/json-schema/lumabill-ch-bank-transaction-schema.json",
  "title": "BankTransaction",
  "x-generated": "2026-11-17",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/lumabill-ch-openapi.yaml#/components/schemas/BankTransaction",
  "type": "object",
  "required": [
    "id",
    "transactionDate",
    "amount",
    "currency",
    "direction",
    "status"
  ],
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "transactionDate": {
      "type": "string",
      "format": "date"
    },
    "valueDate": {
      "type": [
        "string",
        "null"
      ],
      "format": "date"
    },
    "amount": {
      "type": "number",
      "format": "double",
      "description": "Always positive; use `direction` to know if it is a credit or debit"
    },
    "currency": {
      "$ref": "#/$defs/Currency"
    },
    "originalAmount": {
      "type": [
        "number",
        "null"
      ],
      "format": "double",
      "description": "Amount in the original currency when the bank converted the payment (CAMT CcyXchg)"
    },
    "originalCurrency": {
      "allOf": [
        {
          "$ref": "#/$defs/Currency"
        }
      ],
      "nullable": true
    },
    "fxRate": {
      "type": [
        "number",
        "null"
      ],
      "format": "double",
      "description": "Exchange rate reported by the bank statement (CAMT CcyXchg)"
    },
    "direction": {
      "type": "string",
      "enum": [
        "CREDIT",
        "DEBIT"
      ]
    },
    "creditorName": {
      "type": [
        "string",
        "null"
      ]
    },
    "debtorName": {
      "type": [
        "string",
        "null"
      ]
    },
    "reference": {
      "type": [
        "string",
        "null"
      ]
    },
    "remittanceInfo": {
      "type": [
        "string",
        "null"
      ]
    },
    "status": {
      "type": "string",
      "enum": [
        "MATCHED",
        "UNMATCHED",
        "CATEGORIZED",
        "IGNORED"
      ]
    },
    "matchedInvoiceId": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid"
    },
    "matchedInvoiceNumber": {
      "type": [
        "string",
        "null"
      ]
    },
    "matchedInvoiceStatus": {
      "type": [
        "string",
        "null"
      ]
    },
    "matchedInvoiceCurrency": {
      "allOf": [
        {
          "$ref": "#/$defs/Currency"
        }
      ],
      "nullable": true,
      "description": "Currency of the matched invoice (null when none is matched)"
    },
    "matchedInvoices": {
      "type": "array",
      "description": "Every invoice this bank transaction paid, in allocation order (multi-invoice match / Sammelzahlung). Empty when nothing is booked, including auto-match suggestions that only set matchedInvoiceId. matchedInvoiceId / matchedInvoiceNumber / matchedInvoiceStatus describe the first entry.\n",
      "items": {
        "type": "object",
        "required": [
          "id",
          "invoiceNumber",
          "amount",
          "paymentStatus"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "invoiceNumber": {
            "type": [
              "string",
              "null"
            ]
          },
          "documentType": {
            "type": "string",
            "enum": [
              "INVOICE",
              "CREDIT_NOTE"
            ],
            "description": "CREDIT_NOTE on a refund line (a DEBIT that paid back credit notes)"
          },
          "amount": {
            "type": "number",
            "description": "Payment amount allocated to this invoice, in `currency`"
          },
          "currency": {
            "allOf": [
              {
                "$ref": "#/$defs/Currency"
              }
            ],
            "description": "Document currency of `amount`: the foreign currency for allocations on a foreign-currency line or a confirmed cross-currency match\n"
          },
          "paymentStatus": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "PAID",
              "UNPAID",
              "PARTIALLY_PAID",
              null
            ]
          }
        }
      }
    },
    "matchedExpenseId": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid"
    },
    "matchedExpenses": {
      "type": "array",
      "description": "Every expense this (debit) bank transaction paid, in allocation order (multi-expense match / Sammelzahlung). Empty when no expense is booked. matchedExpenseId / matchedExpenseVendor / matchedExpenseDescription describe the first entry.\n",
      "items": {
        "type": "object",
        "required": [
          "id",
          "vendor",
          "description",
          "amount",
          "paymentStatus"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "vendor": {
            "type": [
              "string",
              "null"
            ]
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "amount": {
            "type": "number",
            "description": "Payment amount allocated to this expense, in `currency`"
          },
          "currency": {
            "allOf": [
              {
                "$ref": "#/$defs/Currency"
              }
            ],
            "description": "Document currency of `amount`"
          },
          "paymentStatus": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "PAID",
              "UNPAID",
              "PARTIALLY_PAID",
              null
            ]
          }
        }
      }
    },
    "matchedExpenseVendor": {
      "type": [
        "string",
        "null"
      ]
    },
    "matchedExpenseDescription": {
      "type": [
        "string",
        "null"
      ]
    },
    "matchedExpenseAmount": {
      "type": [
        "number",
        "null"
      ],
      "format": "double"
    },
    "matchedExpenseCurrency": {
      "allOf": [
        {
          "$ref": "#/$defs/Currency"
        }
      ],
      "nullable": true
    },
    "matchedRevenueId": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid"
    },
    "matchedRevenuePayer": {
      "type": [
        "string",
        "null"
      ]
    },
    "matchedRevenueDescription": {
      "type": [
        "string",
        "null"
      ]
    },
    "matchedRevenueAmount": {
      "type": [
        "number",
        "null"
      ],
      "format": "double"
    },
    "matchedRevenueCurrency": {
      "allOf": [
        {
          "$ref": "#/$defs/Currency"
        }
      ],
      "nullable": true
    },
    "counterpartyIban": {
      "type": [
        "string",
        "null"
      ],
      "description": "IBAN of the other side (CAMT, or a mapped CSV column); used to pair transfers between your own bank accounts\n"
    },
    "transferCounterpartId": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid",
      "description": "For a booked transfer between two own bank accounts: the bank transaction of the other leg (both share one journal entry)\n"
    },
    "adjustments": {
      "type": [
        "array",
        "null"
      ],
      "description": "Bank fees, rounding, partial-payment splits booked alongside the main entry",
      "items": {
        "$ref": "#/$defs/BankTransactionAdjustment"
      }
    },
    "aiSuggestion": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": true
    },
    "journalEntryId": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid",
      "description": "Posted journal entry, present once the transaction is reconciled"
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    }
  },
  "$defs": {
    "BankTransactionAdjustment": {
      "type": "object",
      "required": [
        "description",
        "amount",
        "chartAccountId"
      ],
      "properties": {
        "description": {
          "type": "string"
        },
        "amount": {
          "type": "number",
          "format": "double",
          "description": "Signed. Positive books a DEBIT (bank fee, Skonto, FX loss), negative a CREDIT (FX gain, overpayment). Must not be zero."
        },
        "chartAccountId": {
          "type": "string",
          "format": "uuid"
        }
      }
    },
    "Currency": {
      "type": "string",
      "description": "ISO 4217 code of a currency the API converts (ESTV/BAZG rates). The same list applies to every currency field of the API.\n",
      "enum": [
        "CHF",
        "EUR",
        "USD",
        "GBP",
        "JPY",
        "CAD",
        "AUD",
        "SEK",
        "NOK",
        "DKK",
        "HUF"
      ]
    }
  }
}