# Data model — βεβαίωση οφειλών

Status: **implemented** (2026-08-06). Migrations, models, enums, seeder and the two services are
in place; commands and the scheduler follow in phase 3.

## What decided this shape

The microservice is the system of record. The BFF stores nothing: it asks us for βεβαιώσεις,
lookups, and status, and it polls us for outcomes. Four consequences drive every table below.

1. **We hold drafts.** A βεβαίωση exists in our DB from «Αποθήκευση Προχείρου», long before ΚΕΔ
   hears about it. So the natural-key duplicate guard cannot be a plain unique index — it must not
   fire between two drafts.
2. **We hold fields ΚΕΔ never sees.** Ονοματεπώνυμο οφειλέτη, τηλέφωνο επικοινωνίας, the names of
   the συνυπόχρεοι and the attachments are not in the `retrieveKedeAmount` contract (no name,
   phone or attachment field exists anywhere in the ΚΕΔ interface), but the UI needs them, so
   they live here and are simply never written into the envelope.
3. **We poll ΚΕΔ on a schedule**, the BFF polls us. A βεβαίωση nobody is looking at must still
   reach `certified`.
4. **We serve lookups.** Their `RabbitMQResultType` already has a `lookup` member, so this is the
   intended shape rather than a workaround.

## The one thing that is easy to get wrong

**Η Ταυτότητα Οφειλής is per γραμμή ΧΚ, not per βεβαίωση.** `retrieveCloseDay` returns one
`tofeilisRecord` — its own `lineNo`, `payId` and `origAmount` — for *each* γραμμή of the ΧΚ, and
the same ΑΦΜ may recur on several γραμμές: the spec's own sample (Παράρτημα Β, σελ. 25-26) has
one ΑΤΒ (98000) with lines 1-2 both for ΑΦΜ 063745180, each with a different payId. A βεβαίωση
with two συνυπόχρεοι comes back with three ΤΟ. The M1 migration put `taftotita_ofeilis` on the
certification, which cannot represent that; it moves to `beveosi_debtors`.

## Tables

### `beveosi_certifications` — one βεβαίωση

