Skip to content

Commit

Permalink
[feat] add ledger compiler support (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramsayleung authored May 20, 2023
1 parent cd53df8 commit f4fe04d
Show file tree
Hide file tree
Showing 17 changed files with 824 additions and 11 deletions.
28 changes: 17 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,25 +90,31 @@ clean: ## Clean all the temporary files
@rm -rf ./double-entry-generator
@rm -rf ./wasm-dist

test: test-go test-alipay test-wechat test-huobi test-htsec test-icbc ## Run all tests
test: test-go test-alipay-beancount test-alipay-ledger test-wechat-beancount test-wechat-ledger test-huobi-beancount test-htsec-beancount test-icbc-beancount test-icbc-ledger ## Run all tests

test-go: ## Run Golang tests
@go test ./...

test-alipay: ## Run tests for Alipay provider
@$(SHELL) ./test/alipay-test.sh
test-alipay-beancount: ## Run tests for Alipay provider against beancount compiler
@$(SHELL) ./test/alipay-test-beancount.sh
test-alipay-ledger: ## Run tests for Alipay provider against ledger compiler
@$(SHELL) ./test/alipay-test-ledger.sh

test-wechat: ## Run tests for WeChat provider
@$(SHELL) ./test/wechat-test.sh
test-wechat-beancount: ## Run tests for WeChat provider against beancount compiler
@$(SHELL) ./test/wechat-test-beancount.sh
test-wechat-ledger: ## Run tests for WeChat provider against ledger compiler
@$(SHELL) ./test/wechat-test-ledger.sh

test-huobi: ## Run tests for huobi provider
@$(SHELL) ./test/huobi-test.sh
test-huobi-beancount: ## Run tests for huobi provider against beancount compiler
@$(SHELL) ./test/huobi-test-beancount.sh

test-htsec: ## Run tests for htsec provider
@$(SHELL) ./test/htsec-test.sh
test-htsec-beancount: ## Run tests for htsec provider against beancount compiler
@$(SHELL) ./test/htsec-test-beancount.sh

test-icbc: ## Run tests for ICBC provider
@$(SHELL) ./test/icbc-test.sh
test-icbc-beancount: ## Run tests for ICBC provider against beancount compiler
@$(SHELL) ./test/icbc-test-beancount.sh
test-icbc-ledger: ## Run tests for ICBC provider against ledger compiler
@$(SHELL) ./test/icbc-test-ledger.sh

format: ## Format code
@gofmt -s -w pkg
Expand Down
75 changes: 75 additions & 0 deletions example/alipay/example-alipay-output.ledger
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
1970-01-01 * Open Balance
Assets:Alipay 0 CNY
Assets:Alipay:Invest:Fund 0 CNY
Assets:Alipay:Invest:Gold 0 CNY
Assets:FIXME 0 CNY
Expenses:Electronics 0 CNY
Expenses:FIXME 0 CNY
Expenses:Food:Dinner 0 CNY
Expenses:Food:Lunch 0 CNY
Expenses:Groceries 0 CNY
Expenses:Insurance 0 CNY
Income:Alipay:Invest:PnL 0 CNY
Income:Alipay:ShouKuanMa 0 CNY
Income:Alipay:YuEBao:PnL 0 CNY
Income:FIXME 0 CNY
Liabilities:CC:COMM:7449 0 CNY
Equity:Opening Balances
2023-01-18 * xxxx - 转账
; category: "转账红包"
; method: "余额"
; orderId: "2xxxxxxxxxxxxxxxxxxxxxxxxx9"
; payTime: "2023-01-18 10:17:29 +0800 CST"
; source: "支付宝"
; status: "交易成功"
; type: "收入"
Assets:Alipay 222228.50 CNY
Income:FIXME - 222228.50 CNY

2023-02-02 * 蚂蚁财富-蚂蚁(杭州)基金销售有限公司 - 蚂蚁财富-交银定期支付双息平衡混合-卖出至余额宝
; category: "投资理财"
; method: "余额宝"
; orderId: "2xxxxxxxxxxxxxxxxxxxxxxxxxx8"
; payTime: "2023-02-02 15:24:35 +0800 CST"
; source: "支付宝"
; status: "交易成功"
; type: "不计收支"
Expenses:FIXME 99.34 CNY
Assets:Alipay - 99.34 CNY

2023-02-04 * xxxxxxx - 退款-亲情卡
; category: "退款"
; merchantId: "20xxxxxxxxxxxxxxxx5"
; method: "交通银行信用卡(7449)"
; orderId: "2xxxxxxxxxxxxxxxx8"
; payTime: "2023-02-04 18:21:04 +0800 CST"
; source: "支付宝"
; status: "退款成功"
; type: "不计收支"
Liabilities:CC:COMM:7449 16.03 CNY
Expenses:FIXME - 16.03 CNY

2023-02-08 * x4***6 - 商品示例
; category: "日用百货"
; merchantId: "Txxxxxxxxxxxxx0"
; method: "余额"
; orderId: "2xxxxxxxxxxxxxx0"
; payTime: "2023-02-08 14:16:52 +0800 CST"
; source: "支付宝"
; status: "等待确认收货"
; type: "支出"
Expenses:Groceries 20.00 CNY
Assets:Alipay - 20.00 CNY

2023-02-12 * xxxxxxxxxxxx - 亲情卡
; category: "亲友代付"
; merchantId: "20230xxxxxxx014741014xxxxxx"
; method: "交通银行信用卡(7449)"
; orderId: "202302xxxxxx0011000103xxxxxx"
; payTime: "2023-02-12 21:32:14 +0800 CST"
; source: "支付宝"
; status: "交易成功"
; type: "支出"
Expenses:FIXME 49.74 CNY
Liabilities:CC:COMM:7449 - 49.74 CNY

42 changes: 42 additions & 0 deletions example/icbc/credit/example-icbc-credit-output.ledger
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
1970-01-01 * Open Balance
Assets:Bank:CN:ICBC:Savings 0 CNY
Assets:FIXME 0 CNY
Expenses:FIXME 0 CNY
Expenses:Transport:Highway 0 CNY
Equity:Opening Balances
2023-03-20 * 广东联合电子收费股份
; balances: "-16042.73"
; currency: "人民币"
; source: "中国工商银行"
; txType: "********************"
; type: "支出"
Expenses:Transport:Highway 29.45 CNY
Liabilities:Bank:CN:ICBC - 29.45 CNY

2023-04-22 * XX旗舰店
; balances: "-6086.11"
; currency: "人民币"
; source: "中国工商银行"
; txType: "银联在线支付"
; type: "支出"
Expenses:FIXME 0.01 CNY
Liabilities:Bank:CN:ICBC - 0.01 CNY

2023-04-25 * XX分行银行卡中心
; balances: "-1971.63"
; currency: "人民币"
; source: "中国工商银行"
; txType: "人民币自动转帐还款"
; type: "收入"
Liabilities:Bank:CN:ICBC 4621.01 CNY
Assets:Bank:CN:ICBC:Savings - 4621.01 CNY

2023-05-04 * 广东联合电子收费股份
; balances: "-3684.62"
; currency: "人民币"
; source: "中国工商银行"
; txType: "ETC"
; type: "支出"
Expenses:Transport:Highway 12.35 CNY
Liabilities:Bank:CN:ICBC - 12.35 CNY

67 changes: 67 additions & 0 deletions example/icbc/debit/example-icbc-debit-output.ledger
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
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: "总行信用卡合伙人"
; source: "中国工商银行"
; txType: "合伙人返现"
; type: "收入"
Assets:Bank:CN:ICBC 30.00 CNY
Income:Bank:ICBC:CreditCard - 30.00 CNY

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

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

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

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

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

Loading

0 comments on commit f4fe04d

Please sign in to comment.