feat: Ajuste Fino priced per art, with the offer under each Prumo warning (Marcus 10/11, point 1)
The designer treatment becomes Ajuste Fino, priced per art with a batch band set in the Site tab (e.g. R$ 9,90, from 10 arts R$ 6,90). Under each art the Prumo warns about, the Site offers 'Quer que um designer resolva? Ajuste Fino'; the cart keeps 'Ajuste Fino em todas as artes'. The server counts the chosen arts, Tiny gets the line with that quantity, the card shows 'Ajuste Fino · N artes'. Old carts asking the treatment for the whole order keep working. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -265,8 +265,9 @@ class QuoteRequest(StrictModel):
|
||||
destination: Destination | None = None
|
||||
# "Quero aprovar uma prova antes de imprimir": the order waits for the customer.
|
||||
proof: bool = False
|
||||
# "Quero o tratamento pelo designer": a fixed service line, when priced (front 5).
|
||||
treatment: bool = False
|
||||
# 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
|
||||
# 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).
|
||||
@@ -277,6 +278,19 @@ class QuoteRequest(StrictModel):
|
||||
check_splits(self.items)
|
||||
return self
|
||||
|
||||
@model_validator(mode='after')
|
||||
def treatment_arts_exist(self):
|
||||
if isinstance(self.treatment, list):
|
||||
seen = set()
|
||||
for item_index, source_index in self.treatment:
|
||||
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('Ajuste Fino: arte não encontrada no pedido.')
|
||||
if (item_index, source_index) in seen:
|
||||
raise ValueError('Ajuste Fino: cada arte aparece uma vez.')
|
||||
seen.add((item_index, source_index))
|
||||
return self
|
||||
|
||||
@model_validator(mode='after')
|
||||
def destination_matches_freight(self):
|
||||
if self.freight.service == 'pickup':
|
||||
|
||||
@@ -25,7 +25,7 @@ def manual_extra_cents() -> int:
|
||||
|
||||
|
||||
def treatment_cents() -> int:
|
||||
"""The designer's treatment, a fixed amount per order (front 5).
|
||||
"""Ajuste Fino, a fixed amount per art (front 1a).
|
||||
|
||||
Zero keeps the option hidden: the price is the client's decision, and the
|
||||
server and the Site read the same `TREATMENT_CENTS`.
|
||||
|
||||
Reference in New Issue
Block a user