├── tests ├── cost.txt └── one.db ├── .gitignore ├── src ├── expense_tracker │ ├── __init__.py │ ├── __pycache__ │ │ ├── app.cpython-39.pyc │ │ ├── __init__.cpython-39.pyc │ │ ├── __main__.cpython-39.pyc │ │ ├── remotefunc.cpython-39.pyc │ │ ├── remotetracker.cpython-39.pyc │ │ ├── expensetracker.cpython-39.pyc │ │ └── expensetrackerclass.cpython-39.pyc │ ├── expensetracker.py │ ├── templates │ │ └── index.html │ ├── requirements.txt │ ├── app.py │ ├── remotefunc.py │ └── expensetrackerclass.py └── expense_tracker.egg-info │ ├── dependency_links.txt │ ├── top_level.txt │ ├── requires.txt │ ├── entry_points.txt │ ├── SOURCES.txt │ └── PKG-INFO ├── setup.cfg ├── res └── web.jpg ├── pyproject.toml ├── dist ├── expense-tracker-2.0.tar.gz └── expense_tracker-2.0-py3-none-any.whl ├── CONTRIBUTING.md ├── .github └── ISSUE_TEMPLATE │ └── feature_request.md ├── LICENSE ├── setup.py ├── README.md └── CODE_OF_CONDUCT.md /tests/cost.txt: -------------------------------------------------------------------------------- 1 | 1000 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | src/expense_tracker/.env/ -------------------------------------------------------------------------------- /src/expense_tracker/__init__.py: -------------------------------------------------------------------------------- 1 | import expensetracker -------------------------------------------------------------------------------- /src/expense_tracker.egg-info/dependency_links.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/expense_tracker.egg-info/top_level.txt: -------------------------------------------------------------------------------- 1 | expense_tracker 2 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | description-file=README.md 3 | license_files=LICENSE -------------------------------------------------------------------------------- /res/web.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spyke7/EXPENSE-TRACKER/HEAD/res/web.jpg -------------------------------------------------------------------------------- /tests/one.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spyke7/EXPENSE-TRACKER/HEAD/tests/one.db -------------------------------------------------------------------------------- /src/expense_tracker.egg-info/requires.txt: -------------------------------------------------------------------------------- 1 | matplotlib 2 | requests 3 | flask 4 | bcrypt 5 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools>=61.0"] 3 | build-backend = "setuptools.build_meta" -------------------------------------------------------------------------------- /dist/expense-tracker-2.0.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spyke7/EXPENSE-TRACKER/HEAD/dist/expense-tracker-2.0.tar.gz -------------------------------------------------------------------------------- /src/expense_tracker.egg-info/entry_points.txt: -------------------------------------------------------------------------------- 1 | [console_scripts] 2 | expense-tracker = expense_tracker.expensetracker:main 3 | -------------------------------------------------------------------------------- /dist/expense_tracker-2.0-py3-none-any.whl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spyke7/EXPENSE-TRACKER/HEAD/dist/expense_tracker-2.0-py3-none-any.whl -------------------------------------------------------------------------------- /src/expense_tracker/__pycache__/app.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spyke7/EXPENSE-TRACKER/HEAD/src/expense_tracker/__pycache__/app.cpython-39.pyc -------------------------------------------------------------------------------- /src/expense_tracker/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spyke7/EXPENSE-TRACKER/HEAD/src/expense_tracker/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /src/expense_tracker/__pycache__/__main__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spyke7/EXPENSE-TRACKER/HEAD/src/expense_tracker/__pycache__/__main__.cpython-39.pyc -------------------------------------------------------------------------------- /src/expense_tracker/__pycache__/remotefunc.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spyke7/EXPENSE-TRACKER/HEAD/src/expense_tracker/__pycache__/remotefunc.cpython-39.pyc -------------------------------------------------------------------------------- /src/expense_tracker/__pycache__/remotetracker.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spyke7/EXPENSE-TRACKER/HEAD/src/expense_tracker/__pycache__/remotetracker.cpython-39.pyc -------------------------------------------------------------------------------- /src/expense_tracker/__pycache__/expensetracker.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spyke7/EXPENSE-TRACKER/HEAD/src/expense_tracker/__pycache__/expensetracker.cpython-39.pyc -------------------------------------------------------------------------------- /src/expense_tracker/expensetracker.py: -------------------------------------------------------------------------------- 1 | import expensetrackerclass 2 | 3 | usersTracker = expensetrackerclass.ExpenseTracker() 4 | usersTracker.loadFunc() 5 | usersTracker.takeCommand() -------------------------------------------------------------------------------- /src/expense_tracker/__pycache__/expensetrackerclass.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spyke7/EXPENSE-TRACKER/HEAD/src/expense_tracker/__pycache__/expensetrackerclass.cpython-39.pyc -------------------------------------------------------------------------------- /src/expense_tracker/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Expense Tracker 8 | 9 | 10 | Welcome to expense tracker 11 | 12 | -------------------------------------------------------------------------------- /src/expense_tracker/requirements.txt: -------------------------------------------------------------------------------- 1 | bcrypt==4.0.1 2 | Flask==2.2.2 3 | Flask-Bcrypt==1.0.1 4 | Flask-Login==0.6.2 5 | Flask-SQLAlchemy==3.0.2 6 | Flask-WTF==1.0.1 7 | importlib-metadata==5.1.0 8 | Jinja2==3.1.2 9 | jwt==1.3.1 10 | kiwisolver==1.4.2 11 | MarkupSafe==2.1.1 12 | matplotlib==3.5.1 13 | packaging==21.3 14 | Pillow==9.0.1 15 | pycparser==2.21 16 | pyparsing==3.0.7 17 | requests==2.27.1 18 | six==1.16.0 19 | SQLAlchemy==1.4.44 20 | urllib3==1.26.9 21 | Werkzeug==2.2.2 22 | WTForms==3.0.1 23 | gunicorn==20.1.0 24 | psycopg2==2.9.5 25 | psycopg2-binary==2.9.5 -------------------------------------------------------------------------------- /src/expense_tracker.egg-info/SOURCES.txt: -------------------------------------------------------------------------------- 1 | LICENSE 2 | README.md 3 | pyproject.toml 4 | setup.cfg 5 | setup.py 6 | src/expense_tracker/__init__.py 7 | src/expense_tracker/app.py 8 | src/expense_tracker/expensetracker.py 9 | src/expense_tracker/expensetrackerclass.py 10 | src/expense_tracker/remotefunc.py 11 | src/expense_tracker.egg-info/PKG-INFO 12 | src/expense_tracker.egg-info/SOURCES.txt 13 | src/expense_tracker.egg-info/dependency_links.txt 14 | src/expense_tracker.egg-info/entry_points.txt 15 | src/expense_tracker.egg-info/requires.txt 16 | src/expense_tracker.egg-info/top_level.txt -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated. 2 | 3 | If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again! 4 | 5 | - Star the repo. 6 | - Raise an issue about the feature so that we can assign. 7 | - Fork the Project 8 | - Create your Feature Branch (git checkout -b ) 9 | - Commit your Changes (git commit -m 'Add some advices') 10 | - Push to the Branch 11 | - Open a Pull Request 12 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 Shreejan Dolai 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import setuptools 2 | 3 | with open("README.md", "r", encoding="utf-8") as fh: 4 | long_description = fh.read() 5 | 6 | setuptools.setup( 7 | name="expense-tracker", 8 | version="2.0", 9 | author="Shreejan Dolai", 10 | author_email="dolaishreejan@gmail.com", 11 | description="Expense Tracker is a very good tool to keep track of your expenseditures and the total money you saved.🤑🤑", 12 | long_description=long_description, 13 | long_description_content_type="text/markdown", 14 | url="https://github.com/CapedDemon/EXPENSE-TRACKER", 15 | project_urls={ 16 | "Bug Tracker": "https://github.com/CapedDemon/EXPENSE-TRACKER/issues", 17 | }, 18 | classifiers=[ 19 | "Programming Language :: Python :: 3", 20 | "License :: OSI Approved :: MIT License", 21 | "Operating System :: OS Independent", 22 | ], 23 | package_dir={"": "src"}, 24 | packages=setuptools.find_packages(where="src"), 25 | python_requires=">=3.9", 26 | keywords=['expense', 'tracker', 27 | 'money', 'py', 'expense tracker', 'expense-tracker', 'money tracker', 'money-tracker'], 28 | install_requires=[ 29 | 'matplotlib', 30 | 'requests', 31 | 'flask', 32 | 'bcrypt' 33 | ], 34 | entry_points={ 35 | 'console_scripts': [ 36 | 'expense-tracker = expense_tracker.expensetracker:main', 37 | ], 38 | } 39 | ) 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # EXPENSE TRACKER 2 | Language 3 | License 4 | [![CodeFactor](https://www.codefactor.io/repository/github/capeddemon/commandconsole/badge)](https://www.codefactor.io/repository/github/capeddemon/commandconsole) 5 | 6 | Expense Tracker is a very good tool to keep track of your expenseditures and the total money you saved.🤑🤑 7 | 8 | We at some point of our life have kept track of our expenses and the money saved. 📃 We all have used the traditional way of keeping our 9 | record by writing our expenses in our **personal diary** 📃 which can be burnt out, the papers might cut into pieces ✂ or the 📜 diary 10 | got so old 🗑 that we need to write our expenses in another diary.🖋🖋 It is very time consuming also.⏳⌚ 11 | 12 | *But it is the most safe way of keeping record. But the time has changed laptops and mobiles are takng over. Most of the time we are spending on computers only.* 13 | 14 | ![](https://github.com/Shreejan-35/EXPENSE-TRACKER/blob/main/res/web.jpg) 15 | 16 | **SO I HAVE THOUGHT OF MAKING AN PYTHON APPLICATION TO KEEP TRACK OF YOUR IMPORTANT EXPENSES. I SAY IT IS A VERY HANDY TOOL.** 17 | 18 | # 🧐ABOUT EXPENSE TRACKER 🎊🎊 19 | - Python application 20 | - Command Line Application but the things are well managed 21 | - User friendly 22 | - Shows detail view of your expenses and also how much money you saved or how much is extra 23 | - Shows the graph view of your expenses 24 | - You can update and delete your expenses 25 | - You can insert new expenses 26 | - Uses database 27 | - currency converter 28 | - Also saves your data online so that you can get access to your expenses from anywhere anytime. 29 | 30 | # GETTING STARTED 🤨🧐 31 | Working with expense tracker is pretty easy, if I don't say also, then also you all will do it. 32 | 33 | - You can seek the help by pressing **H** 34 | - At first, Press **C** to continue or **H** to take help 35 | - Press **1** to load your database or storage 36 | - Press **2** to load your salary 37 | - Press **3** to insert your expenses in the database 38 | - Press **4** to see your expenses with core details 39 | - Press **5** to update your expenses 40 | - Press **6** to delete your expenses 41 | - Press **7** to change your salary 42 | - Press **8** to see your expenses in other currency 43 | - Press **9** to exit or quit 44 | 45 | **Working Remotely** 46 | - Press **L** to login with a specific username and password 47 | - Press **R** to register yourself 48 | - Press **I** to enter the expenses remotely 49 | - Press **D** to delete your expenses 50 | - Press **U** to update a particular expense 51 | - Press **O** to logout 52 | - Press **DEL** to delete your whole account and all other records 53 | 54 | # 😎INSTALLATION ✨🎏 55 | There are two ways of downloading expense tracker in your computer :- 56 | - Git clone 57 | ``` 58 | https://github.com/spyke7/EXPENSE-TRACKER.git 59 | ``` 60 | - Download the zip file 61 | - using pip 62 | 63 | 64 | If you have python installed then first run this command - 65 | ``` 66 | pip install requirements.txt 67 | ``` 68 | After this run - 69 | ``` 70 | python main.py 71 | ``` 72 | OR 73 | ``` 74 | python3 main.py 75 | ``` 76 | 77 | - Using pip 78 | It is on pypi.org 79 | ``` 80 | pip install expense-tracker 81 | ``` 82 | OR 83 | ``` 84 | pip3 install expense-tracker 85 | ``` 86 | 87 | Then run, 88 | ``` 89 | expense-tracker 90 | ``` 91 | 92 | That's all. 93 | Read the instruction carefully on your screen and you will be able to do it.🎉🎉 94 | 95 | # CONTRIBUTION 96 | Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated. 97 | 98 | If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again! 99 | 100 | - Star the repo. 101 | - Raise an issue about the feature so that we can assign. 102 | - Fork the Project 103 | - Create your Feature Branch (git checkout -b ) 104 | - Commit your Changes (git commit -m 'Add some advices') 105 | - Push to the Branch 106 | - Open a Pull Request 107 | 108 | ## LICENSE 109 | MIT License 110 | -------------------------------------------------------------------------------- /src/expense_tracker.egg-info/PKG-INFO: -------------------------------------------------------------------------------- 1 | Metadata-Version: 2.1 2 | Name: expense-tracker 3 | Version: 2.0 4 | Summary: Expense Tracker is a very good tool to keep track of your expenseditures and the total money you saved.🤑🤑 5 | Home-page: https://github.com/CapedDemon/EXPENSE-TRACKER 6 | Author: Shreejan Dolai 7 | Author-email: dolaishreejan@gmail.com 8 | Project-URL: Bug Tracker, https://github.com/CapedDemon/EXPENSE-TRACKER/issues 9 | Keywords: expense,tracker,money,py,expense tracker,expense-tracker,money tracker,money-tracker 10 | Classifier: Programming Language :: Python :: 3 11 | Classifier: License :: OSI Approved :: MIT License 12 | Classifier: Operating System :: OS Independent 13 | Requires-Python: >=3.9 14 | Description-Content-Type: text/markdown 15 | License-File: LICENSE 16 | 17 | # EXPENSE TRACKER 18 | Language 19 | License 20 | [![CodeFactor](https://www.codefactor.io/repository/github/capeddemon/commandconsole/badge)](https://www.codefactor.io/repository/github/capeddemon/commandconsole) 21 | 22 | Expense Tracker is a very good tool to keep track of your expenseditures and the total money you saved.🤑🤑 23 | 24 | We at some point of our life have kept track of our expenses and the money saved. 📃 We all have used the traditional way of keeping our 25 | record by writing our expenses in our **personal diary** 📃 which can be burnt out, the papers might cut into pieces ✂ or the 📜 diary 26 | got so old 🗑 that we need to write our expenses in another diary.🖋🖋 It is very time consuming also.⏳⌚ 27 | 28 | *But it is the most safe way of keeping record. But the time has changed laptops and mobiles are takng over. Most of the time we are spending on computers only.* 29 | 30 | ![](https://github.com/Shreejan-35/EXPENSE-TRACKER/blob/main/res/web.jpg) 31 | 32 | **SO I HAVE THOUGHT OF MAKING AN PYTHON APPLICATION TO KEEP TRACK OF YOUR IMPORTANT EXPENSES. I SAY IT IS A VERY HANDY TOOL.** 33 | 34 | # 🧐ABOUT EXPENSE TRACKER 🎊🎊 35 | - Python application 36 | - Command Line Application but the things are well managed 37 | - User friendly 38 | - Shows detail view of your expenses and also how much money you saved or how much is extra 39 | - Shows the graph view of your expenses 40 | - You can update and delete your expenses 41 | - You can insert new expenses 42 | - Uses database 43 | - currency converter 44 | - Also saves your data online so that you can get access to your expenses from anywhere anytime. 45 | 46 | # GETTING STARTED 🤨🧐 47 | Working with expense tracker is pretty easy, if I don't say also, then also you all will do it. 48 | 49 | - You can seek the help by pressing **H** 50 | - At first, Press **C** to continue or **H** to take help 51 | - Press **1** to load your database or storage 52 | - Press **2** to load your salary 53 | - Press **3** to insert your expenses in the database 54 | - Press **4** to see your expenses with core details 55 | - Press **5** to update your expenses 56 | - Press **6** to delete your expenses 57 | - Press **7** to change your salary 58 | - Press **8** to see your expenses in other currency 59 | - Press **9** to exit or quit 60 | 61 | **Working Remotely** 62 | - Press **L** to login with a specific username and password 63 | - Press **R** to register yourself 64 | - Press **I** to enter the expenses remotely 65 | - Press **D** to delete your expenses 66 | - Press **U** to update a particular expense 67 | - Press **O** to logout 68 | - Press **DEL** to delete your whole account and all other records 69 | 70 | # 😎INSTALLATION ✨🎏 71 | There are two ways of downloading expense tracker in your computer :- 72 | - Git clone 73 | ``` 74 | git clone https://github.com/CapedDemon/EXPENSE-TRACKER.git 75 | ``` 76 | - Download the zip file 77 | - using pip 78 | 79 | 80 | If you have python installed then first run this command - 81 | ``` 82 | pip install requirements.txt 83 | ``` 84 | After this run - 85 | ``` 86 | python main.py 87 | ``` 88 | OR 89 | ``` 90 | python3 main.py 91 | ``` 92 | 93 | - Using pip 94 | It is on pypi.org 95 | ``` 96 | pip install expense-tracker 97 | ``` 98 | OR 99 | ``` 100 | pip3 install expense-tracker 101 | ``` 102 | 103 | Then run, 104 | ``` 105 | expense-tracker 106 | ``` 107 | 108 | That's all. 109 | Read the instruction carefully on your screen and you will be able to do it.🎉🎉 110 | 111 | # CONTRIBUTION 112 | Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated. 113 | 114 | If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again! 115 | 116 | - Star the repo. 117 | - Raise an issue about the feature so that we can assign. 118 | - Fork the Project 119 | - Create your Feature Branch (git checkout -b ) 120 | - Commit your Changes (git commit -m 'Add some advices') 121 | - Push to the Branch 122 | - Open a Pull Request 123 | 124 | ## LICENSE 125 | MIT License 126 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, religion, or sexual identity 10 | and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | * Demonstrating empathy and kindness toward other people 21 | * Being respectful of differing opinions, viewpoints, and experiences 22 | * Giving and gracefully accepting constructive feedback 23 | * Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | * Focusing on what is best not just for us as individuals, but for the 26 | overall community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | * The use of sexualized language or imagery, and sexual attention or 31 | advances of any kind 32 | * Trolling, insulting or derogatory comments, and personal or political attacks 33 | * Public or private harassment 34 | * Publishing others' private information, such as a physical or email 35 | address, without their explicit permission 36 | * Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at 63 | dolaishreejan@gmail.com. 64 | All complaints will be reviewed and investigated promptly and fairly. 65 | 66 | All community leaders are obligated to respect the privacy and security of the 67 | reporter of any incident. 68 | 69 | ## Enforcement Guidelines 70 | 71 | Community leaders will follow these Community Impact Guidelines in determining 72 | the consequences for any action they deem in violation of this Code of Conduct: 73 | 74 | ### 1. Correction 75 | 76 | **Community Impact**: Use of inappropriate language or other behavior deemed 77 | unprofessional or unwelcome in the community. 78 | 79 | **Consequence**: A private, written warning from community leaders, providing 80 | clarity around the nature of the violation and an explanation of why the 81 | behavior was inappropriate. A public apology may be requested. 82 | 83 | ### 2. Warning 84 | 85 | **Community Impact**: A violation through a single incident or series 86 | of actions. 87 | 88 | **Consequence**: A warning with consequences for continued behavior. No 89 | interaction with the people involved, including unsolicited interaction with 90 | those enforcing the Code of Conduct, for a specified period of time. This 91 | includes avoiding interactions in community spaces as well as external channels 92 | like social media. Violating these terms may lead to a temporary or 93 | permanent ban. 94 | 95 | ### 3. Temporary Ban 96 | 97 | **Community Impact**: A serious violation of community standards, including 98 | sustained inappropriate behavior. 99 | 100 | **Consequence**: A temporary ban from any sort of interaction or public 101 | communication with the community for a specified period of time. No public or 102 | private interaction with the people involved, including unsolicited interaction 103 | with those enforcing the Code of Conduct, is allowed during this period. 104 | Violating these terms may lead to a permanent ban. 105 | 106 | ### 4. Permanent Ban 107 | 108 | **Community Impact**: Demonstrating a pattern of violation of community 109 | standards, including sustained inappropriate behavior, harassment of an 110 | individual, or aggression toward or disparagement of classes of individuals. 111 | 112 | **Consequence**: A permanent ban from any sort of public interaction within 113 | the community. 114 | 115 | ## Attribution 116 | 117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 118 | version 2.0, available at 119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 120 | 121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct 122 | enforcement ladder](https://github.com/mozilla/diversity). 123 | 124 | [homepage]: https://www.contributor-covenant.org 125 | 126 | For answers to common questions about this code of conduct, see the FAQ at 127 | https://www.contributor-covenant.org/faq. Translations are available at 128 | https://www.contributor-covenant.org/translations. 129 | -------------------------------------------------------------------------------- /src/expense_tracker/app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, request, jsonify, render_template 2 | from flask_sqlalchemy import SQLAlchemy 3 | import os 4 | 5 | app = Flask(__name__) 6 | 7 | # I have kept the DATABASE_URL in .env file 8 | # it is gitignored for safety issues 9 | app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv('DATABASE_URL') 10 | 11 | db = SQLAlchemy(app) 12 | 13 | # The user model 14 | # consits only id, username and password 15 | class User(db.Model): 16 | id = db.Column(db.Integer, primary_key=True) 17 | username = db.Column(db.String(80), unique=True, nullable=False) 18 | password = db.Column(db.String(120), nullable=False) 19 | 20 | def __repr__(self): 21 | return '' % self.username 22 | 23 | # Define a Expenses model with the fields 'expense', 'expenditure', and 'date' 24 | class Expenses(db.Model): 25 | id = db.Column(db.Integer, primary_key=True) 26 | username = db.Column(db.String(80), nullable=False) 27 | expense = db.Column(db.String(255), nullable=False) 28 | expenditure = db.Column(db.String(255), nullable=False) 29 | date = db.Column(db.String(30), nullable=False) 30 | 31 | # register route 32 | @app.route('/register', methods=['POST']) 33 | def register(): 34 | if request.is_json: 35 | data = request.get_json() 36 | 37 | if User.query.filter_by(username=data['username']).first(): 38 | return jsonify({'message': 'User with this username already exists! Try Again'}) 39 | 40 | else: 41 | newUser = User(username=data['username'], password=data['password']) 42 | db.session.add(newUser) 43 | db.session.commit() 44 | return {"message": f"User {newUser.username} has been registered successfully."} 45 | else: 46 | return {"message": "The request payload is not in JSON format"} 47 | 48 | # login route 49 | @app.route("/login", methods=["POST"]) 50 | def login(): 51 | if request.is_json: 52 | data = request.get_json() 53 | user = User.query.filter_by(username=data['username'], password=data['password']).first() 54 | 55 | if user: 56 | return jsonify({'message': 'Access Granted'}), 200 57 | else: 58 | return jsonify({'message': 'Access Denied'}), 400 59 | 60 | else: 61 | return {"message": "The request payload is not in JSON format"} 62 | 63 | # route to create the expenses in the expense table 64 | @app.route('/createExpenses', methods=['POST']) 65 | def createExpenses(): 66 | if request.is_json: 67 | expensesData = request.get_json() 68 | if 'expense' not in expensesData or 'expenditure' not in expensesData or 'date' not in expensesData: 69 | return jsonify({'error': 'Missing fields'}) 70 | else: 71 | newExpense = Expenses(username=expensesData["username"], expense=expensesData["expense"], expenditure=expensesData["expenditure"], date=expensesData["date"]) 72 | db.session.add(newExpense) 73 | db.session.commit() 74 | 75 | return jsonify({'message': 'Expense created successfully'}), 200 76 | 77 | else: 78 | return {"message": "The request payload is not in JSON format"} 79 | 80 | # route to get the expenses 81 | @app.route('/showExpenses', methods=['POST','GET']) 82 | def getExpenses(): 83 | if request.is_json: 84 | data = request.get_json() 85 | expenses = Expenses.query.filter_by(username=data["username"]).all() 86 | 87 | expenseList = [] 88 | for expense in expenses: 89 | expenseDict = {'expense': expense.expense, 'expenditure': expense.expenditure, 'date': expense.date} 90 | expenseList.append(expenseDict) 91 | 92 | return jsonify({'expenses': expenseList}), 200 93 | 94 | else: 95 | return {"message": "The request payload is not in JSON format"} 96 | 97 | # route to delete the expenses 98 | @app.route('/deleteExpenses', methods=['POST']) 99 | def delExpenses(): 100 | if request.is_json: 101 | data = request.get_json() 102 | if data["identification1"] == "expense": 103 | if data["identification2"] == "expenditure": 104 | result = Expenses.query.filter_by(username=data["username"], expenditure=data["value2"], expense=data["value1"]).delete() 105 | 106 | if data['identification2'] == "date": 107 | result = Expenses.query.filter_by(username=data["username"], date=data["value2"], expense=data["value1"]).delete() 108 | 109 | elif data["identification1"] == "expenditure": 110 | if data["identification2"] == "expense": 111 | result = Expenses.query.filter_by(username=data["username"], expenditure=data["value1"], expense=data["value2"]).delete() 112 | 113 | if data['identification2'] == "date": 114 | result = Expenses.query.filter_by(username=data["username"], date=data["value2"], expenditure=data["value1"]).delete() 115 | 116 | if data["identification1"] == "date": 117 | if data["identification2"] == "expenditure": 118 | result = Expenses.query.filter_by(username=data["username"], expenditure=data["value2"], date=data["value1"]).delete() 119 | 120 | if data['identification2'] == "expense": 121 | result = Expenses.query.filter_by(username=data["username"], date=data["value1"], expense=data["value2"]).delete() 122 | 123 | if result: 124 | db.session.commit() 125 | return jsonify({'message': 'Successfully deleted'}), 200 126 | else: 127 | return jsonify({'message': 'Could not delete'}) 128 | 129 | else: 130 | return {"message": "The request payload is not in JSON format"} 131 | 132 | 133 | # route for updating the records 134 | @app.route("/updateExpenses", methods=["POST"]) 135 | def updateExpense(): 136 | if request.is_json: 137 | data = request.get_json() 138 | if data["identification"] == "expense": 139 | if data["changed"] == "expenditure": 140 | updated = Expenses.query.filter_by(username=data["username"], expense=data["value"]).update(dict(expenditure=data["changedValue"])) 141 | if data["changed"] == "date": 142 | updated = Expenses.query.filter_by(username=data["username"], expense=data["value"]).update(dict(date=data["changedValue"])) 143 | 144 | elif data["identification"] == "data": 145 | if data["changed"] == "expenditure": 146 | updated = Expenses.query.filter_by(username=data["username"], date=data["value"]).update(dict(expenditure=data["changedValue"])) 147 | if data["changed"] == "expense": 148 | updated = Expenses.query.filter_by(username=data["username"], date=data["value"]).update(dict(expense=data["changedValue"])) 149 | 150 | elif data["identification"] == "expenditure": 151 | if data["changed"] == "expenditure": 152 | updated = Expenses.query.filter_by(username=data["username"], expenditure=data["value"]).update(dict(expense=data["changedValue"])) 153 | if data["changed"] == "date": 154 | updated = Expenses.query.filter_by(username=data["username"], expenditure=data["value"]).update(dict(date=data["changedValue"])) 155 | 156 | if updated: 157 | db.session.commit() 158 | return jsonify({'message': 'Successfully updated'}), 200 159 | else: 160 | return jsonify({'message': 'Could not be updated'}) 161 | 162 | else: 163 | return {"message": "The request payload is not in JSON format"} 164 | 165 | # deleting your whole account 166 | @app.route("/deleteAccount", methods=["POST", "GET"]) 167 | def delAccount(): 168 | if request.is_json: 169 | data = request.get_json() 170 | userExpense = Expenses.query.filter_by(username=data['username']).first() 171 | 172 | if userExpense: 173 | deleteExpense = Expenses.query.filter_by(username=data["username"]).delete() 174 | 175 | if deleteExpense: 176 | db.session.commit() 177 | 178 | else: 179 | delUser = User.query.filter_by(username=data["username"]).delete() 180 | 181 | if delUser: 182 | db.session.commit() 183 | return jsonify({'message': 'Successfully loggedout', 'del':delUser}), 200 184 | else: 185 | return jsonify({'message': 'Could not delete account', 'del':delUser}) 186 | 187 | else: 188 | return {"message": "The request payload is not in JSON format"} 189 | 190 | 191 | @app.route("/") 192 | def home(): 193 | return render_template("index.html") 194 | 195 | if __name__ == '__main__': 196 | # db.drop_all() 197 | db.create_all() 198 | app.run(host = "0.0.0.0", debug=True) -------------------------------------------------------------------------------- /src/expense_tracker/remotefunc.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import json 3 | import matplotlib.pyplot as plt 4 | import hashlib 5 | 6 | class RemoteFunc: 7 | loginUsername = None 8 | loginPassword = None 9 | loggedIn = False 10 | 11 | url = 'https://expense-tracker-itg5.onrender.com/' 12 | headers = {'Content-type': 'application/json'} 13 | 14 | def __init__(self): 15 | print("Initialized the remote...") 16 | 17 | #hashing the passwords 18 | def enCrypt(self, userPassword): 19 | bytesPassword = userPassword.encode('utf-8') # converting password to array of bytes 20 | 21 | #hashing it 22 | hash_object = hashlib.sha256(bytesPassword) 23 | hex_dig = hash_object.hexdigest() 24 | 25 | 26 | return hex_dig 27 | 28 | #register 29 | def Register(self): 30 | if self.loggedIn == False: 31 | try: 32 | newUsername = input("Username: ") 33 | newPassword = input("Password: ") 34 | 35 | if len(newUsername) > 80 or len(newPassword) > 120: 36 | print("Sorry length exceeded") 37 | 38 | else: 39 | #hashing 40 | password = self.enCrypt(newPassword) 41 | 42 | # data to be registered 43 | data = {'username': newUsername, 'password': password} 44 | 45 | # response 46 | response = requests.post(self.url+"register", data=json.dumps(data), headers=self.headers) 47 | 48 | print(response.json()['message']) 49 | 50 | except: 51 | print("Could not perform the task. Try again later - see for good internet connection") 52 | 53 | else: 54 | print("First log out") 55 | 56 | #login 57 | def Login(self): 58 | if self.loggedIn == True: 59 | print("You are already logged in. Press 'O' to logout..") 60 | 61 | else: 62 | try: 63 | userName = input("Username: ") 64 | loginPassword = input("Password: ") 65 | 66 | password = self.enCrypt(loginPassword) 67 | 68 | data = {'username': userName, "password": password} 69 | 70 | #response 71 | response = requests.post(self.url+"login", data=json.dumps(data), headers=self.headers) 72 | 73 | if response.status_code == 200: 74 | self.loggedIn = True 75 | 76 | self.loginUsername = userName 77 | self.loginPassword = loginPassword 78 | 79 | print(response.json()['message']) 80 | 81 | except: 82 | print("Could not perform the task. Try again later - see for good internet connection") 83 | 84 | #logout 85 | def Logout(self): 86 | if self.loggedIn == True: 87 | self.loggedIn = False 88 | self.loginUsername = None 89 | self.loginPassword = None 90 | print("Logged Out..") 91 | 92 | else: 93 | print("You are not logged in") 94 | 95 | #inserting expenses into expense table in database remotely 96 | def InsertExpenses(self): 97 | if self.loggedIn == False: 98 | print("Please login first..") 99 | 100 | else: 101 | try: 102 | entry = True 103 | while entry: 104 | 105 | expense = input( 106 | "PUT THE NAME OF YOUR EXPENDITURE OR FOR WHAT THING YOU HAVE SPENT YOUR MONEY: ") 107 | expenditure = input("HOW MUCH YOU HAVE SPENT ? (without commas - 34000000 - 34 million/3 crore 40 lakhs): ") 108 | date = input( 109 | "Put the date when you spend your money (Format = dd/mm/yyyy): ") 110 | 111 | expenseData = {'username':self.loginUsername, 'expense':expense, 'expenditure':expenditure, "date":date} 112 | 113 | #response 114 | response = requests.post(self.url+"createExpenses", data=json.dumps(expenseData), headers=self.headers) 115 | print(response.json()['message']) 116 | 117 | entryChoice = input( 118 | "DO YOU STILL WANT TO ENTER DATA. TYPE 'Y' IF YOU WANT TO AND 'N' IF YOU WANT TO STOP: ").upper() 119 | if entryChoice == 'N': 120 | entry = False 121 | 122 | except: 123 | print("Could not perform the task. Try again later - see for good internet connection") 124 | 125 | # showing the data 126 | def ShowExpenses(self): 127 | if self.loggedIn == False: 128 | print("Please login first..") 129 | 130 | else: 131 | try: 132 | data = {'username':self.loginUsername} 133 | 134 | #response 135 | response = requests.post(self.url+"showExpenses", data=json.dumps(data), headers=self.headers) 136 | 137 | if response == 404: 138 | print("Username not found. An error occured. Please try again") 139 | 140 | else: 141 | print(response.json()) 142 | moneySpend = 0 143 | index = 1 144 | x_axis = [] 145 | y_axis = [] 146 | 147 | #expense data 148 | expense = response.json() 149 | 150 | print('S.no Reason/Expense/Service Expenditure Date\n') 151 | 152 | for x in expense["expenses"]: 153 | print(str(index) + '. ' + x["expense"] + ' -> ' + x["expenditure"] + ' -> ' + x["date"]) 154 | moneySpend += int(x["expenditure"]) 155 | x_axis.append(x["expense"]) 156 | y_axis.append(int(x["expenditure"])) 157 | index += 1 158 | 159 | print(f"TOTAL MONEY SPEND = {moneySpend}") 160 | 161 | # giving more assistance to the user by showing graph 162 | # each bar represent the amount of money in each object 163 | 164 | graphChoice = input("Do you want to see the graph(Y/N) - ").upper() 165 | if graphChoice == 'Y': 166 | plt.bar(x_axis, y_axis, width=0.3) 167 | plt.title("Expense View") 168 | plt.xlabel("<- Expense Name ->") 169 | plt.ylabel("<- Expenditures ->") 170 | plt.show() 171 | 172 | except: 173 | print("Could not perform the task. Try again later - see for good internet connection") 174 | 175 | # deleting the data 176 | def deleteExpense(self): 177 | if self.loggedIn == False: 178 | print("Please login first..") 179 | 180 | else: 181 | try: 182 | print("Deleting means you will delete the whole one record. Suppose you give an identification for deletion as date then the whole row where the date \nalong with expense, expenditure will be deleted\n") 183 | identification1 = input("Enter one identity for deleting the record(expense, expenditure, date): ").lower() 184 | valueid1 = input("Enter the value of the identity: ") 185 | 186 | identification2 = input( 187 | "Enter another identity for deleting the record(expense, expenditure, date) [This need to be not same as the previous input given]: ").lower() 188 | valueid2 = input("Enter the value of the identity: ") 189 | 190 | # identifications send as json 191 | data = {'username':self.loginUsername, 'identification1': identification1, "identification2":identification2, 'value1':valueid1, 'value2':valueid2} 192 | 193 | #response 194 | response = requests.post(self.url+"deleteExpenses", data=json.dumps(data), headers=self.headers) 195 | 196 | print(response.json()['message']) 197 | 198 | except: 199 | print("Could not perform the task. Try again later - see for good internet connection") 200 | 201 | # updating the records 202 | def updateExpense(self): 203 | if self.loggedIn == False: 204 | print("Please login first..") 205 | 206 | else: 207 | try: 208 | print("Updating means that the record with some identification will be updated or all the records with the same identity will be updated\n ") 209 | identification = input("Enter one identity for updating the record - should be different for the value to be changed (expense, expenditure, date): ").lower() 210 | value = input("Enter the value of the identity: ") 211 | 212 | toChange = input("Enter what field to be changed (expense, expenditure, date): ").lower() 213 | valueChanged = input("Enter the value: ") 214 | 215 | data = {'username':self.loginUsername, "identification":identification, "value":value, "changed":toChange, "changedValue":valueChanged} 216 | 217 | #response 218 | response = requests.post(self.url+"updateExpenses", data=json.dumps(data), headers=self.headers) 219 | 220 | print(response.json()["message"]) 221 | 222 | except: 223 | print("Could not perform the task. Try again later - see for good internet connection") 224 | 225 | 226 | # deleting the whole account 227 | def delAccount(self): 228 | if self.loggedIn == False: 229 | print("Please login first..") 230 | 231 | else: 232 | try: 233 | print("Are you sure ? (Y/N)") 234 | decision = input(":").upper() 235 | 236 | if decision == "Y": 237 | data = {'username':self.loginUsername} 238 | 239 | #response 240 | response = requests.post(self.url+"deleteAccount", data=json.dumps(data), headers=self.headers) 241 | 242 | print(response.json()["message"]) 243 | if (response.status_code == 200): 244 | self.loggedIn = False 245 | self.loginUsername=None 246 | self.loginPassword=None 247 | 248 | else: 249 | print("OK") 250 | 251 | except: 252 | print("Could not perform the task. Try again later - see for good internet connection") -------------------------------------------------------------------------------- /src/expense_tracker/expensetrackerclass.py: -------------------------------------------------------------------------------- 1 | # importing the required libraries 2 | import sqlite3 3 | import os 4 | import matplotlib.pyplot as plt 5 | from requests import get 6 | from pprint import PrettyPrinter 7 | import remotefunc 8 | 9 | class ExpenseTracker: 10 | 11 | __salary = 0 12 | 13 | 14 | def __init__(self): 15 | print(""" 16 | INITIALISED EXPENSE TRACKER 17 | track your expenses 18 | __ 19 | __|__ __ | | 20 | " | __ | | | | 21 | "--|-- __ | | | | | | 22 | | " | | | | | | | | 23 | ---|--" |__| |__| |__| |__| 24 | 25 | 26 | """) 27 | self.remote = remotefunc.RemoteFunc() 28 | print('WELCOME TO EXPENSE TRACKER. HERE YOU CAN STORE YOUR EXPENSES AND KEEP A TRACK OF THEM.\n\t\t\t\tPress H for help\n') 29 | 30 | 31 | # function that shows the user 32 | # the list of commands he/she can use 33 | def helpGuide(self): 34 | print(""" 35 | HELP GUIDE 36 | TAKE HELP ANYTIME YOU NEED 37 | CONTACT - dolaishreejan@gmail.com 38 | 39 | This Guide is for local 40 | management of expenses 41 | 42 | 1. First, press 1 to load or create your database 43 | 2. Press 2 to load your salary 44 | 3. Press 7 to change your salary 45 | 4. Press 3 to insert expenses - the reason you are inserting, 46 | amount, date 47 | 5. Press 4 to see the expenses with core details 48 | 6. Press 5 to update your expenses 49 | 7. Press 6 to delete your expenses 50 | 8. Press 8 to see your expenses with other currency 51 | 9. To see the help guide press H 52 | 53 | 54 | 55 | For Remote Management - 56 | 57 | A. If you have already have login username and password, login 58 | using it by pressing "L" 59 | B. To register press "R" 60 | C. To insert data remotely - "I" 61 | D. To delete - "D" 62 | E. To update - "U" 63 | F. To get records - "S" 64 | G. To logout - "O" 65 | H. To delete your account and other expenses - "DEL" 66 | 67 | Press "Q" for quitting the program 68 | """) 69 | 70 | def createDB(self): 71 | #creating the database 72 | createdb = input("Create new database (C) | Work with previous database (P) - ").upper() 73 | name = input("Enter the name of your database (Expense.db, mongo.db, etc) - ")# seeking name 74 | if createdb == 'C': 75 | self.conn = sqlite3.connect(name) 76 | self.cur = self.conn.cursor() 77 | 78 | elif createdb == 'P': 79 | self.conn = sqlite3.connect(name) 80 | self.cur = self.conn.cursor() 81 | 82 | # making the table 83 | self.cur.execute(""" 84 | CREATE TABLE IF NOT EXISTS expenses (expense TEXT, expenditure TEXT, idate TEXT) 85 | """) 86 | 87 | self.conn.commit() 88 | 89 | def salaryWork(self): 90 | # working with salary 91 | salaryChoice = input("Enter new salary (E) | Load your salary (L) - ").upper() 92 | 93 | if salaryChoice == 'E': 94 | salaryFile = input("Enter the path of the file where your salary will be saved (Ex- salary.txt) - ") 95 | self.salary = input("Enter your salary - ") 96 | with open(salaryFile, 'w') as f: 97 | f.write(self.salary) 98 | f.close() 99 | 100 | elif salaryChoice == 'L': 101 | salaryFile = input( 102 | "Enter the path of the file where your salary is saved (Ex- salary.txt) - ") 103 | 104 | if (os.path.getsize(salaryFile)) == 0: 105 | self.salary = input("Your salary file is empty. Put your salary - ") 106 | with open(salaryFile, 'w') as f: 107 | f.write(self.salary) 108 | f.close() 109 | else: 110 | with open(salaryFile, 'r') as f: 111 | self.salary = f.read() 112 | f.close() 113 | 114 | print("SALARY LOADED\n") 115 | 116 | def insertDB(self): 117 | # entry of data loop 118 | entry = True 119 | while entry: 120 | 121 | expense = input( 122 | "PUT THE NAME OF YOUR EXPENDITURE OR FOR WHAT THING YOU HAVE SPENT YOUR MONEY: ") 123 | expenditure = input("HOW MUCH YOU HAVE SPENT ?: ") 124 | date = input( 125 | "Put the date when you spend your money (Format = dd/mm/yyyy): ") 126 | 127 | self.cur.execute(""" 128 | INSERT INTO expenses (expense, expenditure, idate) VALUES (?, ?, ?)""", (expense, expenditure, date)) 129 | self.conn.commit() 130 | 131 | entryChoice = input( 132 | "DO YOU STILL WANT TO ENTER DATA. TYPE 'Y' IF YOU WANT TO AND 'N' IF YOU WANT TO STOP: ").upper() 133 | if entryChoice == 'N': 134 | entry = False 135 | 136 | def changeSalary(self): 137 | # changing the salary 138 | salaryFile = input( 139 | "Enter the path of the file where your salary will be saved (Ex- salary.txt) - ") 140 | self.salary = input("Enter your new salary: ") 141 | with open(salaryFile, "w") as f: 142 | f.write(self.salary) 143 | 144 | f.close() 145 | print("SALARY CHANGED\n") 146 | 147 | def showDB(self): 148 | # showing the expenses with core details 149 | print(20 * '*') 150 | print("Your expenses are as follows:- \n\n") 151 | recieveData = self.cur.execute(""" 152 | SELECT * FROM expenses 153 | """) 154 | 155 | # printing the expenditure and calculating the total expenditure and stroing the data in lists for plotting the graph 156 | totalExpenditureSum = 0 157 | index = 1 158 | x_axis = [] 159 | y_axis = [] 160 | print('S.no Reason/Expense/Service Expenditure Date\n') 161 | for x in recieveData: 162 | print(str(index) + '. ' + x[0] + ' -> ' + x[1] + ' -> ' + x[2]) 163 | totalExpenditureSum = totalExpenditureSum + int(x[1]) 164 | index += 1 165 | x_axis.append(x[0]) 166 | y_axis.append(int(x[1])) 167 | 168 | print('\n') 169 | 170 | # printing the total salary and total money saved or extra spend 171 | if self.salary != 0: 172 | print("Total salary = " + (self.salary)) 173 | if totalExpenditureSum <= int(self.salary): 174 | print("Money Saved = " + str(int(self.salary) - totalExpenditureSum)) 175 | else: 176 | print("Extra Money Spend = " + str(totalExpenditureSum - int(self.salary))) 177 | 178 | print(20 * '*') 179 | print('\n') 180 | print("(See the graph for more clear vision of your expense.)") 181 | 182 | # plotting th graph 183 | # This is a bar graph 184 | # In the x-axis there are the names or the reasons of your expense 185 | # In the y-axis there are the values of the expense 186 | # The title of the graph is 'Expense View' 187 | graphChoice = input("Do you want to see the graph(Y/N) - ").upper() 188 | if graphChoice == 'Y': 189 | plt.bar(x_axis, y_axis, width=0.3) 190 | plt.title("Expense View") 191 | plt.xlabel("<- Expense Name ->") 192 | plt.ylabel("<- Expenditures ->") 193 | plt.show() 194 | 195 | #updating the expenses 196 | def updateDB(self): 197 | print("i. You need to first give which thing to change.\n") 198 | print("ii. You then need to specify for which rowid or date or expense reason or expenditure you need to change and give its value\n\n") 199 | 200 | changeValue = input( 201 | "Enter the value which you want to change (expense - For changing the expense reason, expenditure - For changing the expenditure or the amount, date - For changing the date) - ") 202 | newvalue = input("Enter the new value: ") 203 | changeValueID = input( 204 | "Enter any one of the value as an identification for changing the value which you give before it(expense, expenditure, date)- ") 205 | idvalue = input("Enter the value of the identification - ") 206 | 207 | if changeValue == "expense": 208 | if changeValueID == "expenditure": 209 | self.cur.execute( 210 | """UPDATE expenses SET expense = ? where expenditure = ?""", (newvalue, idvalue)) 211 | 212 | elif changeValueID == "date": 213 | self.cur.execute( 214 | """UPDATE expenses SET expense = ? where idate = ?""", (newvalue, idvalue)) 215 | 216 | elif changeValue == "expenditure": 217 | if changeValueID == "expense": 218 | self.cur.execute( 219 | """UPDATE expenses SET expenditure = ? where expense = ?""", (newvalue, idvalue)) 220 | 221 | elif changeValueID == "date": 222 | self.cur.execute( 223 | """UPDATE expenses SET expenditure = ? where idate = ?""", (newvalue, idvalue)) 224 | 225 | elif changeValue == "date": 226 | if changeValueID == "expenditure": 227 | self.cur.execute( 228 | """UPDATE expenses SET idate = ? where expenditure = ?""", (newvalue, idvalue)) 229 | 230 | elif changeValueID == "expense": 231 | self.cur.execute( 232 | """UPDATE expenses SET idate = ? where expense = ?""", (newvalue, idvalue)) 233 | 234 | self.conn.commit() 235 | 236 | # deleting the expenses 237 | def deleteDB(self): 238 | print("Deleting means you will delete the whole one record. Suppose you give an identification for deletion as date then the whole row where the date \nalong with expense, expenditure will be deleted\n") 239 | identification1 = input("Enter one identity for deleting the record(expense, expenditure, date): ").lower() 240 | valueid1 = input("Enter the value of the identity: ") 241 | 242 | identification2 = input( 243 | "Enter another identity for deleting the record(expense, expenditure, date) [This need to be not same as the previous input given]: ").lower() 244 | valueid2 = input("Enter the value of the identity: ") 245 | 246 | if identification1 == "expense": 247 | if identification2 == "expenditure": 248 | self.cur.execute( 249 | """DELETE from expenses where expense = ? AND expenditure = ?""", (valueid1,valueid2)) 250 | 251 | elif identification2 == "date": 252 | self.cur.execute( 253 | """DELETE from expenses where expense = ? AND idate = ?""", (valueid1,valueid2)) 254 | 255 | elif identification1 == "expenditure": 256 | if identification2 == "expense": 257 | self.cur.execute( 258 | """DELETE from expenses where expenditure = ? AND expense = ?""", (valueid1, valueid2)) 259 | 260 | elif identification2 == "date": 261 | self.cur.execute( 262 | """DELETE from expenses where expenditure = ? AND idate = ?""", (valueid1, valueid2)) 263 | 264 | elif identification1 == "date": 265 | if identification2 == "expense": 266 | self.cur.execute( 267 | """DELETE from expenses where idate = ? AND expense = ?""", (valueid1, valueid2)) 268 | 269 | elif identification2 == "expenditure": 270 | self.cur.execute( 271 | """DELETE from expenses where idate = ? AND expenditure = ?""", (valueid1, valueid2)) 272 | self.conn.commit() 273 | 274 | # currency converter 275 | def currencyConverter(self): 276 | 277 | #base url 278 | BASE_URL = "https://free.currconv.com/" 279 | API_KEY = "9ed7b0de375985de7037" 280 | 281 | printer = PrettyPrinter() 282 | 283 | endpoint = f"api/v7/currencies?apiKey={API_KEY}" 284 | url = BASE_URL + endpoint 285 | data = get(url).json()['results'] 286 | 287 | data = list(data.items()) 288 | data.sort() 289 | 290 | print("THESE ARE THE LIST OF CURRENCY - \n") 291 | 292 | for name, currency in data: 293 | name = currency['currencyName'] 294 | _id = currency['id'] 295 | symbol = currency.get("currencySymbol", "") 296 | print(f"{_id} - {name} - {symbol}") 297 | 298 | print("\n") 299 | conchoice = input("Do you want to change currency (y/n) - ") 300 | 301 | if conchoice == 'n': 302 | print("BYE\n") 303 | 304 | else: 305 | curr1 = input("Enter the base currency - ").upper() 306 | curr2 = input("Enter a currency to convert to: - ").upper() 307 | 308 | endpoint = f"api/v7/convert?q={curr1}_{curr2}&compact=ultra&apiKey={API_KEY}" 309 | url = BASE_URL + endpoint 310 | data = get(url).json() 311 | 312 | if len(data) == 0: 313 | print('Invalid currencies.\n') 314 | 315 | else: 316 | rate = list(data.values())[0] 317 | print(f"{curr1} -> {curr2} = {rate}\n") 318 | 319 | recieveData = self.cur.execute(""" 320 | SELECT * FROM expenses 321 | """) 322 | 323 | print("Your expenses after the conversion - \n") 324 | index = 1 325 | for x in recieveData: 326 | print(str(index) + '. ' + curr1 + " " + x[1] + " converted -> " + curr2 + " " + str(rate*int(x[1]))) 327 | 328 | print("\n\n") 329 | 330 | 331 | # function to load functions 332 | def loadFunc(self): 333 | self.FunctionMaps = { 334 | #offline 335 | "1": self.createDB, 336 | "2": self.salaryWork, 337 | "3": self.insertDB, 338 | "4": self.showDB, 339 | "5": self.updateDB, 340 | "6": self.deleteDB, 341 | "7": self.changeSalary, 342 | "8": self.currencyConverter, 343 | "H": self.helpGuide, 344 | 345 | #online 346 | "R": self.remote.Register, 347 | "L": self.remote.Login, 348 | "O": self.remote.Logout, 349 | "I": self.remote.InsertExpenses, 350 | "S": self.remote.ShowExpenses, 351 | "D": self.remote.deleteExpense, 352 | "U": self.remote.updateExpense, 353 | "DEL": self.remote.delAccount 354 | } 355 | 356 | # assign users's command to function 357 | def assignFunc(self): 358 | if (self.command not in self.FunctionMaps): 359 | print("Give write command\n") 360 | else : 361 | self.FunctionMaps[self.command]() 362 | 363 | # the function that takes user input 364 | def takeCommand(self): 365 | self.command = input("expense-tracker $: "); 366 | 367 | while self.command != "Q": 368 | if (self.command == "Q"): 369 | print("Bye\n") 370 | break 371 | self.assignFunc() 372 | self.command = input("expense-tracker $: ") --------------------------------------------------------------------------------