Wire fulfillment alerts to Telegram + surface order progress in portal + even out ERPNext sync
Telegram notifications: - Add shared scripts/workers/telegram_notify.py (send_telegram, notify_fulfillment_todo, create_admin_todo) so every worker alerts the operator the same way; fire-and-forget. - Fire notify_fulfillment_todo after each admin_todos insert across all 8 service handlers (9 sites) so no fulfillment task waits unseen. (Orders + quotes + tickets already notified via checkout/quotes/tickets routes.) Client portal order progress: - order-timeline: derive real per-step status from live signals (payment paid, e-signature signed, fulfillment_status) instead of a static template; add current_step to the response. - Extract pure applyLiveStatus into order-timeline-status.ts (DB-free) + unit test (api/test/test_timeline_status.ts, 8 cases). - portal /me now returns compliance_orders.fulfillment_status. - Dashboard renders a client-safe Progress badge (In progress / Action needed / Filed-awaiting-confirmation / Completed); batches show the most actionable status. No back-office mechanics exposed. ERPNext sync parity: - Create a Sales Order for formation and fcc_carrier_registration orders (previously only canada_crtc + compliance synced); write erpnext_sales_order back to each table. Non-blocking, matches existing pattern. Verified: API tsc clean, timeline unit tests 8/8, Astro build 58 pages, cms10114/ink/paper_batch Python tests still green, no mechanics leaks.
This commit is contained in:
parent
41df4d9553
commit
28b1af341d
15 changed files with 706 additions and 73 deletions
|
|
@ -27,6 +27,8 @@ import logging
|
|||
import os
|
||||
from datetime import datetime
|
||||
|
||||
from scripts.workers.telegram_notify import notify_fulfillment_todo
|
||||
|
||||
LOG = logging.getLogger("workers.services.mailbox_setup")
|
||||
|
||||
|
||||
|
|
@ -101,6 +103,18 @@ class MailboxSetupHandler:
|
|||
try:
|
||||
import psycopg2
|
||||
conn = psycopg2.connect(os.environ.get("DATABASE_URL", ""))
|
||||
todo_title = f"Mailbox Setup — {entity_name} ({formation_state})"
|
||||
todo_description = (
|
||||
f"Set up Anytime Mailbox for {entity_name} in {formation_state}.\n\n"
|
||||
f"Steps:\n"
|
||||
f"1. Customer e-signs USPS Form 1583 (link sent)\n"
|
||||
f"2. Schedule online notarization session\n"
|
||||
f"3. Submit notarized 1583 to Anytime Mailbox\n"
|
||||
f"4. Activate mailbox, provide address to customer\n\n"
|
||||
f"Customer: {customer_email}\n"
|
||||
f"Photo ID: on file in MinIO (from intake)\n"
|
||||
f"Notarization: use same service as CRTC BITS"
|
||||
)
|
||||
with conn.cursor() as cur:
|
||||
cur.execute("""
|
||||
INSERT INTO admin_todos (
|
||||
|
|
@ -108,20 +122,12 @@ class MailboxSetupHandler:
|
|||
description, data, status
|
||||
) VALUES (%s, %s, %s, %s, %s, %s, %s, 'pending')
|
||||
""", (
|
||||
f"Mailbox Setup — {entity_name} ({formation_state})",
|
||||
todo_title,
|
||||
"provisioning",
|
||||
"normal",
|
||||
order_number,
|
||||
self.SERVICE_SLUG,
|
||||
f"Set up Anytime Mailbox for {entity_name} in {formation_state}.\n\n"
|
||||
f"Steps:\n"
|
||||
f"1. Customer e-signs USPS Form 1583 (link sent)\n"
|
||||
f"2. Schedule online notarization session\n"
|
||||
f"3. Submit notarized 1583 to Anytime Mailbox\n"
|
||||
f"4. Activate mailbox, provide address to customer\n\n"
|
||||
f"Customer: {customer_email}\n"
|
||||
f"Photo ID: on file in MinIO (from intake)\n"
|
||||
f"Notarization: use same service as CRTC BITS",
|
||||
todo_description,
|
||||
json.dumps({
|
||||
"order_number": order_number,
|
||||
"entity_name": entity_name,
|
||||
|
|
@ -130,6 +136,13 @@ class MailboxSetupHandler:
|
|||
}),
|
||||
))
|
||||
conn.commit()
|
||||
notify_fulfillment_todo(
|
||||
title=todo_title,
|
||||
order_number=order_number,
|
||||
service_slug=self.SERVICE_SLUG,
|
||||
priority="normal",
|
||||
description=todo_description,
|
||||
)
|
||||
conn.close()
|
||||
except Exception as exc:
|
||||
LOG.error("[%s] Failed to create mailbox todo: %s", order_number, exc)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue