fix(performance): 네이버 주문 내역 금액 칸 = 배송비 뺀 판매금액 · 맨 아래 그날 매출 계산식

저장 금액(판매금액 + 배송비)을 그대로 보여 배송비 칸과 겹쳐 보이던 문제

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-19 16:56:25 +09:00
parent 962fed151a
commit 8c1cc3e7bb
6 changed files with 21 additions and 13 deletions
+14 -7
View File
@@ -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 '<td class="perf-num perf-ev-x"></td>';
@@ -690,14 +694,14 @@
"<td>" + esc(r.external_order_id) + "</td>" +
'<td class="perf-ev-name">' + esc(r.product_name) + (r.option_name ? " <span class='perf-muted'>" + esc(r.option_name) + "</span>" : "") + "</td>" +
'<td class="perf-num">' + esc(r.quantity) + "</td>" +
'<td class="perf-num">' + fmt(r.amount) + "</td>" + xcells +
'<td class="perf-num">' + fmt(shown) + "</td>" + xcells +
"<td>" + esc(r.order_date || "") + "</td><td>" + esc(r.payment_date || "") + "</td>" +
"<td>" + esc(r.order_status) + "</td></tr>";
}).join("");
m.body.innerHTML =
'<div class="perf-ev-wrap"><table class="perf-table perf-ev-table"><thead><tr>' +
'<th class="perf-th-label">매출일</th><th class="perf-th-label">구분</th><th class="perf-th-label">주문번호</th>' +
'<th class="perf-th-label perf-ev-name">상품명</th><th>수량</th><th>금액</th>' +
'<th class="perf-th-label perf-ev-name">상품명</th><th>수량</th><th>' + (code === "naver" ? "판매금액" : "금액") + "</th>" +
EXTRA.map(function (x) { return '<th class="perf-ev-x">' + esc(x.label) + "</th>"; }).join("") +
'<th class="perf-th-label">주문일</th>' +
'<th class="perf-th-label">결제일</th><th class="perf-th-label">상태</th></tr></thead><tbody>' + body +
@@ -708,11 +712,14 @@
return '<td class="perf-num perf-ev-x"><b>' + fmt(s.plus || s.minus ? (s.plus || s.minus) : 0) + "</b>" +
(s.plus && s.minus ? '<div class="perf-ev-xsub">환불 ' + fmt(s.minus) + "</div>" : "") + "</td>";
}).join("") +
'<td colspan="3"></td></tr></tfoot></table></div>' +
'<td colspan="3"></td></tr>' +
(code === "naver" ? '<tr class="perf-row-total perf-ev-grand"><th class="perf-td-label" colspan="' + (8 + EXTRA.length + 1) + '">' +
"그날 매출 = 판매금액 " + fmt(sales) + " + 배송비 " + fmt(xsum[0].plus) + " − 환불 " + fmt(xsum[1].plus) + " = <b>" + fmt(total) + "</b>원</th></tr>" : "") +
"</tfoot></table></div>" +
(res.truncated ? '<p class="perf-muted">처음 500건만 표시합니다.</p>' : "") +
'<p class="perf-muted">수수료는 일·쇼핑몰 단위로 계산되어 주문별로는 표시하지 않습니다.' +
(code === "cafe24" ? " 금액은 적립금 사용분을 뺀 값입니다(환불도 적립금으로 돌려준 금액은 뺌)." : "") +
(code === "naver" ? " 결제 금액은 판매금액 + 배송비, 환불은 환불된 날에 빠집니다." : "") +
(code === "naver" ? " 판매금액은 배송비를 뺀 상품 결제금액입니다. 그날 매출 = 판매금액 + 배송비 − 환불(환불된 날)." : "") +
" 적립금·배송비 칸이 비어 있으면 규칙을 바꾸기 전에 받은 자료입니다 — 실적 설정 → 과거 매출 가져오기로 그 기간을 다시 받으세요.</p>";
} catch (err) {
m.body.innerHTML = '<p class="perf-notice is-warn">' + esc(err.message) + "</p>";