feat: one order, one machine: UV and textile never share an order (Marcus, 2026-11-26)
All checks were successful
Build and deploy / Validate source (push) Successful in 6s
Build and deploy / Integration suite on a real stack (push) Successful in 7m56s
Build and deploy / Secret scan and release gate (push) Successful in 7s
Build and deploy / Publish images (push) Successful in 1m16s

The server refuses a cart (and a review) with UV and textile items; the Site
says so as soon as the customer opens a product of the other line, or adds it,
with "Finalizar este pedido" and "Trocar o carrinho por este item". Basic
and premium textile still go together. Proof cards copy their order's items,
so they follow.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-26 09:57:03 -03:00
parent 5ed8109d50
commit a88e7a3288
7 changed files with 82 additions and 5 deletions

View File

@@ -165,6 +165,19 @@ class Split(StrictModel):
of: int = Field(ge=2, le=10, strict=True)
UV_MODES = ('uvfile', 'uv')
ONE_MACHINE = ('Esse produto é impresso em outra máquina e precisa de um pedido separado. '
'Finalize este pedido e faça um novo com ele.')
def check_one_machine(items):
"""One order, one machine (Marcus, 2026-11-26): UV and textile never share
an order, since its card goes to one machine. Basic and premium textile
print on the same machines and may."""
if len({item.mode in UV_MODES for item in items}) > 1:
raise ValueError(ONE_MACHINE)
def check_splits(items):
"""Every split group has each of its parts once, of one product."""
groups = {}
@@ -309,6 +322,7 @@ class QuoteRequest(StrictModel):
@model_validator(mode='after')
def splits_complete(self):
check_splits(self.items)
check_one_machine(self.items)
return self
@model_validator(mode='after')
@@ -399,6 +413,7 @@ class Review(StrictModel):
@model_validator(mode='after')
def splits_complete(self):
check_splits(self.items)
check_one_machine(self.items)
return self
class Pay(StrictModel):