More Shipstation integrations(warehouses)
This commit is contained in:
+24
-3
@@ -2,15 +2,27 @@
|
||||
Status matching helpers.
|
||||
|
||||
Kept separate from companies.py because this is about order lifecycle
|
||||
state (cancelled, terminal-for-recheck-purposes, and later probably
|
||||
"fulfilled"/"shipped"/etc.) rather than company identity - a different
|
||||
axis of classification that will grow independently.
|
||||
state rather than company identity - a different axis of classification
|
||||
that grows independently.
|
||||
|
||||
The model is deliberately an allowlist, not a denylist: ACTIVE_STATUSES
|
||||
is the small set of statuses that represent real work still to do
|
||||
(just "Created" by default). Anything NOT in ACTIVE_STATUSES or
|
||||
CANCELLED_STATUSES is treated as done, automatically - including
|
||||
statuses this app has never been told about by name (like a JIRA
|
||||
automation status such as "1st Contact Attempt" that fires after a
|
||||
ticket is already handled). That's on purpose: enumerating every
|
||||
possible "this means it's done" status would be a losing game as more
|
||||
JIRA-side automation gets added; only naming the couple of statuses
|
||||
that mean "not done yet" is far more robust.
|
||||
|
||||
Matching is case-insensitive since JIRA and ShipStation don't
|
||||
necessarily agree on casing (e.g. "Cancelled" vs "cancelled").
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from app import config
|
||||
|
||||
|
||||
def parse_status_list(raw: str) -> set[str]:
|
||||
return {s.strip().lower() for s in (raw or "").split(",") if s.strip()}
|
||||
@@ -20,6 +32,15 @@ def status_in(status: str | None, status_set: set[str]) -> bool:
|
||||
return (status or "").strip().lower() in status_set
|
||||
|
||||
|
||||
def get_active_statuses() -> set[str]:
|
||||
"""Statuses that mean real, unfinished work - default just 'Created'."""
|
||||
return parse_status_list(config.get("ACTIVE_STATUSES", config.DEFAULT_ACTIVE_STATUSES))
|
||||
|
||||
|
||||
def get_cancelled_statuses() -> set[str]:
|
||||
return parse_status_list(config.get("CANCELLED_STATUSES", config.DEFAULT_CANCELLED_STATUSES))
|
||||
|
||||
|
||||
def find_new_cancellations(status_changes: list[dict], cancelled_statuses: set[str]) -> list[dict]:
|
||||
"""
|
||||
From a batch of status changes, return only the ones that just BECAME
|
||||
|
||||
Reference in New Issue
Block a user