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
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:
@@ -37,6 +37,8 @@ def create_quote(body: QuoteRequest, session_id=Depends(owner)):
|
||||
item['residue_accepted_at'] = accepted_at
|
||||
if item.get('stroke_choice'):
|
||||
item['stroke_choice_at'] = accepted_at
|
||||
if any(s.get('size_confirmed') for s in (item.get('production') or {}).get('sources') or []):
|
||||
item['size_confirmed_at'] = accepted_at
|
||||
reason = quote_review.review_reason(draft)
|
||||
with db.connect() as c:
|
||||
rows = {}
|
||||
|
||||
@@ -136,6 +136,11 @@ class ProductionSource(StrictModel):
|
||||
# report; nothing on the server prices or packs by it.
|
||||
saved_width_cm: Decimal | None = Field(default=None, gt=0, le=10000)
|
||||
saved_dpi: int | None = Field(default=None, ge=1, le=10000, strict=True)
|
||||
# The customer confirmed this ready sheet's size in the Site's dialog: a
|
||||
# known width narrower than the film printed at its real size, or an
|
||||
# unknown width taken as the film's (Marcus, 2026-12-02,
|
||||
# output/revisao/contrato-folha-real.md). The checkout requires it.
|
||||
size_confirmed: bool = False
|
||||
|
||||
class ProductionPlacement(StrictModel):
|
||||
source_index: int = Field(ge=0, le=199, strict=True)
|
||||
@@ -291,7 +296,9 @@ class Item(StrictModel):
|
||||
raise ValueError('Production placement changes the source size')
|
||||
if placement.x_cm+placement.width_cm>film_width+tolerance or placement.y_cm+placement.length_cm>self.production.height_cm+tolerance:
|
||||
raise ValueError('Production placement is outside the film')
|
||||
if is_sheet and (placement.x_cm or auto_rotation):
|
||||
# A ready sheet prints at its real size, centred on the film
|
||||
# (Marcus, 2026-12-02; output/revisao/contrato-folha-real.md).
|
||||
if is_sheet and (auto_rotation or abs(placement.x_cm - (film_width - placement.width_cm) / 2) > tolerance):
|
||||
raise ValueError('Finished sheets must retain their original orientation')
|
||||
if placed != expected:
|
||||
raise ValueError('Production layout does not cover every source copy')
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -106,6 +106,14 @@ def report(order, uploads):
|
||||
lines.append(f'{lead}{dots} ponto{"s" if dots > 1 else ""} < 2 mm — cliente aceitou' +
|
||||
_hora(item.get('residue_accepted_at')))
|
||||
production = item.get('production') or {}
|
||||
film = production.get('film_width_cm')
|
||||
if item.get('mode') in ('file', 'premium', 'uvfile') and film is not None:
|
||||
film = Decimal(str(film))
|
||||
for k, source in enumerate(production.get('sources') or [], 1):
|
||||
width = Decimal(str(source.get('width_cm')))
|
||||
if source.get('size_confirmed') and width < film - Decimal('0.1'):
|
||||
lines.append(f'{lead}Folha {k}: cliente confirmou folha de {_cm(width)} cm no tamanho real' +
|
||||
_hora(item.get('size_confirmed_at')))
|
||||
placements = production.get('placements') or []
|
||||
if item.get('mode') in ('avulsa', 'uv'):
|
||||
rotated = sum(1 for p in placements if p.get('rotation_degrees') in (90, 270))
|
||||
|
||||
Reference in New Issue
Block a user