felhasználói felületre pü

This commit is contained in:
Roo
2026-07-27 08:39:18 +00:00
parent c9118bf52f
commit 6f28d3e70d
72 changed files with 6311 additions and 749 deletions

View File

@@ -393,22 +393,42 @@ class FinancialOrchestrator:
await db.flush()
# 3. Pénztárca egyenleg visszaállítása
# JAVÍTÁS: A Wallet modellben NINCS "wallet_type" és "balance" mező.
# A usernek egyetlen wallet-je van (user_id UNIQUE constraint),
# a credit típusok külön oszlopokban: earned_credits, purchased_credits, service_coins.
# A wallet_type-t az eredeti FinancialLedger bejegyzésből olvassuk ki,
# és a megfelelő oszlopot frissítjük (pont mint process_payment()-ben).
wallet_query = select(Wallet).where(
and_(
Wallet.user_id == original_entry.user_id,
Wallet.wallet_type == original_entry.wallet_type
)
Wallet.user_id == original_entry.user_id
).with_for_update()
wallet_result = await db.execute(wallet_query)
wallet = wallet_result.scalar_one_or_none()
if wallet:
new_balance = wallet.balance - original_entry.amount
wallet_type = original_entry.wallet_type
update_values = {}
if wallet_type == WalletType.EARNED:
new_balance = Decimal(str(wallet.earned_credits)) + original_entry.amount
update_values['earned_credits'] = float(new_balance)
elif wallet_type == WalletType.PURCHASED:
new_balance = Decimal(str(wallet.purchased_credits)) + original_entry.amount
update_values['purchased_credits'] = float(new_balance)
elif wallet_type == WalletType.SERVICE_COINS:
new_balance = Decimal(str(wallet.service_coins)) + original_entry.amount
update_values['service_coins'] = float(new_balance)
elif wallet_type == WalletType.VOUCHER:
# VOUCHER típusnál nincs dedikált mező, SERVICE_COINS-ba tesszük
new_balance = Decimal(str(wallet.service_coins)) + original_entry.amount
update_values['service_coins'] = float(new_balance)
else:
raise ValueError(f"Ismeretlen wallet_type: {wallet_type}")
await db.execute(
update(Wallet)
.where(Wallet.id == wallet.id)
.values(balance=new_balance)
.values(**update_values)
)
# 4. Számlakiállító bevételének csökkentése