feat(project,performance): 보드 카드 끌기 실시간 미리보기 · 회의록 항목 끌어 옮기기·검정 테두리 · 실적 매출 단위·광고비(ROAS%) 줄
[프로젝트]
- 보드 카드 끌기: 기울어진 끄는 모양 + 점선 자리 표시가 카드 사이로 FLIP 애니메이션, 놓은 자리 그대로(다른 섹션도 순서 저장)
- 컬럼 dragenter 도 허용 — 자리 표시가 들어온 직후 놓을 때 drop 이 거부되던 문제
- 끄는 동안 실시간 동기화가 보드를 다시 그리지 않음
- 주간 회의록 항목 칸을 끌어 위아래로 이동(묶인 줄·세로 병합째, 같은 구역) — POST meeting-items/{id}/move-to
- 주간 회의록 표 테두리 모두 검정
- 도움말·모듈 문서 갱신
[실적]
- 설정의 쇼핑몰 원본 데이터 확인·카페24 매출 대조·일별 한 번에 비교 카드 삭제(서버 API 는 유지)
- 보기 설정: 매출 단위 원·천원·백만원(이 브라우저 쿠키 perf_unit)
- 매출 실적 표 매출 칸 아래 광고비(ROAS%) 줄(광고비 색), 카페24 는 구글·메타 두 줄
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,7 +6,7 @@ HTTP 와 무관하다(store 만 주입). 라우터는 파라미터 파싱·권
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import date, timedelta
|
||||
from decimal import Decimal
|
||||
from decimal import ROUND_HALF_UP, Decimal
|
||||
from typing import Any, Mapping, Sequence
|
||||
|
||||
from . import calc
|
||||
@@ -32,6 +32,90 @@ def display_status(marketplace: Mapping[str, Any], status_row: Mapping[str, Any]
|
||||
return (status_row or {}).get("status") or "unknown"
|
||||
|
||||
|
||||
# 매출 단위(2026-10-19, 실적 설정 "보기 설정" — 이 브라우저 쿠키 perf_unit) — (나누는 수, 소수 자리, 단위 이름)
|
||||
UNITS: dict[str, tuple[int, int, str]] = {"won": (1, 0, "원"), "thousand": (1000, 0, "천원"), "million": (1_000_000, 1, "백만원")}
|
||||
UNIT_COOKIE = "perf_unit"
|
||||
|
||||
|
||||
def normalize_unit(value: Any) -> str:
|
||||
return value if value in UNITS else "won"
|
||||
|
||||
|
||||
def amount_text(value: Any, unit: str = "won") -> str:
|
||||
"""금액 → 화면 글자(쉼표). 천원은 정수, 백만원은 소수 한 자리(반올림)."""
|
||||
div, places, _ = UNITS[normalize_unit(unit)]
|
||||
if div == 1:
|
||||
return f"{int(value):,}"
|
||||
q = (Decimal(int(value)) / div).quantize(Decimal(1).scaleb(-places), rounding=ROUND_HALF_UP)
|
||||
return f"{q:,.{places}f}"
|
||||
|
||||
|
||||
def _ad_lines(store: Any, table: list[dict[str, Any]], codes: Sequence[str], cells: Mapping[Any, Any],
|
||||
period: Any, q_start: date, q_end: date) -> None:
|
||||
"""매출 칸 아래 광고비(ROAS%) — 광고비 화면과 같은 값(ROAS = 그 쇼핑몰 매출 ÷ 광고비, 구글·메타·네이버는 보고서 ROAS).
|
||||
카페24 = 구글·메타 두 줄. 행마다 r["ads"][쇼핑몰] = [{label, amount, roas}], r["ads_total"] = 보이는 쇼핑몰 광고비 합(ROAS = 매출 합 ÷ 광고비 합).
|
||||
광고비 표(005)가 없거나 읽기 실패면 줄 없음."""
|
||||
from . import ad_spend # noqa: WPS433
|
||||
|
||||
by_code = sales_ad_channels()
|
||||
want = {ch for c in codes for ch, _ in by_code.get(c, ())}
|
||||
for r in table:
|
||||
r["ads"], r["ads_total"] = {}, None
|
||||
if not want:
|
||||
return
|
||||
try:
|
||||
amounts, _ = store.ad_amounts(q_start, q_end)
|
||||
reader = getattr(store, "ad_roas", None)
|
||||
roas_map = reader(q_start, q_end) if reader else {}
|
||||
except Exception: # noqa: BLE001 — 광고비 표가 없어도 매출 화면은 그대로
|
||||
return
|
||||
spend_by: dict[str, list[tuple[date, int]]] = {}
|
||||
for (d, ch), v in amounts.items():
|
||||
if ch in want and v:
|
||||
spend_by.setdefault(ch, []).append((d, int(v)))
|
||||
|
||||
sales_by: dict[str, list[tuple[date, int]]] = {}
|
||||
for (d, c), m in cells.items():
|
||||
sales_by.setdefault(c, []).append((d, int(m.gross)))
|
||||
|
||||
def spend(ch: str, s: date, e: date) -> int:
|
||||
return sum(v for d, v in spend_by.get(ch, ()) if s <= d <= e)
|
||||
|
||||
def sales(c: str, s: date, e: date) -> int:
|
||||
return sum(v for d, v in sales_by.get(c, ()) if s <= d <= e)
|
||||
|
||||
for r in table:
|
||||
s = date.fromisoformat(r["from"]) if r.get("from") else period.start
|
||||
e = date.fromisoformat(r["to"]) if r.get("to") else period.end
|
||||
tot_spend = tot_sales = 0
|
||||
for c in codes:
|
||||
lines = []
|
||||
for ch, label in by_code.get(c, ()):
|
||||
amt = spend(ch, s, e)
|
||||
if not amt:
|
||||
continue
|
||||
rs = ad_spend.channel_roas(ch, lambda m: sales(m, s, e), amt,
|
||||
lambda f: ad_spend.file_roas(f, roas_map, amounts, s, e))
|
||||
lines.append({"label": label, "amount": amt, "roas": rs})
|
||||
tot_spend += amt
|
||||
if lines:
|
||||
r["ads"][c] = lines
|
||||
tot_sales += sales(c, s, e)
|
||||
if tot_spend:
|
||||
r["ads_total"] = {"amount": tot_spend, "roas": ad_spend.roas(tot_sales, tot_spend)}
|
||||
|
||||
|
||||
def sales_ad_channels() -> dict[str, tuple[tuple[str, str], ...]]:
|
||||
"""쇼핑몰(매출 코드) → 그 아래 보일 광고 채널 [(채널, 줄 이름)]. 카페24 = 구글·메타(자사몰 광고), 네이버 = 네이버 광고,
|
||||
나머지는 광고비 화면의 ROAS 매출 쇼핑몰(쿠팡(윙) 광고 → 쿠팡 매출)."""
|
||||
from . import ad_spend # noqa: WPS433
|
||||
|
||||
out: dict[str, tuple[tuple[str, str], ...]] = {"cafe24": (("google", "구글"), ("meta", "메타")), "naver": (("naver", ""),)}
|
||||
for ch, c in ad_spend.ROAS_SALES_CODE.items():
|
||||
out[c] = out.get(c, ()) + ((ch, ""),)
|
||||
return out
|
||||
|
||||
|
||||
def build_dashboard(store: Any, *, kind: str, anchor: date, today: date,
|
||||
custom_from: date | None = None, custom_to: date | None = None,
|
||||
selected: Sequence[str] = (), holidays: Mapping[str, str] | None = None,
|
||||
@@ -105,6 +189,8 @@ def build_dashboard(store: Any, *, kind: str, anchor: date, today: date,
|
||||
"error": (statuses.get(m["code"]) or {}).get("last_error", "")})
|
||||
|
||||
m_qs = "" if len(codes) == len(all_codes) else "".join(f"&m={c}" for c in codes)
|
||||
table = calc.main_table(period, codes, cells, today=today, holidays=holidays)
|
||||
_ad_lines(store, table, codes, cells, period, q_start, q_end)
|
||||
|
||||
def url(kind: str, anchor_d: date | None = None, start: date | None = None, end: date | None = None) -> str:
|
||||
if kind == "custom":
|
||||
@@ -144,7 +230,7 @@ def build_dashboard(store: Any, *, kind: str, anchor: date, today: date,
|
||||
"short_names": short,
|
||||
"selected_all": len(codes) == len(all_codes),
|
||||
"kpis": kpis,
|
||||
"table": calc.main_table(period, codes, cells, today=today, holidays=holidays),
|
||||
"table": table,
|
||||
"month": calc.month_summary(month_period.start.year, month_period.start.month, codes, cells),
|
||||
"year": calc.year_months(year_period.start.year, codes, cells, today=today),
|
||||
"chart_daily": calc.daily_series(period, codes, cells),
|
||||
|
||||
Reference in New Issue
Block a user