diff --git a/banking/account_management.py b/banking/account_management.py index 1fe44c0e3..4a41344cd 100644 --- a/banking/account_management.py +++ b/banking/account_management.py @@ -3,6 +3,7 @@ import logging from typing import Dict + def create_account(account_type: str, balance: float, customer_id: int) -> Dict: """ Create a new account for a customer. @@ -18,22 +19,23 @@ def create_account(account_type: str, balance: float, customer_id: int) -> Dict: # implementation logging.info(f"Creating account for customer {customer_id}") # Validate input parameters - if account_type not in ['checking', 'savings']: + if account_type not in ["checking", "savings"]: raise ValueError("Invalid account type") if balance < 0: raise ValueError("Balance cannot be negative") # Create account and store it in a database or in-memory data structure account = { - 'id': generate_unique_id(), - 'type': account_type, - 'balance': balance, - 'customer_id': customer_id + "id": generate_unique_id(), + "type": account_type, + "balance": balance, + "customer_id": customer_id, } # Return the account information return account + def update_account(account_id: int, account_type: str, balance: float) -> bool: """ Update an existing account. @@ -49,7 +51,7 @@ def update_account(account_id: int, account_type: str, balance: float) -> bool: # implementation logging.info(f"Updating account {account_id}") # Validate input parameters - if account_type not in ['checking', 'savings']: + if account_type not in ["checking", "savings"]: raise ValueError("Invalid account type") if balance < 0: raise ValueError("Balance cannot be negative") @@ -58,8 +60,8 @@ def update_account(account_id: int, account_type: str, balance: float) -> bool: account = get_account_by_id(account_id) # Update the account information - account['type'] = account_type - account['balance'] = balance + account["type"] = account_type + account["balance"] = balance # Save the updated account back to the database or in-memory data structure save_account(account) @@ -67,6 +69,7 @@ def update_account(account_id: int, account_type: str, balance: float) -> bool: # Return True to indicate success return True + def delete_account(account_id: int) -> bool: """ Delete an account.