fix: the proof crops the finest stroke and closes the contact wait (0.1)

The browser records where the thinnest stroke sits in the assembled film;
the proof takes a 15 cm window around it instead of always the top. A free
proof no longer fails the layout's billed-metres check, and answering the
proof card clears "Aguardando contato" and ends its timer.
This commit is contained in:
Cauê Faleiros
2026-11-06 11:02:39 -03:00
parent d69e326125
commit 392e7da85b
12 changed files with 163 additions and 17 deletions

View File

@@ -141,9 +141,10 @@ def run():
client.call('/operator/orders/' + oid + '/move', {'state': 'tra', 'version': version}, operator=True)
version += 1
# Printing, the folders still get the file of an order they hold (to take
# it to Finalizado later), and no one else's.
machine = client.call('/operator/machines', {'name': 'Print test '+uuid4().hex[:6],
'products': ['textil']}, operator=True)['id']
# it to Finalizado later), and no one else's. The pull chooses the machine.
tag = uuid4().hex[:6]
machine = client.call('/operator/machines', {'name': f'Hot {tag}', 'products': ['textil']},
operator=True)['id']
client.call('/operator/orders/' + oid + '/move', {'state': 'imp', 'version': version,
'machine_id': machine}, operator=True)
version += 1
@@ -170,10 +171,7 @@ def run():
# Item 10: printing, the file goes once into its machine's hot folder for
# its class; Flexi taking it is reported; leaving Imprimindo withdraws
# what Flexi did not take.
tag = uuid4().hex[:6]
machine = client.call('/operator/machines', {'name': f'Hot {tag}', 'products': ['textil']}, operator=True)['id']
try:
client.call('/operator/orders/' + oid + '/machine', {'machine_id': machine}, operator=True)
# No class measured or chosen: the part waits for one.
assert not [p for p in client.call('/operator/queue/hot', {}, operator=True)['write'] if p['order'] == oid]
client.call('/operator/orders/' + oid + '/contraction', {'item_index': 0, 'value': 'C2'}, operator=True)
@@ -215,6 +213,7 @@ def run():
unread = upload_bytes(client, b'LOCAL PRINT TEST - NOT AN IMAGE', name='LOCAL-PROOF-TEST.cdr')
long = loose_item(unread, copies=1)
long['metres'] = '10.5'
long['proof_y_fraction'] = '0.8'
long['production'] = {**long['production'], 'height_cm': 1050,
'placements': [{**long['production']['placements'][0], 'y_cm': 1040}]}
parent = paid_order(client, long)
@@ -223,6 +222,13 @@ def run():
card = next(o for o in board if o['id'] == mine['proof_card']['id'])
assert card['proof_parent']['number'] == parent['number'] and card['state'] == 'rec', card
assert card['snapshot']['proof_of'] == parent['number'] and card['payment'] == {'provider': 'prova'}
assert float(card['snapshot']['items'][0]['proof_y_fraction']) == 0.8, card['snapshot']['items'][0]
# The proof answer is the customer contact: the old "Aguardando contato"
# mark must not survive it (item 0.1).
with db.connect() as c:
c.execute("""UPDATE dtf_local.orders SET contact_since=now(), contact_by='Site',
contact_note='Prova pedida no site' WHERE id=%s""", (parent['id'],))
c.execute('INSERT INTO dtf_local.contact_waits(order_id,started_at) VALUES(%s,now())', (parent['id'],))
with db.connect() as c:
assert not c.execute('SELECT 1 FROM dtf_local.outbox WHERE event_key LIKE %s', (card['id'] + '%',)).fetchone()
c.execute("UPDATE dtf_local.orders SET state='rev' WHERE id=%s", (card['id'],))
@@ -249,6 +255,10 @@ def run():
mine = next(o for o in board if o['id'] == parent['id'])
assert mine['state'] == 'rec' and mine['proof_card']['proof_result'] == 'rejected', mine['proof_card']
assert mine['proof_card']['proof_reason'] == 'Cor do fundo errada'
assert not mine.get('contact_since'), mine
with db.connect() as c:
assert c.execute('SELECT ended_at FROM dtf_local.contact_waits WHERE order_id=%s',
(parent['id'],)).fetchone()['ended_at']
assert not [o for o in board if o['id'] == card['id']], 'an answered proof card leaves the board'
# Rejection releases the parent for corrected artwork, until a new proof card is opened.
final = upload_bytes(client, artwork(), name='LOCAL-PROOF-FINAL.png', order_id=parent['id'])