feat(performance): 네이버 배송비 대조 진단 — reconcile 응답에 주문·배송 묶음 단위 후보(ship_check)
10/18 실데이터에서 상품주문마다 배송비 − 할인 = 38,500, 판매분석 87,500 — 판매분석과 맞는 셈을 실데이터로 고르기 위한 진단 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2186,3 +2186,28 @@ def test_dashboard_manual_cells_and_order():
|
||||
assert ctx["manual_codes"] == ["coupang"] and ctx["manual_cells"] == ["2026-10-05|coupang"]
|
||||
day5 = next(r for r in ctx["table"] if r.get("date") == "2026-10-05")
|
||||
assert day5["cells"]["coupang"]["gross"] == 87000 and day5["cells"]["coupang"]["commission"] == 8700
|
||||
|
||||
|
||||
def test_naver_ship_check_candidates():
|
||||
"""배송비 진단(2026-10-19) — 같은 주문·배송 묶음에 반복되는 배송비·할인을 주문/묶음 단위로 센 후보를 함께 돌려준다."""
|
||||
from app.modules.performance.adapters import naver as nv
|
||||
|
||||
def it(order, po, fee, dc, pkg, status="DELIVERING", pay=10000):
|
||||
x = _naver_item(order, po, "2026-10-18", pay, status=status, ship=fee, ship_dc=dc)
|
||||
x["content"]["productOrder"]["packageNumber"] = pkg
|
||||
return x
|
||||
|
||||
items = [it("A", "A1", 3500, 0, "P1"), it("A", "A2", 3500, 3500, "P1"), # 묶음 2개 — 두 번째는 묶음 할인
|
||||
it("B", "B1", 3500, 3500, "P2"), # 조건부 무료
|
||||
it("C", "C1", 0, 0, "P3"), # 무료배송 상품
|
||||
it("D", "D1", 3500, 0, "P4", status="CANCELED"),
|
||||
it("E", "E1", 3500, 0, "P5", status="CANCELED_BY_NOPAYMENT")] # 미입금 — 제외
|
||||
got = nv.ship_check([{"content": i["content"]} | {"productOrder": i["content"]["productOrder"], "order": i["content"]["order"]}
|
||||
for i in items], date(2026, 10, 18), date(2026, 10, 18))
|
||||
assert got["product_orders"] == 5
|
||||
assert got["per_product_order"] == {"fee": 14000, "discount": 7000, "fee_minus_discount": 7000, "section": 0}
|
||||
assert got["per_order"] == {"groups": 4, "max_fee": 10500, "max_fee_minus_max_discount": 3500,
|
||||
"sum_fee_minus_sum_discount": 7000, "with_fee": 3}
|
||||
assert got["per_package"]["groups"] == 4 and got["per_package"]["max_fee"] == 10500
|
||||
assert [o["order"] for o in got["orders"]] == ["A", "B", "C", "D"] and len(got["orders"][0]["lines"]) == 2
|
||||
assert "홍길동" not in repr(got) and "010-1234-5678" not in repr(got)
|
||||
|
||||
Reference in New Issue
Block a user