feat: a ready sheet prints at its real size, centred on the film, with the customer's confirmation (Marcus, 2026-12-02)
All checks were successful
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 7m55s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 1m43s

Replaces 7111995 (only 57,0 cm entered; a whole order of 56,5-56,9 cm
sheets was refused, DTF-WEB-2C). Marcus's rules, for Arquivo por metro,
Premium (57 cm) and UV (27 cm):
1. A known width up to the film (PNG recording 200 DPI or more, or a PDF
   page) enters at its real size, centred, billed by its real height.
2. Narrower: his warning before the cart, confirmation required
   (Imprimir no tamanho real / Enviar outro arquivo); recorded in the
   Prumo report ("cliente confirmou folha de 35,8 cm no tamanho real") and
   shown in the cart and payment summaries.
3. Wider than the film: refused with his message.
4. Unknown width: taken as the film's, DPI from the pixels; 200 or more
   with a confirmation, under 200 refused with the artes avulsas hint.
Within 0,1 cm of the film counts as the film. The server checks it all
again at checkout (sheet_width_issue, centred placement, size_confirmed).

Also ops.stretched_sheets: the ready-sheet orders since 16/10 laid out
wider than their real width (number, real width, factor), for Marcus.
Contract: output/revisao/contrato-folha-real.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-12-02 09:51:38 -03:00
parent 7af6c9797d
commit 41126a42fd
22 changed files with 634 additions and 153 deletions

View File

@@ -324,15 +324,15 @@ def proportion_issue(files, items, rows):
return None
# A ready sheet in the 57 cm textile products must be 57 cm wide where its real
# width is known (Marcus, 2026-12-01: a pop-up on upload and refused, narrower
# or wider). Known means a PNG whose pHYs records TRUSTED_DPI or more (the A1
# threshold, rodada 5) or a PDF page; anything else keeps the v0 rule (the
# image stretched to the film). output/revisao/contrato-largura-folha.md;
# the Site has the same numbers (web/site-config.js LARGURA_EXATA).
EXACT_SHEET_WIDTH_CM = {'file': 57.0, 'premium': 57.0}
# A ready sheet prints at its real size, centred on the film (Marcus,
# 2026-12-02, output/revisao/contrato-folha-real.md). Its width is known for a
# PNG whose pHYs records TRUSTED_DPI or more (the A1 threshold, rodada 5) and
# for a PDF page; otherwise it is taken as the film's, and its DPI is the
# pixels over that width. The Site has the same numbers (web/site-config.js).
SHEET_FILM_CM = {'file': 57.0, 'premium': 57.0, 'uvfile': 27.0}
SHEET_WIDTH_TOLERANCE_CM = 0.1
TRUSTED_DPI = 200
SHEET_MIN_DPI = 200
def png_saved_dpi(head):
@@ -363,45 +363,72 @@ def png_saved_dpi(head):
def sheet_width_issue(files, items, rows):
"""Why a cart cannot be approved: a ready sheet of a 57 cm textile item
(EXACT_SHEET_WIDTH_CM) whose real width is off by more than
SHEET_WIDTH_TOLERANCE_CM, or None. A PNG's real width is its pixels ÷ its
pHYs DPI × 2.54 when that DPI is TRUSTED_DPI or more; a PDF's is the
source's width_cm (the page the Site measured). Anything else passes."""
"""Why a cart cannot be approved, or None, for each ready sheet of an item
in SHEET_FILM_CM (contrato-folha-real.md, Server V1–V5): a known width
wider than the film, a source width_cm other than the known width (a
stretched sheet), a narrower known width or an unknown one without
size_confirmed, or an unknown width whose effective DPI is under
SHEET_MIN_DPI. measurement 'customer' sources pass."""
def cm(value):
return f'{value:.1f}'.replace('.', ',')
def film_text(value):
return f'{value:.0f}' if value == int(value) else cm(value)
for index, item in enumerate(items, 1):
mode = item.get('mode')
if mode not in EXACT_SHEET_WIDTH_CM:
if mode not in SHEET_FILM_CM:
continue
expected = EXACT_SHEET_WIDTH_CM[mode]
expected_text = f'{expected:g}'
film = SHEET_FILM_CM[mode]
for number, source in enumerate(item['production']['sources'], 1):
if source.get('kind') != 'sheet':
if source.get('kind') != 'sheet' or source.get('measurement') != 'file':
continue
row = rows.get(str(source['upload_id']))
if not row:
continue
name = row['name'].lower()
width = float(source['width_cm'])
confirmed = bool(source.get('size_confirmed'))
if name.endswith('.pdf'):
cm = float(source['width_cm'])
dpi = None
real = width
elif name.endswith('.png'):
dpi = png_saved_dpi(files.head(row))
if dpi is None or dpi < TRUSTED_DPI:
continue
size = image_size(files.head(row))
if not size or not all(size):
continue
cm = size[0] / dpi * 2.54
if dpi is not None and dpi >= TRUSTED_DPI:
size = image_size(files.head(row))
if not size or not all(size):
continue
real = size[0] / dpi * 2.54
else:
real = None
elif name.endswith('.webp'):
real = None
else:
continue
if abs(cm - expected) <= SHEET_WIDTH_TOLERANCE_CM:
if real is not None:
if real > film + SHEET_WIDTH_TOLERANCE_CM:
return (f'Item {index}: a folha {number} tem {cm(real)} cm e não cabe em '
f'{film_text(film)} cm. Reduza no seu programa ou envie as artes separadas.')
if abs(width - real) > SHEET_WIDTH_TOLERANCE_CM:
return (f'Item {index}: a folha {number} foi montada com {cm(width)} cm, mas tem '
f'{cm(real)} cm. Monte o pedido de novo.')
if real < film - SHEET_WIDTH_TOLERANCE_CM and not confirmed:
return (f'Item {index}: confirme a folha {number} de {cm(real)} cm no tamanho real '
'antes de pagar.')
continue
cm_text = f'{cm:.1f}'.replace('.', ',')
if dpi is None:
return (f'Item {index}: a folha {number} tem {cm_text} cm de largura. '
f'A folha montada precisa ter {expected_text} cm.')
return (f'Item {index}: a folha {number} tem {cm_text} cm de largura ({dpi} DPI). '
f'A folha montada precisa ter {expected_text} cm.')
size = image_size(files.head(row))
if not size or not all(size):
continue
# Unknown width: the sheet is taken as the film's (rule 4).
if abs(width - film) > SHEET_WIDTH_TOLERANCE_CM:
return (f'Item {index}: a folha {number} foi montada com {cm(width)} cm, mas tem '
f'{film_text(film)} cm. Monte o pedido de novo.')
effective = js_round(size[0] / (film / 2.54))
if effective < SHEET_MIN_DPI:
return (f'Item {index}: a folha {number} tem {effective} DPI em {film_text(film)} cm, '
f'abaixo do mínimo de {SHEET_MIN_DPI}. Se a sua folha não tem '
f'{film_text(film)} cm, suba as artes como artes avulsas.')
if not confirmed:
return (f'Item {index}: confirme a folha {number} de {film_text(film)} cm antes de pagar.')
return None