-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExample.py
81 lines (67 loc) · 4.93 KB
/
Example.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
# This is a test example that determines the total balance of all aacounts given a budget and a date range.
# Import the budget library
import budgeting_lib as bl
import datetime as dt
import argparse
# Create command line argument
parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('startdate', type=str, help='Start date of the budget')
parser.add_argument('enddate', type=str, help='End date of the budget')
args = parser.parse_args()
# Convert enddate to datetime.date object where the input is given as YYYY-MM-DD
args.startdate = dt.datetime.strptime(args.startdate, '%Y-%m-%d').date()
args.enddate = dt.datetime.strptime(args.enddate, '%Y-%m-%d').date()
# Start and end dates for income and transfers (these can be changed so they are not the same)
# The income start date might be different for each income source, because of the start date is
# the day the income is earn and related to the frequency of the income source.
# Similarly is true for the transfer start date.
startdate = args.startdate
enddate = args.enddate
# Create bills, expenses, and incomes
# A bill has a name, amount, duedate, frequency, category, and ifweekday
bills = [
bl.bill(name="rent", amount=1000.00, duedate=1, frequency="monthly", startdate=startdate, enddate=enddate, category="housing", ifweekday=True),
bl.bill(name="phone", amount=79.99, duedate=1, frequency="monthly", startdate=startdate, enddate=enddate, category="utilities", ifweekday=True),
bl.bill(name="internet", amount=79.99, duedate=15, frequency="monthly", startdate=startdate, enddate=enddate, category="utilities", ifweekday=True),
bl.bill(name="car insurance", amount=94.99, duedate=21, frequency="monthly", startdate=startdate, enddate=enddate, category="car", ifweekday=True),
bl.bill(name="utilties", amount=114.99, duedate=1, frequency="monthly", startdate=startdate, enddate=enddate, category="utilities", ifweekday=True),
bl.bill(name="student loan", amount=500.00, duedate=1, frequency="weekly", startdate=startdate, enddate=enddate, category="debt", ifweekday=True),
bl.bill(name="health insurance", amount=116.00, duedate=1, frequency="monthly", startdate=startdate, enddate=enddate, category="health", ifweekday=True),
bl.bill(name="charity", amount=10.00, duedate=2, frequency="monthly", startdate=startdate, enddate=enddate, category="donations", ifweekday=True),
bl.bill(name="netflix", amount=14.99, duedate=20, frequency="monthly", startdate=startdate, enddate=enddate, category="entertainment", ifweekday=True),
bl.bill(name="spotify", amount=9.99, duedate=20, frequency="monthly", startdate=startdate, enddate=enddate, category="entertainment", ifweekday=True),
bl.bill(name="lightroom", amount=9.99, duedate=20, frequency="monthly", startdate=startdate, enddate=enddate, category="hobbies", ifweekday=True),
]
# An expense has a name, amount, category, and description
expenses = [
bl.expense(name="groceries", amount=200.00, category="food", description="groceries for two weeks"),
bl.expense(name="gas", amount=50.00, category="car", description="gas for car"),
bl.expense(name="eating out", amount=100.00, category="food", description="eating out with friends"),
]
# An income has a name, amount, frequency, category, startdate, enddate, and ifweekday
incomes = [
bl.income(name="paycheck", amount=3000.00, frequency="biweekly", category="income", startdate=startdate, enddate=enddate, payday=1, ifweekday=True)
]
# Create three accounts
# An account has a name, type, balance, bills, expenses, and incomes
accounts = [
bl.account(name="checking", type="checking", balance=1000.00, bills=bills, expenses=expenses, incomes=incomes),
bl.account(name="savings", type="savings", balance=10000.00, bills=[], expenses=[], incomes=[]),
bl.account(name="travel", type="travel", balance=500.00, bills=[], expenses=[], incomes=[]),
]
# Create two transfers
checking_account = accounts[0]
saving_account = accounts[1]
travel_account = accounts[2]
# A transfer has a name, startdate, enddate, amount, frequency, from_account, and to_account
transfers = [
bl.transfer(name="savings", startdate=startdate, enddate=enddate, depositday=1, amount=300.00, frequency="biweekly", from_account=checking_account, to_account=saving_account),
bl.transfer(name="travel", startdate=startdate, enddate=enddate, depositday=1, amount=100.00, frequency="biweekly", from_account=checking_account, to_account=travel_account),
]
# Create a budget
# A budget has a name, startdate, enddate, accounts, and transfers
budget = bl.budget(name="yearly budget", startdate=args.startdate, enddate=args.enddate, accounts=accounts, transfers=transfers)
# Print the summary of the budget
print(budget.summary())
# Print the final summary of the budget
print(budget.summary_final())