feat(vacation): 달력 공휴일 이름 · 잔여 연차를 옵션으로(참여자 표) · 연차 차감·12/31 소멸
- 쉬는 날 = 국경일·대체공휴일(project KR_HOLIDAYS, 2026~2030) + 휴가 설정 공휴일(덮어쓰기, 빨강 해제 = 근무일) — db.holiday_map 한 곳 (달력·날짜 팝업·일수 계산), 메인 달력은 날짜 아래 이름 + 그 주 막대 내림 - 잔여 연차 등록을 설정 → 옵션(관리자): 참여자 전원 아이콘·이름 미리 보여 주는 표, 사용·잔여·작년 참고, 한꺼번에 저장(save_balances) - 사용 연차 = 승인된 연차·오전반차·오후반차만(병가·경조·대체휴무·기타 제외), 해를 넘는 신청은 해마다 나눔, 연도별 12/31 소멸 안내 - 옵션 화면 카드가 화면 높이에 눌려 잘리던 것·입력 칸 최소 너비 수정 - 테스트: 실제 PG(holiday_map·used_days·save_balances), 실제 앱(옵션 표·저장 권한·설정 없음·달력 이름) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user