feat: discard an unpaid quote, delete a test order, cancel a paid one
All checks were successful
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 2m44s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 54s
All checks were successful
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 2m44s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 54s
Cotações (now subtitled "pedidos ainda não pagos") can discard a quote: it leaves every list and the search, and a payment for it is refused like an expired one. A test order can be deleted with its history; its quote is unpaid again. A paid order is cancelled with a required reason: it leaves the board for a "Cancelados" chip, keeps its payment and history, can no longer move, and the customer's account shows it as cancelled. Refunds stay at Mercado Pago and Tiny is not told; the cancel form says so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -147,15 +147,15 @@ ENTRIES = '''WITH live_quote AS (
|
||||
-- files are gone can no longer be paid.
|
||||
SELECT q.id, q.created_at, q.approved FROM dtf_local.quotes q
|
||||
LEFT JOIN dtf_local.orders o ON o.quote_id=q.id
|
||||
WHERE q.owner=%(me)s AND o.id IS NULL
|
||||
WHERE q.owner=%(me)s AND o.id IS NULL AND q.discarded_at IS NULL
|
||||
AND NOT EXISTS (SELECT 1 FROM jsonb_array_elements(q.draft->'items') i
|
||||
CROSS JOIN LATERAL jsonb_array_elements_text(i->'uploads') u(uid)
|
||||
JOIN dtf_local.uploads up ON up.id=u.uid::uuid
|
||||
WHERE up.purged_at IS NOT NULL OR up.expires_at<=now())
|
||||
ORDER BY q.created_at DESC LIMIT 1
|
||||
), entries AS (
|
||||
SELECT 'order' AS kind, o.id, o.number, o.state,
|
||||
CASE WHEN o.state='fin' THEN 'fin' WHEN o.state='cor' THEN 'cor' ELSE 'prod' END AS grp,
|
||||
SELECT 'order' AS kind, o.id, o.number, CASE WHEN o.cancelled_at IS NOT NULL THEN 'cancelled' ELSE o.state END,
|
||||
CASE WHEN o.cancelled_at IS NOT NULL OR o.state='fin' THEN 'fin' WHEN o.state='cor' THEN 'cor' ELSE 'prod' END AS grp,
|
||||
(o.snapshot->>'total_cents')::bigint AS total_cents, o.created_at, o.snapshot->'items' AS items
|
||||
FROM dtf_local.orders o WHERE o.owner=%(me)s
|
||||
UNION ALL
|
||||
|
||||
Reference in New Issue
Block a user