feat(performance): 직접 추가 쇼핑몰(수동 입력)·쇼핑몰 그룹·설정 드래그 순서

- 마이그레이션 009: perf_marketplaces.is_custom·is_group·parent_code
- 설정: [+ 쇼핑몰 추가(수동 입력)]·[+ 그룹 추가], 이름 변경·삭제, 직접 추가 쇼핑몰 그룹 select
- custom_ 코드는 registry.get_adapter 가 수동 입력 전용 어댑터(CustomManualAdapter)로
- 매출 실적 표: 그룹 열 = 보이는 하위 쇼핑몰 합계(일 합계엔 안 더함), ▾/▸ 하위 열 접기(localStorage)
- 설정 표 ⠿ 드래그 → PUT /api/marketplace-order → sort_order, 화면 순서는 ordered_marketplaces 한 곳
- 테스트: test_custom_groups.py, perf_groups.browser.test.js

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-22 10:57:03 +09:00
parent 5ef9a55d91
commit e3a8649b41
18 changed files with 948 additions and 44 deletions
@@ -1,6 +1,6 @@
{% extends "erp_base.html" %}
{% block head_extra %}<link rel="stylesheet" href="/static/performance.css?v=20261021a" />{% endblock %}
{% block head_extra %}<link rel="stylesheet" href="/static/performance.css?v=20261022a" />{% endblock %}
{#- ROAS 덧붙임 — "광고비(ROAS%)". 광고비가 없으면 아무것도 안 붙는다. -#}
{%- macro roas(p) -%}{%- if p is not none -%}<span class="perf-roas">({{ "{:,}".format(p) }}%)</span>{%- endif -%}{%- endmacro -%}
@@ -238,4 +238,4 @@
} | tojson }}</script>
{% endblock %}
{% block scripts %}<script src="/static/performance.js?v=20261021b" defer></script>{% endblock %}
{% block scripts %}<script src="/static/performance.js?v=20261022a" defer></script>{% endblock %}
@@ -1,6 +1,6 @@
{% extends "erp_base.html" %}
{% block head_extra %}<link rel="stylesheet" href="/static/performance.css?v=20261021a" />{% endblock %}
{% block head_extra %}<link rel="stylesheet" href="/static/performance.css?v=20261022a" />{% endblock %}
{%- macro won(v) -%}
{%- if v is none -%}<span class="perf-na"></span>
@@ -139,7 +139,11 @@
<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 %}
{#- 그룹(2026-10-22) — 그룹 열 = 보이는 하위 쇼핑몰 합계, ▾ 로 하위 열 접기/펴기(이 브라우저에 기억) -#}
{% for col in cols %}{% set c = col.code %}
{% if col.kind == 'group' %}<th class="perf-th-group" data-group-head="{{ c }}" title="{{ names[c] }} — 하위 쇼핑몰 {{ group_members[c] | length }}곳 매출 합계"><button type="button" class="perf-gtoggle" data-group-toggle="{{ c }}" aria-expanded="true" title="하위 쇼핑몰 접기/펴기">▾</button>{{ short_names[c] }}</th>
{% else %}<th{% if col.kind == 'child' %} class="perf-th-child" data-group-child="{{ col.group }}"{% endif %} 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>{% endif %}
{% endfor %}
<th class="perf-th-total">{% if period_kind == 'year' %}월 합계{% else %}일 합계{% endif %}</th>
</tr>
</thead>
@@ -149,16 +153,20 @@
<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 %}
{% for col in cols %}
{% set c = col.code %}
{% set m = r.cells[c] %}
{% if r.kind == 'day' and c in manual_codes %}
{% set gattr %}{% if col.kind == 'child' %} data-group-child="{{ col.group }}"{% endif %}{% endset %}
{% if col.kind == 'group' %}
<td class="perf-num perf-td-group" data-group-cell="{{ c }}">{{ m3(m) }}</td>
{% elif 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 }}"
<td class="perf-num is-manual-cell{% if is_manual %} is-manual{% endif %}{% if fx %} is-formula{% endif %}"{{ gattr }} 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 %}"
<td class="perf-num{% if r['from'] and (m.gross or m.commission) %} is-link{% endif %}"{{ gattr }}
{% if r['from'] %}data-code="{{ c }}" data-from="{{ r['from'] }}" data-to="{{ r['to'] }}"{% endif %}>{{ m3(m) }}{{ adl(r.ads[c]) }}</td>
{% endif %}
{% endfor %}
@@ -275,4 +283,4 @@
} | tojson }}</script>
{% endblock %}
{% block scripts %}<script src="/static/performance.js?v=20261021b" defer></script>{% endblock %}
{% block scripts %}<script src="/static/performance.js?v=20261022a" defer></script>{% endblock %}
@@ -1,6 +1,6 @@
{% extends "erp_base.html" %}
{% block head_extra %}<link rel="stylesheet" href="/static/performance.css?v=20261021a" />{% endblock %}
{% block head_extra %}<link rel="stylesheet" href="/static/performance.css?v=20261022a" />{% endblock %}
{%- macro when(v) -%}{{ (v or '')[:16] | replace('T', ' ') or '—' }}{%- endmacro -%}
@@ -41,10 +41,30 @@
{% if is_admin %}<th></th>{% endif %}
</tr>
</thead>
<tbody>
{% for r in rows %}
<tr data-code="{{ r.code }}" data-name="{{ r.name }}">
<th class="perf-td-label" scope="row">{{ r.name }}</th>
{# 드래그 단위(2026-10-22) = tbody 하나 — 그룹 없는 행 하나 또는 그룹 + 하위 쇼핑몰(하위는 그 안에서만 순서 변경) #}
{% for b in blocks %}
<tbody class="perf-sort-block{% if b.row.is_group %} is-group-block{% endif %}">
{% for r in [b.row] + b.children %}
{% if r.is_group %}
<tr class="perf-group-row" data-code="{{ r.code }}" data-name="{{ r.name }}" data-group="1">
<th class="perf-td-label" scope="row">
{% if is_admin %}<span class="perf-drag" title="끌어서 순서 변경(그룹은 하위 쇼핑몰과 함께 움직임)" aria-hidden="true">⠿</span>{% endif %}
<span class="perf-group-name">{{ r.name }}</span> <span class="perf-pill">그룹</span>
</th>
<td colspan="{{ 7 if is_admin else 2 }}" class="perf-muted">하위 쇼핑몰 {{ r.children }}곳 — 매출 실적에서 그룹 열 = 하위 쇼핑몰 매출 합계(수수료도 쇼핑몰별 요율로 계산해 합침)</td>
{% if is_admin %}
<td class="perf-nowrap">
<button type="button" class="erp-btn erp-btn-ghost erp-btn-sm" data-act="rename">이름 변경</button>
<button type="button" class="erp-btn erp-btn-ghost erp-btn-sm perf-del-btn" data-act="delete">삭제</button>
</td>
{% endif %}
</tr>
{% else %}
<tr data-code="{{ r.code }}" data-name="{{ r.name }}"{% if r.parent %} class="perf-child-row" data-parent="{{ r.parent }}"{% endif %}{% if r.is_custom %} data-custom="1"{% endif %}>
<th class="perf-td-label" scope="row">
{% if is_admin %}<span class="perf-drag" title="끌어서 순서 변경" aria-hidden="true">⠿</span>{% endif %}
{% if r.parent %}<span class="perf-child-mark" aria-hidden="true">└</span>{% endif %}{{ r.name }}{% if r.is_custom %} <span class="perf-pill" title="실적 설정에서 직접 추가한 쇼핑몰">직접 추가</span>{% endif %}
</th>
{% if is_admin %}
<td class="perf-center">
<label class="perf-switch" title="사용 여부">
@@ -85,17 +105,37 @@
<td class="perf-muted perf-nowrap" title="마지막 시도: {{ when(r.last_sync_at) }}">{{ when(r.last_success_sync_at) }}</td>
{% if is_admin %}
<td class="perf-nowrap">
{% if not r.manual_only %}
{% if r.is_custom %}
<select class="erp-input perf-group-sel" data-act-group title="그룹 — 그룹으로 묶으면 매출 실적에서 그룹 열이 하위 쇼핑몰 매출 합계">
<option value="">그룹 없음</option>
{% for g in groups %}<option value="{{ g.code }}"{% if r.parent == g.code %} selected{% endif %}>{{ g.name }}</option>{% endfor %}
</select>
<button type="button" class="erp-btn erp-btn-ghost erp-btn-sm" data-act="rename">이름 변경</button>
<button type="button" class="erp-btn erp-btn-ghost erp-btn-sm perf-del-btn" data-act="delete">삭제</button>
{% elif not r.manual_only %}
<button type="button" class="erp-btn erp-btn-outline erp-btn-sm" data-act="creds">설정</button>
<button type="button" class="erp-btn erp-btn-outline erp-btn-sm" data-act="test">연결 테스트</button>
{% endif %}
</td>
{% endif %}
</tr>
{% endif %}
{% endfor %}
</tbody>
{% endfor %}
</table>
</div>
{% if is_admin %}
<div class="perf-add-row">
<button type="button" class="erp-btn erp-btn-outline erp-btn-sm" id="perf-add-shop"
title="API 연동 없이 실적 일자별 표에 매출을 직접 입력하는 쇼핑몰을 추가">+ 쇼핑몰 추가(수동 입력)</button>
<button type="button" class="erp-btn erp-btn-outline erp-btn-sm" id="perf-add-group"
title="직접 추가한 쇼핑몰을 묶는 그룹 — 그룹 매출 = 하위 쇼핑몰 매출 합계">+ 그룹 추가</button>
<span class="perf-muted">⠿ 를 끌어 순서를 바꾸면 매출 실적 열 순서에 그대로 반영됩니다. 그룹은 직접 추가한 쇼핑몰만 묶을 수 있습니다.</span>
{% if not custom_ready %}<span class="perf-notice is-warn">쇼핑몰 직접 추가·그룹은 performance_db 마이그레이션 009
(scripts/sql/performance_db_009_custom_marketplaces.sql)을 적용해야 쓸 수 있습니다.</span>{% endif %}
</div>
{% endif %}
<p class="perf-foot perf-muted">
수수료율은 <b>적용 시작일</b>부터 반영되고, 그 전 실적은 예전 요율로 계산됩니다(과거 실적이 바뀌지 않음).
{% if is_admin %}상태에 마우스를 올리면 마지막 연결 테스트 시각과 최근 오류를 볼 수 있습니다.{% endif %}
@@ -219,4 +259,4 @@
</section>
{% endblock %}
{% block scripts %}<script src="/static/performance.js?v=20261021b" defer></script>{% endblock %}
{% block scripts %}<script src="/static/performance.js?v=20261022a" defer></script>{% endblock %}