Video Demo: https://youtu.be/uB9szcePTnA
My project is a menu driven, expense logging, command line application. The user has the option of adding their daily expenses categorically, viewing all their entries(from the most recent to the oldest transaction, by date) in a tabular format, and generate visual data based on the total expenditure per category. The project utilizes object-oriented programming by modelling expenses as a class.
The main() function implements a match case statement for executing the menu functionality, where each case gives the user an option to perform a certain action in the program. In addition to the user capabilities mentioned in the description, the user can go over the instructions on how to add an entry and lastly is able to exit the program too.
Apart from the main() function, there are 5 other functions for carrying out specific tasks.
The show_menu() function contains the print statements to render the visuals of the main menu interface. I could have not made a seperate function for this as its not performing any computational task, but on realising the match case statment required the visual rendering of the main menu in more than one places, adhering to the DRY(Don't repeat yourself) principle, I decided on defining a function for this.
The add_entry() function takes 3 parameters(expense amount, date of transaction, and category) to add an expense entry to a csv file.
The show_all() function sorts the entries date wise(latest to oldest transaction) and renders them in a tabular format using python's tabulate library.
The categoryExpenseList() function returns a list of lists variable, where each element is a list containing the name of a category and the total amount spent on it.
The generate_visual() function takes 1 parameter, which is the format in which the user wants to see the category wise expenditure date(as returned by categoryExpenseList() function). The 3 format options available include a table format(using tabulate) and a bar graph and pie chart(using python's matplotlib)
This file contains a class named Expense. categories is defined as a class attribute, common and available to all instances of the Expense class. Three instance variables(for the amount, date and category) are defined in the init method. For all the 3 instance attributes, getter and setter properties are defined. A str method is also defined for describing the string representation of the class objects
This csv file contains all the expense entries added by the user
This test file has test functions written for Expense class methods and a project.py function, using python's pytest library. I have written tests for Expense class's init, str and setter properties. The test_init() function tests for the correct initialization of the Expense class, checking if the getter properties for each instance variable returns the expected value. The test_str() tests if the string representations of instances of Expense class are as expected. The test_set_amount(), test_set_date(), and test_set_category() tests check if the setter properties raise an Exception on passing invalid values for amount, date and category input respectively. There are 2 tests(test_valid_entry(), test_invalid_entry()) for the add_entry() function to check if it returns the expected message for valid and invalid entries to each of its 3 parameters