Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions assignment/add_items.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import stock_manager


def add_items(items):
for item in items:
stock_manager.add_new_item_to_database(item)
13 changes: 7 additions & 6 deletions assignment/get_order.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import json
import random


def get_order():
input_file = open ('full_set.json')
input_file = open("./assignment/full_set.json")
products = json.load(input_file)

number_of_products = random.randint(1,10)
number_of_products = random.randint(1, 10)

customer_number = random.randint(1,1000000)
customer = 'Customer ' + str(customer_number)
customer_number = random.randint(1, 1000000)
customer = "Customer " + str(customer_number)

order = {
'customer': customer,
'order_items': random.sample(products, number_of_products)
"customer": customer,
"order_items": random.sample(products, number_of_products),
}

return order
Expand Down
15 changes: 10 additions & 5 deletions assignment/location_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@

# in the future, this extends to multiple warehouses


def create_new_item_location(item, warehouse_name):
if warehouse_name == 'warehouse1':
if warehouse_name == "warehouse1":
db_location = warehouse.get_location_for_new_item(item)
user_location = warehouse.get_human_readable_location(db_location, item)
user_location = warehouse.get_human_readable_location(
db_location, item
)
return db_location, user_location


def convert_db_location_to_human_readable(db_location, item):
if warehouse == 'warehouse1':
user_location = warehouse.get_human_readable_location(db_location, item)
return user_location
if warehouse == "warehouse1":
user_location = warehouse.get_human_readable_location(
db_location, item
)
return user_location
20 changes: 14 additions & 6 deletions assignment/process_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,36 @@
import verify_ean

EAN = "EAN"
CUSTOMER = "customer"
ORDER_ITEMS = "order_items"


def process_order(order):
eans = []
for i in order[1]:
eans.append[i][EAN]

print("Customer: " + order[0] + " ordered the following items:")
order_items = order[ORDER_ITEMS]
for item in order_items:
eans.append(item[EAN])

print("Customer: " + order[CUSTOMER] + " ordered the following items:")
print(eans)

items = 1
while items < len(eans):
item = input("Scan the item (EAN tag), type exit to exit: ")
if item == "bypass":
break

if item == "exit":
print("Stopped processing order")
return

if verify_ean.ean_verified(item, eans):
print("Item scanned.")
items += 1
else:
print("Invalid EAN tag. Please scan again.")

print("All correct items scanned. Processing the order.")

stock_manager.remove_from_stock(order[1])
stock_manager.remove_item_from_database(order[ORDER_ITEMS])
return

3 changes: 2 additions & 1 deletion assignment/stock_manager.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import database_controller as database # Database Controller class that implements getters and setters
# import database_controller as database # Database Controller class that implements getters and setters
import location_manager
import db_connection as database

Expand All @@ -11,6 +11,7 @@ def add_new_item_to_database(item, warehouse="warehouse1"):
item['location'] = db_location
item['stock'] = 1


# here check for stock and either add new item or increase stock
database.add_item(item)

Expand Down
2 changes: 1 addition & 1 deletion assignment/verify_ean.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
def ean_verified(ean: str, eans: list) -> bool:
if ean in eans:
return True
return False
return False
11 changes: 6 additions & 5 deletions assignment/wms.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import json
import get_order

import add_items
import get_order
import process_order

COMMANDS = "add/order/exit"


def wms():
print("Welcome to the Warehouse Management System")
print("Your warehosue is now managed!")
Expand All @@ -13,18 +15,17 @@ def wms():
command = input("Enter a command:" + COMMANDS + "\n")
match command:
case "add":
print("Adding new items")
print("Adding new items")
with open("./assignment/sample_set.json", "r") as file:
items = json.load(file)
add_items.add_items(items)
case "order":
print("Placing a new order")
order = get_order()
order = get_order.get_order()
process_order.process_order(order)
case "exit":
exit()



if __name__ == "__main__":
wms()
wms()