frontend költség beállítások
This commit is contained in:
774
docs/db_schema_audit.md
Normal file
774
docs/db_schema_audit.md
Normal file
@@ -0,0 +1,774 @@
|
||||
# 🏗️ P0 DEEP ARCHITECTURE AUDIT — Teljes Adatbázis Séma Audit
|
||||
|
||||
**Dátum:** 2026-06-20
|
||||
**Hatáskör:** Teljes SQLAlchemy modellréteg (`backend/app/models/`)
|
||||
**Elemzett fájlok:** 26 modellfájl
|
||||
**Feltárt kapcsolatok:** 95 ForeignKey, 65 relationship() deklaráció
|
||||
**JSONB mezők:** 56 darab
|
||||
|
||||
---
|
||||
|
||||
## Tartalomjegyzék
|
||||
1. [Séma Áttekintés](#1-séma-áttekintés)
|
||||
2. [Teljes Táblalista Sémánként](#2-teljes-táblalista-sémánként)
|
||||
3. [Kapcsolati Térkép (Entity-Relationship)](#3-kapcsolati-térkép-entity-relationship)
|
||||
4. [Központi Entitás: Asset (Digital Twin)](#4-központi-entitás-asset-digital-twin)
|
||||
5. [JSONB Mezők Teljes Feltárása](#5-jsonb-mezők-teljes-feltárása)
|
||||
6. [Redundancia Analízis](#6-redundancia-analízis)
|
||||
7. [Hiányosság Elemzés — Admin, Biztosítás, Adó](#7-hiányosság-elemzés)
|
||||
8. [Architekturális Javaslat — Admin & Pénzügyi Adatok Tárolása](#8-architekturális-javaslat)
|
||||
9. [Függelék: Teljes FK-relationship Mátrix](#9-függelék-teljes-fk-relationship-mátrix)
|
||||
|
||||
---
|
||||
|
||||
## 1. Séma Áttekintés
|
||||
|
||||
Az adatbázis **9 PostgreSQL sémára** van bontva, Domain-Driven Design (DDD) elvek szerint:
|
||||
|
||||
| Séma | Táblák száma | Elsődleges Domain |
|
||||
|------|-------------|-------------------|
|
||||
| `vehicle` | ~28 | Járművek, katalógus, költségek, események |
|
||||
| `identity` | 10 | Személyek, felhasználók, tárcák, eszközök |
|
||||
| `fleet` | 7 | Szervezetek, tagok, telephelyek, asset-hozzárendelés |
|
||||
| `system` | 14 | Rendszerparaméterek, dokumentumok, értesítések, címek |
|
||||
| `marketplace` | 10 | Szolgáltatók, szakértői címkék, felfedezés |
|
||||
| `finance` | 7 | Kibocsátók, fizetési szándékok, kivételi kérelmek |
|
||||
| `audit` | 4 | Biztonsági napló, műveleti napló, főkönyv |
|
||||
| `gamification` | 9 | Pontok, szintek, jelvények, szezonok |
|
||||
| `marketing` | 7 | Kampányok, kreatívok, elhelyezések, hirdetések |
|
||||
| **ÖSSZESEN** | **~96 tábla** | |
|
||||
|
||||
---
|
||||
|
||||
## 2. Teljes Táblalista Sémánként
|
||||
|
||||
### 2.1 `vehicle` séma (~28 tábla)
|
||||
|
||||
| Tábla | Modell | Fájl | Leírás |
|
||||
|-------|--------|------|--------|
|
||||
| `vehicle.vehicle_types` | `VehicleType` | `vehicle_definitions.py:17` | Jármű kategóriák JSONB `units`-szal |
|
||||
| `vehicle.feature_definitions` | `FeatureDefinition` | `vehicle_definitions.py:33` | Felszereltség jegyzék |
|
||||
| `vehicle.vehicle_model_definitions` | `VehicleModelDefinition` | `vehicle_definitions.py:48` | **MDM Master** — 60+ mező, 4 JSONB, UniqueConstraint 7 mezőn |
|
||||
| `vehicle.model_feature_maps` | `ModelFeatureMap` | `vehicle_definitions.py:148` | M:N modell↔felszereltség |
|
||||
| `vehicle.dict_body_types` | `BodyTypeDictionary` | `vehicle_definitions.py:162` | Karosszéria típusok i18n-nel |
|
||||
| `vehicle.vehicle_catalog` | `AssetCatalog` | `asset.py:14` | Katalógus bejegyzés, JSONB `factory_data` |
|
||||
| `vehicle.assets` | `Asset` | `asset.py:69` | **Digital Twin** — 84 oszlop, központi entitás |
|
||||
| `vehicle.asset_financials` | `AssetFinancials` | `asset.py:246` | Beszerzési/amortizációs adatok |
|
||||
| `vehicle.asset_costs` | `AssetCost` | `asset.py:271` | TCO költségek |
|
||||
| `vehicle.vehicle_logbook` | `VehicleLogbook` | `asset.py:312` | NAV menetlevél GPS-szel |
|
||||
| `vehicle.asset_inspections` | `AssetInspection` | `asset.py:341` | Napi ellenőrző lista |
|
||||
| `vehicle.asset_reviews` | `AssetReview` | `asset.py:357` | Jármű értékelések |
|
||||
| `vehicle.vehicle_ownership_history` | `VehicleOwnership` | `asset.py:373` | Tulajdonosváltozások |
|
||||
| `vehicle.asset_telemetry` | `AssetTelemetry` | `asset.py:389` | Telemetria (1:1) |
|
||||
| `vehicle.odometer_readings` | `OdometerReading` | `asset.py:398` | Kilométeróra állások időrendben |
|
||||
| `vehicle.asset_assignments` | `AssetAssignment` | `asset.py:415` | Asset↔Organization kapcsolat |
|
||||
| `vehicle.asset_events` | `AssetEvent` | `asset.py:447` | **Digitális Szervizkönyv** |
|
||||
| `vehicle.exchange_rates` | `ExchangeRate` | `asset.py:492` | Árfolyamok |
|
||||
| `vehicle.catalog_discovery` | `CatalogDiscovery` | `asset.py:499` | Robot felfedező munkaterület |
|
||||
| `vehicle.vehicle_expenses` | `VehicleExpenses` | `asset.py:528` | Költség reporting |
|
||||
| `vehicle.vehicle_transfer_requests` | `VehicleTransferRequest` | `asset.py:546` | Asset átadás-átvétel workflow |
|
||||
| `vehicle.cost_categories` | `CostCategory` | `vehicle.py:19` | Hierarchikus költségkategóriák |
|
||||
| `vehicle.costs` | `VehicleCost` | `vehicle.py:64` | **⚠️ VMD-hez kötve, NEM Asset-hez!** |
|
||||
| `vehicle.vehicle_user_ratings` | `VehicleUserRating` | `vehicle.py:112` | 4-dimenziós felhasználói értékelés |
|
||||
| `vehicle.gb_catalog_discovery` | `GbCatalogDiscovery` | `vehicle.py:168` | GB piaci felfedező robot |
|
||||
| `vehicle.motorcycle_specs` | `MotorcycleSpecs` | `motorcycle_specs.py:6` | Motor technikai adatok JSONB-ben |
|
||||
| `vehicle.external_reference_library` | `ExternalReferenceLibrary` | `external_reference.py:6` | Külső referencia könyvtár |
|
||||
| `vehicle.external_reference_queue` | `ExternalReferenceQueue` | `external_reference_queue.py:6` | Külső referencia várólista |
|
||||
| `vehicle.reference_lookup` | `ReferenceLookup` | `reference_data.py` | Referencia kereső JSONB-vel |
|
||||
|
||||
### 2.2 `identity` séma (10 tábla)
|
||||
|
||||
| Tábla | Modell | Fájl | Leírás |
|
||||
|-------|--------|------|--------|
|
||||
| `identity.persons` | `Person` | `identity.py:37` | **DNS** — valós személy, soha nem törölhető |
|
||||
| `identity.users` | `User` | `identity.py:126` | Login entitás, GDPR törölhető |
|
||||
| `identity.wallets` | `Wallet` | `identity.py:223` | Triple Wallet |
|
||||
| `identity.verification_tokens` | `VerificationToken` | `identity.py:244` | Jóváhagyó tokenek |
|
||||
| `identity.social_accounts` | `SocialAccount` | `identity.py:258` | Közösségi fiókok |
|
||||
| `identity.active_vouchers` | `ActiveVoucher` | `identity.py:276` | Aktív utalványok |
|
||||
| `identity.user_trust_profiles` | `UserTrustProfile` | `identity.py:290` | Gondos Gazda Index |
|
||||
| `identity.one_time_passwords` | `OneTimePassword` | `identity.py:321` | Egyszeri jelszavak |
|
||||
| `identity.devices` | `Device` | `identity.py:340` | Eszköz fingerprint |
|
||||
| `identity.user_device_links` | `UserDeviceLink` | `identity.py:355` | User↔Device kapcsolat |
|
||||
|
||||
### 2.3 `fleet` séma (7 tábla)
|
||||
|
||||
| Tábla | Modell | Fájl | Leírás |
|
||||
|-------|--------|------|--------|
|
||||
| `fleet.organizations` | `Organization` | `organization.py:70` | **Központi szervezet** — lifecycle |
|
||||
| `fleet.org_roles` | `OrgRole` | `organization.py:39` | Dinamikus RBAC JSONB-vel |
|
||||
| `fleet.organization_financials` | `OrganizationFinancials` | `organization.py:215` | Éves pénzügyi adatok |
|
||||
| `fleet.organization_members` | `OrganizationMember` | `organization.py:230` | Tagok (user/person/invited_email) |
|
||||
| `fleet.organization_sales_assignments` | `OrganizationSalesAssignment` | `organization.py:268` | Értékesítési hozzárendelés |
|
||||
| `fleet.branches` | `Branch` | `organization.py:279` | Telephelyek PostGIS-szel |
|
||||
| `fleet.asset_assignments` | `AssetAssignment` | `asset.py:415` | Asset-szervezet kapcsolat |
|
||||
|
||||
### 2.4 `system` séma (14 tábla)
|
||||
|
||||
| Tábla | Modell | Fájl | Leírás |
|
||||
|-------|--------|------|--------|
|
||||
| `system.system_parameters` | `SystemParameter` | `system.py:19` | Hierarchikus paraméterek |
|
||||
| `system.internal_notifications` | `InternalNotification` | `system.py:40` | Értesítések |
|
||||
| `system.system_data_completion_weights` | `SystemDataCompletionWeight` | `system.py:62` | Kitöltöttségi súlyok |
|
||||
| `system.system_service_staging` | `SystemServiceStaging` | `system.py:85` | Szolgáltatás staging |
|
||||
| `system.documents` | `Document` | `document.py:11` | NAS-alapú doksi metatároló |
|
||||
| `system.legal_documents` | `LegalDocument` | `legal.py:9` | Jogi dokumentumok |
|
||||
| `system.legal_acceptances` | `LegalAcceptance` | `legal.py:24` | Jogi elfogadások |
|
||||
| `system.translations` | `Translation` | `translation.py:8` | Fordítások |
|
||||
| `system.geo_postal_codes` | `GeoPostalCode` | `address.py:12` | Irányítószám kereső |
|
||||
| `system.geo_streets` | `GeoStreet` | `address.py:22` | Utca regiszter |
|
||||
| `system.geo_street_types` | `GeoStreetType` | `address.py:31` | Utca típusok |
|
||||
| `system.addresses` | `Address` | `address.py:39` | Univerzális cím GPS-szel |
|
||||
| `system.pending_actions` | `PendingAction` | `security.py:22` | **Sentinel** — 4 szem elv |
|
||||
| `system.subscription_tiers` | `SubscriptionTier` | `core_logic.py:12` | Előfizetési csomagok |
|
||||
|
||||
### 2.5 `marketplace` séma (10 tábla)
|
||||
|
||||
| Tábla | Modell | Fájl | Leírás |
|
||||
|-------|--------|------|--------|
|
||||
| `marketplace.service_profiles` | `ServiceProfile` | `service.py:21` | Szolgáltatói profilok PostGIS-szel |
|
||||
| `marketplace.expertise_tags` | `ExpertiseTag` | `service.py:79` | **4-szintű hierarchia** |
|
||||
| `marketplace.service_expertises` | `ServiceExpertise` | `service.py:142` | M:N profil↔tag |
|
||||
| `marketplace.service_staging` | `ServiceStaging` | `service.py:158` | Szolgáltatás staging |
|
||||
| `marketplace.discovery_parameters` | `DiscoveryParameter` | `service.py:184` | Felfedezési paraméterek |
|
||||
| `marketplace.costs` | `Cost` | `service.py:196` | Költségek |
|
||||
| `marketplace.service_specialties` | `ServiceSpecialty` | `core_logic.py:88` | Önhivatkozó hierarchia |
|
||||
| `marketplace.service_providers` | `ServiceProvider` | `social.py:22` | Közösségi szolgáltatók |
|
||||
| `marketplace.ratings` | `Rating` | `address.py:77` | Univerzális értékelés |
|
||||
| `marketplace.service_reviews` | `ServiceReview` | `social.py:86` | Ellenőrzött értékelések |
|
||||
| `marketplace.votes` | `Vote` | `social.py:46` | Közösségi szavazatok |
|
||||
|
||||
### 2.6 `finance` séma (7 tábla)
|
||||
|
||||
| Tábla | Modell | Fájl | Leírás |
|
||||
|-------|--------|------|--------|
|
||||
| `finance.issuers` | `Issuer` | `finance.py:27` | Számlakibocsátók |
|
||||
| `finance.payment_intents` | `PaymentIntent` | `payment.py:30` | **Double Lock** |
|
||||
| `finance.withdrawal_requests` | `WithdrawalRequest` | `payment.py:147` | Kivételi kérelmek |
|
||||
| `finance.org_subscriptions` | `OrganizationSubscription` | `core_logic.py:25` | Szervezeti előfizetés |
|
||||
| `finance.user_subscriptions` | `UserSubscription` | `core_logic.py:49` | Felhasználói előfizetés |
|
||||
| `finance.credit_logs` | `CreditTransaction` | `core_logic.py:72` | Kredit napló |
|
||||
| `finance.exchange_rates` | `ExchangeRate` | `asset.py:492` | Árfolyamok |
|
||||
|
||||
### 2.7 `audit` séma (4 tábla)
|
||||
|
||||
| Tábla | Modell | Fájl | Leírás |
|
||||
|-------|--------|------|--------|
|
||||
| `audit.security_audit_logs` | `SecurityAuditLog` | `audit.py:12` | Biztonsági események |
|
||||
| `audit.operational_logs` | `OperationalLog` | `audit.py:29` | Napi műveletek |
|
||||
| `audit.process_logs` | `ProcessLog` | `audit.py:43` | Robot naplók |
|
||||
| `audit.financial_ledger` | `FinancialLedger` | `audit.py:78` | **Központi főkönyv** |
|
||||
|
||||
### 2.8 `gamification` séma (9 tábla)
|
||||
|
||||
| Tábla | Modell | Fájl | Leírás |
|
||||
|-------|--------|------|--------|
|
||||
| `gamification.point_rules` | `PointRule` | `gamification.py:13` | Akció→pont szabályok |
|
||||
| `gamification.level_configs` | `LevelConfig` | `gamification.py:23` | Szintküszöbök |
|
||||
| `gamification.points_ledger` | `PointsLedger` | `gamification.py:33` | XP/büntetés tranzakciók |
|
||||
| `gamification.user_stats` | `UserStats` | `gamification.py:49` | Aggregált statok |
|
||||
| `gamification.badges` | `Badge` | `gamification.py:71` | Jelvények |
|
||||
| `gamification.user_badges` | `UserBadge` | `gamification.py:80` | M:N user↔jelvény |
|
||||
| `gamification.user_contributions` | `UserContribution` | `gamification.py:95` | Hozzájárulások |
|
||||
| `gamification.seasons` | `Season` | `gamification.py:136` | Szezonok |
|
||||
| `gamification.seasonal_competitions` | `SeasonalCompetitions` | `gamification.py:149` | Versenyek |
|
||||
|
||||
### 2.9 `marketing` séma (7 tábla)
|
||||
|
||||
| Tábla | Modell | Fájl | Leírás |
|
||||
|-------|--------|------|--------|
|
||||
| `marketing.campaigns` | `Campaign` | `marketing.py:65` | Kampányok JSONB célzással |
|
||||
| `marketing.creatives` | `Creative` | `marketing.py:126` | Kreatív anyagok |
|
||||
| `marketing.placements` | `Placement` | `marketing.py:174` | Hirdetési felületek |
|
||||
| `marketing.campaign_creatives` | `CampaignCreative` | `marketing.py:204` | M:N kampány↔kreatív |
|
||||
| `marketing.campaign_placements` | `CampaignPlacement` | `marketing.py:226` | M:N kampány↔elhelyezés |
|
||||
| `marketing.ad_impressions` | `AdImpression` | `marketing.py:247` | Hirdetési megjelenések |
|
||||
| `marketing.ad_clicks` | `AdClick` | `marketing.py:276` | Hirdetési kattintások |
|
||||
|
||||
---
|
||||
|
||||
## 3. Kapcsolati Térkép (Entity-Relationship)
|
||||
|
||||
### 3.1 Vizuális Összefoglaló
|
||||
|
||||
```mermaid
|
||||
erDiagram
|
||||
ASSET ||--o{ ASSET_COST : van
|
||||
ASSET ||--o{ ASSET_EVENT : van
|
||||
ASSET ||--o{ VEHICLE_LOGBOOK : van
|
||||
ASSET ||--o{ ASSET_INSPECTION : van
|
||||
ASSET ||--o{ ASSET_REVIEW : van
|
||||
ASSET ||--o{ ODOMETER_READING : van
|
||||
ASSET ||--o{ VEHICLE_OWNERSHIP : van
|
||||
ASSET ||--o{ ASSET_ASSIGNMENT : van
|
||||
ASSET ||--o{ SERVICE_REQUEST : van
|
||||
ASSET ||--o{ VEHICLE_TRANSFER : van
|
||||
ASSET ||--|| ASSET_FINANCIALS : 1:1
|
||||
ASSET ||--|| ASSET_TELEMETRY : 1:1
|
||||
ASSET ||--o| ASSET_CATALOG : katalogus
|
||||
|
||||
PERSON ||--o{ USER : fiók
|
||||
PERSON ||--o{ ORGANIZATION : tulajdonol
|
||||
USER ||--|| WALLET : 1:1
|
||||
USER ||--|| USER_TRUST_PROFILE : 1:1
|
||||
USER ||--|| USER_STATS : 1:1
|
||||
|
||||
ORGANIZATION ||--o{ MEMBER : tagok
|
||||
ORGANIZATION ||--o{ BRANCH : telephely
|
||||
ORGANIZATION ||--o{ ASSET_ASSIGNMENT : jarmuvek
|
||||
ORGANIZATION ||--o| SERVICE_PROFILE : szolgaltato
|
||||
|
||||
VMD ||--o{ ASSET_CATALOG : varians
|
||||
VMD ||--o{ VEHICLE_COST : koltseg
|
||||
VMD ||--o{ VEHICLE_RATING : ertekeles
|
||||
```
|
||||
|
||||
### 3.2 Kritikus Kapcsolatok
|
||||
|
||||
#### ✳️ FIGYELEM: `VehicleCost` eltérő referenciája
|
||||
A [`VehicleCost`](backend/app/models/vehicle/vehicle.py:64) `vehicle_id` mezeje a [`VehicleModelDefinition`](backend/app/models/vehicle/vehicle_definitions.py:48)-re mutat, **NEM** az [`Asset`](backend/app/models/vehicle/asset.py:69)-re! Ez architekturális anomália: a költségek a modelldefinícióhoz vannak kötve, nem a konkrét járműpéldányhoz.
|
||||
|
||||
#### ✳️ Többféle cost modell
|
||||
- [`VehicleCost`](backend/app/models/vehicle/vehicle.py:64) — VMD-hez kötött
|
||||
- [`AssetCost`](backend/app/models/vehicle/asset.py:271) — Asset-hez kötött (TCO)
|
||||
- [`VehicleExpenses`](backend/app/models/vehicle/asset.py:528) — Asset-hez kötött (expense)
|
||||
- [`Cost`](backend/app/models/marketplace/service.py:196) — MarketPlace költség
|
||||
|
||||
#### ✳️ Person-User Dual Entity
|
||||
- [`Person`](backend/app/models/identity/identity.py:37) — DNS, halhatatlan, `merged_into_id` self-ref
|
||||
- [`User`](backend/app/models/identity/identity.py:126) — Login entitás, törölhető
|
||||
- `OrganizationMember` mindkettőhöz kötődhet
|
||||
|
||||
#### ✳️ Önhivatkozó hierarchiák (7 darab)
|
||||
1. [`CostCategory`](backend/app/models/vehicle/vehicle.py:19) — `parent_id` self
|
||||
2. [`ExpertiseTag`](backend/app/models/marketplace/service.py:79) — `parent_id` + `path` (4 szint)
|
||||
3. [`ServiceSpecialty`](backend/app/models/core_logic.py:88) — `parent_id` self
|
||||
4. [`User.referred_by_id`](backend/app/models/identity/identity.py:149) — self
|
||||
5. [`User.current_sales_agent_id`](backend/app/models/identity/identity.py:150) — self
|
||||
6. [`Person.merged_into_id`](backend/app/models/identity/identity.py:76) — self
|
||||
7. [`ServiceProfile.parent_id`](backend/app/models/marketplace/service.py:31) — self
|
||||
|
||||
---
|
||||
|
||||
## 4. Központi Entitás: Asset (Digital Twin)
|
||||
|
||||
Az [`Asset`](backend/app/models/vehicle/asset.py:69) a rendszer központi entitása, **84 oszloppal** és **12+ kapcsolattal**.
|
||||
|
||||
### 4.1 Asset mezőstruktúra
|
||||
|
||||
```yaml
|
||||
# === AZONOSÍTÓ ÉS KATALÓGUS ===
|
||||
id: UUID (PK) | catalog_id: FK vezerel.vehicle_catalog.id | name: String
|
||||
|
||||
# === JÁRMŰ SPECIFIKUS (DENORMALIZÁLT) ===
|
||||
vin: String(17) | license_plate: String(20) | make: String(100)
|
||||
model: String(255) | year: Integer | variant: String(100)
|
||||
fuel_type: String(50) | engine_size: Integer | color: String(50)
|
||||
seats: Integer | body_type: String(50) | transmission_type: String(30)
|
||||
drivetrain: String(30) | mileage_unit: String(10)
|
||||
|
||||
# === MŰSZAKI ADATOK ===
|
||||
power_hp: Integer | power_kw: Integer | torque_nm: Integer
|
||||
co2_emission: Integer | euro_class: String(10) | emission_class: String(10)
|
||||
|
||||
# === FELSZERELTSÉG ===
|
||||
audio_system_type: String(100)
|
||||
individual_equipment: JSONB # ← CRITICAL: is_primary itt tárolva!
|
||||
|
||||
# === REGISZTRÁCIÓS DOKUMENTUMOK (RÉSZLEGES) ===
|
||||
registration_certificate_number: String(50)
|
||||
registration_certificate_validity: DateTime
|
||||
vehicle_registration_document_number: String(50)
|
||||
|
||||
# === SZERVEZET ÉS LOKÁCIÓ ===
|
||||
current_organization_id: FK | branch_id: FK | relocation_performed: Boolean
|
||||
|
||||
# === TULAJDONOS ÉS ÜZEMELTETŐ ===
|
||||
owner_person_id: FK | owner_org_id: FK
|
||||
operator_person_id: FK | operator_org_id: FK
|
||||
|
||||
# === ÁLLAPOT ===
|
||||
status: String(30) | data_status: String(20) | current_mileage: Integer
|
||||
condition_score: Integer(0-100)
|
||||
|
||||
# === IDŐBÉLYEGEK ===
|
||||
created_at | updated_at | first_registration_date | purchase_date
|
||||
warranty_expiry | last_technical_inspection | next_inspection_date
|
||||
```
|
||||
|
||||
### 4.2 Asset kapcsolati kép
|
||||
|
||||
```
|
||||
Asset
|
||||
├──1:1──► AssetFinancials (pénzügy)
|
||||
├──1:N──► AssetCost (TCO költségek)
|
||||
├──1:N──► AssetEvent (Digitális Szervizkönyv)
|
||||
├──1:N──► VehicleLogbook (NAV menetlevél)
|
||||
├──1:N──► AssetInspection (napi ellenőrzés)
|
||||
├──1:N──► AssetReview (értékelések)
|
||||
├──1:1──► AssetTelemetry
|
||||
├──1:N──► OdometerReading (óraállás)
|
||||
├──1:N──► VehicleOwnership (tulajdonosváltozás)
|
||||
├──1:N──► AssetAssignment (→Organization)
|
||||
├──1:N──► ServiceRequest
|
||||
├──1:N──► VehicleTransferRequest
|
||||
├──N:1──► AssetCatalog
|
||||
├──N:1──► Organization (current)
|
||||
├──N:1──► Branch
|
||||
├──N:1──► Person (owner/operator)
|
||||
└──N:1──► Organization (owner/operator)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 5. JSONB Mezők Teljes Feltárása
|
||||
|
||||
Összesen **56 JSONB mező** található. Alább a kritikusak.
|
||||
|
||||
### 5.1 `Asset.individual_equipment` — KRITIKUS
|
||||
|
||||
**Deklaráció:** [`asset.py:114`](backend/app/models/vehicle/asset.py:114)
|
||||
|
||||
```python
|
||||
individual_equipment: Mapped[dict] = mapped_column(JSONB, server_default=text("'{}'::jsonb"))
|
||||
```
|
||||
|
||||
**Jelenlegi tartalom:**
|
||||
```json
|
||||
{
|
||||
"is_primary": true|false,
|
||||
// + extra felszerelések
|
||||
}
|
||||
```
|
||||
|
||||
**Probléma:** Az `is_primary` logikai mező JSONB-ben van elrejtve, lekérdezhetetlen index nélkül. ORM szinten computed property-ként van kezelve (lásd [`asset.py:183-198`](backend/app/models/vehicle/asset.py:183)).
|
||||
|
||||
### 5.2 Többi Kritikus JSONB Mező
|
||||
|
||||
| Modell | Mező | Cél |
|
||||
|--------|------|-----|
|
||||
| `AssetCatalog` | `factory_data` | Gyári adatok |
|
||||
| `AssetFinancials` | `accounting_details` | Számviteli részletek |
|
||||
| `AssetCost` | `data` | Költség metaadatok |
|
||||
| `VehicleModelDefinition` | `marketing_name_aliases` | Alternatív nevek |
|
||||
| `VehicleModelDefinition` | `raw_api_data` | API nyers válasz |
|
||||
| `VehicleModelDefinition` | `research_metadata` | Kutatási adatok |
|
||||
| `VehicleModelDefinition` | `specifications` | Specifikációk |
|
||||
| `Person` | `identity_docs` | Személyi docs |
|
||||
| `Person` | `ice_contact` | Vészhelyzeti kapcsolat |
|
||||
| `User` | `visual_settings` | UI beállítások |
|
||||
| `User` | `custom_permissions` | Egyedi jogok |
|
||||
| `User` | `alternative_emails` | Alternatív emailek |
|
||||
| `User` | `email_history` | Email változások |
|
||||
| `Organization` | `visual_settings` | Cég UI beállítások |
|
||||
| `Organization` | `settings` | Cég beállítások |
|
||||
| `Organization` | `aliases` | Alias nevek |
|
||||
| `Organization` | `tags` | Címkék |
|
||||
| `Organization` | `notification_settings` | Értesítési beállítások |
|
||||
| `Organization` | `external_integration_config` | Külső integráció |
|
||||
| `ServiceProfile` | `vibe_analysis` | AI hangulatelemzés |
|
||||
| `ServiceProfile` | `social_links` | Közösségi linkek |
|
||||
| `ServiceProfile` | `specialization_tags` | Specializációk |
|
||||
| `ServiceProfile` | `verification_log` | Ellenőrzési napló |
|
||||
| `ServiceProfile` | `opening_hours` | Nyitvatartás |
|
||||
| `ExpertiseTag` | `name_translations` | Többnyelvű név |
|
||||
| `ExpertiseTag` | `search_keywords` | Kulcsszavak |
|
||||
| `OrgRole` | `permissions` | Capability flag-ek |
|
||||
| `Branch` | `opening_hours` | Nyitvatartás |
|
||||
| `Rating` | `images` | Képek array |
|
||||
| `Campaign` | `targeting` | Célzás |
|
||||
| `AssetInspection` | `checklist_results` | Ellenőrző lista |
|
||||
| `PendingAction` | `payload` | Műveleti adatok |
|
||||
| `SubscriptionTier` | `rules` | Csomag szabályok |
|
||||
| `OrganizationSubscription` | `extra_allowances` | **Booster architektúra** |
|
||||
| `SystemParameter` | `value` | Paraméter érték |
|
||||
| `InternalNotification` | `data` | Értesítési adatok |
|
||||
| `SystemServiceStaging` | `raw_data` | Nyers staging adat |
|
||||
| `FinancialLedger` | `details` | Tranzakció részletek |
|
||||
|
||||
---
|
||||
|
||||
## 6. Redundancia Analízis
|
||||
|
||||
### 6.1 MAGAS KOCKÁZATÚ
|
||||
|
||||
#### 1. Dupla Költség Rendszer
|
||||
| Tábla | Referencia | Cél |
|
||||
|-------|-----------|-----|
|
||||
| `VehicleCost` | vehicle_id → VMD.id | ❌ Anomália |
|
||||
| `AssetCost` | asset_id → Asset.id | ✅ Helyes |
|
||||
| `VehicleExpenses` | vehicle_id → Asset.id | ✅ Helyes |
|
||||
|
||||
**Kockázat:** `VehicleCost` a modell-definícióhoz köt, nem a konkrét járműhöz.
|
||||
|
||||
#### 2. Háromszoros kilométeróra tárolás
|
||||
- `Asset.current_mileage` — denormalizált utolsó érték
|
||||
- `OdometerReading.reading` — időbeli adatsor
|
||||
- `AssetTelemetry.current_mileage` — harmadik helyen!
|
||||
|
||||
#### 3. Asset mezők duplikációja
|
||||
`make`, `model`, `year`, `variant`, `fuel_type` szerepel:
|
||||
- `Asset`-ben (denormalizált)
|
||||
- `VehicleModelDefinition`-ben (eredeti)
|
||||
- `AssetCatalog`-ban (katalógus)
|
||||
|
||||
#### 4. Cím adatok duplikációja
|
||||
`Branch` denormalizált címmezőket tartalmaz `Address` mellett.
|
||||
|
||||
### 6.2 KÖZEPES KOCKÁZATÚ
|
||||
|
||||
#### 5. Kettős tulajdonos mezők
|
||||
- `Organization.owner_id` → users (technikai, törölhető)
|
||||
- `Organization.legal_owner_id` → persons (jogi, halhatatlan)
|
||||
|
||||
Szándékos (Dual Entity), de potenciális konfúzió.
|
||||
|
||||
#### 6. Subscription mezők duplikációja
|
||||
`Organization` denormalizáltan tárolja a `subscription_plan`, `base_asset_limit`, `purchased_extra_slots` mezőket, melyek az `OrganizationSubscription`-ban is szerepelnek.
|
||||
|
||||
### 6.3 ALACSONY KOCKÁZAT (szándékos)
|
||||
- `owner_person_id` + `owner_org_id` — B2B/B2C miatt
|
||||
- Triple Wallet mezők — szándékos
|
||||
|
||||
---
|
||||
|
||||
## 7. Hiányosság Elemzés
|
||||
|
||||
### 7.1 Jelenlegi Állapot
|
||||
|
||||
| Domain | Státusz | Megjegyzés |
|
||||
|--------|---------|------------|
|
||||
| **Regisztrációs doksik** | ⚠️ Részleges | 3 mező az Asset-en |
|
||||
| **Műszaki vizsga** | ⚠️ Részleges | 2 mező (last/next) |
|
||||
| **Első forgalomba helyezés** | ✅ Van | `first_registration_date` |
|
||||
| **KGFB biztosítás** | ❌ HIÁNYZIK | Nincs adatmodell |
|
||||
| **Casco biztosítás** | ❌ HIÁNYZIK | Nincs adatmodell |
|
||||
| **Súlyadó** | ❌ HIÁNYZIK | Nincs adatmodell |
|
||||
| **Cégautó adó** | ❌ HIÁNYZIK | Nincs adatmodell |
|
||||
| **Forgalmi engedély** | ⚠️ Részleges | Csak szám + érvényesség |
|
||||
| **Törzskönyv** | ⚠️ Részleges | Csak szám |
|
||||
| **Import megkülönböztetés** | ❌ HIÁNYZIK | Nincs |
|
||||
| **Expected/Recurring költségek** | ❌ HIÁNYZIK | Nincs |
|
||||
|
||||
### 7.2 Specifikus Hiányzó Mezők
|
||||
|
||||
#### Biztosítás (teljesen hiányzik)
|
||||
```
|
||||
insurance_type: KGFB/CASCO/BOTH
|
||||
insurer_name, policy_number, contract_date
|
||||
start_date, expiry_date
|
||||
premium_amount, premium_currency
|
||||
bonus_malus_level (0-20)
|
||||
deductible_amount, is_active, status, notes
|
||||
```
|
||||
|
||||
#### Adók (teljesen hiányzik)
|
||||
```
|
||||
tax_type: WEIGHT_TAX/COMPANY_CAR_TAX/PERFORMANCE_TAX
|
||||
tax_year, tax_amount, tax_currency
|
||||
payment_date, payment_status
|
||||
tax_authority, tax_period_start/end, notes
|
||||
```
|
||||
|
||||
#### Admin (részleges)
|
||||
```
|
||||
MEGLÉVŐ: registration_certificate_number, registration_certificate_validity, vehicle_registration_document_number
|
||||
HIÁNYZÓ: registration_type (FIRST_HU/FIRST_FOREIGN/IMPORT_USED)
|
||||
first_hungarian_registration_date, first_foreign_registration_date
|
||||
title_deed_number, title_deed_issue_date
|
||||
engine_number, number_of_previous_owners
|
||||
original_plate_number, import_country
|
||||
```
|
||||
|
||||
#### Ütemezett költségek (teljesen hiányzik)
|
||||
```
|
||||
expected_cost_type: INSURANCE/TAX/SERVICE/INSPECTION/TIRE_CHANGE/OTHER
|
||||
expected_amount, currency, frequency (MONTHLY/QUARTERLY/YEARLY/ONE_TIME)
|
||||
next_due_date, last_paid_date, is_recurring
|
||||
category_id FK, description, reminder_days_before
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 8. Architekturális Javaslat
|
||||
|
||||
### 8.1 Ajánlott: Dedikált táblák (előnyben részesített)
|
||||
|
||||
```sql
|
||||
-- Biztosítási kötvények
|
||||
vehicle.vehicle_insurance_policies
|
||||
├── id: UUID PK
|
||||
├── asset_id: UUID FK -> vehicle.assets.id
|
||||
├── insurance_type: ENUM(KGFB, CASCO, BOTH)
|
||||
├── insurer_name, policy_number, contract_date, start_date, expiry_date
|
||||
├── premium_amount, premium_currency, bonus_malus_level
|
||||
├── deductible_amount, status, data: JSONB
|
||||
|
||||
-- Adókötelezettségek
|
||||
vehicle.vehicle_tax_obligations
|
||||
├── id: UUID PK
|
||||
├── asset_id: UUID FK -> vehicle.assets.id
|
||||
├── tax_type: ENUM(WEIGHT_TAX, COMPANY_CAR_TAX, PERFORMANCE_TAX)
|
||||
├── tax_year, tax_amount, tax_currency
|
||||
├── payment_date, payment_status, tax_period_start/end
|
||||
├── data: JSONB
|
||||
|
||||
-- Ütemezett költségek
|
||||
vehicle.vehicle_expected_costs
|
||||
├── id: UUID PK
|
||||
├── asset_id: UUID FK -> vehicle.assets.id
|
||||
├── cost_type: ENUM(INSURANCE, TAX, SERVICE, INSPECTION, TIRE_CHANGE, OTHER)
|
||||
├── expected_amount, currency, frequency
|
||||
├── next_due_date, last_paid_date, is_recurring
|
||||
├── category_id FK -> cost_categories.id
|
||||
├── description, reminder_days_before, status, data: JSONB
|
||||
|
||||
-- Regisztrációs dokumentumok (kibővítve)
|
||||
vehicle.vehicle_registration_documents
|
||||
├── id: UUID PK
|
||||
├── asset_id: UUID FK -> vehicle.assets.id UNIQUE
|
||||
├── registration_type: ENUM(FIRST_HU, FIRST_FOREIGN, IMPORT_USED)
|
||||
├── first_hungarian_registration_date, first_foreign_registration_date
|
||||
├── title_deed_number, title_deed_issue_date
|
||||
├── engine_number, number_of_previous_owners
|
||||
├── original_plate_number, import_country, data: JSONB
|
||||
```
|
||||
|
||||
### 8.2 Alternatíva: Meglévő modellek bővítése (gyorsabb)
|
||||
|
||||
#### `Asset` bővítése:
|
||||
```python
|
||||
first_hungarian_registration_date: Mapped[Optional[date]]
|
||||
first_foreign_registration_date: Mapped[Optional[date]]
|
||||
import_country: Mapped[Optional[str]]
|
||||
title_deed_number: Mapped[Optional[str]]
|
||||
engine_number: Mapped[Optional[str]]
|
||||
number_of_previous_owners: Mapped[Optional[int]]
|
||||
```
|
||||
|
||||
#### `AssetFinancials` bővítése:
|
||||
```python
|
||||
insurance_kgfb_policy_number: Mapped[Optional[str]]
|
||||
insurance_kgfb_expiry: Mapped[Optional[date]]
|
||||
insurance_kgfb_premium: Mapped[Optional[float]]
|
||||
insurance_casco_policy_number: Mapped[Optional[str]]
|
||||
insurance_casco_expiry: Mapped[Optional[date]]
|
||||
insurance_casco_premium: Mapped[Optional[float]]
|
||||
bonus_malus_level: Mapped[Optional[int]]
|
||||
```
|
||||
|
||||
### 8.3 Ajánlott Megvalósítási Sorrend
|
||||
|
||||
1. **P1** — `VehicleInsurancePolicy` új modell (dedikált tábla)
|
||||
2. **P1** — `VehicleTaxObligation` új modell (dedikált tábla)
|
||||
3. **P2** — `VehicleExpectedCost` új modell (ütemezett költségek)
|
||||
4. **P2** — `VehicleRegistrationDocument` új modell (admin adatok elkülönítése)
|
||||
5. **P3** — `individual_equipment.is_primary` kivezetése dedikált boolean oszlopba
|
||||
|
||||
---
|
||||
|
||||
## 9. Függelék: Teljes FK-relationship Mátrix
|
||||
|
||||
### 9.1 Minden ForeignKey
|
||||
|
||||
```
|
||||
=== VEHICLE SÉMA ===
|
||||
AssetCatalog.master_definition_id -> vehicle.vehicle_model_definitions.id
|
||||
Asset.catalog_id -> vehicle.vehicle_catalog.id
|
||||
Asset.current_organization_id -> fleet.organizations.id
|
||||
Asset.branch_id -> fleet.branches.id
|
||||
Asset.owner_person_id -> identity.persons.id
|
||||
Asset.owner_org_id -> fleet.organizations.id
|
||||
Asset.operator_person_id -> identity.persons.id
|
||||
Asset.operator_org_id -> fleet.organizations.id
|
||||
AssetFinancials.asset_id -> vehicle.assets.id (UNIQUE)
|
||||
AssetCost.asset_id -> vehicle.assets.id
|
||||
AssetCost.organization_id -> fleet.organizations.id
|
||||
AssetCost.category_id -> vehicle.cost_categories.id
|
||||
AssetCost.document_id -> system.documents.id
|
||||
AssetCost.linked_asset_event_id -> vehicle.asset_events.id
|
||||
VehicleLogbook.asset_id -> vehicle.assets.id
|
||||
VehicleLogbook.driver_id -> identity.users.id
|
||||
AssetInspection.asset_id -> vehicle.assets.id
|
||||
AssetInspection.inspector_id -> identity.users.id
|
||||
AssetReview.asset_id -> vehicle.assets.id
|
||||
AssetReview.user_id -> identity.users.id
|
||||
VehicleOwnership.asset_id -> vehicle.assets.id
|
||||
VehicleOwnership.user_id -> identity.users.id
|
||||
AssetTelemetry.asset_id -> vehicle.assets.id (UNIQUE)
|
||||
OdometerReading.asset_id -> vehicle.assets.id
|
||||
OdometerReading.cost_id -> vehicle.asset_costs.id
|
||||
AssetAssignment.asset_id -> vehicle.assets.id
|
||||
AssetAssignment.organization_id -> fleet.organizations.id
|
||||
AssetEvent.asset_id -> vehicle.assets.id
|
||||
AssetEvent.user_id -> identity.users.id
|
||||
AssetEvent.organization_id -> fleet.organizations.id
|
||||
AssetEvent.cost_id -> vehicle.asset_costs.id
|
||||
AssetEvent.linked_expense_id -> vehicle.asset_costs.id
|
||||
VehicleExpenses.vehicle_id -> vehicle.assets.id
|
||||
VehicleTransferRequest.asset_id -> vehicle.assets.id
|
||||
VehicleTransferRequest.requester_id -> identity.users.id
|
||||
VehicleTransferRequest.current_owner_id -> identity.persons.id
|
||||
VehicleTransferRequest.proof_document_id -> system.documents.id
|
||||
VehicleCost.vehicle_id -> vehicle.vehicle_model_definitions.id
|
||||
VehicleCost.organization_id -> fleet.organizations.id
|
||||
VehicleCost.category_id -> vehicle.cost_categories.id
|
||||
VehicleUserRating.vehicle_id -> vehicle.vehicle_model_definitions.id
|
||||
VehicleUserRating.user_id -> identity.users.id
|
||||
CostCategory.parent_id -> vehicle.cost_categories.id (self-ref)
|
||||
FeatureDefinition.vehicle_type_id -> vehicle.vehicle_types.id
|
||||
VehicleModelDefinition.vehicle_type_id -> vehicle.vehicle_types.id
|
||||
ModelFeatureMap.model_definition_id -> vehicle.vehicle_model_definitions.id
|
||||
ModelFeatureMap.feature_id -> vehicle.feature_definitions.id
|
||||
MotorcycleSpecs.(FK) -> vehicle.auto_data_crawler_queue.id
|
||||
ExternalReferenceLibrary.matched_vmd_id -> vehicle.vehicle_model_definitions.id
|
||||
|
||||
=== IDENTITY SÉMA ===
|
||||
Person.address_id -> system.addresses.id
|
||||
Person.merged_into_id -> identity.persons.id (self-ref)
|
||||
Person.user_id (active_user) -> identity.users.id
|
||||
User.person_id -> identity.persons.id
|
||||
User.referred_by_id -> identity.users.id (self-ref)
|
||||
User.current_sales_agent_id -> identity.users.id (self-ref)
|
||||
Wallet.user_id -> identity.users.id (UNIQUE)
|
||||
Wallet.organization_id -> fleet.organizations.id
|
||||
VerificationToken.user_id -> identity.users.id
|
||||
SocialAccount.user_id -> identity.users.id
|
||||
ActiveVoucher.wallet_id -> identity.wallets.id
|
||||
UserTrustProfile.user_id -> identity.users.id (PK)
|
||||
UserDeviceLink.user_id -> identity.users.id
|
||||
UserDeviceLink.device_hash -> identity.devices.fingerprint_hash
|
||||
|
||||
=== FLEET SÉMA ===
|
||||
Organization.legal_owner_id -> identity.persons.id
|
||||
Organization.address_id -> system.addresses.id
|
||||
Organization.subscription_tier_id -> system.subscription_tiers.id
|
||||
Organization.owner_id -> identity.users.id
|
||||
OrganizationFinancials.organization_id -> fleet.organizations.id
|
||||
OrganizationMember.organization_id -> fleet.organizations.id
|
||||
OrganizationMember.user_id -> identity.users.id
|
||||
OrganizationMember.person_id -> identity.persons.id
|
||||
OrganizationSalesAssignment.organization_id -> fleet.organizations.id
|
||||
OrganizationSalesAssignment.agent_user_id -> identity.users.id
|
||||
Branch.organization_id -> fleet.organizations.id
|
||||
Branch.address_id -> system.addresses.id
|
||||
Rating.author_id -> identity.users.id
|
||||
Rating.target_organization_id -> fleet.organizations.id
|
||||
Rating.target_user_id -> identity.users.id
|
||||
Rating.target_branch_id -> fleet.branches.id
|
||||
|
||||
=== SYSTEM SÉMA ===
|
||||
Address.postal_code_id -> system.geo_postal_codes.id
|
||||
GeoStreet.postal_code_id -> system.geo_postal_codes.id
|
||||
InternalNotification.user_id -> identity.users.id
|
||||
Document.uploaded_by -> identity.users.id
|
||||
LegalAcceptance.user_id -> identity.users.id
|
||||
LegalAcceptance.document_id -> system.legal_documents.id
|
||||
PendingAction.requester_id -> identity.users.id
|
||||
PendingAction.approver_id -> identity.users.id
|
||||
|
||||
=== MARKETPLACE SÉMA ===
|
||||
ServiceProfile.organization_id -> fleet.organizations.id (UNIQUE)
|
||||
ServiceProfile.parent_id -> marketplace.service_profiles.id (self-ref)
|
||||
ExpertiseTag.parent_id -> marketplace.expertise_tags.id (self-ref)
|
||||
ExpertiseTag.suggested_by_id -> identity.persons.id
|
||||
ServiceExpertise.service_id -> marketplace.service_profiles.id
|
||||
ServiceExpertise.expertise_id -> marketplace.expertise_tags.id
|
||||
ServiceRequest.user_id -> identity.users.id
|
||||
ServiceRequest.asset_id -> vehicle.assets.id
|
||||
ServiceRequest.branch_id -> fleet.branches.id
|
||||
ServiceProvider.added_by_user_id -> identity.users.id
|
||||
Vote.user_id -> identity.users.id
|
||||
Vote.provider_id -> marketplace.service_providers.id
|
||||
UserScore.user_id -> identity.users.id
|
||||
UserScore.competition_id -> gamification.competitions.id
|
||||
ServiceReview.service_id -> marketplace.service_profiles.id
|
||||
ServiceReview.user_id -> identity.users.id
|
||||
ServiceReview.transaction_id -> audit.financial_ledger.transaction_id
|
||||
ServiceSpecialty.parent_id -> marketplace.service_specialties.id (self-ref)
|
||||
OrganizationSubscription.org_id -> fleet.organizations.id
|
||||
OrganizationSubscription.tier_id -> system.subscription_tiers.id
|
||||
UserSubscription.user_id -> identity.users.id
|
||||
UserSubscription.tier_id -> system.subscription_tiers.id
|
||||
CreditTransaction.org_id -> fleet.organizations.id
|
||||
|
||||
=== FINANCE SÉMA ===
|
||||
PaymentIntent.payer_id -> identity.users.id
|
||||
PaymentIntent.beneficiary_id -> identity.users.id
|
||||
WithdrawalRequest.user_id -> identity.users.id
|
||||
WithdrawalRequest.approved_by_id -> identity.users.id
|
||||
|
||||
=== AUDIT SÉMA ===
|
||||
SecurityAuditLog.actor_id -> identity.users.id
|
||||
SecurityAuditLog.target_id -> identity.users.id
|
||||
SecurityAuditLog.confirmed_by_id -> identity.users.id
|
||||
OperationalLog.user_id -> identity.users.id
|
||||
FinancialLedger.user_id -> identity.users.id
|
||||
FinancialLedger.person_id -> identity.persons.id
|
||||
FinancialLedger.related_agent_id -> identity.users.id
|
||||
FinancialLedger.issuer_id -> finance.issuers.id
|
||||
|
||||
=== GAMIFICATION SÉMA ===
|
||||
PointsLedger.user_id -> identity.users.id
|
||||
UserStats.user_id -> identity.users.id (PK)
|
||||
UserBadge.user_id -> identity.users.id
|
||||
UserBadge.badge_id -> gamification.badges.id
|
||||
UserContribution.user_id -> identity.users.id
|
||||
UserContribution.season_id -> gamification.seasons.id
|
||||
UserContribution.reviewed_by -> identity.users.id
|
||||
SeasonalCompetitions.season_id -> gamification.seasons.id
|
||||
|
||||
=== MARKETING SÉMA ===
|
||||
CampaignCreative.campaign_id -> marketing.campaigns.id
|
||||
CampaignCreative.creative_id -> marketing.creatives.id
|
||||
CampaignPlacement.campaign_id -> marketing.campaigns.id
|
||||
CampaignPlacement.placement_id -> marketing.placements.id
|
||||
AdImpression.campaign_id -> marketing.campaigns.id
|
||||
AdImpression.creative_id -> marketing.creatives.id
|
||||
AdImpression.placement_id -> marketing.placements.id
|
||||
AdClick.impression_id -> marketing.ad_impressions.id
|
||||
AdClick.campaign_id -> marketing.campaigns.id
|
||||
AdClick.creative_id -> marketing.creatives.id
|
||||
```
|
||||
|
||||
### 9.2 Leggyakrabban Hivatkozott Táblák
|
||||
|
||||
| Tábla | Hivatkozások | Honnan |
|
||||
|-------|-------------|--------|
|
||||
| `identity.users` | **30+** | Minden domainből |
|
||||
| `vehicle.assets` | **12** | cost, event, logbook, inspection, stb. |
|
||||
| `fleet.organizations` | **10** | asset, cost, member, branch, stb. |
|
||||
| `identity.persons` | **6** | user, organization, financial_ledger |
|
||||
| `vehicle.vehicle_model_definitions` | **4** | catalog, cost, rating |
|
||||
| `vehicle.cost_categories` | **3** | asset_cost, vehicle_cost |
|
||||
|
||||
---
|
||||
|
||||
## Összefoglalás
|
||||
|
||||
### Főbb Megállapítások
|
||||
|
||||
1. **Központi entitás:** [`Asset`](backend/app/models/vehicle/asset.py:69) — Digital Twin, 12+ kapcsolattal
|
||||
2. **Legkritikusabb redundancia:** `VehicleCost` a VMD-hez köt (NEM az Asset-hez)
|
||||
3. **Dual Entity:** `Person` (DNS) + `User` (login) sikeresen implementálva
|
||||
4. **7 önhivatkozó hierarchia** — CostCategory, ExpertiseTag (4 szint), ServiceSpecialty, User (referral, sales), Person (merge), ServiceProfile
|
||||
5. **56 JSONB mező** — Rugalmasság, de kereshetőséget ront
|
||||
6. **`individual_equipment.is_primary`** — Logikai mező JSONB-ben elrejtve
|
||||
|
||||
### Kritikus Hiányosságok
|
||||
|
||||
1. ❌ **Biztosítási adatok teljes hiánya** (KGFB, Casco)
|
||||
2. ❌ **Adó adatok teljes hiánya** (súlyadó, cégautó adó)
|
||||
3. ❌ **Első forgalomba helyezés típusának hiánya**
|
||||
4. ❌ **Ütemezett/expected költségek hiánya**
|
||||
5. ⚠️ **Regisztrációs dokumentumok részlegesek** (3 mező)
|
||||
6. ⚠️ **Három cost modell párhuzamosan** eltérő referenciákkal
|
||||
|
||||
### Ajánlott Következő Lépések
|
||||
|
||||
1. **P1:** Dedikált `VehicleInsurancePolicy` és `VehicleTaxObligation` modellek
|
||||
2. **P1:** `Asset` bővítése hiányzó admin mezőkkel
|
||||
3. **P2:** `VehicleExpectedCost` modell
|
||||
4. **P2:** `VehicleRegistrationDocument` modell
|
||||
5. **P3:** `individual_equipment.is_primary` dedikált boolean oszlopba
|
||||
6. **P3:** Cost modellek konszolidációja
|
||||
Reference in New Issue
Block a user