From 85dffb01786bf2008d90b67acb654978b5a37017 Mon Sep 17 00:00:00 2001 From: king Date: Thu, 25 Jun 2026 18:03:45 +0900 Subject: [PATCH] =?UTF-8?q?fix(dispatch):=20=EC=82=AC=EB=B0=A9=EB=84=B7=20?= =?UTF-8?q?=EC=B6=9C=EA=B3=A0=20=EC=97=91=EC=85=80=20=E2=80=94=20=EC=84=B8?= =?UTF-8?q?=ED=8A=B8=20BOM=20=EC=97=86=EC=9C=BC=EB=A9=B4=20=EC=A1=B0?= =?UTF-8?q?=EC=9A=A9=ED=9E=88=20=EB=AF=B8=EB=B6=84=ED=95=B4=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EB=8C=80=EC=8B=A0=20=EB=AA=85=ED=99=95=ED=95=9C=20?= =?UTF-8?q?=EC=97=90=EB=9F=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 세트(MY-)인데 set_bom 에서 BOM 을 못 찾으면 낱개 분해가 안 된 엑셀이 조용히 만들어졌다. 이제 어떤 세트가 분해 불가인지와 원인(itemcode_ro set_components SELECT 권한/누락 BOM)을 422 로 알린다. Co-Authored-By: Claude Opus 4.8 --- app/modules/dispatch/router.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) 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 = {