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.
The code that implements this feature can be found here
-
read_json(): Function to load .json expense record data
-
write_json(user_list): Stores data into the datastore of the bot.
-
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.
-
getUserHistory(chat_id): Takes 1 argument chat_id and uses this to get the relevant user's historical data.
-
getUserHistoryByCategory(chat_id,category): Takes 2 arguments chat_id and category and returns the expenses from a specific category for a given chat id.
-
getUserData(chat_id): This function gives all the data related to a user from the chat_id. Includes budgets and expenses.
-
throw_exception(e, message, bot, logging): Used for error handling in bot code. Throws exception if any is thrown by another part of code.
-
createNewUserRecord(): Creates a new record for a newly registered user
-
getOverallBudget(chatId): Returns overall budget value for given user
-
getCategoryBudget(chatId): Returns category-wise budget split for given user
-
getCategoryBudgetByCategory(chatId, cat): Returns specific category's budget allocation
-
isOverallBudgetAvailable(chatId): Checks whether overall budget is initialized or not
-
isCategoryBudgetAvailable(chatId): Checks whether category wise budget is initialized or not
-
isCategoryBudgetByCategoryAvailable(chatId, cat): Checks whether specified category's budget is initialized or not
-
get_uncategorized_amount(chatId, amount): Calculates the portion of the budget that is not assigned to any specific category
-
display_remaining_budget(message, bot, cat): Displays remaining budget
-
display_remaining_overall_budget(message, bot): Displays overall budget after recorded expenses
-
calculateRemainingOverallBudget(chat_id): Calculate remaining overall budget after recorded expenses
-
calculate_total_spendings(queryResult): Calculate total spendings of the user
-
display_remaining_category_budget(message, bot, cat): Display remaining category budget for a specific category
-
calculateRemainingCategoryBudget(chat_id, cat): Calculate remaining category budget after recorded expenses in the specific category
-
calculateRemainingCateogryBudgetPercent(chat_id, cat): Calculate percentage of spent money on a particular category against its budget.
-
calculate_total_spendings_for_category(queryResult, cat): Calculate total spending of the user within a specific category
-
updateBudgetCategory(chatId, category): initializes the specific budget category
-
getAvailableCategories(history): Get available categories from history data
-
getCategoryWiseSpendings(available_categories, history): Get category wise spending details
-
getFormattedPredictions(category_predictions): Format predictions into readable format from dictionary into string in order to send message to the user.
-
getSpendCategories(): This functions returns the spend categories used in the bot. These are defined the same file.
-
getSpendDisplayOptions(): This functions returns the spend display options used in the bot. These are defined the same file.
-
getCommands(): This functions returns the command options used in the bot. These are defined the same file.
-
def getDateFormat(): This functions returns the date format used in the bot.
-
def getTimeFormat(): This functions returns the time format used in the bot.
-
def getMonthFormat(): This functions returns the month format used in the bot.
-
getBudgetOptions(): This function returns the budget options used by the bot. These are defined in the same file.
-
getBudgetTypes(): This function returns the types of budgets that can be set up by users. These are defined in the same file.
-
getUpdateOptions(): This function returns the update options used by the bot. These are defined in the same file.
-
getAnalyticsOptions(): This function returns the analytics options used by the bot. These are defined in the same file.
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.