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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user