Files
laraundfelix/scripts/paket0-readonly-extra.sql
T
LarsandCursor 7820bececb
Deploy Test / test (push) Failing after 10s
Deploy Test / deploy (push) Skipped
Paket 1: eine aktive Angebotsfassung und Bestellbezeichnung
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-16 06:54:43 +01:00

19 lines
772 B
SQL

\echo '=== Aktive Angebotsfassungen (Überblick) ==='
SELECT ov.offer_id, o.name, ov.number, ov.grant_kind, ov.price_cents
FROM offer_versions ov
JOIN offers o ON o.id = ov.offer_id
WHERE ov.status = 'aktiv'
ORDER BY ov.offer_id, ov.number;
\echo '=== Heutige Registrierungslogik: alle aktiven personen-Registrierungsfassungen ==='
SELECT count(*)::int AS would_issue_count
FROM offer_versions
WHERE status = 'aktiv' AND grant_kind = 'bei_registrierung' AND holder_kind = 'person';
\echo '=== Grants je Angebot (über acquisition reference offer) ==='
SELECT a.reference_id AS offer_id, count(DISTINCT g.id)::int AS grant_count
FROM acquisitions a
JOIN grants g ON g.acquisition_id = a.id
WHERE a.reference_type = 'offer'
GROUP BY a.reference_id
ORDER BY a.reference_id;