Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

Commit c18fe43

Browse files
committed
completed documentations
1 parent 6f83228 commit c18fe43

14 files changed

Lines changed: 534 additions & 9 deletions

projects/Expense-Tracker/README.md

Lines changed: 113 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,116 @@
1-
# Expense Tracker App
1+
# Expense Tracker Application
2+
3+
The Expense Tracker Application is a GUI application built using Python and
4+
Customtkinter/Tkinter for
5+
managing expenses. It allows users to add, update, and delete expense items, generate reports in Excel and PDF formats,
6+
and visualize expense data by category.
7+
8+
---
9+
10+
## Features
11+
12+
- Add, update, and delete expense items.
13+
- Generate reports in Excel and PDF formats.
14+
- Visualize expense data by category.
15+
- User-friendly graphical interface.
16+
17+
---
18+
19+
## Installation
20+
21+
1. Clone the [python-beginner-projects](https://github.com/Mrinank-Bhowmick/python-beginner-projects) repository to your
22+
local machine:
23+
24+
```
25+
git clone https://github.com/Mrinank-Bhowmick/python-beginner-projects.git
26+
```
27+
28+
2. Navigate to the project directory:
29+
30+
```
31+
cd python-beginner-projects/projects/Expense-Tracker
32+
```
33+
34+
3. Install the required dependencies:
35+
36+
```
37+
pip install -r requirements.txt
38+
```
39+
40+
---
41+
42+
## Usage
43+
44+
1. Run the application:
45+
46+
```
47+
python app.py
48+
```
49+
50+
2. The Expense Tracker GUI will open, allowing you to interact with the application.
51+
52+
3. Add, update, or delete expense items using the provided form and buttons.
53+
54+
4. Generate reports by navigating to the "Report" tab and clicking on the respective buttons for Excel or PDF reports.
55+
56+
5. Visualize expense data by navigating to the "Summary By Category" tab.
57+
58+
You can also run the sample using:
59+
60+
```
61+
python sample.py
62+
```
63+
64+
which would use dummy data to test the app.
65+
66+
---
67+
68+
## Screenshots
69+
70+
### Adding Item
71+
72+
![Adding Item](media/adding-item.gif)
73+
74+
### Updating Item
75+
76+
![Updating Item](media/updating-items.gif)
77+
78+
### Deleting Items
79+
80+
![Deleting Items](media/deleting-items.gif)
81+
82+
### Viewing Summary Statistics
83+
84+
![Summary Statistics](media/summary-stats.gif)
85+
86+
### Generating Reports
87+
88+
![Generating Reports](media/generating-reports.gif)
89+
90+
### Excel Report
91+
92+
![Excel Report 1](media/report-excel-1.JPG)
93+
![Excel Report 2](media/report-excel-2.JPG)
94+
95+
### PDF Report
96+
97+
![PDF Report](media/report-pdf.JPG)
98+
99+
100+
---
2101

3102
## Tasks
4-
- [X] Expense Categorization: This feature allows users to classify their expenses into categories like food, transportation, and entertainment, and provides a summary based on these categories.
103+
104+
- [X] Expense Categorization: This feature allows users to classify their expenses into categories like food,
105+
transportation, and entertainment, and provides a summary based on these categories.
5106
- [X] Date Range Filtering: This feature enables users to filter and view their expenses within a specific date range.
6-
- [ ] Expense Analysis: This feature offers statistical insights such as the average expense, highest expense, lowest expense, etc.
7-
- [X] Data Saving and Loading: This feature lets users save their expense data to a file (like CSV or JSON) and load it back when needed.
8-
- [ ] Data Export to PDF/Excel: This feature enables users to export their expense data to common formats like PDF or Excel for easy sharing or printing.
9-
- [ ] Currency Converter: For users dealing with multiple currencies, this feature provides an option to convert expenses to a preferred currency.
107+
- [X] Expense Analysis: This feature offers statistical insights such as the average expense, highest expense, lowest
108+
expense, etc.
109+
- [X] Data Saving and Loading: This feature lets users save their expense data to a file (like CSV or JSON) and load it
110+
back when needed.
111+
- [X] Data Export to PDF/Excel: This feature enables users to export their expense data to common formats like PDF or
112+
Excel for easy sharing or printing.
113+
- [ ] Currency Converter: For users dealing with multiple currencies, this feature provides an option to convert
114+
expenses to a preferred currency.
115+
116+

projects/Expense-Tracker/app.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010

1111

1212
class App(ctk.CTk):
13+
"""
14+
Represents the main application for managing expenses.
15+
16+
This class provides a GUI application for adding, updating, and deleting expense items,
17+
generating reports, and visualizing data.
18+
"""
19+
1320
def __init__(self, db_path, *args, **kwargs):
1421
super().__init__(*args, **kwargs)
1522

@@ -170,19 +177,27 @@ def __init__(self, db_path, *args, **kwargs):
170177
self.protocol("WM_DELETE_WINDOW", self.on_window_close)
171178

172179
def update_pivot_tables(self):
180+
"""Updates the pivot tables."""
181+
173182
self.pivot_table.update_pivot_table()
174183

175184
def generate_excel_report(self):
185+
"""Generates an Excel report."""
186+
176187
excel_path = str(Path(__file__).resolve().parent / 'report.xlsx')
177188
report = ExcelReport(excel_path, self._items_db)
178189
report.generate_report()
179190

180191
def generate_pdf_report(self):
192+
"""Generates a PDF report."""
193+
181194
pdf_path = str(Path(__file__).resolve().parent / 'report.pdf')
182195
report = PdfReport(pdf_path, self._items_db)
183196
report.generate_report()
184197

185198
def on_window_close(self):
199+
"""Callback for window close event."""
200+
186201
# Reference: https://stackoverflow.com/questions/111155/how-do-i-handle-the-window-close-event-in-tkinter
187202
print('Window Closing ...')
188203
self.destroy()
@@ -199,6 +214,8 @@ def _get_form_values(self):
199214
}
200215

