Files

47 lines
1.5 KiB
Python

"""
Turns a ticket's tracking numbers into the JIRA status your team would
set it to at end-of-day close-out - "Waiting For Return" if a return
label was also generated by ShipStation's automation, "Device Return
Not Needed" if it's outgoing-only. Saves having to eyeball each one.
"""
from __future__ import annotations
from typing import List, Optional
from app import config
from app.status_rules import parse_status_list
def get_fulfilled_statuses() -> set[str]:
"""The two statuses that mean 'done, move to the Done pile'."""
return 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
),
]
)
)
def suggest_jira_status(tracking_numbers: List[dict]) -> Optional[str]:
if not tracking_numbers:
return None
has_outgoing = any(not t.get("is_return") for t in tracking_numbers)
has_return = any(t.get("is_return") for t in tracking_numbers)
if not has_outgoing:
# Only a return label with no outgoing - unusual, don't guess.
return None
if has_return:
return config.get(
"FULFILLED_STATUS_WITH_RETURN", config.DEFAULT_FULFILLED_WITH_RETURN
)
return config.get(
"FULFILLED_STATUS_WITHOUT_RETURN", config.DEFAULT_FULFILLED_WITHOUT_RETURN
)