|
|
@@ -9,6 +9,14 @@ from enums.locations import Locations
|
|
|
logger = getLogger(__name__)
|
|
|
user_data_service = DataServiceFactory.get_user_service()
|
|
|
|
|
|
+def get_printer_url(location: Locations) -> str:
|
|
|
+ if location == Locations.KITCHEN:
|
|
|
+ return "http://localhost:6002"
|
|
|
+ elif location == Locations.COCTELERY:
|
|
|
+ return "http://localhost:6004"
|
|
|
+ else:
|
|
|
+ return "http://localhost:6000"
|
|
|
+
|
|
|
def print_order(order: Order, location:Locations ):
|
|
|
"""Send order to printer"""
|
|
|
logger.info(f"Attempting to print order for table {order.table}")
|
|
|
@@ -21,12 +29,7 @@ def print_order(order: Order, location:Locations ):
|
|
|
# case Locations.COCTELERY:
|
|
|
# printer_url = "http://localhost:6004"
|
|
|
|
|
|
- if location == Locations.KITCHEN:
|
|
|
- printer_url = "http://localhost:6002"
|
|
|
- elif location == Locations.COCTELERY:
|
|
|
- printer_url = "http://localhost:6004"
|
|
|
- else:
|
|
|
- printer_url = "http://localhost:6000"
|
|
|
+ printer_url = get_printer_url(location)
|
|
|
|
|
|
try:
|
|
|
if not order.items or not order.table:
|
|
|
@@ -79,7 +82,7 @@ def print_order(order: Order, location:Locations ):
|
|
|
def print_ticket(number_table: int):
|
|
|
"""Send a ticket to the printer"""
|
|
|
logger.info(f"Attempting to print ticket for table {number_table}")
|
|
|
-
|
|
|
+ printer_url = get_printer_url(Locations.BAR)
|
|
|
try:
|
|
|
|
|
|
|
|
|
@@ -110,13 +113,13 @@ def print_ticket(number_table: int):
|
|
|
|
|
|
raise
|
|
|
|
|
|
-def get_status():
|
|
|
+def get_status(location: Locations):
|
|
|
"""Get the status of the printer service"""
|
|
|
logger.info("Checking printer service status")
|
|
|
|
|
|
+ printer_url = get_printer_url(location)
|
|
|
+
|
|
|
try:
|
|
|
-
|
|
|
-
|
|
|
response = requests.get(
|
|
|
f"{printer_url}/status",
|
|
|
headers={"Authorization": f"Bearer PRINTER123cerveza@"},
|