diff --git a/app/modules/cupang/templates/cupang/index.html b/app/modules/cupang/templates/cupang/index.html
index 0e9a041..ae69010 100644
--- a/app/modules/cupang/templates/cupang/index.html
+++ b/app/modules/cupang/templates/cupang/index.html
@@ -2,7 +2,7 @@
{% block head_extra %}
{# 출고리스트 작성 팝업의 날짜 칸은 프로젝트 화면의 날짜 팝업을 그대로 쓴다 — project.js 는 PJ_LIB_ONLY 로 부품만 #}
-
+
@@ -249,7 +249,7 @@
{% endblock %}
{% block scripts %}
-
+
{% endblock %}
@@ -64,7 +64,7 @@
-
+
{% endif %}
{% endblock %}
diff --git a/app/modules/project/CLAUDE.md b/app/modules/project/CLAUDE.md
index d1b9340..c429e24 100644
--- a/app/modules/project/CLAUDE.md
+++ b/app/modules/project/CLAUDE.md
@@ -138,7 +138,9 @@
작업 칸(마이그레이션 026 `parent_task_id`) = 이미 있는 작업을 고르면 그 작업의 세부 작업으로 등록.
등록된 줄 = 줄 어디든 누르면 오른쪽 작업 창(편집, 저장 대기 — 2026-10-26 예전엔 제목만), 세부 업무 줄의 "↳ 상위" = 상위 업무 창, [크게 열기] = 같은 표를 넓은 창으로.
**하위 업무 등록**(2026-10-26, 6-26) — 등록된 줄 [+](`data-quick="add-sub"`) = 바로 아래 세부 업무 초안(프로젝트·`parent_task_id` = 그 업무, 제목을 치면 POST),
- 세부 업무 줄은 상위 줄 아래 들여쓰기(`displayOrder`, 서버 순서·DB 변경 없음). 예전 [2g4] "↳(줄 세부 작업)" 버튼은 표 줄끼리 묶던 다른 기능(025 parent_id).
+ 세부 업무 줄은 상위 줄 아래 들여쓰기(`displayOrder`, 서버 순서·DB 변경 없음).
+ **열 = 담당자 · 프로젝트 · 섹션 · 업무 · 제목**(2026-10-27 제목을 업무 오른쪽으로, 제목 Enter = [적용]으로 포커스). 세부 업무 줄의 섹션 =
+ 고른 업무의 섹션(서버 `parent_stage_name` — 세부의 세부면 섹션 있는 맨 위 업무까지 올라감, `_mt_select` LATERAL 재귀, 고칠 수 없음 회색). 예전 [2g4] "↳(줄 세부 작업)" 버튼은 표 줄끼리 묶던 다른 기능(025 parent_id).
- 실적 모듈 `performance_store` 매출은 머리 카드에만 읽기 전용 — 줄(쇼핑몰)별 자동 결과·이번주 실적·연결 배지·쇼핑몰 연결 메뉴는 폐지, 지난주 결과는 늘 직접 입력.
- "주요 업무" 칸 우클릭 위/아래 줄 추가 = 항목 칸은 그대로 그 항목 안에(마이그레이션 027 `label_cont`, 항목 칸 나누기).
- **글 칸 하이퍼링크**(2026-10-26, 6-26) — 목표·회의록 서식 도구(`_cell_format.html`) 🔗 = 선택 글자에 주소(pj-rich 조각 `link`, http(s)만 — 서버 `store.goal_link`,
diff --git a/app/modules/project/db.py b/app/modules/project/db.py
index c00603f..2b38df2 100644
--- a/app/modules/project/db.py
+++ b/app/modules/project/db.py
@@ -3774,7 +3774,8 @@ class ProjectStore:
out[k] = int(out[k]) if out[k] is not None else None
out["week_start"] = r["week_start"].isoformat()
out["updated_at"] = r["updated_at"].astimezone(KST).isoformat(timespec="seconds") if r.get("updated_at") else ""
- for k in ("project_name", "project_status", "stage_name", "task_title", "task_project_id", "parent_task_title"):
+ for k in ("project_name", "project_status", "stage_name", "task_title", "task_project_id", "parent_task_title",
+ "parent_stage_name"):
if k in r:
out[k] = r[k]
if "task_exists" in r:
@@ -3839,12 +3840,20 @@ class ProjectStore:
f"SELECT {self._mt_cols(conn, 'm.')}, "
" p.name AS project_name, p.status AS project_status, s.name AS stage_name, "
" t.title AS task_title, t.project_id AS task_project_id, (t.id IS NOT NULL) AS task_exists"
- + (", pt.title AS parent_task_title " if v26 else " ") +
+ + (", pt.title AS parent_task_title, pst.name AS parent_stage_name " if v26 else " ") +
"FROM goal_meeting_tasks m "
"LEFT JOIN projects p ON p.id = m.project_id "
"LEFT JOIN project_stages s ON s.id = m.stage_id "
"LEFT JOIN tasks t ON t.id = m.task_id "
- + ("LEFT JOIN tasks pt ON pt.id = m.parent_task_id " if v26 else "") +
+ # 세부 업무로 등록하는 줄(2026-10-27) — 섹션 = 고른 업무의 섹션(세부의 세부면 위로 올라가 섹션 있는 맨 위 업무)
+ + ("LEFT JOIN tasks pt ON pt.id = m.parent_task_id "
+ "LEFT JOIN LATERAL ("
+ " WITH RECURSIVE up AS ("
+ " SELECT u.id, u.parent_task_id, u.stage_id, 0 AS depth FROM tasks u WHERE u.id = m.parent_task_id "
+ " UNION ALL SELECT u2.id, u2.parent_task_id, u2.stage_id, up.depth + 1 FROM tasks u2 "
+ " JOIN up ON u2.id = up.parent_task_id WHERE up.stage_id IS NULL AND up.depth < 20) "
+ " SELECT ps.name FROM up JOIN project_stages ps ON ps.id = up.stage_id ORDER BY up.depth LIMIT 1"
+ ") pst ON TRUE " if v26 else "") +
f"WHERE {where} ORDER BY m.sort_order, m.id", params,
).fetchall()
diff --git a/app/modules/project/router.py b/app/modules/project/router.py
index 2be1a15..20b8bb7 100644
--- a/app/modules/project/router.py
+++ b/app/modules/project/router.py
@@ -4242,7 +4242,7 @@ def _quick_view(st: Any, user: dict[str, Any], rows: list[dict[str, Any]]) -> li
r = dict(r, visible=ok, registered=r.get("task_id") is not None) # 등록됨 여부는 누구에게나(작업 내용은 멤버만)
if not ok:
r.update(project_name="(볼 수 없는 프로젝트)", stage_name="", task_title="", task_id=None,
- task_project_id=None, parent_task_id=None, parent_task_title="")
+ task_project_id=None, parent_task_id=None, parent_task_title="", parent_stage_name="")
out.append(r)
return out
diff --git a/app/modules/project/templates/project/goal_meeting.html b/app/modules/project/templates/project/goal_meeting.html
index afa5d6d..9c729aa 100644
--- a/app/modules/project/templates/project/goal_meeting.html
+++ b/app/modules/project/templates/project/goal_meeting.html
@@ -1,7 +1,7 @@
{% extends "project/_meeting_content_base.html" if meeting_embedded else "erp_base.html" %}
{% block head_extra %}
-
+
{% endblock %}
@@ -114,7 +114,7 @@
제목 아래 두 칸은 표를 스크롤해도 그대로 보입니다. 왼쪽 칸 머리 한 줄에 N월 계획과 숫자 4개(월 목표 · 누적 목표 · 누적 실적 · 목표 대비, 목표 표 매출 단위 예: 백만원 — 숫자에 마우스를 올리면 원 단위 금액과 뜻)와 결정사항 제목이 나오고, 그 아래 칸 전체가 결정사항(진행상황 수시 공유 및 완료 되어야 할 것) 입력란입니다. 오른쪽은 업무 등록 표입니다.
업무 등록(제목에 N주차 업무 등록) — 주차마다 한 표를 모두가 같이 봅니다(다른 사람이 적거나 등록한 줄도 보임, 30초마다·창을 다시 볼 때 새로 읽음). 내가 멤버가 아닌 프로젝트를 고른 남의 줄은 프로젝트 이름을 가립니다. 회의 완료면 읽기 전용입니다.
- 업무 칸 — 비워 두면 고른 섹션에 새 업무로, 업무를 고르면 그 업무의 세부 업무로 등록합니다(목록 = 그 섹션의 진행 중인 메인 업무, 고르면 섹션 칸은 —). 등록된 줄(업무·세부 업무)을 누르면 줄 어디든 오른쪽에 업무 창이 열려 바로 편집할 수 있습니다(연 줄은 옅은 보라색, 다른 줄을 누르면 창이 그 업무로 바뀜, 업무 창에서 저장이 끝나야 닫히거나 다른 업무로 바뀝니다). 세부 업무 줄의 ↳ 상위 업무를 누르면 상위 업무 창이 열립니다.
+ 칸 순서는 담당자 · 프로젝트 · 섹션 · 업무 · 제목입니다(제목에서 Enter = 적용 버튼으로).
+ 업무 칸 — 비워 두면 고른 섹션에 새 업무로, 업무를 고르면 그 업무의 세부 업무로 등록합니다(목록 = 그 섹션의 진행 중인 메인 업무, 고르면 섹션 칸에 그 업무의 섹션이 회색으로 — 상위 업무를 따름). 등록된 줄(업무·세부 업무)을 누르면 줄 어디든 오른쪽에 업무 창이 열려 바로 편집할 수 있습니다(연 줄은 옅은 보라색, 다른 줄을 누르면 창이 그 업무로 바뀜, 업무 창에서 저장이 끝나야 닫히거나 다른 업무로 바뀝니다). 세부 업무 줄의 ↳ 상위 업무를 누르면 상위 업무 창이 열립니다.
하위 업무 등록 — 등록된 줄 오른쪽 add(하위 업무 추가)을 누르면 바로 아래에 그 업무의 세부 업무 줄이 생깁니다(프로젝트·↳ 상위 업무가 채워져 있음). 제목·담당자를 적고 적용하면 세부 업무로 등록되고, 세부 업무 줄에서 다시 add를 누르면 그 아래 단계도 만들 수 있습니다. 세부 업무 줄은 상위 업무 줄 아래에 들여 써서 보입니다.
크게 열기 — 같은 표를 넓은 창으로 열어 씁니다(줄·저장은 그대로, Esc·×로 닫기). 제목 칸에 업무 이름을 씁니다. 담당자·프로젝트·섹션 칸을 누르면 고를 수 있는 목록이 나옵니다(완료 프로젝트·완료 섹션은 목록에 나오지 않습니다). 목록 맨 위 새 프로젝트(Pro user 이상)·새 섹션(그 프로젝트 멤버)을 누르면 이름만 적어 바로 만들고 그 칸에 골라집니다. 새 프로젝트는 섹션 없이 시작하니 섹션 칸에서 새 섹션을 만들어 고르세요.
프로젝트는 내가 멤버인 프로젝트만 나오고, 고르면 첫 섹션이 자동으로 들어갑니다. 담당자는 그 프로젝트의 멤버·소유자 중에서 고릅니다(프로젝트를 먼저 고르면 정확합니다).
diff --git a/app/modules/project/templates/project/inbox.html b/app/modules/project/templates/project/inbox.html
index c63450a..c182397 100644
--- a/app/modules/project/templates/project/inbox.html
+++ b/app/modules/project/templates/project/inbox.html
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
-
+
{% endblock %}
@@ -106,5 +106,5 @@
{% include "project/_side_modals.html" %}
{% include "project/_member_tasks_modal.html" %}
-
+
{% endblock %}
diff --git a/app/modules/project/templates/project/mytasks.html b/app/modules/project/templates/project/mytasks.html
index a9bcc10..e5f428d 100644
--- a/app/modules/project/templates/project/mytasks.html
+++ b/app/modules/project/templates/project/mytasks.html
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
-
+
{% endblock %}
@@ -100,5 +100,5 @@
"today": {{ today | tojson }}
}
-
+
{% endblock %}
diff --git a/app/modules/project/templates/project/notifier.html b/app/modules/project/templates/project/notifier.html
index 292ddde..02655f0 100644
--- a/app/modules/project/templates/project/notifier.html
+++ b/app/modules/project/templates/project/notifier.html
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
-
+
{% endblock %}
@@ -108,5 +108,5 @@
});
})();
-
+
{% endblock %}
diff --git a/app/modules/project/templates/project/project.html b/app/modules/project/templates/project/project.html
index 5a23a93..f36f8f9 100644
--- a/app/modules/project/templates/project/project.html
+++ b/app/modules/project/templates/project/project.html
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
-
+
@@ -476,5 +476,5 @@
-
+
{% endblock %}
diff --git a/app/modules/project/templates/project/trash.html b/app/modules/project/templates/project/trash.html
index a99eb3b..9eace18 100644
--- a/app/modules/project/templates/project/trash.html
+++ b/app/modules/project/templates/project/trash.html
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
-
+
{% endblock %}
@@ -70,5 +70,5 @@
{% include "project/_side_modals.html" %}
{% include "project/_member_tasks_modal.html" %}
-
+
{% endblock %}
diff --git a/app/modules/vacation/CLAUDE.md b/app/modules/vacation/CLAUDE.md
index 74e35d6..db8184f 100644
--- a/app/modules/vacation/CLAUDE.md
+++ b/app/modules/vacation/CLAUDE.md
@@ -26,6 +26,18 @@
(연차 입력·사용·잔여(음수 빨강)·메모, 아직 없으면 작년 연차를 회색 참고, 예전에 등록됐지만 권한이 없는 사람도 아래에), 연도 ‹ › 이동,
`POST /vacation/options/balances` 한꺼번에(`db.save_balances` 한 트랜잭션 — 0~365·0.5일 단위, 빈 칸 = 그대로). 예전 `POST /settings/balances` 는 없앴다.
+## 입사일 · 근로기준법 연차 · 시스템 전 사용 (2026-10-27, 마이그레이션 `vacation_db_002_hire_prior.sql`)
+
+- 옵션 잔여 연차 표 **이름 옆 입사일** = 날짜 버튼(`ErpDatePop.enhance`, « » 1년씩·직접 입력 2020-03-02 Enter, 지우기) → `vacation_employees`(사람마다 하나).
+- **법정 연차** = `store.legal_annual_leave(입사일, 연도)` — 근로기준법 제60조를 **입사일 기준으로 생기는 날을 그해(1/1~12/31)에 모음**
+ (12/31 소멸 규칙과 맞춤): 입사 1년 미만 = 입사일 + 1~11개월마다 1일, 입사일이 돌아올 때마다(근속 n년) `min(25, 15 + (n−1)//2)`.
+ 출근율(개근·80%)은 따지지 않음(모두 채운 것으로). 화면(vacation.js)도 같은 계산으로 입사일을 고르는 즉시 근속·법정·잔여를 다시 보여 줌.
+- 연차 칸 = 직접 입력(값이 있으면 그 값), **비우면 법정 연차**(`vacation_balances.total_days` NULL). 입사일도 연차도 없으면 0.
+- **시스템 전 사용**(`prior_used`) — 이 시스템을 쓰기 전에 그해 이미 쓴 연차, **도입 해(`store.SYSTEM_START_YEAR` = 2026)만** 표에 칸.
+- 잔여 = 총(직접 또는 법정) − 시스템 전 사용 − 승인된 연차·반차 — `db.balance_summary` 한 곳(달력 잔여·옵션 표 모두).
+- 저장 `POST /vacation/options/balances` 줄마다 email·hire·total·prior·memo(칸 수가 다르면 400, 한 줄이라도 틀리면 전부 안 함 — `db.save_balances`).
+ 002 전이면 입사일·시스템 전 사용은 무시(입사일 칸은 숨김 칸, 안내 문구), 연차 직접 입력만 예전처럼.
+
## 휴가 옵션 · 휴가 메일 (2026-10-27, 마이그레이션 `vacation_db_001_options_mail.sql`)
- **옵션** `/vacation/options`(달력 위 [옵션], 누구나 보기): 휴가 승인자(여러 명) · 휴가 승인 통보자 · 잔여 연차.
diff --git a/app/modules/vacation/db.py b/app/modules/vacation/db.py
index 190bb4c..7425037 100644
--- a/app/modules/vacation/db.py
+++ b/app/modules/vacation/db.py
@@ -24,7 +24,9 @@ from psycopg_pool import ConnectionPool
from app.timezone import KST
-from .store import DEDUCT_TYPES, EDITABLE_STATUSES, STATUSES, VACATION_TYPES, compute_days, normalize_half
+from .store import (
+ DEDUCT_TYPES, EDITABLE_STATUSES, STATUSES, VACATION_TYPES, compute_days, legal_annual_leave, normalize_half,
+)
def _email_list(value: Any) -> list[str]:
@@ -156,26 +158,6 @@ class VacationDBStore:
).fetchall()
return [self._balance_serialize(r) for r in rows]
- def upsert_balance(
- self, *, user_email: str, year: int, total_days: float, memo: str = ""
- ) -> dict[str, Any]:
- email = (user_email or "").lower().strip()
- if not email or "@" not in email:
- raise ValueError("올바른 이메일이 필요합니다.")
- with self._pool.connection() as conn:
- row = conn.execute(
- """
- INSERT INTO vacation_balances (user_email, year, total_days, memo)
- VALUES (%s, %s, %s, %s)
- ON CONFLICT (user_email, year) DO UPDATE
- SET total_days = EXCLUDED.total_days,
- memo = EXCLUDED.memo
- RETURNING *
- """,
- (email, year, total_days, (memo or "").strip()),
- ).fetchone()
- return self._balance_serialize(row)
-
def used_days(self, *, user_email: str, year: int) -> float:
"""그해 사용 연차 = 승인된 연차·반차(DEDUCT_TYPES)의 그해 날짜분 합계(2026-10-27).
@@ -208,35 +190,103 @@ class VacationDBStore:
)
return round(total, 2)
- def save_balances(self, *, year: int, rows: list[dict[str, Any]]) -> int:
- """잔여 연차 한꺼번에 저장 [{user_email, total_days, memo}] — 한 트랜잭션, 저장한 줄 수."""
- n = 0
+ def save_balances(self, *, year: int, rows: list[dict[str, Any]], by: str = "") -> int:
+ """잔여 연차 한꺼번에 저장 — 한 트랜잭션, 한 줄이라도 틀리면 전부 안 함. 저장한 줄 수.
+
+ row = {user_email, total_days(None = 입사일 기준 법정 연차), prior_used(시스템 전 사용, None = 0), memo,
+ hire_date("YYYY-MM-DD" | "" = 지움 | 키 없음 = 그대로)}. 002 전이면 입사일·시스템 전 사용은 무시하고
+ total_days 가 없는 줄은 건너뛴다(예전처럼).
+ """
+ v002 = self.hire_ready()
+ clean = []
+ for r in rows:
+ email = (r.get("user_email") or "").lower().strip()
+ if "@" not in email:
+ raise ValueError(f"올바른 이메일이 아닙니다: {email}")
+ total, prior = r.get("total_days"), r.get("prior_used")
+ for label, v in (("연차", total), ("시스템 전 사용", prior)):
+ if v is not None and (float(v) < 0 or float(v) > 365 or round(float(v) * 2) != float(v) * 2):
+ raise ValueError(f"{label} 일수는 0~365, 0.5일 단위입니다: {email}")
+ hire: Any = ...
+ if "hire_date" in r:
+ hv = str(r.get("hire_date") or "").strip()
+ hire = None
+ if hv:
+ try:
+ hire = date.fromisoformat(hv)
+ except ValueError:
+ raise ValueError(f"입사일이 올바르지 않습니다: {email} {hv}") from None
+ if not date(1950, 1, 1) <= hire <= date(year + 1, 12, 31):
+ raise ValueError(f"입사일이 올바르지 않습니다: {email} {hv}")
+ if not v002 and total is None:
+ continue
+ clean.append((email, None if total is None else float(total), float(prior or 0),
+ (r.get("memo") or "").strip()[:200], hire))
+ who = (by or "").lower().strip()
with self._pool.connection() as conn:
with conn.transaction():
- for r in rows:
- email = (r.get("user_email") or "").lower().strip()
- if "@" not in email:
- raise ValueError(f"올바른 이메일이 아닙니다: {email}")
- total = float(r["total_days"])
- if total < 0 or total > 365 or round(total * 2) != total * 2:
- raise ValueError(f"연차 일수는 0~365, 0.5일 단위입니다: {email}")
+ for email, total, prior, memo, hire in clean:
+ if not v002:
+ conn.execute(
+ "INSERT INTO vacation_balances (user_email, year, total_days, memo) VALUES (%s, %s, %s, %s) "
+ "ON CONFLICT (user_email, year) DO UPDATE SET total_days = EXCLUDED.total_days, memo = EXCLUDED.memo",
+ (email, year, total, memo),
+ )
+ continue
conn.execute(
- "INSERT INTO vacation_balances (user_email, year, total_days, memo) VALUES (%s, %s, %s, %s) "
- "ON CONFLICT (user_email, year) DO UPDATE SET total_days = EXCLUDED.total_days, memo = EXCLUDED.memo",
- (email, year, total, (r.get("memo") or "").strip()[:200]),
+ "INSERT INTO vacation_balances (user_email, year, total_days, prior_used, memo) VALUES (%s, %s, %s, %s, %s) "
+ "ON CONFLICT (user_email, year) DO UPDATE SET total_days = EXCLUDED.total_days, "
+ "prior_used = EXCLUDED.prior_used, memo = EXCLUDED.memo",
+ (email, year, total, prior, memo),
)
- n += 1
- return n
+ if hire is not ...:
+ conn.execute(
+ "INSERT INTO vacation_employees (user_email, hire_date, updated_by, updated_at) VALUES (%s, %s, %s, now()) "
+ "ON CONFLICT (user_email) DO UPDATE SET hire_date = EXCLUDED.hire_date, "
+ "updated_by = EXCLUDED.updated_by, updated_at = now()",
+ (email, hire, who),
+ )
+ return len(clean)
- def balance_summary(self, *, user_email: str, year: int) -> dict[str, Any]:
- bal = self.get_balance(user_email=user_email, year=year)
- total = float(bal["total_days"]) if bal else 0.0
- used = self.used_days(user_email=user_email, year=year)
+ # ── 입사일(마이그레이션 002 vacation_employees) — 없으면 입사일 없음 ──
+ def hire_ready(self) -> bool:
+ with self._pool.connection() as conn:
+ row = conn.execute("SELECT to_regclass('public.vacation_employees') AS r").fetchone()
+ return bool(row and row["r"])
+
+ def hire_dates(self) -> dict[str, str]:
+ """{이메일: 입사일 ISO}."""
+ if not self.hire_ready():
+ return {}
+ with self._pool.connection() as conn:
+ rows = conn.execute("SELECT user_email, hire_date FROM vacation_employees WHERE hire_date IS NOT NULL").fetchall()
+ return {r["user_email"]: r["hire_date"].isoformat() for r in rows}
+
+ def balance_summary(self, *, user_email: str, year: int, hire_date: Any = ...) -> dict[str, Any]:
+ """그해 연차(2026-10-27) — 총 = 직접 입력(있으면) 아니면 입사일 기준 법정 연차(근로기준법 제60조, store.legal_annual_leave),
+ 사용 = 시스템 전 사용(prior_used, 002) + 승인된 연차·반차(used_days), 잔여 = 총 − 사용.
+ hire_date 를 넘기면(목록에서 한 번에 읽은 값, None = 없음) 다시 읽지 않는다."""
+ email = user_email.lower().strip()
+ bal = self.get_balance(user_email=email, year=year)
+ if hire_date is ...:
+ hire_date = self.hire_dates().get(email)
+ legal = legal_annual_leave(date.fromisoformat(hire_date) if hire_date else None, year)
+ manual = bal["total_days"] if bal and bal.get("total_days") is not None else None
+ total = manual if manual is not None else (legal["days"] if hire_date else 0.0)
+ prior = float(bal.get("prior_used") or 0) if bal else 0.0
+ erp_used = self.used_days(user_email=email, year=year)
return {
"year": year,
- "total_days": total,
- "used_days": used,
- "remaining_days": round(total - used, 2),
+ "total_days": round(float(total), 2),
+ "manual_total": manual,
+ "legal_days": legal["days"] if hire_date else None,
+ "legal_items": legal["items"],
+ "service_years": legal["service_years"],
+ "hire_date": hire_date or "",
+ "prior_used": prior,
+ "erp_used": erp_used,
+ "used_days": round(prior + erp_used, 2),
+ "remaining_days": round(float(total) - prior - erp_used, 2),
"memo": bal["memo"] if bal else "",
}
@@ -553,8 +603,9 @@ class VacationDBStore:
out = dict(row)
out["id"] = int(out["id"])
out["year"] = int(out["year"])
- out["total_days"] = cls._num(out.get("total_days", 0))
+ out["total_days"] = None if out.get("total_days") is None else cls._num(out["total_days"]) # 002: NULL = 법정 연차
out["used_days"] = cls._num(out.get("used_days", 0))
+ out["prior_used"] = cls._num(out.get("prior_used", 0))
for k in ("created_at", "updated_at"):
v = out.get(k)
if isinstance(v, datetime):
diff --git a/app/modules/vacation/router.py b/app/modules/vacation/router.py
index de30731..f283870 100644
--- a/app/modules/vacation/router.py
+++ b/app/modules/vacation/router.py
@@ -26,7 +26,7 @@ from fastapi.responses import (
from app.timezone import now_kst, today_kst
-from .store import HALF_LABELS, HALVES, VACATION_TYPES
+from .store import HALF_LABELS, HALVES, SYSTEM_START_YEAR, VACATION_TYPES
router = APIRouter(prefix="/vacation", tags=["vacation"])
@@ -486,7 +486,8 @@ def settings_page(request: Request) -> RedirectResponse:
@router.post("/options/balances")
async def balances_save(request: Request) -> RedirectResponse:
- """잔여 연차 한꺼번에(옵션 — ERP 관리자·휴가 승인자·승인 통보자) — 참여자 줄마다 email·total·memo. 연차 칸을 비운 줄은 그대로 둔다(새로 만들지 않음)."""
+ """잔여 연차 한꺼번에(옵션 — ERP 관리자·휴가 승인자·승인 통보자) — 참여자 줄마다 email·hire·total·prior·memo(2026-10-27).
+ hire = 입사일(빈 칸 = 지움), total = 연차 직접 입력(빈 칸 = 입사일 기준 법정 연차), prior = 시스템 전에 그해 쓴 연차(빈 칸 = 0)."""
from urllib.parse import urlencode # noqa: WPS433
user = _require_user(request)
@@ -502,22 +503,27 @@ async def balances_save(request: Request) -> RedirectResponse:
raise HTTPException(status_code=400, detail="연도가 올바르지 않습니다.")
if not 2000 <= year <= 2100:
raise HTTPException(status_code=400, detail="연도가 올바르지 않습니다.")
- emails, totals, memos = form.getlist("email"), form.getlist("total"), form.getlist("memo")
- if not (len(emails) == len(totals) == len(memos)):
+ emails, memos = form.getlist("email"), form.getlist("memo")
+ totals, priors, hires = form.getlist("total"), form.getlist("prior"), form.getlist("hire")
+ if not (len(emails) == len(totals) == len(memos) == len(priors) == len(hires)):
raise HTTPException(status_code=400, detail="잔여 연차 칸이 맞지 않습니다.")
- rows = []
- for email, total, memo in zip(emails, totals, memos):
- total = str(total).strip()
- if not total:
- continue
+
+ def num(v: Any, label: str, email: str) -> float | None:
+ v = str(v).strip()
+ if not v:
+ return None
try:
- rows.append({"user_email": email, "total_days": float(total), "memo": memo})
+ return float(v)
except ValueError:
- raise HTTPException(status_code=400, detail=f"연차 일수가 숫자가 아닙니다: {email}")
+ raise HTTPException(status_code=400, detail=f"{label}이(가) 숫자가 아닙니다: {email}")
+
+ rows = [{"user_email": email, "total_days": num(total, "연차 일수", email), "prior_used": num(prior, "시스템 전 사용", email),
+ "memo": memo, "hire_date": str(hire).strip()}
+ for email, total, prior, memo, hire in zip(emails, totals, priors, memos, hires)]
from starlette.concurrency import run_in_threadpool # noqa: WPS433 — 폼 배열을 읽으려 async, DB 는 동기라 스레드에서
try:
- n = await run_in_threadpool(store.save_balances, year=year, rows=rows)
+ n = await run_in_threadpool(store.save_balances, year=year, rows=rows, by=user["email"])
except ValueError as exc:
raise HTTPException(status_code=400, detail=str(exc))
return RedirectResponse(url="/vacation/options?" + urlencode({"year": year, "msg": f"{year}년 잔여 연차 {n}명을 저장했습니다."})
@@ -526,22 +532,25 @@ async def balances_save(request: Request) -> RedirectResponse:
def _balance_rows(store: Any, year: int) -> list[dict[str, Any]]:
"""옵션 잔여 연차 표 — 참여자(휴가 모듈 사용자) 전원 + 예전에 등록됐지만 지금 권한이 없는 사람.
- 줄마다 그해 연차·사용(승인된 연차·반차)·잔여·메모, 아직 없으면 작년 연차를 참고로."""
+ 줄마다 입사일·근속·법정 연차(근로기준법, 입사일 기준)·연차(직접 입력)·시스템 전 사용·사용·잔여·메모(db.balance_summary 한 곳)."""
users = _vacation_users()
this_year = {b["user_email"]: b for b in store.list_balances(year=year)}
last_year = {b["user_email"]: b for b in store.list_balances(year=year - 1)}
+ hires = store.hire_dates()
rows = []
people = [(u["email"].lower(), u.get("name") or u["email"].split("@")[0], u.get("picture") or "", True) for u in users]
known = {p[0] for p in people}
people += [(e, e.split("@")[0], "", False) for e in sorted(this_year) if e not in known]
for email, name, picture, active in people:
- bal = this_year.get(email)
- used = store.used_days(user_email=email, year=year)
- total = float(bal["total_days"]) if bal else None
+ s = store.balance_summary(user_email=email, year=year, hire_date=hires.get(email))
+ last = last_year.get(email)
rows.append({"email": email, "name": name, "picture": picture, "active": active,
- "total": total, "used": used, "remaining": round(total - used, 2) if total is not None else None,
- "memo": (bal or {}).get("memo") or "",
- "last_total": float(last_year[email]["total_days"]) if email in last_year else None})
+ "hire_date": s["hire_date"], "service_years": s["service_years"],
+ "legal": s["legal_days"], "legal_tip": ", ".join(f"{i['date'][5:]} {i['label']} {i['days']:g}일" for i in s["legal_items"]),
+ "total": s["manual_total"], "effective_total": s["total_days"], "prior": s["prior_used"],
+ "used": s["erp_used"], "remaining": s["remaining_days"] if (s["manual_total"] is not None or s["hire_date"]) else None,
+ "memo": s["memo"],
+ "last_total": last["total_days"] if last and last.get("total_days") is not None else None})
return rows
@@ -691,6 +700,8 @@ def options_page(request: Request) -> HTMLResponse:
"gmail": _gmail_state(request, user),
"msg": request.query_params.get("msg", ""),
"bal_year": bal_year,
+ "bal_prior_year": bal_year == SYSTEM_START_YEAR, # 시스템 도입 해만 "시스템 전 사용" 칸
+ "hire_ready": store.hire_ready() if can_edit else False,
"can_edit": can_edit,
"bal_rows": _balance_rows(store, bal_year) if can_edit else [],
},
diff --git a/app/modules/vacation/store.py b/app/modules/vacation/store.py
index 6ca1ff4..cc39c2c 100644
--- a/app/modules/vacation/store.py
+++ b/app/modules/vacation/store.py
@@ -37,6 +37,49 @@ EDITABLE_STATUSES: tuple[str, ...] = ("작성중", "반려")
# 연차는 그해(1/1~12/31) 것만 쓰고 다음 해로 넘기지 않는다(12/31 소멸 — 해마다 잔여 연차를 새로 등록).
DEDUCT_TYPES: tuple[str, ...] = ("연차", "오전반차", "오후반차")
+# 이 시스템을 쓰기 시작한 해 — 그해만 잔여 연차 표에 "시스템 전 사용"(도입 전에 이미 쓴 연차) 칸(2026-10-27)
+SYSTEM_START_YEAR = 2026
+
+
+def add_months(d: date, n: int) -> date:
+ """d 에서 n 달 뒤 같은 날(없는 날이면 그 달 말일 — 1/31 + 1달 = 2/28)."""
+ m = d.month - 1 + n
+ y, m = d.year + m // 12, m % 12 + 1
+ last = (date(y + (m == 12), m % 12 + 1, 1) - timedelta(days=1)).day
+ return date(y, m, min(d.day, last))
+
+
+def legal_annual_leave(hire: date | None, year: int) -> dict:
+ """근로기준법 제60조 연차 — 입사일 기준으로 생기는 날을 그해(1/1~12/31)에 모은다(연차는 12/31 소멸 규칙과 맞춤).
+
+ · 입사 1년 미만: 1개월 개근마다 1일(입사일 + 1~11개월 되는 날, 최대 11일) — 제60조 ②
+ · 입사일이 돌아올 때마다(근속 n년): 15일 + 최초 1년을 넘는 근속 2년마다 1일, 최대 25일 = min(25, 15 + (n−1)//2) — 제60조 ①④
+ 출근율(1개월 개근·1년 80%)은 따지지 않는다(모두 채운 것으로 본다). 입사일이 없거나 그해 뒤면 0일.
+ 반환 {"days", "items": [{"date", "days", "label"}], "service_years"(12/31 기준 만 근속 연수)}.
+ """
+ out: dict = {"days": 0.0, "items": [], "service_years": 0}
+ if hire is None:
+ return out
+ y0, y1 = date(year, 1, 1), date(year, 12, 31)
+ items = []
+ for m in range(1, 12):
+ d = add_months(hire, m)
+ if y0 <= d <= y1:
+ items.append({"date": d.isoformat(), "days": 1.0, "label": f"입사 {m}개월(월 1일)"})
+ n = 1
+ while True:
+ d = add_months(hire, 12 * n)
+ if d > y1:
+ break
+ if d >= y0:
+ items.append({"date": d.isoformat(), "days": float(min(25, 15 + (n - 1) // 2)), "label": f"근속 {n}년"})
+ n += 1
+ out["items"] = items
+ out["days"] = float(sum(i["days"] for i in items))
+ out["service_years"] = max(0, n - 1)
+ return out
+
+
# 반차 성격의 휴가 종류 (단일 일자 0.5일 강제)
_HALF_DAY_TYPES: dict[str, str] = {"오전반차": "am", "오후반차": "pm"}
diff --git a/app/modules/vacation/templates/vacation/detail.html b/app/modules/vacation/templates/vacation/detail.html
index 7a092a1..d34b3f4 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 ed4ab13..565e3d4 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 %}
@@ -72,5 +72,5 @@
{% endblock %}
{% block scripts %}
-
-{% endblock %}
+
+{% endblock %}
diff --git a/app/modules/vacation/templates/vacation/index.html b/app/modules/vacation/templates/vacation/index.html
index 9d93e75..dd6bf25 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 %}
diff --git a/app/modules/vacation/templates/vacation/options.html b/app/modules/vacation/templates/vacation/options.html
index c5fc190..5b08844 100644
--- a/app/modules/vacation/templates/vacation/options.html
+++ b/app/modules/vacation/templates/vacation/options.html
@@ -2,7 +2,9 @@
{#- 휴가 옵션(2026-10-27) — 승인자·승인 통보자·잔여 연차(수정 = ERP 관리자·승인자·통보자, 나머지는 보기만) + 내 Gmail 연결(누구나).
메일: 제출 = 승인자·통보자, 승인·반려 = 승인자·통보자·신청자. 보내는 사람 = 처리한 사람 본인 Gmail(없으면 회사 메일). -#}
-{% block head_extra %}{% endblock %}
+{% block head_extra %}
+
+{% endblock %}
{% block content %}
@@ -67,33 +69,51 @@
{{ bal_year + 1 }} ›
-
연차는 휴가가 승인되면 차감됩니다(연차·오전반차·오후반차 — 병가·경조·대체휴무·기타는 차감 안 함).
- {{ bal_year }}년 연차는 {{ bal_year }}.12.31 에 소멸하고 다음 해로 넘어가지 않습니다 — 해마다 새로 등록하세요(빈 칸 = 그대로, 회색 숫자 = 작년 연차).
+
이름 옆 입사일을 고르면 근로기준법 제60조대로 {{ bal_year }}년에 생기는 연차를 계산합니다
+ (입사 1년 미만 = 1개월마다 1일·최대 11일, 입사일이 돌아올 때마다 15일 + 최초 1년을 넘는 근속 2년마다 1일·최대 25일, 출근율은 모두 채운 것으로 봄).
+ 연차 칸을 비우면 법정 연차를 쓰고, 숫자를 넣으면 그 값을 씁니다. 휴가가 승인되면 차감됩니다(연차·오전반차·오후반차 — 병가·경조·대체휴무·기타는 차감 안 함).
+ {{ bal_year }}년 연차는 {{ bal_year }}.12.31 에 소멸하고 다음 해로 넘어가지 않습니다.
+ {% if bal_prior_year %}시스템 전 사용 = 이 시스템을 쓰기 전에 {{ bal_year }}년에 이미 쓴 연차(잔여에서 뺍니다).{% endif %}
+ {% if not hire_ready %}
입사일·시스템 전 사용 칸은 scripts/sql/vacation_db_002_hire_prior.sql 적용 뒤 저장됩니다(지금은 연차 직접 입력만).
{% endif %}
-
-
참여자
연차
사용
잔여
메모
+
+
참여자 · 입사일
근속
법정 연차
연차
+ {% if bal_prior_year %}
시스템 전 사용
{% endif %}
+
사용
잔여
메모
{% for b in bal_rows %}
-
+
{% if b.picture %}
{% else %}{{ b.name[:1] }}{% endif %}
- {{ b.name }}
- {{ b.email }}{% if not b.active %} · 휴가 권한 없음{% endif %}
+
+ {{ b.name }}
+ {{ b.email }}{% if not b.active %} · 휴가 권한 없음{% endif %}
+
+ {#- 입사일 — 이름 옆 날짜 버튼(erp-datepop, 숨긴 input 이 값) -#}
+ {#- 002 전이면 숨김 칸만(서버가 무시) — disabled 는 폼에서 빠져 칸 수가 어긋나므로 쓰지 않는다 -#}
+
+
{% if b.hire_date %}{{ b.service_years }}년{% else %}—{% endif %}
+
{{ '%g' % b.legal if b.legal is not none else '—' }}
+ placeholder="{{ ('%g' % b.legal) if b.legal is not none else (('%g' % b.last_total) if b.last_total is not none else '') }}"
+ aria-label="{{ b.name }} 연차(비우면 법정 연차)" />
+ {% if bal_prior_year %}
+
+ {% else %}{% endif %}
{{ '%g' % b.used }}
-
{{ '%g' % b.remaining if b.remaining is not none else '—' }}
-
+
{{ '%g' % b.remaining if b.remaining is not none else '—' }}
+
{% else %}
-
휴가 모듈 권한이 있는 사용자가 없습니다.
+
휴가 모듈 권한이 있는 사용자가 없습니다.
{% endfor %}
@@ -130,3 +150,6 @@
{% endblock %}
+
+{% block scripts %}
+{% endblock %}
diff --git a/app/modules/vacation/templates/vacation/pending.html b/app/modules/vacation/templates/vacation/pending.html
index 39cbaea..7bc505d 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/static/erp-datepop.js b/app/static/erp-datepop.js
index 7596c0e..0310b07 100644
--- a/app/static/erp-datepop.js
+++ b/app/static/erp-datepop.js
@@ -4,7 +4,7 @@
· 브라우저 기본 달력(input[type=date])은 숨기고 그 옆에 날짜 버튼을 둔다 — input 은 값 저장소(.value 읽기/쓰기·change 이벤트 그대로).
· 팝업: 위 칸(시작일·종료일 — 직접 입력 2026-10-27 / 10.27 / 10월 27일 / 1027, Enter), 월 달력(일·공휴일 빨강, 토 파랑,
공휴일 이름은 숫자 밑, 오늘 테두리, 기간 옅은 파랑), 오늘 · 지우기. 바깥 클릭·Esc 로 닫힘, 앵커 아래(자리 없으면 위).
- window.ErpDatePop = { open(anchor, opts), close(), enhanceRange(startInput, endInput, opts), fmt(iso) } */
+ window.ErpDatePop = { open(anchor, opts), close(), enhance(input, opts), enhanceRange(startInput, endInput, opts), fmt(iso), fmtFull(iso) } */
(function () {
"use strict";
@@ -32,6 +32,14 @@
const md = String(d.getMonth() + 1).padStart(2, "0") + "/" + String(d.getDate()).padStart(2, "0") + "(" + wd + ")";
return (String(d.getFullYear()) === today.slice(0, 4) ? "" : d.getFullYear() + "/") + md;
}
+ // 'YYYY-MM-DD' → 'YYYY.MM.DD(요일)' — 입사일처럼 연도가 꼭 보여야 하는 날짜(2026-10-27)
+ function fmtFull(iso) {
+ if (!iso) return "";
+ const d = new Date(String(iso).slice(0, 10) + "T00:00:00");
+ if (isNaN(d.getTime())) return iso;
+ return d.getFullYear() + "." + String(d.getMonth() + 1).padStart(2, "0") + "." + String(d.getDate()).padStart(2, "0") +
+ "(" + ["일", "월", "화", "수", "목", "금", "토"][d.getDay()] + ")";
+ }
function fmtField(iso) {
if (!iso) return "";
const d = new Date(iso + "T00:00:00");
@@ -62,7 +70,8 @@
}
// opts: { start, due, allowStart, active("start"|"due"), labels {start, due}, holidays {iso: 이름}, clear(bool, 기본 true),
- // onChange(patch {due_date, start_date?}) } — 날짜를 누를 때마다 onChange, 마감(종료)일을 고르면 닫힘.
+ // yearNav(bool — « » 1년씩, 입사일처럼 먼 날짜), onChange(patch {due_date, start_date?}) }
+ // — 날짜를 누를 때마다 onChange, 마감(종료)일을 고르면 닫힘.
function open(anchor, opts) {
close();
opts = opts || {};
@@ -118,9 +127,11 @@
field("due", due) +
"" +
'