feat(입출고): 날짜 칸을 ERP 공용 달력으로
발주 목록 기간, 발주일, 입고 예정일, 입고일을 erp-datepop 으로 교체. 국경일·대체공휴일을 빨강·이름으로 표시하고 마우스를 올리면 이름을 보여 준다. 필수 칸은 지우기를 빼고, 잠긴 입고일은 버튼도 비활성화. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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`) + 입출고(오른쪽 달력·날짜 칸).
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -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`).
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
{# 날짜 칸 = ERP 공용 달력(erp-datepop) — inout.js 가 input[type=date] 를 날짜 버튼으로 바꾼다. inout.js 보다 먼저 include. #}
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
<link rel="stylesheet" href="/static/erp-datepop.css?v=20261102a" />
|
||||
<script type="application/json" id="io-holidays">{{ (date_holidays or {}) | tojson }}</script>
|
||||
<script src="/static/erp-datepop.js?v=20261102a" defer></script>
|
||||
@@ -1,6 +1,6 @@
|
||||
{% extends "erp_base.html" %}
|
||||
{% from "inout/_macros.html" import order_badge, progress, due, n, ymd %}
|
||||
{% block head_extra %}<link rel="stylesheet" href="/static/inout.css?v=20261104c" />{% endblock %}
|
||||
{% block head_extra %}<link rel="stylesheet" href="/static/inout.css?v=20261105a" />{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="io-split">{# 2열 — 왼쪽 화면 | 오른쪽 달력(2026-10-21) #}
|
||||
@@ -21,7 +21,7 @@
|
||||
<option value="">전체 공장</option>
|
||||
{% for f in factories %}<option value="{{ f.id }}" {% if filters.factory == f.id %}selected{% endif %}>{{ f.name }}{% if not f.is_active %} (사용 안 함){% endif %}</option>{% endfor %}
|
||||
</select>
|
||||
<label class="io-date">발주일 <input class="erp-input" type="date" name="from" value="{{ filters['from'] }}" /></label>
|
||||
<label class="io-date">발주일 <input class="erp-input" type="date" name="from" value="{{ filters['from'] }}" aria-label="발주일 시작" /></label>
|
||||
<span class="erp-muted">~</span>
|
||||
<input class="erp-input" type="date" name="to" value="{{ filters['to'] }}" aria-label="발주일 끝" />
|
||||
<input class="erp-input io-search" type="search" name="q" value="{{ filters.q }}" placeholder="발주번호·제품 코드·제품 이름" />
|
||||
@@ -71,4 +71,4 @@
|
||||
{% include "inout/_calendar.html" %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% block scripts %}<script src="/static/inout.js?v=20261104c" defer></script>{% endblock %}
|
||||
{% block scripts %}{% include "inout/_datepop.html" %}<script src="/static/inout.js?v=20261105a" defer></script>{% endblock %}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
</footer>
|
||||
</dialog>
|
||||
{%- endmacro -%}
|
||||
{% block head_extra %}<link rel="stylesheet" href="/static/inout.css?v=20261104c" />{% endblock %}
|
||||
{% block head_extra %}<link rel="stylesheet" href="/static/inout.css?v=20261105a" />{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% set active = order.status in ('open', 'partial') %}
|
||||
@@ -155,7 +155,7 @@
|
||||
</div>
|
||||
{% if receiving %}
|
||||
<div class="io-receipt-bar{% if recv_done %} is-locked{% endif %}"{% if recv_done %} aria-disabled="true" title="전체 입고 완료 — 더 입고할 수 없습니다"{% endif %}>
|
||||
<label class="erp-field"><span>입고일 *</span><input type="date" name="receipt_date" value="{{ receipt_form.receipt_date }}" required{{ dis }} /></label>
|
||||
<label class="erp-field"><span>입고일 *</span><input type="date" name="receipt_date" value="{{ receipt_form.receipt_date }}" aria-label="입고일" required{{ dis }} /></label>
|
||||
<label class="erp-field io-grow"><span>메모</span><input type="text" name="memo" value="{{ receipt_form.memo }}" maxlength="500" placeholder="차량·박스 수·검수 메모 등"{{ dis }} /></label>
|
||||
<div class="erp-field io-photo-field">
|
||||
<span>입고증 사진 <small>(최대 {{ max_photos }}장)</small></span>
|
||||
@@ -262,4 +262,4 @@
|
||||
{% include "inout/_calendar.html" %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% block scripts %}<script src="/static/inout.js?v=20261104c" defer></script>{% endblock %}
|
||||
{% block scripts %}{% include "inout/_datepop.html" %}<script src="/static/inout.js?v=20261105a" defer></script>{% endblock %}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{% extends "erp_base.html" %}
|
||||
{% block head_extra %}<link rel="stylesheet" href="/static/inout.css?v=20261104c" />{% endblock %}
|
||||
{% block head_extra %}<link rel="stylesheet" href="/static/inout.css?v=20261105a" />{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="io-split">{# 2열 — 왼쪽 화면 | 오른쪽 달력(2026-10-21) #}
|
||||
@@ -23,8 +23,8 @@
|
||||
</select>
|
||||
{% if not factories %}<span class="io-hint">공장이 없습니다 — 관리자가 옵션에서 먼저 공장을 추가해야 합니다.</span>{% endif %}
|
||||
</label>
|
||||
<label class="erp-field"><span>발주일 *</span><input type="date" name="order_date" value="{{ vals.order_date }}" required /></label>
|
||||
<label class="erp-field"><span>입고 예정일</span><input type="date" name="due_date" value="{{ vals.due_date }}" /></label>
|
||||
<label class="erp-field"><span>발주일 *</span><input type="date" name="order_date" value="{{ vals.order_date }}" aria-label="발주일" required /></label>
|
||||
<label class="erp-field"><span>입고 예정일</span><input type="date" name="due_date" value="{{ vals.due_date }}" aria-label="입고 예정일" /></label>
|
||||
<label class="erp-field"><span>메모</span><input type="text" name="memo" value="{{ vals.memo }}" maxlength="500" placeholder="공장 전달 사항 등" /></label>
|
||||
</div>
|
||||
|
||||
@@ -102,4 +102,4 @@
|
||||
{% include "inout/_calendar.html" %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% block scripts %}<script src="/static/inout.js?v=20261104c" defer></script>{% endblock %}
|
||||
{% block scripts %}{% include "inout/_datepop.html" %}<script src="/static/inout.js?v=20261105a" defer></script>{% endblock %}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{% extends "erp_base.html" %}
|
||||
{% from "inout/_macros.html" import due, n, ymd %}
|
||||
{% block head_extra %}<link rel="stylesheet" href="/static/inout.css?v=20261104c" />{% endblock %}
|
||||
{% block head_extra %}<link rel="stylesheet" href="/static/inout.css?v=20261105a" />{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="io-split">{# 2열 — 왼쪽 화면 | 오른쪽 달력(2026-10-21) #}
|
||||
@@ -91,4 +91,4 @@
|
||||
{% include "inout/_calendar.html" %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% block scripts %}<script src="/static/inout.js?v=20261104c" defer></script>{% endblock %}
|
||||
{% block scripts %}<script src="/static/inout.js?v=20261105a" defer></script>{% endblock %}
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
// 입출고 날짜 칸 = ERP 공용 달력(2026-11-05) — 실제 브라우저(Chromium).
|
||||
// python tests/js/render_inout.py
|
||||
// NODE_PATH=<playwright 경로> PJ_TEST_BROWSER=<Chrome 경로> 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");
|
||||
})();
|
||||
@@ -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 %}<link rel="stylesheet" href="/static/inout.css" />{% endblock %}'
|
||||
'{% block content %}<section class="io"><input type="date" name="receipt_date" value="2026-10-05" aria-label="입고일" required disabled /></section>{% endblock %}'
|
||||
'{% block scripts %}{% include "inout/_datepop.html" %}<script src="/static/inout.js" defer></script>{% 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()
|
||||
Reference in New Issue
Block a user