Add compliance order pipeline tracking + fix Closed status bug

- Added COMPLIANCE_PIPELINE with 7 stages (Received → Filing → Complete)
- Show service items as type label for compliance orders
- Fixed is_cancelled: only "Cancelled" counts, not "Closed" (ERPNext
  auto-sets Closed when fully billed, which is wrong for active orders)
- Changed delivered badge text from "binder delivered" to "documents delivered"

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
justin 2026-05-04 21:09:58 -05:00
parent 42a81f2868
commit 19eb8ff2e8
2 changed files with 33 additions and 3 deletions

View file

@ -164,7 +164,7 @@
{% if order.is_delivered %}
<div class="pw-delivered-badge">
<svg width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.5" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7"/></svg>
Order complete — binder delivered
Order complete — documents delivered
</div>
{% endif %}

View file

@ -58,6 +58,19 @@ CRTC_PIPELINE = [
CRTC_STATE_INDEX = {state: i for i, (state, _) in enumerate(CRTC_PIPELINE)}
# Compliance (FCC) order workflow states
COMPLIANCE_PIPELINE = [
("Received", "Order Received"),
("Processing", "Generating Documents"),
("Pending eSign", "Awaiting Your Signature"),
("Review", "Admin Review"),
("Filing", "Filing with FCC/USAC"),
("Filed", "Filed — Confirmation Received"),
("Delivered", "Complete"),
]
COMPLIANCE_STATE_INDEX = {state: i for i, (state, _) in enumerate(COMPLIANCE_PIPELINE)}
def get_context(context):
# Must be logged in as a Customer portal user
@ -132,6 +145,23 @@ def get_context(context):
action_label = "Sign CRTC Letter →"
else:
action_label = None
elif order_type == "compliance":
pipeline = COMPLIANCE_PIPELINE
step_index = COMPLIANCE_STATE_INDEX.get(state, 0)
total_steps = len(COMPLIANCE_PIPELINE)
# Show the service items as the type label
so_items = frappe.get_all(
"Sales Order Item",
filters={"parent": so["name"]},
fields=["item_name"],
limit=6,
)
if so_items:
type_label = ", ".join(i.get("item_name", "") for i in so_items if "PROCESSING" not in (i.get("item_name") or "").upper())
else:
type_label = "FCC Compliance Services"
action_url = None
action_label = None
else:
pipeline = []
step_index = 0
@ -179,8 +209,8 @@ def get_context(context):
"invoices": invoices,
"action_url": action_url,
"action_label": action_label,
"is_delivered": state == "Delivered",
"is_cancelled": so.get("status") in ("Cancelled", "Closed"),
"is_delivered": state in ("Delivered", "Filed", "Complete"),
"is_cancelled": so.get("status") == "Cancelled",
})
context.orders = orders