+
diff --git a/app/modules/vacation/templates/vacation/options.html b/app/modules/vacation/templates/vacation/options.html
index 3d5ddc5..8f0c060 100644
--- a/app/modules/vacation/templates/vacation/options.html
+++ b/app/modules/vacation/templates/vacation/options.html
@@ -2,7 +2,7 @@
{#- 휴가 옵션(2026-10-27) — 승인자·승인 통보자(수정 = ERP 관리자, 나머지는 보기만) + 내 Gmail 연결(누구나).
메일: 제출 = 승인자·통보자, 승인·반려 = 승인자·통보자·신청자. 보내는 사람 = 처리한 사람 본인 Gmail(없으면 회사 메일). -#}
-{% block head_extra %}
{% endblock %}
+{% block head_extra %}
{% endblock %}
{% block content %}
+ {% if is_admin %}
+ {#- 잔여 연차(2026-10-27, 설정에서 옮김) — 참여자(휴가 모듈 사용자) 전원을 미리 보여 주고 줄마다 연차 입력. 관리자만 보임·저장. -#}
+
+ {% endif %}
+
메일
diff --git a/app/modules/vacation/templates/vacation/pending.html b/app/modules/vacation/templates/vacation/pending.html
index ae1b19f..669fddd 100644
--- a/app/modules/vacation/templates/vacation/pending.html
+++ b/app/modules/vacation/templates/vacation/pending.html
@@ -1,6 +1,6 @@
{% extends "erp_base.html" %}
-{% block head_extra %}{% endblock %}
+{% block head_extra %}{% endblock %}
{% block content %}
diff --git a/app/modules/vacation/templates/vacation/settings.html b/app/modules/vacation/templates/vacation/settings.html
index fd63a56..afce0ae 100644
--- a/app/modules/vacation/templates/vacation/settings.html
+++ b/app/modules/vacation/templates/vacation/settings.html
@@ -1,6 +1,6 @@
{% extends "erp_base.html" %}
-{% block head_extra %}{% endblock %}
+{% block head_extra %}{% endblock %}
{% block content %}
-
+
-
연차 잔여 ({{ year }})
-
-
-
-
-
사용 일수는 승인된 휴가 합계로 자동 계산됩니다.
+
잔여 연차
+
잔여 연차 등록은 휴가 → 옵션 → 잔여 연차로 옮겼습니다 —
+ 참여자 전원을 한 표에서 아이콘·이름과 함께 등록합니다.
+
국경일·대체공휴일(2026~2030)은 자동으로 쉬는 날입니다. 여기 공휴일은 회사 지정 휴일 추가용이고,
+ 국경일 날짜를 빨강 해제로 등록하면 그날은 근무일로 셉니다.
diff --git a/app/static/vacation.css b/app/static/vacation.css
index 334c499..b3a7182 100644
--- a/app/static/vacation.css
+++ b/app/static/vacation.css
@@ -225,6 +225,8 @@
.vac-opt-msg.is-warn { background: #fff7e6; color: #8a5a00; }
.vac-opt-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.vac-opt-card { padding: 16px; }
+/* .erp-page > .vac 는 화면 높이 flex 라 카드가 줄어 내용이 잘렸다(잔여 연차 줄·메일 글) — 옵션 화면은 줄이지 않고 페이지 스크롤 */
+.vac-options > * { flex-shrink: 0; }
.vac-opt-count { font-size: 12px; font-weight: 500; margin-left: 4px; }
.vac-opt-hint { margin: 4px 0 10px; font-size: 12px; line-height: 1.5; }
.vac-opt-now { margin: 0 0 10px; font-size: 12px; color: var(--vac-muted); }
@@ -249,3 +251,23 @@
.vac-mail-log li.is-fail b { color: #c22b10; }
.vac-mail-when { color: var(--vac-muted); margin-right: 6px; font-variant-numeric: tabular-nums; }
.vac-mail-err { display: block; margin-left: 2px; color: #c22b10; font-size: 12px; }
+
+/* 달력 — 공휴일 이름(국경일·대체공휴일·회사 휴일) 날짜 아래(2026-10-27) */
+.vac-hol-name { display: block; margin-top: 2px; font-size: 11px; font-weight: 600; line-height: 1.2; color: var(--vac-red);
+ white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
+.vac-out .vac-hol-name { color: #f0a9a9; }
+/* 공휴일이 있는 주 — 이름 줄만큼 휴가 막대를 내린다(막대 top 38px → 54px) */
+.vac-week.has-hol { min-height: 104px; }
+.vac-week.has-hol .vac-week-bars { top: 54px; }
+/* 옵션 — 잔여 연차 표(설정에서 옮김) */
+.vac-opt-balcard { margin-top: 16px; }
+.vac-bal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
+.vac-bal-years { display: inline-flex; gap: 6px; }
+.vac-bal-table td { vertical-align: middle; }
+.vac-bal-person { display: flex; align-items: center; gap: 8px; min-width: 260px; }
+.vac-bal-person .vac-opt-mail { margin-left: 4px; }
+.vac-bal-input { width: 88px; min-width: 0; text-align: right; } /* erp-input 의 min-width 240px 끔 */
+.vac-bal-memo { width: 100%; min-width: 160px; max-width: 360px; box-sizing: border-box; }
+.vac-bal-num { text-align: right; font-variant-numeric: tabular-nums; }
+.vac-bal-num.is-minus { color: var(--vac-red); font-weight: 700; }
+.vac-bal-table tr.is-inactive td { color: var(--vac-muted); }
diff --git a/docs/DATABASES.md b/docs/DATABASES.md
index 60e817a..1f74e72 100644
--- a/docs/DATABASES.md
+++ b/docs/DATABASES.md
@@ -253,7 +253,9 @@ DDL: `scripts/sql/vacation_db_init.sql` (멱등). DB·역할(`vacation_app`)·
`status` 허용값: `작성중`, `제출`, `승인`, `반려`, `취소`. 워크플로: 작성중/반려 → 제출 → 승인|반려. 삭제는 기본 soft delete(`status='취소'`). 수정은 작성중/반려 상태에서 본인만.
-휴가 일수는 서버(`store.compute_days`)에서 재계산: 주말 + `vacation_holidays(is_red)` 제외, 오전/오후 반차 0.5일, 시작/종료 반차는 각 0.5 차감. 클라이언트 계산은 미리보기(주말만 제외)용.
+휴가 일수는 서버(`store.compute_days`)에서 재계산: 주말 + 쉬는 날 제외, 오전/오후 반차 0.5일, 시작/종료 반차는 각 0.5 차감. 클라이언트 계산은 미리보기용(같은 공휴일 표).
+쉬는 날(2026-10-27) = 국경일·대체공휴일(프로젝트 `KR_HOLIDAYS`, 2026~2030) + `vacation_holidays`(is_red=true 추가·이름, is_red=false = 그 날 근무일) — `db.holiday_map`.
+사용 연차 = 승인된 연차·오전반차·오후반차만, 해를 넘는 신청은 해마다 나눠 셈. 연차는 연도별(`vacation_balances.year`)이라 12/31 소멸·이월 없음.
권한: `vacation`(접근) / `vacation_approver`(승인·반려). admin 은 항상 통과. 공휴일·연차 설정은 admin 전용.
diff --git a/tests/test_vacation_db.py b/tests/test_vacation_db.py
index 4275ad3..c0428be 100644
--- a/tests/test_vacation_db.py
+++ b/tests/test_vacation_db.py
@@ -71,5 +71,84 @@ class VacationOptionsDBTests(unittest.TestCase):
self.st.save_options(approvers=[], notifiers=[], by="admin@test.local")
+@unittest.skipUnless(ENABLED, "VACATION_TEST_DB_URL(localhost) 미설정")
+class VacationHolidayBalanceDBTests(unittest.TestCase):
+ """2026-10-27 — 쉬는 날 = 국경일·대체공휴일 + 설정 공휴일, 연차 = 승인된 연차·반차만·해마다 나눠 셈, 잔여 연차 한꺼번에 저장."""
+
+ @classmethod
+ def setUpClass(cls):
+ from app.modules.vacation.db import VacationDBStore
+
+ cls.st = VacationDBStore(DSN)
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.st.close()
+
+ def test_holiday_map_national_plus_settings(self):
+ st = self.st
+ m = st.holiday_map(date_from="2027-10-01", date_to="2027-10-31") # 설정에 2027 없음 → 국경일 표
+ self.assertEqual(m, {"2027-10-03": "개천절", "2027-10-04": "개천절 대체", "2027-10-09": "한글날", "2027-10-11": "한글날 대체"})
+ self.assertEqual(st.holiday_map(date_from="2026-07-17", date_to="2026-07-17"), {"2026-07-17": "제헌절"}) # seed 에 없던 날
+ # 설정이 덮어쓴다 — 회사 휴일 추가, 이름 바꾸기, 빨강 해제 = 근무일
+ st.upsert_holiday(holiday_date="2027-10-08", name="창립기념일", kind="company", is_red=True)
+ st.upsert_holiday(holiday_date="2027-10-09", name="한글날(회사)", kind="public", is_red=True)
+ st.upsert_holiday(holiday_date="2027-10-11", name="한글날 대체", kind="substitute", is_red=False)
+ try:
+ m = st.holiday_map(date_from="2027-10-01", date_to="2027-10-31")
+ self.assertEqual(m, {"2027-10-03": "개천절", "2027-10-04": "개천절 대체", "2027-10-08": "창립기념일",
+ "2027-10-09": "한글날(회사)"})
+ self.assertEqual(st.red_holiday_set(date_from="2027-10-01", date_to="2027-10-31"), set(m))
+ finally:
+ for h in st.list_holidays(year=2027):
+ if h["holiday_date"] in ("2027-10-08", "2027-10-09", "2027-10-11"):
+ st.delete_holiday(holiday_id=h["id"])
+
+ def _approved(self, owner, vtype, start, end, sh="full", eh="full"):
+ req = self.st.create_request(owner=owner, owner_name="테스트", status="제출",
+ payload={"vacation_type": vtype, "start_date": start, "end_date": end,
+ "start_half": sh, "end_half": eh, "reason": ""})
+ self.st.approve(request_id=req["id"], approver_email="lee@test.local")
+ return req
+
+ def test_used_days_only_annual_types_and_split_by_year(self):
+ st = self.st
+ owner = f"bal-{uuid.uuid4().hex[:6]}@test.local"
+ made = [
+ self._approved(owner, "연차", "2026-11-02", "2026-11-03"), # 2
+ self._approved(owner, "오전반차", "2026-11-04", "2026-11-04"), # 0.5
+ self._approved(owner, "병가", "2026-11-05", "2026-11-06"), # 차감 안 함
+ self._approved(owner, "경조", "2026-11-09", "2026-11-09"), # 차감 안 함
+ self._approved(owner, "연차", "2026-12-30", "2027-01-04"), # 12/30·31 = 2, 1/4 = 1 (1/1 신정·주말 뺌)
+ ]
+ st.create_request(owner=owner, owner_name="테스트", status="제출", # 제출(승인 전)은 차감 안 함
+ payload={"vacation_type": "연차", "start_date": "2026-11-10", "end_date": "2026-11-10",
+ "start_half": "full", "end_half": "full", "reason": ""})
+ try:
+ self.assertEqual(st.used_days(user_email=owner, year=2026), 4.5)
+ self.assertEqual(st.used_days(user_email=owner, year=2027), 1.0)
+ st.save_balances(year=2026, rows=[{"user_email": owner, "total_days": 15, "memo": "입사 2020"}])
+ s26 = st.balance_summary(user_email=owner, year=2026)
+ self.assertEqual((s26["total_days"], s26["used_days"], s26["remaining_days"]), (15.0, 4.5, 10.5))
+ s27 = st.balance_summary(user_email=owner, year=2027) # 다음 해로 넘어가지 않음(등록 전 = 0)
+ self.assertEqual((s27["total_days"], s27["remaining_days"]), (0.0, -1.0))
+ finally:
+ for r in st.list_for(owner):
+ st.hard_delete(request_id=r["id"], user_email=owner, is_admin=True)
+
+ def test_save_balances_validates_all_or_nothing(self):
+ st = self.st
+ a, b = f"a-{uuid.uuid4().hex[:6]}@test.local", f"b-{uuid.uuid4().hex[:6]}@test.local"
+ with self.assertRaises(ValueError):
+ st.save_balances(year=2031, rows=[{"user_email": a, "total_days": 15}, {"user_email": b, "total_days": 15.3}])
+ self.assertIsNone(st.get_balance(user_email=a, year=2031)) # 한 줄이라도 틀리면 전부 저장 안 함
+ self.assertEqual(st.save_balances(year=2031, rows=[{"user_email": a.upper(), "total_days": 15.5, "memo": " x "},
+ {"user_email": b, "total_days": 0}]), 2)
+ self.assertEqual((st.get_balance(user_email=a, year=2031)["total_days"], st.get_balance(user_email=a, year=2031)["memo"]),
+ (15.5, "x"))
+ st.save_balances(year=2031, rows=[{"user_email": a, "total_days": 20, "memo": ""}]) # 덮어쓰기
+ self.assertEqual(st.get_balance(user_email=a, year=2031)["total_days"], 20.0)
+
+
if __name__ == "__main__":
unittest.main()
diff --git a/tests/test_vacation_options_mail.py b/tests/test_vacation_options_mail.py
index bafcfda..60a9b0b 100644
--- a/tests/test_vacation_options_mail.py
+++ b/tests/test_vacation_options_mail.py
@@ -197,9 +197,12 @@ class Store:
self.req.update(status="반려", reject_reason=reason); return dict(self.req)
def list_mail_log(self, request_id):
return []
- def list_holidays(self, year=None):
- return [{"holiday_date": f"{year}-10-09", "name": "한글날", "is_red": True},
- {"holiday_date": f"{year}-05-01", "name": "근로자의날(회사)", "is_red": False}]
+ def list_balances(self, year):
+ return []
+ def used_days(self, user_email, year):
+ return 0.0
+ 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)}
st = Store()
@@ -330,5 +333,77 @@ run(body)
self.assertIn("OK", res.stdout)
+ def test_balances_in_options_settings_and_calendar_holidays(self):
+ """2026-10-27 — 잔여 연차는 옵션(관리자, 참여자 전원 아이콘·이름 미리), 설정엔 없음, 달력 공휴일 이름."""
+ res = _run('''
+lee["picture"] = "https://img.test/lee.png"
+saved = {}
+class Store2(Store):
+ def list_balances(self, year):
+ return [{"user_email": "lee@test.local", "year": year, "total_days": 15, "memo": "입사 2020"},
+ {"user_email": "gone@test.local", "year": year, "total_days": 10, "memo": ""}] if year == 2026 else \
+ [{"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 list_holidays(self, year=None):
+ return []
+ def holiday_map(self, date_from, date_to):
+ return {d: n for d, n in {"2026-10-03": "개천절", "2026-10-05": "개천절 대체", "2026-10-09": "한글날"}.items()
+ 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()
+def body(c):
+ main.app.state.vacation_store = st2
+ who["u"] = admin
+ 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]
+ for u in users: # 참여자 전원 미리(이름 + 이메일 + 줄마다 칸)
+ assert f'name="email" value="{u["email"]}"' in t, u["email"]
+ assert 'src="https://img.test/lee.png"' in t # 사진 있으면 사진, 없으면 첫 글자
+ assert '