fix(performance): 계산식 입력 직후 차감 매출 숫자가 안 보이던 문제

칸 저장 뒤 총매출만 바꾸고 수수료·차감 매출(기본 보기)은 새로고침 때까지
예전 값(–)으로 흐리게 남겼다. 저장 응답에 그날 수수료·차감 매출을 함께
돌려주고 화면이 세 숫자를 바로 바꾼다.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-21 13:15:57 +09:00
parent c655eb100d
commit 34dca7cb76
6 changed files with 22 additions and 8 deletions
+7 -2
View File
@@ -50,7 +50,7 @@ from fastapi.responses import FileResponse, HTMLResponse, JSONResponse
from app.timezone import today_kst
from . import common
from . import calc, common
from .adapters.registry import all_adapters, get_adapter
router = APIRouter(prefix="/performance", tags=["performance"])
@@ -424,8 +424,13 @@ def api_manual_sale(request: Request, code: str, day: str, payload: dict[str, An
except ManualMigrationNeeded:
raise HTTPException(status_code=503, detail=MANUAL_MIGRATION_HELP) from None
api_amount = store.api_amount(code, d)
shown = api_amount if amount is None else amount
# 그날 수수료·수수료 차감 매출도 돌려준다 — 화면이 새로고침 전에도 보고 있는 기준(기본 = 차감 매출) 숫자를 바로 바꾸게
rate_table = getattr(store, "rate_table", None)
money = calc.build_cells({(d, code): shown}, rate_table() if rate_table else {})[(d, code)].as_dict()
return JSONResponse({"ok": True, "code": code, "date": d.isoformat(), "manual": amount, "formula": formula,
"amount": api_amount if amount is None else amount, "api_amount": api_amount})
"amount": shown, "api_amount": api_amount,
"commission": money["commission"], "net": money["net"]})
@router.get("/api/manual-sales/sample.xlsx")
@@ -238,4 +238,4 @@
} | tojson }}</script>
{% endblock %}
{% block scripts %}<script src="/static/performance.js?v=20261021a" defer></script>{% endblock %}
{% block scripts %}<script src="/static/performance.js?v=20261021b" defer></script>{% endblock %}
@@ -275,4 +275,4 @@
} | tojson }}</script>
{% endblock %}
{% block scripts %}<script src="/static/performance.js?v=20261021a" defer></script>{% endblock %}
{% block scripts %}<script src="/static/performance.js?v=20261021b" defer></script>{% endblock %}
@@ -219,4 +219,4 @@
</section>
{% endblock %}
{% block scripts %}<script src="/static/performance.js?v=20261021a" defer></script>{% endblock %}
{% block scripts %}<script src="/static/performance.js?v=20261021b" defer></script>{% endblock %}
@@ -2123,6 +2123,9 @@ def test_manual_sale_api_rules():
def api_amount(self, code, day):
return 50000
def rate_table(self):
return {"coupang": [(date(2026, 1, 1), Decimal("10"))]}
def update_marketplace(self, code, **kw):
if self.missing and kw.get("manual_input") is not None:
raise ManualMigrationNeeded()
@@ -2156,6 +2159,7 @@ def test_manual_sale_api_rules():
assert st.formula is None
body = __import__("json").loads(router.api_manual_sale(None, "coupang", "2026-10-12", {"amount": "1,000+2000*2"}).body)
assert st.saved[-1][2] == 5000 and st.formula == "1000+2000*2" and body["formula"] == "1000+2000*2"
assert body["commission"] == 500 and body["net"] == 4500 # 화면이 새로고침 전에도 차감 매출을 바로 보이게
assert status_of(lambda: router.api_manual_sale(None, "coupang", "2026-10-12", {"amount": "1/0"}))[0] == 400
code, msg = status_of(lambda: router.api_manual_sale(None, "naver", "2026-10-12", {"amount": 1}))
assert code == 400 and "수동 입력" in msg # 꺼진 쇼핑몰