feat(T04): contact management + USt-IdNr. validation + contact UI

- Contact model: company, role (kaeufer/verkaeufer/beide), soft-delete
- ContactPerson model: 1:N relation with CASCADE delete
- USt-IdNr. validation: DE + 10 EU countries
- Contact CRUD: 7 API endpoints with RBAC, search/filter/paginate
- Frontend: ContactList, ContactForm, ContactDetail with EU/Inland toggle
- 73 backend tests (91% coverage), 20 frontend tests
This commit is contained in:
2026-07-14 12:14:21 +02:00
parent 74b5e6afb8
commit 2cf433a01c
20 changed files with 3002 additions and 97 deletions
+25
View File
@@ -68,3 +68,28 @@
- Backend: 73/73 pytest passed, 82% total coverage
- Frontend: 16/16 vitest passed
- test_report.md updated
---
## T04: Kontakt-/Kundenverwaltung + Contact UI (2026-07-14)
### Backend
- models/contact.py: Contact + ContactPerson models with UUID PK, soft-delete, CHECK constraints for role/vat_id_status/country
- schemas/contact.py: ContactCreate/Update/Response/ListResponse + ContactPersonCreate/Response with VAT ID field_validator
- utils/ust_validation.py: DE + 10 EU country regex patterns, EU fallback, validate_vat_id, validate_vat_id_or_raise, get_country_code_from_vat_id
- services/contact_service.py: list_contacts (search, role filter with beide inclusion, is_eu filter, is_private filter, sort, pagination), get_contact_by_id, create_contact (with nested persons), update_contact, soft_delete_contact, add_contact_person, remove_contact_person
- routers/contacts.py: 7 endpoints (list, create, detail, update, delete, add person, remove person) with RBAC (all read, admin+verkaeufer write)
- main.py: Registered contacts router
### Frontend
- lib/contacts.ts: Full API client with typed interfaces + validateVatIdFormat frontend validation
- components/contacts/ContactList.tsx: Table with search, role filter, EU/Inland filter, sort, pagination
- components/contacts/ContactForm.tsx: Create/edit form with USt-IdNr. validation, EU/Inland toggle, country selector, role, legal form, address, contact info, is_private
- components/contacts/ContactDetail.tsx: Detail view with contact persons management (add/remove via Modal)
- app/[locale]/kontakte/: list page, neu (create) page, [id] detail page
- tests/contacts.test.tsx: 20 tests
### Test Results
- Backend: 73/73 pytest passed, 91% coverage on contact modules (service 99%, ust_validation 94%, models 93%, schemas 94%, router 67%)
- Frontend: 20/20 vitest passed
- test_report.md updated