fix(performance): 쿠팡 광고 보고서 — 청구금액이 없는 날짜·파일은 오류 없이 넘어감

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-14 17:42:59 +09:00
parent bbe27eac8b
commit bab495d9f2
8 changed files with 17 additions and 17 deletions
+3 -1
View File
@@ -198,7 +198,9 @@ def parse_coupang_rocket(content: bytes, *, today: date, filename: str = "") ->
break
res.entries = sorted(sums.items())
res.empty_days = sorted(d for d in dated if d not in sums and d <= today)
if not res.entries and not res.errors:
# 날짜 줄은 있는데 청구금액이 한 줄도 없는 파일(그 달 광고비 0 등)은 오류가 아니라 넘어간다(2026-10-14 사용자 요청).
# 날짜 줄 자체가 없을 때만 양식 오류.
if not dated and not res.errors:
raise UploadError("광고비 날짜 줄이 없습니다. 1열 날짜(예: 2026년 10월 01일), 19열 청구금액(+부가가치세) 양식인지 확인하세요.")
return res
@@ -214,4 +214,4 @@
} | tojson }}</script>
{% endblock %}
{% block scripts %}<script src="/static/performance.js?v=20261014d" defer></script>{% endblock %}
{% block scripts %}<script src="/static/performance.js?v=20261014e" defer></script>{% endblock %}
@@ -255,4 +255,4 @@
} | tojson }}</script>
{% endblock %}
{% block scripts %}<script src="/static/performance.js?v=20261014d" defer></script>{% endblock %}
{% block scripts %}<script src="/static/performance.js?v=20261014e" defer></script>{% endblock %}
@@ -204,4 +204,4 @@
</section>
{% endblock %}
{% block scripts %}<script src="/static/performance.js?v=20261014d" defer></script>{% endblock %}
{% block scripts %}<script src="/static/performance.js?v=20261014e" defer></script>{% endblock %}
@@ -76,6 +76,11 @@ def test_coupang_report_date_rows_col19_summed_empty_skipped():
assert not res.errors, res.errors
assert res.entries == [(date(2026, 3, 1), 38), (date(2026, 3, 3), 1)]
assert res.empty_days == [date(2026, 3, 2)]
# 청구금액이 한 줄도 없는 파일(날짜 줄만) — 오류 없이 넘어감(반영할 날 없음)
none = "\n".join([head, "2026-03-01,,,,VENDOR,PA,매출 성장,1,캠페인A,Adcost,DAILY_SOFT,1000,0,0,0,0,0,,",
"2026-03-02,,,,VENDOR,PA,매출 성장,1,캠페인A,Adcost,DAILY_SOFT,1000,0,0,0,0,0,,"]) + "\n"
r0 = ads.parse_coupang_rocket(_xlsx(none), today=TODAY, filename="march.xlsx")
assert r0.entries == [] and not r0.errors and r0.empty_days == [date(2026, 3, 1), date(2026, 3, 2)]
m, _ = ads.merge_results([("a.xlsx", 1.0, ads.parse_coupang_rocket(wing.encode("utf-8"), today=TODAY)),
("b.csv", 2.0, ads.ParseResult(entries=[(date(2026, 3, 2), 7)]))])
assert m.empty_days == [] and dict(m.entries)[date(2026, 3, 2)] == 7 # 다른 파일에 값이 있으면 빈 날 아님