feat: Ajuste Fino Redesenho in the cart (Marcus 12/11, slice R1)

Under each art the Prumo warns about, the customer can choose Ajuste Fino
or Ajuste Fino Redesenho (vectorize or redraw, per art, +48 h, no batch
price). It is a disabled product until Gestão prices it in the Site tab;
the server charges it per chosen art, Tiny gets a DTFIMP.AJF.RED line and
two more business days, the card shows 'Redesenho · N artes' and the
designer gate applies. The preview loop is slice R2.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-12 11:05:17 -03:00
parent 5ca6792221
commit 38f947d632
23 changed files with 429 additions and 60 deletions

View File

@@ -277,6 +277,9 @@ class QuoteRequest(StrictModel):
# Ajuste Fino (front 1a): true selects every art of the cart (old carts and
# the grade rule), a list selects [item_index, source_index] arts.
treatment: bool | list[tuple[int, int]] = False
# Ajuste Fino Redesenho (front 1b): the arts sent to be redrawn, in the
# same [item_index, source_index] identifiers. One service per art.
redesign: list[tuple[int, int]] = Field(default_factory=list)
# A coupon code typed at checkout (front 8.3); the server prices it.
coupon: str | None = Field(default=None, max_length=30)
# What the browser measured while the customer built the cart (item 0.12).
@@ -300,6 +303,24 @@ class QuoteRequest(StrictModel):
seen.add((item_index, source_index))
return self
@model_validator(mode='after')
def redesign_arts_exist(self):
seen = set()
for item_index, source_index in self.redesign:
if (item_index < 0 or source_index < 0 or item_index >= len(self.items)
or source_index >= len(self.items[item_index].production.sources)):
raise ValueError('Redesenho: arte não encontrada no pedido.')
if (item_index, source_index) in seen:
raise ValueError('Redesenho: cada arte aparece uma vez.')
seen.add((item_index, source_index))
# The customer chooses one service per art: basic or Redesenho.
if self.treatment is True:
if seen:
raise ValueError('Escolha Ajuste Fino ou Redesenho para cada arte, não os dois.')
elif isinstance(self.treatment, list) and seen & {(i, s) for i, s in self.treatment}:
raise ValueError('Escolha Ajuste Fino ou Redesenho para cada arte, não os dois.')
return self
@model_validator(mode='after')
def destination_matches_freight(self):
if self.freight.service == 'pickup':