Skip to content

Commit

Permalink
test: add icbc debit v2
Browse files Browse the repository at this point in the history
Signed-off-by: TripleZ <[email protected]>
  • Loading branch information
Triple-Z committed Sep 22, 2024
1 parent d65cceb commit 2767a4a
Show file tree
Hide file tree
Showing 10 changed files with 257 additions and 12 deletions.
File renamed without changes.
22 changes: 22 additions & 0 deletions example/icbc/debit-v2/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
defaultMinusAccount: Assets:FIXME
defaultPlusAccount: Expenses:FIXME
defaultCashAccount: Assets:Bank:CN:ICBC
defaultCurrency: CNY
title: 测试
icbc:
rules:
- peer: 财付通-,支付宝-
ignore: true
- peer: 支付宝
txType: 蚂蚁基金赎回到银行
ignore: true
- peer: 总行信用卡合伙人
targetAccount: Income:Bank:ICBC:CreditCard
- peer: 掌上生活还款
targetAccount: Liabilities:Bank:CMB:CreditCard
- txType: 自动还款
peer: 广东XX分行银行卡中心
ignore: true
- peer: 张三,李四,王五
txTpe: 汇款,网转,汇入
targetAccount: Assets:Borrow
86 changes: 86 additions & 0 deletions example/icbc/debit-v2/example-icbc-debit-v2-output.beancount
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
option "title" "测试"
option "operating_currency" "CNY"

1970-01-01 open Assets:Borrow
1970-01-01 open Assets:FIXME
1970-01-01 open Expenses:FIXME
1970-01-01 open Income:Bank:ICBC:CreditCard
1970-01-01 open Liabilities:Bank:CMB:CreditCard

2023-02-10 * "总行信用卡合伙人"
cardName: "这是卡别名"
currency: "人民币"
peerAccount: "总行信用卡合伙人"
peerAccountNum: "1234****9876"
source: "中国工商银行"
txType: "合伙人返现"
type: "收入"
Assets:Bank:CN:ICBC 30.00 CNY
Income:Bank:ICBC:CreditCard -30.00 CNY

2023-02-20 * "手机银行 张三"
cardName: "这是卡别名"
currency: "人民币"
peerAccount: "张三"
peerAccountNum: "1234****9876"
source: "中国工商银行"
txType: "跨行汇款"
type: "支出"
Assets:Borrow 1234.56 CNY
Assets:Bank:CN:ICBC -1234.56 CNY

2023-04-14 * "ABC公司"
cardName: "这是卡别名"
currency: "人民币"
peerAccount: "ABC公司"
peerAccountNum: "1234****9876"
source: "中国工商银行"
txType: "工资"
type: "收入"
Assets:Bank:CN:ICBC 1234.56 CNY
Assets:FIXME -1234.56 CNY

2023-04-14 * "手机银行 王五"
cardName: "这是卡别名"
currency: "人民币"
peerAccount: "王五"
peerAccountNum: "1234****9876"
source: "中国工商银行"
txType: "网转"
type: "支出"
Assets:Borrow 500.00 CNY
Assets:Bank:CN:ICBC -500.00 CNY

2023-04-20 * "银联无卡支付业务((特约)掌上生活还款)"
cardName: "这是卡别名"
currency: "人民币"
peerAccount: "银联无卡支付业务((特约)掌上生活还款)"
peerAccountNum: "1234****9876"
source: "中国工商银行"
txType: "银联消费"
type: "支出"
Liabilities:Bank:CMB:CreditCard 1234.56 CNY
Assets:Bank:CN:ICBC -1234.56 CNY

2023-04-22 * "李四"
cardName: "这是卡别名"
currency: "人民币"
peerAccount: "李四"
peerAccountNum: "1234****9876"
source: "中国工商银行"
txType: "他行汇入"
type: "收入"
Assets:Bank:CN:ICBC 1234.56 CNY
Assets:Borrow -1234.56 CNY

2023-05-02 * "广东三元麦当劳食品有 深圳市财付通支付科技有限公司"
cardName: "这是卡别名"
currency: "人民币"
peerAccount: "深圳市财付通支付科技有限公司"
peerAccountNum: "1234****9876"
source: "中国工商银行"
txType: "消费"
type: "支出"
Expenses:FIXME 13.40 CNY
Assets:Bank:CN:ICBC -13.40 CNY

84 changes: 84 additions & 0 deletions example/icbc/debit-v2/example-icbc-debit-v2-output.ledger
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
1970/01/01 * Open Balance
Assets:Borrow 0 CNY
Assets:FIXME 0 CNY
Expenses:FIXME 0 CNY
Income:Bank:ICBC:CreditCard 0 CNY
Liabilities:Bank:CMB:CreditCard 0 CNY
Equity:Opening Balances
2023/02/10 * 总行信用卡合伙人
; cardName: "这是卡别名"
; currency: "人民币"
; peerAccount: "总行信用卡合伙人"
; peerAccountNum: "1234****9876"
; source: "中国工商银行"
; txType: "合伙人返现"
; type: "收入"
Assets:Bank:CN:ICBC 30.00 CNY
Income:Bank:ICBC:CreditCard - 30.00 CNY

