feat(vacation): 입사일(이름 옆 날짜) · 근로기준법 연차 자동 · 2026 시스템 전 사용 연차

- 잔여 연차 표 이름 옆 입사일 날짜 버튼(ErpDatePop.enhance, « » 1년씩) → vacation_employees(마이그레이션 002)
- 법정 연차 = 근로기준법 제60조 입사일 기준(1년 미만 월 1일·최대 11, 근속 n년 min(25, 15+(n-1)//2)), 그해 생기는 날을 모음
  (store.legal_annual_leave, 화면도 같은 계산으로 바로 표시) — 연차 칸을 비우면 법정, 숫자면 직접 입력(total_days NULL 허용)
- 2026(도입 해)만 "시스템 전 사용"(prior_used) 칸 — 잔여 = 총 − 시스템 전 사용 − 승인된 연차·반차(db.balance_summary 한 곳)
- 테스트: 법정 연차 규칙, 실제 PG(입사일·법정·직접·시스템 전·검증), 실제 앱 저장, 브라우저(입사일 버튼·바로 계산·전송)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-26 15:53:45 +09:00
parent f0391e88fa
commit d20ce1efac
18 changed files with 592 additions and 97 deletions
+15
View File
@@ -30,6 +30,21 @@ def main() -> None:
html = env.get_template("vacation/form.html").render(**ctx)
with open(os.path.join(OUT_DIR, "vac_form.html"), "w", encoding="utf-8") as f:
f.write(html)
# 옵션 — 잔여 연차 표(2026, 입사일·법정 연차·시스템 전 사용) → tests/js/.out/vac_options.html
row = {"active": True, "picture": "", "service_years": 0, "legal": None, "legal_tip": "", "total": None, "effective_total": 0,
"prior": 0.0, "used": 0.0, "remaining": None, "memo": "", "last_total": None, "hire_date": ""}
octx = {**ctx, "page_title": "휴가 — 옵션", "is_admin": True, "can_edit": True, "msg": "",
"options": {"approvers": [], "notifiers": [], "ready": True, "updated_by": "", "updated_at": ""},
"candidates": [], "effective_approvers": [], "gmail": {"available": False, "connected": False, "smtp": True},
"bal_year": 2026, "bal_prior_year": True, "hire_ready": True,
"bal_rows": [
{**row, "email": "lee@test.local", "name": "이팀장", "hire_date": "2020-03-02", "service_years": 6, "legal": 17.0,
"legal_tip": "03-02 근속 6년 17일", "used": 4.5, "remaining": 12.5},
{**row, "email": "kim@test.local", "name": "김철수", "used": 1.0},
]}
html = env.get_template("vacation/options.html").render(**octx)
with open(os.path.join(OUT_DIR, "vac_options.html"), "w", encoding="utf-8") as f:
f.write(html)
if __name__ == "__main__":
@@ -0,0 +1,87 @@
// 휴가 옵션 잔여 연차 — 이름 옆 입사일 날짜 버튼 · 근로기준법 연차 바로 계산 · 시스템 전 사용(2026-10-27) — 실제 브라우저(Chromium).
// python tests/js/render_vacation.py
// NODE_PATH=<playwright 경로> PJ_TEST_BROWSER=<Chrome 경로> node tests/js/vacation_balances.browser.test.js
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 } : {});
const posts = [];
try {
const p = await (await browser.newContext({ viewport: { width: 1400, height: 900 } })).newPage();
await p.route("**/*", function (r) {
const req = r.request(), url = new URL(req.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 (req.method() === "POST") { posts.push(req.postData()); return r.fulfill({ status: 200, contentType: "text/html", body: "ok" }); }
r.fulfill({ status: 200, contentType: "text/html; charset=utf-8", body: fs.readFileSync(path.join(__dirname, ".out", "vac_options.html"), "utf8") });
});
await p.goto("http://erp.test/vacation/options");
await p.waitForTimeout(200);
const rowState = function (email) {
return p.evaluate(function (email) {
const tr = document.querySelector('input[name="email"][value="' + email + '"]').closest("tr");
const btn = tr.querySelector(".vac-hire-btn");
return { btn: btn && btn.textContent.replace("calendar_month", "").trim(), nextToName: !!btn && btn.parentElement === tr.querySelector(".vac-bal-person"),
hire: tr.querySelector('input[name="hire"]').value, hireShown: getComputedStyle(tr.querySelector('input[name="hire"]')).display !== "none",
years: tr.querySelector(".vac-bal-years-cell").textContent.trim(), legal: tr.querySelector(".vac-bal-legal").textContent.trim(),
placeholder: tr.querySelector('input[name="total"]').placeholder, remain: tr.querySelector(".vac-bal-remain").textContent.trim(),
minus: tr.querySelector(".vac-bal-remain").classList.contains("is-minus") };
}, email);
};
const lee = await rowState("lee@test.local");
check("입사일 = 이름 옆 날짜 버튼(연도까지), 숨긴 input 이 값", lee.nextToName && !lee.hireShown && lee.btn === "2020.03.02(월)" &&
lee.hire === "2020-03-02" && lee.legal === "17" && lee.remain === "12.5", lee);
const kim0 = await rowState("kim@test.local");
check("입사일 없음 = '입사일' 버튼, 근속·법정 —", kim0.btn === "입사일" && kim0.years === "—" && kim0.legal === "—" && kim0.remain === "—", kim0);
// 김철수 입사일 2025-03-01 직접 입력(Enter) → 근속 1년 · 법정 17(1/1·2/1 월 1일 + 3/1 15일) · 잔여 17 − 1(사용)
await p.click('tr:has(input[value="kim@test.local"]) .vac-hire-btn');
const pop = await p.evaluate(function () {
const el = document.querySelector(".pj-datepop");
return el && { navs: el.querySelectorAll(".pj-dp-navbtn").length, field: el.querySelector(".pj-dp-field").placeholder,
clear: !!el.querySelector(".pj-dp-clear") };
});
check("입사일 팝업 = 날짜 하나, « ‹ › » (1년씩 이동), 지우기", !!pop && pop.navs === 4 && pop.field === "입사일" && pop.clear, pop);
await p.fill(".pj-dp-field", "2025-03-01");
await p.press(".pj-dp-field", "Enter");
const kim1 = await rowState("kim@test.local");
check("입사일 고르면 근속·법정 연차·잔여 바로 계산(근로기준법)", kim1.btn === "2025.03.01(토)" && kim1.hire === "2025-03-01" &&
kim1.years === "1년" && kim1.legal === "17" && kim1.placeholder === "17" && kim1.remain === "16", kim1);
// 시스템 전 사용 3.5 → 잔여 12.5, 연차 직접 10 → 10 − 3.5 − 1 = 5.5, 20 넘게 쓰면 빨강
await p.fill('tr:has(input[value="kim@test.local"]) input[name="prior"]', "3.5");
check("시스템 전 사용 → 잔여에서 뺌", (await rowState("kim@test.local")).remain === "12.5");
await p.fill('tr:has(input[value="kim@test.local"]) input[name="total"]', "10");
check("연차 직접 입력이 법정보다 먼저", (await rowState("kim@test.local")).remain === "5.5");
await p.fill('tr:has(input[value="kim@test.local"]) input[name="prior"]', "12");
const kim2 = await rowState("kim@test.local");
check("모자라면 잔여 빨강", kim2.remain === "-3" && kim2.minus, kim2);
// 1년씩 이동 버튼 — 2025년 3월 → « → 2024년 3월
await p.click('tr:has(input[value="lee@test.local"]) .vac-hire-btn');
const t0 = await p.textContent(".pj-dp-title");
await p.click('.pj-dp-navbtn[data-nav="-12"]');
const t1 = await p.textContent(".pj-dp-title");
check("« = 1년 전 달력", t0 === "2020년 3월" && t1 === "2019년 3월", [t0, t1]);
await p.keyboard.press("Escape");
// 저장 — 줄마다 email·hire·total·prior·memo
await p.click('button[type="submit"]:has-text("잔여 연차 저장")');
await p.waitForTimeout(200);
const body = decodeURIComponent((posts[0] || "").replace(/\+/g, " "));
check("저장 → 입사일·연차·시스템 전 사용이 줄마다 전송", /email=kim@test.local/.test(body) && /hire=2025-03-01/.test(body) &&
/hire=2020-03-02/.test(body) && /total=10/.test(body) && /prior=12/.test(body) && (body.match(/hire=/g) || []).length === 2, body);
} finally {
await browser.close();
}
if (fails.length) { console.log("\n" + fails.length + " FAILED"); process.exit(1); }
console.log("\nALL PASS");
})().catch(function (e) { console.error(e); process.exit(1); });