diff --git a/app/modules/performance/CLAUDE.md b/app/modules/performance/CLAUDE.md index 30cfa33..94d6f60 100644 --- a/app/modules/performance/CLAUDE.md +++ b/app/modules/performance/CLAUDE.md @@ -23,7 +23,7 @@ ## 카페24 적립금 · 네이버 배송비·환불 (2026-10-19 규칙 변경) - **카페24** 매출 = 결제합계 − 적립금 사용, 환불 = 실제 + 예치금(적립금 환불 제외). raw `points`. 주문 내역 창 **적립금 사용** 칸·합계. -- **네이버** 매출 = 판매금액(총) + 배송비(raw `goods`·`ship` — 배송 묶음마다 `deliveryFeeAmount` 한 번, 할인 안 뺌 = 판매분석 배송비, 10/18 87,500 확인), 환불 = 클레임 완료일(`CLAIM_COMPLETED_DATETIME`) 조회의 취소·반품 완료 상품주문 −결제금액(`naver:{상품주문}-RF`, raw `refund`). 주문 내역 창 **배송비·환불금액** 칸·합계. +- **네이버** 매출 = 판매금액(총) + 배송비(raw `goods`·`ship` — 배송 묶음마다 `deliveryFeeAmount` 한 번, 할인 안 뺌 = 판매분석 배송비, 10/18 87,500 확인), 환불 = 클레임 완료일(`CLAIM_COMPLETED_DATETIME`) 조회의 취소·반품 완료 상품주문 −결제금액(`naver:{상품주문}-RF`, raw `refund`). 주문 내역 창 **판매금액**(배송비 뺀 raw `goods` — 저장 금액은 판매금액+배송비)·**배송비·환불금액** 칸·합계 + 맨 아래 "그날 매출 = 판매금액 + 배송비 − 환불". - 예전 규칙으로 받은 날은 [과거 매출 가져오기]로 다시 받아야 바뀜(최근 10일은 자동). 사용자 확인값 10/18: 카페24 적립금 16,820 · 네이버 배송비 87,500 · 환불 66,100 — 배포 뒤 대조. ## 매출 업데이트 diff --git a/app/modules/performance/db.py b/app/modules/performance/db.py index 4622f4a..57efedc 100644 --- a/app/modules/performance/db.py +++ b/app/modules/performance/db.py @@ -496,7 +496,8 @@ class PerformanceDBStore: " event_date, sales_date, product_name, option_name, quantity, amount, " " discount_amount, order_status, is_sample, " # 주문 내역 칸(2026-10-19) — 카페24 적립금(결제 +, 환불 −) · 네이버 배송비 · 네이버 환불금액(raw_data 의 숫자만) - " raw_data ->> 'points' AS points, raw_data ->> 'ship' AS ship, raw_data ->> 'refund' AS refund " + " raw_data ->> 'points' AS points, raw_data ->> 'ship' AS ship, raw_data ->> 'refund' AS refund, " + " raw_data ->> 'goods' AS goods " # 네이버 판매금액(배송비 뺀 값) — 주문 내역 '판매금액' 칸 "FROM perf_sales_events WHERE marketplace_code = %s AND sales_date BETWEEN %s AND %s " "ORDER BY sales_date, external_order_id, event_type LIMIT %s", (code, start, end, limit), @@ -504,7 +505,7 @@ class PerformanceDBStore: out = [] for r in rows: row = {k: _iso(v) for k, v in r.items()} - for k in ("points", "ship", "refund"): + for k in ("points", "ship", "refund", "goods"): try: row[k] = int(round(float(row[k]))) if row.get(k) not in (None, "") else None except (TypeError, ValueError): diff --git a/app/modules/performance/templates/performance/ads.html b/app/modules/performance/templates/performance/ads.html index bb6b0c7..bf0e758 100644 --- a/app/modules/performance/templates/performance/ads.html +++ b/app/modules/performance/templates/performance/ads.html @@ -224,4 +224,4 @@ } | tojson }} {% endblock %} -{% block scripts %}{% endblock %} +{% block scripts %}{% endblock %} diff --git a/app/modules/performance/templates/performance/index.html b/app/modules/performance/templates/performance/index.html index 02e255a..940a9dd 100644 --- a/app/modules/performance/templates/performance/index.html +++ b/app/modules/performance/templates/performance/index.html @@ -267,4 +267,4 @@ } | tojson }} {% endblock %} -{% block scripts %}{% endblock %} +{% block scripts %}{% endblock %} diff --git a/app/modules/performance/templates/performance/settings.html b/app/modules/performance/templates/performance/settings.html index 62919d2..0d402d8 100644 --- a/app/modules/performance/templates/performance/settings.html +++ b/app/modules/performance/templates/performance/settings.html @@ -219,4 +219,4 @@ {% endblock %} -{% block scripts %}{% endblock %} +{% block scripts %}{% endblock %} diff --git a/app/static/performance.js b/app/static/performance.js index 9c84edd..48711b5 100644 --- a/app/static/performance.js +++ b/app/static/performance.js @@ -674,10 +674,14 @@ const EXTRA = { cafe24: [{ key: "points", label: "적립금 사용" }], naver: [{ key: "ship", label: "배송비" }, { key: "refund", label: "환불금액" }] }[code] || []; const xsum = EXTRA.map(function () { return { plus: 0, minus: 0 }; }); - let sum = 0, sales = 0, minus = 0; + // 네이버 금액 칸 = 판매금액(배송비 뺀 값, raw goods) — 저장 금액은 판매금액 + 배송비라 배송비 칸과 겹쳐 보이지 않게(2026-10-19) + const goodsOf = function (r) { return code === "naver" && r.goods != null ? r.goods : r.amount; }; + let sum = 0, sales = 0, minus = 0, total = 0; const body = rows.map(function (r) { - sum += r.amount; - if (r.amount >= 0) sales += r.amount; else minus += r.amount; + const shown = goodsOf(r); + sum += shown; + total += r.amount; + if (shown >= 0) sales += shown; else minus += shown; const xcells = EXTRA.map(function (x, k) { const v = r[x.key]; if (v == null || v === 0) return ''; @@ -690,14 +694,14 @@ "" + esc(r.external_order_id) + "" + '' + esc(r.product_name) + (r.option_name ? " " + esc(r.option_name) + "" : "") + "" + '' + esc(r.quantity) + "" + - '' + fmt(r.amount) + "" + xcells + + '' + fmt(shown) + "" + xcells + "" + esc(r.order_date || "") + "" + esc(r.payment_date || "") + "" + "" + esc(r.order_status) + ""; }).join(""); m.body.innerHTML = '
' + '' + - '' + + '" + EXTRA.map(function (x) { return '"; }).join("") + '' + '' + body + @@ -708,11 +712,14 @@ return '"; }).join("") + - '
매출일구분주문번호상품명수량금액상품명수량' + (code === "naver" ? "판매금액" : "금액") + "' + esc(x.label) + "주문일결제일상태
' + fmt(s.plus || s.minus ? (s.plus || s.minus) : 0) + "" + (s.plus && s.minus ? '
환불 ' + fmt(s.minus) + "
" : "") + "
' + + '' + + (code === "naver" ? '' + + "그날 매출 = 판매금액 " + fmt(sales) + " + 배송비 " + fmt(xsum[0].plus) + " − 환불 " + fmt(xsum[1].plus) + " = " + fmt(total) + "원" : "") + + "" + (res.truncated ? '

처음 500건만 표시합니다.

' : "") + '

수수료는 일·쇼핑몰 단위로 계산되어 주문별로는 표시하지 않습니다.' + (code === "cafe24" ? " 금액은 적립금 사용분을 뺀 값입니다(환불도 적립금으로 돌려준 금액은 뺌)." : "") + - (code === "naver" ? " 결제 금액은 판매금액 + 배송비, 환불은 환불된 날에 빠집니다." : "") + + (code === "naver" ? " 판매금액은 배송비를 뺀 상품 결제금액입니다. 그날 매출 = 판매금액 + 배송비 − 환불(환불된 날)." : "") + " 적립금·배송비 칸이 비어 있으면 규칙을 바꾸기 전에 받은 자료입니다 — 실적 설정 → 과거 매출 가져오기로 그 기간을 다시 받으세요.

"; } catch (err) { m.body.innerHTML = '

' + esc(err.message) + "

";