printer-core 0.0.5__tar.gz → 0.0.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {printer_core-0.0.5 → printer_core-0.0.7}/PKG-INFO +1 -1
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/builders/client_ticket_builder.py +15 -1
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/builders/kitchen_ticket_payload_builder.py +1 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/entities/print_models.py +2 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/tests/unitaries/test_client_ticket_builder.py +16 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/tests/unitaries/test_kitchen_ticket_payload_builder.py +18 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/pyproject.toml +1 -1
- {printer_core-0.0.5 → printer_core-0.0.7}/.gitignore +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/README.md +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/__init__.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/algorithms/__init__.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/algorithms/products_modifiers_multiprinter.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/algorithms/products_modifiers_multiprinter_family.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/algorithms/products_modifiers_unique_ticket.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/builders/__init__.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/builders/header_builder.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/builders/printer_products_grouper.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/clock.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/context/__init__.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/context/ticket_context_builder.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/dispatchers/__init__.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/dispatchers/kitchen_ticket_dispatcher.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/dispatchers/payload_dispatcher.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/entities/__init__.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/entities/print_context.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/formatters/__init__.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/formatters/discount_formatter.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/ports.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/selectors/__init__.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/selectors/family_product_selector.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/services/__init__.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/services/flows/__init__.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/services/flows/base.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/services/flows/client.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/services/flows/kitchen.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/services/march_printer_service.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/services/multi_printer_family_service.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/services/multi_printer_service.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/services/order_print_service.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/services/print_policy.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/services/unique_ticket_service.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/tests/__init__.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/tests/unitaries/__init__.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/tests/unitaries/helpers.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/tests/unitaries/test_cases_output.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/tests/unitaries/test_discount_formatter.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/tests/unitaries/test_family_product_selector.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/tests/unitaries/test_flows.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/tests/unitaries/test_header_builder_foodeo_printers.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/tests/unitaries/test_kitchen_ticket_dispatcher.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/tests/unitaries/test_march_printer_service.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/tests/unitaries/test_multi_printer_family_service.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/tests/unitaries/test_multi_printer_service.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/tests/unitaries/test_order_print_service.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/tests/unitaries/test_payload_dispatcher.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/tests/unitaries/test_print_policy.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/tests/unitaries/test_printer_helpers.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/tests/unitaries/test_printer_products_grouper.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/tests/unitaries/test_products_modifiers.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/tests/unitaries/test_ticket_context_builder.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/tests/unitaries/test_unique_ticket_service.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/utils/__init__.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/printer_core/utils/printer_helpers.py +0 -0
- {printer_core-0.0.5 → printer_core-0.0.7}/scripts/link_backend_env.sh +0 -0
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
from decimal import Decimal
|
|
2
2
|
from typing import Any, Callable
|
|
3
|
+
from datetime import datetime
|
|
3
4
|
|
|
5
|
+
from printer_core.clock import SystemClock
|
|
4
6
|
from printer_core.entities import (
|
|
5
7
|
ClientTicketData,
|
|
6
8
|
ClientTicketPayload,
|
|
@@ -9,15 +11,18 @@ from printer_core.entities import (
|
|
|
9
11
|
PrintRequestData,
|
|
10
12
|
PrinterData,
|
|
11
13
|
)
|
|
14
|
+
from printer_core.ports import Clock
|
|
12
15
|
|
|
13
16
|
|
|
14
17
|
class ClientTicketBuilder:
|
|
15
18
|
def __init__(self,
|
|
16
19
|
currency_symbol_resolver: Callable[[str], str] | None = None,
|
|
17
20
|
domicile_service_label: str = "Domicile Service",
|
|
21
|
+
clock: Clock | None = None
|
|
18
22
|
):
|
|
19
23
|
self._currency_symbol_resolver = currency_symbol_resolver or (lambda _: "")
|
|
20
24
|
self._domicile_service_label = domicile_service_label
|
|
25
|
+
self._clock = clock or SystemClock()
|
|
21
26
|
|
|
22
27
|
def build(self,
|
|
23
28
|
request: PrintRequestData,
|
|
@@ -29,7 +34,7 @@ class ClientTicketBuilder:
|
|
|
29
34
|
ticket_text = self._get_attr(ticket_settings, "ticket_text", "")
|
|
30
35
|
qty_client_ticket = self._get_attr(ticket_settings, "qty_client_ticket", 1)
|
|
31
36
|
client_request = ClientTicketData(
|
|
32
|
-
**request.model_dump(exclude={"products", "ticket_text"}),
|
|
37
|
+
**request.model_dump(exclude={"products", "ticket_text", "is_rectified"}),
|
|
33
38
|
ticket_text=ticket_text,
|
|
34
39
|
products=self._build_products(request, products),
|
|
35
40
|
)
|
|
@@ -39,6 +44,8 @@ class ClientTicketBuilder:
|
|
|
39
44
|
elif client_request.details:
|
|
40
45
|
client_request = client_request.model_copy(update={"details": None})
|
|
41
46
|
|
|
47
|
+
client_request = client_request.model_copy(update={"created_at": self._resolve_created_at(request)})
|
|
48
|
+
|
|
42
49
|
printer_name, printer_width = self._resolve_printer(printer)
|
|
43
50
|
payload = ClientTicketPayload(
|
|
44
51
|
data=client_request,
|
|
@@ -95,3 +102,10 @@ class ClientTicketBuilder:
|
|
|
95
102
|
if isinstance(printer, dict):
|
|
96
103
|
return printer["name"], printer["printer_width"]
|
|
97
104
|
return printer.name, printer.printer_width
|
|
105
|
+
|
|
106
|
+
def _resolve_created_at(self, request: PrintRequestData) -> str:
|
|
107
|
+
if request.type in ["domicilio", "recoger"] and request.shift_time and request.delivery_date:
|
|
108
|
+
shift_time = datetime.strptime(request.shift_time, "%H:%M").time()
|
|
109
|
+
delivery_date = datetime.strptime(request.delivery_date, "%Y-%m-%d").date()
|
|
110
|
+
return datetime.combine(delivery_date, shift_time).strftime("%Y-%m-%d %H:%M")
|
|
111
|
+
return self._clock.now_iso()
|
|
@@ -141,6 +141,7 @@ class KitchenTicketData(BaseModel):
|
|
|
141
141
|
headerData: HeaderData | None = None
|
|
142
142
|
products: list[KitchenProductLine] | None = None
|
|
143
143
|
products_groups: list[ProductsGroup] | None = None
|
|
144
|
+
is_rectified: bool = False
|
|
144
145
|
|
|
145
146
|
|
|
146
147
|
class PrintRequestData(BaseModel):
|
|
@@ -181,6 +182,7 @@ class PrintRequestData(BaseModel):
|
|
|
181
182
|
|
|
182
183
|
|
|
183
184
|
class ClientTicketData(PrintRequestData):
|
|
185
|
+
is_rectified: bool = Field(default=False, exclude=True)
|
|
184
186
|
products: list[ClientTicketProduct] | None = None
|
|
185
187
|
|
|
186
188
|
|
{printer_core-0.0.5 → printer_core-0.0.7}/printer_core/tests/unitaries/test_client_ticket_builder.py
RENAMED
|
@@ -76,3 +76,19 @@ class ClientTicketBuilderTest(unittest.TestCase):
|
|
|
76
76
|
|
|
77
77
|
self.assertEqual(payloads[0].data.products[-1].name, "Service")
|
|
78
78
|
self.assertEqual(payloads[0].data.products[-1].price, "2.00")
|
|
79
|
+
|
|
80
|
+
def test_build_does_not_serialize_rectified_flag_when_request_is_rectified(self):
|
|
81
|
+
builder = ClientTicketBuilder()
|
|
82
|
+
request = make_request(is_rectified=True)
|
|
83
|
+
products = [make_product()]
|
|
84
|
+
|
|
85
|
+
payloads = builder.build(
|
|
86
|
+
request=request,
|
|
87
|
+
products=products,
|
|
88
|
+
printer=make_printer(),
|
|
89
|
+
ticket_settings=make_ticket_settings(),
|
|
90
|
+
tpv_key="TPV1",
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
self.assertTrue(request.is_rectified)
|
|
94
|
+
self.assertNotIn("is_rectified", payloads[0].data.model_dump())
|
|
@@ -111,3 +111,21 @@ class KitchenTicketPayloadBuilderTest(unittest.TestCase):
|
|
|
111
111
|
)
|
|
112
112
|
|
|
113
113
|
self.assertEqual(payload.PrintSettings.show_header, False)
|
|
114
|
+
|
|
115
|
+
def test_build_includes_rectified_flag(self):
|
|
116
|
+
builder = KitchenTicketPayloadBuilder(clock=FakeClock())
|
|
117
|
+
request = make_request(request_type="local", is_rectified=True)
|
|
118
|
+
products = [KitchenProductLine(name="A", qty=1, option=None, printer_r="P1", printer_w="80")]
|
|
119
|
+
|
|
120
|
+
payload = builder.build(
|
|
121
|
+
request=request,
|
|
122
|
+
printer_name="P1",
|
|
123
|
+
tpv_key="TPV1",
|
|
124
|
+
printer_width="80",
|
|
125
|
+
products=products,
|
|
126
|
+
ticket_settings=make_ticket_settings(),
|
|
127
|
+
kitchen_ticket_settings=make_kitchen_settings(),
|
|
128
|
+
group_products_func=lambda items: [ProductsGroup(group="G", products=items)],
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
self.assertTrue(payload.data.is_rectified)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{printer_core-0.0.5 → printer_core-0.0.7}/printer_core/algorithms/products_modifiers_multiprinter.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{printer_core-0.0.5 → printer_core-0.0.7}/printer_core/dispatchers/kitchen_ticket_dispatcher.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{printer_core-0.0.5 → printer_core-0.0.7}/printer_core/services/multi_printer_family_service.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{printer_core-0.0.5 → printer_core-0.0.7}/printer_core/tests/unitaries/test_discount_formatter.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{printer_core-0.0.5 → printer_core-0.0.7}/printer_core/tests/unitaries/test_march_printer_service.py
RENAMED
|
File without changes
|
|
File without changes
|
{printer_core-0.0.5 → printer_core-0.0.7}/printer_core/tests/unitaries/test_multi_printer_service.py
RENAMED
|
File without changes
|
{printer_core-0.0.5 → printer_core-0.0.7}/printer_core/tests/unitaries/test_order_print_service.py
RENAMED
|
File without changes
|
{printer_core-0.0.5 → printer_core-0.0.7}/printer_core/tests/unitaries/test_payload_dispatcher.py
RENAMED
|
File without changes
|
|
File without changes
|
{printer_core-0.0.5 → printer_core-0.0.7}/printer_core/tests/unitaries/test_printer_helpers.py
RENAMED
|
File without changes
|
|
File without changes
|
{printer_core-0.0.5 → printer_core-0.0.7}/printer_core/tests/unitaries/test_products_modifiers.py
RENAMED
|
File without changes
|
|
File without changes
|
{printer_core-0.0.5 → printer_core-0.0.7}/printer_core/tests/unitaries/test_unique_ticket_service.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|