Rework of workflow, added the dock back. This is now the beginning of the SKU mismatch issues. FKN FUN TIMES AHEAD

This commit is contained in:
2026-09-04 12:09:49 -05:00
parent a1b438a61f
commit 52bd6f5da2
8 changed files with 395 additions and 68 deletions
+39 -10
View File
@@ -4,15 +4,20 @@ Order detail dialog.
Mainly a debugging aid: shows exactly what JIRA sent back for this
ticket (raw payload), plus the tracking numbers ShipStation supplied
and the JIRA status they suggest - handy for the end-of-day close-out
without having to piece it together by hand.
without having to piece it together by hand. Also offers quick jumps
out to JIRA and Google Maps, since those are common next steps when
something about a ticket needs a closer look.
"""
from __future__ import annotations
import json
import webbrowser
from PyQt6.QtWidgets import QDialog, QVBoxLayout, QTextEdit, QLabel, QPushButton
from PyQt6.QtWidgets import QDialog, QVBoxLayout, QHBoxLayout, QTextEdit, QLabel, QPushButton
from app.external_links import jira_ticket_url, google_maps_search_url
from app.models import Order
from app.ticket_validation import validate_ticket
from app.tracking import suggest_jira_status
@@ -38,21 +43,31 @@ class OrderDetailDialog(QDialog):
info = order.shipping_info or {}
address_line2 = f" {info.get('address2')}" if info.get("address2") else ""
issues = validate_ticket(order.skus, order.line_items)
summary_lines = [
f"Ticket #: {order.ticket_number or '(none found)'}",
f"Company: {order.company}",
f"Created by: {order.creator or '(unknown)'}",
f"SKUs: {', '.join(order.skus or []) or '(none extracted)'}",
f"Status: {order.status}",
"",
"Shipping info (used by the emergency Send to ShipStation action):",
f" Name: {info.get('name') or '(missing)'}",
f" Address: {info.get('address1') or '(missing)'}{address_line2}",
f" {info.get('city', '')}, {info.get('state', '')} {info.get('zip', '')}".rstrip(),
f" Phone: {info.get('phone') or '(none)'} Email: {info.get('email') or '(none)'}",
"",
"Tracking numbers:",
]
if issues:
summary_lines.append("")
summary_lines.append("\u26a0 Flagged for review:")
summary_lines.extend(f" - {issue.message}" for issue in issues)
summary_lines.extend(
[
"",
"Shipping info (used by the emergency Send to ShipStation action):",
f" Name: {info.get('name') or '(missing)'}",
f" Address: {info.get('address1') or '(missing)'}{address_line2}",
f" {info.get('city', '')}, {info.get('state', '')} {info.get('zip', '')}".rstrip(),
f" Phone: {info.get('phone') or '(none)'} Email: {info.get('email') or '(none)'}",
"",
"Tracking numbers:",
]
)
summary_lines.extend(tracking_lines or [" (none pulled yet)"])
if suggested:
summary_lines.append("")
@@ -61,6 +76,16 @@ class OrderDetailDialog(QDialog):
summary_label = QLabel("\n".join(summary_lines))
layout.addWidget(summary_label)
link_buttons = QHBoxLayout()
jira_button = QPushButton("View in JIRA")
jira_button.clicked.connect(lambda: self._open_url(jira_ticket_url(order.ticket_number)))
link_buttons.addWidget(jira_button)
maps_button = QPushButton("Look Up Address on Google Maps")
maps_button.clicked.connect(lambda: self._open_url(google_maps_search_url(order.shipping_info)))
link_buttons.addWidget(maps_button)
link_buttons.addStretch()
layout.addLayout(link_buttons)
layout.addWidget(QLabel("Raw payload from source system:"))
text = QTextEdit()
text.setReadOnly(True)
@@ -71,3 +96,7 @@ class OrderDetailDialog(QDialog):
close_button = QPushButton("Close")
close_button.clicked.connect(self.accept)
layout.addWidget(close_button)
def _open_url(self, url: str | None) -> None:
if url:
webbrowser.open(url)
+17 -3
View File
@@ -30,17 +30,21 @@ from app.models import Order
from app.return_labels import is_emailed_label_order
from app.schedule import get_cutoff_time, is_past_cutoff_today
from app.status_rules import get_cancelled_statuses, status_in
from app.ticket_validation import validate_ticket
from app.tracking import get_fulfilled_statuses
CANCELLED_TEXT_COLOR = QColor(180, 0, 0)
FULFILLED_ROW_COLOR = QColor(210, 240, 210)
ISSUE_TEXT_COLOR = QColor(170, 100, 0)
CHECK_MARK = "\u2713"
WARNING_MARK = "\u26a0"
# Order here is display order, left to right.
COLUMNS = [
("company", "Company"),
("ticket_number", "Ticket #"),
("status", "Status"),
("issues_display", "Issues"),
("packed_display", "Done"),
("skus_display", "SKUs"),
("summary", "Summary"),
@@ -108,9 +112,14 @@ class OrdersTableModel(QAbstractTableModel):
order = self._orders[index.row()]
is_cancelled = status_in(order.status, self._cancelled_statuses)
field_name, _ = COLUMNS[index.column()]
if role == Qt.ItemDataRole.ForegroundRole:
return CANCELLED_TEXT_COLOR if is_cancelled else None
if is_cancelled:
return CANCELLED_TEXT_COLOR
if field_name == "issues_display" and validate_ticket(order.skus, order.line_items):
return ISSUE_TEXT_COLOR
return None
if role == Qt.ItemDataRole.BackgroundRole:
# Cancelled rows use red TEXT (above) instead of a background,
@@ -121,11 +130,16 @@ class OrdersTableModel(QAbstractTableModel):
return FULFILLED_ROW_COLOR
return None
if role == Qt.ItemDataRole.ToolTipRole and field_name == "issues_display":
issues = validate_ticket(order.skus, order.line_items)
return "\n".join(i.message for i in issues) if issues else None
if role != Qt.ItemDataRole.DisplayRole:
return None
field_name, _ = COLUMNS[index.column()]
if field_name == "issues_display":
issues = validate_ticket(order.skus, order.line_items)
return f"{WARNING_MARK} ({len(issues)})" if issues else ""
if field_name == "skus_display":
return ", ".join(order.skus or [])
if field_name == "packed_display":