-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaggregate.py
More file actions
55 lines (47 loc) · 1.69 KB
/
aggregate.py
File metadata and controls
55 lines (47 loc) · 1.69 KB
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
import MiniWorld
import colours
import subprocess as sp
def a():
date = input("Enter Date in the form yyyy-mm-dd: ")
query = f"""
SELECT Sum(Falc.Packages) as Packages, Falcon.Territory_ID as Territory
FROM
(
SELECT SUM(Num_Pkg_bought) as Packages, Falc_Emp_ID
FROM Buys
WHERE Trans_Date = "{date}"
GROUP By Falc_Emp_ID
) as Falc
INNER JOIN Falcon
WHERE Falcon.Employee_ID = Falc.Falc_Emp_ID
GROUP BY Falcon.Territory_ID;
"""
MiniWorld.executeQuery(query)
def b():
year = input("Enter Year: ");
query = f'SELECT Sum(Net_Revenue) - Sum(Net_Spending) AS Net_Profit FROM Organisation_Details WHERE Date >= "{year}-01-01" AND Date <= "{year}-12-31";'
MiniWorld.executeQuery(query)
def aggregate():
while(1):
tmp = sp.call('clear', shell = True)
print("Choose an operation:")
print(f"{colours.bcolors.OKCYAN}")
print("1. Total Amount of Packages sold in a day")
print("2. Net profit acquired by end of the year")
print(f"{colours.bcolors.ENDC}{colours.bcolors.WARNING}")
print("3. Back")
print("4. Exit")
print(f"{colours.bcolors.ENDC}")
ch = input("Enter choice: ").lower()
tmp = sp.call('clear', shell = True)
if ch == '1' or ch == 'total amount of packages sold in a day':
a()
elif ch == '2' or ch == 'net profit acquired by end of the year':
b()
elif ch == '3' or ch == 'back':
return
elif ch == '4' or ch == 'exit':
exit()
else:
print(f"{colours.bcolors.RED}Invalid Option{colours.bcolors.ENDC}")
input("Enter any key to continue: ")