Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(wechat): 去掉默认忽略零钱和零钱通互转的逻辑 #139

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -519,17 +519,20 @@ wechat:
item: /
targetAccount: Income:Wechat:RedPacket
- type: / # 转入零钱通
txType: 转入零钱
txType: 转入零钱通
peer: /
item: /
targetAccount: Assets:Digital:Wechat:Cash
targetAccount: Assets:Digital:Wechat:MiniFund
- type: / # 零钱提现
txType: 零钱提现
targetAccount: Assets:Digital:Wechat:Cash
commissionAccount: Expenses:Wechat:Commission
- type: / # 零钱充值
txType: 零钱充值
targetAccount: Assets:Digital:Wechat:Cash
- type: / # 零钱通转出-到零钱
txType: 零钱通转出-到零钱
targetAccount: Assets:Digital:Wechat:Cash
- type: / # 零钱通转出-到工商银行(9876)
txType: 零钱通转出-到工商银行(9876)
targetAccount: Assets:Bank:CN:ICBC:Savings
Expand Down Expand Up @@ -572,7 +575,7 @@ wechat:
methodAccount: Assets:Digital:Wechat:Cash
- method: 零钱通
fullMatch: true
methodAccount: Assets:Digital:Wechat:Cash
methodAccount: Assets:Digital:Wechat:MiniFund
- method: 工商银行
methodAccount: Assets:Bank:CN:ICBC:Savings
- method: 中国银行
Expand Down Expand Up @@ -622,6 +625,31 @@ wechat:
| 收入 | targetAccount | methodAccount |
| 支出 | methodAccount | targetAccount |

在历史版本中,零钱和零钱通默认视为一个账户,并忽略了零钱和零钱通之间互转的记录;在最新版本中,零钱和零钱通是否视为一个账户交给用户自己决定。如果需要继续视为一个账户,可以参考以下配置规则:

``` yaml
# 将零钱和零钱通视为一个账户
- method: 零钱
fullMatch: true
methodAccount: Assets:Digital:Wechat:Cash
- method: 零钱通
fullMatch: true
methodAccount: Assets:Digital:Wechat:Cash
- type: /
txType: 转入零钱通
peer: /
item: /
targetAccount: Assets:Digital:Wechat:Cash
# 忽略零钱和零钱通之间的互转记录
- txType: "零钱通转出-到零钱"
fullMatch: true
ignore: true
- txType: "转入零钱通-来自零钱"
fullMatch: true
ignore: true
```


### Huobi Global (Crypto)

<details>
Expand Down
9 changes: 6 additions & 3 deletions example/wechat/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,20 @@ wechat:
item: /
targetAccount: Income:Wechat:RedPacket
- type: / # 转入零钱通
txType: 转入零钱
txType: 转入零钱通
peer: /
item: /
targetAccount: Assets:Digital:Wechat:Cash
targetAccount: Assets:Digital:Wechat:MiniFund
- type: / # 零钱提现
txType: 零钱提现
targetAccount: Assets:Digital:Wechat:Cash
commissionAccount: Expenses:Wechat:Commission
- type: / # 零钱充值
txType: 零钱充值
targetAccount: Assets:Digital:Wechat:Cash
- type: / # 零钱通转出-到零钱
txType: 零钱通转出-到零钱
targetAccount: Assets:Digital:Wechat:Cash
- type: / # 零钱通转出-到工商银行(9876)
txType: 零钱通转出-到工商银行(9876)
targetAccount: Assets:Bank:CN:ICBC:Savings
Expand Down Expand Up @@ -78,7 +81,7 @@ wechat:
methodAccount: Assets:Digital:Wechat:Cash
- method: 零钱通
fullMatch: true
methodAccount: Assets:Digital:Wechat:Cash
methodAccount: Assets:Digital:Wechat:MiniFund
- method: 工商银行
methodAccount: Assets:Bank:CN:ICBC:Savings
- method: 中国银行
Expand Down
39 changes: 32 additions & 7 deletions example/wechat/example-wechat-output.beancount
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ option "operating_currency" "CNY"
1970-01-01 open Assets:Bank:CN:BOC:Savings
1970-01-01 open Assets:Bank:CN:ICBC:Savings
1970-01-01 open Assets:Digital:Wechat:Cash
1970-01-01 open Assets:Digital:Wechat:MiniFund
1970-01-01 open Assets:FIXME
1970-01-01 open Assets:Trade:Tencent:LiCaiTong
1970-01-01 open Expenses:FIXME
Expand Down Expand Up @@ -68,6 +69,30 @@ option "operating_currency" "CNY"
Expenses:Food:Meal:Lunch 28.16 CNY
Assets:Bank:CN:BOC:Savings -28.16 CNY

