Skip to main content

A Python project for managing expenses and generating reports

Project description

Who Owes Who - Documentation

Passing Build Stamp

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).

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

  1. Initialize Database: Set up tables using DatabaseManager.
  2. Manage Users:
    • Add users using add_user.
    • List users using list_users.
    • Remove users using remove_user.
  3. Record Expenses:
    • Add expenses using add_expense.
    • List all expenses using list_expenses.
    • Remove expenses using remove_expense.
  4. Calculate and Simplify Balances:
    • Use calculate_balances to calculate balances.
    • Use calculate_debts to compute detailed debts.
    • Use get_user_debts to fetch debts for a specific user.
    • Simplify debts with update_negative_debts.
  5. Generate Reports and Visualize Data:
    • Generate a summary using generate_summary.
    • Export reports with export_report.
    • Visualize debts with visualize_balances.

Example Demo

Here’s a quick demo of the package functionalities, as shown in the accompanying video:

  1. Add a New User: Demonstrated by adding John and Jane.
  2. Add a New Expense: John pays $100 for a team lunch with John, Jane, and Smith.
  3. List Users: Displays the list of all users.
  4. List Expenses: Shows the recorded expenses, including participants.
  5. Remove User: Removes Smith from the database.
  6. Remove Expense: Deletes an expense entry.
  7. Calculate Debts: Computes debts between users.
  8. Generate a Report: Generates a detailed report for John.
  9. Visualize Debts: Creates a pie chart for John’s debt situation.
  10. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

who_owes_who-0.1.0.tar.gz (19.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

who_owes_who-0.1.0-py3-none-any.whl (25.4 kB view details)

Uploaded Python 3

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

Hashes for who_owes_who-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fe2dc7e63ef771e44b749e4e5e9071b6d4d17f8407068f9bb77f6e4e0f05d9ad
MD5 fd5a28e79fcb264cf64a7f2020475483
BLAKE2b-256 8b5a8931487e7f491ffd226b9b38d33e5429ef94ee13d8d2dd9e78bd20acbbe6

See more details on using hashes here.

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

Hashes for who_owes_who-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0de97649609a7ffbfcea1cc044e273b0331bed0155317842a49ac17dd44cf1c1
MD5 4bda7d68bef662f388593a4c7a40572c
BLAKE2b-256 e605ad05f87c2395a6b10169ff4978a590a53230166bc3ea66092a897fd269e8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page