All checks were successful
Build and deploy / Validate source (push) Successful in 1m25s
Build and deploy / Integration suite on a real stack (push) Successful in 4m40s
Build and deploy / Secret scan and release gate (push) Successful in 12s
Build and deploy / Publish images (push) Successful in 1m38s
Round 3, items 9, 4, 16 and 17 (Dropstar, 2026-10-30).
- 9: the Site measures the thinnest stroke of each sheet and loose artwork
(alpha > 40, chamfer distance in strips, width at local maxima, 1st
percentile, at 300 DPI) and sends stroke_px and C1/C2/C3 with the item.
The Kanban shows the class prefilled in the approve step; Produção may
change it (POST /orders/{id}/contraction, who and when recorded), and the
manifest carries it.
- 4: the residue check runs on each loose artwork, accepted per artwork; the
sheet inherits what was accepted.
- 16: fine lines and solid areas in one file. Loose art: a pop-up with
[Subir separado] [Continuar assim]. Ready sheet: protect the fine lines
(default), protect the solid areas (stroke_choice client_c3, starts at C3)
or go back and send two sheets, which holds the order.
- 17: loose art of fine (C1, C2) and solid (C3) strokes goes on separate
sheets, each its own order item (split group/part/of) with its own file
and class. Each sheet rounds to 10 cm and the 1 m minimum is charged once
per group, since the customer did not choose the split. Cart, payment
summary, portal, receipt and mail show it as such.
- The board loads quote views in two queries instead of two per quote.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
73 lines
3.5 KiB
Python
73 lines
3.5 KiB
Python
"""Dropstar's single price per metre for each product; integer BRL cents at the boundary.
|
|
|
|
One price per product (Dropstar, 2026-10-23). The grade is still recorded with
|
|
each item, for the customer and the print room, but it no longer changes the
|
|
price. This module does not inspect artwork or perform pre-flight.
|
|
"""
|
|
import os
|
|
import re
|
|
from decimal import Decimal, ROUND_CEILING
|
|
|
|
PRICES = {'file': 1990, 'avulsa': 2190, 'uvfile': 7990, 'uv': 8990}
|
|
|
|
# A finished sheet the Site cannot open (CDR, AI, PSD, TIFF) is opened by a
|
|
# person before printing. It pays this per metre on top of the product's price
|
|
# when the business sets it, to make the formats the robot reads the cheaper
|
|
# path. Zero adds nothing.
|
|
MANUAL_FORMATS = re.compile(r'\.(cdr|ai|psd|psb|tiff?)$', re.I)
|
|
|
|
|
|
def manual_extra_cents() -> int:
|
|
value = int(os.environ.get('MANUAL_FILE_EXTRA_CENTS', '0') or 0)
|
|
if not 0 <= value <= 100000:
|
|
raise ValueError('MANUAL_FILE_EXTRA_CENTS must be between 0 and 100000')
|
|
return value
|
|
|
|
|
|
def is_manual(item, names) -> bool:
|
|
"""Whether a finished-sheet item has a file someone must open by hand: one
|
|
the customer measured, or one in a format the Site cannot read."""
|
|
return any(source['kind'] == 'sheet' and (source['measurement'] == 'customer' or
|
|
MANUAL_FORMATS.search(names.get(str(source['upload_id']), '')))
|
|
for source in item['production']['sources'])
|
|
|
|
|
|
def price(mode: str, metres: str, grade: int, extra_cents: int = 0, minimum: Decimal = Decimal('1')) -> dict:
|
|
"""The item's charge. The grade is validated and kept with the item; the
|
|
price does not depend on it. A split sheet has no minimum of its own: its
|
|
group has one (bill_splits)."""
|
|
length = Decimal(str(metres))
|
|
if mode not in PRICES or not length.is_finite() or not 0 < length <= 12000:
|
|
raise ValueError('Invalid product or length')
|
|
if isinstance(grade, bool) or not isinstance(grade, int) or not 0 <= grade <= 100:
|
|
raise ValueError('Grade must be an integer between 0 and 100')
|
|
billed = max(minimum, (length * 10).to_integral_value(rounding=ROUND_CEILING) / 10)
|
|
if isinstance(extra_cents, bool) or not isinstance(extra_cents, int) or extra_cents < 0:
|
|
raise ValueError('Invalid extra charge')
|
|
unit = PRICES[mode] + extra_cents
|
|
priced = {'mode': mode, 'metres': str(length), 'grade': grade,
|
|
'billed_metres': str(billed), 'unit_cents': unit,
|
|
'total_cents': int(billed * unit)}
|
|
if extra_cents:
|
|
priced['manual_extra_cents'] = extra_cents
|
|
return priced
|
|
|
|
|
|
def bill_splits(priced: list) -> list:
|
|
"""The order minimum of 1 m once per split group, on its first sheet: the
|
|
customer did not choose the split (item 17), so it never costs a metre more."""
|
|
for group in dict.fromkeys(i['split']['group'] for i in priced if i.get('split')):
|
|
parts = [i for i in priced if (i.get('split') or {}).get('group') == group]
|
|
short = Decimal('1') - sum(Decimal(i['billed_metres']) for i in parts)
|
|
if short > 0:
|
|
first = min(parts, key=lambda i: i['split']['part'])
|
|
billed = Decimal(first['billed_metres']) + short
|
|
first.update(billed_metres=str(billed), total_cents=int(billed * first['unit_cents']))
|
|
return priced
|
|
|
|
|
|
def sheet_label(item: dict) -> str:
|
|
"""' · folha 1 de 2' on a split sheet (item 17), for the customer's lists."""
|
|
split = item.get('split')
|
|
return f" · folha {split['part']} de {split['of']}" if split else ''
|