feat(dispatch): 배송사 배지를 로고 이미지로 표시
- store.courier_logo_url: 배송사명(부분 일치) → 로고 SVG URL, 없으면 텍스트 폴백 - Jinja 필터 courier_logo 등록(main.py) - Ninja Van / J&T Express 내장 SVG 로고 추가(static/dispatch/courier/) - 출고 작업 카드 + Kagayaku 전달 요약에 로고 렌더 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -203,6 +203,49 @@ def normalize_quantity(value: Any) -> int:
|
||||
return n if n > 0 else 1
|
||||
|
||||
|
||||
# ── 배송사 로고 ──
|
||||
# 배송사명(부분 일치, 소문자) → 슬러그. 로고 SVG 가 있는 슬러그만 이미지로
|
||||
# 렌더하고, 없으면 텍스트 배지로 폴백한다. 새 배송사 로고 추가 절차:
|
||||
# 1) app/static/dispatch/courier/<슬러그>.svg 추가
|
||||
# 2) 아래 _COURIER_KEYWORDS 에 (키워드, 슬러그) 추가
|
||||
# 3) _COURIER_LOGO_AVAILABLE 에 슬러그 추가
|
||||
_COURIER_KEYWORDS: tuple[tuple[str, str], ...] = (
|
||||
("ninja", "ninjavan"),
|
||||
("j&t", "jnt"),
|
||||
("jnt", "jnt"),
|
||||
("flash", "flash"),
|
||||
("city", "citylink"),
|
||||
("pos laju", "poslaju"),
|
||||
("poslaju", "poslaju"),
|
||||
("gdex", "gdex"),
|
||||
("gd express", "gdex"),
|
||||
("shopee", "spx"),
|
||||
("spx", "spx"),
|
||||
)
|
||||
|
||||
# 실제 SVG 파일이 있는 슬러그만(없는 건 텍스트 폴백 → 깨진 이미지 방지).
|
||||
_COURIER_LOGO_AVAILABLE: frozenset[str] = frozenset({"ninjavan", "jnt"})
|
||||
|
||||
|
||||
def courier_slug(provider: Any) -> str:
|
||||
"""배송사명 → 로고 슬러그(부분 일치). 매칭 없으면 ""."""
|
||||
name = clean_text(provider).lower()
|
||||
if not name:
|
||||
return ""
|
||||
for keyword, slug in _COURIER_KEYWORDS:
|
||||
if keyword in name:
|
||||
return slug
|
||||
return ""
|
||||
|
||||
|
||||
def courier_logo_url(provider: Any) -> str:
|
||||
"""배송사명 → 로고 SVG URL. SVG 없는 배송사는 ""(템플릿이 텍스트로 폴백)."""
|
||||
slug = courier_slug(provider)
|
||||
if slug in _COURIER_LOGO_AVAILABLE:
|
||||
return f"/static/dispatch/courier/{slug}.svg"
|
||||
return ""
|
||||
|
||||
|
||||
def sku_summary(parcels: list[dict[str, Any]]) -> list[dict[str, Any]]:
|
||||
"""전체 박스 기준 SKU별 총 수량(피킹 요약). seller_sku 오름차순."""
|
||||
totals: dict[str, dict[str, Any]] = {}
|
||||
|
||||
Reference in New Issue
Block a user