2020-02-14 * "/" "/"
merchantId: "/"
method: "零钱通"
orderId: "18000070012002140012244807617587"
payTime: "2020-02-14 01:19:39 +0800 CST"
source: "微信支付"
status: "支付成功"
txType: "零钱通转出-到零钱"
type: "/"
Assets:Digital:Wechat:Cash 2634.78 CNY
Assets:Digital:Wechat:MiniFund -2634.78 CNY

2020-02-14 * "/" "/"
merchantId: "18000070012002140012244807617590"
method: "零钱"
orderId: "18000070012002140012244807617589"
payTime: "2020-02-14 01:20:00 +0800 CST"
source: "微信支付"
status: "支付成功"
txType: "转入零钱通-来自零钱"
type: "/"
Assets:Digital:Wechat:MiniFund 1.23 CNY
Assets:Digital:Wechat:Cash -1.23 CNY

2020-02-14 * "理财通" "中欧医疗健康混合C(003096)"
merchantId: "1800007030102002143310679508"
method: "工商银行"
Expand Down Expand Up @@ -102,7 +127,7 @@ option "operating_currency" "CNY"
txType: "零钱通转出-到工商银行(9876)"
type: "/"
Assets:Bank:CN:ICBC:Savings 5505.00 CNY
Assets:Digital:Wechat:Cash -5505.00 CNY
Assets:Digital:Wechat:MiniFund -5505.00 CNY

2020-11-27 * "用户A" "收款方备注:二维码收款" #income #service
merchantId: "/"
Expand All @@ -125,7 +150,7 @@ option "operating_currency" "CNY"
status: "支付成功"
txType: "转入零钱通-来自工商银行(9876)"
type: "/"
Assets:Digital:Wechat:Cash 2000.00 CNY
Assets:Digital:Wechat:MiniFund 2000.00 CNY
Assets:Bank:CN:ICBC:Savings -2000.00 CNY

2021-01-17 * "某餐厅" "收款方备注:二维码收款"
Expand All @@ -138,7 +163,7 @@ option "operating_currency" "CNY"
txType: "扫二维码付款"
type: "支出"
Expenses:Food:Meal:Dinner 12.00 CNY
Assets:Digital:Wechat:Cash -12.00 CNY
Assets:Digital:Wechat:MiniFund -12.00 CNY

2021-01-22 * "房东" "转账备注:微信转账"
merchantId: "129847129"
Expand All @@ -150,7 +175,7 @@ option "operating_currency" "CNY"
txType: "转账"
type: "支出"
Expenses:Housing:Rent 500.00 CNY
Assets:Digital:Wechat:Cash -500.00 CNY
Assets:Digital:Wechat:MiniFund -500.00 CNY

2021-07-11 * "招商银行()" "/"
merchantId: "/"
Expand Down Expand Up @@ -216,7 +241,7 @@ option "operating_currency" "CNY"
txType: "亲属卡交易"
type: "支出"
Expenses:FIXME 2243.46 CNY
Assets:Digital:Wechat:Cash -2243.46 CNY
Assets:Digital:Wechat:MiniFund -2243.46 CNY

