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:
@@ -43,6 +43,35 @@ def treatment_price(items, choice, offer):
|
||||
return {'cents': unit * count, 'hours': 24, 'arts': count, 'unit_cents': unit}
|
||||
|
||||
|
||||
def redesign_price(items, choice, offer):
|
||||
"""Ajuste Fino Redesenho for the chosen arts: one price per art, never a
|
||||
band. {} when it is not offered or no art is chosen."""
|
||||
if not offer or not offer.get('enabled') or offer.get('unit_cents', 0) <= 0:
|
||||
return {}
|
||||
arts = chosen_arts(items, choice)
|
||||
if not arts:
|
||||
return {}
|
||||
count = len(arts)
|
||||
unit = offer['unit_cents']
|
||||
return {'cents': unit * count, 'hours': 48, 'arts': count, 'unit_cents': unit}
|
||||
|
||||
|
||||
def designer_hours(snapshot):
|
||||
"""The extra hours the paid designer work adds to the deadline: 48 h when
|
||||
any art was sent to Redesenho, else 24 h for the basic Ajuste Fino."""
|
||||
if snapshot.get('redesign'):
|
||||
return 48
|
||||
if snapshot.get('treatment'):
|
||||
return 24
|
||||
return 0
|
||||
|
||||
|
||||
def needs_designer(snapshot):
|
||||
"""Whether a designer must prepare the final PNG before the print queue:
|
||||
a paid Ajuste Fino or Redesenho on any art."""
|
||||
return bool(snapshot.get('treatment') or snapshot.get('redesign'))
|
||||
|
||||
|
||||
def price_items(items, names, catalog_now, manual_extra):
|
||||
"""Price the items without a database: price() per item with the product's
|
||||
base price and the manual extra, bill_splits, then the band of each mode's
|
||||
@@ -70,13 +99,15 @@ def price_items(items, names, catalog_now, manual_extra):
|
||||
|
||||
|
||||
def price_cart(c, items, names, *, coupon_code=None, customer_document=None,
|
||||
wants_treatment=False, treatment_rule=True):
|
||||
wants_treatment=False, wants_redesign=(), treatment_rule=True):
|
||||
"""Price a cart exactly as an order is charged. Returns
|
||||
{'items': [priced item dicts], 'items_total': int, 'coupon': dict|None,
|
||||
'treatment': dict, 'treatment_cents': int, 'grade_flags': dict}.
|
||||
Raises HTTPException(422) for a product switched off, a required Ajuste
|
||||
Fino the cart did not ask for, or a refused coupon.
|
||||
`treatment_rule=False` is for the montador, which assembles the sheet."""
|
||||
'treatment': dict, 'treatment_cents': int, 'redesign': dict,
|
||||
'redesign_cents': int, 'grade_flags': dict}.
|
||||
Raises HTTPException(422) for a product switched off, a Redesenho not
|
||||
offered, a required designer service the cart did not ask for, or a
|
||||
refused coupon. `treatment_rule=False` is for the montador, which
|
||||
assembles the sheet."""
|
||||
from fastapi import HTTPException
|
||||
catalog_now = catalog.current(c)
|
||||
for item in items:
|
||||
@@ -89,7 +120,12 @@ def price_cart(c, items, names, *, coupon_code=None, customer_document=None,
|
||||
if not treatment_rule:
|
||||
flags.pop('tratamento', None)
|
||||
treatment = treatment_price(items, wants_treatment, offer)
|
||||
if 'tratamento' in flags and not treatment:
|
||||
redesign = redesign_price(items, wants_redesign, catalog_now['redesenho'])
|
||||
if chosen_arts(items, wants_redesign) and not redesign:
|
||||
raise HTTPException(422, 'O Redesenho não está disponível agora.')
|
||||
# The grade rule wants a designer on the art: the stronger Redesenho
|
||||
# satisfies it just as the basic Ajuste Fino does.
|
||||
if 'tratamento' in flags and not treatment and not redesign:
|
||||
raise HTTPException(422, grade_rules.treatment_message(flags['tratamento']))
|
||||
coupon = None
|
||||
if coupon_code:
|
||||
@@ -99,4 +135,6 @@ def price_cart(c, items, names, *, coupon_code=None, customer_document=None,
|
||||
'coupon': coupon,
|
||||
'treatment': treatment,
|
||||
'treatment_cents': treatment.get('cents', 0),
|
||||
'redesign': redesign,
|
||||
'redesign_cents': redesign.get('cents', 0),
|
||||
'grade_flags': flags}
|
||||
|
||||
Reference in New Issue
Block a user