Commit graph

93 commits

Author SHA1 Message Date
Thomas Reitz
068a7b81d5 fix(crm): fix voucher ID mapping — Lexware API returns 'id' not 'voucherId'
The voucherlist endpoint returns items with 'id' field, but our interface
defined it as 'voucherId', causing undefined IDs when fetching voucher details.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 18:37:23 +01:00
Thomas Reitz
4924875e92 fix(crm): add mandatory voucherStatus=any to Lexware voucherlist API call
The Lexware Office API requires voucherStatus as a mandatory parameter
for the /v1/voucherlist endpoint. Without it, the API returns 400 Bad
Request. Using 'any' fetches vouchers regardless of status.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 12:00:29 +01:00
Thomas Reitz
b4d1f33862 chore(crm): log Lexware API error response body for debugging
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 11:57:52 +01:00
Thomas Reitz
00f6b9842e fix(crm): link imported Ansprechpartner to CRM company via companyId
When importing contact persons from Lexware, if the parent company
is already in the CRM (detected via linkedMap), the companyId is now
passed to createContact so the contact is properly associated.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 11:20:07 +01:00
Thomas Reitz
332a623d6f fix(crm): fix Lexware import duplicate detection — pageSize 500 exceeded backend max 100
The backend DTO validation enforces @Max(100) on pageSize. The ImportTab
was requesting pageSize=500, causing a 400 Bad Request. This left the
linkedMap empty and showed import buttons for already-imported contacts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 11:12:32 +01:00
Thomas Reitz
6e77bf43b0 feat(crm): prevent duplicate Lexware imports — show linked status in import list
Import tab now loads all CRM companies/contacts and cross-references
lexwareContactId to detect already-imported entries. Linked contacts show
a green badge and "Öffnen" link instead of import buttons.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 10:48:32 +01:00
Thomas Reitz
ba4eec951a fix(crm): fix Lexware import 500 — tenantId validation in TenantGuard and service
- TenantGuard: remove PLATFORM_ADMIN bypass, require tenantId for all users
- lexware-contacts.service: add defensive tenantId check in importAsCompany
  and importAsContact with clear BadRequestException message

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 10:34:46 +01:00
Thomas Reitz
833bc44acd Update 2026-03-11 10:21:14 +01:00
Thomas Reitz
5bc9aebf64 docs(crm): report Lexware import 500 bug — tenantId passed as type instead of value
Bug in lexware-contacts.service.ts:229 — tenantId: String (type)
instead of tenantId: user.tenantId (value). Affects importCompany,
likely also importContact.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 10:08:34 +01:00
Thomas Reitz
84bfb75c18 docs(crm): add deployment log and frontend updates to INSIGHT-CRM.md
- Document white screen fix (missing hooks commit)
- Document server deployment: migrations, seed data, container restart
- Document CRM settings tabbed layout + Lexware import redesign
- List all commits and remaining open items for CRM backend developer

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 10:04:52 +01:00
Thomas Reitz
08b212bfde docs(crm): update INSIGHT-CRM.md with company detail overhaul entries
- Backend: Company Detail Overhaul with Industries, AccountTypes,
  RelationshipTypes, CompanyRelationships, Contracts entities
- Frontend: 3-column CompanyDetailPage, ActivityFeed, admin config sections
- Migration and seed data documentation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 10:00:36 +01:00
Thomas Reitz
0ed1e77844 feat(crm): add company detail overhaul with industries, account types, relationship types
- Backend: new CRUD services/controllers for Industries, AccountTypes,
  RelationshipTypes, CompanyRelationships with Prisma schema migration
