fix(dispatch): 사방넷 출고 엑셀 — 세트 BOM 없으면 조용히 미분해 파일 대신 명확한 에러

세트(MY-)인데 set_bom 에서 BOM 을 못 찾으면 낱개 분해가 안 된 엑셀이
조용히 만들어졌다. 이제 어떤 세트가 분해 불가인지와 원인(itemcode_ro
set_components SELECT 권한/누락 BOM)을 422 로 알린다.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-25 18:03:45 +09:00
parent b74d2be6d3
commit 85dffb0178
+22
View File
@@ -426,6 +426,28 @@ async def stock_export(
raise HTTPException(status_code=404, detail="해당 날짜의 출고 데이터가 없습니다.") raise HTTPException(status_code=404, detail="해당 날짜의 출고 데이터가 없습니다.")
set_bom, sabangnet_map = _itemcode_bom_and_sabangnet(request) set_bom, sabangnet_map = _itemcode_bom_and_sabangnet(request)
# 세트(MY-)인데 BOM 을 못 찾으면 낱개 분해가 안 된 채 파일이 만들어진다.
# 조용히 잘못된 파일을 주지 말고, 어떤 세트가 분해 안 되는지 명확히 알린다.
missing_sets = sorted({
b for b in (
export.split_sku(r.get("seller_sku", ""))[0].strip().upper() for r in rows
)
if b.startswith(export._SET_PREFIX) and b not in set_bom
})
if missing_sets:
reader = getattr(request.app.state, "malaysia_itemcode", None)
hint = getattr(reader, "last_error", "") or getattr(reader, "reason", "")
detail = (
"세트 BOM 을 찾지 못해 낱개로 분해할 수 없습니다: "
+ ", ".join(missing_sets)
+ ". itemcode_db 의 set_components 에 해당 세트 BOM 이 등록돼 있는지, "
"읽기 전용 역할(itemcode_ro)에 set_components SELECT 권한이 있는지 확인하세요."
)
if hint:
detail += f" (itemcode 리더 오류: {hint})"
raise HTTPException(status_code=422, detail=detail)
xlsx_bytes = export.build_stock_xlsx(rows=rows, set_bom=set_bom, sabangnet_map=sabangnet_map) xlsx_bytes = export.build_stock_xlsx(rows=rows, set_bom=set_bom, sabangnet_map=sabangnet_map)
fname = export.stock_filename(d) fname = export.stock_filename(d)
headers = { headers = {