feat(malaysia): 슈퍼관리자 재고 데이터 초기화

- 재고 현황 하단 '위험 구역' 카드(슈퍼관리자만 표시)
- POST /malaysia/reset: stock_movement + daily_stocktake(+line) 전체 삭제
  → 전체 창고 현재고/조사값 0. 마스터(창고/아이템) 보존.
- 권한: is_super_admin 아니면 403 (버튼 숨김 + 서버 이중 검사)
- 2단 확인(confirm + RESET 타이핑)
- i18n 추가, malaysia.js 캐시 버전 bump

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-12 11:32:30 +09:00
parent 84d266ea89
commit 8f882ff4cd
5 changed files with 60 additions and 1 deletions
+18
View File
@@ -688,6 +688,24 @@ class MalaysiaStockStore:
head = self.get_stocktake(stocktake_id=stocktake_id, with_lines=True)
return {"stocktake": head, "adjustments": adjustments, "rows": rows}
# ════════════════════════════════════════════════════════════
# 데이터 초기화 (슈퍼관리자 전용 — 라우터에서 권한 검사)
# ════════════════════════════════════════════════════════════
def reset_all_data(self) -> dict[str, int]:
"""전체 창고의 재고 수량 데이터 초기화.
삭제 대상: stock_movement(입고/출고/조정/조사반영) +
daily_stocktake/daily_stocktake_line(재고조사).
보존 대상: warehouses, malaysia_items(마스터).
한 트랜잭션으로 처리. 반환: 삭제 건수.
"""
with self._pool.connection() as conn:
with conn.transaction():
mv = conn.execute("DELETE FROM stock_movement").rowcount or 0
ln = conn.execute("DELETE FROM daily_stocktake_line").rowcount or 0
hd = conn.execute("DELETE FROM daily_stocktake").rowcount or 0
return {"movements": mv, "stocktake_lines": ln, "stocktakes": hd}
# ════════════════════════════════════════════════════════════
# 직렬화
# ════════════════════════════════════════════════════════════