-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
101 lines (82 loc) · 2.21 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
from rich.console import Console
orders = [
{
'order_no': 1234,
'items': [['s', 5,6,2,11,660],['n', 3,2,1,6.5,39]]
},
{
'order_no': 1133,
'items': [['s', 5,6,2,11,660],['n', 3,2,1,6.5,39]]
}
]
#E2AEDD
#B81365
#BFAB25
#FAF9F9
#FF6700
#3DFAFF
#FF331F
#80ED99
#DC6ACF
def order_print(orders):
gtotal = 0
from rich.theme import Theme
custom_theme = Theme({
"t" : "#b81365",
"on": "#EBCBF4",
"dm": "#dc6acf",
"q": "#ff6700",
"rm": "#80ed99",
"a": "#ff331f",
"tt": "#3dfaff"
})
console = Console(theme=custom_theme)
for i in orders:
o_n = i['order_no']
items = i['items']
for i in items:
gtotal = gtotal + i[-1]
console.print(f'[on]Order No.[/on] {o_n} [t]Type:[/t] {i[0].upper()} [dm]Dimension:[/dm] {i[1]}x{i[2]} [q]Qty:[/q] {i[3]} [rm]Rate:[/rm] {i[4]} [a]Amount:[/a] {i[-1]}')
console.print("[tt]Total[/tt]", gtotal)
def calct(ftype, width, height, qty):
if ftype == 'n':
rate = 6.5
sqft = width*height
amount = 6.5*sqft*qty
return ftype, width, height, sqft, qty, rate, amount
elif ftype == 's':
rate = 11
sqft = width*height
amount = sqft*11*qty
return ftype, width, height, sqft, qty, rate, amount
else:
return 'Error in input'
def add_order():
ftype = input("T :")
width = float(input("W : "))
height = float(input("H : "))
qty = int(input("Q :"))
data = calct(ftype, width, height, qty)
item = [ data[0], data[1], data[2], data[3], data[4], data[5], data[6]]
return item
def gen_order():
order = {}
order_no = int(input("Order no : "))
flag = ''
items = []
while flag != 'q':
item = add_order()
items.append(item)
flag = input("Done ? (q to done or enter to continue) ")
order['order_no'] = order_no
order['items'] = items
orders.append(order)
q = ''
while q != 'q':
# print("Hare Krishna")
import os
os.system('cls')
order_print(orders)
gen_order()
# print(orders)
q = input("Press enter to add new item (q to quit) :")