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:
@@ -201,6 +201,18 @@ class Store:
|
||||
return []
|
||||
def used_days(self, user_email, year):
|
||||
return 0.0
|
||||
def hire_ready(self):
|
||||
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)
|
||||
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 ""}
|
||||
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)}
|
||||
|
||||
@@ -356,8 +368,10 @@ 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):
|
||||
saved.update(year=year, rows=rows); return len(rows)
|
||||
def save_balances(self, year, rows, by=""):
|
||||
saved.update(year=year, rows=rows, by=by); return len(rows)
|
||||
def hire_dates(self):
|
||||
return {"lee@test.local": "2020-03-02"}
|
||||
def list_holidays(self, year=None):
|
||||
return []
|
||||
def holiday_map(self, date_from, date_to):
|
||||
@@ -365,8 +379,6 @@ class Store2(Store):
|
||||
if date_from <= d <= date_to}
|
||||
def list_overlapping(self, date_from, date_to):
|
||||
return []
|
||||
def balance_summary(self, user_email, year):
|
||||
return {"year": year, "total_days": 15.0, "used_days": 4.5, "remaining_days": 10.5, "memo": ""}
|
||||
def list_pending(self):
|
||||
return []
|
||||
st2 = Store2()
|
||||
@@ -383,26 +395,38 @@ def body(c):
|
||||
assert '<span class="vac-opt-face is-ini">k</span>' in t
|
||||
assert "gone@test.local · 휴가 권한 없음" in t # 예전에 등록된 사람도 보여 줌
|
||||
i = t.index('name="email" value="lee@test.local"')
|
||||
row = t[i:i + 900]
|
||||
row = t[i:i + 1800]
|
||||
h = t.rfind('name="hire"', 0, i)
|
||||
assert 'value="2020-03-02"' in t[h:i], t[h:i] # 입사일 = 이름 옆 날짜 칸(값 저장소)
|
||||
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
|
||||
# 저장 — 빈 칸은 건너뜀, 연도·이메일·메모 그대로
|
||||
# 저장 — 줄마다 입사일·연차(빈 칸 = 법정)·시스템 전 사용·메모, 저장한 사람
|
||||
r = c.post("/vacation/options/balances", data={"year": "2026", "email": ["lee@test.local", "kim@test.local", "chip@test.local"],
|
||||
"total": ["16", "", "15.5"], "memo": ["a", "b", "c"]})
|
||||
"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, "rows": [{"user_email": "lee@test.local", "total_days": 16.0, "memo": "a"},
|
||||
{"user_email": "chip@test.local", "total_days": 15.5, "memo": "c"}]}, saved
|
||||
assert c.post("/vacation/options/balances", data={"year": "2026", "email": ["lee@test.local"], "total": ["x"], "memo": [""]}).status_code == 400
|
||||
assert saved == {"year": 2026, "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)만
|
||||
# 승인자(옵션 미지정 → 휴가 승인 권한 chip)는 잔여 연차도 보고 저장
|
||||
who["u"] = chip
|
||||
assert 'id="balances"' in c.get("/vacation/options").text
|
||||
assert c.post("/vacation/options/balances", data={"year": "2026", "email": ["kim@test.local"], "total": ["14"], "memo": [""]}).status_code == 303
|
||||
assert c.post("/vacation/options/balances", data={"year": "2026", "email": ["kim@test.local"], "hire": [""], "total": ["14"],
|
||||
"prior": [""], "memo": [""]}).status_code == 303
|
||||
# 관리자·승인자·통보자 아님 — 표 안 보임, 저장 403
|
||||
who["u"] = kim
|
||||
assert 'id="balances"' not in c.get("/vacation/options").text
|
||||
assert c.post("/vacation/options/balances", data={"year": "2026", "email": ["kim@test.local"], "total": ["30"], "memo": [""]}).status_code == 403
|
||||
assert c.post("/vacation/options/balances", data={"year": "2026", "email": ["kim@test.local"], "hire": [""], "total": ["30"],
|
||||
"prior": [""], "memo": [""]}).status_code == 403
|
||||
# 설정 화면 삭제 — 예전 주소는 옵션으로, 공휴일·잔여 연차 저장 주소 없음
|
||||
who["u"] = admin
|
||||
r = c.get("/vacation/settings?year=2026")
|
||||
|
||||
Reference in New Issue
Block a user