53896f0425
쿠팡(윙) 보고서는 캠페인 줄에도 날짜가 있고 19열이 비어 있어 "청구금액이 비어 있습니다" 오류로 전부 막혔다. 금액이 한 줄도 없던 날은 업로드 창에 알려 준다. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
218 lines
12 KiB
HTML
218 lines
12 KiB
HTML
{% extends "erp_base.html" %}
|
||
|
||
{% block head_extra %}<link rel="stylesheet" href="/static/performance.css?v=20261014b" />{% endblock %}
|
||
|
||
{#- ROAS 덧붙임 — "광고비(ROAS%)". 광고비가 없으면 아무것도 안 붙는다. -#}
|
||
{%- macro roas(p) -%}{%- if p is not none -%}<span class="perf-roas">({{ "{:,}".format(p) }}%)</span>{%- endif -%}{%- endmacro -%}
|
||
|
||
{%- macro won(v) -%}
|
||
{%- if v is none -%}<span class="perf-na"></span>
|
||
{%- elif v == 0 -%}<span class="perf-zero">–</span>
|
||
{%- else -%}{{ "{:,}".format(v) }}{%- endif -%}
|
||
{%- endmacro -%}
|
||
|
||
{% block content %}
|
||
{#- 광고비 — 매출 실적과 같은 기간 이동·표·그래프. 날짜 칸을 눌러 직접 입력(파란 숫자), 업로드로 들어온 값은 주황 숫자. -#}
|
||
<section class="perf perf-ads" id="perf-dash" data-metric="gross" data-fixed-metric="gross">
|
||
{% 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/ads"{% 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 />
|
||
<button class="erp-btn erp-btn-outline" type="submit">조회</button>
|
||
</form>
|
||
</div>
|
||
|
||
{% if migration_needed %}
|
||
<div class="perf-notice is-warn">광고비 저장 표가 아직 없습니다. 관리자가 performance_db 마이그레이션 005
|
||
(scripts/sql/performance_db_005_ad_spend.sql)를 적용하면 입력할 수 있습니다.</div>
|
||
{% endif %}
|
||
|
||
<!-- ── KPI ── -->
|
||
<div class="perf-kpis">
|
||
{% for k in kpis %}
|
||
<div class="perf-kpi{% if k.primary %} is-primary{% endif %}">
|
||
<div class="perf-kpi-label">{{ k.label }}</div>
|
||
{% if k.key == 'ratio' %}
|
||
<div class="perf-kpi-value">{% if k.pct is none %}–{% else %}{{ "%.1f" | format(k.pct) }}%{% endif %}</div>
|
||
<div class="perf-kpi-delta"><span class="perf-muted">{{ k.note }}</span></div>
|
||
{% else %}
|
||
<div class="perf-kpi-value">₩{{ "{:,}".format(k.value) }}</div>
|
||
<div class="perf-kpi-delta">
|
||
{% if k.delta is none %}<span class="perf-muted">{{ k.cmp }} 비교 없음</span>
|
||
{% else %}
|
||
{% set up = k.delta > 0 %}
|
||
<span class="perf-delta {% if k.delta == 0 %}is-flat{% elif up != (k.invert or false) %}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>
|
||
{% endif %}
|
||
</div>
|
||
{% endfor %}
|
||
</div>
|
||
|
||
<!-- ── 일자 × 채널 ── -->
|
||
<div class="erp-card perf-card">
|
||
<div class="perf-card-head">
|
||
<h2 class="perf-h">{% if period_kind == 'year' %}월별 × 광고 채널{% else %}일자별 × 광고 채널{% endif %}</h2>
|
||
{% if upload_channels %}
|
||
<button type="button" class="erp-btn erp-btn-outline erp-btn-sm perf-manual-upload-btn perf-ad-upload-btn" id="perf-ad-upload"
|
||
title="광고 보고서 파일로 일별 광고비를 한 번에 입력">파일 업로드</button>
|
||
{% endif %}
|
||
</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 %}{% if c in detail_channels %}<th class="perf-th-detail" title="{{ names[c] }} — 눌러 일자별 광고 보고서 항목 보기. 괄호 = 보고서 ROAS(구매완료 광고수익률)"><button type="button" class="perf-detail-btn" data-detail-channel="{{ c }}">{{ names[c] }} <span class="material-symbols-outlined" aria-hidden="true">table_view</span></button></th>{% else %}<th title="{{ names[c] }} — 날짜 칸을 눌러 광고비 입력.{% if roas_basis[c] %} 괄호 = ROAS({{ roas_basis[c] }} 매출 ÷ 광고비){% else %} ROAS 는 계산하지 않음(따로 입력){% endif %}">{{ names[c] }} <span class="perf-manual-mark" aria-hidden="true">✎</span></th>{% endif %}{% 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 v = r.cells[c].gross %}
|
||
{% if r.kind == 'day' and not r.future and not migration_needed %}
|
||
{% set up = (r.date ~ '|' ~ c) in upload_cells %}
|
||
<td class="perf-num is-manual-cell{% if v and not up %} is-manual{% endif %}{% if up %} is-upload{% endif %}"
|
||
data-manual-code="{{ c }}" data-date="{{ r.date }}" data-manual-value="{{ v if v else '' }}" tabindex="0"
|
||
title="{% if up %}파일 업로드 값 — 눌러 고치기{% else %}눌러 광고비 입력(비우고 저장하면 지움){% endif %}"><span class="v v-gross">{{ won(v) }}</span>{{ roas(r.roas[c]) }}</td>
|
||
{% else %}
|
||
<td class="perf-num"><span class="v v-gross">{{ won(v) }}</span>{{ roas(r.roas[c]) }}</td>
|
||
{% endif %}
|
||
{% endfor %}
|
||
<td class="perf-num perf-td-total"><span class="v v-gross">{{ won(r.total.gross) }}</span>{{ roas(r.roas_total) }}</td>
|
||
</tr>
|
||
{% endfor %}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
{% if period_kind != 'year' %}
|
||
<p class="perf-muted perf-manual-help">날짜 칸을 눌러 그날 <b>광고비</b>를 직접 입력합니다 — Enter 저장 후 아래 칸, Esc 취소, 비우고 저장하면 지움.
|
||
칸은 <b>광고비(ROAS%)</b> — ROAS = 그 쇼핑몰 매출 실적 총매출 ÷ 광고비(합계 열은 전체 매출). 구글·메타는 ROAS 를 계산하지 않고,
|
||
네이버는 광고 보고서의 ROAS(구매완료 광고수익률)를 씁니다 — 네이버 머리글을 누르면 일자별 보고서 항목.
|
||
파란 숫자 = 직접 입력, 주황 숫자 = 파일 업로드 값. 쿠팡(윙)·쿠팡(로켓)은 [파일 업로드]로 광고 보고서를 올리면 날짜별로 한 번에 들어갑니다.</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></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></div>
|
||
<div class="erp-table-wrap">
|
||
<table class="perf-table">
|
||
<thead><tr><th class="perf-th-label">채널</th><th>광고비</th><th>ROAS</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">{% if r.roas is not none %}{{ "{:,}".format(r.roas) }}%{% else %}<span class="perf-zero">–</span>{% endif %}</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">{% if month.total.roas is not none %}{{ "{:,}".format(month.total.roas) }}%{% else %}<span class="perf-zero">–</span>{% endif %}</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></div>
|
||
<div class="perf-year-sum">
|
||
<div><span>광고비</span><b>₩{{ "{:,}".format(year.total.gross) }}</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>ROAS</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">{% if r.roas is not none %}{{ "{:,}".format(r.roas) }}%{% elif not r.future %}<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(year.total.gross) }}</td>
|
||
<td class="perf-num">{% if year.total.roas is not none %}{{ "{:,}".format(year.total.roas) }}%{% else %}<span class="perf-zero">–</span>{% endif %}</td>
|
||
</tr>
|
||
</tfoot>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<p class="perf-foot perf-muted">
|
||
광고비 기준: 쿠팡(윙)·쿠팡(로켓)은 광고 보고서의 청구금액(+부가가치세). ROAS = 그 쇼핑몰 매출 ÷ 광고비 × 100(구글·메타는 계산 안 함, 네이버는 보고서 값).
|
||
매출 대비 광고비 = 같은 기간 광고비 ÷ 매출 실적 총매출.
|
||
구글·메타는 지금은 직접 입력합니다.
|
||
</p>
|
||
</section>
|
||
|
||
<script type="application/json" id="perf-data">{{ {
|
||
"names": names,
|
||
"codes": codes,
|
||
"daily": chart_daily,
|
||
"share": chart_share,
|
||
"period_kind": period_kind,
|
||
"today": today,
|
||
"manual_api": "/performance/api/ad-spend/",
|
||
"manual_word": "광고비",
|
||
"period_start": period.start.isoformat(),
|
||
"period_end": period.end.isoformat(),
|
||
"period_label": period.label,
|
||
"empty_text": "기간 내 광고비가 없습니다.",
|
||
"upload_channels": upload_channels
|
||
} | tojson }}</script>
|
||
{% endblock %}
|
||
|
||
{% block scripts %}<script src="/static/performance.js?v=20261014d" defer></script>{% endblock %}
|