Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1dd1e8a730 | |||
| b99d2e1944 |
@@ -1,10 +1,11 @@
|
|||||||
import logging
|
import logging
|
||||||
from asyncio import sleep, create_task
|
from asyncio import sleep, create_task
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
from functools import partial
|
||||||
from typing import Optional, Callable
|
from typing import Optional, Callable
|
||||||
|
|
||||||
from rio import Column, Component, event, TextStyle, Text, Spacer, Revealer, ProgressCircle, ScrollContainer, Row, Popup, List, Rectangle, PointerEventListener, \
|
from rio import Column, Component, event, TextStyle, Text, Spacer, Revealer, ProgressCircle, ScrollContainer, Row, Popup, List, Rectangle, PointerEventListener, \
|
||||||
PointerEvent, TextInput, TextInputChangeEvent
|
PointerEvent, TextInput, TextInputChangeEvent, Color, Button, Checkbox, Switch
|
||||||
|
|
||||||
from src.ezgg_lan_manager import ConfigurationService, CateringService, AccountingService
|
from src.ezgg_lan_manager import ConfigurationService, CateringService, AccountingService
|
||||||
from src.ezgg_lan_manager.components.CateringCartItem import CateringCartItem
|
from src.ezgg_lan_manager.components.CateringCartItem import CateringCartItem
|
||||||
@@ -26,6 +27,7 @@ class Cart(Component):
|
|||||||
popup_message: str = ""
|
popup_message: str = ""
|
||||||
popup_is_shown: bool = False
|
popup_is_shown: bool = False
|
||||||
popup_is_error: bool = True
|
popup_is_error: bool = True
|
||||||
|
print_receipt: bool = True
|
||||||
|
|
||||||
async def on_remove_item(self, list_id: int) -> None:
|
async def on_remove_item(self, list_id: int) -> None:
|
||||||
try:
|
try:
|
||||||
@@ -62,7 +64,7 @@ class Cart(Component):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
items_with_amounts[item] = 1
|
items_with_amounts[item] = 1
|
||||||
try:
|
try:
|
||||||
await self.session[CateringService].place_order(items_with_amounts, self.user_id, is_delivery=False)
|
await self.session[CateringService].place_order(items_with_amounts, self.user_id, is_delivery=False, print_receipt=self.print_receipt)
|
||||||
except CateringError as catering_error:
|
except CateringError as catering_error:
|
||||||
logger.error(catering_error)
|
logger.error(catering_error)
|
||||||
if catering_error.error_type == CateringErrorType.INCLUDES_DISABLED_ITEM:
|
if catering_error.error_type == CateringErrorType.INCLUDES_DISABLED_ITEM:
|
||||||
@@ -151,7 +153,7 @@ class NewPosOrderPage(Component):
|
|||||||
user_id: Optional[int] = None
|
user_id: Optional[int] = None
|
||||||
all_menu_items: Optional[list[CateringMenuItem]] = None
|
all_menu_items: Optional[list[CateringMenuItem]] = None
|
||||||
cart: List[CateringMenuItem] = List()
|
cart: List[CateringMenuItem] = List()
|
||||||
|
print_receipt: bool = True
|
||||||
|
|
||||||
@event.on_populate
|
@event.on_populate
|
||||||
async def on_populate(self) -> None:
|
async def on_populate(self) -> None:
|
||||||
@@ -203,8 +205,12 @@ class NewPosOrderPage(Component):
|
|||||||
margin_bottom=0.5,
|
margin_bottom=0.5,
|
||||||
align_x=0.5
|
align_x=0.5
|
||||||
),
|
),
|
||||||
TextInput(text=self.bind().user_id_input_value, label="Nutzer ID", on_change=self.on_user_id_input_change, change_delay=1, margin_bottom=0.5, margin_left=5, margin_right=5),
|
Row(
|
||||||
Cart(cart=self.cart, user_id=self.user_id, clear_cb=self.clear_user_id_input)
|
TextInput(text=self.bind().user_id_input_value, label="Nutzer ID", on_change=self.on_user_id_input_change, change_delay=1, margin_bottom=0.5, margin_left=1, margin_right=1, min_width=20),
|
||||||
|
Text("Bon drucken?:", margin_right=0, margin_left=0, style=TextStyle(fill=self.session.theme.background_color)),
|
||||||
|
Switch(is_on=self.bind().print_receipt, margin_right=1)
|
||||||
|
),
|
||||||
|
Cart(cart=self.cart, user_id=self.user_id, clear_cb=self.clear_user_id_input, print_receipt=self.print_receipt)
|
||||||
)
|
)
|
||||||
) if is_team_member else Spacer()
|
) if is_team_member else Spacer()
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,13 @@ class MatchInfo(Component):
|
|||||||
opponent_2_seat: str = ""
|
opponent_2_seat: str = ""
|
||||||
winner: str = ""
|
winner: str = ""
|
||||||
|
|
||||||
|
def calculate_font_size(self, txt: str) -> float:
|
||||||
|
if len(txt) < 14:
|
||||||
|
return 0.9
|
||||||
|
elif len(txt) < 20:
|
||||||
|
return 0.7
|
||||||
|
return 0.6
|
||||||
|
|
||||||
def build(self) -> Component:
|
def build(self) -> Component:
|
||||||
return Rectangle(
|
return Rectangle(
|
||||||
content=Column(
|
content=Column(
|
||||||
@@ -33,13 +40,13 @@ class MatchInfo(Component):
|
|||||||
style=TextStyle(fill=self.session.theme.success_color if self.winner == self.opponent_1 else self.session.theme.background_color),
|
style=TextStyle(fill=self.session.theme.success_color if self.winner == self.opponent_1 else self.session.theme.background_color),
|
||||||
justify="left",
|
justify="left",
|
||||||
margin_right=0.6,
|
margin_right=0.6,
|
||||||
font_size=0.9
|
font_size=self.calculate_font_size(self.opponent_1)
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
text=f"({self.opponent_1_seat})" if self.opponent_1_seat else "Freilos",
|
text=f"({self.opponent_1_seat})" if self.opponent_1_seat else "Freilos",
|
||||||
style=TextStyle(fill=self.session.theme.background_color),
|
style=TextStyle(fill=self.session.theme.background_color),
|
||||||
justify="left",
|
justify="left",
|
||||||
font_size=0.9
|
font_size=self.calculate_font_size(self.opponent_1)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
Spacer(),
|
Spacer(),
|
||||||
@@ -49,13 +56,13 @@ class MatchInfo(Component):
|
|||||||
style=TextStyle(fill=self.session.theme.success_color if self.winner == self.opponent_2 else self.session.theme.background_color),
|
style=TextStyle(fill=self.session.theme.success_color if self.winner == self.opponent_2 else self.session.theme.background_color),
|
||||||
justify="right",
|
justify="right",
|
||||||
margin_right=0.6,
|
margin_right=0.6,
|
||||||
font_size=0.9
|
font_size=self.calculate_font_size(self.opponent_2)
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
text=f"({self.opponent_2_seat})" if self.opponent_2_seat else "Freilos",
|
text=f"({self.opponent_2_seat})" if self.opponent_2_seat else "Freilos",
|
||||||
style=TextStyle(fill=self.session.theme.background_color),
|
style=TextStyle(fill=self.session.theme.background_color),
|
||||||
justify="right",
|
justify="right",
|
||||||
font_size=0.9
|
font_size=self.calculate_font_size(self.opponent_2)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
margin=0.3
|
margin=0.3
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class CateringService:
|
|||||||
# ORDERS
|
# ORDERS
|
||||||
|
|
||||||
async def place_order(self, menu_items: CateringMenuItemsWithAmount, user_id: int,
|
async def place_order(self, menu_items: CateringMenuItemsWithAmount, user_id: int,
|
||||||
is_delivery: bool = True) -> CateringOrder:
|
is_delivery: bool = True, print_receipt: bool = True) -> CateringOrder:
|
||||||
for menu_item in menu_items:
|
for menu_item in menu_items:
|
||||||
if menu_item.is_disabled:
|
if menu_item.is_disabled:
|
||||||
raise CateringError("Order includes disabled items", CateringErrorType.INCLUDES_DISABLED_ITEM)
|
raise CateringError("Order includes disabled items", CateringErrorType.INCLUDES_DISABLED_ITEM)
|
||||||
@@ -54,6 +54,7 @@ class CateringService:
|
|||||||
await self._accounting_service.remove_balance(user_id, total_price, f"CATERING - {order.order_id}")
|
await self._accounting_service.remove_balance(user_id, total_price, f"CATERING - {order.order_id}")
|
||||||
logger.info(
|
logger.info(
|
||||||
f"User '{order.customer.user_name}' (ID:{order.customer.user_id}) ordered from catering for {self._accounting_service.make_euro_string_from_decimal(total_price)}")
|
f"User '{order.customer.user_name}' (ID:{order.customer.user_id}) ordered from catering for {self._accounting_service.make_euro_string_from_decimal(total_price)}")
|
||||||
|
if print_receipt:
|
||||||
await self._receipt_printing_service.print_order(user, order)
|
await self._receipt_printing_service.print_order(user, order)
|
||||||
# await self.cancel_order(order) # ToDo: Check if commented out before commit. Un-comment to auto-cancel every placed order
|
# await self.cancel_order(order) # ToDo: Check if commented out before commit. Un-comment to auto-cancel every placed order
|
||||||
return order
|
return order
|
||||||
|
|||||||
Reference in New Issue
Block a user