printer-core 0.0.7__tar.gz → 0.0.9__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.7 → printer_core-0.0.9}/PKG-INFO +1 -1
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/algorithms/products_modifiers_unique_ticket.py +13 -1
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/builders/client_ticket_builder.py +8 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/entities/print_models.py +1 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/services/flows/client.py +3 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/services/flows/kitchen.py +0 -6
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/services/unique_ticket_service.py +5 -1
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/tests/unitaries/helpers.py +2 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/tests/unitaries/test_client_ticket_builder.py +32 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/tests/unitaries/test_flows.py +35 -4
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/tests/unitaries/test_printer_helpers.py +10 -2
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/tests/unitaries/test_products_modifiers.py +12 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/utils/printer_helpers.py +17 -14
- {printer_core-0.0.7 → printer_core-0.0.9}/pyproject.toml +1 -1
- {printer_core-0.0.7 → printer_core-0.0.9}/.gitignore +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/README.md +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/__init__.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/algorithms/__init__.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/algorithms/products_modifiers_multiprinter.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/algorithms/products_modifiers_multiprinter_family.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/builders/__init__.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/builders/header_builder.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/builders/kitchen_ticket_payload_builder.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/builders/printer_products_grouper.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/clock.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/context/__init__.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/context/ticket_context_builder.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/dispatchers/__init__.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/dispatchers/kitchen_ticket_dispatcher.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/dispatchers/payload_dispatcher.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/entities/__init__.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/entities/print_context.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/formatters/__init__.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/formatters/discount_formatter.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/ports.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/selectors/__init__.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/selectors/family_product_selector.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/services/__init__.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/services/flows/__init__.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/services/flows/base.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/services/march_printer_service.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/services/multi_printer_family_service.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/services/multi_printer_service.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/services/order_print_service.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/services/print_policy.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/tests/__init__.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/tests/unitaries/__init__.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/tests/unitaries/test_cases_output.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/tests/unitaries/test_discount_formatter.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/tests/unitaries/test_family_product_selector.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/tests/unitaries/test_header_builder_foodeo_printers.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/tests/unitaries/test_kitchen_ticket_dispatcher.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/tests/unitaries/test_kitchen_ticket_payload_builder.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/tests/unitaries/test_march_printer_service.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/tests/unitaries/test_multi_printer_family_service.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/tests/unitaries/test_multi_printer_service.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/tests/unitaries/test_order_print_service.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/tests/unitaries/test_payload_dispatcher.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/tests/unitaries/test_print_policy.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/tests/unitaries/test_printer_products_grouper.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/tests/unitaries/test_ticket_context_builder.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/tests/unitaries/test_unique_ticket_service.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/printer_core/utils/__init__.py +0 -0
- {printer_core-0.0.7 → printer_core-0.0.9}/scripts/link_backend_env.sh +0 -0
|
@@ -3,9 +3,15 @@ from printer_core.formatters.discount_formatter import DiscountFormatter
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
class ProductsModifiersUniqueTicket:
|
|
6
|
-
def __init__(
|
|
6
|
+
def __init__(
|
|
7
|
+
self,
|
|
8
|
+
formatter: DiscountFormatter,
|
|
9
|
+
domicile_service_label: str = "Domicile Service",
|
|
10
|
+
reservation_payment_label: str = "Reservation Payment",
|
|
11
|
+
):
|
|
7
12
|
self._formatter = formatter
|
|
8
13
|
self._domicile_service_label = domicile_service_label
|
|
14
|
+
self._reservation_payment_label = reservation_payment_label
|
|
9
15
|
|
|
10
16
|
def build(self, request: PrintRequestData, products: list[PrintProductData]) -> list[ClientTicketProduct]:
|
|
11
17
|
list_products_in_same_printers: list[ClientTicketProduct] = []
|
|
@@ -27,4 +33,10 @@ class ProductsModifiersUniqueTicket:
|
|
|
27
33
|
qty=1,
|
|
28
34
|
price=str(request.price_domicile_service),
|
|
29
35
|
))
|
|
36
|
+
if request.reservation_payment_amount:
|
|
37
|
+
list_products_in_same_printers.append(ClientTicketProduct(
|
|
38
|
+
name=self._reservation_payment_label,
|
|
39
|
+
qty=1,
|
|
40
|
+
price=str(request.reservation_payment_amount),
|
|
41
|
+
))
|
|
30
42
|
return list_products_in_same_printers
|
|
@@ -18,10 +18,12 @@ class ClientTicketBuilder:
|
|
|
18
18
|
def __init__(self,
|
|
19
19
|
currency_symbol_resolver: Callable[[str], str] | None = None,
|
|
20
20
|
domicile_service_label: str = "Domicile Service",
|
|
21
|
+
reservation_payment_label: str = "Reservation Payment",
|
|
21
22
|
clock: Clock | None = None
|
|
22
23
|
):
|
|
23
24
|
self._currency_symbol_resolver = currency_symbol_resolver or (lambda _: "")
|
|
24
25
|
self._domicile_service_label = domicile_service_label
|
|
26
|
+
self._reservation_payment_label = reservation_payment_label
|
|
25
27
|
self._clock = clock or SystemClock()
|
|
26
28
|
|
|
27
29
|
def build(self,
|
|
@@ -83,6 +85,12 @@ class ClientTicketBuilder:
|
|
|
83
85
|
qty=1,
|
|
84
86
|
price=str(request.price_domicile_service),
|
|
85
87
|
))
|
|
88
|
+
if request.reservation_payment_amount:
|
|
89
|
+
list_products.append(ClientTicketProduct(
|
|
90
|
+
name=self._reservation_payment_label,
|
|
91
|
+
qty=1,
|
|
92
|
+
price=str(request.reservation_payment_amount),
|
|
93
|
+
))
|
|
86
94
|
return list_products
|
|
87
95
|
|
|
88
96
|
def _format_discount(self, product: PrintProductData, currency_symbol: str) -> str:
|
|
@@ -177,6 +177,7 @@ class PrintRequestData(BaseModel):
|
|
|
177
177
|
payed_with: str | None = None
|
|
178
178
|
fiskalyData: FiskalyData | None = None
|
|
179
179
|
price_domicile_service: Any | None = None
|
|
180
|
+
reservation_payment_amount: Any | None = None
|
|
180
181
|
price_per_person: str | None = None
|
|
181
182
|
is_rectified: bool = False
|
|
182
183
|
|
|
@@ -25,10 +25,12 @@ class ClientPrintFlow:
|
|
|
25
25
|
print_settings_builder: PrintSettingsBuilder,
|
|
26
26
|
currency_symbol_resolver: Callable[[str], str],
|
|
27
27
|
domicile_service_label: str,
|
|
28
|
+
reservation_payment_label: str,
|
|
28
29
|
):
|
|
29
30
|
self._gateway = gateway
|
|
30
31
|
self._currency_symbol_resolver = currency_symbol_resolver
|
|
31
32
|
self._domicile_service_label = domicile_service_label
|
|
33
|
+
self._reservation_payment_label = reservation_payment_label
|
|
32
34
|
self._context_builder = TicketContextBuilder(
|
|
33
35
|
header_provider=header_provider,
|
|
34
36
|
print_settings_builder=print_settings_builder,
|
|
@@ -74,6 +76,7 @@ class ClientPrintFlow:
|
|
|
74
76
|
ticket_builder = ClientTicketBuilder(
|
|
75
77
|
currency_symbol_resolver=self._currency_symbol_resolver,
|
|
76
78
|
domicile_service_label=self._domicile_service_label,
|
|
79
|
+
reservation_payment_label=self._reservation_payment_label,
|
|
77
80
|
)
|
|
78
81
|
return ticket_builder.build(
|
|
79
82
|
request=request,
|
|
@@ -10,7 +10,6 @@ from printer_core.entities import (
|
|
|
10
10
|
PrintProductData,
|
|
11
11
|
PrintRequestData,
|
|
12
12
|
PrinterData,
|
|
13
|
-
ProductsGroup,
|
|
14
13
|
)
|
|
15
14
|
from printer_core.ports import FamilyCategoryProvider, HeaderProvider, PrinterGateway, PrintSettingsBuilder
|
|
16
15
|
from printer_core.services.multi_printer_family_service import MultiPrinterFamilyService
|
|
@@ -74,7 +73,6 @@ class KitchenPrintFlow:
|
|
|
74
73
|
gateway=self._gateway,
|
|
75
74
|
currency_symbol_resolver=self._currency_symbol_resolver,
|
|
76
75
|
order_by_func=self._noop_order_by,
|
|
77
|
-
group_products_func=self._noop_group_products,
|
|
78
76
|
)
|
|
79
77
|
return service.build_and_dispatch(
|
|
80
78
|
request=request,
|
|
@@ -88,7 +86,6 @@ class KitchenPrintFlow:
|
|
|
88
86
|
family_provider=self._family_provider,
|
|
89
87
|
currency_symbol_resolver=self._currency_symbol_resolver,
|
|
90
88
|
order_by_func=self._noop_order_by,
|
|
91
|
-
group_products_func=self._noop_group_products,
|
|
92
89
|
)
|
|
93
90
|
return service.build_and_dispatch(
|
|
94
91
|
request=request,
|
|
@@ -108,6 +105,3 @@ class KitchenPrintFlow:
|
|
|
108
105
|
|
|
109
106
|
def _noop_order_by(self, products: list[KitchenProductLine]) -> list[KitchenProductLine]:
|
|
110
107
|
return products
|
|
111
|
-
|
|
112
|
-
def _noop_group_products(self, products: list[KitchenProductLine]) -> list[ProductsGroup]:
|
|
113
|
-
return [ProductsGroup(group="Sin orden", products=products)]
|
|
@@ -10,9 +10,11 @@ class UniqueTicketService:
|
|
|
10
10
|
self,
|
|
11
11
|
currency_symbol_resolver: Callable[[str], str],
|
|
12
12
|
domicile_service_label: str,
|
|
13
|
+
reservation_payment_label: str,
|
|
13
14
|
):
|
|
14
15
|
self._currency_symbol_resolver = currency_symbol_resolver
|
|
15
16
|
self._domicile_service_label = domicile_service_label
|
|
17
|
+
self._reservation_payment_label = reservation_payment_label
|
|
16
18
|
|
|
17
19
|
def build_payload(
|
|
18
20
|
self,
|
|
@@ -24,7 +26,9 @@ class UniqueTicketService:
|
|
|
24
26
|
) -> list[ClientTicketPayload]:
|
|
25
27
|
formatter = DiscountFormatter(currency_symbol_resolver=self._currency_symbol_resolver)
|
|
26
28
|
list_products_in_same_printers = ProductsModifiersUniqueTicket(
|
|
27
|
-
formatter,
|
|
29
|
+
formatter,
|
|
30
|
+
domicile_service_label=self._domicile_service_label,
|
|
31
|
+
reservation_payment_label=self._reservation_payment_label,
|
|
28
32
|
).build(request, products)
|
|
29
33
|
|
|
30
34
|
ticket_text = getattr(ticket_settings, "ticket_text", "")
|
|
@@ -78,6 +78,7 @@ def make_request(
|
|
|
78
78
|
all_discounted: bool = False,
|
|
79
79
|
discount: DiscountData | None = None,
|
|
80
80
|
price_domicile_service: str | None = None,
|
|
81
|
+
reservation_payment_amount: str | None = None,
|
|
81
82
|
**overrides: object,
|
|
82
83
|
) -> PrintRequestData:
|
|
83
84
|
payload = {
|
|
@@ -91,6 +92,7 @@ def make_request(
|
|
|
91
92
|
"all_discounted": all_discounted,
|
|
92
93
|
"discount": discount,
|
|
93
94
|
"price_domicile_service": price_domicile_service,
|
|
95
|
+
"reservation_payment_amount": reservation_payment_amount,
|
|
94
96
|
"command_guests": 2,
|
|
95
97
|
"table_name": "T1",
|
|
96
98
|
}
|
{printer_core-0.0.7 → printer_core-0.0.9}/printer_core/tests/unitaries/test_client_ticket_builder.py
RENAMED
|
@@ -77,6 +77,38 @@ class ClientTicketBuilderTest(unittest.TestCase):
|
|
|
77
77
|
self.assertEqual(payloads[0].data.products[-1].name, "Service")
|
|
78
78
|
self.assertEqual(payloads[0].data.products[-1].price, "2.00")
|
|
79
79
|
|
|
80
|
+
def test_build_adds_reservation_payment_line_when_label_is_configured(self):
|
|
81
|
+
builder = ClientTicketBuilder(reservation_payment_label="Reservation Payment")
|
|
82
|
+
request = make_request(reservation_payment_amount="3.50")
|
|
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.assertEqual(payloads[0].data.products[-1].name, "Reservation Payment")
|
|
94
|
+
self.assertEqual(payloads[0].data.products[-1].qty, 1)
|
|
95
|
+
self.assertEqual(payloads[0].data.products[-1].price, "3.50")
|
|
96
|
+
|
|
97
|
+
def test_build_does_not_add_reservation_payment_line_without_amount(self):
|
|
98
|
+
builder = ClientTicketBuilder(reservation_payment_label="Reservation Payment")
|
|
99
|
+
request = make_request()
|
|
100
|
+
products = [make_product()]
|
|
101
|
+
|
|
102
|
+
payloads = builder.build(
|
|
103
|
+
request=request,
|
|
104
|
+
products=products,
|
|
105
|
+
printer=make_printer(),
|
|
106
|
+
ticket_settings=make_ticket_settings(),
|
|
107
|
+
tpv_key="TPV1",
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
self.assertEqual(len(payloads[0].data.products), 1)
|
|
111
|
+
|
|
80
112
|
def test_build_does_not_serialize_rectified_flag_when_request_is_rectified(self):
|
|
81
113
|
builder = ClientTicketBuilder()
|
|
82
114
|
request = make_request(is_rectified=True)
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
import unittest
|
|
1
2
|
from unittest.mock import patch
|
|
2
3
|
|
|
3
|
-
import unittest
|
|
4
4
|
from printer_core.entities import PrintChannel
|
|
5
5
|
from printer_core.services.flows.client import ClientPrintFlow
|
|
6
6
|
from printer_core.services.flows.kitchen import KitchenPrintFlow
|
|
7
|
-
|
|
8
7
|
from printer_core.tests.unitaries.helpers import (
|
|
9
8
|
FakeGateway,
|
|
10
9
|
FakeHeaderProvider,
|
|
@@ -95,6 +94,36 @@ class ClientPrintFlowTest(unittest.TestCase):
|
|
|
95
94
|
payload = gateway.calls[0][1][0]
|
|
96
95
|
self.assertTrue(payload["data"]["is_invoice"])
|
|
97
96
|
|
|
97
|
+
def test_execute_adds_reservation_payment_line_when_label_is_configured(self):
|
|
98
|
+
gateway = FakeGateway()
|
|
99
|
+
flow = ClientPrintFlow(
|
|
100
|
+
gateway=gateway,
|
|
101
|
+
header_provider=FakeHeaderProvider(),
|
|
102
|
+
print_settings_builder=FakePrintSettingsBuilder(),
|
|
103
|
+
currency_symbol_resolver=lambda _: "",
|
|
104
|
+
domicile_service_label="Service",
|
|
105
|
+
reservation_payment_label="Reservation Payment",
|
|
106
|
+
)
|
|
107
|
+
context = type("Ctx", (), {
|
|
108
|
+
"kitchen_settings": make_kitchen_settings(),
|
|
109
|
+
"ticket_settings": make_ticket_settings(),
|
|
110
|
+
"main_printer": make_printer(),
|
|
111
|
+
"worker": None,
|
|
112
|
+
})()
|
|
113
|
+
|
|
114
|
+
flow.execute(
|
|
115
|
+
base_request=make_request(reservation_payment_amount="3.50"),
|
|
116
|
+
products=[make_product()],
|
|
117
|
+
context=context,
|
|
118
|
+
channel=PrintChannel.LOCAL,
|
|
119
|
+
tpv_key="TPV1",
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
payload = gateway.calls[0][1][0]
|
|
123
|
+
self.assertEqual(payload["data"]["products"][-1]["name"], "Reservation Payment")
|
|
124
|
+
self.assertEqual(payload["data"]["products"][-1]["qty"], 1)
|
|
125
|
+
self.assertEqual(payload["data"]["products"][-1]["price"], "3.50")
|
|
126
|
+
|
|
98
127
|
|
|
99
128
|
class KitchenPrintFlowTest(unittest.TestCase):
|
|
100
129
|
def test_execute_uses_multi_printer_service(self):
|
|
@@ -102,7 +131,7 @@ class KitchenPrintFlowTest(unittest.TestCase):
|
|
|
102
131
|
|
|
103
132
|
class DummyService:
|
|
104
133
|
def __init__(self, **kwargs):
|
|
105
|
-
|
|
134
|
+
captured["service_kwargs"] = kwargs
|
|
106
135
|
|
|
107
136
|
def build_and_dispatch(self, request, products, main_printer, ticket_settings, kitchen_ticket_settings):
|
|
108
137
|
captured["request"] = request
|
|
@@ -132,13 +161,14 @@ class KitchenPrintFlowTest(unittest.TestCase):
|
|
|
132
161
|
)
|
|
133
162
|
|
|
134
163
|
self.assertEqual(captured["request"].print_by, "categories")
|
|
164
|
+
self.assertNotIn("group_products_func", captured["service_kwargs"])
|
|
135
165
|
|
|
136
166
|
def test_execute_uses_family_service_and_skips_print_by(self):
|
|
137
167
|
captured = {}
|
|
138
168
|
|
|
139
169
|
class DummyFamilyService:
|
|
140
170
|
def __init__(self, **kwargs):
|
|
141
|
-
|
|
171
|
+
captured["service_kwargs"] = kwargs
|
|
142
172
|
|
|
143
173
|
def build_and_dispatch(self, request, products, main_printer, ticket_settings, kitchen_ticket_settings):
|
|
144
174
|
captured["request"] = request
|
|
@@ -168,3 +198,4 @@ class KitchenPrintFlowTest(unittest.TestCase):
|
|
|
168
198
|
)
|
|
169
199
|
|
|
170
200
|
self.assertIsNone(captured["request"].print_by)
|
|
201
|
+
self.assertNotIn("group_products_func", captured["service_kwargs"])
|
{printer_core-0.0.7 → printer_core-0.0.9}/printer_core/tests/unitaries/test_printer_helpers.py
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import unittest
|
|
1
2
|
from decimal import Decimal
|
|
2
3
|
|
|
3
|
-
import unittest
|
|
4
4
|
from printer_core.entities import KitchenProductLine
|
|
5
5
|
from printer_core.utils.printer_helpers import build_iva_data, group_products_by_orders, order_products_by_name
|
|
6
6
|
|
|
@@ -52,6 +52,14 @@ class PrinterHelpersTest(unittest.TestCase):
|
|
|
52
52
|
printer_w="80",
|
|
53
53
|
order="not-a-number",
|
|
54
54
|
),
|
|
55
|
+
KitchenProductLine(
|
|
56
|
+
name="E",
|
|
57
|
+
qty=1,
|
|
58
|
+
option=None,
|
|
59
|
+
printer_r="P1",
|
|
60
|
+
printer_w="80",
|
|
61
|
+
order="",
|
|
62
|
+
),
|
|
55
63
|
]
|
|
56
64
|
|
|
57
65
|
grouped = group_products_by_orders(products)
|
|
@@ -61,7 +69,7 @@ class PrinterHelpersTest(unittest.TestCase):
|
|
|
61
69
|
self.assertEqual(grouped[1].group, "Mesa 2")
|
|
62
70
|
self.assertEqual(grouped[1].products[0].order, "2")
|
|
63
71
|
self.assertEqual(grouped[2].group, "Sin orden")
|
|
64
|
-
self.assertEqual([item.name for item in grouped[2].products], ["C"])
|
|
72
|
+
self.assertEqual([item.name for item in grouped[2].products], ["C", "D", "E"])
|
|
65
73
|
|
|
66
74
|
def test_build_iva_data(self):
|
|
67
75
|
data = build_iva_data(Decimal("121.00"), Decimal("21"))
|
{printer_core-0.0.7 → printer_core-0.0.9}/printer_core/tests/unitaries/test_products_modifiers.py
RENAMED
|
@@ -91,6 +91,18 @@ class ProductsModifiersUniqueTicketTest(unittest.TestCase):
|
|
|
91
91
|
self.assertEqual(lines[-1].name, "Service")
|
|
92
92
|
self.assertEqual(lines[-1].price, "2.00")
|
|
93
93
|
|
|
94
|
+
def test_build_appends_reservation_payment_when_label_is_configured(self):
|
|
95
|
+
formatter = DiscountFormatter()
|
|
96
|
+
service = ProductsModifiersUniqueTicket(formatter, reservation_payment_label="Reservation Payment")
|
|
97
|
+
request = make_request(reservation_payment_amount="3.50")
|
|
98
|
+
product = make_product()
|
|
99
|
+
|
|
100
|
+
lines = service.build(request, [product])
|
|
101
|
+
|
|
102
|
+
self.assertEqual(lines[-1].name, "Reservation Payment")
|
|
103
|
+
self.assertEqual(lines[-1].qty, 1)
|
|
104
|
+
self.assertEqual(lines[-1].price, "3.50")
|
|
105
|
+
|
|
94
106
|
def test_build_respects_all_discounted(self):
|
|
95
107
|
formatter = DiscountFormatter()
|
|
96
108
|
service = ProductsModifiersUniqueTicket(formatter)
|
|
@@ -13,21 +13,24 @@ def group_products_by_orders(products: list[KitchenProductLine]) -> list[Product
|
|
|
13
13
|
dict_aux: dict[int, ProductsGroup] = {}
|
|
14
14
|
array_without_order: list[KitchenProductLine] = []
|
|
15
15
|
for product in products:
|
|
16
|
-
if product.order
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
dict_aux[order_id] = ProductsGroup(
|
|
24
|
-
group=product.order_readable or "",
|
|
25
|
-
products=[product],
|
|
26
|
-
)
|
|
27
|
-
except ValueError:
|
|
28
|
-
continue
|
|
29
|
-
else:
|
|
16
|
+
if product.order in (None, ""):
|
|
17
|
+
array_without_order.append(product)
|
|
18
|
+
continue
|
|
19
|
+
|
|
20
|
+
try:
|
|
21
|
+
order_id = int(product.order)
|
|
22
|
+
except ValueError:
|
|
30
23
|
array_without_order.append(product)
|
|
24
|
+
continue
|
|
25
|
+
|
|
26
|
+
product = product.model_copy(update={"order": str(order_id)})
|
|
27
|
+
if order_id in dict_aux:
|
|
28
|
+
dict_aux[order_id].products.append(product)
|
|
29
|
+
else:
|
|
30
|
+
dict_aux[order_id] = ProductsGroup(
|
|
31
|
+
group=product.order_readable or "",
|
|
32
|
+
products=[product],
|
|
33
|
+
)
|
|
31
34
|
|
|
32
35
|
ordered_dict = OrderedDict(sorted(dict_aux.items()))
|
|
33
36
|
list_of_ordered_values: list[ProductsGroup] = list(ordered_dict.values())
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{printer_core-0.0.7 → printer_core-0.0.9}/printer_core/algorithms/products_modifiers_multiprinter.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{printer_core-0.0.7 → printer_core-0.0.9}/printer_core/builders/kitchen_ticket_payload_builder.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{printer_core-0.0.7 → printer_core-0.0.9}/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
|
{printer_core-0.0.7 → printer_core-0.0.9}/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
|
{printer_core-0.0.7 → printer_core-0.0.9}/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.7 → printer_core-0.0.9}/printer_core/tests/unitaries/test_march_printer_service.py
RENAMED
|
File without changes
|
|
File without changes
|
{printer_core-0.0.7 → printer_core-0.0.9}/printer_core/tests/unitaries/test_multi_printer_service.py
RENAMED
|
File without changes
|
{printer_core-0.0.7 → printer_core-0.0.9}/printer_core/tests/unitaries/test_order_print_service.py
RENAMED
|
File without changes
|
{printer_core-0.0.7 → printer_core-0.0.9}/printer_core/tests/unitaries/test_payload_dispatcher.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{printer_core-0.0.7 → printer_core-0.0.9}/printer_core/tests/unitaries/test_unique_ticket_service.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|