Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit e81a4b7

Browse files
Merge branch 'codecov/unit-tests' into ai_tests_for_pr937_1730236383
2 parents d35d608 + 24b3429 commit e81a4b7

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

billing/accounts.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
class BankAccount:
2+
def __init__(self, owner, balance=0.0):
3+
self.owner = owner
4+
if balance < 0:
5+
raise ValueError("Initial balance cannot be negative")
6+
self.balance = balance
7+
8+
def deposit(self, amount):
9+
if amount <= 0:
10+
raise ValueError("Deposit amount must be positive")
11+
self.balance += amount
12+
return self.balance
13+
14+
def withdraw(self, amount):
15+
if amount <= 0:
16+
raise ValueError("Withdrawal amount must be positive")
17+
if amount > self.balance:
18+
raise ValueError("Insufficient funds")
19+
self.balance -= amount
20+
return self.balance
21+
22+
def transfer(self, other_account, amount):
23+
if not isinstance(other_account, BankAccount):
24+
raise ValueError("Recipient must be a BankAccount instance")
25+
self.withdraw(amount)
26+
other_account.deposit(amount)
27+
return self.balance, other_account.balance
28+
29+
def get_balance(self):
30+
return self.balance

0 commit comments

Comments
 (0)