2021-12-15 * "某餐厅" "测试 T+1"
merchantId: "129847129"
Expand All @@ -228,7 +253,7 @@ option "operating_currency" "CNY"
txType: "扫二维码付款"
type: "支出"
Expenses:Food:Meal:MidNight 12.00 CNY
Assets:Digital:Wechat:Cash -12.00 CNY
Assets:Digital:Wechat:MiniFund -12.00 CNY

2021-12-15 * "某餐厅" "测试 T-1"
merchantId: "129847129"
Expand All @@ -240,7 +265,7 @@ option "operating_currency" "CNY"
txType: "扫二维码付款"
type: "支出"
Expenses:Food:Meal:MidNight 12.00 CNY
Assets:Digital:Wechat:Cash -12.00 CNY
Assets:Digital:Wechat:MiniFund -12.00 CNY

2022-07-18 * "测试时间戳,点击底部\"多多视频\"" "/"
merchantId: "10101265586742107189275763431049"
Expand Down
39 changes: 32 additions & 7 deletions example/wechat/example-wechat-output.ledger
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Assets:Bank:CN:BOC:Savings 0 CNY
Assets:Bank:CN:ICBC:Savings 0 CNY
Assets:Digital:Wechat:Cash 0 CNY
Assets:Digital:Wechat:MiniFund 0 CNY
Assets:FIXME 0 CNY
Assets:Trade:Tencent:LiCaiTong 0 CNY
Expenses:FIXME 0 CNY
Expand Down Expand Up @@ -66,6 +67,30 @@
Expenses:Food:Meal:Lunch 28.16 CNY
Assets:Bank:CN:BOC:Savings - 28.16 CNY

2020/02/14 * / - /
; merchantId: "/"
; method: "零钱通"
; orderId: "18000070012002140012244807617587"
; payTime: "2020-02-14 01:19:39 &#43;0800 CST"
; source: "微信支付"
; status: "支付成功"
; txType: "零钱通转出-到零钱"
; type: "/"
Assets:Digital:Wechat:Cash 2634.78 CNY
Assets:Digital:Wechat:MiniFund - 2634.78 CNY

2020/02/14 * / - /
; merchantId: "18000070012002140012244807617590"
; method: "零钱"
; orderId: "18000070012002140012244807617589"
; payTime: "2020-02-14 01:20:00 &#43;0800 CST"
; source: "微信支付"
; status: "支付成功"
; txType: "转入零钱通-来自零钱"
; type: "/"
Assets:Digital:Wechat:MiniFund 1.23 CNY
Assets:Digital:Wechat:Cash - 1.23 CNY

2020/02/14 * 理财通 - 中欧医疗健康混合C(003096)
; merchantId: "1800007030102002143310679508"
; method: "工商银行"
Expand Down Expand Up @@ -100,7 +125,7 @@
; txType: "零钱通转出-到工商银行(9876)"
; type: "/"
Assets:Bank:CN:ICBC:Savings 5505.00 CNY
Assets:Digital:Wechat:Cash - 5505.00 CNY
Assets:Digital:Wechat:MiniFund - 5505.00 CNY

2020/11/27 * 用户A - 收款方备注:二维码收款
; :income:service:
Expand All @@ -124,7 +149,7 @@
; status: "支付成功"
; txType: "转入零钱通-来自工商银行(9876)"
; type: "/"
Assets:Digital:Wechat:Cash 2000.00 CNY
Assets:Digital:Wechat:MiniFund 2000.00 CNY
Assets:Bank:CN:ICBC:Savings - 2000.00 CNY

2021/01/17 * 某餐厅 - 收款方备注:二维码收款
Expand All @@ -137,7 +162,7 @@
; txType: "扫二维码付款"
; type: "支出"
Expenses:Food:Meal:Dinner 12.00 CNY
Assets:Digital:Wechat:Cash - 12.00 CNY
Assets:Digital:Wechat:MiniFund - 12.00 CNY

