feat(expense): 경비 내역 월 선택 필터 + 월 합계, 월별 집계 버튼 제거
- 상단 "월별 집계" 버튼 삭제 - 경비 내역: 월 선택(input month, 변경 시 자동 조회) 기본 이번 달 - 선택 월(사용일 기준)만 표시 + 해당 월 합계금액 표시 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -279,11 +279,15 @@ async def expense_index(request: Request) -> HTMLResponse:
|
|||||||
)
|
)
|
||||||
|
|
||||||
store = _store(request)
|
store = _store(request)
|
||||||
items = sorted(
|
all_items = sorted(
|
||||||
store.list_for(user["email"]),
|
store.list_for(user["email"]),
|
||||||
key=lambda i: (i.get("spent_at", ""), i.get("created_at", "")),
|
key=lambda i: (i.get("spent_at", ""), i.get("created_at", "")),
|
||||||
reverse=True,
|
reverse=True,
|
||||||
)
|
)
|
||||||
|
# 선택한 월(사용일 기준)만 표시. 기본 = 이번 달.
|
||||||
|
_, _, month = _parse_month(request)
|
||||||
|
items = [it for it in all_items if str(it.get("spent_at", ""))[:7] == month]
|
||||||
|
month_total = sum(int(i.get("amount", 0)) for i in items)
|
||||||
summary = store.summary_for(user["email"])
|
summary = store.summary_for(user["email"])
|
||||||
pending_count = 0
|
pending_count = 0
|
||||||
is_approver = is_admin(user) or has_module(user, "expense_approver")
|
is_approver = is_admin(user) or has_module(user, "expense_approver")
|
||||||
@@ -300,6 +304,8 @@ async def expense_index(request: Request) -> HTMLResponse:
|
|||||||
"pending_count": pending_count,
|
"pending_count": pending_count,
|
||||||
"items": items,
|
"items": items,
|
||||||
"summary": summary,
|
"summary": summary,
|
||||||
|
"month": month,
|
||||||
|
"month_total": month_total,
|
||||||
"categories": _categories(request),
|
"categories": _categories(request),
|
||||||
"methods": list(METHODS),
|
"methods": list(METHODS),
|
||||||
"statuses": list(STATUSES),
|
"statuses": list(STATUSES),
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
<!-- ── 페이지 액션 ── -->
|
<!-- ── 페이지 액션 ── -->
|
||||||
<div class="erp-page-actions">
|
<div class="erp-page-actions">
|
||||||
<a class="erp-btn erp-btn-outline" href="/expense/reports">월별 집계</a>
|
|
||||||
{% if is_approver %}
|
{% if is_approver %}
|
||||||
<a class="erp-btn erp-btn-outline" href="/expense/pending">
|
<a class="erp-btn erp-btn-outline" href="/expense/pending">
|
||||||
승인 대기 {% if pending_count %}<strong style="margin-left:6px;">{{ pending_count }}</strong>{% endif %}
|
승인 대기 {% if pending_count %}<strong style="margin-left:6px;">{{ pending_count }}</strong>{% endif %}
|
||||||
@@ -85,8 +84,12 @@
|
|||||||
<div class="erp-card-block">
|
<div class="erp-card-block">
|
||||||
<div class="erp-card-block-head">
|
<div class="erp-card-block-head">
|
||||||
<h2>경비 내역</h2>
|
<h2>경비 내역</h2>
|
||||||
<div style="display: flex; align-items: center; gap: var(--sp-12);">
|
<div style="display: flex; align-items: center; gap: var(--sp-12); flex-wrap: wrap;">
|
||||||
|
<form method="get" action="/expense/" id="ex-month-form" style="display:flex; gap:var(--sp-8); align-items:center; margin:0;">
|
||||||
|
<input type="month" name="month" value="{{ month }}" />
|
||||||
|
</form>
|
||||||
<span class="erp-muted" id="ex-count">{{ items | length }}건</span>
|
<span class="erp-muted" id="ex-count">{{ items | length }}건</span>
|
||||||
|
<span class="erp-muted">합계 <strong>{{ "{:,}".format(month_total) }}</strong> 원</span>
|
||||||
{% if supports_workflow %}
|
{% if supports_workflow %}
|
||||||
<button id="ex-bulk-submit" class="erp-btn erp-btn-primary erp-btn-sm" disabled>
|
<button id="ex-bulk-submit" class="erp-btn erp-btn-primary erp-btn-sm" disabled>
|
||||||
선택 항목 제출 (<span id="ex-bulk-count">0</span>)
|
선택 항목 제출 (<span id="ex-bulk-count">0</span>)
|
||||||
@@ -412,6 +415,10 @@
|
|||||||
const d = new Date();
|
const d = new Date();
|
||||||
form.spent_at.value = `${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,"0")}-${String(d.getDate()).padStart(2,"0")}`;
|
form.spent_at.value = `${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,"0")}-${String(d.getDate()).padStart(2,"0")}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 월 선택 변경 시 자동 조회
|
||||||
|
const monthInput = document.querySelector('#ex-month-form input[name="month"]');
|
||||||
|
if (monthInput) monthInput.addEventListener("change", () => monthInput.form.submit());
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Reference in New Issue
Block a user