feat: montador Venda with shipping at the Site's freight (front 7a.4)
A Venda can now ship: CEP lookup, the address, and the Site's freight options for the packed metres; the server quotes the freight again at approval, adds it to the total and keeps the destination, so Tiny gets the freight and carrier like a Site order. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -289,10 +289,11 @@ class QuoteRequest(StrictModel):
|
||||
return self
|
||||
|
||||
class MontadorOrder(StrictModel):
|
||||
"""What the montador sends (front 7a.3): Interno or Venda, loose artwork
|
||||
only and pickup; the server prices and approves it as a quote. An Interno
|
||||
"""What the montador sends (fronts 7a.3 and 7a.4): Interno or Venda, loose
|
||||
artwork only; the server prices and approves it as a quote. An Interno
|
||||
order takes the fixed customer from the database, a Venda one the customer
|
||||
picked from Tiny."""
|
||||
picked from Tiny. A Venda ships with the Site's freight or travels with the
|
||||
customer's clothing order; an Interno never ships."""
|
||||
request_key: UUID
|
||||
kind: Literal['interno', 'venda']
|
||||
# Empty for an Interno order: the server reads the internal customer.
|
||||
@@ -300,6 +301,9 @@ class MontadorOrder(StrictModel):
|
||||
items: list[Item] = Field(min_length=1, max_length=30)
|
||||
# A Venda that travels with the customer's clothing order; pickup freight.
|
||||
with_order: int | None = Field(default=None, ge=1, le=999999, strict=True)
|
||||
# A Venda with "Envio": the chosen freight service and the full address.
|
||||
freight: Freight | None = None
|
||||
destination: Destination | None = None
|
||||
|
||||
@model_validator(mode='after')
|
||||
def order_kind(self):
|
||||
@@ -307,8 +311,21 @@ class MontadorOrder(StrictModel):
|
||||
raise ValueError('O montador só monta artes avulsas.')
|
||||
if self.kind == 'venda' and self.customer is None:
|
||||
raise ValueError('O pedido de venda precisa do cliente.')
|
||||
if self.kind == 'interno' and self.with_order is not None:
|
||||
raise ValueError('O pedido interno não tem envio.')
|
||||
delivery = bool(self.freight and self.freight.service != 'pickup')
|
||||
if self.kind == 'interno':
|
||||
if self.with_order is not None:
|
||||
raise ValueError('O pedido interno não tem envio.')
|
||||
if delivery or self.destination is not None:
|
||||
raise ValueError('O pedido interno não tem envio.')
|
||||
elif delivery:
|
||||
if self.with_order is not None:
|
||||
raise ValueError('Escolha retirada, envio ou junto com o pedido de roupa.')
|
||||
if self.destination is None:
|
||||
raise ValueError('O envio precisa do endereço completo.')
|
||||
if self.destination.postal_code != self.freight.postal_code:
|
||||
raise ValueError('O CEP do frete e o do endereço precisam ser o mesmo.')
|
||||
elif self.destination is not None:
|
||||
raise ValueError('Só o pedido com envio tem endereço de entrega.')
|
||||
return self
|
||||
|
||||
class Review(StrictModel):
|
||||
|
||||
Reference in New Issue
Block a user