feat(expense): 개인경비 모듈 + ERP 좌측메뉴 셸 + expense_db 연결

- ERP 셸: 좌측 사이드바 + 상단 헤더 + 콘텐츠 영역(erp_base.html)
- 분기: 슈퍼관리자 → 업무모듈 카드, 일반사용자 → ERP 메인(erp_home.html)
- 신규 라우트: /modules (슈퍼관리자 모듈 카드 재진입)
- 개인경비 모듈: app/modules/expense/ (라우터/저장소/템플릿)
  - JSON 저장소(ExpenseStore) + PostgreSQL 저장소(ExpenseDBStore)
  - 팩토리: EXPENSE_DB_URL 있으면 DB, 없으면 JSON 폴백
- DB: scripts/sql/expense_db_init.sql (멱등 DDL, postgres-db 컨테이너)
  - expense_db, 역할 expense_app, 테이블 expense_items, 인덱스/트리거
- 마이그레이션: scripts/migrate_expense_json_to_db.py (멱등, --dry-run)
- 의존성: psycopg[binary,pool]>=3.2
- 환경변수: EXPENSE_DB_URL 추가
- 문서: CLAUDE.md 작업 기준 + docs/{PROJECT_OVERVIEW,SERVER_ARCHITECTURE,DATABASES,DEPLOYMENT}.md
  - main-app 배포 경로 /opt/www/main 고정 명시
  - 위험 명령(DROP/TRUNCATE/rm -rf/volume 삭제) 사용자 승인 정책
