feat(vacation): 연차 12/31 소멸 삭제 — 입사일 기준, 연차마다 쓸 수 있는 기한

- store.leave_grants/leave_period/leave_status: 1년 미만 월 1일 = 입사일부터 1년까지, 근속 n년 연차 = 생긴 날부터 1년까지(근로기준법 제60조)
- 승인된 연차·반차를 날짜별(usage_units = compute_days 규칙)로 나눠 그날 쓸 수 있는 연차 중 먼저 소멸하는 것부터 차감, 생기기 전이면 당겨 씀
- 화면: 지금 연차 기간 · 생기는 연차(오늘까지 +앞으로) · 사용 · 오늘 쓸 수 있는 잔여 · 먼저 소멸(날짜·일수), 해 이동 없음, 달력 위 내 연차도 같은 값
- 직접 입력 = 지금 연차 기간이 시작한 해 줄(override_year), 시스템 전 사용 = 2026 줄(도입일에 쓴 것으로)
- 테스트: 규칙(10/12 입사 사례·먼저 소멸·당겨 씀·시스템 전·입사일 없음), 실제 PG, 실제 앱, 브라우저

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-26 16:27:50 +09:00
parent 197c3c13a3
commit 4b2defac3a
16 changed files with 500 additions and 311 deletions
+20 -16
View File
@@ -205,14 +205,18 @@ class Store:
return True
def hire_dates(self):
return {}
def balance_summary(self, user_email, year, hire_date=None):
bal = {b["user_email"]: b for b in self.list_balances(year)}.get(user_email)
used = self.used_days(user_email, year)
def balance_summary(self, user_email, as_of=None, hire_date=None): # db.balance_summary 모양(입사일 기준, 가짜 계산)
from app.timezone import today_kst
as_of = as_of or today_kst()
bal = {b["user_email"]: b for b in self.list_balances(as_of.year)}.get(user_email)
used = self.used_days(user_email, as_of.year)
manual = bal["total_days"] if bal else None
total = manual if manual is not None else 0.0
return {"year": year, "total_days": total, "manual_total": manual, "legal_days": None, "legal_items": [],
"service_years": 0, "hire_date": hire_date or "", "prior_used": 0.0, "erp_used": used,
"used_days": used, "remaining_days": total - used, "memo": bal["memo"] if bal else ""}
return {"has_hire": bool(hire_date), "service_years": 0, "period_start": f"{as_of.year}-01-01" if manual is not None else "",
"period_end": f"{as_of.year}-12-31" if manual is not None else "", "granted": total, "granted_so_far": total,
"upcoming": 0.0, "used": used, "available": total - used, "expiring": None, "grants": [], "as_of": as_of.isoformat(),
"hire_date": hire_date or "", "key_year": as_of.year, "manual_total": manual, "prior_used": 0.0,
"memo": bal["memo"] if bal else "", "total_days": total, "used_days": used, "remaining_days": total - used}
def holiday_map(self, date_from, date_to): # 국경일 + 설정 공휴일(db.holiday_map) — 해마다 한글날만
return {f"{y}-10-09": "한글날" for y in range(int(date_from[:4]), int(date_to[:4]) + 1)}
@@ -368,8 +372,8 @@ class Store2(Store):
[{"user_email": "kim@test.local", "year": year, "total_days": 12, "memo": ""}]
def used_days(self, user_email, year):
return {"lee@test.local": 4.5}.get(user_email, 0.0)
def save_balances(self, year, rows, by=""):
saved.update(year=year, rows=rows, by=by); return len(rows)
def save_balances(self, rows, by="", as_of=None):
saved.update(rows=rows, by=by); return len(rows)
def hire_dates(self):
return {"lee@test.local": "2020-03-02"}
def list_holidays(self, year=None):
@@ -388,7 +392,7 @@ def body(c):
r = c.get("/vacation/options?year=2026")
assert r.status_code == 200, r.status_code
t = r.text
assert 'id="balances"' in t and "2026년 · 참여자 4명" in t, t[t.find("잔여 연차"):t.find("잔여 연차") + 200]
assert 'id="balances"' in t and "기준 · 참여자 4명" in t, t[t.find("잔여 연차"):t.find("잔여 연차") + 200]
for u in users: # 참여자 전원 미리(이름 + 이메일 + 줄마다 칸)
assert f'name="email" value="{u["email"]}"' in t, u["email"]
assert 'src="https://img.test/lee.png"' in t # 사진 있으면 사진, 없으면 첫 글자
@@ -401,22 +405,22 @@ def body(c):
assert "법정 연차" in t and "시스템 전 사용" in t and "근로기준법 제60조" in t
assert 'value="15"' in row and ">4.5<" in row and ">10.5<" in row and 'value="입사 2020"' in row, row
j = t.index('name="email" value="kim@test.local"')
assert 'placeholder="12"' in t[j:j + 600], t[j:j + 600] # 올해 없음 → 작년 연차를 회색 참고
assert "2026.12.31 에 소멸" in t and "승인되면" in t
assert "입사일 기준" in t and "12/31 에 없어지지 않음" in t and "승인되면" in t and "먼저 소멸" in t
assert "12.31 에 소멸" not in t and "12.31 소멸" not in t
# 저장 — 빈 칸은 건너뜀, 연도·이메일·메모 그대로
# 저장 — 줄마다 입사일·연차(빈 칸 = 법정)·시스템 전 사용·메모, 저장한 사람
r = c.post("/vacation/options/balances", data={"year": "2026", "email": ["lee@test.local", "kim@test.local", "chip@test.local"],
"hire": ["2020-03-02", "", "2025-03-01"], "total": ["16", "", ""],
"prior": ["", "2.5", ""], "memo": ["a", "b", "c"]})
assert r.status_code == 303 and "year=2026" in r.headers["location"], r.status_code
assert saved == {"year": 2026, "by": "admin@test.local", "rows": [
assert r.status_code == 303 and r.headers["location"].startswith("/vacation/options?msg="), r.status_code
assert saved == {"by": "admin@test.local", "rows": [
{"user_email": "lee@test.local", "total_days": 16.0, "prior_used": None, "memo": "a", "hire_date": "2020-03-02"},
{"user_email": "kim@test.local", "total_days": None, "prior_used": 2.5, "memo": "b", "hire_date": ""},
{"user_email": "chip@test.local", "total_days": None, "prior_used": None, "memo": "c", "hire_date": "2025-03-01"}]}, saved
bad = {"year": "2026", "email": ["lee@test.local"], "hire": [""], "prior": [""], "memo": [""]}
assert c.post("/vacation/options/balances", data=dict(bad, total=["x"])).status_code == 400
assert c.post("/vacation/options/balances", data={"year": "2026", "email": ["lee@test.local"], "total": ["1"], "memo": [""]}).status_code == 400 # 칸 수
assert "시스템 전 사용</th>" not in c.get("/vacation/options?year=2027").text # 도입 해(2026)만
assert "시스템 전 사용</th>" in c.get("/vacation/options").text # 도입 해(2026)·다음 해까지 칸
# 승인자(옵션 미지정 → 휴가 승인 권한 chip)는 잔여 연차도 보고 저장
who["u"] = chip
assert 'id="balances"' in c.get("/vacation/options").text
@@ -435,11 +439,11 @@ def body(c):
("/vacation/settings/holidays/1/delete", {}),
("/vacation/settings/balances", {"user_email": "a@test.local", "year": "2026", "total_days": "1"})):
assert c.post(url, data=data).status_code in (404, 405), url
# 달력 — 국경일·대체공휴일 이름이 날짜 아래, 그 주는 has-hol, 잔여 옆 12/31 소멸
# 달력 — 국경일·대체공휴일 이름이 날짜 아래, 그 주는 has-hol, 내 연차 = 입사일 기준(12/31 소멸 없음)
t = c.get("/vacation/?year=2026&month=10").text
assert '<span class="vac-hol-name">개천절</span>' in t and '<span class="vac-hol-name">개천절 대체</span>' in t
assert '<span class="vac-hol-name">한글날</span>' in t and t.count("has-hol") == 2, t.count("has-hol")
assert "2026.12.31 소멸" in t
assert "12.31 소멸" not in t and "입사일 미등록(옵션)" in t and "발생 <strong>" in t
assert 'href="/vacation/settings' not in t and ">설정</a>" not in t and 'href="/vacation/options"' in t # 설정 버튼 없음
print("OK")
run(body)