diff --git a/app/modules/dispatch/router.py b/app/modules/dispatch/router.py index 809a8bd..96996cb 100644 --- a/app/modules/dispatch/router.py +++ b/app/modules/dispatch/router.py @@ -426,6 +426,28 @@ async def stock_export( raise HTTPException(status_code=404, detail="해당 날짜의 출고 데이터가 없습니다.") 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) fname = export.stock_filename(d) headers = {