Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change comments based on feedback #6

Merged
merged 9 commits into from
Mar 4, 2025
Merged
Binary file modified Budget_Allocation_Breakdown_PieChart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 18 additions & 13 deletions Budget_Percentage_Calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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),
Expand Down
93 changes: 61 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 [email protected]: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
Expand Down Expand Up @@ -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)

Binary file modified __pycache__/Budget_Percentage_Calculation.cpython-312.pyc
Binary file not shown.
Binary file modified __pycache__/continue_app.cpython-312.pyc
Binary file not shown.
Binary file modified __pycache__/user_input.cpython-312.pyc
Binary file not shown.
14 changes: 9 additions & 5 deletions continue_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

print(f'Error: Unexpected error {e} occor')

15 changes: 14 additions & 1 deletion user_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: '))

Expand All @@ -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:

Expand All @@ -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
Expand Down