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:
@@ -42,6 +42,7 @@ def session(request: Request, response: Response):
|
||||
products = catalog.current(c)
|
||||
rules = grade_rules.current_rules(c)
|
||||
treatment = products['tratamento']
|
||||
redesign = products['redesenho']
|
||||
return {'environment': ENVIRONMENT, 'cart_scope': str(session_id), 'part_bytes': PART_BYTES,
|
||||
'max_upload_bytes': upload_limit_bytes(), 'payment_provider': payment.name,
|
||||
'password_recovery': mail.configured(),
|
||||
@@ -53,6 +54,9 @@ def session(request: Request, response: Response):
|
||||
'treatment_bands': [{'from_metres': float(band['from_metres']),
|
||||
'unit_cents': band['unit_cents']}
|
||||
for band in treatment['bands']] if treatment['enabled'] else [],
|
||||
# Zero keeps Redesenho hidden, as an off product does. One price
|
||||
# per art, never a band (front 1b).
|
||||
'redesign_cents': redesign['unit_cents'] if redesign['enabled'] else 0,
|
||||
# The grade rules the Site needs for the treatment requirement
|
||||
# (front 8.5): {} when nothing is configured.
|
||||
'grade_rules': rules,
|
||||
|
||||
@@ -8,6 +8,7 @@ from fastapi import APIRouter, Depends, HTTPException, Query, Response
|
||||
from pydantic import Field
|
||||
|
||||
from ... import hotfolder, machines, mail, payments, prumo, receipt, reviews
|
||||
from ...cart_pricing import designer_hours
|
||||
from ...core import db
|
||||
from ...core.auth import audit, can, operator
|
||||
from ...core.models import StrictModel
|
||||
@@ -138,10 +139,10 @@ def assign_late(c, orders, limits):
|
||||
since = since or order['created_at']
|
||||
hours = max(0.0, (now - since).total_seconds() / 3600)
|
||||
limit_hours = float(limit['hours'])
|
||||
# A paid treatment gives Art received its extra hours to prepare the art.
|
||||
treatment = (order.get('snapshot') or {}).get('treatment') or {}
|
||||
if order['state'] == 'rec' and treatment:
|
||||
limit_hours += float(treatment.get('hours', 24))
|
||||
# Paid designer work gives Art received its extra hours to prepare the
|
||||
# art: 48 h for a Redesenho, 24 h for the basic Ajuste Fino.
|
||||
if order['state'] == 'rec':
|
||||
limit_hours += designer_hours(order.get('snapshot') or {})
|
||||
order['state_hours'] = round(hours, 2)
|
||||
order['limit_hours'] = limit_hours
|
||||
order['limit_by'] = limit['responsible']
|
||||
|
||||
@@ -9,6 +9,7 @@ from pydantic import Field
|
||||
from psycopg.types.json import Jsonb
|
||||
|
||||
from ... import hotfolder, machine_log, machines, payments, proof, receipt, reviews
|
||||
from ...cart_pricing import needs_designer
|
||||
from ...core import db
|
||||
from ...core.auth import MOVERS, audit, can, may_move, may_reorder, operator
|
||||
from ...core.models import Contraction, Move, Resolution, StrictModel, UploadStart
|
||||
@@ -208,7 +209,7 @@ def proof_answer(uid: UUID, body: ProofAnswer, user=Depends(can('proof'))):
|
||||
# que o Prumo gerou entram como finais, e o pai segue para a fila.
|
||||
# Itens que ainda dependem de preparo manual continuam em Arte
|
||||
# recebida, com o botão de final disponível.
|
||||
if parent['state'] == 'rec' and not parent['snapshot'].get('treatment'):
|
||||
if parent['state'] == 'rec' and not needs_designer(parent['snapshot']):
|
||||
generated = c.execute('''SELECT p.item_index,p.upload_id FROM dtf_local.print_files p
|
||||
WHERE p.order_id=%s AND p.status='ready' AND p.upload_id IS NOT NULL
|
||||
AND NOT EXISTS (SELECT 1 FROM dtf_local.order_files f
|
||||
@@ -221,7 +222,7 @@ def proof_answer(uid: UUID, body: ProofAnswer, user=Depends(can('proof'))):
|
||||
VALUES(%s,%s,%s,%s,'final',%s,'Prumo')''',
|
||||
(uuid4(), parent['id'], row['upload_id'], row['item_index'],
|
||||
f'Aprovado pela prova do #{card["number"]}'))
|
||||
treatment_clause = f'AND {TREATED}' if parent['snapshot'].get('treatment') else ''
|
||||
treatment_clause = f'AND {TREATED}' if needs_designer(parent['snapshot']) else ''
|
||||
ready = parent['state'] == 'rec' and all(c.execute(f'''SELECT 1 FROM dtf_local.order_files f
|
||||
JOIN dtf_local.orders o ON o.id=f.order_id
|
||||
JOIN dtf_local.uploads u ON u.id=f.upload_id
|
||||
@@ -495,7 +496,7 @@ def move(uid: UUID, body: Move, request: Request, user=Depends(operator)):
|
||||
JOIN dtf_local.uploads u ON u.id=f.upload_id WHERE f.order_id=%s AND {FINAL_OK}''', (uid,)).fetchall()
|
||||
if {r['item_index'] for r in coverage} != set(range(len(row['snapshot']['items']))):
|
||||
raise HTTPException(409, 'Aprove os arquivos finais de todos os itens antes de mandar para Arte conferida.')
|
||||
if row['snapshot'].get('treatment') and not row['parent_id']:
|
||||
if needs_designer(row['snapshot']) and not row['parent_id']:
|
||||
treated = c.execute(f'''SELECT DISTINCT f.item_index FROM dtf_local.order_files f
|
||||
JOIN dtf_local.orders o ON o.id=f.order_id
|
||||
JOIN dtf_local.uploads u ON u.id=f.upload_id
|
||||
|
||||
@@ -5,6 +5,7 @@ from decimal import Decimal
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
|
||||
from ... import machines, payments, unpaid
|
||||
from ...cart_pricing import designer_hours
|
||||
from ...core import db
|
||||
from ...core.auth import operator
|
||||
from .common import ORIGINS, REAL_ORDER, TREATED, person
|
||||
@@ -106,7 +107,7 @@ def production_stats(days: int | None = Query(default=None, ge=7, le=365), start
|
||||
late_rows = c.execute(f'''SELECT s.state,
|
||||
extract(epoch FROM s.until-s.at) - {waited('s.id', 's.at', 's.until')} AS seconds,
|
||||
(s.until AT TIME ZONE 'America/Sao_Paulo')::date AS day,
|
||||
o.snapshot->'treatment' AS treatment
|
||||
o.snapshot->'treatment' AS treatment, o.snapshot->'redesign' AS redesign
|
||||
FROM ({spans}) s LEFT JOIN dtf_local.orders o ON o.id=s.id WHERE s.until IS NOT NULL''',
|
||||
period + period).fetchall()
|
||||
printed = machine_output(c, start, end)
|
||||
@@ -214,9 +215,8 @@ def production_stats(days: int | None = Query(default=None, ge=7, le=365), start
|
||||
if not limit:
|
||||
continue
|
||||
hours = float(limit['hours'])
|
||||
treatment = row.get('treatment') or {}
|
||||
if row['state'] == 'rec' and treatment:
|
||||
hours += float(treatment.get('hours', 24))
|
||||
if row['state'] == 'rec':
|
||||
hours += designer_hours({'treatment': row.get('treatment'), 'redesign': row.get('redesign')})
|
||||
if row['seconds'] > hours * 3600:
|
||||
late[row['state']]['count'] += 1
|
||||
if row['day'] == today:
|
||||
|
||||
@@ -57,7 +57,8 @@ def create_quote(body: QuoteRequest, session_id=Depends(owner)):
|
||||
cart = cart_pricing.price_cart(
|
||||
c, draft['items'], names, coupon_code=code,
|
||||
customer_document=body.customer.cnpj,
|
||||
wants_treatment=draft.get('treatment', False))
|
||||
wants_treatment=draft.get('treatment', False),
|
||||
wants_redesign=draft.get('redesign', []))
|
||||
if reason is not None:
|
||||
freight.quote(body.freight.service, body.freight.postal_code,
|
||||
sum(Decimal(i['billed_metres']) for i in cart['items']),
|
||||
|
||||
@@ -95,8 +95,11 @@ def toggle_product(product: str, body: SiteProductToggle, user=Depends(can('mana
|
||||
def schedule_price(product: str, body: SitePriceNew, user=Depends(can('manage'))):
|
||||
if product not in catalog.PRODUCTS:
|
||||
raise HTTPException(404, 'Produto não encontrado.')
|
||||
if product != 'tratamento' and body.unit_cents <= 0:
|
||||
if product not in ('tratamento', 'redesenho') and body.unit_cents <= 0:
|
||||
raise HTTPException(422, 'O preço precisa ser maior que zero.')
|
||||
# Redesenho is one price per art: its batch band belongs to the basic only.
|
||||
if product == 'redesenho' and body.bands:
|
||||
raise HTTPException(422, 'O Redesenho não tem faixas de preço.')
|
||||
bands = checked_bands(product, body.bands)
|
||||
now = datetime.now(timezone.utc)
|
||||
starts_at = body.starts_at or now
|
||||
|
||||
Reference in New Issue
Block a user