Merge branch 'feat/perf-cafe24-ex-groupbuy'
This commit is contained in:
@@ -64,6 +64,8 @@
|
||||
직접 추가 쇼핑몰만 그룹 select 로 묶음, 이름 변경·삭제(삭제 = 그 쇼핑몰 수동 입력·수수료도). 매출 실적 표 그룹 열 = 보이는 하위 합계(일 합계엔 안 더함),
|
||||
▾/▸ 하위 열 접기(localStorage). ⠿ 드래그 → `PUT /api/marketplace-order` → `sort_order`, 화면 순서는 `dashboard.ordered_marketplaces`
|
||||
(그룹 바로 뒤 하위) 한 곳. 상세 `docs/PERFORMANCE_MODULE.md` "직접 추가 쇼핑몰·그룹".
|
||||
- **카페24(공구 제외) 열**(2026-10-30) — 직접 추가 쇼핑몰 "카페24 공동구매"(이름으로 찾음, 띄어쓰기 무시) 바로 오른쪽에 카페24 − 공동구매 계산 열
|
||||
(`dashboard._cafe24_ex_gb_column`, kind `diff`, 표 열만 — 일 합계엔 안 더함, 클릭·메모 없음). 상세 `docs/PERFORMANCE_MODULE.md` "직접 추가 쇼핑몰·그룹".
|
||||
- **매출 실적 표 모양(2026-10-22)** — `table.perf-autofit`(매출 탭만, 모든 기간 같음): 표가 100% 로 늘지 않고 **열 너비 = 내용 길이**, 날짜 열은 고정 210px 대신 자동 +
|
||||
**가로 스크롤해도 고정**(sticky left, 오른쪽 그림자). 그룹 열 = 진한 보라 머리·왼쪽 묶음 선, 하위 열 = 옅은 보라 머리(위 띠)·옅은 칸, 마지막 하위(`is-glast`, 접히면 그룹 열 `is-gclosed`) = 오른쪽 선.
|
||||
접기 단추 = 22px ⊟/⊞(SVG, 세로 막대가 돌아 바뀜). 접기·펴기 애니메이션 = 하위 칸 내용 `.perf-gc` 너비·칸 여백·투명도 260ms(`setGroup(code, fold, animate)`,
|
||||
|
||||
@@ -57,6 +57,28 @@ def _group_columns(store_rows: Sequence[Mapping[str, Any]], codes: Sequence[str]
|
||||
return cols, members
|
||||
|
||||
|
||||
# 카페24 − 카페24 공동구매 열(2026-10-30) — 직접 추가 쇼핑몰 "카페24 공동구매" 바로 오른쪽, 표 열만(일 합계·그래프·누적엔 안 더함).
|
||||
# shortcut: 공동구매 쇼핑몰은 이름(띄어쓰기 무시)으로 찾는다 — 설정에서 이름을 바꾸면 이 열이 사라진다, 자주 바뀌면 설정 값으로.
|
||||
CAFE24_GB_NAME = "카페24공동구매"
|
||||
CAFE24_EX_GB = "cafe24_ex_gb"
|
||||
|
||||
|
||||
def _cafe24_ex_gb_column(markets: Sequence[Mapping[str, Any]], codes: Sequence[str], cols: list[dict[str, Any]],
|
||||
names: dict[str, str], short: dict[str, str], table: list[dict[str, Any]]) -> None:
|
||||
"""카페24·공동구매 둘 다 보일 때만 공동구매 열 뒤에 차이 열(kind diff — 공동구매가 그룹 하위면 같은 그룹으로 접힘)."""
|
||||
gb = next((m["code"] for m in markets
|
||||
if m["name"].replace(" ", "") == CAFE24_GB_NAME and m["code"] in codes), None)
|
||||
if gb is None or "cafe24" not in codes:
|
||||
return
|
||||
i = next(i for i, col in enumerate(cols) if col["code"] == gb)
|
||||
cols.insert(i + 1, {"code": CAFE24_EX_GB, "kind": "diff", "group": cols[i]["group"]})
|
||||
names[CAFE24_EX_GB] = f"{names['cafe24']} − {names[gb]}"
|
||||
short[CAFE24_EX_GB] = f"{short['cafe24']}(공구 제외)"
|
||||
for r in table:
|
||||
a, b = r["cells"]["cafe24"], r["cells"][gb]
|
||||
r["cells"][CAFE24_EX_GB] = {k: a[k] - b[k] for k in ("gross", "commission", "net")}
|
||||
|
||||
|
||||
def display_status(marketplace: Mapping[str, Any], status_row: Mapping[str, Any] | None,
|
||||
configured: bool) -> str:
|
||||
if not marketplace.get("enabled"):
|
||||
@@ -242,6 +264,7 @@ def build_dashboard(store: Any, *, kind: str, anchor: date, today: date,
|
||||
for g, members in group_members.items():
|
||||
r["cells"][g] = calc.total(calc.Money(gross=r["cells"][c]["gross"], commission=r["cells"][c]["commission"])
|
||||
for c in members).as_dict()
|
||||
_cafe24_ex_gb_column(markets, codes, cols, names, short, table)
|
||||
|
||||
def url(kind: str, anchor_d: date | None = None, start: date | None = None, end: date | None = None) -> str:
|
||||
if kind == "custom":
|
||||
|
||||
@@ -145,9 +145,9 @@
|
||||
{#- 그룹(2026-10-22) — 그룹 열 = 보이는 하위 쇼핑몰 합계, ⊟/⊞ 로 하위 열 접기/펴기(이 브라우저에 기억, 펼치고 접을 때 애니메이션).
|
||||
하위 열은 .perf-gc 로 내용을 감싼다 — 접을 때 그 너비를 0 으로 줄여 열이 부드럽게 닫힌다. is-glast = 그룹의 마지막 하위 열(오른쪽 묶음 선) -#}
|
||||
{% for col in cols %}{% set c = col.code %}
|
||||
{% set glast = col.kind == 'child' and (not loop.nextitem or loop.nextitem.group != col.group) %}
|
||||
{% set sub = col.kind == 'child' or (col.kind == 'diff' and col.group) %}{% set glast = sub and (not loop.nextitem or loop.nextitem.group != col.group) %}
|
||||
{% if col.kind == 'group' %}<th class="perf-th-group" data-col="{{ c }}" data-group-head="{{ c }}" title="{{ names[c] }} — 하위 쇼핑몰 {{ group_members[c] | length }}곳 매출 합계"><span class="perf-gh"><button type="button" class="perf-gtoggle" data-group-toggle="{{ c }}" aria-expanded="true" aria-label="{{ short_names[c] }} 하위 쇼핑몰 접기" title="하위 쇼핑몰 접기/펴기"><svg viewBox="0 0 18 18" width="18" height="18" aria-hidden="true"><rect class="g-box" x="1" y="1" width="16" height="16" rx="4"/><path class="g-h" d="M5 9h8"/><path class="g-v" d="M9 5v8"/></svg></button><span>{{ short_names[c] }}</span></span></th>
|
||||
{% else %}<th data-col="{{ c }}"{% if col.kind == 'child' %} class="perf-th-child{% if glast %} is-glast{% endif %}" data-group-child="{{ col.group }}"{% endif %} title="{{ names[c] }}{% if c in manual_codes %} — 수동 입력(날짜 칸을 눌러 입력){% endif %}">{% if col.kind == 'child' %}<div class="perf-gc">{% endif %}{{ short_names[c] }}{% if c in manual_codes %} <span class="perf-manual-mark" aria-label="수동 입력">✎</span>{% endif %}{% if col.kind == 'child' %}</div>{% endif %}</th>{% endif %}
|
||||
{% else %}<th data-col="{{ c }}"{% if sub %} class="perf-th-child{% if glast %} is-glast{% endif %}" data-group-child="{{ col.group }}"{% endif %} title="{{ names[c] }}{% if c in manual_codes %} — 수동 입력(날짜 칸을 눌러 입력){% endif %}">{% if sub %}<div class="perf-gc">{% endif %}{{ short_names[c] }}{% if c in manual_codes %} <span class="perf-manual-mark" aria-label="수동 입력">✎</span>{% endif %}{% if sub %}</div>{% endif %}</th>{% endif %}
|
||||
{% endfor %}
|
||||
<th class="perf-th-total" data-col="total">{% if period_kind == 'year' %}월 합계{% else %}일 합계{% endif %}</th>
|
||||
</tr>
|
||||
@@ -161,11 +161,13 @@
|
||||
{% for col in cols %}
|
||||
{% set c = col.code %}
|
||||
{% set m = r.cells[c] %}
|
||||
{% set glast = col.kind == 'child' and (not loop.nextitem or loop.nextitem.group != col.group) %}
|
||||
{% set gattr %}{% if col.kind == 'child' %} data-group-child="{{ col.group }}"{% endif %}{% endset %}
|
||||
{% set gc0 %}{% if col.kind == 'child' %}<div class="perf-gc">{% endif %}{% endset %}{% set gc1 %}{% if col.kind == 'child' %}</div>{% endif %}{% endset %}
|
||||
{% set sub = col.kind == 'child' or (col.kind == 'diff' and col.group) %}{% set glast = sub and (not loop.nextitem or loop.nextitem.group != col.group) %}
|
||||
{% set gattr %}{% if sub %} data-group-child="{{ col.group }}"{% endif %}{% endset %}
|
||||
{% set gc0 %}{% if sub %}<div class="perf-gc">{% endif %}{% endset %}{% set gc1 %}{% if sub %}</div>{% endif %}{% endset %}
|
||||
{% if col.kind == 'group' %}
|
||||
<td class="perf-num perf-td-group" data-group-cell="{{ c }}">{{ m3(m) }}</td>
|
||||
{% elif col.kind == 'diff' %}{#- 카페24 − 카페24 공동구매(2026-10-30, dashboard._cafe24_ex_gb_column) — 계산 열이라 클릭·메모 없음 -#}
|
||||
<td class="perf-num{% if glast %} is-glast{% endif %}"{{ gattr }}>{{ gc0 }}{{ m3(m) }}{{ gc1 }}</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) %}
|
||||
|
||||
@@ -221,3 +221,35 @@ def test_dashboard_page_renders_group_header_and_child_cells(client):
|
||||
body = html.split("<tbody>", 1)[1].split("</tbody>", 1)[0]
|
||||
assert 'data-group-cell="group_x"' in body and "150,000" in body
|
||||
assert 'data-group-child="group_x" data-manual-code="custom_a" data-date="2026-10-05"' in body
|
||||
|
||||
|
||||
def test_cafe24_minus_groupbuy_column():
|
||||
"""'카페24 공동구매' 바로 오른쪽 = 카페24 − 공동구매(2026-10-30). 표 열만 — 일 합계엔 안 더함."""
|
||||
st = _Store()
|
||||
st._find("custom_c")["name"] = "카페24 공동구매"
|
||||
st.manual[(date(2026, 10, 5), "custom_c")] = 300_000
|
||||
ctx = dashboard.build_dashboard(st, kind="week", anchor=TODAY, today=TODAY)
|
||||
assert [c["code"] for c in ctx["cols"]][-2:] == ["custom_c", dashboard.CAFE24_EX_GB]
|
||||
day5 = next(r for r in ctx["table"] if r.get("date") == "2026-10-05")
|
||||
assert day5["cells"][dashboard.CAFE24_EX_GB] == {"gross": 700_000, "commission": 0, "net": 700_000}
|
||||
assert day5["total"]["gross"] == 1_450_000 # 카페24 + 매장 150,000 + 공동구매 300,000
|
||||
week = next(r for r in ctx["table"] if r["kind"] == "week")
|
||||
assert week["cells"][dashboard.CAFE24_EX_GB]["gross"] == 700_000
|
||||
|
||||
# 카페24 를 고르지 않으면 열 없음, 공동구매가 그룹 하위면 같은 그룹으로 접힘
|
||||
ctx = dashboard.build_dashboard(st, kind="week", anchor=TODAY, today=TODAY, selected=["custom_c"])
|
||||
assert dashboard.CAFE24_EX_GB not in [c["code"] for c in ctx["cols"]]
|
||||
st._find("custom_c")["parent_code"] = "group_x"
|
||||
ctx = dashboard.build_dashboard(st, kind="week", anchor=TODAY, today=TODAY)
|
||||
assert ctx["cols"][-1] == {"code": dashboard.CAFE24_EX_GB, "kind": "diff", "group": "group_x"}
|
||||
|
||||
|
||||
def test_dashboard_page_renders_cafe24_minus_groupbuy(client):
|
||||
client.store._find("custom_c")["name"] = "카페24 공동구매"
|
||||
client.store.manual[(date(2026, 10, 5), "custom_c")] = 300_000
|
||||
html = client.get("/performance/?period=week&d=2026-10-07").text
|
||||
head = html.split("<thead>", 1)[1].split("</thead>", 1)[0]
|
||||
assert head.index('data-col="custom_c"') < head.index(f'data-col="{dashboard.CAFE24_EX_GB}"')
|
||||
assert "카페24(공구 제외)" in head
|
||||
body = html.split("<tbody>", 1)[1].split("</tbody>", 1)[0]
|
||||
assert "700,000" in body
|
||||
|
||||
@@ -284,6 +284,10 @@
|
||||
10, 20, … 다시 매김(`reorder_marketplaces`). 드래그 단위는 tbody(그룹 없는 행 하나, 또는 그룹 + 하위) — 하위 쇼핑몰은 그 그룹 안에서만.
|
||||
화면 순서 = `dashboard.ordered_marketplaces`(sort_order 순, 그룹 바로 뒤에 하위) — 설정 표·매출 실적 열·필터 공통. 설정 표도 예전
|
||||
`registry` 순서 대신 이 순서(009 없어도 됨).
|
||||
- **카페24(공구 제외) 열**(2026-10-30) — 직접 추가 쇼핑몰 이름이 "카페24 공동구매"(띄어쓰기 무시)면 그 열 바로 오른쪽에
|
||||
카페24 − 카페24 공동구매(총매출·수수료·차감 매출 각각) 계산 열(`dashboard._cafe24_ex_gb_column`, 열 코드 `cafe24_ex_gb`, kind `diff`).
|
||||
카페24·공동구매 둘 다 보일 때만, 표 열만(일 합계·KPI·그래프엔 안 더함), 클릭·메모 없음. 공동구매가 그룹 하위면 같은 그룹으로 접힘.
|
||||
이름으로 찾으므로 설정에서 이름을 바꾸면 열이 사라진다.
|
||||
- 테스트: `app/modules/performance/tests/test_custom_groups.py`, 화면 `tests/js/perf_groups.browser.test.js`(render_performance.py 의 `perf_*_groups.html`).
|
||||
|
||||
### 연동 단계 체크리스트(쇼핑몰마다)
|
||||
|
||||
Reference in New Issue
Block a user