Skip to content

Commit

Permalink
✨ (rule): 添加交通银行信用卡还款规则及测试用例 #600
Browse files Browse the repository at this point in the history
新增交通银行信用卡还款的规则解析逻辑,并在测试文件中添加相应的测试用例。同时,新增测试数据文件以验证规则的正确性。
  • Loading branch information
AnkioTomas committed Dec 28, 2024
1 parent 993145b commit 6b4d0b3
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import { formatDate, isPaymentType, parseWechat, RuleObject, toFloat, transferCurrency } from 'common/index.js';
import {
BillType,
formatDate,
isPaymentType,
parseWechat,
RuleObject,
toFloat,
transferCurrency
} from 'common/index.js';

// 定义源名称和需要匹配的标题数组
const SOURCE = '交通银行微银行';
Expand Down Expand Up @@ -53,6 +61,26 @@ const rules = [
)
},
],
[
//交易卡号:*6662\n交易时间:2024-12-12 06:21\n交易类型:信用卡还款\n交易金额:31604.21元
/交易卡号:\*(\d+)\n交易时间:(.*?)\n交易类型:信用卡还款\n交易金额:(\d+.\d{2})元/,
(match, t, item) => {
let [, number, time, money] = match;

return new RuleObject(
BillType.Transfer,
toFloat(money),
'信用卡还款',
'',
`交通银行(${number})`,
`交通银行信用卡`,
0.0,
transferCurrency('人民币'),
formatDate(time, 'Y-M-D h:i'),
`微信[${SOURCE}-还款]`
);
}
]
];


Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

const { get } = require('./main');
const fs = require('fs');
const path = require('path');
Expand Down Expand Up @@ -62,3 +63,19 @@ test('交通银行支出', () =>
"channel": '微信[交通银行微银行-支出]',
},
]));

test('交通银行信用卡还款', () =>
testAnkio('交通银行信用卡还款', [
{
'type': 'Transfer',
'money': 31604.21,
'fee': 0,
'shopName': '信用卡还款',
'shopItem': '',
'accountNameFrom': '交通银行(6662)',
'accountNameTo': '交通银行信用卡',
'currency': 'CNY',
'time': formatDate('2024-12-12 06:21', 'Y-M-D h:i'),
'channel': '微信[交通银行微银行-还款]'
}
]));
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"mMap":{"tableName":"AppMessage","description":"交易卡号:*6662\n交易时间:2024-12-12 06:21\n交易类型:信用卡还款\n交易金额:31604.21元","source":"交通银行微银行","t":1733955679952,"arg":"msgId","type":5,"appId":"","msgId":215264,"title":"交易提醒"}}

0 comments on commit 6b4d0b3

Please sign in to comment.