{
  "openapi": "3.1.0",
  "info": {
    "title": "accountingd — Customer Account Ledger",
    "description": "REST API of the supplier sub-ledger: customer accounts, the Kontokorrent, open items, dunning, SEPA, EEG payouts and payment matching.",
    "contact": {
      "name": "hupe1980"
    },
    "license": {
      "name": "MIT OR Apache-2.0",
      "identifier": "MIT OR Apache-2.0"
    },
    "version": "0.49.0"
  },
  "paths": {
    "/api/v1/accounts/{malo_id}": {
      "get": {
        "tags": [
          "accounts"
        ],
        "summary": "`GET /api/v1/accounts/{malo_id}`",
        "operationId": "get_account",
        "parameters": [
          {
            "name": "malo_id",
            "in": "path",
            "description": "11-digit Marktlokations-ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "mp_id",
            "in": "query",
            "description": "The own MP-ID the account is kept under — the Lieferant's for a\ncustomer, `[eeg] nb_mp_id` for an EEG plant; defaults to the\nconfigured `lf_mp_id`.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `read-account` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "accounts"
        ],
        "summary": "`PUT /api/v1/accounts/{malo_id}`  — upsert account + update fields (IBAN, Abschlag)",
        "operationId": "put_account",
        "parameters": [
          {
            "name": "malo_id",
            "in": "path",
            "description": "11-digit Marktlokations-ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "mp_id",
            "in": "query",
            "description": "The own MP-ID the account is kept under — the Lieferant's for a\ncustomer, `[eeg] nb_mp_id` for an EEG plant; defaults to the\nconfigured `lf_mp_id`.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateAccountRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Done"
          },
          "403": {
            "description": "Cedar `write-account` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/accounts/{malo_id}/abschlaege": {
      "get": {
        "tags": [
          "accounts"
        ],
        "summary": "`GET /api/v1/accounts/{malo_id}/abschlaege`",
        "description": "The advances of one Marktlokation in a period, in exactly the shape a\nsettling invoice deducts them: date, gross amount, and **the VAT rate the\nadvance was raised at** (§ 14 Abs. 5 Satz 2 UStG — an Endrechnung deducts\nthe part-payments *and the tax attributable to them*, and a gross figure\nalone cannot express that when a rate changed mid-year).\n\nThis is the read `billingd`'s § 40b sweep needs to issue a lawful\nJahresrechnung unattended. Without it the sweep refused every annual\nsettlement, because it could not itemise or deduct the advances § 40 Abs. 1\nEnWG requires it to show — the correct refusal, but it left automated annual\nbilling switched off.\n\n**On the service graph.** `accountingd` sits downstream of `billingd` for\n*events* (`de.mako.billing.rechnung.erstellt` → the receivable). This is a read\nin the other direction, at billing time, and it does not invert anything:\nthe advance register is customer-account state that only the ledger holds,\nexactly as SAP IS-U billing reads FI-CA advances. What would invert the\ngraph is `accountingd` computing an invoice, and it does not.\n\nResponse: `[{ \"datum\", \"betrag_eur\", \"ust_satz\", \"beschreibung\" }]` —\n`energy_billing::AbschlagDeduction` verbatim, oldest first, plus\n`reference`, `offen_ct` and `verrechnet_mit` for reconciliation.",
        "operationId": "get_abschlaege",
        "parameters": [
          {
            "name": "malo_id",
            "in": "path",
            "description": "11-digit Marktlokations-ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lf_mp_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "description": "Inclusive lower bound on the advance's `periode` (ISO 8601 date).",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "Inclusive upper bound on the advance's `periode` (ISO 8601 date).",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "include_open",
            "in": "query",
            "description": "Include advances that were demanded but not received, and ones a\nprevious settling invoice already absorbed. Default `false`.\n\nOff by default because the caller is a settling invoice, and\n§ 14 Abs. 5 Satz 2 UStG lets one deduct „die **vereinnahmten**\nTeilentgelte\" — the advances actually received. Deducting a demanded but\nunpaid advance would hand the customer a settlement that credits money\nnobody paid.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "400": {
            "description": "A malformed parameter",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar `read-account` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/accounts/{malo_id}/abschlag": {
      "put": {
        "tags": [
          "accounts"
        ],
        "summary": "`PUT /api/v1/accounts/{malo_id}/abschlag`  — update monthly advance payment",
        "operationId": "put_abschlag",
        "parameters": [
          {
            "name": "malo_id",
            "in": "path",
            "description": "11-digit Marktlokations-ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PutAbschlagRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Done"
          },
          "403": {
            "description": "Cedar `write-account` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/accounts/{malo_id}/anonymize": {
      "post": {
        "tags": [
          "accounts"
        ],
        "summary": "`POST /api/v1/accounts/{malo_id}/anonymize`",
        "description": "Pseudonymize all PII for an account while preserving financial records.\n\n## What is anonymized\n\n- `accounts.iban` → `\"ANONYMIZED\"`\n- `accounts.mandatsref` → `NULL`\n- `accounts.zahlungsinformation` → `NULL`\n- `accounts.vorauszahlung` → `NULL`\n- `sepa_mandates.iban` → `\"ANONYMIZED\"`\n- `sepa_mandates.kontoinhaber` → `\"ANONYMIZED\"`\n- `sepa_mandates.bic` → `NULL`\n\n## What is preserved\n\nAll `ledger_entries` (amounts, dates, types, references) are kept intact.\n`malo_id` is retained (location pseudonym, not personal data per BDEW).\nFinancial records are exempt from GDPR Art. 17 erasure under Art. 17(3)(b)\nand the § 257 Abs. 4 HGB / § 147 Abs. 3 AO retention periods.\n\n## Audit trail\n\nAn immutable record is written to `anonymization_log` for GDPR Art. 5(2)\naccountability.\n\n## Error responses\n\n- `404` — account not found\n- `409` — already anonymized\n- `422` — missing `requested_by` or `legal_basis`",
        "operationId": "post_anonymize",
        "parameters": [
          {
            "name": "malo_id",
            "in": "path",
            "description": "11-digit Marktlokations-ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "mp_id",
            "in": "query",
            "description": "The own MP-ID the account is kept under — the Lieferant's for a\ncustomer, `[eeg] nb_mp_id` for an EEG plant; defaults to the\nconfigured `lf_mp_id`.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AnonymizeRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `erase-pii` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "409": {
            "description": "Conflicts with the current state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/accounts/{malo_id}/balance": {
      "get": {
        "tags": [
          "accounts"
        ],
        "summary": "`GET /api/v1/accounts/{malo_id}/balance` — the open-items balance\n(`crate::reads::balance`, shared with MCP `get_balance`).",
        "operationId": "get_balance",
        "parameters": [
          {
            "name": "malo_id",
            "in": "path",
            "description": "11-digit Marktlokations-ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "mp_id",
            "in": "query",
            "description": "The own MP-ID the account is kept under — the Lieferant's for a\ncustomer, `[eeg] nb_mp_id` for an EEG plant; defaults to the\nconfigured `lf_mp_id`.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The balance",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Kontostand"
                }
              }
            }
          },
          "403": {
            "description": "Cedar `read-account` refused"
          },
          "404": {
            "description": "`account_not_found`"
          }
        }
      }
    },
    "/api/v1/accounts/{malo_id}/buchen": {
      "post": {
        "tags": [
          "accounts"
        ],
        "summary": "`POST /api/v1/accounts/{malo_id}/buchen`",
        "description": "Post a manual ledger entry to a customer account (operator interface).\n\nUse cases:\n- Manual ZAHLUNG credit when a customer pays by bank transfer outside SEPA mandate\n- BANKRUECKLAST debit when a SEPA direct debit is returned by the bank\n- KORREKTUR for operator-authorised adjustments\n- GUTSCHRIFT for one-off credits (e.g. goodwill, §40 EnWG compensation)\n\n## Idempotency\nSupply `reference_id` to make the post idempotent — re-posting with the same\n`reference_id` replays as a ledger no-op. Omit it and each call books a new\nentry under a fresh random key.",
        "operationId": "post_buchen",
        "parameters": [
          {
            "name": "malo_id",
            "in": "path",
            "description": "11-digit Marktlokations-ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BuchenRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `post-entry` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/accounts/{malo_id}/business-partner": {
      "put": {
        "tags": [
          "accounts"
        ],
        "summary": "`PUT /api/v1/accounts/{malo_id}/business-partner` — link an account to a\nvertragd `kunden_nr` so its balance/dunning aggregate with the customer's\nother market locations (FI-CA contract-account model).",
        "operationId": "put_account_business_partner",
        "parameters": [
          {
            "name": "malo_id",
            "in": "path",
            "description": "11-digit Marktlokations-ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lf_mp_id",
            "in": "query",
            "description": "The Lieferant's MP-ID the customer account is kept under; defaults to\nthe configured `lf_mp_id`.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PutBusinessPartnerRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Done"
          },
          "403": {
            "description": "Cedar `write-account` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/accounts/{malo_id}/clear": {
      "post": {
        "tags": [
          "accounts"
        ],
        "summary": "`POST /api/v1/accounts/{malo_id}/clear` — record a FIFO **Zahlungszuordnung**\n(open credits matched against the oldest open debits). Idempotent: matches\nnothing when everything is already assigned.",
        "operationId": "post_clear",
        "parameters": [
          {
            "name": "malo_id",
            "in": "path",
            "description": "11-digit Marktlokations-ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "mp_id",
            "in": "query",
            "description": "The own MP-ID the account is kept under — the Lieferant's for a\ncustomer, `[eeg] nb_mp_id` for an EEG plant; defaults to the\nconfigured `lf_mp_id`.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `post-entry` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/accounts/{malo_id}/interest-charges": {
      "get": {
        "tags": [
          "accounts"
        ],
        "summary": "`GET /api/v1/accounts/{malo_id}/interest-charges` — list interest charges.",
        "operationId": "get_interest_charges",
        "parameters": [
          {
            "name": "malo_id",
            "in": "path",
            "description": "11-digit Marktlokations-ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lf_mp_id",
            "in": "query",
            "description": "The Lieferant's MP-ID the customer account is kept under; defaults to\nthe configured `lf_mp_id`.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `read-account` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "accounts"
        ],
        "summary": "`POST /api/v1/accounts/{malo_id}/interest-charges` — calculate and book Verzugszinsen.",
        "description": "Calculates interest per §288 BGB against the §247 BGB Basiszinssatz in force\non `period_from`, read from `ecb_base_rates`, at the Absatz the account's\nrecorded Verbraucher status decides (`accounts.verbraucher`, from the\nvertragd contract) — the request does not state it. Creates a `VERZUGSZINSEN`\nledger entry — §275 HGB reports Zinsen on their own line — and records the\ncharge in `interest_charges` for audit. Fails when no Basiszinssatz is\nseeded for the period: the rate is announced, not estimated.",
        "operationId": "post_interest_charge",
        "parameters": [
          {
            "name": "malo_id",
            "in": "path",
            "description": "11-digit Marktlokations-ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateInterestChargeRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "400": {
            "description": "A malformed parameter",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar `post-entry` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/accounts/{malo_id}/kontoauszug": {
      "get": {
        "tags": [
          "accounts"
        ],
        "summary": "`GET /api/v1/accounts/{malo_id}/kontoauszug`  — account statement (portald-consumable)",
        "operationId": "get_kontoauszug",
        "parameters": [
          {
            "name": "malo_id",
            "in": "path",
            "description": "11-digit Marktlokations-ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "mp_id",
            "in": "query",
            "description": "The own MP-ID the account is kept under — the Lieferant's for a\ncustomer, `[eeg] nb_mp_id` for an EEG plant; defaults to the\nconfigured `lf_mp_id`.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "description": "Inclusive start of the statement period (ISO 8601 date).",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "Inclusive end of the statement period (ISO 8601 date).",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `read-account` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/accounts/{malo_id}/ledger": {
      "get": {
        "tags": [
          "accounts"
        ],
        "summary": "`GET /api/v1/accounts/{malo_id}/ledger` — the newest movements with the\nbalance the window opens at (`crate::reads::ledger`, shared with MCP\n`list_ledger`).",
        "operationId": "get_ledger",
        "parameters": [
          {
            "name": "malo_id",
            "in": "path",
            "description": "11-digit Marktlokations-ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "mp_id",
            "in": "query",
            "description": "The own MP-ID the account is kept under — the Lieferant's for a\ncustomer, `[eeg] nb_mp_id` for an EEG plant; defaults to the\nconfigured `lf_mp_id`.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum movements, newest first (default 100, at most 1000); what is\ncut off is folded into `opening_ct`.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The statement window",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Kontoauszug"
                }
              }
            }
          },
          "403": {
            "description": "Cedar `read-account` refused"
          },
          "404": {
            "description": "`account_not_found`"
          }
        }
      }
    },
    "/api/v1/accounts/{malo_id}/locks": {
      "post": {
        "tags": [
          "accounts"
        ],
        "summary": "`POST /api/v1/accounts/{malo_id}/locks` — the same lock, placed on the\naccount rather than through one of its dunning cases.",
        "description": "For a ground known before any Mahnung: an Insolvenz (§ 87 InsO) has to stop\nMahnstufe 1 from being opened at all, and an account without a case has no\ncase to name.",
        "operationId": "place_account_lock",
        "parameters": [
          {
            "name": "malo_id",
            "in": "path",
            "description": "11-digit Marktlokations-ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lf_mp_id",
            "in": "query",
            "description": "The Lieferant's MP-ID the customer account is kept under; defaults to\nthe configured `lf_mp_id`.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PlaceLockRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `manage-dunning` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "409": {
            "description": "Conflicts with the current state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/accounts/{malo_id}/open-items": {
      "get": {
        "tags": [
          "accounts"
        ],
        "summary": "`GET /api/v1/accounts/{malo_id}/open-items`",
        "description": "Returns all unpaid or partially-paid debit entries for this account,\ncomputed via **FIFO clearing** of available credits against oldest debits.\n\n## What is an \"open item\"?\n\nAn open item (Offener Posten) is an individual RECHNUNG, STORNO, MAHNGEBUEHR,\nor ABSCHLAG debit that has not been fully covered by ZAHLUNG/GUTSCHRIFT credits.\n\n## Why not just use `balance_ct`?\n\n`balance_ct` tells you the total outstanding amount but not *which* invoices\nare unpaid. Open-item management answers: \"Invoice R2026-01 is unpaid;\nInvoice R2025-12 is partially paid (€42 remaining).\"\n\n## FIFO clearing\n\nPayments are applied to the oldest debits first. This matches:\n- Standard European utility billing practice (§252 HGB Vorsichtsprinzip)\n- SAP FI-CA default (oldest-first clearing)\n\n## Response\n\n```json\n[\n  { \"id\": \"...\", \"entry_type\": \"RECHNUNG\", \"amount_ct\": 15000,\n    \"outstanding_ct\": 7500, \"reference_id\": \"R2026-01\",\n    \"booking_date\": \"2026-01-15\", \"description\": \"Kundenrechnung\" }\n]\n```",
        "operationId": "get_open_items",
        "parameters": [
          {
            "name": "malo_id",
            "in": "path",
            "description": "11-digit Marktlokations-ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "mp_id",
            "in": "query",
            "description": "The own MP-ID the account is kept under — the Lieferant's for a\ncustomer, `[eeg] nb_mp_id` for an EEG plant; defaults to the\nconfigured `lf_mp_id`.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `read-account` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/accounts/{malo_id}/payment-plans": {
      "get": {
        "tags": [
          "accounts"
        ],
        "summary": "`GET /api/v1/accounts/{malo_id}/payment-plans` — list payment plans for a MaLo.",
        "operationId": "get_payment_plans",
        "parameters": [
          {
            "name": "malo_id",
            "in": "path",
            "description": "11-digit Marktlokations-ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lf_mp_id",
            "in": "query",
            "description": "The Lieferant's MP-ID the customer account is kept under; defaults to\nthe configured `lf_mp_id`.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `read-account` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "accounts"
        ],
        "summary": "`POST /api/v1/accounts/{malo_id}/payment-plans` — create a Zahlungsvereinbarung.",
        "description": "Creates a structured payment plan with an auto-generated installment schedule.\nAn ACTIVE plan suppresses automatic Sperrung escalation (Mahnstufe 3).",
        "operationId": "post_payment_plan",
        "parameters": [
          {
            "name": "malo_id",
            "in": "path",
            "description": "11-digit Marktlokations-ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreatePaymentPlanRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `post-entry` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/accounts/{malo_id}/reconcile": {
      "post": {
        "tags": [
          "accounts"
        ],
        "summary": "`POST /api/v1/accounts/{malo_id}/reconcile`",
        "description": "Detect (and optionally repair) a `balance_ct` cache drift.\n\n`balance_ct` is a denormalized cache maintained by the `write_entry` transaction.\nA crash between `INSERT ledger_entries` and `UPDATE accounts SET balance_ct` could\nleave the cache stale. This endpoint detects the drift and, with `?repair=true`,\natomically resets `balance_ct` to `SUM(ledger_entries.amount_ct)`.\n\n## Response\n\n```json\n{\n  \"is_consistent\": true,\n  \"cached_balance_ct\": 5000,\n  \"recomputed_balance_ct\": 5000,\n  \"drift_ct\": 0\n}\n```\n\nA non-zero `drift_ct` indicates a bug and must be investigated before repair.\nThis endpoint is idempotent: running it multiple times with `repair=true` is safe.",
        "operationId": "post_reconcile",
        "parameters": [
          {
            "name": "malo_id",
            "in": "path",
            "description": "11-digit Marktlokations-ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "mp_id",
            "in": "query",
            "description": "The own MP-ID the account is kept under — the Lieferant's for a\ncustomer, `[eeg] nb_mp_id` for an EEG plant; defaults to the\nconfigured `lf_mp_id`.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "repair",
            "in": "query",
            "description": "When `true`, resets `balance_ct` to the recomputed value (safe, transactional).",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `post-entry` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/accounts/{malo_id}/verbraucher": {
      "put": {
        "tags": [
          "accounts"
        ],
        "summary": "`PUT /api/v1/accounts/{malo_id}/verbraucher` — the § 13 BGB status of the\naccount, as the vertragd contract records it.",
        "description": "One writer: Cedar `sync-verbraucher` is held to vertragd's service\nprincipal, because the status decides the § 288 Abs. 2 BGB Verzugszins and\nthe Abs. 5 Pauschale and the contract is its one source. An operator token\ncannot set it here, and `PUT /api/v1/accounts/{malo_id}` does not carry it.\nCreates the account when it is not there yet.",
        "operationId": "put_account_verbraucher",
        "parameters": [
          {
            "name": "malo_id",
            "in": "path",
            "description": "11-digit Marktlokations-ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lf_mp_id",
            "in": "query",
            "description": "The Lieferant's MP-ID the customer account is kept under; defaults to\nthe configured `lf_mp_id`.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SetVerbraucherRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Done"
          },
          "403": {
            "description": "Cedar `sync-verbraucher` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/accounts/{malo_id}/vorauszahlung": {
      "get": {
        "tags": [
          "accounts"
        ],
        "summary": "`GET /api/v1/accounts/{malo_id}/vorauszahlung`",
        "description": "Retrieve the stored BO4E `Vorauszahlung` for an account.\n\nFalls back to synthesising a `Vorauszahlung` from `abschlag_ct` when no\ntyped record has been stored ([`vorauszahlung_view`]).",
        "operationId": "get_vorauszahlung",
        "parameters": [
          {
            "name": "malo_id",
            "in": "path",
            "description": "11-digit Marktlokations-ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lf_mp_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `read-account` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "No account for that Marktlokation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "accounts"
        ],
        "summary": "`PUT /api/v1/accounts/{malo_id}/vorauszahlung`",
        "description": "Store or replace the BO4E `Vorauszahlung` COM for an account.\n\nBody: `rubo4e::current::Vorauszahlung` JSON (camelCase).\n\nValidation:\n- Read as `Bo4e<rubo4e::current::Vorauszahlung>`, so the BO4E gate runs as\n  the body deserialises; the canonical round-trip is what is stored.\n- `abschlag_ct` is updated atomically from `betrag.wert` (EUR → ct × 100)\n  so the existing Abschlagslauf scheduler continues to work.\n\nQuery parameter: `?lf_mp_id=<mp_id>` (defaults to the configured `lf_mp_id`).\n\n§40 Abs. 1 EnWG: Abschlag must match estimated consumption.\nTyped `Vorauszahlung` enables `portald` Jahresabschluss preview and\nauto-adjustment when deviation exceeds 10 %.",
        "operationId": "put_vorauszahlung",
        "parameters": [
          {
            "name": "malo_id",
            "in": "path",
            "description": "11-digit Marktlokations-ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lf_mp_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "The BO4E `Vorauszahlung` object (`Bo4e<…>`)",
          "content": {
            "application/json": {
              "schema": {}
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Done"
          },
          "403": {
            "description": "Cedar `write-account` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/accounts/{malo_id}/zahlungsinformation": {
      "get": {
        "tags": [
          "accounts"
        ],
        "summary": "`GET /api/v1/accounts/{malo_id}/zahlungsinformation`",
        "description": "Retrieve the stored `Zahlungsinformation` for an account.\nFalls back to a minimal object from `accounts.iban` when no typed payload has\nbeen PUT yet (backward-compatible with legacy IBAN-only mandates).",
        "operationId": "get_zahlungsinformation",
        "parameters": [
          {
            "name": "malo_id",
            "in": "path",
            "description": "11-digit Marktlokations-ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "mp_id",
            "in": "query",
            "description": "The own MP-ID the account is kept under — the Lieferant's for a\ncustomer, `[eeg] nb_mp_id` for an EEG plant; defaults to the\nconfigured `lf_mp_id`.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `read-banking` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "No account for that Marktlokation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "accounts"
        ],
        "summary": "`PUT /api/v1/accounts/{malo_id}/zahlungsinformation`",
        "description": "Store or replace the BO4E `Zahlungsinformation` COM for an account.\n\nBody: `rubo4e::current::Zahlungsinformation` JSON (camelCase).\nAccepts: `iban`, `bic`, `kontoinhaber`, `sepaReferenz`, `zahlungsart`.\n\nSide effects:\n- Validates IBAN via mod-97 before storing.\n- Atomically syncs `accounts.iban` column from `typed.iban` so that\n  `import_payments` (CAMT.054) matching continues to work.",
        "operationId": "put_zahlungsinformation",
        "parameters": [
          {
            "name": "malo_id",
            "in": "path",
            "description": "11-digit Marktlokations-ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "mp_id",
            "in": "query",
            "description": "The own MP-ID the account is kept under — the Lieferant's for a\ncustomer, `[eeg] nb_mp_id` for an EEG plant; defaults to the\nconfigured `lf_mp_id`.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "The BO4E `Zahlungsinformation` object (`Bo4e<…>`)",
          "content": {
            "application/json": {
              "schema": {}
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `write-account` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/aging": {
      "get": {
        "tags": [
          "books"
        ],
        "summary": "`GET /api/v1/aging` — open-receivables aging report.",
        "description": "Groups overdue account balances into four buckets:\n`0-30d` · `31-60d` · `61-90d` · `>90d`\n\nUses the oldest unresolved dunning case issued_at as the \"overdue since\" date\nwhen present; falls back to `accounts.updated_at` otherwise.",
        "operationId": "get_aging",
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `read-books` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/bookings/{key}/discard": {
      "post": {
        "tags": [
          "books"
        ],
        "summary": "`POST /api/v1/bookings/{key}/discard` — drop a parked draft with a reason.",
        "operationId": "post_discard",
        "parameters": [
          {
            "name": "key",
            "in": "path",
            "description": "The parked booking's key",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DiscardRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `post-entry` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/bookings/{key}/rebook": {
      "post": {
        "tags": [
          "books"
        ],
        "summary": "`POST /api/v1/bookings/{key}/rebook` — book a parked draft on an open date.",
        "description": "The successor draft and the retirement of the parked one commit together;\nthe successor is then booked, and answers as the ledger does.",
        "operationId": "post_rebook",
        "parameters": [
          {
            "name": "key",
            "in": "path",
            "description": "The parked booking's key",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RebookRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "400": {
            "description": "A malformed parameter",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar `post-entry` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "409": {
            "description": "Conflicts with the current state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/business-partners/{kunden_nr}/accounts": {
      "get": {
        "tags": [
          "accounts"
        ],
        "summary": "`GET /api/v1/business-partners/{kunden_nr}/accounts` — all accounts.",
        "operationId": "get_bp_accounts",
        "parameters": [
          {
            "name": "kunden_nr",
            "in": "path",
            "description": "vertragd Kundennummer",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `read-account` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/business-partners/{kunden_nr}/balance": {
      "get": {
        "tags": [
          "accounts"
        ],
        "summary": "`GET /api/v1/business-partners/{kunden_nr}/balance` — consolidated balance.",
        "operationId": "get_bp_balance",
        "parameters": [
          {
            "name": "kunden_nr",
            "in": "path",
            "description": "vertragd Kundennummer",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `read-account` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/clearings/{position}/reset": {
      "post": {
        "tags": [
          "books"
        ],
        "summary": "`POST /api/v1/clearings/{position}/reset` — release one Zahlungszuordnung; the\napplied amount returns to both postings' residuals (the clearing record stays).",
        "operationId": "post_reset_clearing",
        "parameters": [
          {
            "name": "position",
            "in": "path",
            "description": "The clearing's log position",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `post-entry` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/credit-payouts": {
      "get": {
        "tags": [
          "books"
        ],
        "summary": "`GET /api/v1/credit-payouts` — the Guthaben Schlussrechnungen owe back,\nearliest due date first, each saying whether it is overdue\n(`crate::guthaben::list`, shared with MCP `list_credit_payouts`).\n`?overdue=true` is the Desk's Heute source.",
        "operationId": "get_credit_payouts",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "description": "Only items in this state (default `open`).",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/Status"
            }
          },
          {
            "name": "overdue",
            "in": "query",
            "description": "Only open items past their due date.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "malo_id",
            "in": "query",
            "description": "Restrict to one Marktlokation.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum rows (default 100, at most 1000).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The payout items",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Guthabenauszahlungen"
                }
              }
            }
          },
          "403": {
            "description": "Cedar `read-books` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/credit-payouts/{payout_id}/paid": {
      "post": {
        "tags": [
          "books"
        ],
        "summary": "`POST /api/v1/credit-payouts/{payout_id}/paid` — book the transfer of a\nGuthaben and close its item, in one transaction; an item is paid once\n(`crate::guthaben::pay`).",
        "operationId": "post_credit_payout_paid",
        "parameters": [
          {
            "name": "payout_id",
            "in": "path",
            "description": "The payout item",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PaidRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Booked and closed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GuthabenAusgezahlt"
                }
              }
            }
          },
          "403": {
            "description": "Cedar `post-entry` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "`credit_payout_not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "409": {
            "description": "`credit_payout_not_open` — paid or cancelled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "`invalid_date`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/dunning": {
      "get": {
        "tags": [
          "books"
        ],
        "summary": "`GET /api/v1/dunning` — the open dunning cases, newest Mahnung first\n(`crate::reads::dunning`, shared with MCP `list_dunning`).",
        "operationId": "get_dunning",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum cases (default 100, at most 1000).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The open cases",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Mahnfaelle"
                }
              }
            }
          },
          "403": {
            "description": "Cedar `read-books` refused"
          }
        }
      }
    },
    "/api/v1/dunning/locks/review": {
      "get": {
        "tags": [
          "dunning"
        ],
        "summary": "`GET /api/v1/dunning/locks/review?older_than_days=90` — open-ended locks.",
        "description": "§ 41f Abs. 2 contemplates circumstances with no foreseeable end and equally\nmakes them reviewable, so an unbounded lock is allowed but surfaced here.",
        "operationId": "get_locks_due_review",
        "parameters": [
          {
            "name": "older_than_days",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `read-books` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/dunning/locks/{lock_id}": {
      "delete": {
        "tags": [
          "dunning"
        ],
        "summary": "`DELETE /api/v1/dunning/locks/{lock_id}` — lift a lock, with a reason.",
        "description": "Lifting for **`vereinbarung_gebrochen`** is § 41g Abs. 1 S. 11: the supplier\nmay resume, but must re-observe § 41f Abs. 1 S. 2 **and Abs. 5**, so the\nAnkündigung state is cleared and the case returns to a *fresh* 8-Werktage\nannouncement. Any other reason leaves the announcement standing.",
        "operationId": "lift_lock",
        "parameters": [
          {
            "name": "lock_id",
            "in": "path",
            "description": "The lock",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LiftLockRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "204": {
            "description": "Done"
          },
          "403": {
            "description": "Cedar `manage-dunning` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "No such lock",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/dunning/{account_id}/escalate": {
      "post": {
        "tags": [
          "dunning"
        ],
        "summary": "`POST /api/v1/dunning/{account_id}/escalate`  — manual dunning escalation",
        "operationId": "escalate_dunning",
        "parameters": [
          {
            "name": "account_id",
            "in": "path",
            "description": "The account",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EscalateDunningRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `manage-dunning` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "No such account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/dunning/{id}/abwendung/angebot": {
      "post": {
        "tags": [
          "dunning"
        ],
        "summary": "`POST /api/v1/dunning/{id}/abwendung/angebot` — § 41g Abs. 1 S. 2 EnWG.",
        "description": "Records that the Grundversorger's **offer** went out, and emits\n`de.mako.accounting.abwendung.angeboten` with the interest-free instalment terms.\n\nOwed within **one week** of the customer demanding it after the Androhung, and\nno later than the Ankündigung. Recorded separately from acceptance because it\nis the only evidence the obligation was met — a supplier that never offered\nand one that offered and was refused are otherwise indistinguishable.\n\nThe instalment period follows § 41g Abs. 1 S. 7–9: **6 to 18 months** in\ngeneral, and **12 to 24 months** once the arrears exceed 300 EUR.",
        "operationId": "abwendung_angebot",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The dunning case",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Done"
          },
          "403": {
            "description": "Cedar `manage-dunning` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "No such dunning case",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "409": {
            "description": "Conflicts with the current state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/dunning/{id}/einwaende": {
      "get": {
        "tags": [
          "dunning"
        ],
        "summary": "`GET /api/v1/dunning/{id}/einwaende` — every objection on this account.",
        "operationId": "get_einwaende",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The dunning case",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `read-books` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "No such dunning case",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "dunning"
        ],
        "summary": "`POST /api/v1/dunning/{id}/einwaende` — § 41f Abs. 3 S. 3–5 EnWG.",
        "description": "Record an amount that must stay **out of the Verzug calculation**: a claim\ndisputed form- und fristgerecht and schlüssig, a disputed price increase, a\nclaim before a § 111b Schlichtungsverfahren, or instalments not yet due.\n\nNot a lock: it does not halt the sequence, it reduces the number the § 41f\nAbs. 3 gates are measured against, and the sequence stops by itself when what\nremains falls below them.",
        "operationId": "place_einwand",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The dunning case",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EinwandRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `manage-dunning` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "No such dunning case",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/dunning/{id}/locks": {
      "get": {
        "tags": [
          "dunning"
        ],
        "summary": "`GET /api/v1/dunning/{id}/locks` — every lock this account has carried.",
        "operationId": "get_locks",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The dunning case",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `read-books` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "dunning"
        ],
        "summary": "`POST /api/v1/dunning/{id}/locks` — stop dunning this account, and say why.",
        "description": "One endpoint for every §§41f/41g halt. A lock carries its ground, its\ncitation, a validity period and the operator who set it, and is lifted by\n`DELETE .../locks/{lock_id}` with a reason — because § 41g Abs. 1 S. 11 lets\nthe supplier resume after a broken agreement, and § 41f Abs. 2 makes the\nGefahr *auf Verlangen glaubhaft zu machen*, hence reviewable.",
        "operationId": "place_lock",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The dunning case",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PlaceLockRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `manage-dunning` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "No such dunning case",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "409": {
            "description": "Conflicts with the current state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/dunning/{id}/resolve": {
      "post": {
        "tags": [
          "dunning"
        ],
        "summary": "`POST /api/v1/dunning/{id}/resolve`",
        "operationId": "resolve_dunning",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The dunning case",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Done"
          },
          "403": {
            "description": "Cedar `manage-dunning` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "No such dunning case",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/eeg/aufrechnungen": {
      "post": {
        "tags": [
          "eeg"
        ],
        "summary": "`POST /api/v1/eeg/aufrechnungen` — record that a plant operator's EEG claim\nwas extinguished by Aufrechnung against the named Gegenforderung.",
        "operationId": "post_eeg_aufrechnung",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AufrechnungRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `record-aufrechnung` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "409": {
            "description": "Conflicts with the current state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/eeg/enfg-zahlungen": {
      "get": {
        "tags": [
          "eeg"
        ],
        "summary": "`GET /api/v1/eeg/enfg-zahlungen?year=&month=` — the EEG/KWKG payments made\nfor one billing month: payouts the bank settled (`ACSC`) and Aufrechnungen\n(§ 13 Abs. 1 Satz 2 EnFG), and nothing that is merely owed. `einsd` builds\nits EnFG ledger from this.",
        "operationId": "get_enfg_zahlungen",
        "parameters": [
          {
            "name": "year",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "month",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `read-enfg` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/eeg/payouts": {
      "get": {
        "tags": [
          "eeg"
        ],
        "summary": "`GET /api/v1/eeg/payouts` — the EEG payout orders, newest first\n(`crate::reads::eeg_payouts`, shared with MCP `list_eeg_payouts`).",
        "description": "`?status=PDNG` finds orders awaiting pain.002 confirmation, `?status=RJCT`\nthe rejected ones (EPC reason codes), `?tr_id=` one plant's orders.",
        "operationId": "get_eeg_payouts",
        "parameters": [
          {
            "name": "malo_id",
            "in": "query",
            "description": "Restrict to one plant's MaLo.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tr_id",
            "in": "query",
            "description": "Restrict to one plant (Technische Ressource).",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "year",
            "in": "query",
            "description": "Billing year of the receipt chain paid.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "month",
            "in": "query",
            "description": "Billing month (1–12) of the receipt chain paid.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "pain.002 status (`PDNG`, `ACCP`, `ACSC`, `RJCT`, `CANC`, …), or `NULL`\nfor orders not yet submitted.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "payment_type",
            "in": "query",
            "description": "`SCT_INST` or `SCT_CORE`.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum rows (default 100, at most 1000).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The payout orders",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EegAuszahlungen"
                }
              }
            }
          },
          "403": {
            "description": "Cedar `read-eeg-payouts` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/eeg/payouts/run": {
      "post": {
        "tags": [
          "eeg"
        ],
        "summary": "`POST /api/v1/eeg/payouts/run`",
        "description": "Pay every receipt chain of one billing month — Vergütung and Marktprämie —\nwhat it has outstanding — the chain's current receipt less what was already paid or\nordered for it (`crate::eeg_auszahlung`). Each order carries the plant and\nbilling month of the receipt it pays, so the EnFG ledger can attribute it;\na chain already paid gets nothing, so a re-run is safe, and a chain whose\norder the bank rejected is paid again.\n\nThis is the operator-triggered path; under `[eeg].auto_payout = true` each\nreceipt is paid as it arrives, by the same rule.\n\nReturns `generated`, `skipped_no_iban`, `nothing_outstanding` and\n`errors`, the last naming each chain whose order could not be built.",
        "operationId": "post_run_eeg_payouts",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RunEegPayoutsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `run-payout` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "503": {
            "description": "`eeg_debtor_not_configured` — `[eeg] debtor_iban` or `debtor_name` is not set",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/eeg/payouts/{payout_id}": {
      "get": {
        "tags": [
          "eeg"
        ],
        "summary": "`GET /api/v1/eeg/payouts/{payout_id}` — get a single payout order with pain.001 XML.",
        "operationId": "get_eeg_payout",
        "parameters": [
          {
            "name": "payout_id",
            "in": "path",
            "description": "The payout order",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `read-eeg-payouts` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "No such payout order",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/eeg/payouts/{payout_id}/status": {
      "put": {
        "tags": [
          "eeg"
        ],
        "summary": "`PUT /api/v1/eeg/payouts/{payout_id}/status`",
        "description": "Record a pain.002 status report for a payout order.\n`ACCP` / `ACSC` → sets `settled_at = now()`; `ACSC` — the funds moved — also\nbooks the payment on the plant's Kontokorrent (`EEG_AUSZAHLUNG`), once.\n`RJCT` / `CANC` → sets `pain002_reason` for audit; emits\n`de.mako.accounting.eeg.payout.rejected` CloudEvent if ERP webhook is configured.\nA settled order stays settled: a later status is `409` — money returned\nafter settlement arrives as a camt return, not as a pain.002.",
        "operationId": "put_eeg_payout_status",
        "parameters": [
          {
            "name": "payout_id",
            "in": "path",
            "description": "The payout order",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Pain002StatusUpdate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Done"
          },
          "403": {
            "description": "Cedar `run-payout` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "No such payout order",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "409": {
            "description": "Conflicts with the current state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/eeg/rueckforderungen": {
      "get": {
        "tags": [
          "eeg"
        ],
        "summary": "`GET /api/v1/eeg/rueckforderungen` — every receipt chain whose plant\noperator owes money back: a correction lowered the period below what was\nalready paid or ordered for it, less what the operator paid back\n(`POST /api/v1/eeg/rueckzahlungen`). `rueckforderung_ct` is the difference.",
        "description": "The only place such a claim is served: an EEG plant account is never an\nOffener Posten and never dunned. Held to `read-enfg` — the claim is the\nNetzbetreiber's, like the payout it reverses.",
        "operationId": "get_eeg_rueckforderungen",
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `read-enfg` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/eeg/rueckzahlungen": {
      "post": {
        "tags": [
          "eeg"
        ],
        "summary": "`POST /api/v1/eeg/rueckzahlungen` — record what a plant operator paid back\nof an overpaid receipt chain (`GET /api/v1/eeg/rueckforderungen`).",
        "description": "The repayment is booked `EEG_RUECKZAHLUNG` on the plant's Kontokorrent and\ncounted against the chain, so a repaid chain leaves the Rückforderungen.\nMore than the chain owes back is `422`, a chain owing nothing `422`, a\nsecond repayment of the chain on the same day `409`.",
        "operationId": "post_eeg_rueckzahlung",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RueckzahlungRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `record-rueckzahlung` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "409": {
            "description": "Conflicts with the current state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/einwaende/{einwand_id}/erledigen": {
      "post": {
        "tags": [
          "dunning"
        ],
        "summary": "`POST /api/v1/einwaende/{einwand_id}/erledigen` — close an objection.",
        "description": "The amount re-enters the § 41f Abs. 3 Verzug from this point, whichever way it\nwas decided: upheld means the claim was reduced or written off (and the\nposting that does so is what removes it from the arrears), withdrawn or\nrejected means it was owed all along.",
        "operationId": "close_einwand",
        "parameters": [
          {
            "name": "einwand_id",
            "in": "path",
            "description": "The objection",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CloseEinwandRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Done"
          },
          "403": {
            "description": "Cedar `manage-dunning` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "No such objection",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/entries/consistency-proof": {
      "get": {
        "tags": [
          "books"
        ],
        "summary": "`GET /api/v1/entries/consistency-proof?since=N` — proves the log has only\nbeen appended to since it held `N` records.",
        "description": "An inclusion proof on its own says the ledger is internally consistent *now*,\nwhich a rebuilt ledger would satisfy just as well. This is the half that makes\nthe log append-only in the eyes of someone who was here before: they check it\nagainst the head they archived and the head returned here.",
        "operationId": "get_consistency_proof",
        "parameters": [
          {
            "name": "since",
            "in": "query",
            "description": "The tree size the auditor archived on an earlier visit.",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "400": {
            "description": "A malformed parameter",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar `read-books` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/entries/{entry_id}/proof": {
      "get": {
        "tags": [
          "books"
        ],
        "summary": "`GET /api/v1/entries/{entry_id}/proof` — a Merkle inclusion proof that the\nentry is in the log, with the head it verifies against (RFC 6962).",
        "operationId": "get_entry_proof",
        "parameters": [
          {
            "name": "entry_id",
            "in": "path",
            "description": "The ledger entry",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "400": {
            "description": "A malformed parameter",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar `read-books` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "No such entry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/jahresabschluss/{malo_id}": {
      "post": {
        "tags": [
          "accounts"
        ],
        "summary": "`POST /api/v1/jahresabschluss/{malo_id}` — the operator-driven settlement.",
        "description": "A thin shell over [`settle_jahresabschluss`], which the annual worker also\ndrives. One implementation, because a settlement an operator triggers and\none a schedule triggers must produce the same postings, the same refund and\nthe same event — and a second copy of two hundred lines of money handling is\nhow they stop doing that.",
        "operationId": "post_jahresabschluss",
        "parameters": [
          {
            "name": "malo_id",
            "in": "path",
            "description": "11-digit Marktlokations-ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lf_mp_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "year",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "dry_run",
            "in": "query",
            "description": "When `true`, returns the computed settlement without committing any entries.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `close-period` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/offene-posten": {
      "get": {
        "tags": [
          "books"
        ],
        "summary": "`GET /api/v1/offene-posten` — the accounts with an open balance, largest\nfirst (`crate::reads::overdue`, shared with MCP `list_overdue`). A\ntenant-wide book read, so Cedar `read-books`.",
        "operationId": "get_offene_posten",
        "parameters": [
          {
            "name": "min_balance_eur",
            "in": "query",
            "description": "Minimum balance in EUR, as a decimal string (e.g. `\"1.99\"`). Default: 1 ct minimum.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum accounts (default 100, at most 1000).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The accounts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UeberfaelligeKonten"
                }
              }
            }
          },
          "403": {
            "description": "Cedar `read-books` refused"
          },
          "422": {
            "description": "`invalid_min_balance`"
          }
        }
      }
    },
    "/api/v1/payment-plans/{plan_id}": {
      "get": {
        "tags": [
          "accounts"
        ],
        "summary": "`GET /api/v1/payment-plans/{plan_id}` — get a payment plan with installments.",
        "operationId": "get_payment_plan",
        "parameters": [
          {
            "name": "plan_id",
            "in": "path",
            "description": "The payment plan",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `read-account` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "No such payment plan",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "accounts"
        ],
        "summary": "`DELETE /api/v1/payment-plans/{plan_id}` — cancel a payment plan.",
        "operationId": "delete_payment_plan",
        "parameters": [
          {
            "name": "plan_id",
            "in": "path",
            "description": "The payment plan",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Done"
          },
          "403": {
            "description": "Cedar `post-entry` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/payments/import": {
      "post": {
        "tags": [
          "payments"
        ],
        "summary": "`POST /api/v1/payments/import`  — ingest a **flat bank export** (JSON array).",
        "description": "Each row: `{ \"iban\": \"...\", \"amount_eur\": \"155.42\", \"reference\": \"...\", \"date\": \"YYYY-MM-DD\",\n            \"bank_transaction_id\": \"...\", \"end_to_end_id\": \"...\", \"return_reason_code\": \"...\" }`\n\nParsed by [`crate::sepa::BankStatementEntry`] — amounts through\n`sepa::ct_from_eur_str` (integer ct, **no f64**), dates through\n`sepa::IsoDate`. The shape is accountingd's own import contract, not an ISO\n20022 message: prefer `POST /api/v1/payments/import/camt054` wherever the\nbank offers real camt, because `EndToEndId`, the `Btch` block and return\nreason codes do not survive a flattening.\n\nA row gives money back when it carries a `return_reason_code` **or** a\nnegative `amount_eur` → `BANKRUECKLAST` debit; anything else is a `ZAHLUNG`\ncredit. The sign is flipped into the ledger's open-items convention by\n`sepa::bank_to_ledger_ct`, the same single conversion the camt paths use.\n\n## Deduplication\n\nEach row is checked against `bank_import_log` before processing.\nIf `bank_transaction_id` is present and already imported, the row is skipped\nand counted as `deduplicated` — no duplicate ledger entries are created.\nWhen `bank_transaction_id` is absent, a stable hash of (iban+amount+date+reference)\nis used as the deduplication key.\n\n`skipped` is a total; the summary breaks it down into `malformed` (the row\ncould not be read), `unmatched` (no account claims it) and `failed` (the\nlookup or the ledger write errored). They call for different responses, and\na single number cannot tell a quiet day from a broken database.",
        "operationId": "import_payments",
        "requestBody": {
          "description": "The bank export rows",
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {}
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `import-payments` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/payments/import/camt052": {
      "post": {
        "tags": [
          "payments"
        ],
        "summary": "`POST /api/v1/payments/import/camt052` — ingest a **camt.052 XML report**\n(Bank-to-Customer Account Report), the bank's intraday view.",
        "description": "The door for a bank that offers intraday reporting as camt.052 rather than\ncamt.054 notifications — a common pairing with an end-of-day camt.053, and\none mako had no way to read at all.\n\n## Provisional by design\n\ncamt.052 reports movements *during* the business day, and its entries are\nprovisional: an entry that is `PDNG` now may be booked, amended or dropped by\nthe time the statement arrives. An append-only ledger cannot un-book a\nposting, so only entries the bank has marked `BOOK` are posted here. The rest\nare counted as `not_booked` and reported back — normally the majority of an\nintraday file, and not an error.\n\nThe booked ones are safe to take early: the same transaction arriving again\nin the evening's camt.053 carries the same `AcctSvcrRef`, so the ledger\nidempotency key makes the second import a no-op.\n\nInterim balances (`ITBD`) are returned rather than posted — a receivables\nledger has no place to put a treasury figure.",
        "operationId": "import_payments_camt052",
        "requestBody": {
          "description": "The camt.052 document exactly as the bank delivers it",
          "content": {
            "application/xml": {
              "schema": {
                "type": "string"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `import-payments` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/payments/import/camt053": {
      "post": {
        "tags": [
          "payments"
        ],
        "summary": "`POST /api/v1/payments/import/camt053` — ingest a **camt.053 XML statement**\n(Bank-to-Customer Statement), the end-of-day record of the operator's own\naccount.",
        "description": "Bookings follow the same rules as the camt.054 import; what a statement adds\nis the balance set. The reported closing balance is\nreturned alongside the import counters so an operator — or the reconciliation\nagent — can compare the bank's own closing figure against the ledger without\na second request.\n\nRunning both imports is safe: `bank_import_log` and the ledger idempotency\nkey are keyed on the bank's transaction reference, so a transaction notified\nintraday by camt.054 and again in the evening's camt.053 books once.",
        "operationId": "import_payments_camt053",
        "requestBody": {
          "description": "The camt.053 document exactly as the bank delivers it",
          "content": {
            "application/xml": {
              "schema": {
                "type": "string"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `import-payments` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/payments/import/camt054": {
      "post": {
        "tags": [
          "payments"
        ],
        "summary": "`POST /api/v1/payments/import/camt054` — ingest a **camt.054 XML document**\nexactly as the bank delivers it (Bank-to-Customer Debit/Credit Notification).",
        "description": "The booking rules are shared with the camt.053 statement import: batched\nentries are expanded per `TxDtls`, returns (Rückläufer) become\n`BANKRUECKLAST` debits and ordinary credits `ZAHLUNG`, and deduplication is\nkeyed on `AcctSvcrRef` (disambiguated per detail by `EndToEndId`) with a\nstable hash of the transaction fields as the fallback.",
        "operationId": "import_payments_camt054",
        "requestBody": {
          "description": "The camt.054 document exactly as the bank delivers it",
          "content": {
            "application/xml": {
              "schema": {
                "type": "string"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `import-payments` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/payments/match": {
      "post": {
        "tags": [
          "payments"
        ],
        "summary": "`POST /api/v1/payments/match` — the accounts an incoming payment may\nbelong to (`crate::reads::payment_match`, shared with MCP\n`suggest_payment_match`). Reads only; booking is the camt import or a\nmanual Buchung.",
        "description": "A read posted as a body because it carries the payer's IBAN: in a query\nstring the IBAN lands in every access log and trace span that records the\nURI, which is personal data no log may hold.",
        "operationId": "match_payment",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PaymentMatchParams"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The candidates",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Zahlungszuordnung"
                }
              }
            }
          },
          "403": {
            "description": "Cedar `read-account` refused"
          },
          "422": {
            "description": "A body that is not a payment to match"
          }
        }
      }
    },
    "/api/v1/payments/unmatched": {
      "get": {
        "tags": [
          "payments"
        ],
        "summary": "`GET /api/v1/payments/unmatched` — the bank lines no account claimed,\noldest first (`crate::unmatched::list`, shared with MCP\n`list_unmatched_payments`). The payer's IBAN appears masked only.",
        "operationId": "get_unmatched_payments",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum rows (default 100, at most 1000).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The lines waiting for an account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnzugeordneteZahlungen"
                }
              }
            }
          },
          "403": {
            "description": "Cedar `read-books` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/payments/{payment_id}/assign": {
      "post": {
        "tags": [
          "payments"
        ],
        "summary": "`POST /api/v1/payments/{payment_id}/assign` — book an unmatched bank line\nto the account the operator chose and close it, in one transaction\n(`crate::unmatched::assign`). `POST /api/v1/payments/match` proposes the\naccount.",
        "operationId": "assign_payment",
        "parameters": [
          {
            "name": "payment_id",
            "in": "path",
            "description": "The unmatched line, as `GET /api/v1/payments/unmatched` names it",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AssignRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Booked and closed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ZahlungZugeordnet"
                }
              }
            }
          },
          "403": {
            "description": "Cedar `import-payments` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "`payment_not_found` or `account_not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "409": {
            "description": "`payment_already_assigned`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/periods/seals": {
      "get": {
        "tags": [
          "books"
        ],
        "summary": "`GET /api/v1/periods/seals` — the Festschreibung history and whether the\nbooks verify.",
        "description": "`audit` replays the whole log and compares every derived table with it, so\n`verified: true` says more than a seal chain could: no balance, clearing or\nseal disagrees with the entries beneath it.",
        "operationId": "get_seals",
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `read-books` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/periods/{period_id}/balance-proof": {
      "get": {
        "tags": [
          "books"
        ],
        "summary": "`GET /api/v1/periods/{period_id}/balance-proof` — proves what one customer's\naccount closed a sealed month at.",
        "description": "The Betriebsprüfung question (§ 147 AO / GoBD) is not \"is this booking in the\nbooks\" but \"what did this customer owe at the balance-sheet date\". A figure\nread out of a table is not evidence for that; this returns the seal's\ninclusion proof and the account's leaf in the sealed balance tree, verified\nagainst the head before it is published.",
        "operationId": "get_period_balance_proof",
        "parameters": [
          {
            "name": "period_id",
            "in": "path",
            "description": "The period, `YYYY-MM`",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "malo_id",
            "in": "query",
            "description": "Marktlokation whose Kontokorrent balance is being proven.",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "mp_id",
            "in": "query",
            "description": "The own MP-ID the Kontokorrent is kept under — the Lieferant's for a\ncustomer, `[eeg] nb_mp_id` for an EEG plant.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `read-books` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "No such period",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/periods/{period_id}/seal": {
      "post": {
        "tags": [
          "books"
        ],
        "summary": "`POST /api/v1/periods/{period_id}/seal` — Festschreibung.",
        "description": "Seals every open calendar month through `period_id` (`YYYY-MM`), earliest\nfirst, committing each month's closing balances to the log. After sealing,\na booking dated inside a sealed month is refused (`ledger.301`) and parks;\ncorrections book into a later open month (§ 146 Abs. 4 AO).",
        "operationId": "post_seal_period",
        "parameters": [
          {
            "name": "period_id",
            "in": "path",
            "description": "The period, `YYYY-MM`",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `close-period` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/sepa/camt029": {
      "post": {
        "tags": [
          "sepa"
        ],
        "summary": "`POST /api/v1/sepa/camt029` — apply the bank's answer to a recall.",
        "description": "The document quotes the request's `Assgnmt/Id` in `RslvdCase/Id`; that is the\nonly thing in it that points back at the case, so an answer naming an\nassignment this tenant never opened is a `404` rather than a guess.\n\nAn accepted recall (`CNCL`, or every named transaction `ACCR`) closes the\ncollections it stopped as `RECALLED`. Any other outcome leaves them open:\na rejected recall means the collection stands, and a pending one means the\nbank has not decided.",
        "operationId": "import_camt029",
        "requestBody": {
          "description": "The camt.029 document exactly as the bank delivers it",
          "content": {
            "application/xml": {
              "schema": {
                "type": "string"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `manage-sepa` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/sepa/collections/{run_id}/entries": {
      "get": {
        "tags": [
          "sepa"
        ],
        "summary": "`GET /api/v1/sepa/collections/{run_id}/entries` — what a collection run\ncollected, and where each entry stands.",
        "description": "The list a reversal is chosen from: `entry_id` is what\n`POST /api/v1/sepa/reversals` takes, and `status` says whether the collection\nis still in flight (`SUBMITTED`), confirmed (`SETTLED`), refused before it\nmoved (`REJECTED`), returned by the debtor (`RETURNED`) or already given back\n(`REVERSED`).",
        "operationId": "get_collection_entries",
        "parameters": [
          {
            "name": "run_id",
            "in": "path",
            "description": "The collection run",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `read-banking` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/sepa/mandates": {
      "post": {
        "tags": [
          "sepa"
        ],
        "summary": "`POST /api/v1/sepa/mandates`  — register SEPA mandate\n`POST /api/v1/sepa/mandates`",
        "operationId": "post_mandate",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateMandateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `manage-sepa` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/sepa/mandates/dormant": {
      "get": {
        "tags": [
          "sepa"
        ],
        "summary": "`GET /api/v1/sepa/mandates/dormant?within_days=30` — the EPC 36-month sweep.",
        "description": "A mandate not presented for **36 consecutive months** must be cancelled by\nthe creditor. The clock resets on every presentation, *including collections\nlater rejected or refunded*, so it counts from `last_presented_at` — stamped\nwhen the collection is written into a run, not when the bank confirms it.\n\nThe debtor banks do not enforce this, so `within_days` looks ahead: a mandate\ngoing dormant next month is worth knowing about while the customer can still\nbe asked for a new one.",
        "operationId": "get_dormant_mandates",
        "parameters": [
          {
            "name": "older_than_days",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `read-banking` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/sepa/mandates/{mandate_id}": {
      "get": {
        "tags": [
          "sepa"
        ],
        "summary": "`GET /api/v1/sepa/mandates/{mandate_id}`",
        "operationId": "get_mandate",
        "parameters": [
          {
            "name": "mandate_id",
            "in": "path",
            "description": "The SEPA mandate",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `read-banking` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "No such mandate",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "sepa"
        ],
        "summary": "`DELETE /api/v1/sepa/mandates/{mandate_id}`  — revoke SEPA mandate.",
        "description": "Sets `revoked_at = today` on the mandate. Revoked mandates are excluded from\nfuture pain.008 generation (§58 ZAG: debtor may revoke at any time until\nthe cut-off time of the collection date).\n\nDoes NOT affect existing `accounts.iban` or `mandatsref` columns —\nupdate those separately if needed via `PUT /api/v1/accounts/{malo_id}`.",
        "operationId": "delete_mandate",
        "parameters": [
          {
            "name": "mandate_id",
            "in": "path",
            "description": "The SEPA mandate",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Done"
          },
          "403": {
            "description": "Cedar `manage-sepa` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "No such mandate",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/sepa/pain002": {
      "post": {
        "tags": [
          "sepa"
        ],
        "summary": "`POST /api/v1/sepa/pain002` — ingest a **pain.002 XML** exactly as the bank\ndelivers it (Customer Payment Status Report).",
        "description": "One document answers a whole submission, so it is applied to whatever it\nrefers to, keyed by the reference the bank echoes back:\n\n| The report is about | Matched on | Effect |\n|---|---|---|\n| a pain.001 EEG payout | `eeg_payout_orders.end_to_end_ref` | status, reason, `settled_at`, VoP outcome |\n| a pain.008 collection | `sepa_collection_entries.end_to_end_id` | `SETTLED` / `REJECTED` + a rejection event |\n\n## A rejected collection is not a Bankrücklastschrift\n\n`RJCT` on a direct debit means the collection **never happened**: no money\nmoved, so nothing is reversed. accountingd books a `ZAHLUNG` only when a camt\nbooking confirms the money arrived, so posting a compensating\n`BANKRUECKLAST` here would credit a payment that was never received and then\ndebit it back. The receivable simply stays open, the entry is marked\n`REJECTED`, and `de.mako.accounting.sepa.collection-rejected` tells the ERP the\nmandate needs attention. A collection that settled and was *then* returned\narrives as a camt.054 R-transaction and is the other event.\n\n## Verification of Payee\n\nVoP has been mandatory for euro credit transfers since 9 October 2025 and its\nresult arrives inside this same message. It is a **different axis** from\nacceptance: `RCVC` says a payee name matched, which is not a statement about\nwhether the payment was taken. The outcome is stored in `vop_outcome` and\nleaves `pain002_status` alone; anything other than a match emits\n`de.mako.accounting.payee.verification-mismatch`, because whether to execute\nafter anything but a match is an operator's decision. The codes are the\nDeutsche Kreditwirtschaft's pain.002 conventions (DFÜ-Abkommen Anlage 3\nV3.9 Kap. 2.2.6); they report the check, not who is liable for executing.",
        "operationId": "import_pain002",
        "requestBody": {
          "description": "The pain.002 document exactly as the bank delivers it",
          "content": {
            "application/xml": {
              "schema": {
                "type": "string"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `manage-sepa` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/sepa/recalls": {
      "post": {
        "tags": [
          "sepa"
        ],
        "summary": "`POST /api/v1/sepa/recalls` — build a **camt.055** asking the bank to stop a\nsubmitted collection before it settles.",
        "description": "The counterpart to `POST /api/v1/sepa/reversals`, and not a substitute for\nit: a pain.007 gives back a collection that already settled, while a recall\ntries to prevent the debit. Only entries still `SUBMITTED` can be recalled —\na settled one is the reversal's business and a rejected one never moved\nmoney.\n\nA recall is a **request**. The bank answers with a camt.029, which\n`POST /api/v1/sepa/camt029` applies; until then the recall stands\n`REQUESTED` and the collections stay open.",
        "operationId": "post_sepa_recall",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateRecallRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `manage-sepa` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "409": {
            "description": "Conflicts with the current state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/sepa/reversals": {
      "post": {
        "tags": [
          "sepa"
        ],
        "summary": "`POST /api/v1/sepa/reversals` — build a **pain.007** giving a settled\ndirect-debit collection back.",
        "description": "A reversal is the creditor's own correction — the Abschlag collected twice,\nor collected after the customer had already paid by transfer. It is the\ncounterpart to a debtor-initiated refund (which arrives as camt.054) and to a\nreject (which arrives as pain.002 and never moved money at all).\n\nEvery field of `OrgnlTxRef` is restated from `sepa_collection_entries` and\n`sepa_mandates` rather than from the request body, so the reversal cannot\ndisagree with what was collected. The DK technical validation subset makes\nthat block — and the mandate inside it — mandatory, so the references-only\nform plain ISO permits is not one a German bank accepts.\n\nThe compensating `SEPA_STORNO` ledger entry re-opens the receivable: the\nmoney leaves the bank account again, so what the collection discharged is\nowed once more.",
        "operationId": "post_sepa_reversal",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateReversalRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `manage-sepa` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "409": {
            "description": "Conflicts with the current state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/sepa/run": {
      "post": {
        "tags": [
          "sepa"
        ],
        "summary": "`POST /api/v1/sepa/run`  — generate pain.008 XML for all active mandates with positive balance",
        "operationId": "run_sepa",
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `manage-sepa` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "409": {
            "description": "Conflicts with the current state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/trial-balance": {
      "get": {
        "tags": [
          "books"
        ],
        "summary": "`GET /api/v1/trial-balance` — Summen- und Saldenliste (§ 238 HGB): gross debit\nand credit turnover and the balance per GL account. Debits must equal credits.",
        "operationId": "get_trial_balance",
        "responses": {
          "200": {
            "description": "Done",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "403": {
            "description": "Cedar `read-books` refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AddressParts": {
        "type": "object",
        "description": "The parts of an ISO 20022 `PstlAdr` that accountingd stores and emits.\n\n## Which form\n\nEPC153-22 v2.2 (30 September 2026) describes three address forms —\nstructured, hybrid (`TwnNm` + `Ctry` plus free-text lines) and unstructured\n— and permits all three, with no end date set for the unstructured form\n(EPC Payment Scheme Management Board decision of 9 September 2026, applied\nto all five scheme rulebooks). accountingd emits the **structured** form only:\n[`PostalAddress::new`] takes `TwnNm` and `Ctry`, so the unstructured form is\nunrepresentable here. `pain.001.001.09` and `pain.008.001.08` carry it.\n\nAn address is optional. Absent parts emit no `PstlAdr` at all; a\n**partially** filled address is an error rather than a silent omission,\nbecause an address someone entered and the bank never received is a\nfailure nobody sees.",
        "properties": {
          "building_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "`BldgNb`."
          },
          "country": {
            "type": [
              "string",
              "null"
            ],
            "description": "`Ctry` — ISO 3166-1 alpha-2, required whenever any part is set."
          },
          "country_subdivision": {
            "type": [
              "string",
              "null"
            ],
            "description": "`CtrySubDvsn` (Bundesland / state)."
          },
          "post_code": {
            "type": [
              "string",
              "null"
            ],
            "description": "`PstCd`."
          },
          "street": {
            "type": [
              "string",
              "null"
            ],
            "description": "`StrtNm`."
          },
          "town": {
            "type": [
              "string",
              "null"
            ],
            "description": "`TwnNm` — required whenever any part is set."
          }
        },
        "additionalProperties": false
      },
      "AnonymizeRequest": {
        "type": "object",
        "required": [
          "requested_by",
          "legal_basis"
        ],
        "properties": {
          "legal_basis": {
            "type": "string",
            "description": "Legal basis for erasure (e.g. `\"GDPR Art. 17 - customer request #42\"`)."
          },
          "requested_by": {
            "type": "string",
            "description": "Operator identity for the GDPR Art. 5(2) audit log."
          }
        },
        "additionalProperties": false
      },
      "ApiError": {
        "type": "object",
        "description": "The problem body every refusal answers with. Branch on `code`; `detail` is for the developer.",
        "required": [
          "error",
          "detail"
        ],
        "properties": {
          "code": {
            "type": "string",
            "description": "A stable English machine code (`limit_too_large`), where the refusal has one."
          },
          "detail": {
            "type": "string",
            "description": "What went wrong, for the developer."
          },
          "error": {
            "type": "string",
            "description": "The HTTP status's reason phrase."
          },
          "error_id": {
            "type": "string",
            "format": "uuid",
            "description": "On a 5xx: the id the service's log line carries; the cause is never in the body."
          },
          "upstream": {
            "type": "string",
            "description": "On a 502/503/504: the service this one called that failed."
          }
        },
        "additionalProperties": true
      },
      "AssignRequest": {
        "type": "object",
        "description": "Body of `POST /api/v1/payments/{payment_id}/assign`.",
        "required": [
          "malo_id"
        ],
        "properties": {
          "lf_mp_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The Lieferant's MP-ID the account is kept under; defaults to the\nconfigured `lf_mp_id`."
          },
          "malo_id": {
            "type": "string",
            "description": "11-digit Marktlokations-ID of the account the payment belongs to."
          }
        },
        "additionalProperties": false
      },
      "AufrechnungRequest": {
        "type": "object",
        "description": "A recorded Aufrechnung, as the operator declares it.",
        "required": [
          "tr_id",
          "malo_id",
          "billing_year",
          "billing_month",
          "amount_ct",
          "gegenforderung",
          "erklaert_am"
        ],
        "properties": {
          "amount_ct": {
            "type": "integer",
            "format": "int64",
            "description": "The amount extinguished, in euro cent; positive."
          },
          "billing_month": {
            "type": "integer",
            "format": "int32"
          },
          "billing_year": {
            "type": "integer",
            "format": "int32",
            "description": "The billing month of the extinguished claim."
          },
          "erklaert_am": {
            "type": "string",
            "description": "The day the Aufrechnung was declared, `YYYY-MM-DD`."
          },
          "gegenforderung": {
            "$ref": "#/components/schemas/Gegenforderung"
          },
          "malo_id": {
            "type": "string"
          },
          "tr_id": {
            "type": "string",
            "description": "The plant whose claim was set off."
          },
          "vermerk": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "additionalProperties": false
      },
      "BuchenRequest": {
        "type": "object",
        "description": "Request body for `POST /api/v1/accounts/{malo_id}/buchen`.",
        "required": [
          "entry_type",
          "amount_ct"
        ],
        "properties": {
          "amount_ct": {
            "type": "integer",
            "format": "int64",
            "description": "Amount in ct (× 10⁻² EUR). Positive = debit; negative = credit."
          },
          "booking_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "ISO 8601 booking date. Defaults to today when absent."
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "description": "Human-readable description for the Kontoauszug."
          },
          "entry_type": {
            "type": "string",
            "description": "Buchungsart. Must be a valid `entry_type` value.\nAllowed: `RECHNUNG`, `ZAHLUNG`, `GUTSCHRIFT`, `EEG_GUTSCHRIFT`,\n`EEG_MARKTPRAEMIE`, `EEG_AUSZAHLUNG`, `EEG_RUECKZAHLUNG`, `BANKRUECKLAST`,\n`MAHNGEBUEHR`, `VERZUGSZINSEN`, `ABSCHLAG`, `ABSCHLAG_VERRECHNUNG`,\n`SEPA_STORNO`, `JAHRESABSCHLUSS`, `KORREKTUR`, `STORNO`.\n\nThe same list [`crate::ledger::ENTRY_TYPES`] holds, so an automated path\nand the operator interface accept exactly the same kinds."
          },
          "mp_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The own MP-ID the account is kept under; defaults to `[eeg] nb_mp_id`\nfor an `EEG_*` entry and the configured `lf_mp_id` for every other."
          },
          "reference_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "External reference (invoice number, payment reference, etc.)."
          },
          "value_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "ISO 8601 value date. Defaults to `booking_date` when absent."
          }
        },
        "additionalProperties": false
      },
      "CloseEinwandRequest": {
        "type": "object",
        "description": "Body of `POST /api/v1/einwaende/{einwand_id}/erledigen`.",
        "required": [
          "erledigung"
        ],
        "properties": {
          "erledigung": {
            "type": "string",
            "description": "`stattgegeben` | `zurueckgenommen` | `zurueckgewiesen`."
          }
        },
        "additionalProperties": false
      },
      "CreateInterestChargeRequest": {
        "type": "object",
        "required": [
          "principal_ct",
          "period_from",
          "period_to"
        ],
        "properties": {
          "invoice_reference": {
            "type": [
              "string",
              "null"
            ]
          },
          "lf_mp_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "period_from": {
            "type": "string"
          },
          "period_to": {
            "type": "string"
          },
          "principal_ct": {
            "type": "integer",
            "format": "int64"
          }
        },
        "additionalProperties": false
      },
      "CreateMandateRequest": {
        "type": "object",
        "required": [
          "malo_id",
          "lf_mp_id",
          "iban",
          "mandatsref",
          "signed_at"
        ],
        "properties": {
          "bic": {
            "type": [
              "string",
              "null"
            ]
          },
          "debtor_address": {
            "$ref": "#/components/schemas/AddressParts",
            "description": "Debtor postal address (`Dbtr/PstlAdr`). Optional; once any part is set,\n`town` + `country` are required."
          },
          "iban": {
            "type": "string"
          },
          "kontoinhaber": {
            "type": [
              "string",
              "null"
            ]
          },
          "lf_mp_id": {
            "type": "string"
          },
          "malo_id": {
            "type": "string"
          },
          "mandatsref": {
            "type": "string"
          },
          "scheme": {
            "type": "string",
            "description": "`CORE` (default) or `B2B`.\n\nNot a formatting detail. A CORE debtor has an unconditional 8-week refund\nright; a B2B debtor has none, and their bank must hold the mandate before\na collection will clear. Collecting a B2B mandate under CORE — which is\nwhat happened while this was unmodelled and every group was hard-coded to\nCORE — grants the debtor a right their mandate does not carry."
          },
          "sequence_type": {
            "type": "string",
            "description": "`FRST` on a new mandate, then `RCUR` once one collection has cleared.\n\nDefaulted because the sequence is this service's to track across the\nmandate's life rather than a caller's input — `portald` omits it, so a\nrequired field would answer every customer-facing mandate registration\nwith 422."
          },
          "signed_at": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "CreatePaymentPlanRequest": {
        "type": "object",
        "required": [
          "malo_id",
          "total_ct",
          "installment_ct",
          "billing_day",
          "first_due_date"
        ],
        "properties": {
          "abwendung_lock_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid",
            "description": "The live `abwendungsvereinbarung` lock on the same account this plan is\nthe Ratenzahlung of (§ 41g Abs. 1 S. 3 Nr. 1 EnWG). When the plan goes\n`DEFAULTED`, the lock is lifted with `vereinbarung_gebrochen`."
          },
          "billing_day": {
            "type": "integer",
            "format": "int32"
          },
          "dunning_case_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "first_due_date": {
            "type": "string"
          },
          "installment_ct": {
            "type": "integer",
            "format": "int64"
          },
          "lf_mp_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "malo_id": {
            "type": "string"
          },
          "note": {
            "type": [
              "string",
              "null"
            ]
          },
          "operator_sub": {
            "type": [
              "string",
              "null"
            ]
          },
          "total_ct": {
            "type": "integer",
            "format": "int64"
          }
        },
        "additionalProperties": false
      },
      "CreateRecallRequest": {
        "type": "object",
        "description": "Body of `POST /api/v1/sepa/recalls`.",
        "required": [
          "run_id"
        ],
        "properties": {
          "end_to_end_ids": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            },
            "description": "The `EndToEndId`s to recall. Absent or empty recalls the **whole**\nsubmission (`GrpCxl`), which is a different request, not a shorthand."
          },
          "reason_code": {
            "type": [
              "string",
              "null"
            ],
            "description": "ISO 20022 `CancellationReason5Code` — `DUPL`, `AGNT`, `CURR`, `CUST`,\n`UPAY`, `CUTA`, `TECH`, `FRAD`. Defaults to `UPAY`: the ordinary case is\na collection that was not due."
          },
          "run_id": {
            "type": "string",
            "format": "uuid",
            "description": "The submitted run to recall (`sepa_collection_runs.run_id`)."
          }
        },
        "additionalProperties": false
      },
      "CreateReversalRequest": {
        "type": "object",
        "description": "Request body for `POST /api/v1/sepa/reversals`.",
        "required": [
          "collection_entry_id"
        ],
        "properties": {
          "collection_entry_id": {
            "type": "string",
            "format": "uuid",
            "description": "The collected entry to give back (`sepa_collection_entries.entry_id`)."
          },
          "reason_code": {
            "type": [
              "string",
              "null"
            ],
            "description": "ISO 20022 `ExternalReversalReason1Code`. Defaults to `MS02` — \"no reason\nspecified by the customer\", the code the DK's own reversal example\ncarries and what a creditor uses when it simply collected in error."
          },
          "reversed_amount_ct": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Partial reversal amount in ct. Absent reverses the whole collection;\nmore than was collected is refused."
          }
        },
        "additionalProperties": false
      },
      "DiscardRequest": {
        "type": "object",
        "description": "Body of `POST /api/v1/bookings/{key}/discard`.",
        "required": [
          "grund"
        ],
        "properties": {
          "grund": {
            "type": "string",
            "description": "Why the booking is dropped — kept with the draft for the audit trail."
          }
        },
        "additionalProperties": false
      },
      "EegAuszahlung": {
        "type": "object",
        "description": "One EEG payout order the Netzbetreiber ran (§ 19 Abs. 1 EEG 2023).",
        "required": [
          "payout_id",
          "malo_id",
          "tr_id",
          "billing_year",
          "billing_month",
          "amount_ct",
          "amount_eur",
          "creditor_name",
          "payment_type",
          "end_to_end_ref",
          "created_at"
        ],
        "properties": {
          "amount_ct": {
            "type": "integer",
            "format": "int64",
            "description": "The amount paid out, in cents."
          },
          "amount_eur": {
            "type": "string",
            "format": "decimal",
            "description": "`amount_ct` as a decimal EUR string."
          },
          "billing_month": {
            "type": "integer",
            "format": "int32",
            "description": "Billing month (1–12) of the receipt chain."
          },
          "billing_year": {
            "type": "integer",
            "format": "int32",
            "description": "Billing year of the receipt chain."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the order was made."
          },
          "creditor_name": {
            "type": "string",
            "description": "The plant operator the order pays."
          },
          "end_to_end_ref": {
            "type": "string",
            "description": "The ISO 20022 `EndToEndId` the pain.002 answers on."
          },
          "malo_id": {
            "type": "string",
            "description": "The plant's Marktlokation."
          },
          "pain002_reason": {
            "type": [
              "string",
              "null"
            ],
            "description": "The EPC reason code of a rejection."
          },
          "pain002_status": {
            "type": [
              "string",
              "null"
            ],
            "description": "The bank's pain.002 status (`PDNG`, `ACCP`, `ACSC`, `RJCT`, `CANC`, …);\nabsent for an order not yet submitted."
          },
          "payment_type": {
            "type": "string",
            "description": "`SCT_INST` or `SCT_CORE`."
          },
          "payout_id": {
            "type": "string",
            "description": "The order."
          },
          "settled_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the bank confirmed the credit."
          },
          "submitted_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the pain.001 was submitted."
          },
          "tr_id": {
            "type": "string",
            "description": "The plant (Technische Ressource) whose receipt chain the order pays."
          }
        }
      },
      "EegAuszahlungen": {
        "type": "object",
        "description": "The EEG payout orders (`list_eeg_payouts`, `GET /api/v1/eeg/payouts`).",
        "required": [
          "payouts",
          "count",
          "saturated"
        ],
        "properties": {
          "count": {
            "type": "integer",
            "description": "How many orders `payouts` holds.",
            "minimum": 0
          },
          "payouts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EegAuszahlung"
            },
            "description": "The orders, newest first."
          },
          "saturated": {
            "type": "boolean",
            "description": "The page is full: more may match than were listed."
          }
        }
      },
      "EinwandArt": {
        "type": "string",
        "description": "An amount that must stay out of the § 41f Abs. 3 Verzug calculation.",
        "enum": [
          "forderung_bestritten",
          "preiserhoehung_bestritten",
          "schlichtung",
          "ratenzahlung_nicht_faellig"
        ]
      },
      "EinwandRequest": {
        "type": "object",
        "description": "Body of `POST /api/v1/dunning/{id}/einwaende`.",
        "required": [
          "art",
          "betrag_ct"
        ],
        "properties": {
          "art": {
            "$ref": "#/components/schemas/EinwandArt"
          },
          "betrag_ct": {
            "type": "integer",
            "format": "int64"
          },
          "ledger_entry_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid",
            "description": "The disputed booking, where one can be pointed at."
          },
          "note": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "additionalProperties": false
      },
      "EscalateDunningRequest": {
        "type": "object",
        "description": "Body of `POST /api/v1/dunning/{account_id}/escalate`.\n\nBoth fields are required. The Mahnstufe and the Zahlungsfrist are what the\nMahnung tells the customer, and accountingd has no configured policy for a\nmanual escalation's Zahlungsfrist — so a value the operator did not send is\nrefused rather than substituted.",
        "required": [
          "stufe",
          "due_days"
        ],
        "properties": {
          "due_days": {
            "type": "integer",
            "format": "int32",
            "description": "Zahlungsfrist in calendar days from today (Europe/Berlin), at least 1.",
            "minimum": 0
          },
          "stufe": {
            "type": "integer",
            "format": "int32",
            "description": "Mahnstufe, 1–3 (the `dunning_cases.stufe` range)."
          }
        }
      },
      "Gegenforderung": {
        "type": "string",
        "description": "The Netzbetreiber's claim a plant operator's EEG claim was set off against.\n\nEach variant is one of the set-offs the EEG 2023 admits against a § 19\nAbs. 1 claim.",
        "enum": [
          "EEG_52_PFLICHTZAHLUNG",
          "ENFG_UMLAGE",
          "UNBESTRITTEN"
        ]
      },
      "GuthabenAusgezahlt": {
        "type": "object",
        "description": "What a payout booked.",
        "required": [
          "payout_id",
          "ledger_entry_id",
          "amount_ct"
        ],
        "properties": {
          "amount_ct": {
            "type": "integer",
            "format": "int64",
            "description": "The amount in cents."
          },
          "ledger_entry_id": {
            "type": "string",
            "description": "The ledger entry the payout is (or will be, once the ledger answers)."
          },
          "payout_id": {
            "type": "string",
            "description": "The item that was paid."
          }
        }
      },
      "Guthabenauszahlung": {
        "type": "object",
        "description": "One Guthaben owed back from a Schlussrechnung.",
        "required": [
          "payout_id",
          "rechnungsnummer",
          "malo_id",
          "lf_mp_id",
          "amount_ct",
          "amount_eur",
          "rechnungsdatum",
          "due_on",
          "status",
          "overdue"
        ],
        "properties": {
          "amount_ct": {
            "type": "integer",
            "format": "int64",
            "description": "The Guthaben in cents."
          },
          "amount_eur": {
            "type": "string",
            "format": "decimal",
            "description": "`amount_ct` as a decimal EUR string."
          },
          "due_on": {
            "type": "string",
            "format": "date",
            "description": "The last day it may be paid out (§ 40c Abs. 3 EnWG, two weeks)."
          },
          "lf_mp_id": {
            "type": "string",
            "description": "The Lieferant's MP-ID the account is kept under."
          },
          "malo_id": {
            "type": "string",
            "description": "11-digit Marktlokations-ID."
          },
          "overdue": {
            "type": "boolean",
            "description": "Open and past `due_on` on today's Europe/Berlin date."
          },
          "payout_id": {
            "type": "string",
            "description": "The item, as `POST /api/v1/credit-payouts/{payout_id}/paid` names it."
          },
          "rechnungsdatum": {
            "type": "string",
            "format": "date",
            "description": "The Schlussrechnung's date."
          },
          "rechnungsnummer": {
            "type": "string",
            "description": "The Schlussrechnung that owes it."
          },
          "status": {
            "$ref": "#/components/schemas/Status",
            "description": "Where it stands."
          }
        }
      },
      "Guthabenauszahlungen": {
        "type": "object",
        "description": "The payout items (`list_credit_payouts`, `GET /api/v1/credit-payouts`).",
        "required": [
          "payouts",
          "count",
          "overdue_count",
          "saturated"
        ],
        "properties": {
          "count": {
            "type": "integer",
            "description": "How many items `payouts` holds.",
            "minimum": 0
          },
          "overdue_count": {
            "type": "integer",
            "description": "How many of them are overdue.",
            "minimum": 0
          },
          "payouts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Guthabenauszahlung"
            },
            "description": "The items, earliest due date first."
          },
          "saturated": {
            "type": "boolean",
            "description": "The page is full: more may match than were listed."
          }
        }
      },
      "Kontoauszug": {
        "type": "object",
        "description": "A statement window (`list_ledger`, `GET /api/v1/accounts/{malo_id}/ledger`):\n`opening_ct` plus every `signed_ct` is the newest line's `running_ct`.",
        "required": [
          "malo_id",
          "mp_id",
          "opening_ct",
          "lines"
        ],
        "properties": {
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Kontobewegung"
            },
            "description": "The movements, newest first."
          },
          "malo_id": {
            "type": "string",
            "description": "11-digit Marktlokations-ID."
          },
          "mp_id": {
            "type": "string",
            "description": "The own MP-ID the account is kept under — the Lieferant's for a\ncustomer, the Netzbetreiber's for an EEG plant."
          },
          "opening_ct": {
            "type": "integer",
            "format": "int64",
            "description": "The signed balance the window opens at, in cents — what was booked\nbefore it and what `limit` cut off its front."
          }
        }
      },
      "Kontobewegung": {
        "type": "object",
        "description": "One movement on the Kontokorrent.",
        "required": [
          "entry_id",
          "side",
          "amount_ct",
          "signed_ct",
          "running_ct",
          "booking_date"
        ],
        "properties": {
          "amount_ct": {
            "type": "integer",
            "format": "int64",
            "description": "The movement in cents, always positive; `side` carries the sign."
          },
          "beleg": {
            "type": [
              "string",
              "null"
            ],
            "description": "The Beleg the booking cites — a Rechnungsnummer, a bank reference."
          },
          "booking_date": {
            "type": "string",
            "format": "date",
            "description": "The booking date."
          },
          "entry_id": {
            "type": "string",
            "description": "The doubleentry entry id."
          },
          "entry_type": {
            "type": [
              "string",
              "null"
            ],
            "description": "The Buchungsart, e.g. `RECHNUNG`, `ZAHLUNG`, `GUTSCHRIFT`, `ABSCHLAG`."
          },
          "running_ct": {
            "type": "integer",
            "format": "int64",
            "description": "The running balance after this movement, in cents."
          },
          "side": {
            "type": "string",
            "description": "`D` (debit — increases the receivable) or `C` (credit)."
          },
          "signed_ct": {
            "type": "integer",
            "format": "int64",
            "description": "Signed contribution to the balance (debit +, credit −), in cents."
          }
        }
      },
      "Kontostand": {
        "type": "object",
        "description": "The account's open-items balance (`get_balance`,\n`GET /api/v1/accounts/{malo_id}/balance`).",
        "required": [
          "malo_id",
          "mp_id",
          "balance_ct",
          "balance_eur",
          "status",
          "abschlag_ct"
        ],
        "properties": {
          "abschlag_ct": {
            "type": "integer",
            "format": "int64",
            "description": "The monthly Abschlag in cents."
          },
          "balance_ct": {
            "type": "integer",
            "format": "int64",
            "description": "Open-items balance in cents: positive is owed, negative a Guthaben."
          },
          "balance_eur": {
            "type": "string",
            "format": "decimal",
            "description": "`balance_ct` as a decimal EUR string, e.g. `\"-12.50\"`."
          },
          "malo_id": {
            "type": "string",
            "description": "11-digit Marktlokations-ID."
          },
          "mp_id": {
            "type": "string",
            "description": "The own MP-ID the account is kept under — the Lieferant's for a\ncustomer, the Netzbetreiber's for an EEG plant."
          },
          "status": {
            "$ref": "#/components/schemas/Saldostatus",
            "description": "Where the balance stands."
          }
        }
      },
      "LiftLockRequest": {
        "type": "object",
        "description": "Body of `DELETE /api/v1/dunning/locks/{lock_id}`.",
        "required": [
          "grund"
        ],
        "properties": {
          "grund": {
            "type": "string",
            "description": "Why the lock no longer applies. `vereinbarung_gebrochen` carries the\n§ 41g Abs. 1 S. 11 side effect described below."
          }
        },
        "additionalProperties": false
      },
      "LockGrund": {
        "type": "string",
        "description": "A reason to stop dunning an account.\n\nEvery halt carries a ground, a citation, a validity period and a lifting\nreason — none of them optional. A halt that cannot be lifted makes an account\npermanently undunnable, and § 41f Abs. 2 in particular describes a\ncircumstance that is *auf Verlangen glaubhaft zu machen*, so reviewable.",
        "enum": [
          "abwendungsvereinbarung",
          "schutzbeduerftigkeit",
          "zahlungsaussicht",
          "insolvenz",
          "operator"
        ]
      },
      "Mahnfaelle": {
        "type": "object",
        "description": "The open dunning cases (`list_dunning`, `GET /api/v1/dunning`).",
        "required": [
          "faelle",
          "count",
          "saturated"
        ],
        "properties": {
          "count": {
            "type": "integer",
            "description": "How many cases `faelle` holds.",
            "minimum": 0
          },
          "faelle": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Mahnfall"
            },
            "description": "The open cases, newest Mahnung first."
          },
          "saturated": {
            "type": "boolean",
            "description": "The page is full: more cases may be open than were listed."
          }
        }
      },
      "Mahnfall": {
        "type": "object",
        "description": "One open dunning case.",
        "required": [
          "id",
          "account_id",
          "stufe",
          "amount_due_ct",
          "amount_due_eur",
          "issued_at",
          "due_date"
        ],
        "properties": {
          "account_id": {
            "type": "string",
            "description": "The customer account it was opened on."
          },
          "amount_due_ct": {
            "type": "integer",
            "format": "int64",
            "description": "The amount the Mahnung demands, in cents."
          },
          "amount_due_eur": {
            "type": "string",
            "format": "decimal",
            "description": "`amount_due_ct` as a decimal EUR string."
          },
          "due_date": {
            "type": "string",
            "format": "date",
            "description": "The payment date the Mahnung sets."
          },
          "id": {
            "type": "string",
            "description": "The dunning case."
          },
          "issued_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the Mahnung was issued."
          },
          "sperrauftrag_ce_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The CloudEvent id of the Sperrauftrag a Mahnstufe 3 raised, if any."
          },
          "stufe": {
            "type": "integer",
            "format": "int32",
            "description": "The Mahnstufe, 1–3."
          }
        }
      },
      "PaidRequest": {
        "type": "object",
        "description": "Body of `POST /api/v1/credit-payouts/{payout_id}/paid`.",
        "required": [
          "paid_on"
        ],
        "properties": {
          "paid_on": {
            "type": "string",
            "format": "date",
            "description": "The value date of the transfer (YYYY-MM-DD)."
          },
          "reference": {
            "type": [
              "string",
              "null"
            ],
            "description": "The bank reference of the transfer."
          }
        },
        "additionalProperties": false
      },
      "Pain002StatusUpdate": {
        "type": "object",
        "description": "Request body for `PUT /api/v1/eeg/payouts/{payout_id}/status`\n\nProcess a pain.002 Payment Status Report from the bank.\nUpdates the `pain002_status` and `settled_at` / `pain002_reason` columns.\n\nEPC reason codes (ISO 20022):\n- `AC01` — incorrect account number (IBAN)\n- `AM04` — insufficient funds\n- `AC06` — account blocked\n- `MD01` — no mandate (direct debit only — not applicable here)\n- `RJCT` + empty reason — generic rejection",
        "required": [
          "status"
        ],
        "properties": {
          "reason_code": {
            "type": [
              "string",
              "null"
            ],
            "description": "EPC/ISO 20022 reason code (e.g. `\"AC01\"`). Absent for ACCP."
          },
          "status": {
            "type": "string",
            "description": "`ACCP` | `ACSC` | `RJCT` | `CANC`"
          }
        },
        "additionalProperties": false
      },
      "PaymentMatchParams": {
        "type": "object",
        "description": "`suggest_payment_match`'s parameters — the body of\n`POST /api/v1/payments/match`. It reads and books nothing.\n\n`Debug` leaves the IBAN out: a payment to match is logged, if ever, by its\namount and reference, never by the payer's account.",
        "required": [
          "amount_ct",
          "reference"
        ],
        "properties": {
          "amount_ct": {
            "type": "integer",
            "format": "int64",
            "description": "Payment amount in 1/100 EUR cents (e.g. 12500 = 125.00 EUR)."
          },
          "end_to_end_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "`EndToEndId`, when the bank echoed one back."
          },
          "iban": {
            "type": [
              "string",
              "null"
            ],
            "description": "Counterparty IBAN, when the bank reported one — the strongest evidence\nof who paid, and the rung that resolves without any guessing."
          },
          "reference": {
            "type": "string",
            "description": "Payment reference / Verwendungszweck from the bank statement."
          },
          "tolerance_pct": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Fuzzy tolerance for the fallback rung: how many percent the open balance\nmay deviate from the payment (default 2 %). Ignored when the reference\nidentifies the account outright."
          },
          "value_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "Value date of the payment (YYYY-MM-DD)."
          }
        },
        "additionalProperties": false
      },
      "PlaceLockRequest": {
        "type": "object",
        "description": "Body of `POST /api/v1/dunning/{id}/locks`.",
        "required": [
          "grund"
        ],
        "properties": {
          "grund": {
            "$ref": "#/components/schemas/LockGrund"
          },
          "note": {
            "type": [
              "string",
              "null"
            ]
          },
          "rechtsgrundlage": {
            "type": [
              "string",
              "null"
            ],
            "description": "The citation this rests on. Defaults to the ground's own."
          },
          "valid_from": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "description": "When the lock takes effect. Absent = today. Settable because the evidence\na lock rests on has its own dates — a certificate covering January to\nMarch is recorded as it reads, not as of the day it was typed in."
          },
          "valid_to": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "description": "When the lock lapses. Absent = open-ended, and open-ended locks are\nlisted by `GET /api/v1/dunning/locks/review`."
          }
        },
        "additionalProperties": false
      },
      "PutAbschlagRequest": {
        "type": "object",
        "description": "Body of `PUT /api/v1/accounts/{malo_id}/abschlag`.",
        "required": [
          "abschlag_ct"
        ],
        "properties": {
          "abschlag_ct": {
            "type": "integer",
            "format": "int64",
            "description": "The new monthly Abschlag in ct (× 10⁻² EUR). Required."
          }
        }
      },
      "PutBusinessPartnerRequest": {
        "type": "object",
        "description": "Body of `PUT /api/v1/accounts/{malo_id}/business-partner`.",
        "required": [
          "kunden_nr"
        ],
        "properties": {
          "kunden_nr": {
            "type": "string",
            "description": "The vertragd `kunden_nr` the account belongs to. Required, non-blank."
          }
        }
      },
      "Quelle": {
        "type": "string",
        "description": "The import door a line arrived through.",
        "enum": [
          "flat",
          "camt052",
          "camt053",
          "camt054"
        ]
      },
      "RebookRequest": {
        "type": "object",
        "description": "Body of `POST /api/v1/bookings/{key}/rebook`.",
        "required": [
          "buchungsdatum"
        ],
        "properties": {
          "buchungsdatum": {
            "type": "string",
            "description": "The date to book on (ISO 8601) — an open month; the parked list names\nthe first one as `vorschlag_datum`."
          }
        },
        "additionalProperties": false
      },
      "RueckzahlungRequest": {
        "type": "object",
        "description": "A plant operator's repayment of an overpaid receipt chain, as the operator\nof accountingd records it.",
        "required": [
          "tr_id",
          "billing_year",
          "billing_month",
          "amount_ct",
          "eingegangen_am"
        ],
        "properties": {
          "amount_ct": {
            "type": "integer",
            "format": "int64",
            "description": "The amount received, in euro cent; positive, at most what is owed back."
          },
          "billing_month": {
            "type": "integer",
            "format": "int32"
          },
          "billing_year": {
            "type": "integer",
            "format": "int32"
          },
          "eingegangen_am": {
            "type": "string",
            "description": "The day the money arrived, `YYYY-MM-DD`."
          },
          "tr_id": {
            "type": "string",
            "description": "The plant and billing month of the overpaid chain."
          },
          "vermerk": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "additionalProperties": false
      },
      "RunEegPayoutsRequest": {
        "type": "object",
        "description": "Request body for `POST /api/v1/eeg/payouts/run`.",
        "required": [
          "billing_year",
          "billing_month"
        ],
        "properties": {
          "billing_month": {
            "type": "integer",
            "format": "int32",
            "description": "The billing month, 1–12."
          },
          "billing_year": {
            "type": "integer",
            "format": "int32",
            "description": "The **billing** year of the receipts to pay — the period they settle,\nnot the day the run happens."
          },
          "instant_override": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "When `true`, force SCT Inst regardless of `[eeg].sepa_instant` config.\nWhen `false` or absent, use the config flag."
          },
          "malo_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Only pay this MaLo's chains (for a targeted re-run)."
          }
        },
        "additionalProperties": false
      },
      "Saldostatus": {
        "type": "string",
        "description": "Where an account's balance stands: `overdue` — the customer owes\n(`balance_ct > 0`); `credit` — a Guthaben (`balance_ct < 0`); `settled` —\nnothing is open.",
        "enum": [
          "overdue",
          "credit",
          "settled"
        ]
      },
      "SetVerbraucherRequest": {
        "type": "object",
        "description": "`PUT /api/v1/accounts/{malo_id}/verbraucher` — the § 13 BGB status as the\nvertragd contract records it. `null` is „not recorded\" and clears a status\nan earlier contract on the MaLo set; the field is required, so an empty body\ncannot be read as either.",
        "properties": {
          "verbraucher": {
            "type": [
              "boolean",
              "null"
            ]
          }
        },
        "additionalProperties": false
      },
      "Status": {
        "type": "string",
        "description": "Where a payout item stands.",
        "enum": [
          "open",
          "paid",
          "cancelled"
        ]
      },
      "UeberfaelligeKonten": {
        "type": "object",
        "description": "The accounts with an open balance (`list_overdue`,\n`GET /api/v1/offene-posten`).",
        "required": [
          "accounts",
          "count",
          "saturated"
        ],
        "properties": {
          "accounts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UeberfaelligesKonto"
            },
            "description": "The accounts, largest balance first."
          },
          "count": {
            "type": "integer",
            "description": "How many accounts `accounts` holds.",
            "minimum": 0
          },
          "saturated": {
            "type": "boolean",
            "description": "At least `limit` accounts matched: more may be overdue than were listed."
          }
        }
      },
      "UeberfaelligesKonto": {
        "type": "object",
        "description": "One account with an overdue balance.",
        "required": [
          "account_id",
          "malo_id",
          "lf_mp_id",
          "balance_ct",
          "balance_eur",
          "abschlag_ct",
          "updated_at"
        ],
        "properties": {
          "abschlag_ct": {
            "type": "integer",
            "format": "int64",
            "description": "The monthly Abschlag in cents."
          },
          "account_id": {
            "type": "string",
            "description": "The customer account."
          },
          "balance_ct": {
            "type": "integer",
            "format": "int64",
            "description": "The open balance in cents."
          },
          "balance_eur": {
            "type": "string",
            "format": "decimal",
            "description": "`balance_ct` as a decimal EUR string."
          },
          "kunden_nr": {
            "type": [
              "string",
              "null"
            ],
            "description": "The operator's customer number, where recorded."
          },
          "lf_mp_id": {
            "type": "string",
            "description": "The Lieferant's MP-ID the account is kept under."
          },
          "malo_id": {
            "type": "string",
            "description": "11-digit Marktlokations-ID."
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the account's balance last changed."
          }
        }
      },
      "UnzugeordneteZahlung": {
        "type": "object",
        "description": "One bank line no account claimed.",
        "required": [
          "payment_id",
          "bank_transaction_id",
          "amount_ct",
          "amount_eur",
          "is_return",
          "value_date",
          "reference",
          "source",
          "received_at"
        ],
        "properties": {
          "amount_ct": {
            "type": "integer",
            "format": "int64",
            "description": "The amount in cents, always positive; `is_return` carries the direction."
          },
          "amount_eur": {
            "type": "string",
            "format": "decimal",
            "description": "`amount_ct` as a decimal EUR string."
          },
          "bank_transaction_id": {
            "type": "string",
            "description": "The bank's transaction reference."
          },
          "end_to_end_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The `EndToEndId`, when the bank itemised one."
          },
          "iban_masked": {
            "type": [
              "string",
              "null"
            ],
            "description": "The payer's IBAN as `DE…3000`, when the bank reported one."
          },
          "is_return": {
            "type": "boolean",
            "description": "A Rücklastschrift (money leaving the account) rather than a payment in."
          },
          "payment_id": {
            "type": "string",
            "description": "The line, as `POST /api/v1/payments/{payment_id}/assign` names it."
          },
          "received_at": {
            "type": "string",
            "format": "date-time",
            "description": "When it was imported."
          },
          "reference": {
            "type": "string",
            "description": "The Verwendungszweck."
          },
          "source": {
            "$ref": "#/components/schemas/Quelle",
            "description": "The import door it arrived through."
          },
          "value_date": {
            "type": "string",
            "format": "date",
            "description": "The value date."
          }
        }
      },
      "UnzugeordneteZahlungen": {
        "type": "object",
        "description": "The bank lines waiting for an account (`list_unmatched_payments`,\n`GET /api/v1/payments/unmatched`).",
        "required": [
          "payments",
          "count",
          "saturated"
        ],
        "properties": {
          "count": {
            "type": "integer",
            "description": "How many lines `payments` holds.",
            "minimum": 0
          },
          "payments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UnzugeordneteZahlung"
            },
            "description": "The lines, oldest value date first."
          },
          "saturated": {
            "type": "boolean",
            "description": "The page is full: more may be waiting than were listed."
          }
        }
      },
      "UpdateAccountRequest": {
        "type": "object",
        "properties": {
          "abschlag_ct": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64"
          },
          "address": {
            "$ref": "#/components/schemas/AddressParts",
            "description": "Postal address (`PstlAdr`). Each part is `COALESCE`d, so an omitted part\nleaves the stored value alone — the same shape as every other field here."
          },
          "billing_day": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32"
          },
          "iban": {
            "type": [
              "string",
              "null"
            ]
          },
          "mandatsref": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "additionalProperties": false
      },
      "ZahlungZugeordnet": {
        "type": "object",
        "description": "What an assignment booked.",
        "required": [
          "payment_id",
          "malo_id",
          "lf_mp_id",
          "ledger_entry_id",
          "entry_type",
          "amount_ct"
        ],
        "properties": {
          "amount_ct": {
            "type": "integer",
            "format": "int64",
            "description": "The amount in cents, always positive."
          },
          "entry_type": {
            "type": "string",
            "description": "`ZAHLUNG` or `BANKRUECKLAST`."
          },
          "ledger_entry_id": {
            "type": "string",
            "description": "The ledger entry the booking is (or will be, once the ledger answers)."
          },
          "lf_mp_id": {
            "type": "string",
            "description": "The Lieferant's MP-ID the account is kept under."
          },
          "malo_id": {
            "type": "string",
            "description": "11-digit Marktlokations-ID."
          },
          "payment_id": {
            "type": "string",
            "description": "The line that was assigned."
          }
        }
      },
      "Zahlungszuordnung": {
        "type": "object",
        "description": "The accounts an incoming payment may belong to (`suggest_payment_match`,\n`POST /api/v1/payments/match`).",
        "required": [
          "payment_amount_ct",
          "payment_amount_eur",
          "payment_reference",
          "candidates_count",
          "candidates",
          "note"
        ],
        "properties": {
          "candidates": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Zuordnungskandidat"
            },
            "description": "One exact candidate, or up to ten ranked by amount proximity."
          },
          "candidates_count": {
            "type": "integer",
            "description": "How many candidates `candidates` holds.",
            "minimum": 0
          },
          "note": {
            "type": "string",
            "description": "How to read the answer."
          },
          "payment_amount_ct": {
            "type": "integer",
            "format": "int64",
            "description": "The payment in cents."
          },
          "payment_amount_eur": {
            "type": "string",
            "format": "decimal",
            "description": "`payment_amount_ct` as a decimal EUR string."
          },
          "payment_reference": {
            "type": "string",
            "description": "The Verwendungszweck the bank reported."
          },
          "tolerance_pct": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "The tolerance the amount-proximity rung ran with, in percent; absent\nwhen the reference identified the account."
          }
        }
      },
      "Zuordnungskandidat": {
        "type": "object",
        "description": "One account a payment may belong to.",
        "required": [
          "account_id",
          "malo_id",
          "lf_mp_id",
          "open_balance_ct",
          "open_balance_eur",
          "matched_by",
          "confidence",
          "residual_ct"
        ],
        "properties": {
          "account_id": {
            "type": "string",
            "description": "The customer account."
          },
          "confidence": {
            "type": "string",
            "description": "`EXACT` for an exact rung; `MEDIUM` or `LOW` for amount proximity."
          },
          "lf_mp_id": {
            "type": "string",
            "description": "The Lieferant's MP-ID the account is kept under."
          },
          "malo_id": {
            "type": "string",
            "description": "11-digit Marktlokations-ID."
          },
          "matched_by": {
            "type": "string",
            "description": "The evidence: an exact rung (`iban`, `end_to_end_id`,\n`remittance_token`) or `amount_proximity`."
          },
          "open_balance_ct": {
            "type": "integer",
            "format": "int64",
            "description": "The account's open balance in cents."
          },
          "open_balance_eur": {
            "type": "string",
            "format": "decimal",
            "description": "`open_balance_ct` as a decimal EUR string."
          },
          "residual_ct": {
            "type": "integer",
            "format": "int64",
            "description": "What stays open after booking the payment, in cents (0 settles it)."
          },
          "similarity_score": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Amount closeness 0–100, only on the amount-proximity rung.",
            "minimum": 0
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "accounts",
      "description": "One customer account: balance and Kontokorrent"
    },
    {
      "name": "books",
      "description": "Tenant-wide books: open items, aging, trial balance, period seals and proofs"
    },
    {
      "name": "payments",
      "description": "Payment reconciliation"
    },
    {
      "name": "eeg",
      "description": "EEG payouts to plant operators"
    },
    {
      "name": "dunning",
      "description": "Dunning cases, Mahnsperren and Forderungseinwände"
    },
    {
      "name": "sepa",
      "description": "SEPA mandates, collections, reversals and recalls"
    }
  ]
}
