Files
webshop/.agents/skills/grand-functions/references/schema.md

3.3 KiB

Datenmodell & Beziehungen (Schema)

Das Datenbankschema besteht aus folgenden Tabellen im Schema public:

companies (Unternehmen)

  • Repräsentiert die Partner-Unternehmen (Retailer).
  • id (UUID, Primary Key)
  • name (TEXT)
  • street, zip, city, email (Adressdaten)

users (Systembenutzer)

  • Erweitert die Authentifizierungsdaten aus auth.users.
  • id (UUID, References auth.users(id))
  • role (TEXT, standardmäßig 'partner', oder 'admin')
  • company_id (UUID, References public.companies(id))

end_customers (Endkunden)

  • Die Endkunden, für die die Partner Lizenzen bestellen.
  • id (UUID, Primary Key)
  • partner_id (UUID, References public.companies(id)) <-- Direkte Zuordnung zur Firma des Partners
  • company_name (TEXT)
  • first_name, last_name, street, zip, city, email (Stammdaten)
  • bank_iban, bank_bic, bank_name, bank_owner (Bankdaten)
  • is_anonymized (BOOLEAN) <-- Für DSGVO-Löschung

categories (Kategorien)

  • Steuert das Layout und Verhalten im Wizard.
  • id (UUID, Primary Key)
  • name (TEXT)
  • is_required (BOOLEAN) <-- Muss ausgewählt werden
  • allow_multiple (BOOLEAN) <-- Mehrfachauswahl erlaubt (Checkbox statt Radio)
  • sort_order (INTEGER) <-- Sortierung im Wizard
  • show_in_branches (BOOLEAN)
  • preselect (BOOLEAN)
  • resets_others (BOOLEAN)

products (Katalogprodukte / Basis-Editionen)

  • Hauptlösungen (z.B. Basic-Kasse, Backoffice).
  • id (UUID, Primary Key)
  • category_id (UUID, References categories)
  • name (TEXT)
  • base_price (DECIMAL)
  • tax_rate (DECIMAL)
  • billing_interval (TEXT: 'one_time' / 'monthly')
  • show_in_branches (BOOLEAN)

modules (Zusatzmodule / Erweiterungen)

  • Optionale Erweiterungen für Produkte.
  • id (UUID, Primary Key)
  • product_id (UUID, References products)
  • category_id (UUID, References categories)
  • name (TEXT)
  • price (DECIMAL)
  • has_quantity (BOOLEAN)

global_inclusions (Globale automatische Beigaben)

  • Regelt, welche Module bei Auswahl eines Produkts kostenlos enthalten sind.
  • id (UUID, Primary Key)
  • trigger_product_id (UUID, References products)
  • included_module_id (UUID, References modules)

global_exclusions (Globale Ausschlüsse)

  • Regelt Inkompatibilitäten zwischen Produkten und/oder Modulen.
  • id (UUID, Primary Key)
  • product_id (UUID, References products)
  • excluded_product_id (UUID, References products, optional)
  • excluded_module_id (UUID, References modules, optional)

orders (Bestellungen / Anfragen)

  • Gespeicherte Snapshots von Konfigurationen.
  • id (UUID, Primary Key)
  • user_id (UUID, References auth.users(id))
  • company_id (UUID, References public.companies(id))
  • end_customer_id (UUID, References end_customers(id))
  • order_number (TEXT, Format: AE-YYYY-NNNNN)
  • order_hash (TEXT, Idempotenz-Guard)
  • type (TEXT: 'purchase' / 'subscription') <-- Wichtig für den Checkout-Split
  • payment_method (TEXT) <-- Rechnung bei Kauf, SEPA bei Abo
  • total_price (DECIMAL)
  • customer_snapshot (JSONB) <-- Stammdaten zum Bestellzeitpunkt
  • order_snapshot (JSONB) <-- Konfiguration zum Bestellzeitpunkt
  • pdf_url (TEXT)
  • status (TEXT: 'pending', 'active', 'completed', 'cancelled')
  • created_at (TIMESTAMPTZ)