fix(card): 扫码支付等流水不再被算成收入 #81
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.33) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.33 · 159 lines diff across 1 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.304
Real PR Conversation Timeline
1 comments
"Review active on #81"
general
weight: 0.35
JimmyWang0417
变更说明
校园卡流水里,食堂窗口扫码支付的记录(
icon=qrCode-payment、turnoverType=二维码支付)不含任何已知的支出关键词,于是走进_signed_amount_cents()的默认分支,按正数显示成收入,余额走势和收支统计都跟着错。根因是方向完全靠类型文案关键词猜;学校一加新支付渠道就会漏。改为三级判断:
1. 优先用
typeFrom:官方 ncard 账单页前端按"1" === typeFrom显示+,其余一律-,这是权威规则。2. 缺
typeFrom时退回原有关键词匹配(收入优先,保留「消费退款」取正的行为),并把「二维码支付 / qrcode-payment」补进支出关键词。3. 关键词也对不上时看钱落到哪:充值
toAccount=0(或等于fromAccount)视为留在卡里,否则视为转出。服务端返回负数时仍原样保留;
typeFrom、toAccount、fromAccount缺失或格式异常时安全退化,不会抛错。验证
PR Tests / CI Gate已通过。测试证据
test/card/test_campus_card.py新增 3 个用例(合成数据,不访问真实接口):test_qrcode_payment_is_expense:扫码支付记为支出;在未修复的代码上得到+850,失败。test_type_from_decides_direction_before_keywords:typeFrom优先于关键词,字符串/整数都能识别。test_unknown_type_falls_back_to_destination_account:未知类型按toAccount判断方向。本地环境:Windows 11,Python 3.12。
🤖 Generated with Claude Code