-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin.py
70 lines (54 loc) · 1.98 KB
/
admin.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
from user import User
from item import Item
from order import Order
from customer import Customer
class Admin(User):
'''
class for the whole store system where the admin has the most privilges
'''
def __init__(self):
self.orders = []
self.customers = []
#item issues
def add_item(self,item):
Item.all_items.append(item)
Item.all_ids[item.name]=item.id
def find_item(self,item):
if item in Item.all_items and item.stock>0:
#return item
print(item)
elif item in Item.all_items and item.stock<=0:
#return "this item is out of stock"
print ("this item is out of stock")
else:
#return "this item is not found"
print("this item is not found")
def delete_item(self,item):
Item.all_items.remove(item)
del Item.all_ids[item.name]
#customer issues
def add_customer(self, customer):
Customer.all_customers.append(customer)
customer_added = Customer(customer)
return customer_added
def find_customer(self,customer):
if customer in Customer.all_customers : #and customer.id !=0
print(customer)
#return customer
else:
#return "this customer is not defined"
print( "this customer is not defined")
def delete_customer(self, customer):
Customer.all_customers.remove(customer)
#reports
def sales_report(self):
total_sales=0
for order in Order.all_orders:
total_sales += order.order_cost()
return total_sales
def stock_report(self):
stock_alarm = []
for item in Item.all_items:
if item.stock < 2:
stock_alarm.append(item)
return f"{stock_alarm} \n watch out!!! this item is about to be sold out"