feat(malaysia): 재고현황 조사수량·차이 표기, 확정 관리자 제한, 슈퍼관리자 조사삭제

- 재고현황 헤더 "전산 재고 현황", Last Stocktake 옆 조사수량+차이(±) 표기
  (차이 = 마지막 재고조사 낱개 total − 전산재고)
- 재고조사 확정(전산 반영)은 관리자(is_admin)만 가능, 비관리자 안내
- 슈퍼관리자만 재고조사 완전 삭제(목록/상세 버튼 + /delete 라우트)
- "◀◀ 조사 목록" 버튼 검정 바탕(primary)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-11 16:38:38 +09:00
parent 3d85ccf43e
commit c07d3301e4
5 changed files with 102 additions and 16 deletions
+22
View File
@@ -360,6 +360,28 @@ class MalaysiaStockStore:
out.sort(key=lambda x: x["item_code"])
return out
def latest_stocktake(self, *, warehouse_code: str) -> dict[str, Any] | None:
"""가장 최근(취소 제외) 재고조사 헤더. 없으면 None."""
with self._pool.connection() as conn:
row = conn.execute(
"SELECT * FROM daily_stocktake "
"WHERE warehouse_code = %s AND status <> 'cancelled' "
"ORDER BY stocktake_date DESC, id DESC LIMIT 1",
(warehouse_code,),
).fetchone()
return self._serialize(row) if row else None
def delete_stocktake(self, *, stocktake_id: int) -> None:
"""재고조사 완전 삭제(헤더+라인 CASCADE). 슈퍼관리자 전용 동작.
주의: finalize 시 생성된 STOCKTAKE movement 는 별도이므로 같이 지우지 않는다
(재고 이력 보존). 헤더/라인만 제거.
"""
with self._pool.connection() as conn:
cur = conn.execute("DELETE FROM daily_stocktake WHERE id = %s", (stocktake_id,))
if cur.rowcount == 0:
raise KeyError(stocktake_id)
def latest_set_quantities(self, *, warehouse_code: str) -> dict[str, Any]:
"""가장 최근(취소 제외) 재고조사에 입력된 콤보(MY-) 수량.