2023/02/20 * 手机银行 张三
; cardName: "这是卡别名"
; currency: "人民币"
; peerAccount: "张三"
; peerAccountNum: "1234****9876"
; source: "中国工商银行"
; txType: "跨行汇款"
; type: "支出"
Assets:Borrow 1234.56 CNY
Assets:Bank:CN:ICBC - 1234.56 CNY

2023/04/14 * ABC公司
; cardName: "这是卡别名"
; currency: "人民币"
; peerAccount: "ABC公司"
; peerAccountNum: "1234****9876"
; source: "中国工商银行"
; txType: "工资"
; type: "收入"
Assets:Bank:CN:ICBC 1234.56 CNY
Assets:FIXME - 1234.56 CNY

2023/04/14 * 手机银行 王五
; cardName: "这是卡别名"
; currency: "人民币"
; peerAccount: "王五"
; peerAccountNum: "1234****9876"
; source: "中国工商银行"
; txType: "网转"
; type: "支出"
Assets:Borrow 500.00 CNY
Assets:Bank:CN:ICBC - 500.00 CNY

2023/04/20 * 银联无卡支付业务((特约)掌上生活还款)
; cardName: "这是卡别名"
; currency: "人民币"
; peerAccount: "银联无卡支付业务((特约)掌上生活还款)"
; peerAccountNum: "1234****9876"
; source: "中国工商银行"
; txType: "银联消费"
; type: "支出"
Liabilities:Bank:CMB:CreditCard 1234.56 CNY
Assets:Bank:CN:ICBC - 1234.56 CNY

2023/04/22 * 李四
; cardName: "这是卡别名"
; currency: "人民币"
; peerAccount: "李四"
; peerAccountNum: "1234****9876"
; source: "中国工商银行"
; txType: "他行汇入"
; type: "收入"
Assets:Bank:CN:ICBC 1234.56 CNY
Assets:Borrow - 1234.56 CNY

2023/05/02 * 广东三元麦当劳食品有 深圳市财付通支付科技有限公司
; cardName: "这是卡别名"
; currency: "人民币"
; peerAccount: "深圳市财付通支付科技有限公司"
; peerAccountNum: "1234****9876"
; source: "中国工商银行"
; txType: "消费"
; type: "支出"
Expenses:FIXME 13.40 CNY
Assets:Bank:CN:ICBC - 13.40 CNY

20 changes: 20 additions & 0 deletions example/icbc/debit-v2/example-icbc-debit-v2-records.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
明细查询文件下载

卡号: 1234****9876,"卡别名: 这是卡别名"

子账户序号: 00000,子账户类别: 活期,"子账户别名: "

交易日期,摘要,交易详情,交易场所,交易国家或地区简称,钞/汇,交易金额(收入),交易金额(支出),交易币种,记账金额(收入),记账金额(支出),记账币种,余额,对方户名,对方账户
2023-05-02 ,"消费 "," ","广东三元麦当劳食品有 ","CHN ",钞 ,"- ","- ",- ," ","13.40 ",人民币 ,"xx,yyyy.zz ","深圳市财付通支付科技有限公司 ","1234****9876 ",
2023-04-25 ,"自动还款 "," ","广东XX分行银行卡中心 ","CHN ",钞 ,"- ","- ",- ," ","1,234.56 ",人民币 ,"xx,yyyy.zz ","张三 ","1234****9876 ",
2023-04-22 ,"他行汇入 "," "," ","CHN ",钞 ,"- ","- ",- ,"1,234.56 "," ",人民币 ,"xx,yyyy.zz ","李四 ","1234****9876 ",
2023-04-20 ,"银联消费 "," "," ","CHN ",钞 ,"- ","- ",- ," ","1,234.56 ",人民币 ,"xx,yyyy.zz ","银联无卡支付业务((特约)掌上生活还款) ","1234****9876 ",
2023-04-14 ,"工资 "," "," ","CHN ",钞 ,"- ","- ",- ,"1,234.56 "," ",人民币 ,"xx,yyyy.zz ","ABC公司 ","1234****9876 ",
2023-04-14 ,"网转 "," ","手机银行 ","CHN ",钞 ,"- ","- ",- ," ","500.00 ",人民币 ,"xx,yyyy.zz ","王五 ","1234****9876 ",
2023-02-28 ,"蚂蚁基金赎回到银行 "," ","支付宝 ","CHN ",钞 ,"- ","- ",- ,"341.58 "," ",人民币 ,"xx,yyyy.zz ","支付宝(中国)网络技术有限公司 ","1234****9876 ",
2023-02-20 ,"跨行汇款 "," ","手机银行 ","CHN ",钞 ,"- ","- ",- ," ","1,234.56 ",人民币 ,"xx,yyyy.zz ","张三 ","1234****9876 ",
2023-02-10 ,"合伙人返现 "," "," ","CHN ",钞 ,"- ","- ",- ,"30.00 "," ",人民币 ,"xx,yyyy.zz ","总行信用卡合伙人 ","1234****9876 ",
2023-02-09 ,"消费 "," ","财付通-群收款 ","CHN ",钞 ,"- ","- ",- ," ","24.00 ",人民币 ,"xx,yyyy.zz ","深圳市财付通支付科技有限公司 ","1234****9876 ",
2023-02-08 ,"退款 "," ","财付通-微信红包 ","CHN ",钞 ,"- ","- ",- ,"1.04 "," ",人民币 ,"xx,yyyy.zz ","深圳市财付通支付科技有限公司 ","1234****9876 ",