Rewrites the M1 table. `xk_no` → `mc_no` (the spec's name), and the ΑΤΒ/ΤΟ columns move or split.

| column | type | notes |
|---|---|---|
| `id` | bigint PK | |
| `audit_protocol` | char(36), unique | our unique id, sent to ΚΕΔ in `auditProtocol`. Stores the `{n}/DD-MM-YYYY` sequence string since M2 (the column type predates the format change). **Reused verbatim on resend** — that is how ΚΕΔ spots duplicates (Παράρτημα Ζ) |
| `hash_id` | char(64), unique | SHA-256 hex of `audit_protocol`, computed once at draft creation (`CertificationService::createDraft` — the column's single writer) and backfilled for existing rows. Server-only: never a request field. The BFF's lookup selector and base key for its MinIO object names. Null only on ΑΦΕΚ fixture rows created outside `createDraft` |
| `status` | varchar(30), index | see the state machine below |
| `locked_at` / `locked_by` | datetime / varchar(100) | set when sent, cleared only per Παράρτημα Ζ |
| **input — debtor** | | |
| `afm` | char(12), index | the primary debtor, denormalised from `beveosi_debtors` position 0 so the duplicate guard and the list filter stay cheap |
| **input — debt** | | |
| `kae` | char(5) | the ΚΑΕ of the primary line, denormalised from `beveosi_kae_lines` for the same reason |
| `fiscal_year` | char(4) | ΚΕΔ requires >= 2010 and <= current year |
| `apof_no_etos` | varchar(40) | Αριθμός απόφασης – Έτος |
| `sunolo` | decimal(17,2) | must equal Σ(δόσεις) = Σ(ΚΑΕ γραμμές) |
| `comments` | text | must contain έτος + αριθμός απόφασης |
| `txt_code` | varchar(10) | είδος φόρου, from config, not user input |
| `ext_org` | char(5) | snapshotted per row: if ΑΑΔΕ ever reassigns it, old rows must still describe what was sent |
| `ypiresia_descr` | varchar(30) | |
| `ins_frequency` | tinyint unsigned | 1 = μήνας, 2 = δίμηνο, … |
| `last_day_rule` | tinyint unsigned | 1 = τελευταία εργάσιμη, 2 = τακτή (needs ΑΑΔΕ activation) |
| `doy` | char(4), null | ΔΟΥ καθ' υπέρβαση αρμοδιότητας, optional |
| `doy_flag` | tinyint unsigned, null | 1 only for ΔΟΥ ακινήτου |
| `discount_amt` | decimal(17,2), null | spec says «ΔΕΝ χρησιμοποιείται»; kept for completeness |
| `discount_pcg` | decimal(4,2), null | |
| `discount_date` | date, null | mandatory when `discount_pcg` is set |
| `afm_ypogr` | char(12) | must exist in `declared_signers` |
| `name_ypogr` | varchar(120) | |
| **output — retrieveKedeAmount** | | |
| `result_doy` | char(4), null | the ΔΟΥ that certified. Distinct from the input `doy` |
| `dept_id` / `mct_code` / `sct_code` / `source_code` / `year` | small ints / char(5) | returned verbatim |
| `mc_no` | int unsigned, null | Αριθμός Χρηματικού Καταλόγου |
| `line_no` | int unsigned, null | of the primary debtor |
| `mc_date` | date, null | the date we submitted — the key `retrieveCloseDay` needs |
| **output — retrieveCloseDay** | | |
| `atb_no` | **decimal(20,0)**, null | 20 digits. Never BIGINT |
| `atb_date` | date, null | |
| **bookkeeping** | | |
| `error_code` / `error_descr` | varchar(100) / text | last ΚΕΔ rejection |
| `submitted_at` / `certified_at` | datetime, null | |
| `last_reconciled_at` | datetime, null | drives the scheduled sweep |
| `reconcile_attempts` | unsigned int | for backoff and for spotting rows stuck forever |
| `created_by_user_id` / `created_by_ip` | varchar(100) / varchar(45) | `auditUserId`/`auditUserIp` are mandatory (Παράρτημα Γ) and arrive as ordinary params |
| `unit_id` / `unit_acronym` | varchar(120), null / varchar(120), null | η μονάδα που υπέβαλλε τη βεβαίωση, as the BFF sends it — ours only, never sent to ΚΕΔ (the SOAP `auditUnit` stays `config('ked.audit_unit')`, the calling Φορέας). `unit_id` is indexed: the `list_beveoseis` filter (prefix match on either column). `unit_id` required on submission, `unit_acronym` optional; both optional on drafts. Null on pre-feature rows |
| `attachments` | json, null | local `[{title, filepath}]` — see the note below |
| `created_at` / `updated_at` | timestamps | list filtering is by `created_at` |

Indexes: `status`, `afm`, `created_at`, `(status, last_reconciled_at)` for the sweep,
`(mc_date, mc_no)` for reconciliation matching.

**Attachments** (added 2026-10) are the Φορέας' own metadata per βεβαίωση: `{title, filepath}`
rows where `filepath` points at their MinIO object storage — opaque to us, never fetched or
validated. The column is `->json()` (longtext + `JSON_VALID` check on MariaDB 10.6 — the first
JSON column in the schema) and the whole list is replaced on every write that carries it
(`set_beveosi_attachments`; optional on draft/submit). Because nothing here is ever transmitted,
the Παράρτημα Ζ lock does not apply: attachments are editable at **any** status, including
`certified` — the lock guards what ΚΕΔ has seen, and ΚΕΔ never sees this. Unrelated to the
deferred ΚΕΔ request elements `attachedFile`/`attFileName`/`attExtension` (the PDF απόφασης).
Served in detail only, never in the list summary.

**Duplicate guard.** The rule we need is "no two *live* βεβαιώσεις for the same
(afm, kae, fiscal_year, apof_no_etos)", where live means sent or beyond. Drafts and failed rows
must be free to repeat. MariaDB 10.6 has no partial indexes, but a unique index ignores NULLs. So
`duplicate_guard` holds `afm|kae|fiscal_year|apof_no_etos` while the row is live and NULL
otherwise, with a unique index on it. Any number of drafts coexist; the moment a second row goes
`sent` for the same debt, the database refuses it.

A **stored generated column** was the first choice, because it cannot be forgotten by a future
caller. MariaDB 10.6 rejects it — error 1901, «Function or expression … cannot be used in the
GENERATED ALWAYS AS clause» — and not because of the `CASE`: even `AS (afm) STORED` and
collation-pinned variants are refused. So the value is maintained in application code instead, by
`BeveosiCertification::guardKeyFor()`, which `CertificationService` calls on every status
transition. The unique index still does the real work: `CertificationServiceTest` proves a
duplicate is rejected even when the service is bypassed entirely and the row is inserted straight
through the query builder.

This is the last line of defence behind `DB::transaction` + `lockForUpdate()`, and it is what
protects against the BFF-timeout-then-user-resubmits path.

### `beveosi_debtors` — the AFM list, one row per ΑΦΜ

Position 0 is the οφειλέτης; the rest are συνυπόχρεοι. Both go in the same table because ΚΕΔ
sends them in the same repeated `AFM` element and returns a ΤΟ for each.

| column | type | notes |
|---|---|---|
| `certification_id` | FK, cascade | |
| `position` | unsigned tinyint | 0 = primary debtor |
| `afm` | char(12) | leading zeros significant |
| `full_name` | varchar(120), null | **UI only — never sent to ΚΕΔ** |
| `contact_phone` | varchar(20), null | **UI only — never sent to ΚΕΔ**; ο οφειλέτης only (replaced `father_name`, 2026-10: the client wanted a contact phone in the form instead) |
| `relation_code` | tinyint unsigned, null | NULL for the primary debtor |
| `relation_category` | tinyint unsigned, null | NULL for the primary debtor |
| `amount` | decimal(17,2) | |
| `line_no` | int unsigned, null | the debtor's γραμμή in the ΧΚ: the primary's arrives with `retrieveKedeAmount` (set at submit), the rest with `retrieveCloseDay` |
| `pay_id` | char(30), null | **Ταυτότητα Οφειλής, per γραμμή ΧΚ** — the same ΑΦΜ can recur on another γραμμή of the same ΧΚ with a different ΤΟ; the sole input key of `retrievePayProgress` / `retrievePaymentData`, surfaced as `taftotites` in every summary |
| `orig_amount` | decimal(17,2), null | from `retrieveCloseDay` |

Unique `(certification_id, afm)`. `(relation_code, relation_category)` must be one of the seven
pairs in `lookup_relations`.

### `beveosi_installments` — ο πίνακας δόσεων

`certification_id` FK, `aa` unsigned int, `due_date` date, `amount` decimal(17,2).
Unique `(certification_id, aa)`. No row may have a zero or empty amount — ΚΕΔ rejects the whole
βεβαίωση for it, and a rejected send still costs daily quota.

### `beveosi_kae_lines` — η λίστα ΚΑΕ

`certification_id` FK, `kae` char(5), `amount` decimal(17,2). Same zero-amount rule.

### `declared_signers` — οι υπογράφοντες

ΚΕΔ takes the **whole valid list** each time, never a delta, and caps it at 10.

`afm` char(12) unique, `first_name` varchar(50), `last_name` varchar(50), `is_active` bool,
`declared_at` datetime null, `last_sync_error` varchar(200) null, timestamps.

Kept locally so `submit_beveosi` can reject an undeclared `afmYpogr` **before** spending a ΚΕΔ
call, and so the BFF can render the signer dropdown from what ΚΕΔ actually accepted.

### `ked_call_log` — unchanged apart from one column

Already live from M1 and already written by `KedCallRecorder`. Adds `certification_id` (nullable
FK) so a row's whole ΚΕΔ conversation is retrievable. Keeping this journal is an obligation on the
Φορέας (Παράρτημα Γ), not a debugging nicety.

### `ked_audit_records` — the audit ledger

One row per outbound ΚΕΔ call, written by `KedAuditLedger` in two steps: the row is opened
**before** the wire hop (`outcome` NULL = in flight) and completed after it (`SUCCESS` / `ERROR`;
`LOST` is set only by the sweeper that rides `ked:reconcile`). A call killed mid-flight still
consumed ΚΕΔ quota — their counters include it, so the ledger must show the attempt.

Where `ked_call_log` keeps the full masked envelopes, this is the slim, queryable half: the six
Παράρτημα Γ audit values as columns, the outcome lifecycle, and ΚΕΔ's own `call_sequence_id`. The
pairing «our `auditTransactionId` ↔ their `callSequenceId`» is what makes pilot calls provable
against ΚΕΔ's logs — the evidence ΑΑΔΕ asks for before production credentials. Printed by
`ked:audit-report` (runbook §6a), whose `--out` CSV matches the template ΑΑΔΕ accepted from
katoikia (`docs/source_docs/audit/audit_records_202609031539.csv`).

The row `id` is a **UUID** (the template's first column). `audit_transaction_id` is the
**per-method counter** («1», «2», … — Παράρτημα Γ p. 33), unique only within
`(integration_name, action_name)`, which is the table's composite unique key.
`audit_transaction_date` stores the verbatim UTC string that went on the wire. `integration_name`
is the whole web service (`kedeProgressService`); `action_name` is the method. Βεβαιώσεις join
through `audit_protocol` — the SOAP client knows nothing about models, and that column is the one
identifier both sides of a call already share. Rows are never rewritten except by the outcome
write and the LOST sweep.

### `ked_audit_sequences` — the two counters

MariaDB has no sequences, so `KedAuditSequence` emulates them: one row per counter, bumped under
`lockForUpdate` (the duplicate-guard idiom), minted outside any DB transaction at call time.

- **per action** — `auditTransactionId`: row per `integration:action`, handed out by
  `AuditRecordFactory::make()`.
- **generic** — `auditProtocol`: `{n}/DD-MM-YYYY` (Παράρτημα Γ's own example format, p. 34).
  Minted **once per βεβαίωση** at draft creation and reused verbatim on every resend and on the
  closeDay call — regenerating it is how duplicate debts get raised at the ΔΟΥ (Παράρτημα Ζ).
  Signer declarations and sweep probes mint one-shot protocols from the same counter. The date is
  the mint date and never changes.

### Lookup tables

Seeded, served to the BFF as `lookup` responses.

- **`lookup_relations`** — `code`, `category`, `label_el`. Exactly the seven pairs from the spec
  (2/1 ΔΙΑΧΕΙΡΙΣΤΗΣ … 3/20 ΑΛΛΗΛΕΓΓΥΩΣ ΚΑΙ ΕΙΣ ΟΛΟΚΛΗΡΟΝ). A table rather than config because it is
  spec data the validator checks against.
- **`lookup_kae`** — `kae` char(5), `description_el`, `is_active`. Seeded with 82838. A table
  because ΑΑΔΕ may grant more.
- **`lookup_tax_types`** — `txt_code`, `description_el`, `is_active`. Seeded with 4102.

Statuses, `insFrequency` and `lastDayRule` are **not** tables. They are PHP enums with Greek
labels, served through the same `lookup` command — putting them in the database would let the
labels drift from the values the code branches on.

## State machine

```
draft ──submit──▶ sent ──answer OK──▶ certified_pending_closeday ──ΑΤΒ matched──▶ certified
  ▲                │                              │
  │                │ answer = rejection           │ (scheduled sweep)
  │                ▼                              │
  └──── failed ◀───┘                              │
        (unlocked, resendable, SAME audit_protocol)│
                   │
                   │ no answer at all (timeout, SoapFault)
                   ▼
        needs_reconciliation  (LOCKED — only proof of absence releases it)
```

`draft` and `failed` are unlocked. Everything from `sent` onwards is locked. The distinction that
matters: **a rejection is proof the debt was not registered** (unlock and let them fix it); **no
answer is proof of nothing** (stay locked). An empty `retrieveVerificationProgress` is not proof
either — the ΧΚ may open on a later date — so `needs_reconciliation` is never released
automatically. It surfaces to a human — and since Φάση 4 (2026-11-04) the human has a proper
tool, `artisan ked:settle`: `--absent` releases the row as `failed` (resendable, same
`audit_protocol`) with `settled_by`/`settled_at`/`settled_note` recording who decided and on
what evidence; `--found --mc-no=… --doy=…` records the ΧΚ and hands completion back to the
sweep. The one automatic exit is `KedeNeverConnectedException` — a transport failure at the
connect phase, before any byte was sent: provably nothing exists at ΚΕΔ, so a submit in that
case reverts the row to its previous state and answers `retryable: true` instead of locking.
Read timeouts keep the lock: the request was written, the outcome is unknown.

All six statuses are **ours**: the ΚΕΔ API has no status concept — it answers with error codes
and data (ΔΟΥ, ΧΚ, γραμμή, ΑΤΒ, Τ.Ο.), and these states encode the Παράρτημα Ζ lifecycle around
those answers. Beyond what Παράρτημα Ζ demands (locked-at-send, rejected, ambiguous, certified)
only `draft` and the `certified_pending_closeday` / `certified` split are additions of ours — the
split is forced: `retrieveKedeAmount` never returns the ΑΤΒ, so «certified but no Τ.Ο. yet» is a
real state the UI must be able to show.

## Scheduled reconciliation — new infrastructure

The sweep, roughly every 15 minutes:

1. Take the distinct `mc_date` of rows in `certified_pending_closeday` / `needs_reconciliation`.
2. One `retrieveVerificationProgress` per date. It returns **every** ΧΚ opened that date, ours
   among others — match on `result_doy` + `mc_no`, never on position.
3. One `retrieveCloseDay` per matched ΧΚ. Match `tofeilisRecord` rows to `beveosi_debtors` by
   `lineNo` and trimmed `afm`; write `atb_no`/`atb_date` on the parent and `pay_id`/`line_no`/
   `orig_amount` on each debtor; move the row to `certified`.
4. Row untouched → bump `reconcile_attempts`, leave locked.

This needs something running `artisan schedule:work`, which the compose file does not have today —
a fourth service, or a supervisor entry alongside `rabbitmq:read`. It also means we make ΚΕΔ calls
with no user present, so the daily quota (`GET_AUTHORIZATION_MAX_OPEN_CALLS_EXCEEDED`) becomes a
real budget: one call per date plus one per open ΧΚ, per sweep.

## Deleting

`draft` and `failed` can be deleted, hard — nothing outside our database knows the debt exists
under either one. Every other status is undeletable through this service:

| status | delete? | why |
|---|---|---|
| `draft` | yes, hard | never sent; ours alone |
| `failed` | yes, hard — but costs the audit_protocol | ΚΕΔ rejected it, so nothing exists at the ΔΟΥ. Correcting and resending (reusing the row, and with it the `audit_protocol` ΚΕΔ already saw) stays the recommended path; deleting is for whoever has decided to abandon the attempt instead — a later resubmission for the same debt then mints a brand-new `audit_protocol` rather than resuming the old one |
| `sent`, `certified_pending_closeday`, `certified` | **never** | a debt exists (or may exist) against a real person at the ΔΟΥ |
| `needs_reconciliation` | **never** | we do not know whether a debt exists — the whole point of the state |

Removing a real debt is Μείωση/Διαγραφή through **kedeDeleteService**, a separate service with its
own credentials — see `afek_records` below (M4, done). Deleting our row would not remove the
debt; it would only destroy our record of it.

## `afek_records` / `afek_kae_lines` — one Μείωση/Διαγραφή (M4)

An ΑΦΕΚ (Ατομικό Φύλλο Έκπτωσης) is its own entity, not a `CertificationStatus` case: a
certified debt can carry several Μειώσεις over time, and `certified` stays terminal on the
certification itself. `debtor_id` is the precise match target — `deptId`/`atbNo`/`mcNo`/`lineNo`
together identify one `beveosi_debtors` row (one Ταυτότητα Οφειλής), not the certification as a
whole, since a βεβαίωση with συνυπόχρεοι has several independently-reducible ones.
`certification_id` is denormalized from `debtor_id` so "every Μείωση for this certified debt" is
a plain `hasMany`, no join required. Both FKs are `restrictOnDelete`.

**`xk_line_no` vs `afek_line_no` — the easiest bug to introduce here.** The deleteKedeAmount
*request*'s `lineNo` is the ΧΚ line (`== beveosi_debtors.line_no`); the *response*'s `lineNo` is
the new ΑΦΕΚ's own line — a different number entirely. The spec's own Παράρτημα Ζ document
history exists because ΑΑΔΕ had to clarify this ambiguity to itself. Two separately-named
columns, never conflated.

Lifecycle (`App\Ked\Delete\AfekStatus`): `sent` → `awaiting_finalization` (deleteKedeAmount
succeeded, `afek_no` known) → `finalized` (terminal, deleteKedeComplete confirmed) / `failed`
(rejected, unlocked) / `needs_reconciliation` (no answer, stays locked). No `draft` state — a
Μείωση's input is small and single-shot, unlike a βεβαίωση's multi-day installment-planning
workflow. **The delete-service spec gives no Παράρτημα Ζ-style locking guide at all** (searched
the whole PDF — zero mentions of κλείδωμα/διπλ/lock); this state machine and the `duplicate_guard`
column are designed by analogy to `beveosi_certifications`, not derived from spec text. The guard
key is narrower than the certification side's: `debtor_id` plus the sorted set of targeted ΚΑΕ
codes, since two Μειώσεις against the same debt on disjoint ΚΑΕ are safe to run concurrently.

`afek_kae_lines` mirrors `beveosi_kae_lines` but `kae` is `CHAR(10)` here, not `CHAR(5)` — the
delete-service spec's own Παράρτημα Δ field table, not a typo. The remaining-deletable-balance
check (`kaeLines.*.amount` must not exceed what is left of that ΚΑΕ on the original debt) is
conservative: every non-`failed` ΑΦΕΚ already submitted for that certification/ΚΑΕ counts
against the balance, not just `finalized` ones (`DeleteKedeAmountRules::checkKaeBalance()`),
mirroring the certification side's duplicate-guard philosophy of never letting two in-flight
requests jointly overcommit.

The `decFile`/`attFileName`/`attExtension` decision-file attachment is pass-through only:
`attFileName`/`attExtension` are stored on `afek_records` (so detail views can show what was
attached), but the base64 content itself is never persisted — forwarded into the SOAP envelope
at submit time and then gone, same treatment as the progress service's still-unused
`attachedFile`.

## Open questions

1. **Can one ΧΚ carry several βεβαιώσεις? YES — answered by the pilot, 2026-08-07.** Δημόκριτος
   had reported that ΚΕΔ opens **one ΧΚ per ΑΦΜ**, i.e. no batching; that report was second-hand,
   and it is **wrong**. A pilot ΧΚ carried three γραμμές for the same ΑΦΜ from two separate
   βεβαιώσεις, all sharing one ΑΤΒ. The `mc_no` + `line_no` + per-debtor `pay_id` shape does
   represent this correctly, so no redesign. **The close-day matching that used to match on ΑΦΜ
   alone is fixed (2026-10-19)**: `ReconciliationService` now claims each `tofeilisRecord` by
   `line_no` first and only falls back to ΑΦΜ when it is unambiguous, so a late reconciliation
   can no longer hand a debtor another βεβαίωση's ΤΟ. Still unknown: how ΚΕΔ allocates
   γραμμές to συνυπόχρεοι — until that is answered (pilot test or ΑΑΔΕ), a συνυπόχρεος whose ΑΦΜ
   repeats in the ΧΚ is deliberately left with no ΤΟ rather than a guessed one.
2. **Sweep interval and daily quota.** Unknown. `GET_AUTHORIZATION_MAX_OPEN_CALLS_EXCEEDED` is a
   real error code, so a limit exists, but nobody has told us the number. Mitigation until then:
   the interval is config (`KED_RECONCILE_INTERVAL`), the sweep makes one call per open *date*
   rather than per row, and `reconcile_attempts` drives a backoff so a permanently stuck row stops
   consuming quota. Ask Δημόκριτος for the limit.
3. **Audit params.** `created_by_user_id` / `created_by_ip` come from `auditUserId` /
   `auditUserIp`, which the BFF sends as ordinary params — they confirmed they can put anything in
   the payload. Two things still to agree in `docs/message-contract.md`: both are **mandatory**
   (Παράρτημα Γ), so a submit without them is a validation error rather than a silent omission;
   and the names must be exactly `auditUserId`/`auditUserIp`. Their interpreter rewrites any param
   called `date`, `date_from`, `date_to`, `created_at` or `updated_at` through `Carbon::parse()`,
   so our list filters must avoid those names — `dateFrom`/`dateTo` are safe, `date_from` is not.
4. **Payments are deliberately unpersisted.** `get_payment_progress` / `get_payment_data` store
   nothing: every view is one live ΚΕΔ call, the audit obligation is already met by
   `ked_call_log` + `ked_audit_records`, `certified` is terminal so no reader exists for a
   snapshot, and payment rows have no natural unique key (the same payment returns in overlapping
   ranges) — freezing an invented one into a schema before a single live response has been seen
   is exactly the guess the «spec ≠ pilot» lesson warns about. If Δημόκριτος asks for
   list-screen «Υπόλοιπο» KPIs or a scheduled «πόσα εισπράχθηκαν» report, the deferred sketch is:
   `beveosi_payment_snapshots` (`beveosi_debtors` FK, `pay_id` char(30), 7 × decimal(17,2),
   `call_sequence_id`, `observed_at`, latest-wins) and/or `beveosi_payments` (`pay_id`,
   `payment_date`, `poso/kef/tokoi` decimal(17,2), the `dbt_*` columns, best-effort unique on
   `pay_id + payment_date + dbt_mc_no + dbt_mc_line + poso`). The command contracts do not change
   either way.