2021/01/22 * 房东 - 转账备注:微信转账
; merchantId: "129847129"
Expand All @@ -149,7 +174,7 @@
; txType: "转账"
; type: "支出"
Expenses:Housing:Rent 500.00 CNY
Assets:Digital:Wechat:Cash - 500.00 CNY
Assets:Digital:Wechat:MiniFund - 500.00 CNY

2021/07/11 * 招商银行() - /
; merchantId: "/"
Expand Down Expand Up @@ -215,7 +240,7 @@
; txType: "亲属卡交易"
; type: "支出"
Expenses:FIXME 2243.46 CNY
Assets:Digital:Wechat:Cash - 2243.46 CNY
Assets:Digital:Wechat:MiniFund - 2243.46 CNY

2021/12/15 * 某餐厅 - 测试 T&#43;1
; merchantId: "129847129"
Expand All @@ -227,7 +252,7 @@
; txType: "扫二维码付款"
; type: "支出"
Expenses:Food:Meal:MidNight 12.00 CNY
Assets:Digital:Wechat:Cash - 12.00 CNY
Assets:Digital:Wechat:MiniFund - 12.00 CNY

2021/12/15 * 某餐厅 - 测试 T-1
; merchantId: "129847129"
Expand All @@ -239,7 +264,7 @@
; txType: "扫二维码付款"
; type: "支出"
Expenses:Food:Meal:MidNight 12.00 CNY
Assets:Digital:Wechat:Cash - 12.00 CNY
Assets:Digital:Wechat:MiniFund - 12.00 CNY

2022/07/18 * 测试时间戳,点击底部\&#34;多多视频\&#34; - /
; merchantId: "10101265586742107189275763431049"
Expand Down
1 change: 1 addition & 0 deletions example/wechat/example-wechat-records.csv
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
2020-02-14 01:32:14,购买理财通,理财通,"鹏华增值宝(000569)",/,¥10000.00,工商银行,支付成功,1800007367312002141165262215 ,1800007308102002143430655989 ,"/"
2020-02-14 01:24:33,购买理财通,理财通,"中欧医疗健康混合C(003096)",/,¥3000.00,工商银行,支付成功,1800045030312002144223548046 ,1800007030102002143310679508 ,"/"
2020-02-14 01:19:39,零钱通转出-到零钱,/,"/",/,¥2634.78,零钱通,支付成功,18000070012002140012244807617587 ,/ ,"/"
2020-02-14 01:20:00,转入零钱通-来自零钱,/,"/",/,¥1.23,零钱,支付成功,18000070012002140012244807617589 ,18000070012002140012244807617590 ,"/"
2020-07-06 14:54:38,零钱通转出-到工商银行(9876),/,"/",/,¥5505.00,零钱通,支付成功,18000070282007060048243102923587 ,/ ,"/"
2019-04-16 10:28:55,零钱充值,工商银行(9876),"/",/,¥1300.00,工商银行(9876),充值完成,110190416100031243293946287587 ,/ ,"/"
2021-10-19 16:08:00,亲属卡交易,哈哈,"亲属卡",支出,¥2243.46,零钱通,支付成功,42000011202110191201583411 ,XSFF-SD2021101916055813620 ,"/"
Expand Down
6 changes: 0 additions & 6 deletions pkg/provider/wechat/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package wechat

import (
"fmt"
"log"
"regexp"
"strconv"
"strings"
Expand Down Expand Up @@ -31,11 +30,6 @@ func (w *Wechat) translateToOrders(array []string) error {

bill.TxType = getTxType(array[1])
switch bill.TxType {
case TxTypeCash2Cash:
fallthrough
case TxTypeCash2CashLooseChange:
log.Printf("Get an unusable tx type, ignore it: %s\n", bill.TxType)
return nil
case TxTypeUnknown:
return fmt.Errorf("Failed to get the tx type %s: %v", array[1], err)
}
Expand Down
Loading