From 212a3dd6b0c6c732a18d80e3190cc41530ffa3ae Mon Sep 17 00:00:00 2001 From: king Date: Thu, 5 Nov 2026 14:11:45 +0900 Subject: [PATCH] =?UTF-8?q?feat(=EC=9E=85=EC=B6=9C=EA=B3=A0):=20=EB=82=A0?= =?UTF-8?q?=EC=A7=9C=20=EC=B9=B8=EC=9D=84=20ERP=20=EA=B3=B5=EC=9A=A9=20?= =?UTF-8?q?=EB=8B=AC=EB=A0=A5=EC=9C=BC=EB=A1=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 발주 목록 기간, 발주일, 입고 예정일, 입고일을 erp-datepop 으로 교체. 국경일·대체공휴일을 빨강·이름으로 표시하고 마우스를 올리면 이름을 보여 준다. 필수 칸은 지우기를 빼고, 잠긴 입고일은 버튼도 비활성화. Co-Authored-By: Claude Opus 5.5 --- CLAUDE.md | 4 +- app/modules/inout/CLAUDE.md | 2 + app/modules/inout/router.py | 12 ++- .../inout/templates/inout/_datepop.html | 5 ++ app/modules/inout/templates/inout/index.html | 6 +- .../inout/templates/inout/order_detail.html | 6 +- .../inout/templates/inout/order_form.html | 8 +- .../inout/templates/inout/pending.html | 4 +- app/static/inout.css | 3 +- app/static/inout.js | 12 +++ tests/js/inout_datepop.browser.test.js | 77 +++++++++++++++++++ tests/js/render_inout.py | 45 +++++++++++ 12 files changed, 168 insertions(+), 16 deletions(-) create mode 100644 app/modules/inout/templates/inout/_datepop.html create mode 100644 tests/js/inout_datepop.browser.test.js create mode 100644 tests/js/render_inout.py diff --git a/CLAUDE.md b/CLAUDE.md index e1eda17..02b0e47 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -66,8 +66,8 @@ - `asset/media.py prepare_photo`(이미지 확인·메타데이터 제거): 자산 + 라이브 커머스. - `app/mail.py`: 프로젝트 알림 메일. - ERP 모든 화면 스크립트: `erp-notice.js`(공지) · `erp-overdue.js`(프로젝트 마감 알림). -- 아사나식 날짜 팝업: 프로젝트(`project.js` 안) + 공용 복사본 `erp-datepop.js/css`(휴가 신청) — 바꾸면 둘 다. -- 국경일·대체공휴일 표 `project/store.py KR_HOLIDAYS`: 프로젝트 캘린더·날짜 팝업 + 휴가(달력·일수 계산 `vacation/db.holiday_map`). +- 아사나식 날짜 팝업: 프로젝트(`project.js` 안) + 공용 복사본 `erp-datepop.js/css`(휴가 신청·입출고 날짜 칸) — 바꾸면 둘 다. +- 국경일·대체공휴일 표 `project/store.py KR_HOLIDAYS`: 프로젝트 캘린더·날짜 팝업 + 휴가(달력·일수 계산 `vacation/db.holiday_map`) + 입출고(오른쪽 달력·날짜 칸). --- diff --git a/app/modules/inout/CLAUDE.md b/app/modules/inout/CLAUDE.md index f59473f..03f9c85 100644 --- a/app/modules/inout/CLAUDE.md +++ b/app/modules/inout/CLAUDE.md @@ -119,3 +119,5 @@ - 시각은 DB 시간대와 무관하게 KST 로 읽음(`db._KstTimestamptzLoader`). - 날짜 서식은 모두 `yyyy.mm.dd(요일)`(`ymd`·`ymdhm` 매크로, `store.fmt_date`). +- **날짜 칸 = ERP 공용 달력**(2026-11-05, `erp-datepop`, `_datepop.html` + `inout.js` 머리) — 발주 목록 기간·발주일·입고 예정일·입고일. `input[type=date]` 는 숨긴 값 저장소(폼 전송 그대로), 국경일·대체공휴일 빨강·이름 + 마우스를 올리면 이름(`title`, 표 = `project.store.KR_HOLIDAYS`, `router._date_holidays`). + 필수 칸은 [지우기] 없음(숨긴 required 칸이 비면 브라우저가 안내 없이 저장을 막는다), 잠긴 입고일은 버튼도 disabled. 테스트 `tests/js/inout_datepop.browser.test.js`(`render_inout.py`). diff --git a/app/modules/inout/router.py b/app/modules/inout/router.py index b05c75e..99c02cc 100644 --- a/app/modules/inout/router.py +++ b/app/modules/inout/router.py @@ -106,6 +106,16 @@ def _require(st: Any, user: dict[str, Any], what: str) -> dict[str, bool]: return p +def _date_holidays() -> dict[str, str]: + """날짜 칸 달력(erp-datepop)의 국경일·대체공휴일 — 프로젝트 달력과 같은 표.""" + try: + from app.modules.project.store import KR_HOLIDAYS # noqa: WPS433 + + return dict(KR_HOLIDAYS) + except Exception: # noqa: BLE001 — 표를 못 읽어도 날짜 입력은 된다 + return {} + + def _render(request: Request, name: str, user: dict[str, Any], ctx: dict[str, Any], status_code: int = 200) -> HTMLResponse: from app.main import build_erp_nav, render_template # noqa: WPS433 @@ -114,7 +124,7 @@ def _render(request: Request, name: str, user: dict[str, Any], ctx: dict[str, An return render_template(request, name, { "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(), + "msg": request.query_params.get("msg", ""), "today": today_kst(), "date_holidays": _date_holidays(), "open_options": request.query_params.get("options") == "1" and perms["admin"], # 톱니 팝업 바로 열기 **ctx, }, status_code=status_code) diff --git a/app/modules/inout/templates/inout/_datepop.html b/app/modules/inout/templates/inout/_datepop.html new file mode 100644 index 0000000..de86fd2 --- /dev/null +++ b/app/modules/inout/templates/inout/_datepop.html @@ -0,0 +1,5 @@ +{# 날짜 칸 = ERP 공용 달력(erp-datepop) — inout.js 가 input[type=date] 를 날짜 버튼으로 바꾼다. inout.js 보다 먼저 include. #} + + + + diff --git a/app/modules/inout/templates/inout/index.html b/app/modules/inout/templates/inout/index.html index 93bf3d3..589939d 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 order_badge, progress, due, n, ymd %} -{% block head_extra %}{% endblock %} +{% block head_extra %}{% endblock %} {% block content %}
{# 2열 — 왼쪽 화면 | 오른쪽 달력(2026-10-21) #} @@ -21,7 +21,7 @@ {% for f in factories %}{% endfor %} - + ~ @@ -71,4 +71,4 @@ {% include "inout/_calendar.html" %}
{% endblock %} -{% block scripts %}{% endblock %} +{% block scripts %}{% include "inout/_datepop.html" %}{% endblock %} diff --git a/app/modules/inout/templates/inout/order_detail.html b/app/modules/inout/templates/inout/order_detail.html index 83cc7fd..a99f7fa 100644 --- a/app/modules/inout/templates/inout/order_detail.html +++ b/app/modules/inout/templates/inout/order_detail.html @@ -20,7 +20,7 @@ {%- endmacro -%} -{% block head_extra %}{% endblock %} +{% block head_extra %}{% endblock %} {% block content %} {% set active = order.status in ('open', 'partial') %} @@ -155,7 +155,7 @@ {% if receiving %}
- +
입고증 사진 (최대 {{ max_photos }}장) @@ -262,4 +262,4 @@ {% include "inout/_calendar.html" %}
{% endblock %} -{% block scripts %}{% endblock %} +{% block scripts %}{% include "inout/_datepop.html" %}{% endblock %} diff --git a/app/modules/inout/templates/inout/order_form.html b/app/modules/inout/templates/inout/order_form.html index d011d4c..aaa4b75 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 %}
{# 2열 — 왼쪽 화면 | 오른쪽 달력(2026-10-21) #} @@ -23,8 +23,8 @@ {% if not factories %}공장이 없습니다 — 관리자가 옵션에서 먼저 공장을 추가해야 합니다.{% endif %} - - + +
@@ -102,4 +102,4 @@ {% include "inout/_calendar.html" %}
{% endblock %} -{% block scripts %}{% endblock %} +{% block scripts %}{% include "inout/_datepop.html" %}{% endblock %} diff --git a/app/modules/inout/templates/inout/pending.html b/app/modules/inout/templates/inout/pending.html index f349215..ef3c78c 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, ymd %} -{% block head_extra %}{% endblock %} +{% block head_extra %}{% endblock %} {% block content %}
{# 2열 — 왼쪽 화면 | 오른쪽 달력(2026-10-21) #} @@ -91,4 +91,4 @@ {% include "inout/_calendar.html" %}
{% endblock %} -{% block scripts %}{% endblock %} +{% block scripts %}{% endblock %} diff --git a/app/static/inout.css b/app/static/inout.css index 663b399..9e8fa90 100644 --- a/app/static/inout.css +++ b/app/static/inout.css @@ -16,7 +16,8 @@ .io-filter { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; } .io-filter .erp-select { width: auto; } .io-search { width: 260px; } -.io-filter input[type="date"] { width: 150px; } +.io .pj-date-btn { margin-top: 0; height: 34px; box-sizing: border-box; } +.io .pj-date-btn:disabled { opacity: .5; cursor: not-allowed; } .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; } .io-seg-btn { padding: 5px 12px; border-radius: 8px; font-size: 12.5px; color: var(--color-rich-black); text-decoration: none; white-space: nowrap; } diff --git a/app/static/inout.js b/app/static/inout.js index 1e578f6..822bc50 100644 --- a/app/static/inout.js +++ b/app/static/inout.js @@ -21,6 +21,18 @@ } function fmt(n) { return n.toLocaleString("ko-KR"); } + // ── 날짜 칸 = ERP 공용 달력(프로젝트와 같은 모양, 국경일·대체공휴일 빨강·이름, 마우스를 올리면 이름) ── + // 필수 칸은 [지우기]를 뺀다 — 숨긴 required 칸이 비면 브라우저가 안내 없이 저장을 막는다. + if (window.ErpDatePop) { + let holidays = {}; + try { holidays = JSON.parse((document.getElementById("io-holidays") || {}).textContent || "{}"); } catch (_) { holidays = {}; } + document.querySelectorAll('input[type="date"]').forEach(function (input) { + const pop = window.ErpDatePop.enhance(input, { label: input.getAttribute("aria-label") || "날짜", + format: window.ErpDatePop.fmtFull, clear: !input.required, holidays: holidays }); + if (pop) pop.button.disabled = input.disabled; + }); + } + // ── 목록 줄 누르기 → 발주서 ── document.addEventListener("click", function (e) { const row = e.target.closest(".io-row-link"); diff --git a/tests/js/inout_datepop.browser.test.js b/tests/js/inout_datepop.browser.test.js new file mode 100644 index 0000000..f8588e5 --- /dev/null +++ b/tests/js/inout_datepop.browser.test.js @@ -0,0 +1,77 @@ +// 입출고 날짜 칸 = ERP 공용 달력(2026-11-05) — 실제 브라우저(Chromium). +// python tests/js/render_inout.py +// NODE_PATH= PJ_TEST_BROWSER= node tests/js/inout_datepop.browser.test.js +// 기본 달력 대신 날짜 버튼, 국경일·대체공휴일 빨강·이름·말풍선(title), 고르면 값 전송, 필수 칸은 지우기 없음, 잠긴 칸은 못 누름. +const fs = require("fs"), path = require("path"); +const { chromium } = require("playwright"); +const ROOT = path.join(__dirname, "..", ".."); +const fails = []; +function check(name, cond, extra) { + if (cond) console.log("PASS " + name); + else { console.log("FAIL " + name + (extra !== undefined ? " → " + JSON.stringify(extra) : "")); fails.push(name); } +} + +(async function () { + const exe = process.env.PJ_TEST_BROWSER; + const browser = await chromium.launch(exe ? { executablePath: exe } : {}); + try { + const p = await (await browser.newContext({ viewport: { width: 1400, height: 900 } })).newPage(); + const errors = []; + p.on("pageerror", function (e) { errors.push(String(e)); }); + await p.route("**/*", function (r) { + const url = new URL(r.request().url()).pathname; + if (url.startsWith("/static/")) { + const f = path.join(ROOT, "app", url); + if (!fs.existsSync(f)) return r.fulfill({ status: 404, body: "" }); + const type = f.endsWith(".css") ? "text/css" : f.endsWith(".js") ? "application/javascript" : "font/woff2"; + return r.fulfill({ status: 200, contentType: type, body: fs.readFileSync(f) }); + } + if (!url.endsWith(".html")) return r.fulfill({ status: 200, contentType: "application/json", body: "{}" }); + r.fulfill({ status: 200, contentType: "text/html; charset=utf-8", body: fs.readFileSync(path.join(__dirname, ".out", url.slice(1)), "utf8") }); + }); + + await p.goto("http://erp.test/inout_form.html"); + await p.waitForTimeout(200); + const order = p.locator('input[name="order_date"]'), due = p.locator('input[name="due_date"]'); + check("기본 달력 칸은 숨김", !(await order.isVisible()) && !(await due.isVisible())); + const orderBtn = p.locator('input[name="order_date"] + button'), dueBtn = p.locator('input[name="due_date"] + button'); + check("발주일 버튼 = yyyy.mm.dd(요일)", (await orderBtn.textContent()).includes("2026.10.05(월)"), await orderBtn.textContent()); + + await orderBtn.click(); + const pop = p.locator(".pj-datepop"); + check("달력이 열림", await pop.isVisible()); + const hol = pop.locator('[data-iso="2026-10-09"]'); + check("한글날 = 빨강 칸·이름·말풍선", (await hol.getAttribute("class")).includes("is-sun") && (await hol.getAttribute("title")) === "한글날" && (await hol.textContent()).includes("한글날"), await hol.getAttribute("title")); + check("필수 칸은 지우기 없음", (await pop.getByText("지우기").count()) === 0); + await p.waitForTimeout(200); // 등장 애니메이션 뒤에 찍는다 + await p.screenshot({ path: path.join(__dirname, ".out", "inout_datepop.png") }); + await pop.locator('[data-iso="2026-10-08"]').click(); + await p.keyboard.press("Escape"); + check("고른 날짜가 값으로", (await order.inputValue()) === "2026-10-08", await order.inputValue()); + check("버튼 글자도 바뀜", (await orderBtn.textContent()).includes("2026.10.08(목)")); + + await dueBtn.click(); + check("선택 칸은 지우기 있음", (await pop.getByText("지우기").count()) === 1); + // 대체공휴일 — 2026-03-02 삼일절 대체(달을 넘겨 찾지 않고 표 값으로 확인) + const holidays = await p.evaluate(function () { return JSON.parse(document.getElementById("io-holidays").textContent); }); + check("대체공휴일도 표에 있음", holidays["2026-03-02"] === "삼일절 대체", holidays["2026-03-02"]); + await p.keyboard.press("Escape"); + + await p.goto("http://erp.test/inout_list.html"); + await p.waitForTimeout(200); + check("목록 필터 시작일 버튼", (await p.locator('input[name="from"] + button').textContent()).includes("2026.10.01(목)")); + const box = await p.locator('input[name="from"] + button').boundingBox(); + const search = await p.locator('input[name="q"]').boundingBox(); + check("필터 줄 높이가 맞음", Math.abs((box.y + box.height / 2) - (search.y + search.height / 2)) < 4, { box: box, search: search }); + await p.screenshot({ path: path.join(__dirname, ".out", "inout_list.png") }); + + await p.goto("http://erp.test/inout_locked.html"); + await p.waitForTimeout(200); + check("잠긴 입고일은 못 누름", await p.locator('input[name="receipt_date"] + button').isDisabled()); + check("스크립트 오류 없음", errors.length === 0, errors); + } finally { + await browser.close(); + } + if (fails.length) { console.log("\n" + fails.length + " FAILED"); process.exit(1); } + console.log("\nALL OK"); +})(); diff --git a/tests/js/render_inout.py b/tests/js/render_inout.py new file mode 100644 index 0000000..b3907bd --- /dev/null +++ b/tests/js/render_inout.py @@ -0,0 +1,45 @@ +"""입출고 날짜 칸 화면을 진짜 ERP 셸(erp_base.html)로 렌더 — 공용 달력 브라우저 테스트용(2026-11-05). + + python tests/js/render_inout.py # → tests/js/.out/inout_form.html · inout_list.html · inout_locked.html + +DB 없이 날짜 칸에 필요한 값만 넣는다(나머지 값은 비어 있음 — ChainableUndefined). 공휴일 = 실제 표. +""" + +from __future__ import annotations + +import os +import sys +from datetime import date + +import jinja2 + +ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +sys.path.insert(0, ROOT) +OUT_DIR = os.path.join(ROOT, "tests", "js", ".out") + +from app.modules.inout.router import _date_holidays # noqa: E402 + + +def main() -> None: + os.makedirs(OUT_DIR, exist_ok=True) + env = jinja2.Environment( + loader=jinja2.FileSystemLoader([os.path.join(ROOT, "app", "templates"), os.path.join(ROOT, "app", "modules", "inout", "templates")]), + autoescape=True, undefined=jinja2.ChainableUndefined) + base = {"date_holidays": _date_holidays(), "today": date(2026, 10, 5), "user": {"name": "테스트", "email": "t@test.local"}, "nav_items": [], "perms": {"can_order": True, "can_receive": True}} + pages = { + "inout_form.html": ("inout/order_form.html", {"vals": {"order_date": "2026-10-05", "due_date": ""}, "factories": []}), + "inout_list.html": ("inout/index.html", {"filters": {"from": "2026-10-01", "to": "", "status": "open", "q": "", "factory": ""}, "factories": [], "orders": [], "status_filters": {}}), + } + for out, (name, ctx) in pages.items(): + with open(os.path.join(OUT_DIR, out), "w", encoding="utf-8") as f: + f.write(env.get_template(name).render(**base, **ctx)) + # 입고 칸만 — order_detail.html 은 값이 많아, 전체 입고 완료로 잠긴 입고일 칸(disabled)을 같은 스크립트로 확인 + locked = env.from_string('{% extends "erp_base.html" %}{% block head_extra %}{% endblock %}' + '{% block content %}
{% endblock %}' + '{% block scripts %}{% include "inout/_datepop.html" %}{% endblock %}') + with open(os.path.join(OUT_DIR, "inout_locked.html"), "w", encoding="utf-8") as f: + f.write(locked.render(**base)) + + +if __name__ == "__main__": + main()