Skip to content

Commit

Permalink
✨ (短信中国银行): 新增网上支付支取规则及测试用例 #654
Browse files Browse the repository at this point in the history
新增对中国银行短信中网上支付支取信息的解析规则,并添加相应的测试用例。更新了 `main.js` 中的正则表达式和 `main.test.js` 中的测试数据,确保能够正确解析和处理相关短信内容。
  • Loading branch information
AnkioTomas committed Dec 28, 2024
1 parent ae1912e commit b3e0feb
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/rule/com.android.phone/app/短信中国银行/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,28 @@ const rules = [

return obj;
}
]
],

[
// 您的借记卡账户6450,于12月28日网上支付支取人民币1.00元,交易后余额1653.35【中国银行】
/您的借记卡账户(\d{4}),于(.*?)网上支付支取(.*?)([\d,]+.\d{2})元,交易后余额[\d,]+.\d{2}$/,
match => {
let [, number, date, currency, money] = match;

];
let obj = new RuleObject();
obj.money = toFloat(money);
obj.channel = `中国银行[支出]`;
obj.currency = transferCurrency(currency);
obj.time = formatDate(date, 'M月D日');
obj.type = BillType.Expend;
obj.accountNameFrom = `中国银行(${number})`;
obj.shopName = '网上支付';
obj.shopItem = '支取';

return obj;
}
]
];

/**
* @param {string} data - JSON格式的数据
Expand All @@ -62,5 +79,3 @@ export function get(data) {
}
}
}


14 changes: 14 additions & 0 deletions src/rule/com.android.phone/app/短信中国银行/main.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

const { get } = require('./main');
const { testAnkio, testAnkioInit } = require('../../../../tests/TestUtils');
const { formatDate } = require('common/Time.js');
Expand Down Expand Up @@ -31,5 +32,18 @@ test('中国银行支出', () =>
'currency': 'CNY',
'time': formatDate('2024-12-24 13:05:14', 'Y-M-D h:i:s'),
'channel': '中国银行[支出]'
},
{
'type': 'Expend',
'money': 1,
'fee': 0,
'shopName': '网上支付',
'shopItem': '支取',
'accountNameFrom': '中国银行(6450)',
'accountNameTo': '',
'currency': 'CNY',
'time': formatDate('12月28日', 'M月D日'),
'channel': '中国银行[支出]'
}
]));

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"sender":"95566","body":"您的借记卡账户6450,于12月28日网上支付支取人民币1.00元,交易后余额1653.35【中国银行】","t":1735366567873}

0 comments on commit b3e0feb

Please sign in to comment.