admin_nyelvi_javítas
This commit is contained in:
116
.roo/history.md
116
.roo/history.md
@@ -451,3 +451,119 @@ A konténer indításakor előre létező import hibák jelentkeztek (`expenses.
|
||||
- Total: 7000.00 ✅
|
||||
- Max amount cap (50000) verified ✅
|
||||
- Sync engine: 1303 OK, 0 Fixed, 0 Shadow
|
||||
|
||||
## Phase 2 - MLM Commission & Wallet Integration (2026-07-24)
|
||||
|
||||
### ✅ Implementált változtatások
|
||||
1. **CommissionRule model** - 3 új mező: gen1_max_amount, gen2_max_amount (Numeric(18,2)), gen2_renewal_percent (Numeric(5,2))
|
||||
2. **Pydantic schemas** - új mezők a Create/Update/Response DTO-kban + is_renewal flag a DistributionRequest-ben
|
||||
3. **commission_service.py** - Phase 2 business logic:
|
||||
- _credit_commission_to_wallet(): Wallet.earned_credits + FinancialLedger CREDIT
|
||||
- _is_user_recently_active(): 180 napos inaktivitás ellenőrzés
|
||||
- Per-level caps (gen1_max_amount/gen2_max_amount fallback commission_max_amount-ra)
|
||||
- Inaktív Gen1 esetén Gen2 kifizetés kihagyása
|
||||
- Renewal logika (gen2_renewal_percent vs upline_commission_percent)
|
||||
- db.commit() a wallet/ledger írások után
|
||||
4. **Frontend Admin UI** - 3 új mező a commission-rules.vue formban + i18n kulcsok (HU/EN)
|
||||
5. **Sync Engine** - 3 új oszlop sikeresen hozzáadva a marketplace.commission_rules táblához
|
||||
6. **Tesztek** - 4/4 teszt sikeresen lefutott (commission distribution + max amount cap)
|
||||
|
||||
## Phase 3 - Commission Rule Priority Engine & Conflict Resolution Flow (2026-07-24)
|
||||
|
||||
### ✅ Implementált változtatások
|
||||
|
||||
**Task 1: Priority Resolution Engine (Verifikáció)**
|
||||
- [`get_active_rule()`](backend/app/services/commission_service.py:333) már helyesen implementálva:
|
||||
- `campaign_priority`: campaign=0, egyéb=1
|
||||
- `region_priority`: exact match=0, GLOBAL=1, else=2
|
||||
- `tier_priority`: PLATINUM=0 → CONTRACTED=4, else=99
|
||||
- `.order_by(campaign_priority, region_priority, tier_priority).limit(1)`
|
||||
|
||||
**Task 2: Conflict Detection & Audit Logging**
|
||||
- [`schemas/commission.py`](backend/app/schemas/commission.py:159): `ConflictingRuleInfo` + `ConflictResponse` DTO-k
|
||||
- [`commission_service.py`](backend/app/services/commission_service.py:59): `check_rule_conflict()` - exact match (tier, region_code, is_campaign) aktív szabályokra
|
||||
- [`commission_service.py`](backend/app/services/commission_service.py:103): `create_commission_rule()` - conflict check + force_override deaktiválás
|
||||
- [`commission_service.py`](backend/app/services/commission_service.py:189): `update_commission_rule()` - conflict check exclude_rule_id-vel
|
||||
- [`admin_commission.py`](backend/app/api/v1/endpoints/admin_commission.py:179): 409 Conflict response `ConflictingRuleInfo` struktúrával
|
||||
|
||||
**Task 3: Frontend UI Approval Workflow**
|
||||
- [`commission-rules.vue`](frontend_admin/pages/finance/commission-rules.vue:595): `showConflictModal`, `conflictingRule`, `pendingPayload` refs
|
||||
- Konfliktus modal: amber figyelmeztetés + conflicting rule adatok + Cancel/Confirm gombok
|
||||
- `saveRule()`: 409 catch → pendingPayload tárolás → modal megjelenítés
|
||||
- `confirmOverride()`: re-submit `force_override: true`-val
|
||||
- [`hu/commission.json`](frontend_admin/i18n/locales/hu/commission.json): magyar konfliktus szövegek
|
||||
- [`en/commission.json`](frontend_admin/i18n/locales/en/commission.json): angol konfliktus szövegek
|
||||
|
||||
### ✅ Verifikáció
|
||||
1. **Sync Engine** - 1306 items OK (schema in sync)
|
||||
2. **Commission Distribution Test** - 4/4 passed
|
||||
3. **Python imports** - No syntax errors
|
||||
|
||||
---
|
||||
|
||||
## FinancialManager: Subscription Purchase & Payment Gateway Module (Gitea #411)
|
||||
|
||||
**Dátum:** 2026-07-24
|
||||
**Scope:** Backend (Strategy Pattern, FastAPI, SQLAlchemy)
|
||||
|
||||
### 🔧 Létrehozott fájlok
|
||||
|
||||
1. [`mock_payment_gateway.py`](backend/app/services/mock_payment_gateway.py) - MockPaymentGateway (Strategy Pattern implementáció, 3 mód: auto_approve, simulate_failure, simulate_timeout)
|
||||
2. [`subscription_activator.py`](backend/app/services/subscription_activator.py) - SubscriptionActivator (User/Org szintű aktiválás P0 stackinggel)
|
||||
3. [`financial_manager.py`](backend/app/services/financial_manager.py) - FinancialManager orchestrator (teljes vásárlási életciklus)
|
||||
4. [`financial_manager.py`](backend/app/schemas/financial_manager.py) - PurchaseRequest/PurchaseResponse Pydantic sémák
|
||||
5. [`financial_manager.py`](backend/app/api/v1/endpoints/financial_manager.py) - API végpontok (POST /purchase-package, GET /status)
|
||||
|
||||
### 🔧 Módosított fájlok
|
||||
|
||||
1. [`api.py`](backend/app/api/v1/api.py) - Financial Manager router regisztráció
|
||||
|
||||
### 🐛 Javított adatbázis enumok
|
||||
- `finance.wallet_type` - hozzáadva: EARNED, PURCHASED, SERVICE_COINS, VOUCHER
|
||||
- `finance.payment_intent_status` - hozzáadva: COMPLETED, CANCELLED, EXPIRED
|
||||
|
||||
### ✅ Verifikáció
|
||||
1. **Sync Engine** - 1306 items OK (schema in sync)
|
||||
2. **FinancialManager Test Suite** - 24/24 passed
|
||||
3. **API Integration** - purchase-package endpoint fully functional
|
||||
|
||||
---
|
||||
|
||||
## Build Inactivity & Subscription Monitor (Gitea #412)
|
||||
|
||||
**Dátum:** 2026-07-24
|
||||
**Scope:** Backend (Workers, Scheduler, Auth, DB Schema)
|
||||
|
||||
### 🔧 Módosított/Létrehozott fájlok
|
||||
|
||||
#### 1. [`identity.py`](backend/app/models/identity/identity.py:178)
|
||||
- Hozzáadva: `last_activity_at` mező a `User` modellhez (DateTime(timezone=True), nullable)
|
||||
- Komment: "Updated on login/token-refresh; used by the 180-day inactivity worker"
|
||||
|
||||
#### 2. [`subscription_monitor_worker.py`](backend/app/workers/system/subscription_monitor_worker.py) (ÚJ)
|
||||
- Teljes subscription lifecycle kezelés: `UserSubscription` és `OrganizationSubscription`
|
||||
- `FOR UPDATE SKIP LOCKED` atomi zárolás
|
||||
- Fallback `is_default_fallback` tier-re lejáratkor
|
||||
- `FinancialLedger` bejegyzés (`SUBSCRIPTION_EXPIRED`)
|
||||
- `NotificationService` értesítés
|
||||
- Nem írja felül a meglévő `subscription_worker.py`-t
|
||||
|
||||
#### 3. [`inactivity_monitor_worker.py`](backend/app/workers/system/inactivity_monitor_worker.py) (ÚJ)
|
||||
- 180 napos inaktivitás detektálás (kétfázisú: `last_activity_at` + `created_at` alapján)
|
||||
- Subquery approach a `FOR UPDATE` + outer join PostgreSQL hiba elkerülésére
|
||||
- `custom_permissions['inactivity_suspended']` flag beállítása MLM engine számára
|
||||
- `is_active = False`, `FinancialLedger` bejegyzés, `NotificationService` értesítés
|
||||
|
||||
#### 4. [`scheduler.py`](backend/app/core/scheduler.py:207)
|
||||
- Subscription Monitor job: 01:00 UTC (CronTrigger, jitter=900)
|
||||
- Inactivity Monitor job: 02:00 UTC (CronTrigger, jitter=900)
|
||||
- Mindkét job `ProcessLog`-ba naplóz
|
||||
|
||||
#### 5. [`auth.py`](backend/app/api/v1/endpoints/auth.py:65)
|
||||
- `user.last_activity_at = datetime.now(timezone.utc)` beállítás login, verify-email és Google auth végpontokban
|
||||
|
||||
### ✅ Verifikáció
|
||||
1. **Sync Engine** - 1306 items OK, 1 fixed (`last_activity_at` oszlop hozzáadva)
|
||||
2. **Subscription Monitor** - Sikeres futás, 0 expired subscription (dev adatbázis)
|
||||
3. **Inactivity Monitor** - Sikeres futás, 0 inactive user (dev adatbázis)
|
||||
4. **FOR UPDATE fix** - Subquery approach alkalmazva a PostgreSQL outer join korlátozás miatt
|
||||
|
||||
Reference in New Issue
Block a user