Merge front 7a.4: montador Venda with shipping
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -111,11 +111,11 @@ def montador_upload(body: UploadStart, user=Depends(can('assemble'))):
|
||||
|
||||
@router.post('/api/operator/montador/orders')
|
||||
def montador_order(body: MontadorOrder, request: Request, user=Depends(can('assemble'))):
|
||||
"""The card a montador sheet becomes (front 7a.3): Interno (the fixed
|
||||
internal customer, origin dropflow, never Tiny) or Venda (a Tiny customer,
|
||||
origin atendimento, invoiced and sent to Tiny). Pickup in both, at the
|
||||
Site's table price; the order records whether it travels with a clothing
|
||||
order."""
|
||||
"""The card a montador sheet becomes (fronts 7a.3 and 7a.4): Interno (the
|
||||
fixed internal customer, origin dropflow, never Tiny) or Venda (a Tiny
|
||||
customer, origin atendimento, invoiced and sent to Tiny), at the Site's
|
||||
table price. A Venda is picked up, travels with a clothing order or ships
|
||||
with the Site's freight; approve quotes the freight again."""
|
||||
role = request.state.operator['role']
|
||||
if body.kind not in MONTADOR_KINDS.get(role, set()):
|
||||
raise HTTPException(403, 'Seu perfil não permite este tipo de pedido.')
|
||||
@@ -127,7 +127,8 @@ def montador_order(body: MontadorOrder, request: Request, user=Depends(can('asse
|
||||
customer = body.customer
|
||||
origin, method = 'atendimento', payments.INVOICED_METHOD
|
||||
draft = QuoteRequest(request_key=body.request_key, customer=customer, items=body.items,
|
||||
freight=Freight(service='pickup')).model_dump(mode='json', exclude={'request_key'})
|
||||
freight=body.freight or Freight(service='pickup'),
|
||||
destination=body.destination).model_dump(mode='json', exclude={'request_key'})
|
||||
draft['montador'] = True
|
||||
draft['kind'] = body.kind
|
||||
if body.with_order:
|
||||
|
||||
@@ -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