A Python project for managing expenses and generating reports
Project description
Who Owes Who - Documentation
Overview
Who Owes Who is a Python package designed to manage shared expenses among users. It provides functionality to track expenses, calculate balances, simplify debts, and generate reports with detailed visualizations. This package is built for users who need to manage group expenses efficiently and keep track of debts.
Key Functionalities
1. Database Management (db_management.py)
Handles database initialization and table creation.
DatabaseManager- Initializes the SQLite database and creates required tables (
users,expenses,balances,debts).
- Initializes the SQLite database and creates required tables (
2. User Management (user_management.py)
Manages user-related operations.
add_user(name: str)- Adds a user to the database.
remove_user(name: str)- Removes a user and their associated balances and debts.
list_users()- Lists all registered users.
3. Expense Management (expense_operations.py)
Tracks and manages expenses.
add_expense(payer: str, amount: float, participants: list)- Records a new expense, splitting the amount among participants.
remove_expense(id: int)- Deletes an existing expense by its ID.
list_expenses()- Lists all recorded expenses.
4. Balance Calculation (balance_calculation.py)
Calculates user balances and simplifies debts.
calculate_balances()- Calculates net balances for all users.
calculate_debts()- Computes detailed debts between creditors and debtors.
get_user_debts(user: str)- Retrieves debts specific to a user.
update_negative_debts()- Converts negative debt balances to proper positive entries.
5. Reporting Tools (report_generation.py)
Generates summaries, exports reports, and visualizes data.
generate_summary(user: str)- Summarizes expenses and debts in a well-formatted string.
export_report(user: str, file_format: str)- Exports reports in TXT, CSV, or XLSX formats.
visualize_balances(user: str)- Creates pie charts summarizing debts and balances.
Usage Flow
- Initialize Database: Set up tables using
DatabaseManager. - Manage Users:
- Add users using
add_user. - List users using
list_users. - Remove users using
remove_user.
- Add users using
- Record Expenses:
- Add expenses using
add_expense. - List all expenses using
list_expenses. - Remove expenses using
remove_expense.
- Add expenses using
- Calculate and Simplify Balances:
- Use
calculate_balancesto calculate balances. - Use
calculate_debtsto compute detailed debts. - Use
get_user_debtsto fetch debts for a specific user. - Simplify debts with
update_negative_debts.
- Use
- Generate Reports and Visualize Data:
- Generate a summary using
generate_summary. - Export reports with
export_report. - Visualize debts with
visualize_balances.
- Generate a summary using
Example Demo
Here’s a quick demo of the package functionalities, as shown in the accompanying video:
- Add a New User: Demonstrated by adding
JohnandJane. - Add a New Expense: John pays $100 for a team lunch with
John, Jane, and Smith. - List Users: Displays the list of all users.
- List Expenses: Shows the recorded expenses, including participants.
- Remove User: Removes
Smithfrom the database. - Remove Expense: Deletes an expense entry.
- Calculate Debts: Computes debts between users.
- Generate a Report: Generates a detailed report for
John. - Visualize Debts: Creates a pie chart for
John’sdebt situation. - Export Report: Saves the report as a CSV file.
Example Code
from expense_tracker.reporting_tools.balance_calculation import BalanceManager
from expense_tracker.reporting_tools.report_generation import ReportGeneration
from expense_tracker.expense_management.db_management import DatabaseManager
# Initialize database and managers
db = DatabaseManager("expense_tracker.db")
balance_manager = BalanceManager(db)
report_gen = ReportGeneration(db)
# Add users and expenses
db.cursor.execute("INSERT INTO users (name) VALUES ('John'), ('Jane'), ('Smith')")
db.conn.commit()
balance_manager.calculate_debts()
report_gen.export_report("John", file_format="csv")
Contribution
Feel free to fork the repository and submit pull requests for additional features or bug fixes.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file who_owes_who-0.1.0.tar.gz.
File metadata
- Download URL: who_owes_who-0.1.0.tar.gz
- Upload date:
- Size: 19.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe2dc7e63ef771e44b749e4e5e9071b6d4d17f8407068f9bb77f6e4e0f05d9ad
|
|
| MD5 |
fd5a28e79fcb264cf64a7f2020475483
|
|
| BLAKE2b-256 |
8b5a8931487e7f491ffd226b9b38d33e5429ef94ee13d8d2dd9e78bd20acbbe6
|
File details
Details for the file who_owes_who-0.1.0-py3-none-any.whl.
File metadata
- Download URL: who_owes_who-0.1.0-py3-none-any.whl
- Upload date:
- Size: 25.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0de97649609a7ffbfcea1cc044e273b0331bed0155317842a49ac17dd44cf1c1
|
|
| MD5 |
4bda7d68bef662f388593a4c7a40572c
|
|
| BLAKE2b-256 |
e605ad05f87c2395a6b10169ff4978a590a53230166bc3ea66092a897fd269e8
|