Skip to content

Commit

Permalink
✨ (rule): 添加招商银行收入处理规则及测试用例 #488
Browse files Browse the repository at this point in the history
新增招商银行收入处理规则,支持解析银联入账短信并生成相应的账单对象。同时添加了对应的测试用例和测试数据文件,确保规则的正确性和可靠性。
  • Loading branch information
AnkioTomas committed Dec 18, 2024
1 parent 605eda3 commit 3b84283
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/rule/com.android.phone/app/短信招商银行/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,26 @@ const rules = [
obj.accountNameTo = `招商银行信用卡(${toNumber})`;
return obj;
}
] , //您账户1999于11月12日15:04银联入账人民币0.09元,余额238.06元(微信零钱提现/微信零钱提现)
[
//您账户1999于11月12日15:04银联入账人民币0.09元,余额238.06元(微信零钱提现/微信零钱提现)
/您账户(\d{4})于(\d+月\d+日\d+:\d+)(.*?)人民币([\d,]+.\d{2})元,余额(.*?)元((.*?))/,
match => {
let [, fromNumber, date, shopItem, money, total,shopName] = match;

let obj = new RuleObject();

obj.money = toFloat(money);
obj.channel = `招商银行[入账]`;
obj.currency = 'CNY';
obj.shopName = shopName;
obj.shopItem = shopItem;
obj.time = formatDate(date, "M月D日h:i");

obj.type = BillType.Income;
obj.accountNameFrom = `招商银行(${fromNumber})`;
return obj;
}
]
];

Expand All @@ -56,4 +76,4 @@ export function get(data) {
return rule[1](match, t);
}
}
}
}
16 changes: 16 additions & 0 deletions src/rule/com.android.phone/app/短信招商银行/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,19 @@ test('招商银行信用卡还款', () =>
"channel": '招商银行[还款]',
},
]));

test('招商银行收入', () =>
testAnkio('招商银行收入', [
{
"type": "Income",
"money": 0.09,
"fee": 0,
"shopName": '微信零钱提现/微信零钱提现',
"shopItem": '银联入账',
"accountNameFrom": '招商银行(1999)',
"accountNameTo": '',
"currency": 'CNY',
"time": formatDate("11月12日15:04", "M月D日h:i"),
"channel": '招商银行[入账]',
},
]));
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"sender": "95555",
"body": "【招商银行】您账户1999于11月12日15:04银联入账人民币0.09元,余额238.06元(微信零钱提现/微信零钱提现)",
"t": 1731395062038
}

0 comments on commit 3b84283

Please sign in to comment.