{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/ordogrid/json-schema/ordogrid-movement-history-schema.json",
  "title": "MovementHistory",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/ordogrid-payments-api-openapi.yml#/components/schemas/MovementHistory",
  "properties": {
    "data": {
      "items": {
        "$ref": "#/$defs/FinancialMovement"
      },
      "type": "array"
    },
    "document_snapshot": {
      "$ref": "#/$defs/DocumentSnapshot"
    },
    "object": {
      "const": "list"
    },
    "settlement": {
      "$ref": "#/$defs/Settlement"
    }
  },
  "type": "object",
  "$defs": {
    "DocumentSnapshot": {
      "properties": {
        "calculation_version": {
          "type": "integer"
        },
        "created_at": {
          "description": "UTC, ISO 8601 with milliseconds and Z, e.g. 2026-10-22T10:00:00.123Z.",
          "format": "date-time",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$",
          "type": "string"
        },
        "currency": {
          "type": "string"
        },
        "document_revision": {
          "type": "integer"
        },
        "document_total": {
          "description": "Exact decimal currency amount; no binary arithmetic. Precision follows capabilities.currencies.",
          "pattern": "^-?[0-9]+(?:\\.[0-9]+)?$",
          "type": "string"
        },
        "payable_amount": {
          "description": "Exact decimal currency amount; no binary arithmetic. Precision follows capabilities.currencies.",
          "pattern": "^-?[0-9]+(?:\\.[0-9]+)?$",
          "type": "string"
        },
        "prepayments": {
          "description": "Exact decimal currency amount; no binary arithmetic. Precision follows capabilities.currencies.",
          "pattern": "^-?[0-9]+(?:\\.[0-9]+)?$",
          "type": "string"
        },
        "rounding_amount": {
          "description": "Exact decimal currency amount; no binary arithmetic. Precision follows capabilities.currencies.",
          "pattern": "^-?[0-9]+(?:\\.[0-9]+)?$",
          "type": "string"
        },
        "settlement_revision": {
          "type": "integer"
        },
        "tax_inclusive_amount": {
          "description": "Exact decimal currency amount; no binary arithmetic. Precision follows capabilities.currencies.",
          "pattern": "^-?[0-9]+(?:\\.[0-9]+)?$",
          "type": "string"
        }
      },
      "type": "object"
    },
    "FinancialMovement": {
      "properties": {
        "actor": {
          "type": [
            "string",
            "null"
          ]
        },
        "amount": {
          "description": "Exact decimal currency amount; no binary arithmetic. Precision follows capabilities.currencies.",
          "pattern": "^-?[0-9]+(?:\\.[0-9]+)?$",
          "type": "string"
        },
        "credit_note_id": {
          "type": "string"
        },
        "credit_note_ids": {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "currency": {
          "enum": [
            "EUR",
            "USD",
            "GBP",
            "JPY"
          ],
          "type": "string"
        },
        "external_id": {
          "type": [
            "string",
            "null"
          ]
        },
        "id": {
          "type": "string"
        },
        "integration_id": {
          "type": [
            "string",
            "null"
          ]
        },
        "kind": {
          "enum": [
            "payment",
            "prepayment",
            "reversal",
            "credit",
            "refund",
            "refund_reversal"
          ],
          "type": "string"
        },
        "method": {
          "type": [
            "string",
            "null"
          ]
        },
        "object": {
          "const": "financial_movement"
        },
        "occurred_at": {
          "description": "Occurrence time, in UTC. A credit occurs at its credit note's issue date.",
          "format": "date-time",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$",
          "type": "string"
        },
        "recorded_at": {
          "description": "UTC, ISO 8601 with milliseconds and Z, e.g. 2026-10-22T10:00:00.123Z.",
          "format": "date-time",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$",
          "type": "string"
        },
        "reference": {
          "maxLength": 500,
          "type": [
            "string",
            "null"
          ]
        },
        "refund_allocations": {
          "items": {
            "properties": {
              "amount": {
                "description": "Exact decimal currency amount; no binary arithmetic. Precision follows capabilities.currencies.",
                "pattern": "^-?[0-9]+(?:\\.[0-9]+)?$",
                "type": "string"
              },
              "payment_id": {
                "type": "string"
              }
            },
            "required": [
              "payment_id",
              "amount"
            ],
            "type": "object"
          },
          "type": "array"
        },
        "reverses": {
          "type": "string"
        }
      },
      "type": "object"
    },
    "Settlement": {
      "description": "Payments include prepayments net of reversals; credits never include cash refunds. Outstanding=max(0,total-credits-payments+refunds); refund_due=max(0,payments-refunds-(total-credits)).",
      "properties": {
        "as_of": {
          "description": "UTC, ISO 8601 with milliseconds and Z, e.g. 2026-10-22T10:00:00.123Z.",
          "format": "date-time",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$",
          "type": "string"
        },
        "credits": {
          "description": "Exact decimal currency amount; no binary arithmetic. Precision follows capabilities.currencies.",
          "pattern": "^-?[0-9]+(?:\\.[0-9]+)?$",
          "type": "string"
        },
        "currency": {
          "type": "string"
        },
        "document_total": {
          "description": "Exact decimal currency amount; no binary arithmetic. Precision follows capabilities.currencies.",
          "pattern": "^-?[0-9]+(?:\\.[0-9]+)?$",
          "type": "string"
        },
        "legacy_reconciliation_required": {
          "type": "boolean"
        },
        "outstanding": {
          "description": "Exact decimal currency amount; no binary arithmetic. Precision follows capabilities.currencies.",
          "pattern": "^-?[0-9]+(?:\\.[0-9]+)?$",
          "type": "string"
        },
        "payments": {
          "description": "Exact decimal currency amount; no binary arithmetic. Precision follows capabilities.currencies.",
          "pattern": "^-?[0-9]+(?:\\.[0-9]+)?$",
          "type": "string"
        },
        "prepayments": {
          "description": "Exact decimal currency amount; no binary arithmetic. Precision follows capabilities.currencies.",
          "pattern": "^-?[0-9]+(?:\\.[0-9]+)?$",
          "type": "string"
        },
        "refund_due": {
          "description": "Exact decimal currency amount; no binary arithmetic. Precision follows capabilities.currencies.",
          "pattern": "^-?[0-9]+(?:\\.[0-9]+)?$",
          "type": "string"
        },
        "refunds": {
          "description": "Exact decimal currency amount; no binary arithmetic. Precision follows capabilities.currencies.",
          "pattern": "^-?[0-9]+(?:\\.[0-9]+)?$",
          "type": "string"
        },
        "revision": {
          "type": "integer"
        },
        "status": {
          "enum": [
            "unpaid",
            "partial",
            "settled",
            "refund_due"
          ],
          "type": "string"
        }
      },
      "type": "object"
    }
  }
}