fix(ar): 单户逾期文案口径——账龄最老 N 天 / 逾期合计 ¥X(占该户 Y%)
ci/woodpecker/push/main Pipeline was successful

D2:%d 为最老逾期天数、%s 为 31 天以上逾期合计,旧文案「期末逾期 151 天以上 ¥300,120」
会被读成最老档即 30 万(HKJJ120 150+ 实为 65,115.00)。只改文案,判据/params/历史行零变更。
新增回归用例:HKJJ120 逐档实数 ⇒ 账龄最老 151 天,逾期合计 ¥300,120.00(占该户 85.14%)。
This commit is contained in:
wecom-fullstack
2026-10-21 16:01:08 +08:00
parent a7a663f6cd
commit 7022a05928
2 changed files with 31 additions and 1 deletions
+1 -1
View File
@@ -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"],
@@ -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"]}