Adds per-user wallet configuration
Allows users to configure their own wallet ID, enabling the system to track expenses and receivables on a per-user basis. Introduces new database table, models, API endpoints, and UI elements to manage user-specific wallet settings.
This commit is contained in:
parent
31344607c6
commit
bb1dbcccd8
7 changed files with 236 additions and 6 deletions
32
crud.py
32
crud.py
|
|
@ -14,8 +14,10 @@ from .models import (
|
|||
CreateJournalEntry,
|
||||
EntryLine,
|
||||
JournalEntry,
|
||||
StoredUserWalletSettings,
|
||||
UserBalance,
|
||||
UserCastleSettings,
|
||||
UserWalletSettings,
|
||||
)
|
||||
|
||||
db = Database("ext_castle")
|
||||
|
|
@ -377,3 +379,33 @@ async def update_castle_settings(
|
|||
settings = UserCastleSettings(**data.dict(), id=user_id)
|
||||
await db.update("extension_settings", settings)
|
||||
return settings
|
||||
|
||||
|
||||
# ===== USER WALLET SETTINGS =====
|
||||
|
||||
|
||||
async def create_user_wallet_settings(
|
||||
user_id: str, data: UserWalletSettings
|
||||
) -> UserWalletSettings:
|
||||
settings = StoredUserWalletSettings(**data.dict(), id=user_id)
|
||||
await db.insert("user_wallet_settings", settings)
|
||||
return settings
|
||||
|
||||
|
||||
async def get_user_wallet_settings(user_id: str) -> Optional[UserWalletSettings]:
|
||||
return await db.fetchone(
|
||||
"""
|
||||
SELECT * FROM user_wallet_settings
|
||||
WHERE id = :user_id
|
||||
""",
|
||||
{"user_id": user_id},
|
||||
UserWalletSettings,
|
||||
)
|
||||
|
||||
|
||||
async def update_user_wallet_settings(
|
||||
user_id: str, data: UserWalletSettings
|
||||
) -> UserWalletSettings:
|
||||
settings = StoredUserWalletSettings(**data.dict(), id=user_id)
|
||||
await db.update("user_wallet_settings", settings)
|
||||
return settings
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue