Skip to content
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
<li><a href="#check-out-the-video">Check out the video!</a></li>
<li><a href="#what-is-new-in-this-version">What is new in this version?</a></li>
<li><a href="#installation">Installation</a></li>
<li><a href="#how-to-run">How To Run</a></li>
<li><a href="#configuring-email-credentials-for-smtp-sending-emails-from-your-account">Configuring Email Credentials for SMTP: Sending Emails from Your Account</a></li>
<li><a href="#testing">Testing</a></li>
<li><a href="#code-coverage">Code Coverage</a></li>
<li><a href="#use-cases">Use Cases</a></li>
<li><a href="#automated-analysis-tools">Automated Analysis Tools</a></li>
<li><a href="#License">License</a></li>
<li><a href="#code-documentation">Code Documentation</a></li>
Expand Down Expand Up @@ -68,7 +71,7 @@ DollarSplitBot: Where simplicity meets financial harmony at your fingertips.

## Check out the video!

To demonstrate our application's functionality and showcase its working examples, we have produced a YouTube video for the DollarSplitBot project. In this video, we showcase that the system operates as intended. You can view the video by clicking on the following link: [YouTube Link](https://youtu.be/aCjcT1CHAzU)
To demonstrate our application's functionality and showcase its working examples, we have produced a YouTube video for the DollarSplitBot project. In this video, we showcase that the system operates as intended. You can view the video by clicking on the following link: [YouTube Link](https://www.youtube.com/watch?v=JT06PTMHz7Y)

## What is new in this version?

Expand Down
26 changes: 0 additions & 26 deletions code/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,6 @@ def run(message, bot):
displays the user's historical data.
"""

# try:
# helper.read_json()
# chat_id = message.chat.id
# user_history = helper.getUserHistory(chat_id)

# if user_history is None:
# raise Exception("Sorry! No spending records found!")

# if len(user_history) == 0:
# bot.send_message(chat_id, "Sorry! No spending records found!")
# else:
# # Create a CSV representation of the data
# csv_data = "DATE, CATEGORY, AMOUNT\n"

# for line in user_history:
# rec = line.split(",") # Assuming data is comma-separated
# if len(rec) == 3:
# csv_data += f"{rec[0]}, {rec[1]}, {rec[2]}\n"

# # Send the CSV data as a text message
# bot.send_message(chat_id, csv_data)

# except Exception as e:
# logging.exception(str(e))
# bot.reply_to(message, "Oops! " + str(e))

try:
helper.read_json()
chat_id = message.chat.id
Expand Down
24 changes: 0 additions & 24 deletions code/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,10 @@
import logging
from matplotlib import pyplot as plt
from telebot import types

#Issue 15 - Added tabulate and fpdf libraries
from tabulate import tabulate
from fpdf import FPDF

#Issue 23 - Added Tabula library
#import tabula

#from reportlab.lib import colors
#from reportlab.lib.pagesizes import letter
#from reportlab.platypus import SimpleDocTemplate, Table, TableStyle

#Issue - 33

# === Documentation of pdf.py ===


def run(message, bot):
"""
run(message, bot): This is the main function used to implement the pdf save feature.
Expand All @@ -31,8 +18,6 @@ def run(message, bot):
#print('User-history--> ',user_history)
print('User_list', user_list)

#Issue 23 - add two pdf types - start

markup = types.ReplyKeyboardMarkup(one_time_keyboard=True)
#markup.row_width = 2
markup.add("PDF for Total Expenses - Category wise", "PDF showing who owes whom how much")
Expand All @@ -41,7 +26,6 @@ def run(message, bot):
user_history = helper.getUserHistory(chat_id)

bot.register_next_step_handler(msg, pdfGeneration, bot,user_list, user_history)
#Issue 23 - add two pdf types - end

except Exception as e:
logging.exception(str(e))
Expand Down Expand Up @@ -108,10 +92,6 @@ def pdfGeneration(message, bot, user_list, user_history):
pdf.output("expense_report.pdf")
bot.send_document(chat_id, open("expense_report.pdf", "rb"))
print("PDF generated successfully.")
#issue 15 - modified the format of pdf document - start


#Issue 3 - added the else condition - start
else:
message = "Looks like you have not entered any data yet. Please enter some data and then try creating a pdf."
bot.send_message(chat_id, message)
Expand All @@ -127,8 +107,6 @@ def pdfGeneration(message, bot, user_list, user_history):
display_text += commands[c] + "\n"
bot.send_message(chat_id, "Please select a menu option from below:")
bot.send_message(chat_id, display_text)
#Issue 3 - added the else condition - end
#Issue 23 - added code for generating pdf showing who owes whom how much
elif choice == 'PDF showing who owes whom how much':
message = "Alright. I just created a pdf of your expense history!"
bot.send_message(chat_id, message)
Expand All @@ -155,8 +133,6 @@ def pdfGeneration(message, bot, user_list, user_history):

pdf.set_font("helvetica", size=12)
for user, details in user_list.items():
#print('User! ', user)
#print('details! ', details)
for i, user_name in enumerate(details["users"]):
#amounts = ''
pdf.cell(50, 10, user_name, border=1, align="C", fill=True)
Expand Down
27 changes: 27 additions & 0 deletions code/send_mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ def run(message, bot):
bot.register_next_step_handler(message1, add_emails, bot)

def add_emails(message, bot):
"""
add_emails(message, bot):
Takes 2 arguments - message (a message received from the user) and bot (the chatbot instance).
This function extracts the email from the user's message and associates it with the user's chat ID in the user_emails dictionary.
It can also perform email validation. If the email is invalid, it sends a message to the user to enter a valid email.
Finally, the user is notified that their email has been recorded and is asked if they want to send an email to the provided address.
"""
chat_id = message.chat.id
email = message.text
# Assuming you want to store the email address in the user_emails dictionary
Expand All @@ -30,11 +37,24 @@ def add_emails(message, bot):

# Example of a basic email validation function (you can expand this)
def is_valid_email(email):
"""
is_valid_email(email):
Takes one argument - email (the email address to be validated).
This function checks if the provided email address is in a valid format using a regular expression pattern.
If the email is in a valid format, it returns True; otherwise, it returns False.
"""
import re
email_pattern = r'^\S+@\S+\.\S+$'
return re.match(email_pattern, email) is not None

def send_email(choice, bot):
"""
send_email(choice, bot):
Takes two arguments - choice (user's choice of sending an email) and bot (the chatbot instance).
If the user's choice is 'Y' or 'y', this function sets up a Gmail SMTP connection, composes and sends emails to all users stored in the user_emails dictionary.
It uses a Gmail account for sending emails, and the email content is based on data obtained from the 'helper.read_json()' function.
After sending the emails, it closes the SMTP connection.
"""
if str(choice.text) == "Y" or str(choice.text) == "y":
# Set up the Gmail API
smtp_server = 'smtp.gmail.com'
Expand Down Expand Up @@ -68,6 +88,13 @@ def send_email(choice, bot):


def format_text_data(user_list):
"""
format_text_data(user_list):
Takes one argument - user_list (a dictionary containing details about owed and owing amounts among users).
This function formats the provided user_list data into a text representation with detailed information on who owes and is owed money.
The formatted text data is enclosed in triple backticks for use in Markdown or code block formatting.
The resulting text data is returned as a string.
"""
text_data = "```\n"

for user, details in user_list.items():
Expand Down
29 changes: 8 additions & 21 deletions docs/code.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,21 @@
code.py is the main file from where calls to the corresponding .py files for all features are sent. It contains a number of endpoints which redirect to function calls in the corresponding files.