- Frontend: new hooks, API functions, and types for all config entities
- CompanyDetailPage redesign with ActivityFeed, RelationshipsCard
- CompanyFormModal extended with industry, account type, owner fields
- Activities service now supports companyId filter + includeContacts

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 09:21:57 +01:00
Thomas Reitz
4e5c26cadd feat(frontend): add tabbed layout to CRM Settings page
- Restructure CRM Settings into 3 tabs: Module | Lexoffice Sync | Weitere Einstellungen
- Extract LexwareSyncContent as reusable component from LexwareSyncPage
- Embed Import/Export directly in Settings "Lexoffice Sync" tab
- Move Industries, AccountTypes, RelationshipTypes configs to "Weitere Einstellungen" tab
- Keep standalone /crm/lexware-sync route as fallback
- Add tab bar styles matching existing design pattern

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 09:07:16 +01:00
Thomas Reitz
55329188f6 feat(frontend): redesign Lexware Import with browsable list + Ansprechpartner
- Replace search-only ImportTab with paginated browsable list of all Lexware contacts
- Add expandable Ansprechpartner (contact persons) section per company
- Individual Ansprechpartner can be imported as CRM contacts
- Add pagination controls for navigating large contact lists
- Search filter still available (min. 3 chars, backend MinLength constraint)
- Clean up useLexwareContacts hook with proper query key

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 07:21:05 +01:00
Thomas Reitz
4f05026bc8 feat(frontend): add Lexware Office Import/Export admin page
New admin page under /crm/lexware-sync with two tabs:
- Import: Search Lexware contacts and import as CRM company or contact
- Export: List CRM companies/contacts and push to Lexware Office
Accessible via CRM Settings page (admin-only).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 23:00:42 +01:00
Thomas Reitz
6b847cb9f6 fix(frontend): move hooks before conditional return in Lexware components
React hooks must not be called after conditional returns (Rules of Hooks).
Moves all hook calls above the isModuleEnabled check in LexwareSection
and DealVouchersSection to prevent silent component crashes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 22:37:30 +01:00
Thomas Reitz
81d84e7eb0 docs(crm): document Lexware Office frontend integration
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 22:21:50 +01:00
Thomas Reitz
2381409e6d feat(frontend): add Lexware Office integration UI
Implements complete Lexware Office frontend integration:
- Types: LexwareVoucher, DealVoucher, LexwareContact, VoucherType
- API: lexwareContactsApi + lexwareVouchersApi (16 endpoints)
- Hooks: React Query hooks for search, link/unlink, sync, vouchers
- LexwareSection: reusable component for Company/Contact detail pages
  with status badge, sync/push/refresh buttons, and voucher table
- LexwareSearchModal: search Lexware contacts and link to CRM entities
- DealVouchersSection: link/unlink vouchers on Deal detail page
- CRM Settings: Lexware Office toggle (admin-configurable)
- Company/Contact/Deal detail pages extended with Lexware sections

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 22:20:18 +01:00
Thomas Reitz
9d496d2e53 feat(crm): integrate Lexware Office for vouchers and contact sync
Adds complete Lexware Office integration to CRM service:
- Rate-limited HTTP client (Token Bucket, 2 req/s)
- Bidirectional contact sync (manual import + ERP-push)
- Voucher caching (quotes, orders, invoices, credit notes)
- Deal-voucher linking (m:n join table with audit)
- Cron jobs: voucher refresh (4h), ERP push (30min)
- Distributed locks via Redis for job deduplication
- Health check extended with Lexware status
- Prisma schema: LexwareVoucher, DealVoucher, VoucherType enum
- Companies/Contacts/Deals services extended with Lexware data

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 20:28:41 +01:00
Thomas Reitz
411a6bbbcb feat(crm): add CRM Settings page with module visibility toggles
- New CrmSettingsContext with localStorage persistence (later swappable to API)
- CrmSettingsPage: toggle switches per CRM module (Kontakte, Unternehmen,
  Vorgänge, Pipelines), only accessible for PLATFORM_ADMIN/TENANT_ADMIN
- CrmModuleGuard: route protection for disabled modules (redirect to dashboard)
- Sidebar: NavLinks conditionally rendered based on module settings
- "Einstellungen" NavLink in CRM section (admin-only, gear icon)
- CRM section hidden when all modules disabled and user is not admin

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 20:22:16 +01:00
Thomas Reitz
028364cd7d docs(crm): document Company module frontend implementation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 20:13:28 +01:00
Thomas Reitz
36f571f5c3 feat(crm): add Company module + extend Contact/Deal with company relation
- New Company CRUD: CompaniesPage (list/search/pagination), CompanyFormModal,
  CompanyDetailPage (contacts + deals tables)
- Sidebar: "Unternehmen" NavLink between Kontakte and Vorgänge
- ContactsPage: Company column, ContactFormModal: company search + position field,
  ContactDetailPage: company link + position display
- DealsPage: Company column, DealFormModal: company search dropdown,
  DealDetailPage: company link in info card
- Types/API/Hooks extended with Company entity, cross-entity query invalidation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 20:10:58 +01:00
Thomas Reitz
a13cca054b docs(crm): document Company entity for frontend developer
Update INSIGHT-CRM.md with complete Company API documentation,
Contact/Deal changes (companyId, position), and frontend integration
suggestions. Update Summarize.md with current test results.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 19:47:39 +01:00
Thomas Reitz
ab4898210e docs(crm): frontend update nach backend-feedback
- Stage-Editing, DealDetail-Optimierung, Deals→Vorgänge Renaming
- Offene Punkte aktualisiert

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 19:40:29 +01:00
Thomas Reitz
0b78160f33 feat(crm): inline stage editing, DealDetail optimization, rename Deals to Vorgänge
- PipelinesPage: Stages können jetzt per Doppelklick oder Stift-Icon
  inline bearbeitet werden (Name, Farbe) via PATCH endpoint
