feat: the bobbin footer names the customer and counts the pieces, without price (Rodada 5, C3)

DROPSTAR · Pedido DTF-7 · <cliente> · Item 1/2 · data · metros · N peças
(loose arts) or N cópias (a ready sheet repeated). The name is tidied to
cp1252 and cut at 24 characters; the proof footer is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-30 11:13:48 -03:00
parent 7fc091a1bd
commit f739c9d4e4
3 changed files with 68 additions and 10 deletions

View File

@@ -129,7 +129,7 @@ class PrintFileTests(unittest.TestCase):
job = {'snapshot': {'items': [spec, spec]}, 'number': 7, 'item_index': 1,
'ordered_at': datetime(2026, 10, 23, 15, 0, tzinfo=timezone.utc)}
line = footer(job, spec)
self.assertEqual(line, 'DROPSTAR · Pedido DTF-7 · Item 2/2 · 23/10/2026 · 1,00 m · ESPELHADO')
self.assertEqual(line, 'DROPSTAR · Pedido DTF-7 · Item 2/2 · 23/10/2026 · 1,00 m · 1 peça · ESPELHADO')
self.assertIn(b'/F1 31 Tf ( \xb7 ESPELHADO) Tj', footer_commands(line, (100, 80)))
# About 1 cm tall on the 57 cm film (Dropstar, 2026-10-28); on the 27 cm UV
# the line shrinks to fit the width instead of running off the film.
@@ -149,6 +149,35 @@ class PrintFileTests(unittest.TestCase):
self.assertEqual(file_prefix(130, 0, 2), 'DTF-130-v2-item-1')
self.assertEqual(file_prefix(130, 0, 1), 'DTF-130-item-1')
def test_the_footer_names_the_customer_and_the_pieces(self):
from datetime import datetime, timezone
from app.printjobs import footer
def line(name, spec, items=2):
customer = {} if name is None else {'name': name}
job = {'snapshot': {'items': [spec] * items, 'customer': customer},
'number': 7, 'item_index': 0,
'ordered_at': datetime(2026, 10, 21, 15, 0, tzinfo=timezone.utc)}
return footer(job, spec)
spec = item([placement(0, 0, 20, 10)], [source(20, 10)], 10)
start = 'DROPSTAR · Pedido DTF-7 · '
end = ' · Item 1/2 · 21/10/2026 · 1,00 m · 1 peça'
# An accent stays; an emoji does not; a long name is cut with an ellipsis.
self.assertEqual(line('Gráfica São José', spec), start + 'Gráfica São José' + end)
self.assertEqual(line('Loja 🌟 Azul', spec), start + 'Loja Azul' + end)
self.assertEqual(line('Gráfica São José do Vale do Paraíba', spec),
start + 'Gráfica São José do Val…' + end)
# Without a name the field is left out, with no stray separator.
self.assertEqual(line(None, spec), 'DROPSTAR · Pedido DTF-7' + end)
# A ready sheet counts its copies, and only says so above one.
sheet = item([placement(0, 0, 20, 10)], [{**source(20, 10), 'kind': 'sheet', 'copies': 3}], 10)
self.assertEqual(line('Cliente', sheet),
'DROPSTAR · Pedido DTF-7 · Cliente · Item 1/2 · 21/10/2026 · 1,00 m · 3 cópias')
single = item([placement(0, 0, 20, 10)], [{**source(20, 10), 'kind': 'sheet', 'copies': 1}], 10)
self.assertEqual(line('Cliente', single),
'DROPSTAR · Pedido DTF-7 · Cliente · Item 1/2 · 21/10/2026 · 1,00 m')
def test_jpeg_bytes_are_embedded_unchanged(self):
path = self.save(quadrants(), 'a.jpg', quality=90)
pdf, _ = self.render(item([placement(0, 0, 20, 10)], [source(20, 10)], 10), [path])