printer-core 1.0.0__tar.gz → 1.0.2__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-1.0.0 → printer_core-1.0.2}/PKG-INFO +1 -1
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/algorithms/products_modifiers_multiprinter.py +7 -2
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/algorithms/products_modifiers_multiprinter_family.py +6 -1
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/algorithms/products_modifiers_unique_ticket.py +11 -2
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/builders/client_ticket_builder.py +11 -2
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/entities/print_models.py +1 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/services/multi_printer_family_service.py +11 -3
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/services/multi_printer_service.py +6 -2
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/services/order_print_service.py +5 -1
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/services/unique_ticket_service.py +5 -1
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/tests/unitaries/helpers.py +4 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/tests/unitaries/test_client_ticket_builder.py +25 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/tests/unitaries/test_order_print_service.py +2 -1
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/tests/unitaries/test_printer_helpers.py +2 -1
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/tests/unitaries/test_products_modifiers.py +52 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/utils/printer_helpers.py +2 -2
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/utils/product_price_presenter.py +9 -6
- {printer_core-1.0.0 → printer_core-1.0.2}/pyproject.toml +1 -1
- {printer_core-1.0.0 → printer_core-1.0.2}/.gitignore +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/README.md +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/__init__.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/algorithms/__init__.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/builders/__init__.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/builders/header_builder.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/builders/kitchen_ticket_payload_builder.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/builders/printer_products_grouper.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/clock.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/context/__init__.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/context/ticket_context_builder.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/dispatchers/__init__.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/dispatchers/kitchen_ticket_dispatcher.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/dispatchers/payload_dispatcher.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/entities/__init__.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/entities/print_context.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/formatters/__init__.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/formatters/discount_formatter.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/ports.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/selectors/__init__.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/selectors/family_product_selector.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/services/__init__.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/services/flows/__init__.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/services/flows/base.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/services/flows/client.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/services/flows/kitchen.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/services/march_printer_service.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/services/print_policy.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/tests/__init__.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/tests/unitaries/__init__.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/tests/unitaries/test_cases_output.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/tests/unitaries/test_discount_formatter.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/tests/unitaries/test_family_product_selector.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/tests/unitaries/test_flows.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/tests/unitaries/test_header_builder_foodeo_printers.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/tests/unitaries/test_kitchen_ticket_dispatcher.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/tests/unitaries/test_kitchen_ticket_payload_builder.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/tests/unitaries/test_march_printer_service.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/tests/unitaries/test_multi_printer_family_service.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/tests/unitaries/test_multi_printer_service.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/tests/unitaries/test_payload_dispatcher.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/tests/unitaries/test_print_policy.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/tests/unitaries/test_printer_products_grouper.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/tests/unitaries/test_ticket_context_builder.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/tests/unitaries/test_unique_ticket_service.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/printer_core/utils/__init__.py +0 -0
- {printer_core-1.0.0 → printer_core-1.0.2}/scripts/link_backend_env.sh +0 -0
{printer_core-1.0.0 → printer_core-1.0.2}/printer_core/algorithms/products_modifiers_multiprinter.py
RENAMED
|
@@ -14,13 +14,18 @@ class ProductsModifiersMultiPrinter:
|
|
|
14
14
|
request: PrintRequestData,
|
|
15
15
|
products: list[PrintProductData],
|
|
16
16
|
kitchen_ticket_settings: Any,
|
|
17
|
-
|
|
17
|
+
main_printer: PrinterData | dict[str, Any] | None,
|
|
18
|
+
show_options_price: bool = True,
|
|
18
19
|
) -> list[KitchenProductLine]:
|
|
19
20
|
list_products_own_printer: list[KitchenProductLine] = []
|
|
20
21
|
for product in products:
|
|
21
22
|
if product.printer == []:
|
|
22
23
|
continue
|
|
23
|
-
displayed_product, displayed_price = prepare_product_price(
|
|
24
|
+
displayed_product, displayed_price = prepare_product_price(
|
|
25
|
+
request,
|
|
26
|
+
product,
|
|
27
|
+
show_options_price=show_options_price,
|
|
28
|
+
)
|
|
24
29
|
printers = product.printer
|
|
25
30
|
if printers is None:
|
|
26
31
|
if main_printer is None:
|
|
@@ -14,8 +14,13 @@ class ProductsModifiersMultiprinterFamily:
|
|
|
14
14
|
product: PrintProductData,
|
|
15
15
|
request: PrintRequestData,
|
|
16
16
|
kitchen_ticket_settings: Any,
|
|
17
|
+
show_options_price: bool = True,
|
|
17
18
|
) -> None:
|
|
18
|
-
displayed_product, displayed_price = prepare_product_price(
|
|
19
|
+
displayed_product, displayed_price = prepare_product_price(
|
|
20
|
+
request,
|
|
21
|
+
product,
|
|
22
|
+
show_options_price=show_options_price,
|
|
23
|
+
)
|
|
19
24
|
for actual_printer in product.printer or []:
|
|
20
25
|
printer_payload = self._resolve_printer(actual_printer)
|
|
21
26
|
name_with_discount: str = displayed_product.product_name
|
|
@@ -14,10 +14,19 @@ class ProductsModifiersUniqueTicket:
|
|
|
14
14
|
self._domicile_service_label = domicile_service_label
|
|
15
15
|
self._reservation_payment_label = reservation_payment_label
|
|
16
16
|
|
|
17
|
-
def build(
|
|
17
|
+
def build(
|
|
18
|
+
self,
|
|
19
|
+
request: PrintRequestData,
|
|
20
|
+
products: list[PrintProductData],
|
|
21
|
+
show_options_price: bool = True,
|
|
22
|
+
) -> list[ClientTicketProduct]:
|
|
18
23
|
list_products_in_same_printers: list[ClientTicketProduct] = []
|
|
19
24
|
for product in products:
|
|
20
|
-
displayed_product, displayed_price = prepare_product_price(
|
|
25
|
+
displayed_product, displayed_price = prepare_product_price(
|
|
26
|
+
request,
|
|
27
|
+
product,
|
|
28
|
+
show_options_price=show_options_price,
|
|
29
|
+
)
|
|
21
30
|
with_discount = ""
|
|
22
31
|
if not request.all_discounted:
|
|
23
32
|
with_discount = self._formatter.format(displayed_product, request.currency or "")
|
|
@@ -40,7 +40,11 @@ class ClientTicketBuilder:
|
|
|
40
40
|
client_request = ClientTicketData(
|
|
41
41
|
**request.model_dump(exclude={"products", "ticket_text", "is_rectified"}),
|
|
42
42
|
ticket_text=ticket_text,
|
|
43
|
-
products=self._build_products(
|
|
43
|
+
products=self._build_products(
|
|
44
|
+
request,
|
|
45
|
+
products,
|
|
46
|
+
show_options_price=self._get_attr(ticket_settings, "show_options_price", False),
|
|
47
|
+
),
|
|
44
48
|
)
|
|
45
49
|
|
|
46
50
|
if client_request.type in ["domicilio", "recoger"]:
|
|
@@ -66,11 +70,16 @@ class ClientTicketBuilder:
|
|
|
66
70
|
self,
|
|
67
71
|
request: PrintRequestData,
|
|
68
72
|
products: list[PrintProductData],
|
|
73
|
+
show_options_price: bool = True,
|
|
69
74
|
) -> list[ClientTicketProduct]:
|
|
70
75
|
list_products: list[ClientTicketProduct] = []
|
|
71
76
|
currency_symbol = self._currency_symbol_resolver(request.currency or "")
|
|
72
77
|
for product in products:
|
|
73
|
-
displayed_product, displayed_price = prepare_product_price(
|
|
78
|
+
displayed_product, displayed_price = prepare_product_price(
|
|
79
|
+
request,
|
|
80
|
+
product,
|
|
81
|
+
show_options_price=show_options_price,
|
|
82
|
+
)
|
|
74
83
|
with_discount = ""
|
|
75
84
|
if not request.all_discounted:
|
|
76
85
|
with_discount = self._format_discount(displayed_product, currency_symbol)
|
{printer_core-1.0.0 → printer_core-1.0.2}/printer_core/services/multi_printer_family_service.py
RENAMED
|
@@ -38,7 +38,7 @@ class MultiPrinterFamilyService:
|
|
|
38
38
|
self,
|
|
39
39
|
request: PrintRequestData,
|
|
40
40
|
products: list[PrintProductData],
|
|
41
|
-
|
|
41
|
+
main_printer: PrinterData | None,
|
|
42
42
|
ticket_settings: Any,
|
|
43
43
|
kitchen_ticket_settings: Any,
|
|
44
44
|
) -> list[KitchenTicketPayload]:
|
|
@@ -58,7 +58,11 @@ class MultiPrinterFamilyService:
|
|
|
58
58
|
if product_with_printer is None:
|
|
59
59
|
continue
|
|
60
60
|
family_builder.append_product(
|
|
61
|
-
list_products_own_printer,
|
|
61
|
+
list_products_own_printer,
|
|
62
|
+
product_with_printer,
|
|
63
|
+
request,
|
|
64
|
+
kitchen_ticket_settings,
|
|
65
|
+
show_options_price=getattr(ticket_settings, "show_options_price", False),
|
|
62
66
|
)
|
|
63
67
|
dispatched.extend(self._dispatch_products(
|
|
64
68
|
list_products_own_printer, request, ticket_settings, kitchen_ticket_settings
|
|
@@ -70,7 +74,11 @@ class MultiPrinterFamilyService:
|
|
|
70
74
|
if product_with_printer is None:
|
|
71
75
|
continue
|
|
72
76
|
family_builder.append_product(
|
|
73
|
-
list_products_own_printer,
|
|
77
|
+
list_products_own_printer,
|
|
78
|
+
product_with_printer,
|
|
79
|
+
request,
|
|
80
|
+
kitchen_ticket_settings,
|
|
81
|
+
show_options_price=getattr(ticket_settings, "show_options_price", False),
|
|
74
82
|
)
|
|
75
83
|
|
|
76
84
|
dispatched.extend(self._dispatch_products(
|
|
@@ -27,13 +27,17 @@ class MultiPrinterService:
|
|
|
27
27
|
self,
|
|
28
28
|
request: PrintRequestData,
|
|
29
29
|
products: list[PrintProductData],
|
|
30
|
-
|
|
30
|
+
main_printer: PrinterData | None,
|
|
31
31
|
ticket_settings: Any,
|
|
32
32
|
kitchen_ticket_settings: Any,
|
|
33
33
|
) -> list[KitchenTicketPayload]:
|
|
34
34
|
formatter = DiscountFormatter(currency_symbol_resolver=self._currency_symbol_resolver)
|
|
35
35
|
list_products_own_printer = ProductsModifiersMultiPrinter(formatter).build(
|
|
36
|
-
request,
|
|
36
|
+
request,
|
|
37
|
+
products,
|
|
38
|
+
kitchen_ticket_settings,
|
|
39
|
+
main_printer,
|
|
40
|
+
show_options_price=getattr(ticket_settings, "show_options_price", False),
|
|
37
41
|
)
|
|
38
42
|
|
|
39
43
|
if (request.order_by or "standard") == "name":
|
|
@@ -74,7 +74,11 @@ class OrderPrintService:
|
|
|
74
74
|
enriched = enriched.model_copy(update={"currency": context.global_settings.currency})
|
|
75
75
|
|
|
76
76
|
total, enriched = self._compute_total(channel, enriched)
|
|
77
|
-
iva_data = build_iva_data(
|
|
77
|
+
iva_data = build_iva_data(
|
|
78
|
+
total,
|
|
79
|
+
Decimal(str(context.global_settings.iva)),
|
|
80
|
+
getattr(context.global_settings, "iva_name", "IVA"),
|
|
81
|
+
)
|
|
78
82
|
enriched = enriched.model_copy(update={"total": str(total), "ivaData": iva_data})
|
|
79
83
|
return enriched
|
|
80
84
|
|
|
@@ -29,7 +29,11 @@ class UniqueTicketService:
|
|
|
29
29
|
formatter,
|
|
30
30
|
domicile_service_label=self._domicile_service_label,
|
|
31
31
|
reservation_payment_label=self._reservation_payment_label,
|
|
32
|
-
).build(
|
|
32
|
+
).build(
|
|
33
|
+
request,
|
|
34
|
+
products,
|
|
35
|
+
show_options_price=getattr(ticket_settings, "show_options_price", False),
|
|
36
|
+
)
|
|
33
37
|
|
|
34
38
|
ticket_text = getattr(ticket_settings, "ticket_text", "")
|
|
35
39
|
qty_client_ticket = getattr(ticket_settings, "qty_client_ticket", 1)
|
|
@@ -144,6 +144,7 @@ def make_ticket_settings(
|
|
|
144
144
|
qty_kitchen_ticket: int = 1,
|
|
145
145
|
qty_client_ticket: int = 1,
|
|
146
146
|
ticket_text: str = "",
|
|
147
|
+
show_options_price: bool = True,
|
|
147
148
|
**overrides: object,
|
|
148
149
|
) -> SimpleNamespace:
|
|
149
150
|
payload = {
|
|
@@ -151,6 +152,7 @@ def make_ticket_settings(
|
|
|
151
152
|
"qty_kitchen_ticket": qty_kitchen_ticket,
|
|
152
153
|
"qty_client_ticket": qty_client_ticket,
|
|
153
154
|
"ticket_text": ticket_text,
|
|
155
|
+
"show_options_price": show_options_price,
|
|
154
156
|
}
|
|
155
157
|
payload.update(overrides)
|
|
156
158
|
return SimpleNamespace(**payload)
|
|
@@ -179,6 +181,7 @@ def make_kitchen_settings(
|
|
|
179
181
|
def make_global_settings(
|
|
180
182
|
currency: str | None = "EUR",
|
|
181
183
|
iva: int = 21,
|
|
184
|
+
iva_name: str = "IVA",
|
|
182
185
|
use_payment_terminal: bool = False,
|
|
183
186
|
use_cashmatic: bool = False,
|
|
184
187
|
use_cashlogy: bool = False,
|
|
@@ -186,6 +189,7 @@ def make_global_settings(
|
|
|
186
189
|
return SimpleNamespace(
|
|
187
190
|
currency=currency,
|
|
188
191
|
iva=iva,
|
|
192
|
+
iva_name=iva_name,
|
|
189
193
|
use_payment_terminal=use_payment_terminal,
|
|
190
194
|
use_cashmatic=use_cashmatic,
|
|
191
195
|
use_cashlogy=use_cashlogy,
|
{printer_core-1.0.0 → printer_core-1.0.2}/printer_core/tests/unitaries/test_client_ticket_builder.py
RENAMED
|
@@ -121,6 +121,31 @@ class ClientTicketBuilderTest(unittest.TestCase):
|
|
|
121
121
|
self.assertEqual(printed.price, "10.00")
|
|
122
122
|
self.assertEqual(printed.option[0]["price"], "5.00")
|
|
123
123
|
|
|
124
|
+
def test_hidden_option_prices_use_product_total_without_mutating_input(self):
|
|
125
|
+
product = make_product(
|
|
126
|
+
total_price="15.00",
|
|
127
|
+
importe="10.00",
|
|
128
|
+
option=[{
|
|
129
|
+
"name": "Extra queso",
|
|
130
|
+
"qty": 1,
|
|
131
|
+
"price": "5.00",
|
|
132
|
+
"unitary_price": "5.00",
|
|
133
|
+
}],
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
printed = ClientTicketBuilder().build(
|
|
137
|
+
request=make_request(),
|
|
138
|
+
products=[product],
|
|
139
|
+
printer=make_printer(),
|
|
140
|
+
ticket_settings=make_ticket_settings(show_options_price=False),
|
|
141
|
+
tpv_key="TPV1",
|
|
142
|
+
)[0].data.products[0]
|
|
143
|
+
|
|
144
|
+
self.assertEqual(printed.price, "15.00")
|
|
145
|
+
self.assertIsNone(printed.option[0]["price"])
|
|
146
|
+
self.assertIsNone(printed.option[0]["unitary_price"])
|
|
147
|
+
self.assertEqual(product.option[0]["price"], "5.00")
|
|
148
|
+
|
|
124
149
|
def test_build_adds_domicile_service_line(self):
|
|
125
150
|
builder = ClientTicketBuilder(domicile_service_label="Service")
|
|
126
151
|
request = make_request(request_type="domicilio", price_domicile_service="2.00")
|
{printer_core-1.0.0 → printer_core-1.0.2}/printer_core/tests/unitaries/test_order_print_service.py
RENAMED
|
@@ -48,7 +48,7 @@ class OrderPrintServiceTest(unittest.TestCase):
|
|
|
48
48
|
context = type("Ctx", (), {
|
|
49
49
|
"ticket_settings": make_ticket_settings(ticket_kitchen_local=True, ticket_client_local=True),
|
|
50
50
|
"kitchen_settings": make_kitchen_settings(print_by="categories"),
|
|
51
|
-
"global_settings": make_global_settings(currency="EUR", iva=21),
|
|
51
|
+
"global_settings": make_global_settings(currency="EUR", iva=21, iva_name="VAT"),
|
|
52
52
|
})()
|
|
53
53
|
|
|
54
54
|
result = service.print_job(job, context, PrintChannel.LOCAL)
|
|
@@ -60,6 +60,7 @@ class OrderPrintServiceTest(unittest.TestCase):
|
|
|
60
60
|
self.assertEqual(enriched.currency, "EUR")
|
|
61
61
|
self.assertEqual(enriched.price_domicile_service, None)
|
|
62
62
|
self.assertIsNotNone(enriched.ivaData)
|
|
63
|
+
self.assertEqual(enriched.ivaData.iva_name, "VAT")
|
|
63
64
|
|
|
64
65
|
def test_print_job_domicile_total_includes_service_price(self):
|
|
65
66
|
kitchen_flow = FakeFlow(FlowTarget.KITCHEN, return_value=[])
|
{printer_core-1.0.0 → printer_core-1.0.2}/printer_core/tests/unitaries/test_printer_helpers.py
RENAMED
|
@@ -72,8 +72,9 @@ class PrinterHelpersTest(unittest.TestCase):
|
|
|
72
72
|
self.assertEqual([item.name for item in grouped[2].products], ["C", "D", "E"])
|
|
73
73
|
|
|
74
74
|
def test_build_iva_data(self):
|
|
75
|
-
data = build_iva_data(Decimal("121.00"), Decimal("21"))
|
|
75
|
+
data = build_iva_data(Decimal("121.00"), Decimal("21"), "VAT")
|
|
76
76
|
|
|
77
77
|
self.assertEqual(data.Base, "100.00")
|
|
78
78
|
self.assertEqual(data.impo, "21.00")
|
|
79
79
|
self.assertEqual(data.iva, "21")
|
|
80
|
+
self.assertEqual(data.iva_name, "VAT")
|
{printer_core-1.0.0 → printer_core-1.0.2}/printer_core/tests/unitaries/test_products_modifiers.py
RENAMED
|
@@ -87,6 +87,31 @@ class ProductsModifiersMultiPrinterTest(unittest.TestCase):
|
|
|
87
87
|
self.assertEqual(line.option[0]["price"], None)
|
|
88
88
|
self.assertEqual(line.option[0]["unitary_price"], None)
|
|
89
89
|
|
|
90
|
+
def test_hidden_option_prices_use_total_in_category_kitchen_line(self):
|
|
91
|
+
service = ProductsModifiersMultiPrinter(DiscountFormatter())
|
|
92
|
+
product = make_product(
|
|
93
|
+
total_price="15.00",
|
|
94
|
+
importe="10.00",
|
|
95
|
+
option=[{
|
|
96
|
+
"name": "Extra queso",
|
|
97
|
+
"qty": 1,
|
|
98
|
+
"price": "5.00",
|
|
99
|
+
"unitary_price": "5.00",
|
|
100
|
+
}],
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
line = service.build(
|
|
104
|
+
make_request(),
|
|
105
|
+
[product],
|
|
106
|
+
make_kitchen_settings(show_price_per_unit=True),
|
|
107
|
+
make_printer(),
|
|
108
|
+
show_options_price=False,
|
|
109
|
+
)[0]
|
|
110
|
+
|
|
111
|
+
self.assertEqual(line.price, "15.00")
|
|
112
|
+
self.assertIsNone(line.option[0]["price"])
|
|
113
|
+
self.assertIsNone(line.option[0]["unitary_price"])
|
|
114
|
+
|
|
90
115
|
|
|
91
116
|
class ProductsModifiersMultiprinterFamilyTest(unittest.TestCase):
|
|
92
117
|
def test_append_product_adds_lines(self):
|
|
@@ -148,6 +173,33 @@ class ProductsModifiersMultiprinterFamilyTest(unittest.TestCase):
|
|
|
148
173
|
self.assertEqual(lines[0].option[0]["price"], None)
|
|
149
174
|
self.assertEqual(lines[0].option[0]["unitary_price"], None)
|
|
150
175
|
|
|
176
|
+
def test_hidden_option_prices_use_total_in_family_kitchen_line(self):
|
|
177
|
+
service = ProductsModifiersMultiprinterFamily(DiscountFormatter())
|
|
178
|
+
product = make_product(
|
|
179
|
+
printer=[make_printer()],
|
|
180
|
+
total_price="15.00",
|
|
181
|
+
importe="10.00",
|
|
182
|
+
option=[{
|
|
183
|
+
"name": "Extra queso",
|
|
184
|
+
"qty": 1,
|
|
185
|
+
"price": "5.00",
|
|
186
|
+
"unitary_price": "5.00",
|
|
187
|
+
}],
|
|
188
|
+
)
|
|
189
|
+
lines = []
|
|
190
|
+
|
|
191
|
+
service.append_product(
|
|
192
|
+
lines,
|
|
193
|
+
product,
|
|
194
|
+
make_request(),
|
|
195
|
+
make_kitchen_settings(show_price_per_unit=True),
|
|
196
|
+
show_options_price=False,
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
self.assertEqual(lines[0].price, "15.00")
|
|
200
|
+
self.assertIsNone(lines[0].option[0]["price"])
|
|
201
|
+
self.assertIsNone(lines[0].option[0]["unitary_price"])
|
|
202
|
+
|
|
151
203
|
|
|
152
204
|
class ProductsModifiersUniqueTicketTest(unittest.TestCase):
|
|
153
205
|
def test_build_appends_domicile_service(self):
|
|
@@ -38,8 +38,8 @@ def group_products_by_orders(products: list[KitchenProductLine]) -> list[Product
|
|
|
38
38
|
return list_of_ordered_values
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
def build_iva_data(total: Decimal, iva: Decimal) -> IvaData:
|
|
41
|
+
def build_iva_data(total: Decimal, iva: Decimal, iva_name: str = "IVA") -> IvaData:
|
|
42
42
|
aa: Decimal = Decimal(total)
|
|
43
43
|
iva_value: Decimal = Decimal(str(iva))
|
|
44
44
|
base: Decimal = Decimal(aa / (1 + iva_value / 100)).quantize(Decimal(".01"))
|
|
45
|
-
return IvaData(Base=str(base), impo=str(aa - base), iva=str(iva_value))
|
|
45
|
+
return IvaData(Base=str(base), impo=str(aa - base), iva=str(iva_value), iva_name=iva_name)
|
|
@@ -8,9 +8,13 @@ from printer_core.entities import PrintProductData, PrintRequestData
|
|
|
8
8
|
def prepare_product_price(
|
|
9
9
|
request: PrintRequestData,
|
|
10
10
|
product: PrintProductData,
|
|
11
|
+
show_options_price: bool = True,
|
|
11
12
|
) -> tuple[PrintProductData, Any]:
|
|
12
13
|
"""Return a display copy and its total without mutating print-job data."""
|
|
13
|
-
|
|
14
|
+
has_individual_discount = bool(
|
|
15
|
+
not request.all_discounted and product.discount and product.discount_type
|
|
16
|
+
)
|
|
17
|
+
if show_options_price and not has_individual_discount:
|
|
14
18
|
return product, product.importe
|
|
15
19
|
|
|
16
20
|
options = deepcopy(product.option)
|
|
@@ -24,9 +28,8 @@ def prepare_product_price(
|
|
|
24
28
|
option["price"] = None
|
|
25
29
|
option["unitary_price"] = None
|
|
26
30
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"importe"
|
|
30
|
-
|
|
31
|
-
})
|
|
31
|
+
update = {"option": options}
|
|
32
|
+
if has_individual_discount:
|
|
33
|
+
update["importe"] = Decimal(str(product.importe or 0)) + options_total
|
|
34
|
+
presented = product.model_copy(update=update)
|
|
32
35
|
return presented, product.total_price
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{printer_core-1.0.0 → printer_core-1.0.2}/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-1.0.0 → printer_core-1.0.2}/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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{printer_core-1.0.0 → printer_core-1.0.2}/printer_core/tests/unitaries/test_discount_formatter.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{printer_core-1.0.0 → printer_core-1.0.2}/printer_core/tests/unitaries/test_march_printer_service.py
RENAMED
|
File without changes
|
|
File without changes
|
{printer_core-1.0.0 → printer_core-1.0.2}/printer_core/tests/unitaries/test_multi_printer_service.py
RENAMED
|
File without changes
|
{printer_core-1.0.0 → printer_core-1.0.2}/printer_core/tests/unitaries/test_payload_dispatcher.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{printer_core-1.0.0 → printer_core-1.0.2}/printer_core/tests/unitaries/test_unique_ticket_service.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|