From 7022a05928ec382015e939dcdeb06809546718d6 Mon Sep 17 00:00:00 2001 From: wecom-fullstack Date: Wed, 21 Oct 2026 16:01:08 +0800 Subject: [PATCH] =?UTF-8?q?fix(ar):=20=E5=8D=95=E6=88=B7=E9=80=BE=E6=9C=9F?= =?UTF-8?q?=E6=96=87=E6=A1=88=E5=8F=A3=E5=BE=84=E2=80=94=E2=80=94=E8=B4=A6?= =?UTF-8?q?=E9=BE=84=E6=9C=80=E8=80=81=20N=20=E5=A4=A9=20/=20=E9=80=BE?= =?UTF-8?q?=E6=9C=9F=E5=90=88=E8=AE=A1=20=C2=A5X=EF=BC=88=E5=8D=A0?= =?UTF-8?q?=E8=AF=A5=E6=88=B7=20Y%=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit D2:%d 为最老逾期天数、%s 为 31 天以上逾期合计,旧文案「期末逾期 151 天以上 ¥300,120」 会被读成最老档即 30 万(HKJJ120 150+ 实为 65,115.00)。只改文案,判据/params/历史行零变更。 新增回归用例:HKJJ120 逐档实数 ⇒ 账龄最老 151 天,逾期合计 ¥300,120.00(占该户 85.14%)。 --- backend/app/services/ar_overdue_alert.py | 2 +- .../tests/test_ar_aging_overdue_20261020.py | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/backend/app/services/ar_overdue_alert.py b/backend/app/services/ar_overdue_alert.py index 26f96484..dd21218f 100644 --- a/backend/app/services/ar_overdue_alert.py +++ b/backend/app/services/ar_overdue_alert.py @@ -706,7 +706,7 @@ def compute( unit_total = _dec(r.get("total_amt")) pct = (float(c["overdue_amt"] / unit_total) if unit_total > 0 else None) msg = _clip( - "【应收账款逾期】%s(%s)%s 期末逾期 %d 天以上 ¥%s,占该户应收 %s%%|建议:%s|责任人:%s" + "【应收账款逾期】%s(%s)%s 账龄最老 %d 天,逾期合计 ¥%s(占该户 %s%%)|建议:%s|责任人:%s" % ( r.get("unit_name"), r.get("unit_code"), period, c["oldest_days"], _fmt_money(c["overdue_amt"]), _fmt_pct(pct), action or "见规则配置", who["name"], diff --git a/backend/tests/test_ar_aging_overdue_20261020.py b/backend/tests/test_ar_aging_overdue_20261020.py index 0fa5cf9a..90746639 100644 --- a/backend/tests/test_ar_aging_overdue_20261020.py +++ b/backend/tests/test_ar_aging_overdue_20261020.py @@ -232,6 +232,36 @@ def test_single_overdue_red_and_yellow_households(staff: Session): assert "|责任人:" in c["alert_message"] +def test_single_customer_message_wording_hkjj120_20261021(aging: Session): + """D2(2026-10-21):单户文案须把「最老账龄」与「逾期合计」分开写清。 + + 样例 = 生产 HKJJ120 逐档实数(借方应收户口径,只读复核): + total 352,494.00 = 52,374 + 34,549 + 35,799 + 80,191 + 84,466 + 65,115 + 31 天以上逾期合计 = 300,120.00(占该户 85.14%),150+ 档 = 65,115.00。 + 旧文案「期末逾期 151 天以上 ¥300,120.00」会被读成「最老档就是 30 万」, + 故本用例硬断言旧措辞不再出现、新措辞逐字出现,且判据字段(金额/天数/占比)零变化。 + """ + _reset_table(aging) + _add(aging, "2026-09", "HKJJ120", "西安酣君品创贸易有限责任公司", 352494.00, + [52374.00, 34549.00, 35799.00, 80191.00, 84466.00, 65115.00]) + p = json.loads(json.dumps(BASE_PARAMS)) + p["assignee_by_unit"] = {"HKJJ120": "李世昌"} + res = ar_overdue_alert.compute(aging, ENT, "2026-09", p) + c = {x["unit_code"]: x for x in res["per_customer"]}["HKJJ120"] + # 判据字段(禁随文案改动) + assert c["level"] == "red" + assert c["oldest_days"] == 151 + assert c["overdue_amt"] == pytest.approx(300120.00) + assert c["total_amt"] == pytest.approx(352494.00) + assert c["pct_of_unit"] == pytest.approx(0.851419, abs=1e-6) + # 文案口径 + assert "账龄最老 151 天,逾期合计 ¥300,120.00(占该户 85.14%)" in c["alert_message"] + assert "期末逾期" not in c["alert_message"] + assert c["alert_message"].count("|建议:") == 1 + assert c["alert_message"].endswith("|责任人:李世昌") + assert len(c["alert_message"]) <= 500 + + def test_assignee_chain_salesman_then_dept(staff: Session): res = ar_overdue_alert.compute(staff, ENT, "2026-09", BASE_PARAMS) by_code = {c["unit_code"]: c for c in res["per_customer"]}