人民币合计,,,,,,,,,"1,234.56 ","9,876.54 ",
30 changes: 23 additions & 7 deletions test/icbc-test-beancount.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,35 @@ if [ $? -ne 0 ]; then
exit 1
fi

# generate icbc debit bills output in beancount format
# generate icbc debit bills (v1) output in beancount format
"$ROOT_DIR/bin/double-entry-generator" translate \
--provider icbc \
--config "$ROOT_DIR/example/icbc/debit/config.yaml" \
--output "$ROOT_DIR/test/output/test-icbc-debit-output.beancount" \
"$ROOT_DIR/example/icbc/debit/example-icbc-debit-records.csv"
--config "$ROOT_DIR/example/icbc/debit-v1/config.yaml" \
--output "$ROOT_DIR/test/output/test-icbc-debit-v1-output.beancount" \
"$ROOT_DIR/example/icbc/debit-v1/example-icbc-debit-v1-records.csv"

diff -u --color \
"$ROOT_DIR/example/icbc/debit/example-icbc-debit-output.beancount" \
"$ROOT_DIR/test/output/test-icbc-debit-output.beancount"
"$ROOT_DIR/example/icbc/debit-v1/example-icbc-debit-v1-output.beancount" \
"$ROOT_DIR/test/output/test-icbc-debit-v1-output.beancount"

if [ $? -ne 0 ]; then
echo "[FAIL] ICBC provider (debit mode) output is different from expected output."
echo "[FAIL] ICBC provider (debit mode v1) output is different from expected output."
exit 1
fi

# generate icbc debit bills (v2) output in beancount format
"$ROOT_DIR/bin/double-entry-generator" translate \
--provider icbc \
--config "$ROOT_DIR/example/icbc/debit-v2/config.yaml" \
--output "$ROOT_DIR/test/output/test-icbc-debit-v2-output.beancount" \
"$ROOT_DIR/example/icbc/debit-v2/example-icbc-debit-v2-records.csv"

diff -u --color \
"$ROOT_DIR/example/icbc/debit-v2/example-icbc-debit-v2-output.beancount" \
"$ROOT_DIR/test/output/test-icbc-debit-v2-output.beancount"

if [ $? -ne 0 ]; then
echo "[FAIL] ICBC provider (debit mode v2) output is different from expected output."
exit 1
fi

Expand Down
27 changes: 22 additions & 5 deletions test/icbc-test-ledger.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,37 @@ if [ $? -ne 0 ]; then
exit 1
fi

# generate icbc debit bills output in beancount format
# generate icbc debit bills (v1) output in beancount format
"$ROOT_DIR/bin/double-entry-generator" translate \
--provider icbc \
--target ledger \
--config "$ROOT_DIR/example/icbc/debit/config.yaml" \
--config "$ROOT_DIR/example/icbc/debit-v1/config.yaml" \
--output "$DEBIT_OUTPUT" \
"$ROOT_DIR/example/icbc/debit/example-icbc-debit-records.csv"
"$ROOT_DIR/example/icbc/debit-v1/example-icbc-debit-v1-records.csv"

diff -u --color \
"$ROOT_DIR/example/icbc/debit/example-icbc-debit-output.ledger" \
"$ROOT_DIR/example/icbc/debit-v1/example-icbc-debit-v1-output.ledger" \
"$DEBIT_OUTPUT"

if [ $? -ne 0 ]; then
echo "[FAIL] ICBC provider (debit mode) output is different from expected output."
echo "[FAIL] ICBC provider (debit mode v1) output is different from expected output."
exit 1
fi

# generate icbc debit bills (v1) output in beancount format
"$ROOT_DIR/bin/double-entry-generator" translate \
--provider icbc \
--target ledger \
--config "$ROOT_DIR/example/icbc/debit-v2/config.yaml" \
--output "$DEBIT_OUTPUT" \
"$ROOT_DIR/example/icbc/debit-v2/example-icbc-debit-v2-records.csv"

diff -u --color \
"$ROOT_DIR/example/icbc/debit-v2/example-icbc-debit-v2-output.ledger" \
"$DEBIT_OUTPUT"

if [ $? -ne 0 ]; then
echo "[FAIL] ICBC provider (debit mode v2) output is different from expected output."
exit 1
fi

Expand Down

0 comments on commit 2767a4a

Please sign in to comment.