# Location of Code for this Feature
The code that implements this feature can be found [here](https://github.com/sak007/MyDollarBot-BOTGo/blob/main/code/code.py)
The code that implements this feature can be found [here](https://github.com/shonilbhide/dollar_bot/blob/Rubrics/code/code.py)


# Code Description
## Functions

1. main()
The entire bot's execution begins here. It ensure the **bot** variable begins polling and actively listening for requests from telegram.

2. listener(user_requests):
Takes 1 argument **user_requests** and logs all user interaction with the bot including all bot commands run and any other issue logs.

3. start_and_menu_command(m):
Prints out the the main menu displaying the features that the bot offers and the corresponding commands to be run from the Telegram UI to use these features. Commands used to run this: commands=['start', 'menu']

4. command_add(message)
Takes 1 argument **message** which contains the message from the user along with the chat ID of the user chat. It then calls add.py to run to execute the add functionality. Commands used to run this: commands=['add']
- run(message, bot): This function serves as the entry point for the budget feature. It displays a menu in the chatbot, prompting the user to select an operation related to their budget. The available options are determined by the helper.getBudgetOptions() function. Once the user makes a selection, the control is passed to the post_operation_selection(message, bot) function for further processing.

5. command_history(message):
Takes 1 argument **message** which contains the message from the user along with the chat ID of the user chat. It then calls history.py to run to execute the add functionality. Commands used to run this: commands=['history']
- post_operation_selection(message, bot): This function processes the user's selection of a budget operation. It checks if the selected operation is valid and, if not, informs the user that the operation is invalid. If the user is new and doesn't have a budget record, it initializes one. Depending on the selected operation (e.g., add, update, view, delete), it calls the respective sub-module functions to perform the desired operation and then stores the updated budget data using helper.write_json(user_list).

6. command_edit(message):
Takes 1 argument **message** which contains the message from the user along with the chat ID of the user chat. It then calls edit.py to run to execute the add functionality. Commands used to run this: commands=['edit']
- budget_update.run(message, bot): This function is called when the user selects the "add" or "update" operation. It handles the process of adding or updating budget expenses. The exact details of these operations are likely implemented in the budget_update module.

7. command_display(message):
Takes 1 argument **message** which contains the message from the user along with the chat ID of the user chat. It then calls display.py to run to execute the add functionality. Commands used to run this: commands=['display']
- budget_view.run(message, bot): This function is called when the user selects the "view" operation. It is responsible for displaying the user's budget information, such as expenses and balances. The specific implementation of the viewing process is likely found in the budget_view module.

8. command_delete(message):
Takes 1 argument **message** which contains the message from the user along with the chat ID of the user chat. It then calls delete.py to run to execute the add functionality. Commands used to run this: commands=['display']
- budget_delete.run(message, bot): This function is called when the user selects the "delete" operation. It is responsible for managing the process of deleting specific budget expenses. The details of how the deletion process works are likely defined in the budget_delete module.

# How to run this feature?
This file contains information on the main code.py file from where all features are run. Instructions to run this are the same as instructions to run the project and can be found in README.md.
This file contains information on the main code.py file from where all features are run. Instructions to run this are the same as instructions to run the project and can be found in README.md.
10 changes: 5 additions & 5 deletions docs/graphing.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ This feature enables the user to see their expense in a graphical format to enab
Currently, the /display command will provide the expenses as a message to the users via the bot. To better the UX, we decided to add the option to show the expenses in a Bar Graph.

# Location of Code for this Feature
The code that implements this feature can be found [here](https://github.com/sak007/MyDollarBot-BOTGo/blob/main/code/graphing.py)
The code that implements this feature can be found [here](https://github.com/shonilbhide/dollar_bot/blob/Rubrics/code/graphing.py)

# Code Description
## Functions

1. visualize(total_text):
This is the main function used to implement the graphing part of display feature. This file is called from display.py, and takes the user expense as a string and creates a dictionary which in turn is fed as input matplotlib to create the graph
- viewBudget(data): This function creates a pie chart to visualize different budget categories. It takes a dictionary of budget data as input and generates a graph that represents the budget distribution across various categories. To provide a visual representation of how the budget is allocated in different spending categories.

2. addlabels(x, y):
This function is used to add the labels to the graph. It takes the expense values and adds the values inside the bar graph for each expense type
- addlabels(x, y): This function is used to add labels to the bar graph. It takes two lists, 'x' (category names) and 'y' (expenditure values), and adds the corresponding values inside the bars of a bar graph. To make the bar graph more informative by labeling each bar with its expenditure value.

- visualize(total_text, monthly_budget): This is the main function that generates a bar graph to compare actual expenditure with the budget for different categories. It takes two inputs: 'total_text,' which contains information about actual expenses, and 'monthly_budget,' which is a dictionary specifying the budget for each category. To create a visual comparison between the user's actual expenditures and their budgeted amounts for different spending categories.

# How to run this feature?
After you've added sufficient input data, use the /display command and you can see the output in a pictorial representation.
34 changes: 12 additions & 22 deletions docs/helper.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,32 @@
The helper file contains a set of functions that are commonly used for repeated tasks in the various features of MyDollarBot. Since these come up often, we have put them all up here in a separate file for reusability.

# Location of Code for this Feature
The code that implements this feature can be found [here](https://github.com/sak007/MyDollarBot-BOTGo/blob/main/code/helper.py)
The code that implements this feature can be found [here](https://github.com/shonilbhide/dollar_bot/blob/main/code/helper.py)

# Code Description
## Functions

1. read_json():
Function to load .json expense record data
- spend_categories: This is a list of predefined spending categories, such as "Food," "Groceries," "Utilities," etc. These categories are used to categorize expenses.

2. write_json(user_list):
Stores data into the datastore of the bot.
- choices: A list containing three options: "Date," "Category," and "Cost." These options might be used to select how the user wants to view or filter their expense data.

3. validate_entered_amount(amount_entered):
Takes 1 argument, **amount_entered**. It validates this amount's format to see if it has been correctly entered by the user.
- spend_display_option: This list contains two options: "Day" and "Month." These options could be used to specify whether the user wants to view expenses on a daily or monthly basis.

4. getUserHistory(chat_id):
Takes 1 argument **chat_id** and uses this to get the relevant user's historical data.
- spend_estimate_option: Another list with two options: "Next day" and "Next month." These might be used to estimate future expenses based on past spending data.

5. getSpendCategories():
This functions returns the spend categories used in the bot. These are defined the same file.
- update_options: A dictionary with two key-value pairs, "continue" and "exit." These options could be used to continue or exit a particular process within the program.

6. getSpendDisplayOptions():
This functions returns the spend display options used in the bot. These are defined the same file.
- budget_options: A dictionary with options related to budget management, such as "add," "update," "view," and "delete."

7. getCommands():
This functions returns the command options used in the bot. These are defined the same file.
- budget_types: A dictionary that defines different types of budgets, such as "Overall Budget" and "Category-Wise Budget."

8. def getDateFormat():
This functions returns the date format used in the bot.
- data_format: A dictionary that seems to be an initial data structure for storing user data, expenses, and budgets. It has placeholders for various data, including user information, expenses, and budget details.

9. def getTimeFormat():
This functions returns the time format used in the bot.
- commands: A dictionary that provides descriptions of various commands or actions that the user can perform within the program. These descriptions include commands like "add," "display," "edit," etc.

10. def getMonthFormat():
This functions returns the month format used in the bot.
Functions: The code defines several functions, including read_json, write_json, validate_entered_amount, and others. These functions likely handle reading and writing data, validating user input, and managing user records and budgets

# How to run this feature?
Once the project is running(please follow the instructions given in the main README.md for this), please type /add into the telegram bot.

This file is not a feature and cannot be run per se. Its functions are used all over by the other files as it provides helper functions for various functionalities and features.
This file is not a feature and cannot be run per se. Its functions are used all over by the other files as it provides helper functions for various functionalities and features.
Loading