diff --git a/Budget_Allocation_Breakdown_PieChart.png b/Budget_Allocation_Breakdown_PieChart.png index a7c91eb..4edb20a 100644 Binary files a/Budget_Allocation_Breakdown_PieChart.png and b/Budget_Allocation_Breakdown_PieChart.png differ diff --git a/Budget_Percentage_Calculation.py b/Budget_Percentage_Calculation.py index 002b008..b310434 100644 --- a/Budget_Percentage_Calculation.py +++ b/Budget_Percentage_Calculation.py @@ -6,10 +6,13 @@ # Import tabulate to display budget breakdown in a table format from tabulate import tabulate - # To add coloured text in console output - # Fore: For changing the text colour (e.g., Fore.RED for red text) - # Style: For additional text formatting like BRIGHT, DIM, and NORMAL - # init: To ensure compatibility with Windows terminals by enabling ANSI color codes + """ + To add coloured text in console output + Fore: For changing the text colour (e.g., Fore.RED for red text) + Style: For additional text formatting like BRIGHT, DIM, and NORMAL + init: To ensure compatibility with Windows terminals by enabling ANSI color codes + """ + from colorama import Fore, Style, init # Import pyfiglet for ASCII art title formatting @@ -24,13 +27,15 @@ # A class to represents a monthly budget allocation system class Budget: - # Initializes the budget with income and expenses, ensuring values are valid. - # Parameters: - # income (float): The user's total monthly income. - # fixed_expenses (float): The total fixed expenses deducted from the income. + """ + Initializes the budget with income and expenses, ensuring values are valid. + Parameters: + income (float): The user's total monthly income. + fixed_expenses (float): The total fixed expenses deducted from the income. + """ def __init__(self, income, fixed_expenses): - # Attributes: - # income (float): Stores the provided income value. + + # Attributes: income (float): Stores the provided income value. self.income = income # fixed_expenses (float): Stores the provided fixed expenses value. @@ -82,9 +87,9 @@ def display_budget(self): # Print the text in red text print(f"{Fore.RED}Your Monthly Budget Allocation:") - # Define a list of tuples containing budget categories and their calculated values - # Each tuple consists of two elements: the category name (as a string) and the corresponding value -# that was calculated earlier in the budget_calculation() method. + """Define a list of tuples containing budget categories and their calculated values. + Each tuple consists of two elements: the category name (as a string) and the corresponding value + that was calculated earlier in the budget_calculation() method.""" catergories = [ ("Saving" , savings), ("Investment" , investments), diff --git a/README.md b/README.md index b20506b..9e0fdff 100644 --- a/README.md +++ b/README.md @@ -1,57 +1,85 @@ # Budget_allocation_app ## Overview - ###The Budget Allocation App is a command-line interface (CLI) tool designed to help users optimize their monthly income through tailored budgeting and expense planning. + The Budget Allocation App is a command-line interface (CLI) tool designed to help users optimize their monthly income through tailored budgeting and expense planning. The app calculates how users can best allocate their income across various expense categories by allocating remaining income after fixed expense have been deducted. It provides a visual breakdown of spending into categories displaying in table format and in a pie chart in .png format. ## Features - **User Input**: Collects monthly income and fixed expenses from the user. - **Budget Allocation**: Calculates the budget and allocates for various categories such as Savings, Investments, Dining Out, and Guilt-Free Spending post expenses deductions. - **Budget Visualization**: Displays formated budgeted in tables and a pie chart representing the budget breakdown. - - *Supports multiple calculations - *Includes error handling and input validation - -## Requirement: - Before running the app, ensure you have the following installed: - - **Python 3.x** (Recommended: Python 3.8+) - The following Python libraries (can be installed using 'pip'): - - 'matplotlib': For visualizing the budget allocation in a pie chart. - - 'tabulate': For formatting the budget data into a table. - - 'colorama': For terminal text formatting (used to display colorful output). - - 'pyfiglet': For printing the app header in an ASCII art style. - - You can install these dependencies by running: + #### User Input: Collects monthly income and fixed expenses from the user. + #### Budget Allocation: Calculates the budget and allocates for various categories such as Savings, Investments, Dining Out, and Guilt-Free Spending post expenses deductions. + #### Budget Visualization: Displays formated budgeted in tables and a pie chart representing the budget breakdown. + + #### Supports multiple calculations + #### Includes error handling and input validation + +## System Requirements: + #### Before running the app, ensure you have the following installed: + #### Python 3.x (Recommended: Python 3.8+) + The following Python libraries (can be installed using 'pip') + - 'matplotlib': For visualizing the budget allocation in a pie chart. + - 'tabulate': For formatting the budget data into a table. + - 'colorama': For terminal text formatting (used to display colorful output). + - 'pyfiglet': For printing the app header in an ASCII art style. + + You can install these dependencies by running: ```bash - pip install matplotlib tabulate colorama pyfiglet``` + pip install matplotlib tabulate colorama pyfiglet + ``` + Recommended operating systems, with memory of minimum 2GB RAM (for smooth execution of the script) : + - Windows + - MacOS + - Linux + +## Installation Steps +Inside the terminal: -## Installation - ###Step 1: Create new folder for repository to be saved in. +1. Create new folder for repository to be saved in and change your directory to be in the folder. ``` mkdir Budget_allocation_app cd Budget_allocation_app ``` - ### Step 2: - Clone this repository to your local machine via terminal: +2. Clone this repository to your local machine via terminal. + ``` git clone git@github.com:Angie-newbie/Budget_allocation_app.git ``` - - ### Step 3: - Create virtual environment to install dependencies in your IDE: - ###Step 4: Install the required dependencies: +3. To start open and code in your chosen IDE: + ``` + code . + ``` + +5. Create virtual environment to install dependencies in your IDE: + + Create virtual environment in your chosen IDE + ``` + python -m venv .venv + ``` + Activate the environment + macOS/Unix + ``` + source .venv/bin/activate + ``` + Windows + ``` + .venv\Scripts\activate + ``` + Verify activation + ``` + python --version + ``` + Check installed packages & create output into requirements.txt file + ``` + pip freeze > requirements.txt + ``` +6. Install the required dependencies: ``` pip install matplotlib tabulate colorama pyfiglet ``` - ###Step 3: Run the App - ``` - python main.py - ``` - ## Usage of app +To run the Budget Allocation App In termimal: ``` python main.py @@ -92,3 +120,4 @@ Guilt-Free Spending: 10% of remaining income - `tabulate` (version 0.9.0) - Licensed under the [MIT License](https://opensource.org/licenses/MIT) - `colorama` (version 0.4.6) - Licensed under the [MIT License](https://opensource.org/licenses/MIT) - `pyfiglet` (version 0.8) - Licensed under the [MIT License](https://opensource.org/licenses/MIT) + diff --git a/__pycache__/Budget_Percentage_Calculation.cpython-312.pyc b/__pycache__/Budget_Percentage_Calculation.cpython-312.pyc index 5b80541..2c0414d 100644 Binary files a/__pycache__/Budget_Percentage_Calculation.cpython-312.pyc and b/__pycache__/Budget_Percentage_Calculation.cpython-312.pyc differ diff --git a/__pycache__/continue_app.cpython-312.pyc b/__pycache__/continue_app.cpython-312.pyc index d4d25cb..daefd26 100644 Binary files a/__pycache__/continue_app.cpython-312.pyc and b/__pycache__/continue_app.cpython-312.pyc differ diff --git a/__pycache__/user_input.cpython-312.pyc b/__pycache__/user_input.cpython-312.pyc index e18e76e..d8f0e1a 100644 Binary files a/__pycache__/user_input.cpython-312.pyc and b/__pycache__/user_input.cpython-312.pyc differ diff --git a/continue_app.py b/continue_app.py index 6b2c61c..8e64b8d 100644 --- a/continue_app.py +++ b/continue_app.py @@ -17,19 +17,23 @@ def ask_to_continue(): answer = input('Do you wish to calculate another budget? (y/n): ') # If user enters 'y', return True to continue the process - if answer == 'y': + if answer.lower() == 'y': return True - + # If user enters 'n', print a message and return False to exit. - elif answer == 'n': + elif answer.lower() == 'n': print('Thank you for using the Budget App!') return False # If the input is not 'y' or 'n', show an error message and prompt again. else: print("Invalid input! Please enter 'y' for yes or 'n' for no.") + + # Handle key interruption by user by pressing ctrl + c + except KeyboardInterrupt: + print('\nApp terminated by user.') # Handle any unexpected errors except Exception as e : - print(f'Error: Unexpected error {e} occor') - \ No newline at end of file + print(f'Error: Unexpected error {e} occor') + diff --git a/user_input.py b/user_input.py index bd5cedd..f0c1366 100644 --- a/user_input.py +++ b/user_input.py @@ -41,6 +41,8 @@ def get_user_input(self): # Prompt again continue + + # Prompt user for fixed expenses and validate input self.fix_expenses = float(input('Please enter your monthly fixed expenses: ')) @@ -53,9 +55,14 @@ def get_user_input(self): # Prompt again continue + # If the user expesnes > monthly income: + elif self.fix_expenses > self.income: + print(f"Error: Expenses cannot be greater than your monthly income. Please try again.") + # Return validated values for running the calculation + continue return self.income, self.fix_expenses - + # Handles cases where the user enters a non-numeric value except ValueError: @@ -65,6 +72,12 @@ def get_user_input(self): # Prompt again continue + # Catches user pressing ctrl + c + except KeyboardInterrupt: + print(f"App exited by user.") + exit() + + # Catches any other unexpected errors except Exception as e: # Print the error message