3
3
from reportlab .lib .pagesizes import A4
4
4
from reportlab .lib .styles import getSampleStyleSheet
5
5
from datetime import datetime
6
+ import win10toast
6
7
7
8
def store_products ():
8
9
print ('=====> WELCOME TO MY-SCHOOL <=====' )
@@ -52,6 +53,8 @@ def store_products():
52
53
53
54
parchasing = True
54
55
56
+ totalFee = 0
57
+ discount = 3000
55
58
while (parchasing ):
56
59
buy_course = int (input ("Which Course Do you wan to Buy (0, 1, 2....) : " ))
57
60
if (buy_course > len (default_courses )):
@@ -75,13 +78,54 @@ def store_products():
75
78
course ['Price' ]
76
79
])
77
80
81
+ if course ['Price' ] != 'Free' :
82
+ totalFee += course ['Price' ]
83
+
84
+
78
85
for row in templete :
79
86
print (row )
80
- exit = input ("Do you want to exit (0 - exit) : " )
87
+
88
+ exit = input ("\n Do you want to exit (0 - exit - No) : " )
81
89
if (exit == 'exit' or exit == '0' ):
82
90
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
+ ])
86
107
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 ])
87
131
store_products ()
0 commit comments