fix(performance): 카페24 결제합계에서 품목 상품추가할인 빼기 + 대조 표에 카페24 열별 차이

일별 비교 결과 결제합계가 틀린 날은 모두 카페24 상품구매금액이 100원 단위가
아닌 날이고, 차이만큼 더하면 정확히 100원 단위가 된다(9/23 1,860,738+62,
9/22 2,620,740+260, 9/12 7,889,287+13 …). 카페24 화면의 상품구매금액은
품목 상품추가할인(items[].additional_discount_price, 문서: 상품추가할인액)을
뺀 값인데, initial_order_amount 에는 이 할인이 없어 우리가 그만큼 많았다.

- order_total: 판매가 합계 − 품목 상품추가할인 + 배송비 − 할인 − 쿠폰
- order_total_now: 취소·반품 품목의 추가할인은 제외
- 대조 표: 상품구매금액을 추가할인 뺀 값으로 + 판매가 합계·추가할인 세부 줄
- 일별 비교에서 날짜를 눌러 연 대조 표에 붙여넣은 카페24 열과 열별 차이 표시
- 테스트 추가

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-29 21:43:50 +09:00
parent 614332a1e6
commit 6f43f8066a
4 changed files with 68 additions and 22 deletions
@@ -650,6 +650,23 @@ def test_cafe24_scope_and_replace_range():
("naver", "direct-naver-1"), ("cafe24", "sample")}, got
def test_cafe24_item_additional_discount():
"""카페24 상품구매금액 = 판매가 합계 − 품목 상품추가할인(additional_discount_price). 주문 금액에는 없다.
실데이터: 9/23 카페24 상품구매금액 1,860,738 — 판매가 합계 1,860,800 과 62원 차이."""
from app.modules.performance.adapters.cafe24 import order_total, order_total_now
o = _c24_order("A") # 50,000 + 3,000 − 1,000 − 5,000
o["items"][0]["additional_discount_price"] = "38.00"
o["items"][1]["additional_discount_price"] = "24.00"
assert order_total(o) == 47_000 - 62
ev = _FakeCafe24([]).normalize_order(o)[0]
assert ev.amount == 46_938 and ev.discount_amount == 62 + 1_000 + 5_000
# 현재 금액: 취소된 품목의 추가할인은 빼지 않는다
o["actual_order_amount"] = dict(o["initial_order_amount"])
o["items"][1]["order_status"] = "C40"
assert order_total_now(o) == 47_000 - 38
def test_daily_check_db_vs_live():
"""일별 비교: 저장값(카페24 경유 다른 마켓 열 포함) + 지금 API 값(저장 안 함)."""
import app.modules.performance.sync as syncmod