f79b970056
- 매출 수동 입력·광고비 날짜 칸과 엑셀·광고 보고서 업로드에서 오늘 이후 날짜 허용 - 이번달 등 일자별 표의 기간 합계 행을 제목 행 바로 아래로 - 날짜 칸에 = 없이 1000+2000 계산식 입력(formula.parse_amount), 식은 마이그레이션 008 formula 열에 저장해 파랑 굵은 숫자·다시 누르면 식 - 광고비 탭 직접 입력값은 굵게 해제(굵게는 계산식만) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
279 lines
16 KiB
HTML
279 lines
16 KiB
HTML
{% extends "erp_base.html" %}
|
||
|
||
{% block head_extra %}<link rel="stylesheet" href="/static/performance.css?v=20261021a" />{% endblock %}
|
||
|
||
{%- macro won(v) -%}
|
||
{%- if v is none -%}<span class="perf-na"></span>
|
||
{%- elif v == 0 -%}<span class="perf-zero">–</span>
|
||
{%- else -%}{{ amt(v) }}{%- endif -%}
|
||
{%- endmacro -%}
|
||
{#- 큰 금액(KPI·연 누적) — 원 단위면 ₩1,234, 천원·백만원이면 1,234천원 -#}
|
||
{%- macro money(v) -%}
|
||
{%- if unit == 'won' -%}₩{{ amt(v) }}{%- else -%}{{ amt(v) }}<small class="perf-unit-suffix">{{ unit_label }}</small>{%- endif -%}
|
||
{%- endmacro -%}
|
||
{#- 매출 칸 아래 광고비(ROAS%) — 광고비 화면과 같은 값·색. 카페24 = 구글·메타 두 줄(이름 붙임) -#}
|
||
{%- macro adl(lines) -%}
|
||
{%- for a in lines or [] -%}<span class="perf-adl" title="{{ (a.label ~ ' ') if a.label }}광고비 {{ '{:,}'.format(a.amount) }}원{% if a.roas is not none %} · ROAS {{ '{:,}'.format(a.roas) }}%{% endif %}">{% if a.label %}<i>{{ a.label }}</i>{% endif %}{{ amt(a.amount) }}{% if a.roas is not none %}<em>({{ "{:,}".format(a.roas) }}%)</em>{% endif %}</span>{%- endfor -%}
|
||
{%- endmacro -%}
|
||
|
||
{#- 일 합계 광고비(ROAS%) — ROAS = 일 합계 금액 ÷ 일 합계 광고비. 수수료 차감 매출 보기면 차감 매출 기준, 그 밖엔 총매출 기준 -#}
|
||
{%- macro adl_total(a) -%}
|
||
{%- for key, cls in (("roas", "for-gross"), ("roas_net", "for-net")) -%}
|
||
{%- set rs = a[key] -%}
|
||
<span class="perf-adl perf-adl-tot {{ cls }}" title="광고비 합계 {{ '{:,}'.format(a.amount) }}원{% if rs is not none %} · ROAS {{ '{:,}'.format(rs) }}% (일 합계 {{ '수수료 차감 매출' if key == 'roas_net' else '총매출' }} ÷ 광고비){% endif %}">{{ amt(a.amount) }}{% if rs is not none %}<em>({{ "{:,}".format(rs) }}%)</em>{% endif %}</span>
|
||
{%- endfor -%}
|
||
{%- endmacro -%}
|
||
|
||
{#- 한 칸에 총매출/수수료/차감매출 세 값을 넣고, 보기 전환은 CSS(data-metric)로. -#}
|
||
{%- macro m3(m) -%}
|
||
<span class="v v-gross">{{ won(m.gross) }}</span><span class="v v-commission">{{ won(m.commission) }}</span><span class="v v-net">{{ won(m.net) }}</span>
|
||
{%- endmacro -%}
|
||
|
||
{% block content %}
|
||
<section class="perf" id="perf-dash" data-metric="{{ metric }}">
|
||
{% include "performance/_tabs.html" %}
|
||
|
||
<!-- ── 기간 · 필터 · 업데이트 ── -->
|
||
<div class="perf-toolbar">
|
||
<div class="perf-quick" role="group" aria-label="기간 선택">
|
||
{% for q in nav.quick %}
|
||
<a class="perf-seg{% if q.active %} is-active{% endif %}" href="{{ q.url }}">{{ q.label }}</a>
|
||
{% endfor %}
|
||
<button type="button" class="perf-seg{% if period_kind == 'custom' %} is-active{% endif %}" id="perf-custom-btn">직접선택</button>
|
||
</div>
|
||
|
||
<div class="perf-nav">
|
||
<a class="perf-nav-btn" href="{{ nav.prev }}" title="{{ period.prev_label }}">‹ {{ period.prev_label }}</a>
|
||
<span class="perf-nav-label">{{ period.label }}</span>
|
||
<a class="perf-nav-btn" href="{{ nav.next }}" title="{{ period.next_label }}">{{ period.next_label }} ›</a>
|
||
</div>
|
||
|
||
<form class="perf-custom" id="perf-custom" method="get" action="/performance/"{% if period_kind != 'custom' %} hidden{% endif %}>
|
||
<input type="hidden" name="period" value="custom" />
|
||
<input class="erp-input perf-date" type="date" name="from" value="{{ period.start.isoformat() }}" required />
|
||
<span class="perf-muted">~</span>
|
||
<input class="erp-input perf-date" type="date" name="to" value="{{ period.end.isoformat() }}" required />
|
||
{% for c in codes %}{% if not selected_all %}<input type="hidden" name="m" value="{{ c }}" />{% endif %}{% endfor %}
|
||
<button class="erp-btn erp-btn-outline" type="submit">조회</button>
|
||
</form>
|
||
|
||
<details class="perf-filter" id="perf-filter">
|
||
<summary class="erp-btn erp-btn-outline">쇼핑몰: {% if selected_all %}전체{% else %}{{ codes | length }}곳{% endif %}</summary>
|
||
<form class="perf-filter-pop" method="get" action="/performance/">
|
||
<input type="hidden" name="period" value="{{ period_kind }}" />
|
||
{% if period_kind == 'custom' %}
|
||
<input type="hidden" name="from" value="{{ period.start.isoformat() }}" />
|
||
<input type="hidden" name="to" value="{{ period.end.isoformat() }}" />
|
||
{% else %}
|
||
<input type="hidden" name="d" value="{{ period.anchor.isoformat() }}" />
|
||
{% endif %}
|
||
{% for c in all_codes %}
|
||
<label class="perf-check"><input type="checkbox" name="m" value="{{ c }}"{% if c in codes %} checked{% endif %} /> {{ names[c] }}</label>
|
||
{% endfor %}
|
||
<div class="perf-filter-act">
|
||
<button type="button" class="erp-btn erp-btn-ghost" data-perf-check-all>전체</button>
|
||
<button type="submit" class="erp-btn erp-btn-primary">적용</button>
|
||
</div>
|
||
</form>
|
||
</details>
|
||
|
||
<div class="perf-update">
|
||
<span class="perf-muted" id="perf-last-update">마지막 업데이트
|
||
<b>{{ (last_update_at or '')[:16] | replace('T', ' ') or '—' }}</b></span>
|
||
{% if auto_sync %}
|
||
{# 다음 자동 업데이트까지 남은 시간 — 초 단위로 실시간(performance.js initNextUpdate, 2026-10-19) #}
|
||
<span class="perf-muted perf-next-update" id="perf-next-update" title="자동 업데이트: 매일 {{ auto_sync.hours[0] }}~{{ auto_sync.hours[1] }}시 {{ auto_sync.slot }}분마다">다음 업데이트까지 <b>—</b></span>
|
||
{% endif %}
|
||
{# 업데이트 중에도 누를 수 있다 — 진행 중인 업데이트(수동·자동)의 진행 창을 다시 연다(2026-10-19) #}
|
||
<button type="button" class="erp-btn erp-btn-primary{% if running %} is-running{% endif %}" id="perf-sync-btn"
|
||
title="{% if running %}업데이트 진행 상황 보기{% else %}지금 보고 있는 기간({{ period.label }}, 오늘까지)의 매출을 쇼핑몰에서 다시 가져옵니다{% endif %}">
|
||
{% if running %}업데이트 중 · 진행 보기{% else %}매출 업데이트{% endif %}
|
||
</button>
|
||
</div>
|
||
</div>
|
||
|
||
{% if no_marketplaces %}
|
||
<div class="perf-notice">매출에 포함된 쇼핑몰이 없습니다. {% if is_admin %}<a href="/performance/settings">실적 설정</a>에서 쇼핑몰 사용을 켜세요.{% endif %}</div>
|
||
{% endif %}
|
||
|
||
{% if problems %}
|
||
<div class="perf-notice is-warn" id="perf-problems">
|
||
<b>연결 오류</b>
|
||
{% for p in problems %}<span class="perf-problem" title="{{ p.error }}">{{ p.name }} · {{ p.label }}</span>{% endfor %}
|
||
<span class="perf-muted">— 해당 쇼핑몰은 마지막 정상 수집분까지만 반영됩니다. 나머지는 정상입니다.</span>
|
||
</div>
|
||
{% endif %}
|
||
<div class="perf-notice" id="perf-sync-result" hidden></div>
|
||
|
||
<!-- ── KPI — 수수료 차감 매출 한 줄(금액 + 비교 기간 대비 %, 2026-10-19) ── -->
|
||
{% for k in kpis %}
|
||
<div class="perf-kpi-line" title="{{ k.label }}">
|
||
<b class="perf-kpi-line-value">{{ money(k.value) }}</b>
|
||
{% if k.delta is none %}<span class="perf-muted">{{ k.cmp }} 비교 없음</span>
|
||
{% else %}
|
||
<span class="perf-delta {% if k.delta == 0 %}is-flat{% elif k.delta > 0 %}is-up{% else %}is-down{% endif %}">
|
||
{% if k.delta > 0 %}▲{% elif k.delta < 0 %}▼{% else %}–{% endif %} {{ "%.1f" | format(k.delta | abs) }}%</span>
|
||
<span class="perf-muted">{{ k.cmp }} 대비</span>
|
||
{% endif %}
|
||
</div>
|
||
{% endfor %}
|
||
|
||
<!-- ── 일자 × 쇼핑몰 ── -->
|
||
<div class="erp-card perf-card">
|
||
<div class="perf-card-head">
|
||
<h2 class="perf-h">{% if period_kind == 'year' %}월별 × 쇼핑몰{% else %}일자별 × 쇼핑몰{% endif %}</h2>
|
||
<span class="perf-head-notes">{% if unit != 'won' %}<span class="perf-muted">단위: {{ unit_label }}</span>{% endif %}
|
||
<span class="perf-adl-note" title="매출 아래 주황 숫자 = 그 쇼핑몰 광고비(ROAS%) — 광고비 탭과 같은 값. 카페24 는 구글·메타"><span class="perf-adl-key"></span>광고비(ROAS%)</span></span>
|
||
{% if manual_upload_names %}
|
||
<button type="button" class="erp-btn erp-btn-outline erp-btn-sm perf-manual-upload-btn" id="perf-manual-upload"
|
||
title="수동 입력 쇼핑몰 매출을 엑셀 파일로 한 번에 입력">엑셀 업로드</button>
|
||
{% endif %}
|
||
<div class="perf-metric" role="group" aria-label="표시 기준">
|
||
<button type="button" class="perf-seg" data-metric="gross">총매출</button>
|
||
<button type="button" class="perf-seg" data-metric="commission">수수료</button>
|
||
<button type="button" class="perf-seg" data-metric="net">수수료 차감 매출</button>
|
||
</div>
|
||
</div>
|
||
<div class="erp-table-wrap perf-table-wrap">
|
||
<table class="perf-table perf-main">
|
||
<thead>
|
||
<tr>
|
||
<th class="perf-th-label">{% if period_kind == 'year' %}월{% else %}날짜{% endif %}</th>
|
||
{% for c in codes %}<th title="{{ names[c] }}{% if c in manual_codes %} — 수동 입력(날짜 칸을 눌러 입력){% endif %}">{{ short_names[c] }}{% if c in manual_codes %} <span class="perf-manual-mark" aria-label="수동 입력">✎</span>{% endif %}</th>{% endfor %}
|
||
<th class="perf-th-total">{% if period_kind == 'year' %}월 합계{% else %}일 합계{% endif %}</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
{% for r in table %}
|
||
<tr class="perf-row-{{ r.kind }}{% if r.weekday == 5 %} is-sat{% endif %}{% if r.weekday == 6 or r.holiday %} is-sun{% endif %}{% if r.today %} is-today{% endif %}{% if r.future %} is-future{% endif %}">
|
||
<th class="perf-td-label" scope="row"{% if r.holiday %} title="{{ r.holiday }}"{% endif %}>
|
||
{{ r.label }}{% if r.holiday %}<small class="perf-hol">{{ r.holiday }}</small>{% endif %}
|
||
</th>
|
||
{% for c in codes %}
|
||
{% set m = r.cells[c] %}
|
||
{% if r.kind == 'day' and c in manual_codes %}
|
||
{% set is_manual = (r.date ~ '|' ~ c) in manual_cells %}
|
||
{% set fx = (formula_cells or {}).get(r.date ~ '|' ~ c) %}
|
||
<td class="perf-num is-manual-cell{% if is_manual %} is-manual{% endif %}{% if fx %} is-formula{% endif %}" data-manual-code="{{ c }}" data-date="{{ r.date }}"
|
||
data-manual-value="{{ m.gross if is_manual else '' }}"{% if fx %} data-formula="{{ fx }}"{% endif %} tabindex="0"
|
||
title="{% if fx %}계산식 {{ fx }} — 눌러 고치기{% elif is_manual %}수동 입력값 — 눌러 고치기(비우고 저장하면 API 값){% else %}눌러 총매출 직접 입력(1000+2000 같은 계산식도 됨){% endif %}">{{ m3(m) }}{{ adl(r.ads[c]) }}</td>
|
||
{% else %}
|
||
<td class="perf-num{% if r['from'] and (m.gross or m.commission) %} is-link{% endif %}"
|
||
{% if r['from'] %}data-code="{{ c }}" data-from="{{ r['from'] }}" data-to="{{ r['to'] }}"{% endif %}>{{ m3(m) }}{{ adl(r.ads[c]) }}</td>
|
||
{% endif %}
|
||
{% endfor %}
|
||
<td class="perf-num perf-td-total">{{ m3(r.total) }}{% if r.ads_total %}{{ adl_total(r.ads_total) }}{% endif %}</td>
|
||
</tr>
|
||
{% endfor %}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
{% if manual_codes and period_kind != 'year' %}
|
||
<p class="perf-muted perf-manual-help">✎ 표시 쇼핑몰은 날짜 칸을 눌러 <b>총매출</b>을 직접 입력합니다 — Enter 저장 후 아래 칸, Esc 취소,
|
||
비우고 저장하면 다시 API 수집값. <b>1000+2000</b> 처럼 = 없이 계산식을 넣으면 바로 계산됩니다. 파란 숫자 = 수동 입력값, 파랑 굵은 숫자 = 계산식. 수수료는 그날 수수료율로 계산되고, 입력을 마치면 합계·그래프가 다시 계산됩니다.</p>
|
||
{% endif %}
|
||
</div>
|
||
|
||
<!-- ── 그래프 ── -->
|
||
<div class="perf-grid2">
|
||
<div class="erp-card perf-card">
|
||
<div class="perf-card-head"><h2 class="perf-h">{% if period_kind == 'year' %}월별{% else %}일별{% endif %} 매출 추이</h2>
|
||
<span class="perf-muted perf-metric-name"></span></div>
|
||
<div class="perf-chart" id="perf-chart-daily"></div>
|
||
</div>
|
||
<div class="erp-card perf-card">
|
||
<div class="perf-card-head"><h2 class="perf-h">쇼핑몰별 비중</h2>
|
||
<span class="perf-muted">{{ period.label }}</span></div>
|
||
<div class="perf-chart" id="perf-chart-share"></div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- ── 월 누적 · 연간 누적 ── -->
|
||
<div class="perf-grid2">
|
||
<div class="erp-card perf-card">
|
||
<div class="perf-card-head"><h2 class="perf-h">{{ month.label }} 쇼핑몰별 누적 실적</h2>{% if unit != 'won' %}<span class="perf-muted perf-unit-note">단위: {{ unit_label }}</span>{% endif %}</div>
|
||
<div class="erp-table-wrap">
|
||
<table class="perf-table">
|
||
<thead><tr><th class="perf-th-label">쇼핑몰</th><th>총매출</th><th>수수료</th><th>수수료 차감 매출</th><th>매출 비중</th></tr></thead>
|
||
<tbody>
|
||
{% for r in month.rows %}
|
||
<tr>
|
||
<th class="perf-td-label" scope="row">{{ names[r.code] }}</th>
|
||
<td class="perf-num">{{ won(r.gross) }}</td>
|
||
<td class="perf-num">{{ won(r.commission) }}</td>
|
||
<td class="perf-num">{{ won(r.net) }}</td>
|
||
<td class="perf-num perf-share">
|
||
{% if r.share is not none %}<span class="perf-bar" style="--w: {{ [r.share, 0] | max }}%"></span>{{ "%.1f" | format(r.share) }}%{% else %}<span class="perf-zero">–</span>{% endif %}
|
||
</td>
|
||
</tr>
|
||
{% endfor %}
|
||
</tbody>
|
||
<tfoot>
|
||
<tr class="perf-row-total">
|
||
<th class="perf-td-label" scope="row">합계</th>
|
||
<td class="perf-num">{{ won(month.total.gross) }}</td>
|
||
<td class="perf-num">{{ won(month.total.commission) }}</td>
|
||
<td class="perf-num">{{ won(month.total.net) }}</td>
|
||
<td class="perf-num">{% if month.total.share is not none %}100%{% else %}<span class="perf-zero">–</span>{% endif %}</td>
|
||
</tr>
|
||
</tfoot>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="erp-card perf-card">
|
||
<div class="perf-card-head"><h2 class="perf-h">{{ year.year }}년 누적</h2>{% if unit != 'won' %}<span class="perf-muted perf-unit-note">단위: {{ unit_label }}</span>{% endif %}</div>
|
||
<div class="perf-year-sum">
|
||
<div><span>총매출</span><b>{{ money(year.total.gross) }}</b></div>
|
||
<div><span>수수료</span><b>{{ money(year.total.commission) }}</b></div>
|
||
<div><span>수수료 차감 매출</span><b>{{ money(year.total.net) }}</b></div>
|
||
</div>
|
||
<div class="erp-table-wrap">
|
||
<table class="perf-table perf-year">
|
||
<thead><tr><th class="perf-th-label">월</th><th>총매출</th><th>수수료</th><th>수수료 차감 매출</th></tr></thead>
|
||
<tbody>
|
||
{% for r in year.rows %}
|
||
<tr class="{% if r.future %}is-future{% endif %}">
|
||
<th class="perf-td-label" scope="row">{{ r.label }}</th>
|
||
<td class="perf-num">{{ won(r.gross) }}</td>
|
||
<td class="perf-num">{{ won(r.commission) }}</td>
|
||
<td class="perf-num">{{ won(r.net) }}</td>
|
||
</tr>
|
||
{% endfor %}
|
||
</tbody>
|
||
<tfoot>
|
||
<tr class="perf-row-total">
|
||
<th class="perf-td-label" scope="row">합계</th>
|
||
<td class="perf-num">{{ won(year.total.gross) }}</td>
|
||
<td class="perf-num">{{ won(year.total.commission) }}</td>
|
||
<td class="perf-num">{{ won(year.total.net) }}</td>
|
||
</tr>
|
||
</tfoot>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<p class="perf-foot perf-muted">
|
||
매출 기준: 결제는 결제일, 취소·반품은 발생일에 반영(음수). 수수료는 그날 적용되는 쇼핑몰 수수료율로 계산하며
|
||
일·쇼핑몰 단위로 원 미만 반올림합니다. 금액을 누르면 주문 목록을 볼 수 있습니다.
|
||
</p>
|
||
</section>
|
||
|
||
<script type="application/json" id="perf-data">{{ {
|
||
"names": names,
|
||
"codes": codes,
|
||
"daily": chart_daily,
|
||
"share": chart_share,
|
||
"period_kind": period_kind,
|
||
"period_start": period.start.isoformat(),
|
||
"period_end": period.end.isoformat(),
|
||
"today": today,
|
||
"unit": unit,
|
||
"manual_upload_names": manual_upload_names,
|
||
"auto_sync": auto_sync
|
||
} | tojson }}</script>
|
||
{% endblock %}
|
||
|
||
{% block scripts %}<script src="/static/performance.js?v=20261021a" defer></script>{% endblock %}
|