diff --git a/backend/app/main.py b/backend/app/main.py index 6b086a4..c2c9597 100755 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -21,7 +21,7 @@ import ezdxf from ezdxf import recover from fastapi import FastAPI, File, Form, Header, HTTPException, Request, UploadFile from fastapi.middleware.cors import CORSMiddleware -from fastapi.responses import FileResponse, HTMLResponse +from fastapi.responses import FileResponse, HTMLResponse, Response from fastapi.staticfiles import StaticFiles from openpyxl import load_workbook from pydantic import BaseModel, Field @@ -42,6 +42,11 @@ app.add_middleware( LEGACY_STATIC_DIR = LEGACY_DIR / "static" INCOMING_FILES_DIR = BASE_DIR / "incoming-files" +INCOMING_SERVED_DIR = INCOMING_FILES_DIR / "served" +INCOMING_REFERENCE_DIR = INCOMING_FILES_DIR / "reference" +BUSINESS_DASHBOARD_DIR = INCOMING_FILES_DIR / "사업관리대장" +BUSINESS_LEDGER_SERVED_DIR = INCOMING_SERVED_DIR / "ledger" +BUSINESS_LEDGER_INDEX_PATH = BUSINESS_LEDGER_SERVED_DIR / "index.html" FIXED_OFFICE_SOURCE_KEY = "technical-development-center" FIXED_OFFICE_CONFIGS = { "technical-development-center": { @@ -61,6 +66,7 @@ FIXED_OFFICE_CONFIGS = { }, } _fixed_office_cache: dict[str, dict[str, object]] = {} +BUSINESS_LEDGER_DEFAULT_SOURCE_KEY = "business_ledger_default" AUTH_DEFAULT_PASSWORD = "1111" AUTH_PASSWORD_ITERATIONS = 390000 AUTH_SESSION_HOURS = 12 @@ -82,6 +88,66 @@ MH_HEADER_ORDER = [ "사업 종류", "연장근무 프로젝트 코드", "연장근무 프로젝트명", "연장근무 서브코드", "연장근무 시간(실제)", "연장근무 시간(가공)" ] +def sync_default_business_ledger_source(cur) -> None: + cur.execute("SELECT to_regclass('public.integration_binary_sources') IS NOT NULL AS table_exists") + row = cur.fetchone() + table_exists = bool(row["table_exists"]) if row is not None else False + if not table_exists: + return + candidates = [ + BUSINESS_LEDGER_SERVED_DIR / "사업관리대장-1.xlsx", + BUSINESS_DASHBOARD_DIR / "사업관리대장-1.xlsx", + BUSINESS_DASHBOARD_DIR / "사업관리 대장-1.xlsx", + BUSINESS_DASHBOARD_DIR / "사업관리대장.xlsx", + BUSINESS_DASHBOARD_DIR / "사업관리 대장.xlsx", + ] + source_path = next((candidate for candidate in candidates if candidate.exists()), None) + if source_path is None: + return + content = source_path.read_bytes() + content_sha256 = hashlib.sha256(content).hexdigest() + meta_json = { + "byte_size": len(content), + "source_path": str(source_path), + "synced_from": "startup", + } + cur.execute( + """ + INSERT INTO integration_binary_sources ( + source_key, source_name, filename, mime_type, content, content_sha256, meta_json, imported_at + ) + VALUES (%s, %s, %s, %s, %s, %s, %s::jsonb, NOW()) + ON CONFLICT (source_key) DO UPDATE + SET source_name = EXCLUDED.source_name, + filename = EXCLUDED.filename, + mime_type = EXCLUDED.mime_type, + content = EXCLUDED.content, + content_sha256 = EXCLUDED.content_sha256, + meta_json = EXCLUDED.meta_json, + imported_at = NOW() + WHERE integration_binary_sources.content_sha256 IS DISTINCT FROM EXCLUDED.content_sha256 + OR integration_binary_sources.filename IS DISTINCT FROM EXCLUDED.filename + OR integration_binary_sources.mime_type IS DISTINCT FROM EXCLUDED.mime_type + OR integration_binary_sources.meta_json IS DISTINCT FROM EXCLUDED.meta_json + """, + ( + BUSINESS_LEDGER_DEFAULT_SOURCE_KEY, + "사업관리대장 기본 원본", + source_path.name, + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + content, + content_sha256, + json.dumps(meta_json, ensure_ascii=False), + ), + ) + + +app.mount( + "/integrations/ledger-assets", + StaticFiles(directory=str(BUSINESS_LEDGER_SERVED_DIR), check_dir=False), + name="integration-ledger-assets", +) + class MemberPayload(BaseModel): id: int | None = None @@ -3910,6 +3976,7 @@ def startup() -> None: init_db() with get_conn() as conn: with conn.cursor() as cur: + sync_default_business_ledger_source(cur) sync_auth_users_from_members(cur) conn.commit() @@ -3939,6 +4006,37 @@ def health() -> dict[str, object]: } +@app.get("/api/integration/business-ledger-default") +def integration_business_ledger_default() -> Response: + with get_conn() as conn: + with conn.cursor() as cur: + cur.execute( + """ + SELECT filename, mime_type, content + FROM integration_binary_sources + WHERE source_key = %s + ORDER BY imported_at DESC + LIMIT 1 + """, + (BUSINESS_LEDGER_DEFAULT_SOURCE_KEY,), + ) + row = cur.fetchone() + if not row: + raise HTTPException(status_code=404, detail="Business ledger default source not found.") + filename = str(row["filename"] or "사업관리대장-1.xlsx") + headers = { + "Content-Disposition": 'inline; filename="business-ledger-default.xlsx"', + "X-Source-Filename": "business-ledger-default.xlsx", + "Cache-Control": "no-store, no-cache, must-revalidate, max-age=0", + "Pragma": "no-cache", + } + return Response( + content=bytes(row["content"]), + media_type=str(row["mime_type"] or "application/octet-stream"), + headers=headers, + ) + + @app.post("/api/auth/login") def auth_login( request: Request, @@ -4500,15 +4598,30 @@ def legacy_organization_backup() -> FileResponse: @app.get("/integrations/payment") def integration_payment() -> FileResponse: - target = INCOMING_FILES_DIR / "payment.html" + # 8081 phase-1 cleanup: integration HTML is served only from incoming-files/served. + target = INCOMING_SERVED_DIR / "payment.html" if not target.exists(): raise HTTPException(status_code=404, detail="Payment integration file not found.") return FileResponse(target) +@app.get("/integrations/ledger") +def integration_ledger() -> FileResponse: + # #21 phase-1: runtime no longer decodes reference wrapper HTML. Serve the promoted + # ledger entry file from incoming-files/served/ledger only. + target = BUSINESS_LEDGER_INDEX_PATH + if not target.exists(): + raise HTTPException(status_code=404, detail="Business ledger integration file not found.") + response = FileResponse(target) + response.headers["Cache-Control"] = "no-store, no-cache, must-revalidate, max-age=0" + response.headers["Pragma"] = "no-cache" + return response + + @app.get("/integrations/mh") def integration_mh() -> FileResponse: - target = INCOMING_FILES_DIR / "mh.html" + # Keep the served path explicit so comparison/reference copies are never picked up by accident. + target = INCOMING_SERVED_DIR / "mh.html" if not target.exists(): raise HTTPException(status_code=404, detail="MH integration file not found.") return FileResponse(target) diff --git a/docs/DEV_PROD_DB_PROTOCOL.md b/docs/DEV_PROD_DB_PROTOCOL.md index 27024b3..b1b1128 100644 --- a/docs/DEV_PROD_DB_PROTOCOL.md +++ b/docs/DEV_PROD_DB_PROTOCOL.md @@ -187,7 +187,7 @@ docker compose -p mh-dashboard-organization-dev --env-file .env -f docker-compos - 로컬 전용 디자인 참고 자산 복사 - `incoming-files/sample style.css` - `incoming-files/260320.html` - - `incoming-files/사업관리대장/` + - `incoming-files/reference/ledger/` - `incoming-files/1.png` - `incoming-files/seat/center_chair_people_map(2).html` diff --git a/docs/NEXT_SESSION_CHECKPOINT.md b/docs/NEXT_SESSION_CHECKPOINT.md index 3623c45..03bae81 100644 --- a/docs/NEXT_SESSION_CHECKPOINT.md +++ b/docs/NEXT_SESSION_CHECKPOINT.md @@ -2,193 +2,152 @@ ## Current Base -- branch: `total` -- latest checked commit: `24852d4` -- main history doc: [DEVELOPMENT_HISTORY.md](/home/hyunho/projects/mh-dashboard-organization/docs/DEVELOPMENT_HISTORY.md) -- work rulebook: [WORK_RULEBOOK.md](/home/hyunho/projects/mh-dashboard-organization/docs/WORK_RULEBOOK.md) -- execution flow: [WORK_EXECUTION_FLOW.md](/home/hyunho/projects/mh-dashboard-organization/docs/WORK_EXECUTION_FLOW.md) -- dev/prod protocol: [DEV_PROD_DB_PROTOCOL.md](/home/hyunho/projects/mh-dashboard-organization/docs/DEV_PROD_DB_PROTOCOL.md) -- regression checklist: [REGRESSION_CHECKLIST.md](/home/hyunho/projects/mh-dashboard-organization/docs/REGRESSION_CHECKLIST.md) -- today prep note: [TODAY_WORK_PREP_2026-03-30.md](/home/hyunho/projects/mh-dashboard-organization/docs/TODAY_WORK_PREP_2026-03-30.md) +- `8080` 공개 기준 브랜치: `total` +- `8081` 작업 기준 브랜치: `work-8081` +- `8080` 공개 기준 커밋: `637b390` +- `8081` worktree 경로: `/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081` +- `8081` 실제 서빙 책임 맵: [architecture/8081_SERVING_MAP.md](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/docs/architecture/8081_SERVING_MAP.md) +- 메인 히스토리: [DEVELOPMENT_HISTORY.md](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/docs/DEVELOPMENT_HISTORY.md) +- 작업 룰북: [WORK_RULEBOOK.md](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/docs/WORK_RULEBOOK.md) +- 실행 플로우: [WORK_EXECUTION_FLOW.md](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/docs/WORK_EXECUTION_FLOW.md) +- dev/prod DB 프로토콜: [DEV_PROD_DB_PROTOCOL.md](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/docs/DEV_PROD_DB_PROTOCOL.md) +- 회귀 체크리스트: [REGRESSION_CHECKLIST.md](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/docs/REGRESSION_CHECKLIST.md) ## Mandatory Start Rule -매일 아침 또는 그날의 첫 작업을 시작할 때는 코드를 수정하기 전에 반드시 아래 순서를 먼저 수행해야 한다. +당일 첫 작업 전에는 아래 순서를 먼저 확인한다. -1. Gitea 브랜치 상태 확인 +1. 브랜치 기준 확인 2. 열린 이슈 확인 -3. [WORK_RULEBOOK.md](/home/hyunho/projects/mh-dashboard-organization/docs/WORK_RULEBOOK.md) 확인 +3. [WORK_RULEBOOK.md](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/docs/WORK_RULEBOOK.md) 확인 4. 이 문서 확인 -5. 현재 워크트리의 미푸시 커밋, 변경 파일, 미추적 파일 확인 +5. `git status`, 변경 파일, 미추적 파일 확인 주의: -- 위 절차를 확인하기 전에는 새 코드 작성이나 기존 코드 수정부터 시작하지 않는다. -- 커밋과 푸시는 자동으로 하지 않고, 사용자 지시가 있을 때만 수행한다. +- `8080` 기준 코드는 직접 수정하지 않는다. +- 새 작업은 항상 `.dev-worktree-8081`에서 진행한다. +- 커밋과 푸시는 사용자 지시가 있을 때만 수행한다. -## What Was Finished +## Confirmed Runtime Rule -### Dashboard Integration +- `8080`은 루트 workspace의 `total` 기준으로 유지한다. +- `8081`은 `.dev-worktree-8081` + `work-8081` 기준으로만 수정한다. +- `main`, `hyunho`는 보류 브랜치이며 현재 작업에 사용하지 않는다. +- `8081` 변경을 `8080`에 올릴 때는 reviewed file diff 기준으로만 반영한다. +- `8081` DB는 운영 정본이 아니라 `8080` 기준 검증용 복제본처럼 다룬다. -- `조직 현황`, `프로젝트별 분석`, `팀/개인별 분석`, `자리배치도`를 하나의 허브에 통합 -- `payment.html`, `mh.html`을 현재 프로젝트에 편입 -- 공통 헤더, 탭, 로그인 정보, 공통 기간 제어 구성 +## What Was Stabilized -### Integrated DB +### Branch / Worktree Safety -- `organization.xlsx`, `MH.xlsx`, `payment.csv`, `ptj.csv` 기반 통합 DB 구성 -- raw/staging/standard 성격의 구조를 PostgreSQL에 반영 -- `members`, `seat_maps`, `seat_slots`, `seat_positions` -- `integration_raw_*`, `integration_work_logs`, `integration_work_log_segments`, `integration_vouchers` -- 프로젝트 카테고리 매핑 반영 +- 기존 `8081` 작업본은 [`.dev-worktree-8081-backup-2026-04-01`](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081-backup-2026-04-01)로 보존 +- 현재 [`.dev-worktree-8081`](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081)는 `work-8081` 기준으로 재생성 +- `8080` 루트 workspace는 그대로 두고 분리 운영 -### Team / Member Analysis +### 8081 Design / Serving Baseline -- `omh.html` 원본 기준으로 계산식/카테고리/디자인 복원 -- DB raw MH 데이터를 원본 입력 구조처럼 다시 공급하는 방식으로 정리 +- 디자인 SSOT 토큰: + - [frontend/public/design-tokens.css](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/frontend/public/design-tokens.css) +- 디자인 SSOT 패턴: + - [frontend/public/design-patterns.css](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/frontend/public/design-patterns.css) +- 디자인 기준 문서: + - [architecture/DESIGN_SSOT.md](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/docs/architecture/DESIGN_SSOT.md) +- 로그인 기본 스타일은 [frontend/public/styles.css](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/frontend/public/styles.css) 기준으로 유지 +- `8081` 허브 전용 디자인은 [frontend/public/styles-8081-design.css](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/frontend/public/styles-8081-design.css)에서만 덮어씀 +- 조직현황은 [legacy/static/common.css](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/legacy/static/common.css), [legacy/static/organization.css](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/legacy/static/organization.css), [legacy/static/organization.js](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/legacy/static/organization.js)를 사용 +- 프로젝트별 분석 디자인은 [incoming-files/served/payment.html](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/incoming-files/served/payment.html) 내부에서 `design-tokens.css` + `design-patterns.css`를 참조 +- 프로젝트별 분석 수정 원본은 [frontend/apps/payment/index.html](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/frontend/apps/payment/index.html) 이고, 반영은 [scripts/publish_payment_app.sh](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/scripts/publish_payment_app.sh)로 한다. +- 팀/개인별 분석 수정 원본은 [frontend/apps/team/index.html](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/frontend/apps/team/index.html) 이고, 반영은 [scripts/publish_team_app.sh](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/scripts/publish_team_app.sh)로 한다. +- 사업관리대장 실제 서비스 코드는 [incoming-files/served/ledger](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/incoming-files/served/ledger) 기준으로 본다. +- 사업관리대장 앱 소스 기준은 [frontend/apps/ledger](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/frontend/apps/ledger) 이고, 반영은 [scripts/publish_ledger_app.sh](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/scripts/publish_ledger_app.sh)로 한다. +- 사업관리대장 상세 팝업 디자인 수정 원본은 [frontend/apps/ledger/assets/ledger-override.js](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/frontend/apps/ledger/assets/ledger-override.js) 기준으로 본다. -### Project Analysis +디자인 수정 우선순위: -- `opayment.html` 원본 기준으로 화면 복원 -- `payment.csv` 분류 우선, `ptj.csv` fallback 적용 -- 연장근무는 `연장근무 시간(가공)` 기준으로 반영 - -### Organization / Seat Map - -- 조직도 상세 프로필에 `재석위치` preview 연결 -- 관리자/비관리자 자리배치도 화면 분리 -- 저장 후 조직도와 비관리자 열람에 반영되도록 seat save 흐름 정리 -- seat persistence bug 수정 - - 원인: `seat_positions_map_cell_idx`가 slot 기반 도면에도 적용됨 - - 조치: `seat_slot_id IS NULL`인 grid map에만 적용되도록 수정 - -### Member Data Governance - -- 이름 alias, 퇴사 제외, 조직 override를 DB 테이블 기반으로 전환 -- 사용 테이블: - - `member_aliases` - - `member_retirements` - - `member_overrides` - -### Auth Baseline - -- 실제 로그인 API 연결 완료 -- 프런트 로그인 화면이 `/api/auth/login` 사용 -- 세션/로그아웃/세션 조회 API 구성 완료 -- 사용 테이블: - - `auth.users` - - `auth.sessions` - - `auth.login_audit_logs` -- 현재 남은 범위: - - mock login 정리 - - 역할별 권한 체크 적용 - - 쓰기 API 보호 범위 정리 - -### External Access - -- WSL 내부 8080 리슨 확인 -- 현재 다른 PC에서 접속 확인 -- 현재 기준 주소: - - `http://172.16.40.144:8080` - -## Important Runtime Notes - -### Dev / Prod Protocol - -- 코드 선행은 `8081`, 공개 반영은 `8080` -- 데이터 정본은 `8080` DB -- `8081` DB는 독립 정본이 아니라 `8080` 기준 복제본처럼 관리해야 함 -- `8081` 코드는 `.dev-worktree-8081` 기준으로 유지 -- 조직도, 멤버, 자리배치 검증 전에는 `DEV_PROD_DB_PROTOCOL.md`를 먼저 확인 -- 기능 수정 후 완료 판단은 `REGRESSION_CHECKLIST.md`를 기준으로 해야 함 -- 빠른 재시작은 `./scripts/start_local_dashboards.sh` - -### Seat Map Save - -- 저장이 안 되면 먼저 backend 로그에서 `PUT /api/seat-maps/{id}/layout` 상태코드 확인 -- 과거 핵심 장애는 DB 인덱스 충돌이었다 -- 현재 저장 구조는: - - `seat_positions` - - `members.seat_label` - 둘 다 같이 갱신 - -### External Access - -- Windows LAN IP가 바뀌면 접속 주소가 바뀔 수 있음 -- WSL IP가 바뀌면 `portproxy connectaddress`를 다시 맞춰야 함 -- 다음 확인 명령: - - Windows: `ipconfig` - - WSL: `hostname -I` - - Windows: `netsh interface portproxy show all` - -## Open Issues - -- `#2` 백엔드 영속 저장 구조 운영 마무리 -- `#3` 사무실 좌석 배치도 조회 및 관리자 편집 기능 고도화 -- `#5` 실제 인증 체계 전환 -- `#7` 자리배치도 팀별 색상 오버레이 표시 -- `#8` 자리배치도 좌석 클릭 시 개인 상위 조직 트리 표시 -- `#9` 조직도·자리배치도 변경 이력 버전 누적 저장 - -현재 해석: -- `#6`은 코드 기준 사실상 완료 상태이며 Gitea 정리 대상 -- `#5`는 "로그인 구현"보다 "권한 제어 마무리"가 핵심 -- `#2`의 기존 "스냅샷 검증" 범위는 현재 코드와 불일치하므로 범위 재정의 필요 - -## Unfinished Ideas Discussed Today - -### Seat Map UX - -- 자리배치도 내 인원 등록 시 팀별 색상 표시 -- 좌석 클릭 시 본인까지의 상위 조직 트리 표시 -- 나머지 사무실 2개 도면 추가 - - `한맥빌딩 7층` - - `한맥빌딩 6층` -- 비관리자 열람 화면 품질 추가 점검 - -### History / Versioning - -- 조직도와 자리배치도 수정 이력을 버전 누적형으로 저장 -- 원본 DB와 별도의 history/version 구조 설계 -- `valid_from`, `valid_to` 기반 시점 조회(as-of date) 구조 적용 -- 날짜 또는 revision label 기준으로 버전 묶음 관리 -- 상세 설계 문서: - - [HISTORY_ASOF_DB_PLAN.md](/home/hyunho/projects/mh-dashboard-organization/docs/HISTORY_ASOF_DB_PLAN.md) +1. [frontend/public/design-tokens.css](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/frontend/public/design-tokens.css) +2. [frontend/public/design-patterns.css](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/frontend/public/design-patterns.css) +3. 화면별 실제 서빙 파일 주의: -- 현재 코드에는 조직도/자리배치도 버전 이력 기능이 아직 없음 -- 월간 스냅샷 방향은 범위에서 제외 -### Project Analysis Accuracy +- `incoming-files/sample style.css`는 참고 기준이지만 직접 런타임 수정 파일이 아니다. +- `incoming-files` 원본/reference 파일을 먼저 고치지 않는다. +- 새 디자인 수정은 먼저 토큰/패턴 파일에서 해결 가능한지 확인한 뒤, 불가피할 때만 화면별 파일에 내린다. -- 총합은 거의 맞았지만 일부 프로젝트 단위 소수점/분류 오차는 추가 정밀 보정 필요 -- `opayment` 기준으로 특정 프로젝트 차이를 계속 줄여야 함 +### 1차 구조 정리 진행분 -### Auth / Permission +- 이슈 기준: + - `#14` 전체 구조 정리 umbrella + - `#18` 1차: 파일 책임 맵 정리 및 프런트 서빙 경로 정돈 + - `#19` 2차: 백엔드 라우터/서빙 책임 분리 + - `#20` 3차: worktree/스크립트/문서 정리 +- 책임 맵 문서 추가: + - [architecture/8081_SERVING_MAP.md](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/docs/architecture/8081_SERVING_MAP.md) +- `/integrations/payment`, `/integrations/mh`의 실제 서빙 파일을 분리: + - [incoming-files/served/payment.html](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/incoming-files/served/payment.html) + - [incoming-files/served/mh.html](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/incoming-files/served/mh.html) +- 기존 [incoming-files/payment.html](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/incoming-files/payment.html), [incoming-files/mh.html](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/incoming-files/mh.html)은 비교/복구용 복사본으로 당분간 유지 +- backend 서빙 경로는 [backend/app/main.py](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/backend/app/main.py)에서 `incoming-files/served/*`를 보도록 정리 시작 -- mock login을 개발용 fallback 수준으로 제한하거나 제거 -- 역할별 접근 제어 정리 -- 조직도/자리배치도/분석 화면 권한 경계 재정리 +## Current Actual Serving Map + +- `/`: + - [frontend/public/index.html](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/frontend/public/index.html) +- `/styles.css`: + - [frontend/public/styles.css](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/frontend/public/styles.css) +- `/styles-8081-design.css`: + - [frontend/public/styles-8081-design.css](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/frontend/public/styles-8081-design.css) +- `/legacy/organization`: + - [legacy/static/DashBoard-organization.html](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/legacy/static/DashBoard-organization.html) +- `/integrations/payment`: + - [incoming-files/served/payment.html](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/incoming-files/served/payment.html) +- `/integrations/ledger`: + - [incoming-files/served/ledger/index.html](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/incoming-files/served/ledger/index.html) +- `/integrations/mh`: + - [incoming-files/served/mh.html](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/incoming-files/served/mh.html) + +## Cross Checks Last Confirmed + +- `8080`: `curl http://localhost:8080/api/health` 정상 +- `8081` dev 컨테이너: proxy/backend/frontend/db `healthy` +- `8081` backend 내부 확인: + - `/api/health` 200 + - `/legacy/organization` 200 + - `/integrations/payment` 200 + - `/integrations/ledger` 200 + - `/integrations/mh` 200 +- `incoming-files/served` 내 실제 서빙 파일 존재 확인 + +주의: + +- Codex 터미널 세션에서는 `curl http://localhost:8081`가 간헐적으로 실패할 수 있다. +- 이 경우 브라우저 확인 또는 컨테이너 내부 라우트 확인을 기준으로 판단한다. + +## Open Issues Relevant Now + +- `#14` 누적된 임시 로직 정리 및 중복 코드 제거 +- `#16` 사업관리대장 메인 연동 및 기본 원본 DB화 +- `#17` 8081 분리 worktree 기동 절차와 로컬 디자인 자산 복제 고정 +- `#18` 8081 파일 책임 맵 정리 및 프런트 서빙 경로 정돈 +- `#19` 8081 백엔드 라우터/서빙 책임 분리 +- `#20` 8081 worktree 준비 스크립트·문서·운영 규칙 정리 +- `#21` reference 의존 제거 및 8081 실제 서비스 코드 독립화 ## Recommended Next Work Order -1. `#2` 범위를 현재 코드 기준으로 재정의하고 영속성 운영 검증 완료 -2. `#5`에서 권한 체크, mock login 정리, 쓰기 API 보호 적용 -3. `8081` DB를 `8080` 정본 기준으로 동기화하는 반복 가능한 절차 마련 -4. `#9`를 as-of date 기반 history 구조로 설계 후 `members`, `seat_positions` 부터 이력화 -5. 그 다음 `#8`, 나머지 도면 추가, `#7`, 프로젝트 분석 오차 보정 순으로 진행 +1. `#21` 이후 기준으로 실제 서비스 파일과 reference 파일 경계를 유지 +2. 사업관리대장 세부 데이터 정합성 보정 +3. 그 다음 화면별 앱 구조 승격 검토 +4. 필요 시 `#19`, `#20` 잔여 정리 항목 재평가 ## Quick Resume Prompt 다음 세션 시작 시 아래 기준으로 이어가면 된다. -- 브랜치 `total`에서 시작 -- 최근 커밋 `1d15cf9` 확인 -- `docs/DEVELOPMENT_HISTORY.md` -- `docs/NEXT_SESSION_CHECKPOINT.md` -- `docs/DEV_PROD_DB_PROTOCOL.md` -- `docs/REGRESSION_CHECKLIST.md` -- `docs/HISTORY_ASOF_DB_PLAN.md` -- Gitea 이슈 `#2`, `#5`, `#9` - -그리고 먼저 현재 외부 접속, 자리배치 저장, 실제 로그인 동작을 확인한 뒤 다음 기능 개발로 넘어간다. +- `8080` 기준은 `total` +- `8081` 작업은 `work-8081` + `.dev-worktree-8081` +- 먼저 [WORK_RULEBOOK.md](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/docs/WORK_RULEBOOK.md), [NEXT_SESSION_CHECKPOINT.md](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/docs/NEXT_SESSION_CHECKPOINT.md), [architecture/8081_SERVING_MAP.md](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/docs/architecture/8081_SERVING_MAP.md) 확인 +- 디자인 수정이면 [frontend/public/design-tokens.css](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/frontend/public/design-tokens.css), [frontend/public/design-patterns.css](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/frontend/public/design-patterns.css), [architecture/DESIGN_SSOT.md](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/docs/architecture/DESIGN_SSOT.md) 먼저 확인 +- 현재 구조 독립화 기준 이슈는 `#21` +- 작업 전 `git status`, dev 컨테이너 상태, `/api/health`, `/legacy/organization`, `/integrations/payment`, `/integrations/ledger`, `/integrations/mh`를 먼저 확인 diff --git a/docs/WORK_EXECUTION_FLOW.md b/docs/WORK_EXECUTION_FLOW.md index 9db488f..6136f17 100644 --- a/docs/WORK_EXECUTION_FLOW.md +++ b/docs/WORK_EXECUTION_FLOW.md @@ -40,6 +40,8 @@ - 기능 검증 기준: `8081` - 사업관리대장 디자인 기준: `MH 통합 대시보드_260320.html` - 허브 공통 시각 언어 기준: `sample style.css` +- 런타임 디자인 토큰 기준: `frontend/public/design-tokens.css` +- 런타임 디자인 패턴 기준: `frontend/public/design-patterns.css` - 현재 작업 지시 기준: 연결된 Gitea 이슈 작업 시작 전에 먼저 정해야 하는 질문: @@ -51,6 +53,14 @@ 이걸 모르고 코드를 건드리면 높은 확률로 엉뚱한 파일을 수정하게 된다. +디자인 작업 추가 규칙: + +- 디자인 수정은 항상 `design-tokens.css`와 `design-patterns.css`를 먼저 확인한다. +- 색/패널/버튼/테이블/팝업이 공통 규칙으로 해결 가능한지 먼저 본다. +- 해결 가능하면 화면별 파일을 고치지 않고 토큰/패턴 파일에서 수정한다. +- 화면별 실제 서빙 파일은 마지막 단계에서만 조정한다. +- 원본/reference 파일은 비교용이지 직접 수정 우선 대상이 아니다. + ## 2. 이슈 생성 또는 연결 작업은 이슈 없이 하지 않는다. diff --git a/docs/WORK_RULEBOOK.md b/docs/WORK_RULEBOOK.md index 6895ad9..7aee334 100644 --- a/docs/WORK_RULEBOOK.md +++ b/docs/WORK_RULEBOOK.md @@ -218,6 +218,26 @@ mock, fallback, hotfix, 임시 우회 로직은 허용할 수 있다. ## Rule 13. 8081 Must Start From The Isolated Worktree +`8081` 작업은 항상 `.dev-worktree-8081` 기준으로 시작한다. + +세부 규칙: + +- 디자인 작업도 예외가 아니다. +- 허브/조직현황/프로젝트별 분석/사업관리대장 수정 전에 현재 실제 서빙 파일과 SSOT 파일을 먼저 확인한다. + +디자인 작업 강제 우선순위: + +1. `frontend/public/design-tokens.css` +2. `frontend/public/design-patterns.css` +3. `docs/architecture/DESIGN_SSOT.md` +4. 그 다음 화면별 실제 서빙 파일 + +금지: + +- reference/original 파일을 먼저 수정하기 +- 예전 파란톤/indigo/slate 계열을 새 기본값으로 다시 넣기 +- 토큰/패턴으로 해결 가능한 문제를 화면별 임시 하드코딩으로 처리하기 + `8081` 작업용은 포트만 다른 복제 서버가 아니라, 코드 소스까지 분리된 전용 worktree여야 한다. 세부 규칙: diff --git a/docs/architecture/8081_SERVING_MAP.md b/docs/architecture/8081_SERVING_MAP.md new file mode 100644 index 0000000..f00447f --- /dev/null +++ b/docs/architecture/8081_SERVING_MAP.md @@ -0,0 +1,112 @@ +# 8081 Serving Map + +## Purpose + +이 문서는 `8081` 작업용에서 어떤 URL이 어떤 파일을 실제로 읽는지 고정하기 위한 책임 맵이다. +이번 1차 정리의 목표는 기능 변경이 아니라 `실제 서빙 파일`, `공통 기본 스타일`, `8081 전용 오버라이드`, `참고 원본 자산`의 경계를 분명히 하는 것이다. + +## Runtime Entry Points + +- 허브 엔트리: `/` + - 파일: `frontend/public/index.html` +- 허브 공통 스크립트: + - 파일: `frontend/public/app.js` +- 허브 공통 기본 스타일: + - 파일: `frontend/public/styles.css` +- 허브 8081 전용 디자인 오버라이드: + - 파일: `frontend/public/styles-8081-design.css` + +## Login Rules + +- 로그인 화면 기본 구조와 스타일은 `8080` 공통 기준을 따른다. +- 로그인 기본 스타일은 `frontend/public/styles.css`에서만 정의한다. +- `frontend/public/styles-8081-design.css`에는 로그인 관련 셀렉터를 넣지 않는다. + +## Legacy Organization + +- URL: `/legacy/organization` +- HTML 파일: + - `DashBoard-organization.html` +- 정적 자산: + - `legacy/static/common.css` + - `legacy/static/organization.css` + - `legacy/static/organization.js` + +## Integration Screens + +- URL: `/integrations/payment` + - 현재 실제 서빙 파일: `incoming-files/served/payment.html` + - 앱 소스 기준: `frontend/apps/payment/index.html` + - publish 규칙: `scripts/publish_payment_app.sh` +- URL: `/integrations/ledger` + - 현재 실제 서빙 파일: `incoming-files/served/ledger/index.html` + - 현재 실제 runtime asset 경로: `incoming-files/served/ledger/*` + - 앱 소스 기준: `frontend/apps/ledger/*` + - publish 규칙: `frontend/apps/ledger/index.html` placeholder를 `scripts/publish_ledger_app.sh`가 runtime asset 경로로 치환 +- URL: `/integrations/mh` + - 현재 실제 서빙 파일: `incoming-files/served/mh.html` + - 앱 소스 기준: `frontend/apps/team/index.html` + - publish 규칙: `scripts/publish_team_app.sh` + +정리 원칙: + +- `incoming-files` 아래에서는 `served/`를 실제 서빙 자산용으로 사용한다. +- `reference/`는 원본 참고 파일, 복구 참고 파일, 비교용 자산만 둔다. +- 1차 정리에서는 기존 실제 서빙 파일을 `served/`에 복사하고, backend 서빙 경로를 먼저 `served/`로 갱신한다. +- `사업관리대장`은 `#21`부터 wrapper decode 방식 대신 `served/ledger/index.html`과 `served/ledger/*`를 직접 서빙한다. +- `사업관리대장` 수정 원본은 `#21` 다음 단계부터 `frontend/apps/ledger/*`를 먼저 보고, `scripts/publish_ledger_app.sh`로 runtime served 파일에 반영한다. +- 기존 루트 `incoming-files/payment.html`, `incoming-files/mh.html`는 안전한 비교/복구를 위해 당분간 남겨둔다. + +## Seat Map + +- 허브 화면 구성: + - `frontend/public/index.html` + - `frontend/public/app.js` + - `frontend/public/styles.css` + - `frontend/public/styles-8081-design.css` +- API / viewer: + - `backend/app/main.py` + - `backend/app/db.py` + - `backend/app/center_chair_viewer_template.html` + +## Incoming Files Classification + +### Served + +- 실제 URL에서 직접 읽는 파일 +- 예: + - `served/payment.html` + - `served/mh.html` + +### Reference + +- 원본 HTML/CSS/XLSX/CSV +- 복구 비교용 자산 +- 직접 서빙하지 않는 참고 파일 +- 필요 시 다음 차수에서 `reference/` 하위로 단계적 재배치한다. + +예: + +- `260320.html` +- `sample style.css` +- `opayment.html` +- `omh.html` +- `reference/ledger/MH 통합 대시보드_260320.html` +- `reference/ledger/MH 통합 대시보드_260320.css` +- 원본 xlsx/csv + +## Out Of Scope For Phase 1 + +- DB 스키마 의미 변경 +- 계산식 변경 +- 권한 로직 변경 +- 신규 기능 추가 +- backend 라우터 대분해 + +## Phase 1 Success Criteria + +- 수정 대상 파일을 화면별로 즉시 찾을 수 있다. +- 로그인은 `styles.css`만 본다. +- 허브 8081 디자인은 `styles-8081-design.css`만 본다. +- `/integrations/payment`, `/integrations/mh`의 실제 서빙 파일 위치가 문서와 코드에서 일치한다. +- 기존 참고 자산을 지우지 않고도 실제 서빙 경로와 참고 경로를 구분할 수 있다. diff --git a/docs/architecture/DESIGN_SSOT.md b/docs/architecture/DESIGN_SSOT.md new file mode 100644 index 0000000..03fa7e5 --- /dev/null +++ b/docs/architecture/DESIGN_SSOT.md @@ -0,0 +1,129 @@ +# Design SSOT + +## Source of truth + +- Primary visual source: [incoming-files/sample style.css](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/incoming-files/sample%20style.css) +- Runtime token file: [design-tokens.css](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/frontend/public/design-tokens.css) +- Runtime pattern file: [design-patterns.css](/home/hyunho/projects/mh-dashboard-organization/.dev-worktree-8081/frontend/public/design-patterns.css) + +`sample style.css` defines the intended MH visual language. `design-tokens.css` is the token-level SSOT, and `design-patterns.css` is the component-level SSOT that packages those tokens into reusable runtime patterns. + +## Rules + +- New UI must use `design-tokens.css` variables first. +- New UI must use `design-patterns.css` patterns before adding page-local variants. +- Direct hex values are exceptions, not defaults. +- Page files may define layout and composition, but color, panel, border, radius, and shadow values must come from tokens. +- Shared aliases in `legacy/static/common.css` and `frontend/public/styles.css` exist only to bridge older code to the SSOT. +- Reference files under `incoming-files/*` are not visual authority. Runtime visuals must follow `design-tokens.css` and `design-patterns.css`. + +## Fixed vs Flexible + +SSOT is not a pixel-locked screenshot spec. It is a design rule system with two layers. + +### Fixed rules + +These should be treated as stable defaults across screens. + +- Brand color family and accent family +- Surface, border, text, and shadow tokens +- Radius scale +- Button, tab, input, panel, and card visual language +- Typography tone and hierarchy +- Background atmosphere and overall contrast direction + +### Flexible rules + +These must be interpreted per screen based on content density and interaction needs. + +- KPI card width and number of columns +- Sidebar/content split ratios +- Table column widths +- Search/filter placement +- Card stacking and wrap behavior +- Desktop/mobile breakpoint behavior + +Example: + +- Wrong SSOT: `KPI width is 100px` +- Correct SSOT: `KPI cards use the shared panel, radius, spacing, and text hierarchy tokens, and their width adapts to content without collapsing readability` + +## When SSOT does not define a component + +If a screen needs a pattern that SSOT does not explicitly define yet, do not fall back to arbitrary legacy styling. + +Use this order: + +1. Reuse existing tokens and the nearest shared pattern +2. Design the missing component in the same visual grammar +3. If the pattern is likely to repeat, document and promote it into SSOT + +This applies to examples such as: + +- A table pattern that does not exist in the current SSOT +- A KPI strip that needs a different density than the sample +- A new modal layout for a data-heavy screen + +## Candidate and deprecated styles + +Not every style already visible in the product is automatically part of SSOT. + +- `SSOT` + - Approved and repeatable patterns + - Token-backed visual rules +- `candidate` + - Screen-local styles that look usable but do not yet have a documented basis + - Can be promoted later if they prove reusable +- `deprecated` + - Old blue/slate/indigo defaults + - Temporary hardcoded fixes + - Styles that conflict with the sample-based MH visual language + +When a screen has a design with no clear basis, classify it as `candidate` first. Promote it only after it has been checked for reuse and consistency. + +## Token groups + +- Surface: `--ds-bg`, `--ds-panel`, `--ds-panel-soft`, `--ds-panel-strong` +- Text: `--ds-ink`, `--ds-text-soft`, `--ds-text-muted` +- Brand: `--ds-brand`, `--ds-brand-deep`, `--ds-brand-soft`, `--ds-accent`, `--ds-accent-soft`, `--ds-mint` +- Borders and shadows: `--ds-line`, `--ds-line-soft`, `--ds-shadow-*` +- Layout primitives: `--ds-radius-*`, `--ds-space-*`, `--ds-page-max-width` + +## Promoted runtime patterns + +These are now the official reusable patterns for current screens. + +- Panels and heads: `.ds-panel`, `.ds-panel-head` +- KPI cards: `.ds-kpi-card`, `.ds-kpi-people`, `.ds-kpi-inverse` +- Filter surfaces and toggles: `.ds-filter-surface`, `.ds-filter-toggle`, `.ds-reset-button` +- Tables: `.ds-table-head`, `.ds-table-head-row`, `.ds-table-row`, `.ds-axis-cell`, `.ds-axis-cell-idle`, `.ds-axis-cell-active` +- Value emphasis: `.ds-project-cell`, `.ds-income`, `.ds-expense`, `.ds-subhead`, `.ds-empty`, `.ds-strong`, `.ds-muted` +- Breakdown/detail UI: `.ds-progress-track*`, `.ds-mode-chip`, `.ds-name-chip`, `.ds-mini-table-*`, `.ds-group-title` +- Position chips: `.ds-position-*` via `position-*` compatibility classes +- Business ledger popup/detail blocks: `.popup-*`, `.inline-card`, `.project-head-*`, `.summary-*`, `.ledger-*`, `.badge`, `.project-link` +- Organization modal forms/buttons: `.member-form-*`, `.modal-btn*` +- Seatmap action visibility: `.seatmap-actions .ghost-button` + +These patterns may still have compatibility selectors for existing screen classes, but they should now be treated as the official design layer. + +## Migration order + +1. Token file and common aliases +2. Hub shell and shared controls +3. Team/Personal analysis and Organization +4. Project analysis +5. Business ledger detail cleanup + +## Implementation guidance + +- Prefer tokenized ranges over hardcoded single values when layout depends on data volume +- Prefer `design-patterns.css` component rules over one-off inline colors +- If a new pattern is introduced during implementation, update this document once the pattern is stable +- If a screen needs an exception, keep the exception local and explain why it cannot follow the shared pattern + +## Anti-patterns + +- Adding new `#4f46e5`, `#4338ca`, `bg-slate-*`, `text-indigo-*` style defaults +- Reintroducing separate page-level color systems +- Hardcoding “quick fix” brand colors in JS templates when a token/class can carry the same intent +- Letting reference/original files override runtime pattern files diff --git a/frontend/apps/ledger/README.md b/frontend/apps/ledger/README.md new file mode 100644 index 0000000..b160759 --- /dev/null +++ b/frontend/apps/ledger/README.md @@ -0,0 +1,26 @@ +# Ledger App Source + +`사업관리대장` 화면의 앱 구조 source-of-truth 디렉터리다. + +현재 원칙: + +- 실제 runtime 응답은 여전히 `incoming-files/served/ledger/`를 사용한다. +- 하지만 HTML/CSS/JS 수정 원본은 이 디렉터리에서 먼저 관리한다. +- 변경 후에는 `scripts/publish_ledger_app.sh`로 `served/ledger/`에 반영한다. + +구성: + +- `index.html`: ledger 엔트리 HTML 원본 템플릿 +- `assets/MH 통합 대시보드_260320.css`: ledger base stylesheet +- `assets/ledger-override.css`: 8081 ledger 스타일 확장 +- `assets/ledger-override.js`: 8081 ledger UI/상호작용 확장 + +주의: + +- `index.html`은 runtime 경로를 직접 하드코딩하지 않는다. +- `__LEDGER_HEAD_ASSETS__`, `__LEDGER_BODY_SCRIPTS__` placeholder는 publish 시 실제 `/integrations/ledger-assets/*` 경로로 치환된다. + +범위: + +- 이 디렉터리는 `#21` 이후 `사업관리대장`을 화면별 앱 구조로 승격하기 위한 첫 단계다. +- 아직 프레임워크 앱은 아니고, 독립 관리되는 정식 화면 소스 디렉터리다. diff --git a/incoming-files/사업관리대장/MH 통합 대시보드_260320.css b/frontend/apps/ledger/assets/MH 통합 대시보드_260320.css similarity index 100% rename from incoming-files/사업관리대장/MH 통합 대시보드_260320.css rename to frontend/apps/ledger/assets/MH 통합 대시보드_260320.css diff --git a/frontend/apps/ledger/assets/ledger-override.css b/frontend/apps/ledger/assets/ledger-override.css new file mode 100644 index 0000000..505b65e --- /dev/null +++ b/frontend/apps/ledger/assets/ledger-override.css @@ -0,0 +1,328 @@ +html, +body { + margin: 0; + padding: 0; +} + +body.mh-business-theme { + overflow-x: hidden; + background: + radial-gradient(circle at top left, rgba(214, 138, 58, 0.16), transparent 24%), + radial-gradient(circle at top right, rgba(47, 153, 115, 0.10), transparent 20%), + linear-gradient(180deg, #f6efe6 0%, #f1eadf 100%); +} + +body.mh-business-theme .wrap { + width: min(100%, 2000px); + max-width: 2000px; + margin: 0 auto; + padding: 18px 18px 26px; + box-sizing: border-box; +} + +body.mh-business-theme .top, +body.mh-business-theme .status { + display: none !important; +} + +body.mh-business-theme .cards { + display: grid; + grid-template-columns: repeat(12, minmax(0, 1fr)); + gap: 14px; + margin: 0 0 16px; +} + +body.mh-business-theme .business-shell { + width: 100%; + box-sizing: border-box; + margin-top: 2px; + padding: 18px; + border-radius: 32px; + background: + radial-gradient(circle at 16% 14%, rgba(255,255,255,0.05), transparent 18%), + radial-gradient(circle at 88% 8%, rgba(255,255,255,0.04), transparent 16%), + linear-gradient(145deg, #0b352b 0%, #174e41 52%, #245f50 100%); + box-shadow: 0 26px 54px rgba(15, 58, 47, 0.16); + border: 1px solid rgba(255,255,255,0.08); +} + +body.mh-business-theme .cards-toolbar { + grid-column: 1 / -1; + display: flex; + flex-direction: column; + gap: 14px; + padding: 10px 0 2px; +} + +body.mh-business-theme .cards-toolbar-row { + display: flex; + align-items: center; + gap: 10px; + flex-wrap: wrap; +} + +body.mh-business-theme .cards-toolbar-search { + margin-left: auto; + display: flex; + align-items: center; + min-width: min(360px, 100%); + flex: 1 1 320px; + max-width: 520px; +} + +body.mh-business-theme .cards-toolbar-search .search { + width: 100%; + min-width: 0; + border-radius: 999px; + border: 1px solid rgba(255,255,255,0.12); + background: rgba(255,255,255,0.10); + color: #f4efe6; + padding: 14px 18px; + font-size: 14px; + font-weight: 800; + box-shadow: inset 0 1px 0 rgba(255,255,255,0.04); +} + +body.mh-business-theme .cards-toolbar-search .search::placeholder { + color: rgba(244, 239, 230, 0.74); +} + +body.mh-business-theme #btnUpload { + display: none !important; +} + +body.mh-business-theme .cards-toolbar-metrics { + display: grid; + grid-template-columns: repeat(3, minmax(0, 1fr)); + gap: 14px; +} + +body.mh-business-theme .summary-year-chip { + display: inline-flex; + align-items: center; + justify-content: center; + min-width: 60px; + padding: 10px 16px; + border-radius: 999px; + border: 1px solid rgba(255,255,255,0.14); + background: rgba(255,255,255,0.08); + color: #f4efe6; + font-size: 12px; + font-weight: 900; + cursor: pointer; +} + +body.mh-business-theme .summary-year-chip.active { + background: linear-gradient(180deg, #fff8ee 0%, #f2dec0 100%); + color: #0a2a22; + border-color: rgba(242, 196, 132, 0.58); + box-shadow: 0 12px 28px rgba(10, 42, 34, 0.18); +} + +body.mh-business-theme .summary-filter-chip { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + gap: 6px; + width: 100%; + min-height: 98px; + padding: 18px 22px; + border-radius: 999px; + border: 1px solid rgba(255,255,255,0.14); + background: linear-gradient(180deg, rgba(255,255,255,0.10) 0%, rgba(255,255,255,0.07) 100%); + color: #f4efe6; + box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 16px 30px rgba(7, 28, 22, 0.14); + cursor: pointer; + text-align: center; +} + +body.mh-business-theme .summary-filter-chip.active { + background: linear-gradient(180deg, #fff8ee 0%, #f2dec0 100%); + color: #0a2a22; + border-color: rgba(242, 196, 132, 0.58); +} + +body.mh-business-theme .summary-filter-chip .label { + color: rgba(244, 239, 230, 0.78); + font-size: 13px; + font-weight: 900; +} + +body.mh-business-theme .summary-filter-chip.active .label { + color: rgba(10, 42, 34, 0.78); +} + +body.mh-business-theme .summary-filter-chip .count { + color: #fff7e6; + font-size: 32px; + line-height: 1; + font-weight: 900; +} + +body.mh-business-theme .summary-filter-chip.active .count { + color: #b86b1f; +} + +body.mh-business-theme .summary-filter-chip .meta { + color: #f2c484; + font-size: 11px; + font-weight: 800; + text-align: center; +} + +body.mh-business-theme .summary-filter-chip.active .meta { + color: #7c5a20; +} + +body.mh-business-theme .card { + grid-column: span 2; + min-height: 110px; + border-radius: 24px; + border: 1px solid rgba(217, 197, 168, 0.55); + background: linear-gradient(180deg, rgba(255,250,243,0.96) 0%, rgba(248,242,232,0.96) 100%); + padding: 18px 20px; + box-shadow: 0 18px 32px rgba(15, 58, 47, 0.08); +} + +body.mh-business-theme .card.management { + grid-column: span 2; +} + +body.mh-business-theme .card .k { + color: #5b6d63; + font-size: 12px; + font-weight: 900; +} + +body.mh-business-theme .card .v { + margin-top: 8px; + color: #17392f; + font-size: 30px; + font-weight: 900; +} + +body.mh-business-theme .card .n { + margin-top: 8px; + color: #7b6953; + font-size: 11px; + font-weight: 700; +} + +body.mh-business-theme .panel { + border-radius: 28px; + border: 1px solid rgba(217, 197, 168, 0.55); + box-shadow: 0 18px 32px rgba(15, 58, 47, 0.08); +} + +body.mh-business-theme .table-wrap { + width: 100%; + max-width: 100%; + border-radius: 28px; + overflow-x: hidden !important; +} + +body.mh-business-theme .table-vat-note { + display: none !important; +} + +body.mh-business-theme table { + width: 100% !important; + min-width: 0 !important; + table-layout: fixed; + background: rgba(255, 250, 243, 0.96); +} + +body.mh-business-theme thead th { + background: #0f352b; + color: #fff5e6; + border-right: 1px solid rgba(242, 196, 132, 0.2); +} + +body.mh-business-theme tbody td { + background: rgba(255, 250, 243, 0.96); +} + +body.mh-business-theme .group-row td { + padding: 12px 14px 10px; + background: linear-gradient(180deg, rgba(255, 248, 238, 0.98) 0%, rgba(242, 222, 192, 0.78) 100%); + border-top: 1px solid rgba(214, 138, 58, 0.26); + border-bottom: 1px solid rgba(217, 197, 168, 0.54); +} + +body.mh-business-theme .group-chip { + display: inline-flex; + align-items: center; + gap: 8px; + padding: 6px 12px; + border-radius: 999px; + background: rgba(255, 250, 243, 0.98); + border: 1px solid rgba(214, 138, 58, 0.3); + color: #17392f; + font-size: 12px; + font-weight: 900; + box-shadow: 0 8px 18px rgba(15, 58, 47, 0.08); + cursor: pointer; +} + +body.mh-business-theme .group-chip .group-toggle { + margin-left: 4px; + width: 22px; + height: 22px; + display: inline-flex; + align-items: center; + justify-content: center; + border-radius: 999px; + background: rgba(242, 196, 132, 0.18); + color: #b66e22; + font-size: 14px; + line-height: 1; +} + +body.mh-business-theme .project-link { + display: inline-flex; + align-items: center; + gap: 6px; + padding: 0; + border: 0; + background: none; + color: #17392f; + font: inherit; + font-weight: 900; + text-align: left; + cursor: pointer; +} + +body.mh-business-theme .project-link:hover { + color: #0f6a55; +} + +@media (max-width: 1280px) { + body.mh-business-theme .cards-toolbar-metrics { + grid-template-columns: 1fr; + } + + body.mh-business-theme .card { + grid-column: span 4; + } +} + +@media (max-width: 880px) { + body.mh-business-theme .wrap { + padding: 12px 12px 20px; + } + + body.mh-business-theme .cards { + grid-template-columns: 1fr; + } + + body.mh-business-theme .card { + grid-column: auto; + } + + body.mh-business-theme .cards-toolbar-search { + margin-left: 0; + max-width: none; + flex-basis: 100%; + } +} diff --git a/frontend/apps/ledger/assets/ledger-override.js b/frontend/apps/ledger/assets/ledger-override.js new file mode 100644 index 0000000..853e51c --- /dev/null +++ b/frontend/apps/ledger/assets/ledger-override.js @@ -0,0 +1,498 @@ +(function () { + window.__mhLedgerEnhancementLoaded = false; + if (typeof S === "undefined" || typeof E === "undefined" || typeof render !== "function") return; + window.__mhLedgerEnhancementLoaded = true; + if (!S.dashboard) S.dashboard = { year: "", section: "active" }; + if (!S.collapsedGroups) S.collapsedGroups = {}; + + function bgToday() { + var now = new Date(); + return new Date(now.getFullYear(), now.getMonth(), now.getDate()); + } + + function bgParseDate(value) { + var text = String(value || "").trim(); + if (!text) return null; + var match = text.match(/(20\d{2})\D?(\d{1,2})\D?(\d{1,2})/); + if (match) { + var parsed = new Date(Number(match[1]), Number(match[2]) - 1, Number(match[3])); + return isNaN(parsed.getTime()) ? null : parsed; + } + var fallback = new Date(text); + if (isNaN(fallback.getTime())) return null; + return new Date(fallback.getFullYear(), fallback.getMonth(), fallback.getDate()); + } + + function bgYearFromText(value) { + var match = String(value || "").trim().match(/(20\d{2})/); + return match ? match[1] : ""; + } + + function bgStartYear(row) { + return bgYearFromText(row && row.sDate); + } + + function bgEndYear(row) { + return bgYearFromText(row && row.eDate); + } + + function bgDisplayYear(row) { + var start = bgStartYear(row); + if (start) return start; + var contractMatch = String((row && row.cDate) || "").trim().match(/(20\d{2})/); + if (contractMatch) return contractMatch[1]; + var nameMatch = String((row && row.name) || "").trim().match(/^(20\d{2})/); + if (nameMatch) return nameMatch[1]; + return bgEndYear(row) || "미지정"; + } + + function bgCompletionYear(row) { + return bgEndYear(row) || bgDisplayYear(row); + } + + function bgDateOrYearStart(row) { + var yearText = bgDisplayYear(row); + return bgParseDate(row && row.sDate) || bgParseDate(row && row.cDate) || (/^20\d{2}$/.test(yearText) ? new Date(Number(yearText), 0, 1) : null); + } + + function bgDateOrYearEnd(row) { + var completionYear = bgCompletionYear(row); + return bgParseDate(row && row.eDate) || (/^20\d{2}$/.test(completionYear) ? new Date(Number(completionYear), 11, 31) : null); + } + + function bgYearCutoff(year) { + var targetYear = Number(year || 0); + if (!targetYear) return null; + var today = bgToday(); + if (targetYear < today.getFullYear()) return new Date(targetYear, 11, 31); + if (targetYear === today.getFullYear()) return today; + return null; + } + + function bgYearStartDate(year) { + var targetYear = Number(year || 0); + return targetYear ? new Date(targetYear, 0, 1) : null; + } + + function bgActiveInYear(row, year) { + var cutoff = bgYearCutoff(year); + var yearStart = bgYearStartDate(year); + var startDate = bgDateOrYearStart(row); + var endDate = bgDateOrYearEnd(row); + if (!(cutoff && yearStart && startDate)) return false; + if (startDate > cutoff) return false; + if (endDate && endDate < yearStart) return false; + return !(endDate && endDate <= cutoff); + } + + function bgStartedInYear(row, year) { + var cutoff = bgYearCutoff(year); + var startDate = bgDateOrYearStart(row); + if (!(cutoff && startDate)) return false; + return startDate.getFullYear() === Number(year || 0) && startDate <= cutoff; + } + + function bgCompletedInYear(row, year) { + var cutoff = bgYearCutoff(year); + var endDate = bgDateOrYearEnd(row); + if (!(cutoff && endDate)) return false; + return endDate.getFullYear() === Number(year || 0) && endDate <= cutoff; + } + + function bgYearRange(row) { + var years = []; + var startYear = Number(bgDisplayYear(row) || 0); + var endYear = Number(bgCompletionYear(row) || 0); + if (startYear && endYear && endYear >= startYear) { + for (var year = startYear; year <= endYear; year += 1) years.push(String(year)); + } else if (startYear) { + years.push(String(startYear)); + } + return years; + } + + function bgYears(rows) { + var currentYear = new Date().getFullYear(); + var years = Array.from(new Set((Array.isArray(rows) ? rows : []).flatMap(bgYearRange).filter(function (year) { + return /^20\d{2}$/.test(year); + }))).sort(function (a, b) { + return Number(b) - Number(a); + }); + years = years.filter(function (year) { + var numericYear = Number(year); + return numericYear >= 2018 && numericYear <= currentYear; + }); + return years.length ? years : [String(currentYear)]; + } + + function bgEnsureYear(rows) { + var years = bgYears(rows); + if (!years.includes(S.dashboard.year)) S.dashboard.year = years[0]; + return years; + } + + function bgTotals(targetRows) { + return (Array.isArray(targetRows) ? targetRows : []).reduce(function (acc, row) { + acc.c += Number((row && row.cSup) || 0); + acc.col += Number((row && row.col) || 0); + acc.recv += Number((row && row.recv) || 0); + return acc; + }, { c: 0, col: 0, recv: 0 }); + } + + function isSupportServiceRow(row) { + var category = String((row && row.cat) || "").trim(); + return category.indexOf("경영지원") >= 0 || category.indexOf("서비스") >= 0; + } + + function isBaronProjectRow(row) { + var category = String((row && row.cat) || "").trim(); + if (category.indexOf("바론") < 0) return false; + if (isSupportServiceRow(row)) return false; + return true; + } + + function bgSummarize(rows, selectedYear) { + var items = Array.isArray(rows) ? rows : []; + var targetYear = selectedYear || bgEnsureYear(items)[0]; + var activeRows = items.filter(function (row) { return bgActiveInYear(row, targetYear); }); + var newProjectRows = items.filter(function (row) { return bgStartedInYear(row, targetYear); }); + var completedRows = items.filter(function (row) { return bgCompletedInYear(row, targetYear); }); + var managementRows = newProjectRows.filter(isSupportServiceRow); + return { + targetYear: targetYear, + activeRows: activeRows, + newProjectRows: newProjectRows, + completedRows: completedRows, + managementRows: managementRows, + managementTotals: bgTotals(managementRows) + }; + } + + function bgMatches(row) { + var section = S.dashboard.section || "active"; + var selectedYear = S.dashboard.year || bgEnsureYear(S.all)[0]; + if (section === "new") return bgStartedInYear(row, selectedYear); + if (section === "completed") return bgCompletedInYear(row, selectedYear); + return bgActiveInYear(row, selectedYear); + } + + function normalizeStatusLabel(status) { + var value = String(status || "").trim(); + if (!value) return "-"; + if (value.indexOf("진행") >= 0) return "과업 진행중"; + return value; + } + + function formatSplitPercent(split) { + var numeric = parseFloat(String(split || "").replace(/[^0-9.\-]/g, "")); + if (!Number.isFinite(numeric) || numeric === 0) return "분담율 -%"; + return "분담율 " + numeric.toFixed(2) + "%"; + } + + function projectYear(row) { + var start = String((row && row.sDate) || "").trim(); + var startMatch = start.match(/(20\d{2})/); + if (startMatch) return startMatch[1]; + var name = String((row && row.name) || "").trim(); + var nameMatch = name.match(/^(20\d{2})/); + if (nameMatch) return nameMatch[1]; + var end = String((row && row.eDate) || "").trim(); + var endMatch = end.match(/(20\d{2})/); + if (endMatch) return endMatch[1]; + return "미지정"; + } + + function groupSortRank(row) { + var selectedYear = Number((S.dashboard && S.dashboard.year) || projectYear(row) || 0); + var startYear = Number(projectYear(row) || 0); + if (typeof bgCompletedInYear === "function" && bgCompletedInYear(row, String(selectedYear))) return 9999; + if (!startYear) return 9998; + return startYear; + } + + function tableGroupLabel(row) { + var startYear = projectYear(row); + if (/^20\d{2}$/.test(startYear)) return startYear + "년"; + return "미지정"; + } + + function renderLedgerTable() { + var table = document.querySelector(".panel table"); + if (!table || !E.tbody) return; + var thead = table.querySelector("thead"); + if (thead) { + thead.innerHTML = '
| 기성 차수 | 세금계산서 발행일 | 수금일 | 수금금액 | 미수금액 | 비고 |
|---|---|---|---|---|---|
| ' + esc((index + 1) + "차") + '' + esc(payment.pay || "-") + ' | ' + esc(payment.issueDate ? d(payment.issueDate) : "-") + ' | ' + esc(payment.collectDate ? d(payment.collectDate) : "-") + ' | ' + esc(won(payment.collected || 0)) + ' | ' + esc(won(payment.receivable || 0)) + ' | ' + esc(noteParts.join(" / ") || "-") + ' |
|
+
+
+
+
+ |
+
+
+
+
+
+ |
+
+
+
+
+
+ |
+
+
+
+
+
+ |
+
+
+
+
+
+ |
+
+
+
+
+
+ |
+
+
+
+
+
+ |
+
+
+
+
+
+ |
+
|---|
총 0명 참여 중
+ +※ 인정시간: 평일(8시간+연장 3시간) 및 주말(5시간)
+