-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
新增泉州公积金中心短信解析规则,支持解析公积金缴存信息并生成收入账单对象。同时添加了相应的测试用例和测试数据,确保规则的正确性和稳定性。
- Loading branch information
1 parent
ab15ec0
commit 0c0a444
Showing
3 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { BillType, Currency, formatDate, RuleObject, splitSms, toFloat } from 'common/index.js'; | ||
|
||
let rules = [ | ||
{ | ||
// *辉您公积金账号[尾号6864]于10月30日缴存2186元,余额12611.76元。【泉州公积金中心】 | ||
'regex': /(.*?)您公积金账号\[尾号(\d+)\]于(.*?)缴存(.*?)元,余额(.*?)元。【泉州公积金中心】/, | ||
'match': (match,t) => { | ||
let [, shopName,number,date, money,shopItem, ] = match; | ||
let obj = new RuleObject(); | ||
|
||
obj.money = toFloat(money); | ||
obj.channel = `泉州公积金中心[收入]`; | ||
obj.shopName = shopName; | ||
obj.shopItem = `余额:${shopItem}`; | ||
obj.time = t; | ||
|
||
obj.type = BillType.Income; | ||
|
||
obj.accountNameFrom = `泉州公积金中心(${number})`; | ||
return obj; | ||
} | ||
|
||
}, | ||
]; | ||
|
||
export function get (data) { | ||
let { sender, bankName, text, t } = splitSms(data); | ||
if (bankName !== '福建12329') { | ||
return null; | ||
} | ||
for (let rule of rules) { | ||
const match = text.match(rule.regex); | ||
if (match) { | ||
return rule.match(match,t); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const { get } = require('./main'); | ||
const { testAnkio, testAnkioInit } = require('../../../../tests/TestUtils'); | ||
const { formatDate } = require('common/Time.js'); | ||
testAnkioInit(get, __dirname, 'com.android.phone'); | ||
test('泉州公积金中心收入', () => | ||
testAnkio('泉州公积金中心收入', [ | ||
{ | ||
"type": "Income", | ||
"money": 2186, | ||
"fee": 0, | ||
"shopName": '*辉', | ||
"shopItem": '余额:12611.76', | ||
"accountNameFrom": '泉州公积金中心(6864)', | ||
"accountNameTo": '', | ||
"currency": 'CNY', | ||
"time": 1730341259074, | ||
"channel": '泉州公积金中心[收入]', | ||
}, | ||
])); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"sender": "12329", | ||
"body": "【福建12329】*辉您公积金账号[尾号6864]于10月30日缴存2186元,余额12611.76元。【泉州公积金中心】", | ||
"t": 1730341259074 | ||
} |