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:
@@ -13,6 +13,7 @@ from uuid import uuid4
|
||||
from PIL import Image, ImageDraw
|
||||
|
||||
from app import tiny
|
||||
from app.adapters import FakeTiny
|
||||
from app.core import db
|
||||
from tests.print_file_test import artwork
|
||||
from tests.smoke_test import Client, item_spec, upload_bytes
|
||||
@@ -20,6 +21,7 @@ from tests.smoke_test import Client, item_spec, upload_bytes
|
||||
PASSWORD = 'senha-de-teste-123'
|
||||
UV = 'uv'
|
||||
PREMIUM = 'premium'
|
||||
REDESIGN = 'redesenho'
|
||||
|
||||
|
||||
def premium_sheet():
|
||||
@@ -61,11 +63,11 @@ def run():
|
||||
manager.call('/session')
|
||||
manager.call('/operator/me', operator=True)
|
||||
manager = manager.operator_client
|
||||
prices, user, treatment_enabled = [], None, None
|
||||
prices, user, treatment_enabled, redesign_enabled = [], None, None, None
|
||||
try:
|
||||
products = manager.call('/operator/site/products')['products']
|
||||
assert {product['id'] for product in products} == \
|
||||
{'file', 'avulsa', 'uvfile', 'uv', 'premium', 'tratamento'}
|
||||
{'file', 'avulsa', 'uvfile', 'uv', 'premium', 'tratamento', REDESIGN}
|
||||
assert all(product['unit'] in ('metro', 'pedido', 'arte') and product['title'] for product in products)
|
||||
|
||||
# Front 3: Premium is listed and starts switched off (Marcus, 2026-11-10).
|
||||
@@ -128,6 +130,62 @@ def run():
|
||||
{'produto': {'id': 105}, 'quantidade': 3, 'valorUnitario': 9.9,
|
||||
'infoAdicional': 'Ajuste Fino · 3 artes · +24 h'}], pedido['itens']
|
||||
|
||||
# Front 1b: Ajuste Fino Redesenho, one price per art, never a band.
|
||||
redesign = next(product for product in products if product['id'] == REDESIGN)
|
||||
redesign_enabled = redesign['enabled']
|
||||
assert redesign['enabled'] is False, redesign
|
||||
assert redesign['title'] == 'Ajuste Fino Redesenho', redesign
|
||||
assert redesign['unit'] == 'arte', redesign
|
||||
manager.call(f'/operator/site/products/{REDESIGN}', {'enabled': True})
|
||||
# Enabled but still unpriced: the Site hides it and the server refuses it.
|
||||
refused = client.call('/quotes', {'request_key': str(uuid4()), 'customer': customer,
|
||||
'items': [arts], 'redesign': [[0, 0]], 'freight': {'service': 'pickup'}}, expected=422)
|
||||
assert refused['detail'] == 'O Redesenho não está disponível agora.', refused
|
||||
banded = manager.call(f'/operator/site/products/{REDESIGN}/prices', {
|
||||
'unit_cents': 2990,
|
||||
'bands': [{'from_metres': '10', 'unit_cents': 690}]}, expected=422)
|
||||
assert 'faixas' in banded['detail'], banded
|
||||
made = manager.call(f'/operator/site/products/{REDESIGN}/prices', {'unit_cents': 2990})
|
||||
prices.append(made['id'])
|
||||
assert client.call('/session')['redesign_cents'] == 2990
|
||||
two = client.call('/quotes', {'request_key': str(uuid4()), 'customer': customer,
|
||||
'items': [arts], 'redesign': [[0, 0], [0, 1]], 'freight': {'service': 'pickup'}})
|
||||
assert two['status'] == 'approved', two
|
||||
redesenho = client.call('/quotes/' + two['id'])['approved']
|
||||
assert redesenho['redesign'] == {'cents': 5980, 'hours': 48, 'arts': 2,
|
||||
'unit_cents': 2990}, redesenho
|
||||
assert redesenho['total_cents'] == redesenho['items'][0]['total_cents'] + 5980, redesenho
|
||||
# Basic and Redesenho on different arts: each priced on its own service,
|
||||
# and the basic band counts only the basic arts.
|
||||
mixed = client.call('/quotes', {'request_key': str(uuid4()), 'customer': customer,
|
||||
'items': [arts], 'treatment': [[0, 0], [0, 1], [0, 2]],
|
||||
'redesign': [[0, 3], [0, 4]], 'freight': {'service': 'pickup'}})
|
||||
mixed = client.call('/quotes/' + mixed['id'])['approved']
|
||||
assert mixed['treatment'] == {'cents': 2970, 'hours': 24, 'arts': 3,
|
||||
'unit_cents': 990}, mixed
|
||||
assert mixed['redesign'] == {'cents': 5980, 'hours': 48, 'arts': 2,
|
||||
'unit_cents': 2990}, mixed
|
||||
assert mixed['total_cents'] == mixed['items'][0]['total_cents'] + 2970 + 5980, mixed
|
||||
# Tiny: the line resolves DTFIMP.AJF.RED through the fake catalogue.
|
||||
fake = FakeTiny()
|
||||
pedido = tiny.order_payload({'order_id': two['id'], 'order': redesenho,
|
||||
'number': 2, 'payment': {}, 'origin': 'site'}, 777,
|
||||
date(2026, 11, 12), product_id=fake.product_id)
|
||||
red_code = fake.product_id('DTFIMP.AJF.RED')
|
||||
assert [line for line in pedido['itens'] if line['produto']['id'] == red_code] == [
|
||||
{'produto': {'id': red_code}, 'quantidade': 2, 'valorUnitario': 29.9,
|
||||
'infoAdicional': 'Ajuste Fino Redesenho · 2 artes · +48 h'}], pedido['itens']
|
||||
# One service per art: a pair in both lists is refused by the model.
|
||||
both = client.call('/quotes', {'request_key': str(uuid4()), 'customer': customer,
|
||||
'items': [arts], 'treatment': [[0, 0]], 'redesign': [[0, 0]],
|
||||
'freight': {'service': 'pickup'}}, expected=422)
|
||||
assert 'Escolha Ajuste Fino ou Redesenho' in str(both['detail']), both
|
||||
# Switched off again, a chosen Redesenho is refused.
|
||||
manager.call(f'/operator/site/products/{REDESIGN}', {'enabled': False})
|
||||
refused = client.call('/quotes', {'request_key': str(uuid4()), 'customer': customer,
|
||||
'items': [arts], 'redesign': [[0, 0]], 'freight': {'service': 'pickup'}}, expected=422)
|
||||
assert refused['detail'] == 'O Redesenho não está disponível agora.', refused
|
||||
|
||||
manager.call(f'/operator/site/products/{UV}', {'enabled': True})
|
||||
uid = upload_bytes(client, artwork(), name='LOCAL-SITE-ADMIN.png')
|
||||
item = {**item_spec('uv', '1', 0, uid), 'quality_status': 'warning', 'quality_acknowledged': True}
|
||||
@@ -214,6 +272,7 @@ def run():
|
||||
staff.call(f'/operator/site/prices/{made["id"]}/cancel', {}, expected=403)
|
||||
print('PASS: the Site tab switches a product off and refuses quotes, lists Premium switched off'
|
||||
' and accepts it once enabled, prices Ajuste Fino per art with its band,'
|
||||
' prices Redesenho per art without bands and sends it to Tiny,'
|
||||
' schedules and cancels prices, charges the new price, and refuses a non-manage profile')
|
||||
finally:
|
||||
with db.connect() as c:
|
||||
@@ -221,6 +280,9 @@ def run():
|
||||
c.execute('DELETE FROM dtf_local.product_prices WHERE id=ANY(%s::bigint[])', (prices,))
|
||||
c.execute("UPDATE dtf_local.products SET enabled=true WHERE id=%s", (UV,))
|
||||
c.execute("UPDATE dtf_local.products SET enabled=false WHERE id=%s", (PREMIUM,))
|
||||
if redesign_enabled is not None:
|
||||
c.execute("UPDATE dtf_local.products SET enabled=%s WHERE id=%s",
|
||||
(redesign_enabled, REDESIGN))
|
||||
if treatment_enabled is not None:
|
||||
try:
|
||||
manager.call('/operator/site/products/tratamento', {'enabled': treatment_enabled})
|
||||
|
||||
Reference in New Issue
Block a user