From 4c171587536693f003b2a86d82fd132045951419 Mon Sep 17 00:00:00 2001 From: king Date: Fri, 16 Oct 2026 15:45:53 +0900 Subject: [PATCH] =?UTF-8?q?feat(inout):=20=EC=98=B5=EC=85=98=EC=9D=84=20?= =?UTF-8?q?=ED=86=B1=EB=8B=88=20=ED=8C=9D=EC=97=85=EC=9C=BC=EB=A1=9C,=20?= =?UTF-8?q?=EA=B2=B9=EC=B9=98=EB=8D=98=20=EC=98=B5=EC=85=98=20=ED=99=94?= =?UTF-8?q?=EB=A9=B4=20=EC=A0=95=EB=A6=AC,=20=EA=B3=B5=EC=9E=A5=20?= =?UTF-8?q?=EB=8B=B4=EB=8B=B9=EC=9E=90=C2=B7=EC=97=B0=EB=9D=BD=EC=B2=98=20?= =?UTF-8?q?=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 옵션 탭 → 상단 오른쪽 톱니(관리자) → 팝업(탭: 담당자·공장). 내용은 /inout/settings?panel=1, 저장은 팝업 안에서(X-Inout-Options: 1 → JSON, 같은 탭 그대로 다시 그림), 바뀌면 닫을 때 새로고침. 예전 /inout/settings 주소는 목록으로 가서 팝업 열기(?options=1). - 겹침 원인: 공용 .erp-input(min-width 240px + content-box)이 좁은 칸에서 옆 칸을 덮고, .erp-table-wrap(카드 그림자·둥근 모서리)이 카드 안에서 상자를 겹쳐 보이게 함 → .io/.io-dlg 안에서만 바로잡음. 공장 표는 진짜 + 입력칸 form 속성으로 열 맞춤(줄 선·배경 어긋남 없음). - 공장 담당자·연락처 분리: inout_db 002(manager 열, 이름만 있던 연락처는 담당자로). 발주서 화면에 공장 담당자·연락처. 002 미적용이어도 발주서 화면은 열리고 공장 저장만 안내. - 테스트: 팝업·JSON 저장·예전 주소·권한, 담당자/연락처, 002 전후. 실제 브라우저로 겹침 0·줄 맞춤 확인. Co-Authored-By: Claude Opus 5.5 --- CLAUDE.md | 2 +- app/modules/inout/db.py | 44 ++++++---- app/modules/inout/router.py | 61 ++++++++----- app/modules/inout/templates/inout/_nav.html | 26 +++++- .../inout/templates/inout/_options_panel.html | 73 ++++++++++++++++ app/modules/inout/templates/inout/index.html | 4 +- .../inout/templates/inout/order_detail.html | 6 +- .../inout/templates/inout/order_form.html | 4 +- .../inout/templates/inout/pending.html | 4 +- .../inout/templates/inout/settings.html | 74 ---------------- app/static/inout.css | 87 +++++++++++++++---- app/static/inout.js | 83 ++++++++++++++++++ docs/DEPLOYMENT.md | 12 +++ docs/INOUT_MODULE.md | 13 ++- scripts/sql/inout_db_002_factory_manager.sql | 23 +++++ scripts/sql/inout_db_init.sql | 4 +- tests/test_inout_db.py | 4 +- tests/test_inout_web.py | 35 +++++--- 18 files changed, 402 insertions(+), 157 deletions(-) create mode 100644 app/modules/inout/templates/inout/_options_panel.html delete mode 100644 app/modules/inout/templates/inout/settings.html create mode 100644 scripts/sql/inout_db_002_factory_manager.sql diff --git a/CLAUDE.md b/CLAUDE.md index 96ce7b9..dd59db4 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -42,7 +42,7 @@ Claude Code는 이 저장소에서 작업을 시작하기 전에 **반드시 아 - 긴급 공지 (`app/modules/notice/`, `project_db` 마이그레이션 024 `urgent_notice*`) — 수퍼관리자만 작성(`/notice/`, ERP 왼쪽 아래·Project ⚙ 옵션). 제목·내용(이미지 bytea)·띄울 시각·전체/고른 사람 → ERP 모든 화면(`erp_base.html`·`main.html`·`admin.html` 의 `static/erp-notice.js`) 가로·세로 정가운데에 [확인] 누를 때까지(Esc·바깥 클릭 무시), 확인 기록. 연결 풀은 `ProjectStore.pool` 공유, 새 환경변수 없음. PC 알림 프로그램은 아직 미지원. 상세는 `docs/NOTICE_MODULE.md` -- 입출고 관리 (`app/modules/inout/`, `inout_db`, 2026-10-16) — 본사 → 공장 제품 제작 발주(발주서 `PO-YYMMDD-NN`, 제품 = `itemcode_db.single_items` 단품만, 검색 `GET /inout/api/items`·저장 때 서버 재확인), 물류 입고를 여러 번 나눠 입력, 품목별 발주·입고·미입고, 미입고 현황(제품별 합계·발주별·지연), 초과 입고는 확인 화면 후 허용(트랜잭션 안에서 발주서 잠그고 판단, `confirm_over`), 잔량 종결·취소(입고 없을 때만). 상태는 저장하지 않고 누적 입고로 계산(`store.order_status`). 권한키 `inout`(조회), **발주 담당·입고 담당·공장은 모듈 옵션**(`/inout/settings`, ERP 관리자, `inout_roles`·`inout_factories`), 관리자는 둘 다. 이카운트 "발주 대비 미입고"·Odoo 분할 입고/종결 참고. 상세 `docs/INOUT_MODULE.md` +- 입출고 관리 (`app/modules/inout/`, `inout_db`, 2026-10-16) — 본사 → 공장 제품 제작 발주(발주서 `PO-YYMMDD-NN`, 제품 = `itemcode_db.single_items` 단품만, 검색 `GET /inout/api/items`·저장 때 서버 재확인), 물류 입고를 여러 번 나눠 입력, 품목별 발주·입고·미입고, 미입고 현황(제품별 합계·발주별·지연), 초과 입고는 확인 화면 후 허용(트랜잭션 안에서 발주서 잠그고 판단, `confirm_over`), 잔량 종결·취소(입고 없을 때만). 상태는 저장하지 않고 누적 입고로 계산(`store.order_status`). 권한키 `inout`(조회), **발주 담당·입고 담당·공장(담당자·연락처 따로, 002)은 모듈 옵션 — 상단 톱니 → 팝업**(`/inout/settings?panel=1`, ERP 관리자, `inout_roles`·`inout_factories`, 공용 `.erp-input`·`.erp-table-wrap` 겹침은 `.io` 안에서만 바로잡음), 관리자는 둘 다. 이카운트 "발주 대비 미입고"·Odoo 분할 입고/종결 참고. 상세 `docs/INOUT_MODULE.md` 상세는 `docs/PROJECT_OVERVIEW.md`. diff --git a/app/modules/inout/db.py b/app/modules/inout/db.py index 7d0fc46..939f537 100644 --- a/app/modules/inout/db.py +++ b/app/modules/inout/db.py @@ -11,6 +11,7 @@ from __future__ import annotations from datetime import date from typing import Any +from psycopg.errors import UndefinedColumn from psycopg.rows import dict_row from psycopg_pool import ConnectionPool @@ -52,27 +53,32 @@ class InoutDBStore: f"FROM inout_factories f {where} ORDER BY f.is_active DESC, f.sort_order, f.name" ).fetchall() - def save_factory(self, *, factory_id: int | None, name: str, contact: str = "", memo: str = "", + def save_factory(self, *, factory_id: int | None, name: str, manager: str = "", contact: str = "", memo: str = "", is_active: bool = True, sort_order: int = 0) -> int: + """공장 추가·수정. 담당자(manager, 002)·연락처(contact)는 따로.""" name = (name or "").strip() if not name or len(name) > 100: raise ValueError("공장 이름을 1~100자로 입력하세요.") - vals = (name, (contact or "").strip()[:200], (memo or "").strip()[:store.MEMO_MAX], bool(is_active), int(sort_order)) - with self._pool.connection() as conn: - dup = conn.execute("SELECT id FROM inout_factories WHERE lower(name) = lower(%s) AND id <> %s", - (name, factory_id or 0)).fetchone() - if dup: - raise ValueError(f"같은 이름의 공장이 이미 있습니다: {name}") - if factory_id: - row = conn.execute( - "UPDATE inout_factories SET name=%s, contact=%s, memo=%s, is_active=%s, sort_order=%s " - "WHERE id=%s RETURNING id", (*vals, factory_id)).fetchone() - if not row: - raise ValueError("공장을 찾을 수 없습니다.") - return int(row["id"]) - return int(conn.execute( - "INSERT INTO inout_factories (name, contact, memo, is_active, sort_order) VALUES (%s,%s,%s,%s,%s) RETURNING id", - vals).fetchone()["id"]) + vals = (name, (manager or "").strip()[:100], (contact or "").strip()[:200], (memo or "").strip()[:store.MEMO_MAX], + bool(is_active), int(sort_order)) + try: + with self._pool.connection() as conn: + dup = conn.execute("SELECT id FROM inout_factories WHERE lower(name) = lower(%s) AND id <> %s", + (name, factory_id or 0)).fetchone() + if dup: + raise ValueError(f"같은 이름의 공장이 이미 있습니다: {name}") + if factory_id: + row = conn.execute( + "UPDATE inout_factories SET name=%s, manager=%s, contact=%s, memo=%s, is_active=%s, sort_order=%s " + "WHERE id=%s RETURNING id", (*vals, factory_id)).fetchone() + if not row: + raise ValueError("공장을 찾을 수 없습니다.") + return int(row["id"]) + return int(conn.execute( + "INSERT INTO inout_factories (name, manager, contact, memo, is_active, sort_order) " + "VALUES (%s,%s,%s,%s,%s,%s) RETURNING id", vals).fetchone()["id"]) + except UndefinedColumn: + raise ValueError("DB 마이그레이션 inout_db 002(공장 담당자 칸)가 아직 적용되지 않았습니다.") from None def delete_factory(self, factory_id: int) -> None: """발주 기록이 없는 공장만 지운다(있으면 '사용 안 함'으로 숨김).""" @@ -187,7 +193,9 @@ class InoutDBStore: def get_order(self, order_id: int) -> dict[str, Any] | None: with self._pool.connection() as conn: head = conn.execute( - "SELECT o.*, f.name AS factory_name FROM inout_orders o JOIN inout_factories f ON f.id = o.factory_id WHERE o.id=%s", + # 담당자(manager)는 002 열 — 미적용 DB 에서도 깨지지 않게 to_jsonb 로 읽는다 + "SELECT o.*, f.name AS factory_name, to_jsonb(f) ->> 'manager' AS factory_manager, f.contact AS factory_contact " + "FROM inout_orders o JOIN inout_factories f ON f.id = o.factory_id WHERE o.id=%s", (order_id,)).fetchone() if not head: return None diff --git a/app/modules/inout/router.py b/app/modules/inout/router.py index bb5e582..4a66d2c 100644 --- a/app/modules/inout/router.py +++ b/app/modules/inout/router.py @@ -8,7 +8,8 @@ POST /inout/orders/{id}/close|reopen|cancel 종결·종결 풀기·취소(발주 담당) POST /inout/orders/{id}/receipts 입고 저장(입고 담당) — 발주 초과면 확인 화면, confirm_over=1 로 다시 보내야 저장 POST /inout/orders/{id}/receipts/{rid}/delete 잘못 넣은 입고 지우기(입고 담당) - GET|POST /inout/settings… 옵션 — 공장 목록·발주 담당·입고 담당(ERP 관리자) + GET /inout/settings?panel=1 옵션 팝업 내용(톱니, ERP 관리자) — 공장 목록·발주 담당·입고 담당 + POST /inout/settings/… 옵션 저장 — 팝업(X-Inout-Options: 1)이면 JSON, 아니면 목록으로 이동 GET /inout/api/items?q= 코드표 단품 검색(JSON) 권한: 모듈 권한키 `inout`(조회). 발주 담당·입고 담당은 옵션(inout_roles)에서 지정, ERP 관리자는 둘 다 + 옵션. @@ -100,6 +101,7 @@ def _render(request: Request, name: str, user: dict[str, Any], ctx: dict[str, An "user": user, "is_admin": perms["admin"], "perms": perms, "nav_items": build_erp_nav(user, active="inout"), "msg": request.query_params.get("msg", ""), "today": today_kst(), + "open_options": request.query_params.get("options") == "1" and perms["admin"], # 톱니 팝업 바로 열기 **ctx, }, status_code=status_code) @@ -421,13 +423,7 @@ def _candidates() -> list[dict[str, str]]: return sorted(out, key=lambda x: x["email"]) -@router.get("/settings", response_class=HTMLResponse) -def settings(request: Request) -> Any: - got = _ctx(request) - if not isinstance(got, tuple): - return got - st, user = got - _require(st, user, "admin") +def _options_ctx(request: Request, st: Any) -> dict[str, Any]: roles = st.list_roles() cands = _candidates() known = {c["email"] for c in cands} @@ -437,11 +433,35 @@ def settings(request: Request) -> Any: cands.append({"email": e, "name": "(입출고 모듈 권한 없음)"}) known.add(e) reader = _items(request) - return _render(request, "inout/settings.html", user, { - "tab": "settings", "factories": st.list_factories(include_inactive=True), "roles": roles, - "role_labels": store.ROLE_LABELS, "candidates": cands, - "items_status": "연결됨" if reader is not None and reader.enabled else (reader.reason if reader else "없음"), - }) + return {"factories": st.list_factories(include_inactive=True), "roles": roles, "role_labels": store.ROLE_LABELS, + "candidates": cands, + "items_status": "연결됨" if reader is not None and reader.enabled else (reader.reason if reader else "없음")} + + +def _is_popup(request: Request) -> bool: + """옵션 팝업(inout.js)이 보낸 요청 — 이동 대신 JSON 으로 답하고 팝업이 제자리에서 다시 그린다.""" + return request.headers.get("x-inout-options") == "1" + + +def _options_done(request: Request, message: str, *, ok: bool = True) -> Any: + if _is_popup(request): + return JSONResponse({"ok": ok, "message": message}, status_code=200 if ok else 400) + return _redirect("/inout/?options=1", message) + + +@router.get("/settings", response_class=HTMLResponse) +def settings(request: Request, panel: int = 0) -> Any: + """옵션 — 팝업(톱니)으로 연다. panel=1 = 팝업 안 내용만, 그 밖엔 발주 목록으로 가서 팝업을 띄운다(예전 주소 호환).""" + got = _ctx(request) + if not isinstance(got, tuple): + return got + st, user = got + _require(st, user, "admin") + if not panel: + return RedirectResponse(url="/inout/?options=1", status_code=303) + from app.main import render_template # noqa: WPS433 + + return render_template(request, "inout/_options_panel.html", _options_ctx(request, st)) @router.post("/settings/factories") @@ -454,11 +474,12 @@ async def settings_factory_save(request: Request) -> Any: form = await request.form() try: st.save_factory(factory_id=_opt_int(form.get("id")), name=str(form.get("name") or ""), - contact=str(form.get("contact") or ""), memo=str(form.get("memo") or ""), - is_active=form.get("is_active") == "1", sort_order=_opt_int(form.get("sort_order")) or 0) + manager=str(form.get("manager") or ""), contact=str(form.get("contact") or ""), + memo=str(form.get("memo") or ""), is_active=form.get("is_active") == "1", + sort_order=_opt_int(form.get("sort_order")) or 0) except ValueError as exc: - return _redirect("/inout/settings", str(exc)) - return _redirect("/inout/settings", "공장을 저장했습니다.") + return _options_done(request, str(exc), ok=False) + return _options_done(request, "공장을 저장했습니다.") @router.post("/settings/factories/{factory_id}/delete") @@ -471,8 +492,8 @@ def settings_factory_delete(request: Request, factory_id: int) -> Any: try: st.delete_factory(factory_id) except ValueError as exc: - return _redirect("/inout/settings", str(exc)) - return _redirect("/inout/settings", "공장을 지웠습니다.") + return _options_done(request, str(exc), ok=False) + return _options_done(request, "공장을 지웠습니다.") @router.post("/settings/roles") @@ -485,7 +506,7 @@ async def settings_roles(request: Request) -> Any: form = await request.form() for role in store.ROLES: st.set_role_members(role, [str(e) for e in form.getlist(f"{role}_email")], by=user.get("email", "")) - return _redirect("/inout/settings", "담당자를 저장했습니다.") + return _options_done(request, "담당자를 저장했습니다.") # ──────────────────────────────────────────────────────────── diff --git a/app/modules/inout/templates/inout/_nav.html b/app/modules/inout/templates/inout/_nav.html index ed4f7a3..73f232a 100644 --- a/app/modules/inout/templates/inout/_nav.html +++ b/app/modules/inout/templates/inout/_nav.html @@ -1,8 +1,7 @@ -{# 입출고 관리 공용 상단: 탭(발주 목록·미입고 현황·옵션) + 새 발주서 + 알림 문구(?msg=) #} +{# 입출고 관리 공용 상단: 탭(발주 목록·미입고 현황) + 담당 표시 + 새 발주서 + 옵션 톱니(관리자, 팝업) + 알림 문구(?msg=) #}
발주 목록 미입고 현황 - {% if perms.admin %}옵션{% endif %} {% if perms.can_order %}발주 담당{% endif %} @@ -10,5 +9,28 @@ {% if not perms.can_order and not perms.can_receive %}조회만 가능 — 담당 지정은 옵션(관리자){% endif %} {% if perms.can_order %}+ 새 발주서{% endif %} + {% if perms.admin %} + + {% endif %}
{% if msg %}

{{ msg }}

{% endif %} + +{% if perms.admin %} +{# 옵션 팝업 — 내용은 열 때 GET /inout/settings?panel=1 로 받아 넣고, 저장은 제자리에서(inout.js) #} + +
+

입출고 관리 옵션

+ +
+ +

불러오는 중…

+
+{% endif %} diff --git a/app/modules/inout/templates/inout/_options_panel.html b/app/modules/inout/templates/inout/_options_panel.html new file mode 100644 index 0000000..fa1e0d0 --- /dev/null +++ b/app/modules/inout/templates/inout/_options_panel.html @@ -0,0 +1,73 @@ +{# 옵션 팝업 내용(GET /inout/settings?panel=1) — 탭: 담당자 · 공장. 폼 저장은 inout.js 가 제자리에서(X-Inout-Options: 1 → JSON). + 공장 줄은 표(
) 안에 폼을 둘 수 없어 입력칸에 form="…" 속성으로 표 밖 폼에 묶는다 — 열이 머리 줄과 맞는다. #} +
+ + +
+ +
+

+ 발주 담당 — 발주서 작성·고치기·잔량 종결·취소. 입고 담당 — 물류에 들어온 입고 수량 입력·지우기. + 그 밖의 사람은 조회만 합니다. ERP 관리자는 지정 없이도 둘 다 할 수 있습니다. + 후보 = ERP 관리자 화면에서 입출고 관리 권한을 받은 사용자. +

+
+
+ {% for role, label in role_labels.items() %}{% endfor %} + + {% for c in candidates %} + + + {% for role in role_labels %} + + {% endfor %} + + {% else %} + + {% endfor %} + +
사용자{{ label }}
{{ c.name or c.email }}{{ c.email }}
입출고 관리 권한을 받은 사용자가 없습니다 — ERP 관리자 화면에서 먼저 권한을 주세요.
+
+ + + + + +

코드표(단품) 연결: {{ items_status }}

diff --git a/app/modules/inout/templates/inout/index.html b/app/modules/inout/templates/inout/index.html index a93a79d..cae415a 100644 --- a/app/modules/inout/templates/inout/index.html +++ b/app/modules/inout/templates/inout/index.html @@ -1,6 +1,6 @@ {% extends "erp_base.html" %} {% from "inout/_macros.html" import status_badge, progress, due, n %} -{% block head_extra %}{% endblock %} +{% block head_extra %}{% endblock %} {% block content %}
@@ -58,4 +58,4 @@
{% endblock %} -{% block scripts %}{% endblock %} +{% block scripts %}{% endblock %} diff --git a/app/modules/inout/templates/inout/order_detail.html b/app/modules/inout/templates/inout/order_detail.html index 03128ed..25bcad6 100644 --- a/app/modules/inout/templates/inout/order_detail.html +++ b/app/modules/inout/templates/inout/order_detail.html @@ -1,6 +1,6 @@ {% extends "erp_base.html" %} {% from "inout/_macros.html" import status_badge, progress, due, n %} -{% block head_extra %}{% endblock %} +{% block head_extra %}{% endblock %} {% block content %} {% set active = order.status in ('open', 'partial') %} @@ -14,7 +14,7 @@

{{ order.order_no }}

{{ status_badge(order.status, order.status_label) }}
-
공장
{{ order.factory_name }}
+
공장
{{ order.factory_name }}{% if order.factory_manager or order.factory_contact %}{{ order.factory_manager }}{% if order.factory_manager and order.factory_contact %} · {% endif %}{{ order.factory_contact }}{% endif %}
발주일
{{ order.order_date.strftime('%Y-%m-%d') }}
입고 예정일
{{ due(order.due_date, today, active) }}
진행
{{ progress(order.summary) }}
@@ -130,4 +130,4 @@ {% endblock %} -{% block scripts %}{% endblock %} +{% block scripts %}{% endblock %} diff --git a/app/modules/inout/templates/inout/order_form.html b/app/modules/inout/templates/inout/order_form.html index 18bdd96..8a9d84e 100644 --- a/app/modules/inout/templates/inout/order_form.html +++ b/app/modules/inout/templates/inout/order_form.html @@ -1,5 +1,5 @@ {% extends "erp_base.html" %} -{% block head_extra %}{% endblock %} +{% block head_extra %}{% endblock %} {% block content %}
@@ -76,4 +76,4 @@
{% endblock %} -{% block scripts %}{% endblock %} +{% block scripts %}{% endblock %} diff --git a/app/modules/inout/templates/inout/pending.html b/app/modules/inout/templates/inout/pending.html index b85709f..b7de66f 100644 --- a/app/modules/inout/templates/inout/pending.html +++ b/app/modules/inout/templates/inout/pending.html @@ -1,6 +1,6 @@ {% extends "erp_base.html" %} {% from "inout/_macros.html" import due, n %} -{% block head_extra %}{% endblock %} +{% block head_extra %}{% endblock %} {% block content %}
@@ -88,4 +88,4 @@ {% endif %}
{% endblock %} -{% block scripts %}{% endblock %} +{% block scripts %}{% endblock %} diff --git a/app/modules/inout/templates/inout/settings.html b/app/modules/inout/templates/inout/settings.html deleted file mode 100644 index aed2b8a..0000000 --- a/app/modules/inout/templates/inout/settings.html +++ /dev/null @@ -1,74 +0,0 @@ -{% extends "erp_base.html" %} -{% block head_extra %}{% endblock %} - -{% block content %} -
- {% include "inout/_nav.html" %} - -
-
-

담당자

ERP 관리자는 지정 없이도 둘 다 할 수 있습니다
-

- 발주 담당 — 발주서 작성·고치기·잔량 종결·취소. 입고 담당 — 물류에 들어온 입고 수량 입력·지우기. - 그 밖의 사람은 조회만 합니다. 후보 = ERP 관리자 화면에서 입출고 관리 권한을 받은 사용자. -

-
- - {% for role, label in role_labels.items() %}{% endfor %} - - {% for c in candidates %} - - - {% for role in role_labels %} - - {% endfor %} - - {% else %} - - {% endfor %} - -
사용자{{ label }}
{{ c.name or c.email }}
{{ c.email }}
입출고 관리 권한을 받은 사용자가 없습니다 — ERP 관리자 화면에서 먼저 권한을 주세요.
-
-
-
- -
-

공장(발주처)

발주 기록이 있는 공장은 지우지 말고 '사용 안 함'으로
- {# 줄마다 폼 하나(표 안에 폼을 넣을 수 없어 격자로) — 머리 줄과 같은 열 #} -
-
- 이름담당자·연락처메모순서사용발주 -
- {% for f in factories %} -
- - - - - - - {{ f.order_count }}건 - - - {% if not f.order_count %}{% endif %} - -
- {% endfor %} -
- - - - - - - -
-
-
- -

코드표(단품) 연결: {{ items_status }}

-
-
-{% endblock %} diff --git a/app/static/inout.css b/app/static/inout.css index 06388b7..864b752 100644 --- a/app/static/inout.css +++ b/app/static/inout.css @@ -14,8 +14,8 @@ /* 거르기 줄 */ .io-filter { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; } -.io-filter .erp-input, .io-filter .erp-select { width: auto; } -.io-search { min-width: 220px; } +.io-filter .erp-select { width: auto; } +.io-search { width: 260px; } .io-filter input[type="date"] { width: 150px; } .io-date { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--color-midtone-gray); } .io-seg { display: inline-flex; padding: 2px; border: 1px solid var(--color-subtle-ash); border-radius: 10px; background: #fff; } @@ -69,7 +69,7 @@ .io-kpis-head { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); align-self: start; min-width: 320px; } .io-head-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-top: 12px; border-top: 1px solid var(--color-subtle-ash); } .io-head-actions form { display: inline-flex; gap: 6px; align-items: center; margin: 0; } -.io-close-reason { width: 200px; } +.io-close-reason { width: 220px; } /* 입고 입력 */ .io-col-no { width: 36px; color: var(--color-midtone-gray); } @@ -87,6 +87,7 @@ /* 발주서 폼 */ .io-order-form { overflow: visible; } .io-lines .io-col-qty { width: 130px; } +.io-lines .erp-input { width: 100%; } .io-lines .io-col-del { width: 48px; text-align: center; } .io-lines tfoot td { padding: 10px 16px; border-top: 1px solid var(--color-subtle-ash); } .io-item-cell { position: relative; min-width: 320px; } @@ -102,23 +103,75 @@ .io-suggest-item:hover, .io-suggest-item.is-active { background: #eef6ff; } .io-suggest-empty { padding: 10px 12px; font-size: 12.5px; color: var(--color-midtone-gray); white-space: normal; } -/* 옵션 */ -.io-settings { display: flex; flex-direction: column; gap: 14px; } -.io-col-check { width: 90px; text-align: center !important; } -.io-factories { padding: 6px 12px 12px; } -.io-factory-row { display: grid; grid-template-columns: minmax(140px, 1.2fr) minmax(140px, 1.2fr) minmax(120px, 1.5fr) 70px 50px 60px auto; - gap: 8px; align-items: center; padding: 6px 8px; margin: 0; border-bottom: 1px solid var(--color-subtle-ash); } -.io-factory-head { font-size: 12px; color: var(--color-midtone-gray); font-weight: 500; } -.io-factory-row .erp-input { width: 100%; min-width: 0; } -.io-factory-row.io-inactive .erp-input { color: var(--color-midtone-gray); background: var(--color-ghost-gray); } -.io-new-factory { border-bottom: 0; background: #fafbfc; border-radius: 8px; } -.io-factory-btns { display: inline-flex; gap: 6px; justify-content: flex-end; } -.io-check { display: inline-flex; justify-content: center; } +/* ── 공용 ERP 스타일과 겹치는 부분(2026-10-16 옵션 화면 겹침) ── + · .erp-input 은 min-width 240px + content-box 라 좁은 칸에서 옆 칸을 덮는다 → 이 모듈 안에서는 테두리 기준·최소폭 없음 + · .erp-table-wrap 은 카드 모양(그림자·둥근 모서리)이라 카드 안에 넣으면 상자가 겹쳐 보인다 → 카드 안에서는 평평하게 */ +.io *, .io *::before, .io *::after, .io-dlg *, .io-dlg *::before, .io-dlg *::after { box-sizing: border-box; } +.io .erp-input { min-width: 0; } +.io .erp-card-block .erp-table-wrap { border-radius: 0; box-shadow: none; background: transparent; } + +/* 옵션 톱니(관리자) — 실적 설정 톱니처럼 둥근 아이콘 단추 */ +.io-gear { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; + border: 1px solid var(--color-subtle-ash); border-radius: 50%; background: #fff; color: #525860; cursor: pointer; + transition: background .12s, color .12s, border-color .12s; } +.io-gear:hover { background: var(--color-ghost-gray); color: var(--color-rich-black); border-color: #c9ccd1; } +.io-gear:focus-visible { outline: 2px solid var(--color-rich-black); outline-offset: 2px; } +.io-factory-who { display: block; font-size: 12px; color: var(--color-midtone-gray); margin-top: 2px; } + +/* 옵션 팝업 */ +.io-dlg { width: min(1040px, calc(100vw - 40px)); max-height: min(760px, calc(100vh - 40px)); padding: 0; border: 1px solid var(--color-subtle-ash); + border-radius: 12px; box-shadow: 0 12px 40px rgba(0, 0, 0, .2); color: var(--color-rich-black); overflow: hidden; } +.io-dlg[open] { display: flex; flex-direction: column; } +.io-dlg:focus { outline: none; } +.io-dlg-tabs button:focus-visible { outline: 2px solid var(--color-rich-black); outline-offset: -4px; border-radius: 6px; } +.io-dlg::backdrop { background: rgba(0, 0, 0, .35); } +.io-dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 14px 22px; border-bottom: 1px solid var(--color-subtle-ash); } +.io-dlg-head h2 { margin: 0; font-size: 17px; font-weight: 600; } +.io-dlg-x { display: inline-flex; padding: 6px; border: 0; border-radius: 6px; background: none; color: #6d6e6f; cursor: pointer; } +.io-dlg-x:hover { background: var(--color-ghost-gray); color: var(--color-rich-black); } +.io-dlg-msg { margin: 12px 22px 0; padding: 9px 12px; border-radius: 8px; background: #e6f8e9; color: #1e7a34; border: 1px solid #c2efc8; font-size: 13px; } +.io-dlg-msg.is-bad { background: #fbe9e6; color: #a1261b; border-color: #efc6bf; } +.io-dlg-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 14px 22px 18px; } +.io-dlg-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--color-subtle-ash); margin-bottom: 14px; } +.io-dlg-tabs button { padding: 8px 14px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: none; + font: inherit; font-size: 14px; color: var(--color-midtone-gray); cursor: pointer; } +.io-dlg-tabs button:hover { color: var(--color-rich-black); } +.io-dlg-tabs button.is-active { color: var(--color-rich-black); font-weight: 600; border-bottom-color: var(--color-rich-black); } +.io-dlg-count { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 999px; background: var(--color-ghost-gray); font-size: 11px; text-align: center; } +.io-dlg-body .io-help { padding: 0 0 12px; } +.io-dlg-form { margin: 0; } +.io-dlg-table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; } +.io-dlg-table th { text-align: left; font-weight: 500; font-size: 12px; color: var(--color-midtone-gray); padding: 8px 6px; border-bottom: 1px solid var(--color-subtle-ash); white-space: nowrap; } +.io-dlg-table td { padding: 7px 6px; border-bottom: 1px solid var(--color-subtle-ash); vertical-align: middle; } +.io-dlg-table tbody tr:last-child td { border-bottom: 0; } +.io-dlg-table .io-c { text-align: center; } +.io-dlg-table td.io-c input[type="checkbox"] { width: 16px; height: 16px; } +.io-user { display: block; font-weight: 500; } +.io-sub { font-size: 12px; color: var(--color-midtone-gray); } +.io-empty { text-align: center; padding: 18px; color: var(--color-midtone-gray); } +.io-in { width: 100%; min-width: 0; padding: 6px 9px; border: 1px solid var(--color-subtle-ash); border-radius: 6px; font: inherit; font-size: 13px; + color: var(--color-rich-black); background: #fff; } +.io-in:focus { outline: none; border-color: var(--color-rich-black); box-shadow: 0 0 0 3px rgba(0, 0, 0, .06); } +.io-in-num { text-align: right; } +.io-factory-table col.w-name { width: 18%; } +.io-factory-table col.w-man { width: 12%; } +.io-factory-table col.w-tel { width: 18%; } +.io-factory-table col.w-memo { width: auto; } +.io-factory-table col.w-sort { width: 64px; } +.io-factory-table col.w-use { width: 48px; } +.io-factory-table col.w-cnt { width: 52px; } +.io-factory-table col.w-btn { width: 128px; } +.io-factory-table tr.is-inactive .io-in { background: var(--color-ghost-gray); color: var(--color-midtone-gray); } +.io-factory-table .io-new-row td { background: #fafbfc; border-top: 1px solid var(--color-subtle-ash); } +.io-btns { text-align: right; white-space: nowrap; } /* td 에 flex 를 주면 표 칸이 깨진다(줄 선·배경 어긋남) */ +.io-btns .erp-btn + .erp-btn { margin-left: 4px; } +.io-dlg-actions { display: flex; justify-content: flex-end; padding-top: 12px; } +.io-dlg-foot { margin: 14px 0 0; font-size: 12px; color: var(--color-midtone-gray); } @media (max-width: 900px) { .io-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .io-head { grid-template-columns: 1fr; } .io-kpis-head { min-width: 0; } - .io-factory-row { grid-template-columns: 1fr 1fr; } - .io-factory-head { display: none; } + .io-dlg-body { overflow-x: auto; } + .io-factory-table { min-width: 860px; } } diff --git a/app/static/inout.js b/app/static/inout.js index 30a5010..086134b 100644 --- a/app/static/inout.js +++ b/app/static/inout.js @@ -2,6 +2,7 @@ · 목록 줄 누르기 = 발주서로 · 발주서 폼: 제품 줄 추가·지우기·번호·합계, 코드표 단품 검색(GET /inout/api/items?q=) 드롭다운 · 발주서 화면: [남은 수량 모두 채우기], 이번 입고 합계 + · 옵션 팝업(톱니): 담당자·공장 — 열 때 내용을 받고, 저장은 제자리 · data-erp-confirm-btn: 버튼별 확인(formaction 이 있는 버튼 — 공용 data-erp-confirm 은 form.submit() 이라 누른 버튼이 사라짐) */ (function () { "use strict"; @@ -224,4 +225,86 @@ }); paintTotal(); } + + // ── 옵션 팝업(톱니, 관리자) — 내용은 GET /inout/settings?panel=1, 저장은 제자리(X-Inout-Options: 1 → JSON) ── + const optBtn = document.getElementById("io-options-btn"); + const optDlg = document.getElementById("io-options"); + if (optBtn && optDlg) initOptions(optBtn, optDlg); + + function initOptions(btn, dlg) { + const body = dlg.querySelector("#io-options-body"); + const msgEl = dlg.querySelector(".io-dlg-msg"); + let changed = false, pane = "roles"; + + function say(text, bad) { + msgEl.textContent = text || ""; + msgEl.hidden = !text; + msgEl.classList.toggle("is-bad", !!bad); + } + function showPane(name) { + pane = name; + body.querySelectorAll(".io-dlg-tabs [data-pane]").forEach(function (t) { + const on = t.dataset.pane === name; + t.classList.toggle("is-active", on); + t.setAttribute("aria-selected", on ? "true" : "false"); + t.tabIndex = on ? 0 : -1; + }); + body.querySelectorAll(".io-dlg-pane").forEach(function (p) { p.hidden = p.dataset.pane !== name; }); + } + async function load() { + const res = await fetch("/inout/settings?panel=1", { headers: { "X-Inout-Options": "1" } }); + if (!res.ok) throw new Error("HTTP " + res.status); + body.innerHTML = await res.text(); + showPane(pane); + } + async function open() { + say(""); + if (!dlg.open) dlg.showModal(); + try { + await load(); + dlg.focus({ preventScroll: true }); // 닫기(✕)에 초점 테두리가 생기지 않게 창 자체에(Tab 으로 안으로 이동) + } catch (_) { + body.innerHTML = '

옵션을 불러오지 못했습니다. 잠시 뒤 다시 여세요.

'; + } + } + btn.addEventListener("click", open); + dlg.addEventListener("click", function (e) { + if (e.target.closest("[data-close]")) { dlg.close(); return; } + const tab = e.target.closest(".io-dlg-tabs [data-pane]"); + if (tab) showPane(tab.dataset.pane); + }); + dlg.addEventListener("close", function () { + const url = new URL(location.href); + const hadParam = url.searchParams.has("options"); + url.searchParams.delete("options"); + url.searchParams.delete("msg"); + if (changed) location.href = url.toString(); // 담당 표시·공장 목록이 바뀌었을 수 있다 + else if (hadParam) history.replaceState(null, "", url.toString()); + }); + dlg.addEventListener("submit", async function (e) { + const form = e.target; + if (!form.classList || !form.classList.contains("io-dlg-form")) return; + e.preventDefault(); + const sub = e.submitter; + if (sub && sub.dataset.confirm && !(await confirmMsg(sub.dataset.confirm))) return; + const action = sub && sub.getAttribute("formaction") ? sub.getAttribute("formaction") : form.getAttribute("action"); + const buttons = Array.from(dlg.querySelectorAll("button[type=submit]")); + buttons.forEach(function (b) { b.disabled = true; }); + try { + const res = await fetch(action, { method: "POST", headers: { "X-Inout-Options": "1" }, + body: new URLSearchParams(new FormData(form)) }); + let data = {}; + try { data = await res.json(); } catch (_) {} + if (!res.ok || data.ok === false) { say(data.message || data.detail || "저장하지 못했습니다.", true); return; } + changed = true; + await load(); + say(data.message || "저장했습니다."); + } catch (_) { + say("저장하지 못했습니다(연결 오류). 다시 눌러 주세요.", true); + } finally { + buttons.forEach(function (b) { if (b.isConnected) b.disabled = false; }); + } + }); + if (btn.dataset.open === "1") open(); + } })(); diff --git a/docs/DEPLOYMENT.md b/docs/DEPLOYMENT.md index 5372439..e877744 100644 --- a/docs/DEPLOYMENT.md +++ b/docs/DEPLOYMENT.md @@ -287,6 +287,18 @@ curl -s http://127.0.0.1:8080/inout/health # {"status":"ok"} — DSN 그다음 ERP 관리자 화면에서 쓸 사람에게 **입출고 관리** 권한 → 입출고 관리 → 옵션에서 공장·발주 담당·입고 담당 지정. 백업: 매일 `docker exec postgres-db pg_dump -U postgres inout_db > /var/backups/postgres/inout_db_$(date +%F).sql`. +## 입출고 관리 공장 담당자 마이그레이션 (inout_db 002) + +002는 `inout_factories.manager`(담당자) 열만 추가한다(다시 실행 가능). 예전 "담당자·연락처" 한 칸에 숫자 없이 이름만 있던 값은 담당자로 옮긴다. +미적용이면 공장 저장만 안내(발주·입고는 그대로). + +```bash +cd /opt/www/main +docker exec postgres-db pg_dump -U postgres inout_db > ~/inout_db_before_002_$(date +%Y%m%d%H%M).sql +docker exec -i postgres-db psql -v ON_ERROR_STOP=1 -U postgres -d inout_db < scripts/sql/inout_db_002_factory_manager.sql +docker exec postgres-db psql -U postgres -d inout_db -c "SELECT name, manager, contact FROM inout_factories ORDER BY id;" +``` + ## 긴급 공지 마이그레이션 (024) 024는 `urgent_notices`·`urgent_notice_targets`·`urgent_notice_acks`·`urgent_notice_images` 테이블만 추가한다(기존 값 그대로, 다시 실행 가능). diff --git a/docs/INOUT_MODULE.md b/docs/INOUT_MODULE.md index 864ef29..4d20a5f 100644 --- a/docs/INOUT_MODULE.md +++ b/docs/INOUT_MODULE.md @@ -38,7 +38,7 @@ | 모듈 권한 `inout` | 발주 목록·발주서·미입고 현황 조회 | | **발주 담당**(옵션에서 지정) | 발주서 작성·고치기·잔량 종결/풀기·취소 | | **입고 담당**(옵션에서 지정) | 입고 수량 입력·입고 기록 지우기 | -| ERP 관리자(`role=admin`) | 위 전부 + **옵션**(공장 목록·담당자) | +| ERP 관리자(`role=admin`) | 위 전부 + **옵션**(공장 목록·담당자) — 상단 오른쪽 **톱니** → 팝업 | 담당자 후보 = ERP 관리자 화면에서 `inout` 권한을 받은 사용자. 권한이 빠졌는데 담당으로 남은 사람도 옵션에 보여서 뺄 수 있다. 담당은 `inout_roles(email, role)` — role `order`(발주)·`receive`(입고). @@ -58,23 +58,28 @@ cupang·malaysia 와 같은 DSN). 화면에서 코드·이름으로 검색(`GET | `/inout/pending` | 미입고 현황 — 요약 숫자, 제품별 합계, 발주별, 초과 입고 | | `/inout/orders/new`, `/{id}/edit` | 발주서 폼 — 공장·발주일·입고 예정일·메모, 제품 줄(검색 드롭다운·수량·줄 메모), 합계 | | `/inout/orders/{id}` | 발주서 — 품목별 발주·입고·미입고·상태, **이번 입고** 칸(입고 담당) + [남은 수량 모두 채우기], 입고 기록, 종결·취소 | -| `/inout/settings` | 옵션(관리자) — 담당자(발주·입고 체크), 공장(이름·연락처·메모·순서·사용, 발주 기록 없을 때만 지우기) | +| 톱니 → 옵션 팝업 | 관리자만. 탭 **담당자**(발주·입고 체크) · **공장**(이름·담당자·연락처·메모·순서·사용, 발주 기록 없을 때만 지우기). 내용은 `GET /inout/settings?panel=1`, 저장은 팝업 안에서(`X-Inout-Options: 1` → JSON, 같은 탭 그대로 다시 그림), 바뀐 게 있으면 닫을 때 화면 새로고침. 예전 주소 `/inout/settings` = 목록으로 가서 팝업(`?options=1`) | 화면은 서버 폼(POST → 303 + `?msg=` 안내). `static/inout.js` 는 입력 보조만(제품 검색 드롭다운 — `position: fixed` 로 body 에 붙여 표 가로 스크롤에 잘리지 않음, 줄 추가·삭제·합계, 남은 수량 채우기, 버튼별 확인 `data-erp-confirm-btn`). -공용 `.erp-page` 가 content-box 라 넓은 표에서 48px 넘치므로 이 화면만 `.erp-page:has(> .io) { box-sizing: border-box }`. +공용 스타일과 겹치는 것 — 이 모듈 안에서만 바로잡는다(공용 파일은 그대로): +`.erp-page` 가 content-box 라 넓은 표에서 48px 넘침 → `.erp-page:has(> .io) { box-sizing: border-box }`; +`.erp-input` 이 min-width 240px + content-box 라 좁은 칸에서 옆 칸을 덮음, `.erp-table-wrap` 이 카드 모양(그림자·둥근 모서리)이라 카드 안에서 상자가 겹쳐 보임 +→ `.io`·`.io-dlg` 안은 border-box·최소폭 없음·카드 안 표는 평평하게(2026-10-16 옵션 화면 겹침). 공장 표는 진짜 `` + 입력칸 `form="…"` 속성(줄마다 표 밖 폼)으로 열을 맞춘다. ## 6. DB (`inout_db`, `scripts/sql/inout_db_init.sql`) | 표 | 내용 | |---|---| -| `inout_factories` | 공장 — 이름(대소문자 무시 유일)·연락처·메모·사용·순서 | +| `inout_factories` | 공장 — 이름(대소문자 무시 유일)·담당자(`manager`, 002)·연락처(`contact`)·메모·사용·순서 | | `inout_roles` | 담당자 — (email, role: order/receive) | | `inout_orders` | 발주서 — 번호·공장·발주일·입고 예정일·메모·종결(시각·사람·사유)·취소 | | `inout_order_lines` | 발주 품목 — 단품 코드·이름 사본·수량·줄 메모, 발주서 안에서 코드 유일 | | `inout_receipts` | 입고 1건(한 번 들어온 것) — 입고일·메모·입력자 | | `inout_receipt_lines` | 입고 품목별 수량 | +마이그레이션 `inout_db_002_factory_manager.sql`(2026-10-16): `manager` 열 추가, 예전 한 칸에 숫자 없이 이름만 있던 값은 담당자로 옮김(숫자가 있으면 연락처로 둠). +002 미적용이어도 발주서 화면은 열리고(담당자 = `to_jsonb(f)->>'manager'`), 공장 저장만 "002 필요" 안내. 앱 계정 `inout_app` 은 SELECT/INSERT/UPDATE/DELETE + 시퀀스만. 초기화는 멱등(DROP·TRUNCATE 없음). 백업 권장: 매일 `pg_dump inout_db`. ## 7. 테스트 diff --git a/scripts/sql/inout_db_002_factory_manager.sql b/scripts/sql/inout_db_002_factory_manager.sql new file mode 100644 index 0000000..02e4ed2 --- /dev/null +++ b/scripts/sql/inout_db_002_factory_manager.sql @@ -0,0 +1,23 @@ +-- ===================================================================== +-- inout_db 마이그레이션 002 — 공장 담당자·연락처 분리(2026-10-16) +-- ===================================================================== +-- 멱등(idempotent). 열 추가만, 삭제 없음. 운영: /opt/www/main 에서 기존 inout_db 에 적용(백업 먼저). +-- +-- 왜(사용자 요청): 공장 옵션의 "담당자·연락처" 한 칸을 담당자 / 연락처 두 칸으로. +-- inout_factories.manager(담당자) 를 추가하고 contact 는 연락처만 담는다. +-- 예전 한 칸에 숫자 없이 이름만 들어 있던 값(예: "이석준")은 담당자로 옮긴다 — 숫자가 있으면 연락처로 보고 그대로 둔다. +-- (manager 가 비어 있는 행만 — 다시 실행해도 같다.) +-- 되돌리기: 백업에서 inout_factories 만 복원(열은 남아도 앱은 동작). +-- ===================================================================== +\set ON_ERROR_STOP on +BEGIN; + +ALTER TABLE inout_factories ADD COLUMN IF NOT EXISTS manager TEXT NOT NULL DEFAULT ''; +COMMENT ON COLUMN inout_factories.manager IS '공장 담당자 이름(연락처는 contact)'; + +UPDATE inout_factories + SET manager = contact, contact = '' + WHERE manager = '' AND contact <> '' AND contact !~ '[0-9]'; + +COMMIT; +SELECT 'inout_db 002 factory manager ready' AS status; diff --git a/scripts/sql/inout_db_init.sql b/scripts/sql/inout_db_init.sql index c7b6907..0ed57ca 100644 --- a/scripts/sql/inout_db_init.sql +++ b/scripts/sql/inout_db_init.sql @@ -49,7 +49,8 @@ $$ LANGUAGE plpgsql; CREATE TABLE IF NOT EXISTS inout_factories ( id SERIAL PRIMARY KEY, name TEXT NOT NULL CHECK (char_length(name) BETWEEN 1 AND 100), - contact TEXT NOT NULL DEFAULT '', -- 담당자·연락처(자유 글) + manager TEXT NOT NULL DEFAULT '', -- 담당자 이름(002) + contact TEXT NOT NULL DEFAULT '', -- 연락처 memo TEXT NOT NULL DEFAULT '', is_active BOOLEAN NOT NULL DEFAULT TRUE, sort_order INTEGER NOT NULL DEFAULT 0, @@ -57,6 +58,7 @@ CREATE TABLE IF NOT EXISTS inout_factories ( updated_at TIMESTAMPTZ NOT NULL DEFAULT now() ); CREATE UNIQUE INDEX IF NOT EXISTS uq_inout_factories_name ON inout_factories (lower(name)); +ALTER TABLE inout_factories ADD COLUMN IF NOT EXISTS manager TEXT NOT NULL DEFAULT ''; -- 002 이전에 만든 DB 도 같게 DROP TRIGGER IF EXISTS trg_inout_factories_updated ON inout_factories; CREATE TRIGGER trg_inout_factories_updated BEFORE UPDATE ON inout_factories FOR EACH ROW EXECUTE FUNCTION inout_set_updated_at(); diff --git a/tests/test_inout_db.py b/tests/test_inout_db.py index 2131ee3..a87b5a2 100644 --- a/tests/test_inout_db.py +++ b/tests/test_inout_db.py @@ -23,7 +23,7 @@ class InoutDbTests(unittest.TestCase): cls.st = InoutDBStore(DSN) cls.tag = uuid.uuid4().hex[:6] - cls.fid = cls.st.save_factory(factory_id=None, name=f"테스트공장-{cls.tag}", contact="김공장 010") + cls.fid = cls.st.save_factory(factory_id=None, name=f"테스트공장-{cls.tag}", manager="김공장", contact="010-1234") @classmethod def tearDownClass(cls): @@ -44,6 +44,8 @@ class InoutDbTests(unittest.TestCase): def test_partial_receipts_until_done(self): o = self.order([("MT-A", 100), ("MT-B", 50)]) self.assertRegex(o["order_no"], r"^PO-261016-\d{2}$") + head = self.st.get_order(o["id"]) + self.assertEqual((head["factory_manager"], head["factory_contact"]), ("김공장", "010-1234")) # 담당자·연락처 따로(002) ids = self.line_ids(o["id"]) self.assertEqual(self.st.get_order(o["id"])["status"], "open") self.st.add_receipt(o["id"], {ids["MT-A"]: "60"}, receipt_date="2026-10-20", memo="1차", confirm_over=False, by="w@x") diff --git a/tests/test_inout_web.py b/tests/test_inout_web.py index 5d527c5..7147b61 100644 --- a/tests/test_inout_web.py +++ b/tests/test_inout_web.py @@ -97,18 +97,32 @@ admin, buyer, wh, viewer = (U("admin-%s@t.local" % tag, role="admin"), U("buyer- users.extend([admin, buyer, wh, viewer]) def body(c): - # ── 옵션: 공장·담당자(관리자만) ── + # ── 옵션(톱니 팝업): 공장·담당자(관리자만) ── who["u"] = buyer - assert c.get("/inout/settings").status_code == 403 + assert c.get("/inout/settings?panel=1").status_code == 403 + assert 'id="io-options-btn"' not in c.get("/inout/").text # 관리자 아니면 톱니 없음 who["u"] = admin - page = c.get("/inout/settings") - assert page.status_code == 200 and buyer["email"] in page.text and "발주 담당" in page.text - r = c.post("/inout/settings/factories", data={"name": "공장-" + tag, "contact": "김 010", "is_active": "1"}, - follow_redirects=False) - assert r.status_code == 303 and "msg=" in r.headers["location"] - fid = re.search(r'name="id" value="(\\d+)" />\\s*옵션" not in lst # 탭 대신 톱니 + 팝업 + r = c.get("/inout/settings", follow_redirects=False) # 예전 주소 = 목록으로 가서 팝업 열기 + assert r.status_code == 303 and r.headers["location"] == "/inout/?options=1" + assert 'data-open="1"' in c.get("/inout/?options=1").text + panel = c.get("/inout/settings?panel=1").text + assert buyer["email"] in panel and "발주 담당" in panel and "