diff --git a/concepts/Billing-Konzept.md b/concepts/Billing-Konzept.md index 29067f4..71ce24d 100644 --- a/concepts/Billing-Konzept.md +++ b/concepts/Billing-Konzept.md @@ -1082,20 +1082,21 @@ Jedes AICore-Plugin definiert seine eigenen Preise via `calculatePriceCHF()`. Di gateway/modules/ ├── aicore/ │ ├── aicoreModelSelector.py # Provider-Filter via RBAC -│ ├── aicorePluginAnthropic.py # Preise auf CHF mit 50% Aufschlag -│ ├── aicorePluginOpenai.py # Preise auf CHF mit 50% Aufschlag +│ ├── aicorePluginAnthropic.py # Preise auf CHF mit 50% Aufschlag anpassen +│ ├── aicorePluginOpenai.py # Preise auf CHF mit 50% Aufschlag anpassen +│ ├── aicorePluginPerplexity.py # Preise auf CHF mit 50% Aufschlag anpassen +│ ├── aicorePluginTavily.py # Preise auf CHF mit 50% Aufschlag anpassen │ └── aicoreBase.py # connectorType für Billing ├── datamodels/ -│ ├── datamodelChat.py # ChatWorkflow.mandateId hinzufügen -│ └── datamodelUam.py # Mandate-Referenz +│ └── datamodelUam.py # Mandate-Referenz (keine Änderung an Chat-Modellen!) ├── interfaces/ -│ ├── interfaceBootstrap.py # Root-Mandant Billing Setup + RBAC +│ ├── interfaceBootstrap.py # Root-Mandant Billing Setup + RBAC für Provider │ └── interfaceRbac.py # Resource-Berechtigungen für Provider ├── workflows/ -│ ├── automation/mainWorkflow.py # Billing-Integration -│ └── processing/workflowProcessor.py # Balance-Checks + RBAC Provider-Check -└── routes/ - └── routeChat.py # mandateId im Workflow speichern +│ └── processing/workflowProcessor.py # Balance-Checks + RBAC Provider-Check + BillingTransaction +└── features/ + ├── chatplayground/ # Billing-Integration (mandateId aus Context) + └── automation/ # Billing-Integration (mandateId bereits vorhanden) ``` ### Neu zu erstellen @@ -1105,11 +1106,75 @@ gateway/modules/ ├── datamodels/ │ └── datamodelBilling.py # Neue Billing-Modelle ├── interfaces/ -│ └── interfaceDbBilling.py # Billing CRUD-Operationen +│ └── interfaceDbBilling.py # Billing CRUD-Operationen (poweron_billing DB) ├── services/ │ └── serviceBilling/ │ ├── mainServiceBilling.py # Zentrale Billing-Logik │ └── subBillingReports.py # Report-Generierung └── routes/ └── routeBilling.py # Billing API-Endpoints + +frontend_nyla/src/ +├── pages/ +│ └── billing/ # Billing UI-Seiten +└── components/ + └── billing/ # Billing-Komponenten (Charts, etc.) ``` + +--- + +## Implementierungs-Checkliste + +### Vor der Implementierung zu klären + +- [ ] **AICore Preise:** Aktuelle Preise sind in USD definiert. Müssen auf CHF umgestellt werden mit 50% Aufschlag. +- [ ] **Datenbank:** Neue `poweron_billing` Datenbank oder in `poweron_app` integrieren? +- [ ] **Email-Service:** Welcher Email-Provider wird für Billing-Benachrichtigungen verwendet? + +### Phase 1: Backend Grundstruktur + +- [ ] `datamodelBilling.py` erstellen (BillingAccount, BillingTransaction, BillingSettings, UsageStatistics, BillingAddress) +- [ ] `interfaceDbBilling.py` erstellen (CRUD-Operationen) +- [ ] Datenbank-Migrations-Script erstellen +- [ ] AICore-Plugins: Preise von USD auf CHF umstellen (`calculatepriceCHF` mit echten CHF-Werten) + +### Phase 2: Service-Layer + +- [ ] `mainServiceBilling.py` implementieren (Balance-Check, Transaction-Recording, Provider-Check via RBAC) +- [ ] RBAC-Integration: `resource.aicore.*` Resources registrieren +- [ ] Bootstrap: Billing-Settings für ROOT-Mandant, RBAC-Berechtigungen für Provider + +### Phase 3: Workflow-Integration + +- [ ] `workflowProcessor.py`: BillingService integrieren +- [ ] Vor AI-Call: Balance prüfen, Provider-Berechtigung prüfen +- [ ] Nach AI-Call: BillingTransaction erstellen (mit mandateId aus Request-Context) +- [ ] Exception-Handling: InsufficientBalanceException, ProviderNotAllowedException + +### Phase 4: API-Endpoints + +- [ ] `routeBilling.py` erstellen +- [ ] User-Endpoints: Balance, Transactions, Statistics +- [ ] Admin-Endpoints: Settings, Credit-Aufladung, Mandanten-Übersicht + +### Phase 5: Frontend (Nyla) + +- [ ] Billing-Container in Navigation integrieren +- [ ] Dashboard-Seite: Guthaben-Übersicht, Charts +- [ ] Transaktions-Seite: Historie mit Filterung +- [ ] Admin-Seite: Mandanten-Verwaltung, Guthaben-Aufladung +- [ ] Chat Playground: Provider-Auswahl UI +- [ ] Automation Editor: Tab "LLM Modelle" + +### Phase 6: Reports & Notifications + +- [ ] Email-Templates erstellen (Monatsreport, Balance-Warnung) +- [ ] Scheduler für Monatsreport (1. jeden Monats) +- [ ] Balance-Warnung bei Unterschreitung der Schwelle + +### Qualitätssicherung + +- [ ] Unit-Tests für BillingService +- [ ] Integration-Tests für Workflow mit Billing +- [ ] E2E-Tests für Billing-UI +- [ ] Datenmigration für bestehende Mandanten testen