Skip to content

Commit 5337aba

Browse files
committed
code Updated
1 parent da2b2f1 commit 5337aba

File tree

2 files changed

+48
-4
lines changed

2 files changed

+48
-4
lines changed
Binary file not shown.

Project 13 - Generating Payment Receipts/main.py

+48-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from reportlab.lib.pagesizes import A4
44
from reportlab.lib.styles import getSampleStyleSheet
55
from datetime import datetime
6+
import win10toast
67

78
def store_products():
89
print('=====> WELCOME TO MY-SCHOOL <=====')
@@ -52,6 +53,8 @@ def store_products():
5253

5354
parchasing = True
5455

56+
totalFee = 0
57+
discount = 3000
5558
while(parchasing):
5659
buy_course = int(input("Which Course Do you wan to Buy (0, 1, 2....) : "))
5760
if(buy_course > len(default_courses)):
@@ -75,13 +78,54 @@ def store_products():
7578
course['Price']
7679
])
7780

81+
if course['Price'] != 'Free':
82+
totalFee += course['Price']
83+
84+
7885
for row in templete:
7986
print(row)
80-
exit = input("Do you want to exit (0 - exit) : ")
87+
88+
exit = input("\nDo you want to exit (0 - exit - No) : ")
8189
if(exit == 'exit' or exit == '0'):
8290
parchasing = False
83-
84-
85-
91+
92+
93+
templete.append([
94+
("Discount"),
95+
(""),
96+
(""),
97+
(""),
98+
(discount),
99+
])
100+
templete.append([
101+
("Total"),
102+
(""),
103+
(""),
104+
(""),
105+
(totalFee-discount),
106+
])
86107

108+
pdf = SimpleDocTemplate('Receipt.pdf', pagesize = A4)
109+
toaster = win10toast.ToastNotifier()
110+
t_title = "Courses Reciept Ready!"
111+
message = "Courses has been parchased from My-School"
112+
toaster.show_toast(t_title, message)
113+
styles = getSampleStyleSheet()
114+
title_style = styles['Heading1']
115+
title_style.alignment = 1
116+
title = Paragraph('My-School Courses', title_style)
117+
style = TableStyle(
118+
[
119+
( "BOX" , ( 0, 0 ), ( -1, -1 ), 1 , colors.black ),
120+
( "GRID" , ( 0, 0 ), ( 4 , 4 ), 1 , colors.black ),
121+
( "BACKGROUND" , ( 0, 0 ), ( 3, 0 ), colors.gray ),
122+
( "TEXTCOLOR" , ( 0, 0 ), ( -1, 0 ), colors.black ),
123+
( "BACKGROUND" , ( 0, 0 ), ( 4, 0 ), colors.gray ),
124+
( "ALIGN" , ( 0, 0 ), ( -1, -1 ), "CENTER" ),
125+
( "BACKGROUND" , ( 0 , 1 ) , ( -1 , -1 ), colors.beige ),
126+
("BACKGROUND", (0, -2), (-1, -1), colors.lightblue),
127+
]
128+
)
129+
table = Table(templete, style=style)
130+
pdf.build([title, table])
87131
store_products()

0 commit comments

Comments
 (0)