feat: the 8 mm between a ready sheet's copies stay on the film but are no longer billed (Marcus, 2026-12-03)
All checks were successful
Build and deploy / Validate source (push) Successful in 59s
Build and deploy / Integration suite on a real stack (push) Successful in 8m58s
Build and deploy / Secret scan and release gate (push) Successful in 10s
Build and deploy / Publish images (push) Successful in 1m45s

Marcus on 26/11 had the gaps count in the billed metres; on 2026-12-03,
after customers of Lais and Kedma refused orders billed 10 and 20 cm more,
"por hora pode tirar a cobrança". A ready sheet is now billed on the sum of
its sheets and copies (pricing.billable_metres: the layout's height less
unbilled_gaps_cm, at most 8 mm between each two pieces); `metres` stays the
film laid out, which the print file, the parts and the folders follow, and
the print file's billed-length guard allows the gap film. Loose art keeps
its packing. The Site bills folhaCobradaM, the copies line reads
"5 × 45,9 cm = 229,3 cm" and the buy box explains that length. The Lais
case, 5 sheets of 100 cm, bills 5,00 m instead of 5,10 m.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-12-03 11:24:13 -03:00
parent 3b4f851fc2
commit 911892351f
10 changed files with 91 additions and 21 deletions

View File

@@ -80,9 +80,12 @@ def price_items(items, names, catalog_now, manual_extra):
for item in items:
extra = manual_extra if pricing.is_manual(item, names) else 0
product = catalog_now[item['mode']]
priced.append({**pricing.price(item['mode'], str(item['metres']), item['grade'], extra,
minimum=Decimal('0') if item.get('split') else Decimal('1'),
unit_cents=product['unit_cents']),
# Billed on the length less a ready sheet's gaps; `metres` stays the
# film the layout uses, which the print file and the folders follow.
charged = pricing.price(item['mode'], str(pricing.billable_metres(item)), item['grade'], extra,
minimum=Decimal('0') if item.get('split') else Decimal('1'),
unit_cents=product['unit_cents'])
priced.append({**charged, 'metres': str(item['metres']),
**({'split': item['split']} if item.get('split') else {})})
pricing.bill_splits(priced)
totals = {}

View File

@@ -12,6 +12,31 @@ from decimal import Decimal, ROUND_CEILING
# 2026-11-27): a length that passes a step by up to 8 mm is billed at that
# step, by more at the next one. The Site rounds the same (web/site-config.js).
STEP_GRACE_M = Decimal('0.008')
# The film between a ready sheet's copies (app/core/models.py SHEET_GAP_CM).
SHEET_GAP_CM = Decimal('0.8')
def unbilled_gaps_cm(production):
"""The film between a ready sheet's copies and sheets (8 mm each, Marcus
26/11): laid out, but not billed since Marcus's 2026-12-03 answer ("por
hora pode tirar a cobrança"). The layout's height less its pieces; zero
for loose art, whose spacing is part of the packing."""
production = production or {}
sources = production.get('sources') or []
if not sources or any(source.get('kind') != 'sheet' for source in sources):
return Decimal('0')
placements = production.get('placements') or []
if len(placements) < 2:
return Decimal('0')
pieces = sum(Decimal(str(p['length_cm'])) for p in placements)
# Never more than one gap of SHEET_GAP_CM between each two pieces.
most = SHEET_GAP_CM * (len(placements) - 1)
return min(most, max(Decimal('0'), Decimal(str(production['height_cm'])) - pieces))
def billable_metres(item):
"""The metres an item is billed on: its length less the unbilled gaps."""
return Decimal(str(item['metres'])) - unbilled_gaps_cm(item.get('production')) / 100
def billed_length(length):

View File

@@ -27,7 +27,7 @@ from decimal import Decimal
from PIL import Image, ImageOps
from .core.models import PRODUCTION_VERSIONS
from .core.pricing import STEP_GRACE_M
from .core.pricing import STEP_GRACE_M, unbilled_gaps_cm
PT_PER_CM = 72 / 2.54
# Acrobat's page limit, 200 inches (5,08 m). A longer sheet is written at its
@@ -388,8 +388,10 @@ def check_layout(item, sizes, vector=(), proof=False):
production = item['production']
height = Decimal(str(production['height_cm']))
billed = Decimal(str(item['billed_metres'])) * 100
# Up to 8 mm past the billed length is the customer's grace (app/core/pricing.py).
if not proof and height > billed + STEP_GRACE_M * 100 + HEIGHT_TOLERANCE_CM:
# Up to 8 mm past the billed length is the customer's grace, and a ready
# sheet's gaps are film not billed (app/core/pricing.py).
allowed = billed + STEP_GRACE_M * 100 + unbilled_gaps_cm(production) + HEIGHT_TOLERANCE_CM
if not proof and height > allowed:
raise Unsupported(f'a montagem tem {height} cm, mas só {billed} cm foram cobrados')
lowest = None
for placement in production['placements']: