diff --git a/app/modules/vacation/CLAUDE.md b/app/modules/vacation/CLAUDE.md index 67903b7..74e35d6 100644 --- a/app/modules/vacation/CLAUDE.md +++ b/app/modules/vacation/CLAUDE.md @@ -3,31 +3,33 @@ > 이 모듈만 고칠 때 읽는 요약. 별도 상세 문서 없음 — 코드가 기준. > 정적 파일: `app/static/vacation.css`, `app/static/vacation.js`. 템플릿: `templates/`. -- 월간 달력(구글식 bar) / 연차·반차 신청 / 승인 워크플로 / 공휴일·연차 설정. +- 월간 달력(구글식 bar) / 연차·반차 신청 / 승인 워크플로 / 옵션(승인자·통보자·잔여 연차). +- **설정 화면 없음**(2026-10-27 삭제 — [설정] 버튼·공휴일 추가/삭제 기능 포함). `GET /vacation/settings` 는 옵션으로 넘김, 공휴일 저장 주소 없음. - 권한키 `vacation`(사용)·`vacation_approver`(승인). - **신청 화면 날짜 칸 = 프로젝트와 같은 아사나식 날짜 팝업**(2026-10-27, 공용 `app/static/erp-datepop.js`·`.css` — project.js `openDatePopover`· `enhanceDateInput` 을 떼어 낸 것). 시작일·종료일 input 은 숨긴 값 저장소, 옆 날짜 버튼 둘(`ErpDatePop.enhanceRange`) — 어느 쪽을 눌러도 같은 기간 팝업(누른 칸이 먼저, 시작일 고르면 종료일 칸으로, 종료일 고르면 닫힘, 지우기 없음), 반차는 하루짜리 팝업(시작=종료). 직접 입력(10/27·1027 Enter). - 공휴일 = 휴가 설정 공휴일 중 빨강(`router._red_holidays`, 작년~내년, `#vac-holidays`) — 팝업 빨강·이름 + 예상 일수에서도 뺀다(서버 compute_days 와 같은 표). + 공휴일 = 국경일·대체공휴일(`router._red_holidays` → `db.holiday_map`, 작년~내년, `#vac-holidays`) — 팝업 빨강·이름 + 예상 일수에서도 뺀다(서버 compute_days 와 같은 표). 테스트 `tests/js/vacation_datepop.browser.test.js`(`render_vacation.py`). ## 공휴일 · 연차 (2026-10-27) -- **쉬는 날 = 대한민국 국경일·대체공휴일 + 휴가 설정 공휴일**(`db.holiday_map` 한 곳 — 달력·날짜 팝업·일수 계산 `red_holiday_set` 모두). - 국경일 표는 프로젝트 모듈 `app/modules/project/store.py` `KR_HOLIDAYS`(2026~2030, 새 연도는 그 표에 추가). 설정 공휴일이 덮어씀 — - 빨강 = 쉬는 날(이름은 설정 값, 회사 휴일 추가), **빨강 해제 = 그 국경일을 근무일로**. 예전엔 설정 표만 써서 seed 가 없는 해·제헌절은 근무일로 셌다. +- **쉬는 날 = 대한민국 국경일·대체공휴일 표만**(`db.holiday_map` 한 곳 — 달력·날짜 팝업·일수 계산 `red_holiday_set` 모두). + 표는 프로젝트 모듈 `app/modules/project/store.py` `KR_HOLIDAYS`(2026~2030, **새 연도는 그 표에 추가**). 공휴일 설정 화면은 없앴고 + `vacation_holidays` 표(예전 seed·직접 넣은 줄)는 남아 있지만 읽지 않는다. 예전엔 그 표만 써서 seed 가 없는 해·제헌절은 근무일로 셌다. 이미 저장된 신청의 일수는 그대로(새로 저장·수정할 때 다시 계산). - 메인 달력: 공휴일 이름이 **날짜 숫자 아래**(`.vac-hol-name`), 그 주는 `.vac-week.has-hol`(휴가 막대 top 38 → 54px). - **연차 차감** = 승인된 `DEDUCT_TYPES`(연차·오전반차·오후반차)만(`db.used_days`, 병가·경조·대체휴무·기타는 안 뺌 — 예전엔 모든 승인 휴가를 뺐다), 제출·작성중은 안 뺌. 해를 넘는 신청은 해마다 그 해 날짜만큼 나눔(예전엔 시작일 연도에 통째로). **연차는 그해 것만 — 12/31 소멸**, 다음 해로 넘기지 않음 (`vacation_balances` 가 연도별, 새해는 새로 등록. 달력 잔여 옆 "yyyy.12.31 소멸"). -- **잔여 연차 등록 = 옵션**(설정에서 옮김, ERP 관리자만 보기·저장) — 참여자(휴가 모듈 사용자) 전원을 아이콘·이름·이메일과 함께 미리 보여 주는 표 +- **잔여 연차 등록 = 옵션**(설정에서 옮김, 옵션 수정 권한자만 보기·저장) — 참여자(휴가 모듈 사용자) 전원을 아이콘·이름·이메일과 함께 미리 보여 주는 표 (연차 입력·사용·잔여(음수 빨강)·메모, 아직 없으면 작년 연차를 회색 참고, 예전에 등록됐지만 권한이 없는 사람도 아래에), 연도 ‹ › 이동, `POST /vacation/options/balances` 한꺼번에(`db.save_balances` 한 트랜잭션 — 0~365·0.5일 단위, 빈 칸 = 그대로). 예전 `POST /settings/balances` 는 없앴다. ## 휴가 옵션 · 휴가 메일 (2026-10-27, 마이그레이션 `vacation_db_001_options_mail.sql`) -- **옵션** `/vacation/options`(달력 위 [옵션], 누구나 보기 · **수정 = ERP 관리자**): 휴가 승인자(여러 명) · 휴가 승인 통보자. +- **옵션** `/vacation/options`(달력 위 [옵션], 누구나 보기): 휴가 승인자(여러 명) · 휴가 승인 통보자 · 잔여 연차. + **수정 = ERP 관리자(수퍼관리자 포함) + 지금 승인자(옵션 지정, 없으면 휴가 승인 권한자) + 승인 통보자**(`router._can_edit_options` 한 곳, 2026-10-27 — 예전엔 관리자만). `vacation_options` 키 `approval` = `{"approvers": [...], "notifiers": [...]}`(`db.get_options`·`save_options`, 휴가 모듈 사용자만 고를 수 있음). - **승인·반려 권한**(`router._is_approver`) = ERP 관리자 + 옵션 승인자(지정했으면 그 사람만), 승인자를 비우면 예전처럼 `vacation_approver` 권한자. 승인 대기 버튼·상세 조회·`_require_approver` 모두 이 한 곳. diff --git a/app/modules/vacation/db.py b/app/modules/vacation/db.py index b4cd6b2..190bb4c 100644 --- a/app/modules/vacation/db.py +++ b/app/modules/vacation/db.py @@ -9,7 +9,7 @@ - 연결 풀은 lazy open — 부팅 시 DB 가 잠시 끊겨도 컨테이너가 죽지 않게. 휴가 일수는 서버에서 `store.compute_days` 로 재계산하여 저장한다. -공휴일 집합은 vacation_holidays(is_red=TRUE)에서 읽어 계산에 넘긴다(holiday provider). +공휴일 집합은 대한민국 국경일·대체공휴일 표(holiday_map)를 계산에 넘긴다(holiday provider). """ from __future__ import annotations @@ -120,86 +120,23 @@ class VacationDBStore: return out # ════════════════════════════════════════════════════════════ - # 공휴일 (vacation_holidays) — holiday provider + # 공휴일 — 대한민국 국경일·대체공휴일 표(holiday provider, 설정 화면 없음) # ════════════════════════════════════════════════════════════ - def list_holidays(self, *, year: int | None = None) -> list[dict[str, Any]]: - clause = "" - params: list[Any] = [] - if year: - clause = "WHERE EXTRACT(YEAR FROM holiday_date) = %s" - params.append(year) - with self._pool.connection() as conn: - rows = conn.execute( - f"SELECT * FROM vacation_holidays {clause} ORDER BY holiday_date ASC", - params, - ).fetchall() - return [self._holiday_serialize(r) for r in rows] - def holiday_map(self, *, date_from: str, date_to: str) -> dict[str, str]: """[date_from, date_to] 범위의 쉬는 날 {ISO 날짜: 이름} — 휴가일수 계산·달력·날짜 팝업의 단일 진실 공급원. - = 대한민국 국경일·대체공휴일(프로젝트 모듈 `KR_HOLIDAYS`, 2026~2030 — 새 연도는 그 표에 추가) 위에 - 휴가 설정 공휴일(vacation_holidays)을 덮어쓴다: 빨강(is_red) 이면 쉬는 날(이름은 설정 값), 빨강 해제면 쉬지 않는 날로 뺀다 - (2026-10-27 — 예전엔 설정 표만 써서 seed 가 없는 해·제헌절은 근무일로 셌다). + = 대한민국 국경일·대체공휴일(프로젝트 모듈 `KR_HOLIDAYS`, 2026~2030 — 새 연도는 그 표에 추가). + 휴가 공휴일 설정 화면은 2026-10-27 없앴다 — vacation_holidays 표는 남아 있지만 읽지 않는다. """ from app.modules.project.store import KR_HOLIDAYS # noqa: WPS433 date_from, date_to = str(date_from)[:10], str(date_to)[:10] - out = {d: n for d, n in KR_HOLIDAYS.items() if date_from <= d <= date_to} - with self._pool.connection() as conn: - rows = conn.execute( - "SELECT holiday_date, name, is_red FROM vacation_holidays " - "WHERE holiday_date BETWEEN %s AND %s", - (date_from, date_to), - ).fetchall() - for r in rows: - d = r["holiday_date"] - iso = d.isoformat() if isinstance(d, date) else str(d) - if r["is_red"]: - out[iso] = r["name"] or out.get(iso, "") - else: - out.pop(iso, None) - return dict(sorted(out.items())) + return {d: n for d, n in sorted(KR_HOLIDAYS.items()) if date_from <= d <= date_to} def red_holiday_set(self, *, date_from: str, date_to: str) -> set[str]: """[date_from, date_to] 범위의 쉬는 날 ISO 날짜 집합(holiday_map 과 같은 기준).""" return set(self.holiday_map(date_from=date_from, date_to=date_to)) - def upsert_holiday( - self, - *, - holiday_date: str, - name: str, - kind: str = "public", - is_red: bool = True, - ) -> dict[str, Any]: - hd = (holiday_date or "").strip() - nm = (name or "").strip() - if not hd or not nm: - raise ValueError("공휴일 날짜와 이름은 필수입니다.") - with self._pool.connection() as conn: - row = conn.execute( - """ - INSERT INTO vacation_holidays (holiday_date, name, kind, is_red) - VALUES (%s, %s, %s, %s) - ON CONFLICT (holiday_date) DO UPDATE - SET name = EXCLUDED.name, - kind = EXCLUDED.kind, - is_red = EXCLUDED.is_red - RETURNING * - """, - (hd, nm, (kind or "public").strip(), bool(is_red)), - ).fetchone() - return self._holiday_serialize(row) - - def delete_holiday(self, *, holiday_id: int) -> None: - with self._pool.connection() as conn: - cur = conn.execute( - "DELETE FROM vacation_holidays WHERE id = %s", (holiday_id,) - ) - if cur.rowcount == 0: - raise KeyError(holiday_id) - # ════════════════════════════════════════════════════════════ # 잔여 연차 (vacation_balances) # ════════════════════════════════════════════════════════════ @@ -609,22 +546,6 @@ class VacationDBStore: out["days"] = cls._num(out.get("days", 0)) return out - @staticmethod - def _holiday_serialize(row: dict[str, Any] | None) -> dict[str, Any] | None: - if row is None: - return None - out = dict(row) - out["id"] = int(out["id"]) - v = out.get("holiday_date") - if isinstance(v, date): - out["holiday_date"] = v.isoformat() - out["is_red"] = bool(out.get("is_red", True)) - for k in ("created_at", "updated_at"): - v = out.get(k) - if isinstance(v, datetime): - out[k] = v.astimezone(KST).isoformat(timespec="seconds") - return out - @classmethod def _balance_serialize(cls, row: dict[str, Any] | None) -> dict[str, Any] | None: if row is None: diff --git a/app/modules/vacation/router.py b/app/modules/vacation/router.py index df74ee0..de30731 100644 --- a/app/modules/vacation/router.py +++ b/app/modules/vacation/router.py @@ -3,7 +3,7 @@ - 경로: /vacation - 권한: 로그인 + `vacation` 모듈 권한 (관리자는 항상 통과). 서버 측 검사. 승인/반려 = admin + (휴가 옵션에 승인자를 지정했으면 그 사람들, 아니면 `vacation_approver` 권한자) — 2026-10-27. -- 휴가 옵션(`/vacation/options`, 수정은 admin): 승인자·승인 통보자. 제출·승인·반려 메일은 `notify.py` +- 휴가 옵션(`/vacation/options`, 수정 = admin·승인자·통보자): 승인자·승인 통보자·잔여 연차. 공휴일 = 국경일 표(설정 화면 없음). 제출·승인·반려 메일은 `notify.py` (처리한 사람 본인 Gmail — 입출고와 같은 Gmail 연결, 없으면 회사 SMTP). - 데이터: VacationDBStore (vacation_db / PostgreSQL) 전용. VACATION_DB_URL 미설정 시 store 가 None 이며, 각 페이지는 "설정 필요" 안내를 보여준다. @@ -84,6 +84,23 @@ def _is_approver(request: Request, user: dict[str, Any]) -> bool: return has_module(user, "vacation_approver") +def _can_edit_options(request: Request, user: dict[str, Any], opts: dict[str, Any] | None = None, + users: list[dict[str, Any]] | None = None) -> bool: + """휴가 옵션(승인자·통보자·잔여 연차) 수정 — ERP 관리자(수퍼관리자 포함) + 지금 승인자(옵션 지정, 없으면 휴가 승인 권한자) + + 승인 통보자(2026-10-27, 예전엔 관리자만).""" + from app.store import is_admin # noqa: WPS433 + + from . import notify # noqa: WPS433 + + if is_admin(user): + return True + opts = opts if opts is not None else _options(request) + email = str(user.get("email") or "").strip().lower() + if email in (opts.get("notifiers") or []): + return True + return email in notify.approver_emails(opts, users if users is not None else _vacation_users()) + + def _vacation_users() -> list[dict[str, Any]]: """휴가 모듈을 쓰는 등록 사용자(옵션 후보·메일 이름) — 이름 순.""" from app.main import user_store # noqa: WPS433 @@ -204,7 +221,7 @@ def _build_calendar( range_start = weeks_dates[0][0] range_end = weeks_dates[-1][-1] - # 쉬는 날 = 국경일·대체공휴일 + 휴가 설정 공휴일(db.holiday_map) — 빨강 + 날짜 밑 이름(2026-10-27) + # 쉬는 날 = 대한민국 국경일·대체공휴일(db.holiday_map) — 빨강 + 날짜 밑 이름(2026-10-27) holiday_names = store.holiday_map( date_from=range_start.isoformat(), date_to=range_end.isoformat() ) @@ -344,7 +361,7 @@ def _form_context(request: Request, user: dict[str, Any]) -> dict[str, Any]: def _red_holidays(request: Request) -> dict[str, str]: - """날짜 팝업 공휴일(빨강·이름) — 국경일·대체공휴일 + 휴가 설정 공휴일, 작년~내년. 일수 계산과 같은 표(db.holiday_map).""" + """날짜 팝업 공휴일(빨강·이름) — 국경일·대체공휴일, 작년~내년. 일수 계산과 같은 표(db.holiday_map).""" st = _store(request) if st is None: return {} @@ -461,104 +478,20 @@ def pending_page(request: Request) -> HTMLResponse: ) -@router.get("/settings", response_class=HTMLResponse) -def settings_page(request: Request) -> HTMLResponse: - from app.main import build_erp_nav, render_template # noqa: WPS433 - from app.store import is_admin # noqa: WPS433 - - guard = _guard(request) - if not isinstance(guard, tuple): - return guard - store, user = guard - if not is_admin(user): - return render_template( - request, - "denied.html", - {"reason": "휴가 설정은 관리자만 접근할 수 있습니다.", "is_admin": False}, - status_code=403, - ) - today = today_kst() - try: - year = int(request.query_params.get("year") or today.year) - except ValueError: - year = today.year - return render_template( - request, - "vacation/settings.html", - { - "user": user, - "is_admin": True, - "is_approver": True, - "nav_items": build_erp_nav(user, active="vacation"), - "page_title": "휴가 — 설정", - "page_subtitle": "공휴일 관리 (잔여 연차는 옵션)", - "year": year, - "holidays": store.list_holidays(year=year), - }, - ) - - -@router.post("/settings/holidays") -def holiday_upsert( - request: Request, - holiday_date: str = Form(...), - name: str = Form(...), - kind: str = Form("public"), - is_red: str = Form(""), - user: dict[str, Any] = Depends(_require_user), -) -> RedirectResponse: - from app.store import is_admin # noqa: WPS433 - - if not is_admin(user): - raise HTTPException(status_code=403, detail="관리자만 가능합니다.") - store = _store(request) - if store is None: - raise HTTPException(status_code=503, detail="vacation_db 미설정") - try: - store.upsert_holiday( - holiday_date=holiday_date, - name=name, - kind=kind, - is_red=is_red in ("1", "true", "on", "True"), - ) - except ValueError as exc: - raise HTTPException(status_code=400, detail=str(exc)) - year = holiday_date[:4] - return RedirectResponse(url=f"/vacation/settings?year={year}", status_code=303) - - -@router.post("/settings/holidays/{holiday_id:int}/delete") -def holiday_delete( - request: Request, - holiday_id: int, - year: str = Form(""), - user: dict[str, Any] = Depends(_require_user), -) -> RedirectResponse: - from app.store import is_admin # noqa: WPS433 - - if not is_admin(user): - raise HTTPException(status_code=403, detail="관리자만 가능합니다.") - store = _store(request) - if store is None: - raise HTTPException(status_code=503, detail="vacation_db 미설정") - try: - store.delete_holiday(holiday_id=holiday_id) - except KeyError: - raise HTTPException(status_code=404, detail="공휴일을 찾을 수 없습니다.") - suffix = f"?year={year}" if year else "" - return RedirectResponse(url=f"/vacation/settings{suffix}", status_code=303) +@router.get("/settings") +def settings_page(request: Request) -> RedirectResponse: + """예전 설정 화면(공휴일·잔여 연차) — 2026-10-27 없앴다(공휴일 = 국경일 표, 잔여 연차 = 옵션). 예전 주소는 옵션으로.""" + return RedirectResponse(url="/vacation/options", status_code=303) @router.post("/options/balances") async def balances_save(request: Request) -> RedirectResponse: - """잔여 연차 한꺼번에(옵션, ERP 관리자) — 참여자 줄마다 email·total·memo. 연차 칸을 비운 줄은 그대로 둔다(새로 만들지 않음).""" + """잔여 연차 한꺼번에(옵션 — ERP 관리자·휴가 승인자·승인 통보자) — 참여자 줄마다 email·total·memo. 연차 칸을 비운 줄은 그대로 둔다(새로 만들지 않음).""" from urllib.parse import urlencode # noqa: WPS433 - from app.store import is_admin # noqa: WPS433 - user = _require_user(request) - if not is_admin(user): - raise HTTPException(status_code=403, detail="잔여 연차는 ERP 관리자만 등록할 수 있습니다.") + if not _can_edit_options(request, user): + raise HTTPException(status_code=403, detail="잔여 연차는 ERP 관리자·휴가 승인자·승인 통보자만 등록할 수 있습니다.") store = _store(request) if store is None: raise HTTPException(status_code=503, detail="vacation_db 미설정") @@ -705,7 +638,7 @@ def health() -> dict[str, str]: # ──────────────────────────────────────────────────────────── -# 휴가 옵션(2026-10-27) — 승인자·승인 통보자(수정 = ERP 관리자), 내 Gmail 연결(누구나 — 내가 보내는 휴가 메일) +# 휴가 옵션(2026-10-27) — 승인자·승인 통보자·잔여 연차(수정 = ERP 관리자·승인자·통보자), 내 Gmail 연결(누구나 — 내가 보내는 휴가 메일) # ──────────────────────────────────────────────────────────── def _gmail_state(request: Request, user: dict[str, Any]) -> dict[str, Any]: from app import mail as smtp # noqa: WPS433 @@ -735,6 +668,7 @@ def options_page(request: Request) -> HTMLResponse: store, user = guard opts = _options(request) users = _vacation_users() + can_edit = _can_edit_options(request, user, opts, users) today = today_kst() try: bal_year = int(request.query_params.get("year") or today.year) @@ -757,7 +691,8 @@ def options_page(request: Request) -> HTMLResponse: "gmail": _gmail_state(request, user), "msg": request.query_params.get("msg", ""), "bal_year": bal_year, - "bal_rows": _balance_rows(store, bal_year) if is_admin(user) else [], + "can_edit": can_edit, + "bal_rows": _balance_rows(store, bal_year) if can_edit else [], }, ) @@ -771,10 +706,8 @@ def options_save( ) -> RedirectResponse: from urllib.parse import urlencode # noqa: WPS433 - from app.store import is_admin # noqa: WPS433 - - if not is_admin(user): - raise HTTPException(status_code=403, detail="휴가 옵션은 ERP 관리자만 바꿀 수 있습니다.") + if not _can_edit_options(request, user): + raise HTTPException(status_code=403, detail="휴가 옵션은 ERP 관리자·휴가 승인자·승인 통보자만 바꿀 수 있습니다.") store = _store(request) if store is None: raise HTTPException(status_code=503, detail="vacation_db 미설정") diff --git a/app/modules/vacation/templates/vacation/detail.html b/app/modules/vacation/templates/vacation/detail.html index fe2fccc..7a092a1 100644 --- a/app/modules/vacation/templates/vacation/detail.html +++ b/app/modules/vacation/templates/vacation/detail.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/form.html b/app/modules/vacation/templates/vacation/form.html index 8df045c..ed4ab13 100644 --- a/app/modules/vacation/templates/vacation/form.html +++ b/app/modules/vacation/templates/vacation/form.html @@ -1,6 +1,6 @@ {% extends "erp_base.html" %} -{% block head_extra %} +{% block head_extra %} {#- 날짜 칸 = 프로젝트와 같은 아사나식 날짜 팝업(2026-10-27, erp-datepop) -#} {% endblock %} diff --git a/app/modules/vacation/templates/vacation/index.html b/app/modules/vacation/templates/vacation/index.html index 0aee012..9d93e75 100644 --- a/app/modules/vacation/templates/vacation/index.html +++ b/app/modules/vacation/templates/vacation/index.html @@ -1,6 +1,6 @@ {% extends "erp_base.html" %} -{% block head_extra %}{% endblock %} +{% block head_extra %}{% endblock %} {% block content %}
@@ -15,10 +15,7 @@ {% endif %} 엑셀 - {% if is_admin %} - 설정 - {% endif %} - {#- 옵션(2026-10-27) — 승인자·승인 통보자(수정 = 관리자) · 내 Gmail 연결(누구나) -#} + {#- 옵션(2026-10-27) — 승인자·승인 통보자·잔여 연차(수정 = 관리자·승인자·통보자) · 내 Gmail 연결(누구나). 설정 버튼은 없앰 -#} 옵션
diff --git a/app/modules/vacation/templates/vacation/options.html b/app/modules/vacation/templates/vacation/options.html index 8f0c060..c5fc190 100644 --- a/app/modules/vacation/templates/vacation/options.html +++ b/app/modules/vacation/templates/vacation/options.html @@ -1,8 +1,8 @@ {% extends "erp_base.html" %} -{#- 휴가 옵션(2026-10-27) — 승인자·승인 통보자(수정 = ERP 관리자, 나머지는 보기만) + 내 Gmail 연결(누구나). +{#- 휴가 옵션(2026-10-27) — 승인자·승인 통보자·잔여 연차(수정 = ERP 관리자·승인자·통보자, 나머지는 보기만) + 내 Gmail 연결(누구나). 메일: 제출 = 승인자·통보자, 승인·반려 = 승인자·통보자·신청자. 보내는 사람 = 처리한 사람 본인 Gmail(없으면 회사 메일). -#} -{% block head_extra %}{% endblock %} +{% block head_extra %}{% endblock %} {% block content %}
@@ -34,7 +34,7 @@ {% for c in candidates %}
  • {% endfor %}
    - {% if is_admin and options.ready %} + {% if can_edit and options.ready %} {% if options.updated_by %}마지막 저장 {{ options.updated_by }} · {{ options.updated_at[:16] | replace('T', ' ') }}{% endif %} - {% elif not is_admin %} - 승인자·통보자는 ERP 관리자만 바꿀 수 있습니다. + {% elif not can_edit %} + 옵션은 ERP 관리자·휴가 승인자·승인 통보자만 바꿀 수 있습니다. {% endif %}
    - {% if is_admin %} - {#- 잔여 연차(2026-10-27, 설정에서 옮김) — 참여자(휴가 모듈 사용자) 전원을 미리 보여 주고 줄마다 연차 입력. 관리자만 보임·저장. -#} + {% if can_edit %} + {#- 잔여 연차(2026-10-27, 설정에서 옮김) — 참여자(휴가 모듈 사용자) 전원을 미리 보여 주고 줄마다 연차 입력. 관리자·승인자·통보자만 보임·저장. -#}

    잔여 연차 {{ bal_year }}년 · 참여자 {{ bal_rows | selectattr('active') | list | length }}명

    diff --git a/app/modules/vacation/templates/vacation/pending.html b/app/modules/vacation/templates/vacation/pending.html index 669fddd..39cbaea 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 deleted file mode 100644 index afce0ae..0000000 --- a/app/modules/vacation/templates/vacation/settings.html +++ /dev/null @@ -1,79 +0,0 @@ -{% extends "erp_base.html" %} - -{% block head_extra %}{% endblock %} - -{% block content %} -
    - -
    - - - - -
    - -
    - - -
    -

    공휴일 ({{ year }})

    - -
    - - - - - -
    - -
    - - - - {% for h in holidays %} - - - - - - - - {% else %} - - {% endfor %} - -
    날짜이름종류빨강
    {{ h.holiday_date }}{{ h.name }}{{ h.kind }}{% if h.is_red %}●{% else %}○{% endif %} -
    - - -
    -
    등록된 공휴일이 없습니다.
    -
    -
    - - -
    -

    잔여 연차

    -

    잔여 연차 등록은 휴가 → 옵션 → 잔여 연차로 옮겼습니다 — - 참여자 전원을 한 표에서 아이콘·이름과 함께 등록합니다.

    -

    국경일·대체공휴일(2026~2030)은 자동으로 쉬는 날입니다. 여기 공휴일은 회사 지정 휴일 추가용이고, - 국경일 날짜를 빨강 해제로 등록하면 그날은 근무일로 셉니다.

    -
    - -
    -
    -{% endblock %} diff --git a/app/static/vacation.css b/app/static/vacation.css index b3a7182..d28646c 100644 --- a/app/static/vacation.css +++ b/app/static/vacation.css @@ -200,25 +200,9 @@ .erp-btn-sm { padding: 2px 10px; font-size: 12px; } .erp-input-sm { padding: 2px 8px; font-size: 12px; min-width: 140px; } -/* ── 설정 ── */ -.vac-settings-head { margin-bottom: 4px; } -.vac-year-form { display: flex; gap: 8px; align-items: flex-end; } -.vac-year-field { max-width: 140px; } -.vac-settings-grid { - display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; - align-items: start; -} -@media (max-width: 1100px) { .vac-settings-grid { grid-template-columns: 1fr; } } -.vac-set-card { padding: 16px; } +/* ── 카드 머리(옵션 등) — 예전 설정 화면 규칙은 2026-10-27 화면과 함께 삭제 ── */ .vac-card-head h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; } -.vac-holiday-form, .vac-balance-form { - display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); - gap: 10px; margin-bottom: 12px; align-items: end; -} -.vac-holiday-form button, .vac-balance-form button { grid-column: 1 / -1; } .vac-check { display: flex; align-items: center; gap: 6px; font-size: 13px; } -.vac-set-scroll { max-height: 420px; overflow: auto; } -.vac-set-note { font-size: 12px; margin-top: 8px; } /* ── 휴가 옵션(2026-10-27) — 승인자·승인 통보자 · 메일 ── */ .vac-opt-msg { margin: 0 0 12px; padding: 8px 12px; border-radius: 8px; background: #eef6ff; color: #1a4fa0; font-size: 13px; } diff --git a/docs/DATABASES.md b/docs/DATABASES.md index 1f74e72..b189195 100644 --- a/docs/DATABASES.md +++ b/docs/DATABASES.md @@ -248,16 +248,16 @@ DDL: `scripts/sql/vacation_db_init.sql` (멱등). DB·역할(`vacation_app`)· | 테이블 | 용도 | | --- | --- | | `vacation_requests` | 휴가 신청(헤더). 종류/기간/시작·종료 구분(full/am/pm)/일수/사유/상태/승인자/반려사유 | -| `vacation_holidays` | 공휴일(`holiday_date` UNIQUE). `is_red=true` 면 달력 빨강 + 일수 계산 제외. 관리자가 settings 에서 추가/수정/삭제 | +| `vacation_holidays` | 예전 공휴일 설정(2026 seed). **2026-10-27 부터 읽지 않음** — 공휴일 = 국경일·대체공휴일 표(`KR_HOLIDAYS`), 설정 화면 삭제 | | `vacation_balances` | 사용자별 연차(`UNIQUE(user_email, year)`). `total_days` 설정, 사용일수는 승인 휴가 합계로 자동 계산 | `status` 허용값: `작성중`, `제출`, `승인`, `반려`, `취소`. 워크플로: 작성중/반려 → 제출 → 승인|반려. 삭제는 기본 soft delete(`status='취소'`). 수정은 작성중/반려 상태에서 본인만. 휴가 일수는 서버(`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`. +쉬는 날(2026-10-27) = 국경일·대체공휴일(프로젝트 `KR_HOLIDAYS`, 2026~2030, 새 연도는 그 표에 추가) — `db.holiday_map`. `vacation_holidays` 는 읽지 않는다. 사용 연차 = 승인된 연차·오전반차·오후반차만, 해를 넘는 신청은 해마다 나눠 셈. 연차는 연도별(`vacation_balances.year`)이라 12/31 소멸·이월 없음. -권한: `vacation`(접근) / `vacation_approver`(승인·반려). admin 은 항상 통과. 공휴일·연차 설정은 admin 전용. +권한: `vacation`(접근) / `vacation_approver`(승인·반려 — 옵션에 승인자를 지정하면 그 사람들). admin 은 항상 통과. 옵션(승인자·통보자·잔여 연차) 수정 = admin + 승인자 + 통보자. **마이그레이션 001**(`scripts/sql/vacation_db_001_options_mail.sql`, 2026-10-27, 테이블만 추가·멱등): `vacation_options`(키 `approval` = 휴가 승인자·승인 통보자 JSONB — 승인자를 지정하면 그 사람들 + admin 만 승인·반려) · diff --git a/tests/test_vacation_db.py b/tests/test_vacation_db.py index c0428be..53de035 100644 --- a/tests/test_vacation_db.py +++ b/tests/test_vacation_db.py @@ -73,7 +73,7 @@ class VacationOptionsDBTests(unittest.TestCase): @unittest.skipUnless(ENABLED, "VACATION_TEST_DB_URL(localhost) 미설정") class VacationHolidayBalanceDBTests(unittest.TestCase): - """2026-10-27 — 쉬는 날 = 국경일·대체공휴일 + 설정 공휴일, 연차 = 승인된 연차·반차만·해마다 나눠 셈, 잔여 연차 한꺼번에 저장.""" + """2026-10-27 — 쉬는 날 = 국경일·대체공휴일 표, 연차 = 승인된 연차·반차만·해마다 나눠 셈, 잔여 연차 한꺼번에 저장.""" @classmethod def setUpClass(cls): @@ -85,24 +85,21 @@ class VacationHolidayBalanceDBTests(unittest.TestCase): def tearDownClass(cls): cls.st.close() - def test_holiday_map_national_plus_settings(self): + def test_holiday_map_is_national_table_only(self): + """쉬는 날 = 국경일·대체공휴일 표만(공휴일 설정 화면 삭제 — vacation_holidays 에 남은 줄은 읽지 않음).""" st = self.st - m = st.holiday_map(date_from="2027-10-01", date_to="2027-10-31") # 설정에 2027 없음 → 국경일 표 + 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-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) + self.assertEqual(st.holiday_map(date_from="2026-07-17", date_to="2026-07-17"), {"2026-07-17": "제헌절"}) # 예전 seed 에 없던 날 + with st._pool.connection() as conn: # noqa: SLF001 — 예전 설정 화면이 남긴 줄을 흉내 + conn.execute("INSERT INTO vacation_holidays (holiday_date, name, kind, is_red) VALUES ('2027-10-08', '창립기념일', 'company', TRUE), " + "('2027-10-11', '한글날 대체', 'substitute', FALSE) ON CONFLICT (holiday_date) DO NOTHING") 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.holiday_map(date_from="2027-10-01", date_to="2027-10-31"), m) # 그대로 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"]) + with st._pool.connection() as conn: # noqa: SLF001 + conn.execute("DELETE FROM vacation_holidays WHERE holiday_date IN ('2027-10-08', '2027-10-11')") def _approved(self, owner, vtype, start, end, sh="full", eh="full"): req = self.st.create_request(owner=owner, owner_name="테스트", status="제출", diff --git a/tests/test_vacation_options_mail.py b/tests/test_vacation_options_mail.py index 60a9b0b..7a3e4cb 100644 --- a/tests/test_vacation_options_mail.py +++ b/tests/test_vacation_options_mail.py @@ -239,7 +239,7 @@ def body(c): who["u"] = kim r = c.get("/vacation/options") assert r.status_code == 200, r.status_code - assert "휴가 승인자" in r.text and "휴가 승인 통보자" in r.text and "ERP 관리자만 바꿀 수 있습니다" in r.text + assert "휴가 승인자" in r.text and "휴가 승인 통보자" in r.text and "ERP 관리자·휴가 승인자·승인 통보자만 바꿀 수 있습니다" in r.text assert 'value="lee@test.local" disabled' in r.text and ">저장" not in r.text assert "Gmail 연결을 쓸 수 없는 서버" in r.text # 입출고 DB 없음 → 회사 메일 안내 assert c.post("/vacation/options", data={"approvers": ["lee@test.local"]}).status_code == 403 @@ -254,6 +254,17 @@ def body(c): assert r.status_code == 303 and r.headers["location"].startswith("/vacation/options?msg="), r.status_code assert st.opts["approvers"] == ["lee@test.local"] and st.opts["notifiers"] == ["kim@test.local"] assert 'value="lee@test.local" checked' in c.get("/vacation/options").text + # 옵션 수정 = 관리자 + 승인자 + 통보자(2026-10-27) — 통보자 kim·승인자 lee 는 저장 가능, 칩만 있는 chip 은 이제 승인자가 아니라 403 + who["u"] = kim + r = c.get("/vacation/options") + assert 'value="lee@test.local" checked' in r.text and 'value="chip@test.local" disabled' not in r.text and ">저장" in r.text + assert c.post("/vacation/options", data={"approvers": ["lee@test.local"], "notifiers": ["kim@test.local"]}).status_code == 303 + who["u"] = lee + assert c.post("/vacation/options", data={"approvers": ["lee@test.local"], "notifiers": ["kim@test.local"]}).status_code == 303 + who["u"] = chip + assert c.post("/vacation/options", data={"approvers": ["chip@test.local"]}).status_code == 403 + assert st.opts["approvers"] == ["lee@test.local"] and st.opts["notifiers"] == ["kim@test.local"] + who["u"] = admin # 승인자를 지정하면 그 사람만(+관리자) — 칩만 있는 chip 은 이제 403 st.req["status"] = "제출" who["u"] = chip @@ -384,20 +395,28 @@ def body(c): 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 - # 관리자 아님 — 표 안 보임, 저장 403 + # 승인자(옵션 미지정 → 휴가 승인 권한 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 + # 관리자·승인자·통보자 아님 — 표 안 보임, 저장 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 - # 설정 — 잔여 연차 입력 없음(옵션 안내) + # 설정 화면 삭제 — 예전 주소는 옵션으로, 공휴일·잔여 연차 저장 주소 없음 who["u"] = admin - t = c.get("/vacation/settings?year=2026").text - assert "/vacation/settings/balances" not in t and "/vacation/options?year=2026#balances" in t - assert c.post("/vacation/settings/balances", data={"user_email": "a@test.local", "year": "2026", "total_days": "1"}).status_code in (404, 405) + r = c.get("/vacation/settings?year=2026") + assert r.status_code == 303 and r.headers["location"] == "/vacation/options", r.status_code + for url, data in (("/vacation/settings/holidays", {"holiday_date": "2026-10-08", "name": "x"}), + ("/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 소멸 t = c.get("/vacation/?year=2026&month=10").text assert '개천절' in t and '개천절 대체' in t assert '한글날' in t and t.count("has-hol") == 2, t.count("has-hol") assert "2026.12.31 소멸" in t + assert 'href="/vacation/settings' not in t and ">설정" not in t and 'href="/vacation/options"' in t # 설정 버튼 없음 print("OK") run(body) ''')