diff --git a/scripts/workers/services/base_handler.py b/scripts/workers/services/base_handler.py index 2a20ffa..56389d8 100644 --- a/scripts/workers/services/base_handler.py +++ b/scripts/workers/services/base_handler.py @@ -234,31 +234,16 @@ class BaseServiceHandler(ABC): except Exception as exc: logger.warning("Could not update order status: %s", exc) - # For batch orders, only the first order (lowest order_number) sends the - # intake email. Others just pause silently. This avoids the race condition - # where concurrent handlers all check DB before any has committed. - if batch_id and customer_email: - try: - conn2 = psycopg2.connect(os.environ.get("DATABASE_URL", "")) - cur2 = conn2.cursor() - cur2.execute( - """SELECT MIN(order_number) FROM compliance_orders - WHERE batch_id = %s""", - (batch_id,), - ) - first_order = cur2.fetchone()[0] - cur2.close() - conn2.close() - if first_order and order_number != first_order: - logger.info( - "Skipping intake email for %s — batch %s will send from %s", - order_number, batch_id, first_order, - ) - return - except Exception: - pass # If check fails, send the email anyway + # For batch orders, the checkout API already sends a combined intake + # email (sendComplianceIntakeEmail). Workers should NOT send their own. + if batch_id: + logger.info( + "Skipping worker intake email for %s — batch %s intake email sent by checkout API", + order_number, batch_id, + ) + return - # Email the client + # Email the client (single/standalone orders only) if customer_email: try: import PyJWT as pyjwt diff --git a/site/src/components/intake/Wizard.astro b/site/src/components/intake/Wizard.astro index 930e1a6..53e59cd 100644 --- a/site/src/components/intake/Wizard.astro +++ b/site/src/components/intake/Wizard.astro @@ -319,8 +319,18 @@ const STEP_LABELS: Record = { }; // ── Pre-fill from order data when accessed via token (paid batch order) ── + // Also remove the "payment" step since payment is already done. + const urlParams = new URLSearchParams(window.location.search); + if (urlParams.has("token") || urlParams.has("order")) { + const payIdx = steps.indexOf("payment"); + if (payIdx >= 0) { + steps.splice(payIdx, 1); + rebuildStepBar(); + } + } + (async () => { - const params = new URLSearchParams(window.location.search); + const params = urlParams; const token = params.get("token"); const frn = params.get("frn"); if (!token) return;