- DealDetailPage: Nutzt jetzt deal.pipeline.stages direkt statt
  separatem usePipeline() API-Call (Backend liefert alle Stages mit)
- UI-Texte: "Deals" → "Vorgänge", "Deal" → "Vorgang" in allen
  user-facing Strings (Sidebar, Seiten, Modals, Fehlermeldungen)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 19:38:58 +01:00
Thomas Reitz
56a9ed9647 feat(crm): add Company entity + rename Deals to Vorgaenge
- New Company model with full CRUD under /api/v1/crm/companies
- Contact now has companyId relation + position field
- Deal now has companyId relation
- Company detail includes contacts (top 20) and deals (top 10)
- All endpoints include company in responses
- Swagger tags renamed: Deals -> Vorgaenge (Deals)
- Error messages use "Vorgang" instead of "Deal"

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 19:30:34 +01:00
Thomas Reitz
3d8f568c9a docs(crm): backend response to frontend integration report
Confirmed all 6 frontend assumptions, documented new PATCH stage
endpoint and HTTPS router. Activity list already supported.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 19:23:53 +01:00
Thomas Reitz
c9e2c4a44c feat(crm): add PATCH endpoint for pipeline stages + HTTPS router
- New PATCH /pipelines/:id/stages/:stageId endpoint to update
  stage name, color, and sortOrder
- Added HTTPS (websecure) Traefik router for CRM service
- Both requested by frontend developer via INSIGHT-CRM.md

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 19:22:33 +01:00
Thomas Reitz
f62d032480 docs: CRM-Kommunikationsdatei mit Frontend-Integrationsstand
Initiale Dokumentation des CRM-Frontend-Status fuer die Abstimmung
zwischen Frontend- und Backend-Entwickler.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 19:18:34 +01:00
Thomas Reitz
c739dce161 feat: CRM Frontend-Modul mit Kontakte, Deals, Pipelines und Aktivitäten
Komplette CRM-Frontend-Integration in die bestehende React-GUI:

