EOD and Carryover tickets added
This commit is contained in:
@@ -28,7 +28,9 @@ from PyQt6.QtWidgets import (
|
||||
|
||||
from app import config
|
||||
from app.models import Order
|
||||
from app.schedule import get_cutoff_time, is_past_cutoff
|
||||
from app.status_rules import parse_status_list, status_in
|
||||
from app.tracking import get_fulfilled_statuses
|
||||
|
||||
CANCELLED_ROW_COLOR = QColor(255, 210, 210)
|
||||
FULFILLED_ROW_COLOR = QColor(210, 240, 210)
|
||||
@@ -40,7 +42,8 @@ COLUMNS = [
|
||||
("summary", "Summary"),
|
||||
("status", "Status"),
|
||||
("tracking_display", "Tracking #"),
|
||||
("source_created_at", "Created"),
|
||||
("created_display", "Created"),
|
||||
("past_cutoff_display", "Past Cutoff"),
|
||||
]
|
||||
|
||||
ALL_COMPANIES = "All Companies"
|
||||
@@ -55,31 +58,27 @@ def _format_tracking(tracking_numbers) -> str:
|
||||
)
|
||||
|
||||
|
||||
def _format_created(source_created_at) -> str:
|
||||
if not source_created_at:
|
||||
return ""
|
||||
return source_created_at.strftime("%b %d, %I:%M %p").replace(" 0", " ")
|
||||
|
||||
|
||||
class OrdersTableModel(QAbstractTableModel):
|
||||
def __init__(self, orders: List[Order] | None = None, parent=None):
|
||||
super().__init__(parent)
|
||||
self._orders: List[Order] = orders or []
|
||||
self._cancelled_statuses: set[str] = set()
|
||||
self._fulfilled_statuses: set[str] = set()
|
||||
self._cutoff_time = None
|
||||
|
||||
def set_orders(self, orders: List[Order]) -> None:
|
||||
# Re-read status lists each refresh, in case Settings changed.
|
||||
# Re-read status lists and cutoff time each refresh, in case Settings changed.
|
||||
self._cancelled_statuses = parse_status_list(
|
||||
config.get("CANCELLED_STATUSES", config.DEFAULT_CANCELLED_STATUSES)
|
||||
)
|
||||
self._fulfilled_statuses = parse_status_list(
|
||||
",".join(
|
||||
[
|
||||
config.get(
|
||||
"FULFILLED_STATUS_WITH_RETURN", config.DEFAULT_FULFILLED_WITH_RETURN
|
||||
),
|
||||
config.get(
|
||||
"FULFILLED_STATUS_WITHOUT_RETURN",
|
||||
config.DEFAULT_FULFILLED_WITHOUT_RETURN,
|
||||
),
|
||||
]
|
||||
)
|
||||
)
|
||||
self._fulfilled_statuses = get_fulfilled_statuses()
|
||||
self._cutoff_time = get_cutoff_time()
|
||||
self.beginResetModel()
|
||||
self._orders = orders
|
||||
self.endResetModel()
|
||||
@@ -119,6 +118,10 @@ class OrdersTableModel(QAbstractTableModel):
|
||||
return ", ".join(order.skus or [])
|
||||
if field_name == "tracking_display":
|
||||
return _format_tracking(order.tracking_numbers)
|
||||
if field_name == "created_display":
|
||||
return _format_created(order.source_created_at)
|
||||
if field_name == "past_cutoff_display":
|
||||
return "Yes" if is_past_cutoff(order.source_created_at, self._cutoff_time) else ""
|
||||
|
||||
value = getattr(order, field_name)
|
||||
return "" if value is None else str(value)
|
||||
|
||||
Reference in New Issue
Block a user