-
Notifications
You must be signed in to change notification settings - Fork 7
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
Peter Jones
committed
Apr 10, 2024
1 parent
49bfd71
commit f60f085
Showing
3 changed files
with
75 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,49 @@ | ||
import { RuleObject } from "../../../../utils/RuleObject"; | ||
import { BillType } from "../../../../utils/BillType"; | ||
import { Currency } from "../../../../utils/Currency"; | ||
|
||
|
||
export function get(data) { | ||
data = JSON.parse(data); | ||
let mapItem = data.mMap; | ||
if (mapItem.source!=="长沙银行") return null; | ||
if (mapItem.title==="交易成功提醒") { | ||
let result = { | ||
type: null, | ||
money: 0, | ||
fee: 0, | ||
shopName: "", | ||
shopItem: "", | ||
accountNameFrom: "", | ||
accountNameTo: "", | ||
currency: null, | ||
time: null, | ||
channel:"长沙银行"+mapItem.title | ||
}; | ||
let text = mapItem.description; | ||
let regex = /交易时间:(.*?)\n交易类型:(.*?)(个人账户:尾号(\d{4}))\n交易金额:人民币(.*?)元\n账户余额:.*?元\n交易说明:(.*)/; | ||
let match = text.match(regex); | ||
if (match) { | ||
if (match[2].includes("支付取出")) { | ||
result.type = BillType.Expend; | ||
} | ||
result.time = match[1]; | ||
result.shopItem = match[5]; | ||
result.money = parseFloat(match[4]); | ||
result.accountNameFrom =`长沙银行(${match[3]})`; | ||
result.currency = Currency['人民币']; | ||
} | ||
return new RuleObject( | ||
result.type, | ||
result.money, | ||
result.shopName, | ||
result.shopItem, | ||
result.accountNameFrom, | ||
result.accountNameTo, | ||
result.fee, | ||
result.currency, | ||
result.time, | ||
result.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,25 @@ | ||
const { get } = require('./main'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
test("长沙住房公积金每月汇缴", () => { | ||
|
||
const dataFilePath = path.join(__dirname, 'tests', '长沙银行支付宝支付取出.txt'); | ||
// 使用readFileSync来同步读取文件内容 | ||
const data = fs.readFileSync(dataFilePath, 'utf8') | ||
|
||
let result = get(data); | ||
|
||
expect(result).toEqual({ | ||
type: 0, | ||
money: 200, | ||
fee: 0, | ||
shopName: '', | ||
shopItem: '中国电信股份有限公司全渠道运营中心-商品...', | ||
accountNameFrom: '长沙银行(2754)', | ||
accountNameTo: '', | ||
currency: 'CNY', | ||
time: "04月10日09:03", | ||
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 @@ | ||
{"mMap":{"tableName":"AppMessage","description":"交易时间:04月10日09:03\n交易类型:支付宝支付取出(个人账户:尾号2754)\n交易金额:人民币200.00元\n账户余额:19,720.27元\n交易说明:中国电信股份有限公司全渠道运营中心-商品...","source":"长沙银行","arg":"msgId","type":5,"appId":"","msgId":60255,"title":"交易成功提醒"}} |