forked from michaelzheng67/Real_estate_ML
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransaction_helper.py
36 lines (31 loc) · 1.21 KB
/
transaction_helper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Withdraws money from accounts when making a purchase
# Order of choice is tax based
def payment_selection(financial_accounts, price):
if price > financial_accounts.cash_account:
price -= financial_accounts.cash_account
financial_accounts.cash_account = 0
else:
financial_accounts.cash_account -= price
price = 0
if price > financial_accounts.investing_account:
investment_used = financial_accounts.investing_account
price -= financial_accounts.investing_account
financial_accounts.investing_account = 0
else:
investment_used = price
financial_accounts.investing_account -= price
price = 0
if price > financial_accounts.tfsa:
tfsa_used = financial_accounts.tfsa
price -= financial_accounts.tfsa
financial_accounts.tfsa = 0
else:
tfsa_used = price
financial_accounts.tfsa -= price
price = 0
rrsp_used = price
financial_accounts.rrsp -= price
financial_accounts.tfsa_total_contrib_room += tfsa_used
financial_accounts.rrsp_total_contrib_room += rrsp_used
financial_accounts.income_deduction += rrsp_used
return financial_accounts, investment_used, rrsp_used