Creates default user accounts on wallet setup
Ensures consistent user account structure by proactively creating core liability and asset accounts when a user configures their wallet settings.
This commit is contained in:
parent
9054b3eb62
commit
992a8fe554
1 changed files with 11 additions and 1 deletions
12
services.py
12
services.py
|
|
@ -2,11 +2,12 @@ from .crud import (
|
|||
create_castle_settings,
|
||||
create_user_wallet_settings,
|
||||
get_castle_settings,
|
||||
get_or_create_user_account,
|
||||
get_user_wallet_settings,
|
||||
update_castle_settings,
|
||||
update_user_wallet_settings,
|
||||
)
|
||||
from .models import CastleSettings, UserWalletSettings
|
||||
from .models import AccountType, CastleSettings, UserWalletSettings
|
||||
|
||||
|
||||
async def get_settings(user_id: str) -> CastleSettings:
|
||||
|
|
@ -42,4 +43,13 @@ async def update_user_wallet(
|
|||
else:
|
||||
settings = await update_user_wallet_settings(user_id, data)
|
||||
|
||||
# Proactively create core user accounts when wallet is configured
|
||||
# This ensures all users have a consistent account structure from the start
|
||||
await get_or_create_user_account(
|
||||
user_id, AccountType.LIABILITY, "Accounts Payable"
|
||||
)
|
||||
await get_or_create_user_account(
|
||||
user_id, AccountType.ASSET, "Accounts Receivable"
|
||||
)
|
||||
|
||||
return settings
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue