-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlot_Budget.py
154 lines (141 loc) · 8.58 KB
/
Plot_Budget.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import budgeting_lib as bl
import budgeting_other_lib as bol
import datetime as dt
import pandas as pd
import matplotlib.pyplot as plt
from datetime import datetime
dates = [
(dt.date(2023, 7, 11), dt.date(2024, 3, 14)),
(dt.date(2024, 3, 15), dt.date(2025, 3, 14)),
(dt.date(2025, 3, 15), dt.date(2025, 12, 31))
]
# name, amount, category, frequency, duedate, and ifweekday
bills = [
[
{'name': 'SameYou', 'amount': 5.15, 'category': 'Subscription', 'frequency': 'Monthly', 'duedate': 1, 'ifweekday': True},
{'name': 'Disney+', 'amount': 10.99, 'category': 'Subscription', 'frequency': 'Monthly', 'duedate': 2, 'ifweekday': False},
{'name': 'Spotify', 'amount': 9.99, 'category': 'Subscription', 'frequency': 'Monthly', 'duedate': 14, 'ifweekday': False},
{'name': 'Phone Bill', 'amount': 50, 'category': 'Subscription', 'frequency': 'Monthly', 'duedate': 20, 'ifweekday': False},
{'name': 'Other Insure', 'amount': 100, 'category': 'Subscription', 'frequency': 'Monthly', 'duedate': 22, 'ifweekday': False},
{'name': 'Internet', 'amount': 69.95, 'category': 'Subscription', 'frequency': 'Monthly', 'duedate': 30, 'ifweekday': False},
{'name': 'Rent', 'amount': 1000, 'category': 'Subscription', 'frequency': 'Monthly', 'duedate': 1, 'ifweekday': False},
{'name': 'Utilities', 'amount': 120, 'category': 'Subscription', 'frequency': 'Monthly', 'duedate': 1, 'ifweekday': False},
{'name': 'Health Insurance', 'amount': 116, 'category': 'Subscription', 'frequency': 'Monthly', 'duedate': 1, 'ifweekday': False},
{'name': 'CoPilot', 'amount': 10, 'category': 'Subscription', 'frequency': 'Monthly', 'duedate': 2, 'ifweekday': False}
],
[
{'name': 'SameYou', 'amount': 5.15, 'category': 'Subscription', 'frequency': 'Monthly', 'duedate': 1, 'ifweekday': True},
{'name': 'Disney+', 'amount': 10.99, 'category': 'Subscription', 'frequency': 'Monthly', 'duedate': 2, 'ifweekday': False},
{'name': 'Spotify', 'amount': 9.99, 'category': 'Subscription', 'frequency': 'Monthly', 'duedate': 14, 'ifweekday': False},
{'name': 'Phone Bill', 'amount': 50, 'category': 'Subscription', 'frequency': 'Monthly', 'duedate': 20, 'ifweekday': False},
{'name': 'Other Insure', 'amount': 100, 'category': 'Subscription', 'frequency': 'Monthly', 'duedate': 22, 'ifweekday': False},
{'name': 'Internet', 'amount': 69.95, 'category': 'Subscription', 'frequency': 'Monthly', 'duedate': 30, 'ifweekday': False},
{'name': 'Rent', 'amount': 1000, 'category': 'Subscription', 'frequency': 'Monthly', 'duedate': 1, 'ifweekday': False},
{'name': 'Utilities', 'amount': 120, 'category': 'Subscription', 'frequency': 'Monthly', 'duedate': 1, 'ifweekday': False},
{'name': 'Health Insurance', 'amount': 116, 'category': 'Subscription', 'frequency': 'Monthly', 'duedate': 1, 'ifweekday': False},
{'name': 'CoPilot', 'amount': 10, 'category': 'Subscription', 'frequency': 'Monthly', 'duedate': 2, 'ifweekday': False}
],
[
{'name': 'SameYou', 'amount': 5.15, 'category': 'Subscription', 'frequency': 'Monthly', 'duedate': 1, 'ifweekday': True},
{'name': 'Disney+', 'amount': 10.99, 'category': 'Subscription', 'frequency': 'Monthly', 'duedate': 2, 'ifweekday': False},
{'name': 'Spotify', 'amount': 9.99, 'category': 'Subscription', 'frequency': 'Monthly', 'duedate': 14, 'ifweekday': False},
{'name': 'Phone Bill', 'amount': 50, 'category': 'Subscription', 'frequency': 'Monthly', 'duedate': 20, 'ifweekday': False},
{'name': 'Other Insure', 'amount': 100, 'category': 'Subscription', 'frequency': 'Monthly', 'duedate': 22, 'ifweekday': False},
{'name': 'Internet', 'amount': 69.95, 'category': 'Subscription', 'frequency': 'Monthly', 'duedate': 30, 'ifweekday': False},
{'name': 'Rent', 'amount': 1000, 'category': 'Subscription', 'frequency': 'Monthly', 'duedate': 1, 'ifweekday': False},
{'name': 'Utilities', 'amount': 120, 'category': 'Subscription', 'frequency': 'Monthly', 'duedate': 1, 'ifweekday': False},
{'name': 'Health Insurance', 'amount': 116, 'category': 'Subscription', 'frequency': 'Monthly', 'duedate': 1, 'ifweekday': False},
{'name': 'CoPilot', 'amount': 10, 'category': 'Subscription', 'frequency': 'Monthly', 'duedate': 2, 'ifweekday': False}
],
]
# name, amount, category, description
expenses = [
[
{'name': 'Gas', 'amount': 100, 'category': 'Expense', 'description': 'Gas for the car'},
{'name': 'Groceries', 'amount': 350, 'category': 'Expense', 'description': 'Groceries for the month'},
],
[
{'name': 'Gas', 'amount': 100, 'category': 'Expense', 'description': 'Gas for the car'},
{'name': 'Groceries', 'amount': 350, 'category': 'Expense', 'description': 'Groceries for the month'},
],
[
{'name': 'Gas', 'amount': 100, 'category': 'Expense', 'description': 'Gas for the car'},
{'name': 'Groceries', 'amount': 350, 'category': 'Expense', 'description': 'Groceries for the month'},
],
]
# name, amount, payday, ifweekday, category, frequency
incomes = [
[
{'name': 'Paycheck', 'amount': 1500, 'payday': 14, 'ifweekday': True, 'category': 'Income', 'frequency': 'Biweekly'},
],
[
{'name': 'Paycheck', 'amount': 1600, 'payday': 14, 'ifweekday': True, 'category': 'Income', 'frequency': 'Biweekly'},
],
[
{'name': 'Paycheck', 'amount': 1700, 'payday': 14, 'ifweekday': True, 'category': 'Income', 'frequency': 'Biweekly'},
],
]
# name, type
accounts = [
[
{'name': 'Checking', 'type': 'checking'},
{'name': 'Savings', 'type': 'savings'},
{'name': 'Travel', 'type': 'savings'},
{'name': 'Student Loan', 'type': 'loan'},
],
[
{'name': 'Checking', 'type': 'checking'},
{'name': 'Savings', 'type': 'savings'},
{'name': 'Travel', 'type': 'savings'},
{'name': 'Student Loan', 'type': 'loan'},
],
[
{'name': 'Checking', 'type': 'checking'},
{'name': 'Savings', 'type': 'savings'},
{'name': 'Travel', 'type': 'savings'},
{'name': 'Student Loan', 'type': 'loan'},
]
]
# name, amount, from_account, to_account, frequency, depositday
transfers = [
[
{'name': 'Checking to Savings', 'amount': 300, 'from_account': 'Checking', 'to_account': 'Savings', 'frequency': 'biweekly', 'depositday': 14},
{'name': 'Checking to Travel', 'amount': 50, 'from_account': 'Checking', 'to_account': 'Travel', 'frequency': 'biweekly', 'depositday': 14},
{'name': 'Checking to Student Loan', 'amount': 500, 'from_account': 'Checking', 'to_account': 'Student Loan', 'frequency': 'monthly', 'depositday': 14},
],
[
{'name': 'Checking to Savings', 'amount': 400, 'from_account': 'Checking', 'to_account': 'Savings', 'frequency': 'biweekly', 'depositday': 14},
{'name': 'Checking to Travel', 'amount': 50, 'from_account': 'Checking', 'to_account': 'Travel', 'frequency': 'biweekly', 'depositday': 14},
{'name': 'Checking to Student Loan', 'amount': 500, 'from_account': 'Checking', 'to_account': 'Student Loan', 'frequency': 'monthly', 'depositday': 14},
],
[
{'name': 'Checking to Savings', 'amount': 500, 'from_account': 'Checking', 'to_account': 'Savings', 'frequency': 'biweekly', 'depositday': 14},
{'name': 'Checking to Travel', 'amount': 50, 'from_account': 'Checking', 'to_account': 'Travel', 'frequency': 'biweekly', 'depositday': 14},
{'name': 'Checking to Student Loan', 'amount': 500, 'from_account': 'Checking', 'to_account': 'Student Loan', 'frequency': 'monthly', 'depositday': 14},
],
]
# name
budgets = [
{'name': 'budget1'},
{'name': 'budget2'},
{'name': 'budget3'}
]
initial_balances = [334,2015,664.26,0,0]
summary = bol.summary_dataframe(dates, bills, expenses, incomes, accounts, transfers, budgets, initial_balances)
# Drop the total spent, total income, and total balance columns
summary = summary.drop(columns=['Total Spent', 'Total Earned', 'Total Balance'])
# Plot the dataframe
summary.plot(figsize=(20,15))
plt.axhline(y=0, color='black', linestyle='--')
plt.xlabel('Date', fontsize=18)
plt.ylabel('Balance', fontsize=18)
plt.xticks(fontsize=14)
plt.yticks(fontsize=14)
plt.title(f'Budget Plot', fontsize=20)
plt.legend(loc='upper left', fontsize=18)
# Show the final balance for each account on the plot as a label
for account in summary.columns:
plt.text(summary.index[-1], summary[account].iloc[-1], str(int(summary[account].iloc[-1])), fontsize=12)
plt.tight_layout()
# Save the plot
plt.savefig('plot_budget.png')