Sunday, March 30, 2025

Finance and Accounting Automation - Expense Tracker

 Notes:

  • What problem does it solve?: Helps businesses or individuals track and categorize expenses.

  • How can businesses benefit from customizing the code?: Customize categories and set budgets for each category to better manage cash flow and cut unnecessary spending.

  • How can businesses adopt the solution further?: Integrate the tool with accounting software to track expenses in real time and send alerts when expenses exceed set limits.


Actual Python Code:

import pandas as pd

class ExpenseTracker:
    def __init__(self):
        self.expenses = []

    def add_expense(self, date, category, amount):
        self.expenses.append({'Date': date, 'Category': category, 'Amount': amount})

    def get_expenses(self):
        return pd.DataFrame(self.expenses)

    def categorize_expenses(self):
        df = self.get_expenses()
        return df.groupby('Category')['Amount'].sum()

# Example usage
tracker = ExpenseTracker()
tracker.add_expense('2025-03-01', 'Marketing', 200)
tracker.add_expense('2025-03-02', 'Office Supplies', 50)
tracker.add_expense('2025-03-03', 'Marketing', 150)
print("All Expenses:")
print(tracker.get_expenses())
print("\nCategorized Expenses:")
print(tracker.categorize_expenses())

No comments:

Post a Comment

IoT (Internet of Things) Automation - Smart Energy Usage Tracker

  Notes: Problem Solved: Logs and analyzes power usage from smart meters. Customization Benefits: Track per-device energy and set ale...