201216
def clear_form(self):
217+
"""Clears the form."""
218+
202219
self.entry_name.delete(0, last_index=len(self.entry_name.get()))
203220
self.entry_amount.delete(0, last_index=len(self.entry_amount.get()))
204221
self.entry_description.delete(0, last_index=len(self.entry_description.get()))
@@ -207,6 +224,8 @@ def clear_form(self):
207224
self.entry_subcategory.delete(0, last_index=len(self.entry_subcategory.get()))
208225

209226
def fill_form(self, name, amount, description, date, category='None', subcategory='None'):
227+
"""Fills the form with provided values."""
228+
210229
self.clear_form()
211230
self.entry_name.insert(0, name)
212231
self.entry_amount.insert(0, amount)
@@ -216,6 +235,8 @@ def fill_form(self, name, amount, description, date, category='None', subcategor
216235
self.entry_subcategory.insert(0, subcategory)
217236

218237
def on_btn_add_clicked(self):
238+
"""Callback for add button click event."""
239+
219240
new_item = self._create_item_from_form()
220241

221242
if new_item is not None:
@@ -226,6 +247,8 @@ def on_btn_add_clicked(self):
226247
self.clear_form()
227248

228249
def on_btn_update_clicked(self):
250+
"""Callback for update button click event."""
251+
229252
# Get the (one) selected item
230253
selected_item = self.items_table.focus()
231254
item_dct = self.items_table.item(selected_item)
@@ -260,6 +283,8 @@ def on_btn_update_clicked(self):
260283
self.clear_form()
261284

262285
def on_btn_delete_clicked(self):
286+
"""Callback for delete button click event."""
287+
263288
yes_or_no = messagebox.askyesno("Delete Item", "Do you want to continue?")
264289

265290
if not yes_or_no:
@@ -279,7 +304,13 @@ def on_btn_delete_clicked(self):
279304
self.items_table.deletes_item(item_objs)
280305

281306
def _create_item(self, inp_item):
282-
# inp_item: List[str|int|float]
307+
"""
308+
Creates an item from input.
309+
310+
Args:
311+
inp_item (List[str|int|float]): List representing an item.
312+
"""
313+
283314
try:
284315
item_id = inp_item[0]
285316
item_name = inp_item[1]
@@ -314,6 +345,8 @@ def _create_item(self, inp_item):
314345
return None
315346

316347
def _create_item_from_form(self) -> Item | None:
348+
"""Creates an item from the form."""
349+
317350
try:
318351
if self.entry_category.get().strip() in ['None', '']:
319352
category = None
@@ -338,6 +371,8 @@ def _create_item_from_form(self) -> Item | None:
338371
return None
339372

340373
def on_row_selected(self, e):
374+
"""Callback for row selection event."""
375+
341376
# Reference: https://stackoverflow.com/questions/30614279/tkinter-treeview-get-selected-item-values
342377

343378
# Reference: For Multiple Selected Rows

0 commit comments

Comments
 (0)