FKN SHITSTATION AND THEIR GODDAMN SANDBOX BS - Sandbox will be it's own separate entity
This commit is contained in:
+84
-3
@@ -159,14 +159,31 @@ class MainWindow(QMainWindow):
|
||||
list_carriers_action.triggered.connect(self._on_list_carriers_clicked)
|
||||
data_menu.addAction(list_carriers_action)
|
||||
|
||||
list_stores_action = QAction("List ShipStation Stores...", self)
|
||||
list_stores_action = QAction("About ShipStation Store IDs...", self)
|
||||
list_stores_action.setStatusTip(
|
||||
"Shows the store IDs actually valid for whichever API key is currently active "
|
||||
"(test or production)"
|
||||
"ShipStation's V2 API has no way to list stores - explains where to find a "
|
||||
"store_id instead"
|
||||
)
|
||||
list_stores_action.triggered.connect(self._on_list_stores_clicked)
|
||||
data_menu.addAction(list_stores_action)
|
||||
|
||||
list_warehouses_action = QAction("List ShipStation Warehouses...", self)
|
||||
list_warehouses_action.setStatusTip(
|
||||
"Shows the warehouse IDs actually valid for whichever API key is currently active "
|
||||
"(test or production)"
|
||||
)
|
||||
list_warehouses_action.triggered.connect(self._on_list_warehouses_clicked)
|
||||
data_menu.addAction(list_warehouses_action)
|
||||
|
||||
create_test_warehouses_action = QAction("Create Test Warehouse(s)...", self)
|
||||
create_test_warehouses_action.setStatusTip(
|
||||
"Test Mode only - the sandbox account starts with zero warehouses, so this "
|
||||
"creates one per company (using the same return-address settings) and saves "
|
||||
"the resulting IDs into TEST_SHIPSTATION_*_WAREHOUSE_ID"
|
||||
)
|
||||
create_test_warehouses_action.triggered.connect(self._on_create_test_warehouses_clicked)
|
||||
data_menu.addAction(create_test_warehouses_action)
|
||||
|
||||
orders_menu = menu_bar.addMenu("&Orders")
|
||||
|
||||
self._pack_ticket_action = QAction("Pack Ticket", self)
|
||||
@@ -305,6 +322,70 @@ class MainWindow(QMainWindow):
|
||||
)
|
||||
QMessageBox.information(self, f"ShipStation Stores ({mode})", "\n".join(lines))
|
||||
|
||||
def _on_list_warehouses_clicked(self) -> None:
|
||||
from app.services.shipstation_send import list_warehouses, ShipStationSendError
|
||||
|
||||
mode = "TEST" if config.is_shipstation_test_mode() else "PRODUCTION"
|
||||
try:
|
||||
warehouses = list_warehouses()
|
||||
except ShipStationSendError as exc:
|
||||
QMessageBox.critical(self, "Could not list warehouses", str(exc))
|
||||
return
|
||||
|
||||
if not warehouses:
|
||||
QMessageBox.information(
|
||||
self,
|
||||
f"ShipStation Warehouses ({mode})",
|
||||
f"No warehouses are set up in this {mode.lower()} ShipStation account.",
|
||||
)
|
||||
return
|
||||
|
||||
lines = [f"Warehouses visible to your current {mode} API key:", ""]
|
||||
for warehouse in warehouses:
|
||||
lines.append(
|
||||
f" warehouse_id: {warehouse.get('warehouse_id', '?')} "
|
||||
f"{warehouse.get('name', '?')}"
|
||||
)
|
||||
QMessageBox.information(self, f"ShipStation Warehouses ({mode})", "\n".join(lines))
|
||||
|
||||
def _on_create_test_warehouses_clicked(self) -> None:
|
||||
if not config.is_shipstation_test_mode():
|
||||
QMessageBox.information(
|
||||
self,
|
||||
"Test Mode is off",
|
||||
"Turn on ShipStation Test Mode first (Data menu). This creates a "
|
||||
"warehouse in whichever ShipStation account your API key currently "
|
||||
"points to, and it's meant for the sandbox account only.",
|
||||
)
|
||||
return
|
||||
|
||||
from app.services.shipstation_send import (
|
||||
create_test_warehouse_for_company,
|
||||
ShipStationSendError,
|
||||
)
|
||||
|
||||
companies = [
|
||||
("Signify Health", "TEST_SHIPSTATION_SIGNIFY_WAREHOUSE_ID"),
|
||||
("Oak Street Health", "TEST_SHIPSTATION_OAKSTREET_WAREHOUSE_ID"),
|
||||
]
|
||||
|
||||
lines = []
|
||||
for company, setting_key in companies:
|
||||
existing = config.load_settings().get(setting_key)
|
||||
if existing:
|
||||
lines.append(f"{company}: already set to {existing} - skipped")
|
||||
continue
|
||||
try:
|
||||
warehouse = create_test_warehouse_for_company(company)
|
||||
except ShipStationSendError as exc:
|
||||
lines.append(f"{company}: FAILED - {exc}")
|
||||
continue
|
||||
warehouse_id = warehouse.get("warehouse_id", "")
|
||||
config.save_settings({setting_key: warehouse_id})
|
||||
lines.append(f"{company}: created {warehouse_id} and saved it to {setting_key}")
|
||||
|
||||
QMessageBox.information(self, "Create Test Warehouse(s)", "\n".join(lines))
|
||||
|
||||
def _on_order_double_clicked(self, order) -> None:
|
||||
dialog = OrderDetailDialog(order, self)
|
||||
dialog.exec()
|
||||
|
||||
Reference in New Issue
Block a user