- Types, API-Client und React Query Hooks für alle CRM-Entitäten
- Kontakte: Liste mit Suche/Filter, Detail mit Aktivitäten-Timeline, Create/Edit Modal
- Deals: Liste mit Pipeline/Stage/Status-Filter, Detail mit Fortschrittsbalken, Create/Edit Modal
- Pipelines: Verwaltungsseite mit klappbaren Cards und Stage-Management
- Aktivitäten: Formular-Modal für Notizen, Anrufe, E-Mails, Meetings, Aufgaben
- CRM-Navigation in Sidebar (aufklappbar, mit Inline-SVG-Icons)
- Routen in App.tsx für alle CRM-Seiten
- Vite-Proxy für lokale CRM-API-Entwicklung

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 19:13:02 +01:00
Thomas Reitz
f65b9fb930 docs(crm): add frontend integration guide for CRM module
Comprehensive developer handoff document covering all CRM API endpoints,
TypeScript interfaces, response formats, React Query hook patterns,
and recommended frontend structure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 18:17:11 +01:00
Thomas Reitz
43877bbb4a docs(crm): update Summarize.md with deployment status and test results
All CRM endpoints tested successfully on insight-dev-01.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 18:08:00 +01:00
Thomas Reitz
525fe006e9 fix(crm): add Host rule and priority to Traefik router
Core-api router with Host+PathPrefix(/api) was catching CRM requests.
Added Host rule and priority=100 to ensure CRM router takes precedence
for /api/v1/crm/* paths.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 17:39:51 +01:00
Thomas Reitz
a03d1d0586 fix(crm): correct Traefik middleware name to cors-api@file
The CORS middleware is named cors-api, not cors-headers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 17:38:13 +01:00
Thomas Reitz
aa5fc2e44d fix(crm): use direct postgres connection instead of pgbouncer
PgBouncer in transaction pool mode strips the search_path startup
parameter, which Prisma needs for the app_crm schema. CRM now
connects directly to PostgreSQL.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 16:34:56 +01:00
Thomas Reitz
86e5d36e98 fix(crm): correct pgbouncer port from 6432 to 5432
PgBouncer listens internally on port 5432, not 6432.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 16:30:23 +01:00
Thomas Reitz
b3eb533fa7 chore(crm): add package-lock.json for Docker build
npm ci requires package-lock.json to ensure reproducible builds.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 16:20:35 +01:00
Thomas Reitz
094db465cb feat(crm): add standalone dev environment and test token generator
- docker-compose.crm-dev.yml: isolierte Testumgebung (PostgreSQL + Redis + CRM)
- scripts/generate-token.ts: generiert Test-JWTs fuer curl-basiertes API-Testing
- scripts/init-schema.sql: erstellt app_crm Schema beim DB-Start
- keys/: Test-RSA-Schluessel (nur fuer lokale Entwicklung!)
- Fix: multiSchema previewFeature entfernt (deprecated)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 16:03:59 +01:00
Thomas Reitz
8783d01fc0 feat(crm): scaffold CRM service with full CRUD modules
Eigenstaendiger NestJS-Service unter packages/crm-service/ mit:
- Prisma Schema (app_crm): Contact, Activity, Pipeline, PipelineStage, Deal
- JWT RS256 Auth mit shared Public Key und Token-Revocation
- Multi-Tenancy: TenantGuard + tenantId-Filter auf allen Queries
- CRUD-Module: Contacts, Activities, Pipelines, Deals
- Docker-Integration: docker-compose.crm.yml (Port 3100, Traefik-Route /api/v1/crm)
- Health-Check, Swagger, GlobalExceptionFilter, Pagination

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 15:54:13 +01:00
Thomas Reitz
ffd48a38a3 Update Briefing 2026-03-10 15:30:07 +01:00
Thomas Reitz
b18fe9376c docs: add CRM service handoff document for new dev session
Comprehensive briefing for a new Claude Code chat to build the CRM
container service, including: protected paths, architecture overview,
JWT validation, database schema conventions, Docker integration,
multi-tenancy rules, and quick-start guide.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 15:18:04 +01:00
Thomas Reitz
15ea7627e8 docs: add developer integration guide for container applications
Comprehensive guide (INTEGRATION.md) explaining how external container
applications can integrate with the INSIGHT platform, including:
- Docker network integration and service discovery
- JWT authentication and token validation (RS256)
- API endpoints and communication patterns
- Traefik routing configuration
- Database access via PgBouncer
- Redis caching with namespace conventions
- Frontend sidebar integration
- Security requirements and checklist
- Example docker-compose extension

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 12:52:01 +01:00
Thomas Reitz
8f738cadb5 chore: hide Mandanten tab from admin navigation
Temporarily removed until multi-tenancy is implemented.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 12:20:54 +01:00
Thomas Reitz
96834c541c fix: enlarge brand/logo section in sidebar
- Increase min-height from 56px to 68px
- Logo maxHeight 32px → 44px, maxWidth 140px → 160px
- Brand title font-size 1.25rem → 1.5rem
- More padding in brand area

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 12:17:14 +01:00
Thomas Reitz
ca3938a933 fix: move theme toggle below profile section in sidebar
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 12:16:24 +01:00
Thomas Reitz
3bedda2b9d feat: dark mode, collapsible sidebar, branding customization
- Add Light/Dark/System theme toggle with ThemeContext and CSS variables
- Sidebar fully collapsible (icons-only mode, persisted in localStorage)
- Anwendungen section collapsible with chevron toggle
- Admin "Anpassungen" page: logo upload, sidebar color picker with presets
- Backend branding endpoints (GET/POST /settings/branding) stored in Redis
- Optional custom icon upload for external links (click icon field)
- Backend favicon proxy with HTML parsing for reliable icon loading
- Dark mode CSS variables for all components
- Login page SSO button and error styles use CSS variables

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 11:47:51 +01:00
Thomas Reitz
0f9b3d4f36 feat: backend favicon proxy with HTML parsing, collapsible sidebar sections
- Add GET /settings/favicon?url= endpoint that parses HTML for <link rel="icon"> tags
- Falls back to /favicon.ico if no icon link found in HTML
- Caches favicon URLs in Redis (24h TTL)
- Frontend uses backend proxy for reliable favicon loading (fixes Atlassian etc.)
- Anwendungen section in sidebar is now collapsible with chevron toggle

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 11:29:19 +01:00
Thomas Reitz
0a52606012 fix: use direct favicon.ico, open links in app mode (popup window)
- Favicon loaded directly from website's /favicon.ico instead of
  Google's service (which was unreliable/blocked on internal networks)
- Letter-initial fallback when favicon can't be loaded
- External links open in popup window (app mode) instead of new tab

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 11:23:11 +01:00
Thomas Reitz
65c5c7b7dd feat: use website favicons instead of manual icon upload
External links now automatically show the favicon of the target website
using Google's favicon service. No manual icon upload needed — just
enter label and URL.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 11:19:34 +01:00
Thomas Reitz
f89e06c09d fix: use proper gear icon for admin section in sidebar
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 11:11:48 +01:00