Fix default categories
This commit is contained in:
parent
ac6763df1b
commit
001d589a1e
10
.vscode/launch.json
vendored
10
.vscode/launch.json
vendored
@ -11,7 +11,15 @@
|
|||||||
"program": "main.py",
|
"program": "main.py",
|
||||||
"console": "integratedTerminal",
|
"console": "integratedTerminal",
|
||||||
"justMyCode": true,
|
"justMyCode": true,
|
||||||
"args": ["C:\\Users\\saram\\Downloads\\Statement_082022_4653.pdf"]
|
"args": ["C:\\Users\\saram\\Downloads\\Statement_072022_4653.pdf"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Create Database",
|
||||||
|
"type": "python",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "database.py",
|
||||||
|
"console": "integratedTerminal",
|
||||||
|
"justMyCode": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
34
database.py
34
database.py
@ -9,30 +9,33 @@ def create_tables():
|
|||||||
with instance:
|
with instance:
|
||||||
instance.create_tables([User, TransactionCategory, Transaction, Source])
|
instance.create_tables([User, TransactionCategory, Transaction, Source])
|
||||||
|
|
||||||
|
def add_user():
|
||||||
# Make my user.
|
# Make my user.
|
||||||
instance.connect()
|
instance.connect()
|
||||||
User.create(username='ciphercules')
|
User.create(username='ciphercules')
|
||||||
instance.close()
|
instance.close()
|
||||||
|
|
||||||
def add_default_categories():
|
def add_default_categories():
|
||||||
|
"""Helper function to add default categories. Should be called manually."""
|
||||||
categories = [
|
categories = [
|
||||||
{"food": ["snacks", "fast_food", "groceries", "restaurant"]},
|
("food", ["snacks", "fast_food", "groceries", "restaurant"]),
|
||||||
{"clothing": []},
|
("clothing", []),
|
||||||
{"event": ["event_food", "birthday", "movie_theater"]},
|
("event", ["event_food", "birthday", "movie_theater"]),
|
||||||
{"finance": ["interest"]},
|
("finance", ["interest"]),
|
||||||
{"hobby": ["gym", "game_development", "projects", "education"]},
|
("hobby", ["gym", "game_development", "projects", "education"]),
|
||||||
{"home_improvement": []},
|
("home_improvement", []),
|
||||||
{"pet": ["health", "dog_food"]},
|
("pet", ["dog_health", "dog_food"]),
|
||||||
{"media": ["book", "music", "television", "video_game"]},
|
("media", ["book", "music", "television", "video_game"]),
|
||||||
{"health": ["medicine"]},
|
("health", ["medicine"]),
|
||||||
{"transit": ["car_insurance", "car_registration", "gas", "parking", "taxi", "car_maintenance"]},
|
("transit", ["car_insurance", "car_registration", "gas", "parking", "taxi", "car_maintenance"]),
|
||||||
{"utilities": ["electricity", "gas", "laundry", "cell_phone", "trash", "water"]},
|
("utilities", ["electricity", "natural_gas", "laundry", "cell_phone", "trash", "water"]),
|
||||||
{"rent": []},
|
("rent", []),
|
||||||
]
|
]
|
||||||
|
|
||||||
instance.connect()
|
instance.connect()
|
||||||
with instance.atomic():
|
with instance.atomic():
|
||||||
for parent, children in categories.items():
|
for category in categories:
|
||||||
|
parent, children = category
|
||||||
parent_db = TransactionCategory.create(name=parent)
|
parent_db = TransactionCategory.create(name=parent)
|
||||||
for child in children:
|
for child in children:
|
||||||
TransactionCategory.create(name=child, parent=parent_db)
|
TransactionCategory.create(name=child, parent=parent_db)
|
||||||
@ -67,3 +70,8 @@ class Transaction(BaseModel):
|
|||||||
description = CharField()
|
description = CharField()
|
||||||
amount = FloatField()
|
amount = FloatField()
|
||||||
subcategory = ForeignKeyField(TransactionCategory, backref='+', null=True)
|
subcategory = ForeignKeyField(TransactionCategory, backref='+', null=True)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
create_tables()
|
||||||
|
add_user()
|
||||||
|
add_default_categories()
|
4
todo.txt
4
todo.txt
@ -7,8 +7,8 @@ Every week, I need to:
|
|||||||
|
|
||||||
## Parse capital one statement
|
## Parse capital one statement
|
||||||
x Given a PDF bank statement from capital one, extract the transaction date, description, and amount from each transaction
|
x Given a PDF bank statement from capital one, extract the transaction date, description, and amount from each transaction
|
||||||
Store the data in a SQL lite database
|
xStore the data in a SQL lite database
|
||||||
x Create database schema
|
x Create database schema
|
||||||
x Automatically add capital one transactions to database
|
x Automatically add capital one transactions to database
|
||||||
Add web page to add categories
|
|
||||||
Add web page to categorize transactions
|
Add web page to categorize transactions
|
||||||
|
Add web page to add categories
|
Loading…
Reference in New Issue
Block a user