feat(performance): 쿠팡(윙) 광고비도 파일 업로드(로켓과 같은 광고 보고서 양식)
- 업로드 창 채널 = 쿠팡(윙) · 쿠팡(로켓), 1열 날짜 · 19열 청구금액(+부가가치세) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
- 화면 날짜 칸을 눌러 직접 입력(source=manual), 업로드 파일로 한 번에 입력(source=upload, 같은 날 덮어씀).
|
||||
- 구글·메타는 지금은 직접 입력만(API 연동은 다음 단계).
|
||||
|
||||
쿠팡(로켓) 업로드 양식(2026-10-13 사용자 제공 — 쿠팡 광고 보고서 CSV/엑셀):
|
||||
쿠팡(윙)·쿠팡(로켓) 업로드 양식(2026-10-13·14 사용자 제공 — 둘 다 같은 쿠팡 광고 보고서 CSV/엑셀):
|
||||
1행 머리글, 1열 = 날짜("2026년 10월 01일"), 19열 = 청구금액(+부가가치세) → 그날 광고비.
|
||||
날짜 줄 아래 캠페인 줄(1열 빈 칸)과 맨 위 "전체" 합계 줄은 건너뛴다.
|
||||
|
||||
@@ -129,11 +129,10 @@ def parse_coupang_rocket(content: bytes, *, today: date, filename: str = "") ->
|
||||
return res
|
||||
|
||||
|
||||
# 업로드 양식이 정해진 채널 → 파일 읽기 함수
|
||||
PARSERS: dict[str, Callable[..., ParseResult]] = {"coupang_rocket": parse_coupang_rocket}
|
||||
UPLOAD_HELP = {
|
||||
"coupang_rocket": "쿠팡 광고 보고서(CSV 또는 엑셀) — 1열 날짜, 19열 청구금액(+부가가치세)을 그날 광고비로 넣습니다.",
|
||||
}
|
||||
# 업로드 양식이 정해진 채널 → 파일 읽기 함수(채널 순서 = 업로드 창 선택 순서). 쿠팡(윙)도 로켓과 같은 양식(2026-10-14).
|
||||
PARSERS: dict[str, Callable[..., ParseResult]] = {"coupang_wing": parse_coupang_rocket, "coupang_rocket": parse_coupang_rocket}
|
||||
_COUPANG_HELP = "쿠팡 광고 보고서(CSV 또는 엑셀) — 1열 날짜, 19열 청구금액(+부가가치세)을 그날 광고비로 넣습니다."
|
||||
UPLOAD_HELP = {"coupang_wing": _COUPANG_HELP, "coupang_rocket": _COUPANG_HELP}
|
||||
|
||||
|
||||
# ════════════════════════════════════════════════════════════
|
||||
|
||||
@@ -108,7 +108,7 @@
|
||||
</div>
|
||||
{% if period_kind != 'year' %}
|
||||
<p class="perf-muted perf-manual-help">날짜 칸을 눌러 그날 <b>광고비</b>를 직접 입력합니다 — Enter 저장 후 아래 칸, Esc 취소, 비우고 저장하면 지움.
|
||||
파란 숫자 = 직접 입력, 주황 숫자 = 파일 업로드 값. 쿠팡(로켓)은 [파일 업로드]로 광고 보고서를 올리면 날짜별로 한 번에 들어갑니다.</p>
|
||||
파란 숫자 = 직접 입력, 주황 숫자 = 파일 업로드 값. 쿠팡(윙)·쿠팡(로켓)은 [파일 업로드]로 광고 보고서를 올리면 날짜별로 한 번에 들어갑니다.</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
@@ -182,8 +182,8 @@
|
||||
</div>
|
||||
|
||||
<p class="perf-foot perf-muted">
|
||||
광고비 기준: 쿠팡(로켓)은 광고 보고서의 청구금액(+부가가치세). 매출 대비 광고비 = 같은 기간 광고비 ÷ 매출 실적 총매출.
|
||||
구글·메타·쿠팡(윙)은 지금은 직접 입력합니다.
|
||||
광고비 기준: 쿠팡(윙)·쿠팡(로켓)은 광고 보고서의 청구금액(+부가가치세). 매출 대비 광고비 = 같은 기간 광고비 ÷ 매출 실적 총매출.
|
||||
구글·메타는 지금은 직접 입력합니다.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ def test_ad_dashboard_month():
|
||||
assert k["spend"]["value"] == 270000 and k["ratio"]["pct"] == 10.0 # 270,000 ÷ 2,700,000
|
||||
assert k["ytd"]["value"] == 370000 and k["mtd"]["value"] == 270000
|
||||
assert ctx["upload_cells"] == ["2026-10-01|coupang_rocket"]
|
||||
assert [c["code"] for c in ctx["upload_channels"]] == ["coupang_rocket"]
|
||||
assert [c["code"] for c in ctx["upload_channels"]] == ["coupang_wing", "coupang_rocket"]
|
||||
day1 = next(r for r in ctx["table"] if r.get("date") == "2026-10-01")
|
||||
assert day1["cells"]["coupang_rocket"]["gross"] == 220000 and day1["total"]["gross"] == 220000
|
||||
assert ctx["table"][-1]["kind"] == "total" and ctx["table"][-1]["total"]["gross"] == 270000
|
||||
@@ -147,6 +147,10 @@ def test_ad_spend_endpoints(monkeypatch):
|
||||
assert r.json()["saved"] == 3 and r.json()["total"] == 220000 + 216697 + 220231 and r.json()["to"] == "2026-10-12"
|
||||
assert store.saved[0] == ("coupang_rocket", date(2026, 10, 1), 220000, "upload")
|
||||
store.saved.clear()
|
||||
r = client.post("/performance/api/ad-spend/upload?channel=coupang_wing", files={"file": ("w.csv", ROCKET_CSV.encode("utf-8-sig"))})
|
||||
assert r.status_code == 200 and r.json()["name"] == "쿠팡(윙)" # 윙도 같은 양식
|
||||
assert store.saved[0] == ("coupang_wing", date(2026, 10, 1), 220000, "upload") and len(store.saved) == 3
|
||||
store.saved.clear()
|
||||
bad = ROCKET_CSV + "2026년 10월 06일,RETAIL,,,,,,,,,,,1,0,1,1,1,0,9\n"
|
||||
r = client.post("/performance/api/ad-spend/upload?channel=coupang_rocket", files={"file": ("r.csv", bad.encode("utf-8"))})
|
||||
assert r.status_code == 400 and r.json()["errors"] and store.saved == []
|
||||
|
||||
@@ -347,9 +347,9 @@
|
||||
저장 `perf_ad_spend`(마이그레이션 005 — 채널 × 날짜 하나에 금액, `source` manual/upload/api), 미적용이면 화면에 안내·API 503.
|
||||
- 날짜 칸을 눌러 직접 입력(`PUT /api/ad-spend/{channel}/{day}`, 비우면 지움, 오늘까지) — 파란 숫자. 매출 수동 입력과 같은 JS(`MANUAL_API`).
|
||||
- [파일 업로드](`POST /api/ad-spend/upload?channel=`) — 양식이 정해진 채널만(`ad_spend.PARSERS`). 파일에 있는 날만 덮어쓰고(주황 숫자),
|
||||
잘못된 줄이 하나라도 있으면 아무것도 저장하지 않는다. **쿠팡(로켓)** = 쿠팡 광고 보고서 CSV(UTF-8/CP949)·엑셀:
|
||||
잘못된 줄이 하나라도 있으면 아무것도 저장하지 않는다. **쿠팡(윙)·쿠팡(로켓)**(같은 양식, 윙은 2026-10-14) = 쿠팡 광고 보고서 CSV(UTF-8/CP949)·엑셀:
|
||||
1열 날짜(`2026년 10월 01일`), 19열 청구금액(+부가가치세). "전체" 합계 줄·머리글·캠페인 줄(1열 빈 칸)은 건너뜀.
|
||||
- 쿠팡(윙)·구글·메타 업로드 양식/API 는 아직 — 지금은 직접 입력.
|
||||
- 구글·메타 업로드 양식/API 는 아직 — 지금은 직접 입력.
|
||||
- **대시보드** `/performance/?period=day|week|month|year|custom&d=&from=&to=&m=<쇼핑몰>…`
|
||||
기간 버튼(오늘/이번주/이번달/올해/직접선택) + 이전/다음, 쇼핑몰 필터, KPI 5개, 일자×쇼핑몰 표(주간합계·기간합계, 연간은 월 행),
|
||||
[총매출|수수료|수수료 차감 매출] 전환(서버가 세 값을 다 그리고 CSS 로 전환, 선택은 localStorage), 일별 추이·쇼핑몰 비중(SVG),
|
||||
|
||||
@@ -171,7 +171,9 @@ function gross(td) { return td.querySelector(".v-gross").textContent.trim(); }
|
||||
e.d.getElementById("perf-ad-upload").click();
|
||||
const modal = e.d.querySelector(".perf-modal");
|
||||
const opts = Array.from(modal.querySelectorAll(".perf-ad-channel option")).map(function (o) { return o.value; });
|
||||
check("[업로드] 채널 선택 = 양식이 정해진 쿠팡(로켓)", opts.join(",") === "coupang_rocket", opts);
|
||||
check("[업로드] 채널 선택 = 양식이 정해진 쿠팡(윙)·쿠팡(로켓)", opts.join(",") === "coupang_wing,coupang_rocket", opts);
|
||||
modal.querySelector(".perf-ad-channel").value = "coupang_rocket";
|
||||
modal.querySelector(".perf-ad-channel").dispatchEvent(new e.w.Event("change"));
|
||||
check("[업로드] 양식 안내(19열 청구금액)", /19열/.test(modal.querySelector(".perf-ad-help").textContent));
|
||||
const fileInput = modal.querySelector(".perf-upload-file");
|
||||
const f = new e.w.File(["날짜"], "rocket.csv", { type: "text/csv" });
|
||||
|
||||
Reference in New Issue
Block a user