Skip to content

Commit

Permalink
Create transaction.py
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored May 10, 2024
1 parent 8affc59 commit 3ea2281
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions banking/transaction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from datetime import datetime
from banking.accounts import BankAccount

def transfer(from_account: BankAccount, to_account: BankAccount, amount):
"""
Transfers the specified amount from the from_account to the to_account.
"""
from_account.withdraw(amount)
to_account.deposit(amount)

transaction_date = datetime.now()
from_account_number = from_account.account_number
to_account_number = to_account.account_number
transaction_amount = amount

print(f"Transfer from account {from_account_number} to account {to_account_number} for ${transaction_amount:.2f} on {transaction_date}")

0 comments on commit 3ea2281

Please sign in to comment.