-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPOSystem.py
More file actions
51 lines (44 loc) · 1.89 KB
/
POSystem.py
File metadata and controls
51 lines (44 loc) · 1.89 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
class Sales():
def __init__(self):
self.Sales = {}
def get_sale(self):
return self.Sales
def set_Sales(self, name, price ,quantity):
self.Sales = {name: {"Price": price, "Quantity": quantity}}
class Inventory(Sales):
def __init__(self):
super().__init__()
self.Inventory = {}
def set_Inventory(self, name, price, quant):
self.Inventory[name] = {"Price": price, "Quantity": quant}
def get_Inventory(self):
return self.Inventory
def remove_Inventory(self, name, quantity):
if self.Inventory.get(name) != None:
self.Sales[name] = {"Product": name, "Quantity": quantity}
if self.Inventory[name]["Quantity"] == 1:
print(f'There is only {self.Inventory[name]["Quantity"]} left')
ans = input("Would you like to Continue (Y/N): ")
if ans.upper() == 'Y' or ans.upper == "YES":
self.Inventory[name]["Quantity"] -= quantity
price = self.Inventory[name]["Price"]
Sales.set_Sales(self, name, price, quantity)
self.Inventory.pop(f'{name}', None)
elif self.Inventory[name]["Quantity"] > 1:
price = self.Inventory[name]["Price"]
Sales().set_Sales(name, price, quantity)
self.Inventory[name]["Quantity"] -= quantity
else:
print(f'{name} does not exist in the inventory')
else:
print(f'{name} does not exist in the inventory')
# class Checkout(Inventory):
y = Inventory()
y.set_Inventory('Rolex', 15000,2)
y.set_Inventory('Patek Philippe', 100000, 1)
y.set_Inventory('Hublot', 50000, 5)
y.set_Inventory('Richard Mille', 100000, 5)
print(y.get_Inventory())
y.remove_Inventory('Richard Mille', 4)
print(y.get_Inventory())
print(y.get_sale())