This commit is contained in:
2026-05-29 02:21:03 +09:00
parent d7b6c7d029
commit 9c58b022e2
19 changed files with 2337 additions and 5 deletions
+164
View File
@@ -0,0 +1,164 @@
<!doctype html>
<html lang="ko">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>{{ page_title or "ERP" }} — DBX Corporation</title>
<link rel="stylesheet" href="/static/erp.css" />
<link rel="stylesheet" href="/static/erp-shell.css" />
{% block head_extra %}{% endblock %}
</head>
<body class="erp-body erp-app-body">
<div class="erp-app">
<!-- ── 좌측 사이드바 ── -->
<aside class="erp-sidebar" data-collapsed="false">
<div class="erp-sidebar-head">
<a href="/" class="erp-sidebar-brand">
<img src="/static/dbx-logo.png" alt="DBX" class="erp-sidebar-logo" />
<span class="erp-sidebar-system">ERP</span>
</a>
<button type="button" class="erp-sidebar-toggle" id="erp-sidebar-toggle" aria-label="사이드바 접기">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<polyline points="15 18 9 12 15 6"/>
</svg>
</button>
</div>
<nav class="erp-sidebar-nav">
{% set last_group = namespace(value=None) %}
{% for item in nav_items %}
{% if item.group != last_group.value %}
<div class="erp-sidebar-group">{{ item.group }}</div>
{% set last_group.value = item.group %}
{% endif %}
{% set classes = "erp-sidebar-item" %}
{% if item.active %}{% set classes = classes + " is-active" %}{% endif %}
{% if item.disabled %}{% set classes = classes + " is-disabled" %}{% endif %}
{% if item.disabled %}
<div class="{{ classes }}" title="{{ item.disabled_reason or '준비중' }}">
{% else %}
<a class="{{ classes }}" href="{{ item.url }}"
{% if item.target == '_blank' %}target="_blank" rel="noopener noreferrer"{% endif %}>
{% endif %}
<span class="erp-sidebar-icon">{{ item.icon | safe }}</span>
<span class="erp-sidebar-label">{{ item.label }}</span>
{% if item.badge %}<span class="erp-sidebar-badge">{{ item.badge }}</span>{% endif %}
{% if item.target == '_blank' %}
<span class="erp-sidebar-ext" aria-hidden="true">
<svg width="11" height="11" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/>
<polyline points="15 3 21 3 21 9"/>
<line x1="10" y1="14" x2="21" y2="3"/>
</svg>
</span>
{% endif %}
{% if item.disabled %}
</div>
{% else %}
</a>
{% endif %}
{% endfor %}
</nav>
<div class="erp-sidebar-foot">
{% if user.is_super_admin %}
<a class="erp-sidebar-item" href="/modules" title="업무 모듈 선택 화면">
<span class="erp-sidebar-icon">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<rect x="3" y="3" width="7" height="7"/><rect x="14" y="3" width="7" height="7"/>
<rect x="3" y="14" width="7" height="7"/><rect x="14" y="14" width="7" height="7"/>
</svg>
</span>
<span class="erp-sidebar-label">업무 모듈</span>
</a>
{% endif %}
{% if is_admin %}
<a class="erp-sidebar-item" href="/admin">
<span class="erp-sidebar-icon">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M12 2 4 6v6c0 5 3.4 9.4 8 10 4.6-.6 8-5 8-10V6l-8-4Z"/>
</svg>
</span>
<span class="erp-sidebar-label">관리자</span>
</a>
{% endif %}
</div>
</aside>
<!-- ── 우측 콘텐츠 ── -->
<div class="erp-content">
<header class="erp-topbar">
<div class="erp-topbar-left">
<button type="button" class="erp-sidebar-mobile-toggle" id="erp-sidebar-mobile-toggle" aria-label="메뉴 열기">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<line x1="3" y1="6" x2="21" y2="6"/>
<line x1="3" y1="12" x2="21" y2="12"/>
<line x1="3" y1="18" x2="21" y2="18"/>
</svg>
</button>
<div class="erp-topbar-title">
<h1>{{ page_title or "" }}</h1>
{% if page_subtitle %}<p>{{ page_subtitle }}</p>{% endif %}
</div>
</div>
<div class="erp-topbar-right">
<div class="erp-user-chip">
{% if user.picture %}
<img class="erp-user-avatar" src="{{ user.picture }}" alt="{{ user.name }}" />
{% else %}
<span class="erp-user-avatar-fallback">{{ user.name[0] | upper }}</span>
{% endif %}
<div class="erp-user-info">
<span class="erp-user-name">{{ user.name }}</span>
<span class="erp-user-email">{{ user.email }}</span>
</div>
</div>
<a class="erp-btn erp-btn-outline" href="/logout">로그아웃</a>
</div>
</header>
<main class="erp-page">
{% block content %}{% endblock %}
</main>
</div>
</div>
<script>
(function () {
const sidebar = document.querySelector(".erp-sidebar");
const collapseBtn = document.getElementById("erp-sidebar-toggle");
const mobileBtn = document.getElementById("erp-sidebar-mobile-toggle");
if (collapseBtn) {
collapseBtn.addEventListener("click", () => {
const next = sidebar.dataset.collapsed === "true" ? "false" : "true";
sidebar.dataset.collapsed = next;
try { localStorage.setItem("erp_sidebar_collapsed", next); } catch (_) {}
});
try {
const saved = localStorage.getItem("erp_sidebar_collapsed");
if (saved === "true") sidebar.dataset.collapsed = "true";
} catch (_) {}
}
if (mobileBtn) {
mobileBtn.addEventListener("click", () => {
sidebar.classList.toggle("is-open");
});
}
})();
</script>
{% block scripts %}{% endblock %}
</body>
</html>
+64
View File
@@ -0,0 +1,64 @@
{% extends "erp_base.html" %}
{% block content %}
<section class="erp-home">
<div class="erp-hero">
<h2 class="erp-hero-title">안녕하세요, {{ user.name }}님</h2>
<p class="erp-hero-sub" id="erp-hero-sub"></p>
</div>
<div class="erp-home-grid">
<article class="erp-tile">
<div class="erp-tile-head">
<span class="erp-tile-label">바로가기</span>
<span class="erp-badge erp-badge-neutral">개인업무</span>
</div>
<h3 class="erp-tile-title">개인경비</h3>
<p class="erp-tile-desc">법인카드/개인지출 등록과 정산 신청.</p>
<a class="erp-btn erp-btn-primary" href="/expense/">개인경비 열기</a>
</article>
<article class="erp-tile">
<div class="erp-tile-head">
<span class="erp-tile-label">바로가기</span>
<span class="erp-badge erp-badge-outline">준비중</span>
</div>
<h3 class="erp-tile-title">휴가</h3>
<p class="erp-tile-desc">연차/반차 신청과 잔여일수 확인.</p>
<button class="erp-btn erp-btn-outline" disabled>오픈 예정</button>
</article>
<article class="erp-tile">
<div class="erp-tile-head">
<span class="erp-tile-label">알림</span>
<span class="erp-badge erp-badge-outline">공지</span>
</div>
<h3 class="erp-tile-title">시스템 안내</h3>
<ul class="erp-tile-list">
<li>좌측 메뉴에서 사용 가능한 업무 모듈을 확인하세요.</li>
<li>외부 모듈(주문/CORM)은 새 창에서 열립니다.</li>
<li>권한이 필요한 모듈은 관리자에게 요청하세요.</li>
</ul>
</article>
</div>
</section>
<script>
(function() {
const d = new Date();
const h = d.getHours();
let greet = "오늘도 좋은 하루 되세요.";
if (h < 5) greet = "늦은 시간까지 수고 많으세요.";
else if (h < 12) greet = "활기찬 아침입니다.";
else if (h < 18) greet = "오후 업무 화이팅입니다.";
else greet = "오늘도 고생 많으셨습니다.";
const days = ["일","월","화","수","목","금","토"];
const dateStr = `${d.getFullYear()}.${String(d.getMonth()+1).padStart(2,"0")}.${String(d.getDate()).padStart(2,"0")} (${days[d.getDay()]})`;
const el = document.getElementById("erp-hero-sub");
if (el) el.textContent = `${dateStr} · ${greet}`;
})();
</script>
{% endblock %}