├── .gitattributes ├── .github └── workflows │ └── manual.yml ├── Menu.txt ├── README.md ├── flow of control └── invoice flow of control.png ├── invoice generator.py └── requirements.txt /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.github/workflows/manual.yml: -------------------------------------------------------------------------------- 1 | name: Update Contributors 2 | 3 | on: 4 | pull_request: 5 | types: 6 | - closed 7 | 8 | jobs: 9 | update-contributors: 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - name: Checkout repository 14 | uses: actions/checkout@v2 15 | 16 | - name: Update Contributors 17 | run: | 18 | # Extract the contributors from the merged PR 19 | CONTRIBUTORS=$(git log --format="%aN" ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.merge_commit_sha }} | sort | uniq) 20 | 21 | # Generate the updated contributors section 22 | CONTRIBUTORS_SECTION="## Contributors\n\n" 23 | CONTRIBUTORS_SECTION+="| Contributor |\n" 24 | CONTRIBUTORS_SECTION+="| ----------- |\n" 25 | for contributor in $CONTRIBUTORS; do 26 | CONTRIBUTORS_SECTION+="| $contributor |\n" 27 | done 28 | 29 | # Replace the existing contributors section in the README 30 | sed -i -e '/## Contributors/,/^$/c\'"$CONTRIBUTORS_SECTION" README.md 31 | 32 | # Commit and push the changes 33 | git config user.name "${{ github.actor }}" 34 | git config user.email "${{ github.actor }}@users.noreply.github.com" 35 | git commit -am "Update contributors [skip ci]" 36 | git push 37 | 38 | - name: Create Pull Request 39 | uses: peter-evans/create-pull-request@v3 40 | with: 41 | token: ${{ secrets.GITHUB_TOKEN }} 42 | commit-message: Update contributors section 43 | branch: update-contributors 44 | title: Update contributors section 45 | body: This PR updates the contributors section in the README file. 46 | -------------------------------------------------------------------------------- /Menu.txt: -------------------------------------------------------------------------------- 1 | 1, Margherita, 75 2 | 2, Double cheese Margherita, 130 3 | 3, Pepper, 175 4 | 4, Cheese & Barbeque Chicken, 130 5 | 5, Veg Extravaganza, 210 6 | 6, Meatza, 245 7 | 7, Veg singles, 170 8 | 8, Chochlate lava cake, 160 9 | 9, mogumogu, 80 10 | 10, coke, 50 11 | 11, mazza ,25 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Invoice-generator-python 2 | 3 | - A simple python program used to print invoices with some features: 4 | - automatic calculation 5 | - nice output 6 | - intuitive procedure 7 | ___ 8 | ## Dependencies 9 | 10 | - pyfiglet : The ASCII text can be used to display many stylish texts by using the module pyfiglet. ![coderatul pyfiglet git main commit ](https://user-images.githubusercontent.com/72141859/116881225-fcfef480-abf0-11eb-92af-55bdf8825d1b.png) 11 | 12 | - PrettyTable : PrettyTable is a Python library for generating simple ASCII tables. It was inspired by the ASCII tables used in the PostgreSQL shell psql. We can control many aspects of a table, such as the width of the column padding, the alignment of text, or the table border, We can sort data. 13 | 14 | - DateTime : Datetime module supplies classes to work with date and time. 15 | 16 | ## Installation 17 | 18 | - Clone the repository to your system: 19 | 20 | ``` 21 | git clone https://github.com/MySTerY1747/invoice-generator-python.git 22 | ``` 23 | 24 | - Next, cd into the program's directory: 25 | 26 | ``` 27 | cd invoice-generator-python/ 28 | ``` 29 | 30 | - Install all the dependencies are met: 31 | 32 | ``` 33 | pip install -r requirements.txt 34 | ``` 35 | 36 | - Lastly, run the program using python: 37 | 38 | ``` 39 | python3 '.\invoice generator.py' 40 | ``` 41 | 42 | ## Usage: 43 | - To change the menu, go to "menu.txt" in the root folder of the project and following the formatting in the example, describe the desired menu. 44 | - Formatting "menu.txt": 45 | - - make sure you don't leave any empty line in the start or in between 46 | - make sure all 3 elements of row are present and are seperated by a comma (,) 47 | - make sure that only 3 elemets are present for a row as there are only 3 columns 48 | - a ideal row in Menu.txt would look like -> 1, pizza, 169 49 | - To change the name of the restaurant, change line 7 of the code in the "invoice generator.py" file. 50 | 51 | ======= 52 | ## Features 53 | - Menu can be modified by simpling changing Menu.txt 54 | - Now Quantity is also shown against products added 55 | - Other small But useful features are commented below 56 | ``` 57 | ------------------- Menu ------------------- 58 | +------+----------------------------+-------+ 59 | | S.no | Items | Cost | 60 | +------+----------------------------+-------+ 61 | | 1 | Margherita | 75 | 62 | | 2 | Double cheese Margherita | 130 | 63 | | 3 | Pepper | 175 | 64 | | 4 | Cheese & Barbeque Chicken | 130 | 65 | | 5 | Veg Extravaganza | 210 | 66 | | 6 | Meatza | 245 | 67 | | 7 | Veg singles | 170 | 68 | | 8 | Chochlate lava cake | 160 | 69 | | 9 | mogumogu | 80 | 70 | | 10 | coke | 50 | 71 | | 11 | mazza | 25 | 72 | +------+----------------------------+-------+ 73 | -------------------------------------------- 74 | 75 | Name of Customer: atul kushwaha 76 | 77 | *_* enter slno. to add items or enter "q" to quit adding times *_* 78 | *_* if you added something by mistake then enter quantity as 0 *_* 79 | *_* Default Quantity is set to 1 *_* 80 | 81 | 82 | enter the slno. of item you want to order: 2 83 | enter quantity desired(default = 1, to skip press enter): 84 | 85 | 86 | enter the slno. of item you want to order: 3 87 | enter quantity desired(default = 1, to skip press enter): 1 88 | 89 | 90 | enter the slno. of item you want to order: 122 91 | ~ slno."122" not found, please check and enter again ~ 92 | 93 | enter the slno. of item you want to order: q 94 | INVOICE 95 | Name : Atul Kushwaha 96 | Date : 21/05/23 Time: 02:00:33 97 | GST (%): 5 98 | The Net Amount To Be Paid is: 320.25 99 | The total number of item purchase : 2 100 | ------------------------------------- INVOICE ------------------------------------- 101 | +------+---------------------------+----------+-------------------+------------------+ 102 | | slno | item | quantity | price of [1 u]nit | price of n units | 103 | +------+---------------------------+----------+-------------------+------------------+ 104 | | 1 | Double cheese Margherita | 1 | 130 | 130 | 105 | | 2 | Pepper | 1 | 175 | 175 | 106 | +------+---------------------------+----------+-------------------+------------------+ 107 | ------------------------------------------------------------------------------------- 108 | Thanks for shopping with us !!! 109 | Visit us again , have a great day😊 !!! 110 | 111 | ``` 112 | ## Author: 113 | - [Atul Kushwaha](https://github.com/coderatul) 114 | 115 | ## Contributors: 116 | - [kiozet](https://github.com/kiozet) 117 | - [Bhavesh_71](https://github.com/Bhavesh71) 118 | -------------------------------------------------------------------------------- /flow of control/invoice flow of control.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coderatul/invoice-generator-python/3822823b84940645b8331601bf9b7c25b4941ff0/flow of control/invoice flow of control.png -------------------------------------------------------------------------------- /invoice generator.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import pyfiglet 3 | from datetime import date, datetime 4 | from prettytable import PrettyTable 5 | 6 | #here store name is LOS POLLOS HERMANOS 7 | print(pyfiglet.figlet_format("LOS POLLOS HERMANOS")) 8 | 9 | #you can add row-wise-details by editing Menu.txt file where elements are seperated by a comma "," 10 | 11 | #printing Menu 12 | menu = PrettyTable(['S.no','Items','Cost']) 13 | with open("Menu.txt","r") as f: 14 | rows =[] 15 | for i in (f.read().split("\n")): 16 | rows.append(i.split(",")) 17 | try: 18 | menu.add_rows(rows) 19 | except: 20 | print(" ~ something is wrong with Menu.txt file ~ ") 21 | print(""" 22 | - make sure you don't leave any empty line in the start or in between 23 | - make sure all 3 elements of row are present and are seperated by a comma (,) 24 | - make sure that only 3 elemets are present for a row as there are only 3 columns 25 | - a ideal row in Menu.txt would look like -> 1, pizza, 169 26 | """) 27 | sys.exit() 28 | print('-'*19,'Menu','-'*19) 29 | print(menu) 30 | print('-'*44,"\n") 31 | 32 | #getting name of customer 33 | name = input("Name of Customer: ").title() 34 | 35 | #basic info about entering prices based on flow of control of this project 36 | print(""" 37 | *_* enter slno. to add items or enter "q" to quit adding times *_* 38 | *_* if you added something by mistake then enter quantity as 0 *_* 39 | """) 40 | #creating a dictionary to get product_name(value) and price(value) via Slno.(key) 41 | data = {} 42 | for j in rows: 43 | data[j[0]] = list(j[1:]) 44 | 45 | slno = 1 46 | total_quantity = 0 47 | amount = 0 48 | recipt = [] 49 | # the above list_nested recipt would contain row-wise info for invoice 50 | while(True): 51 | item = input("enter the slno. of item you want to order: ").strip() 52 | try: 53 | data.get(item)[0] 54 | except: 55 | if item == "q": 56 | pass 57 | else: 58 | print(f"~ slno.\"{item}\" not found, please check and enter again ~\n") 59 | else: 60 | try: 61 | quantity = input("enter quantity desired(default = 1, to skip press enter): ") 62 | 63 | if quantity == '': 64 | quantity = 1 65 | 66 | else: 67 | quantity = int(quantity) 68 | 69 | print("\n") 70 | except: 71 | raise TypeError("please enter an integer as quantity") 72 | if quantity == 0: 73 | slno -= 1 74 | else: 75 | recipt.append([slno,data.get(item)[0],quantity,data.get(item)[1],int(data.get(item)[1]) * quantity]) 76 | amount += int(data.get(item)[1]) * quantity 77 | total_quantity += quantity 78 | slno += 1 79 | finally: 80 | pass 81 | if item == "q": 82 | break 83 | 84 | #calculating GST(Goods Service Tax) apllying GST as 5% 85 | GST = 5 86 | gst = (amount * GST) / 100 87 | final_amount = amount + gst 88 | 89 | date = date.today().strftime("%d/%m/%y") 90 | time = datetime.now().strftime("%H:%M:%S") 91 | 92 | 93 | #printing recipt 94 | print(f" INVOICE") 95 | print(f"Name : {name}") 96 | print(f"Date : {date} Time: {time}") 97 | print(f"GST (%): {GST}") 98 | print(f"The Net Amount To Be Paid is: {final_amount}") 99 | print(f"The total number of item purchase : {total_quantity}") 100 | 101 | #printing INVOICE/BILL using prettytable module 102 | print('-'*37,'INVOICE','-'*37) 103 | from prettytable import PrettyTable 104 | invoice = PrettyTable(['slno','item','quantity','price of [1 u]nit','price of n units']) 105 | invoice.add_rows(recipt) 106 | print(invoice) 107 | print('-'*85) 108 | print(" Thanks for shopping with us !!!") 109 | print(" Visit us again , have a great day😊 !!!") 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coderatul/invoice-generator-python/3822823b84940645b8331601bf9b7c25b4941ff0/requirements.txt --------------------------------------------------------------------------------