Skip to content

Commit

Permalink
feat: support jd provider (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
CNLHC authored Apr 17, 2024
1 parent dd479fe commit d0cf159
Show file tree
Hide file tree
Showing 15 changed files with 912 additions and 1 deletion.
59 changes: 59 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,17 @@ double-entry-generator translate \
+ Beancount 转换的结果示例: [example-bmo-out.beancount](./example/bmo/debit/example-bmo-output.beancount)
+ Ledger 转换的结果示例: [example-bmo-out.ledger](./example/bmo/debit/example-bmo-output.ledger)

### 京东

1. 打开京东手机 APP
2. 前往我的 -> 我的钱包 -> 账单
3. 点击右上角 Icon(三条横杠)
4. 选择“账单导出(仅限个人对账)”

#### 格式示例

[example-jd-records.csv](./example/jd/example-jd-records.csv)

## 配置

### 支付宝
Expand Down Expand Up @@ -855,6 +866,54 @@ BMO账单中的记账金额中存在收入/支出之分,通过这个机制就
| 收入 | targetAccount | defaultCashAccount |
| 支出 | defaultCashAccount | targetAccount |

### 京东

```yaml
defaultMinusAccount: Assets:FIXME
defaultPlusAccount: Expenses:FIXME
defaultCurrency: CNY
title: 测试
jd:
rules:
- method: 京东白条
methodAccount: Liabilities:Baitiao
- method: 小金库零用钱
methodAccount: Assets:EPay:JD
- item: 椰子
targetAccount: Expenses:Food
- item: 京东小金库-转入
peer: 京东金融
targetAccount: Assets:EPay:JD
- category: 美妆个护
targetAccount: Expenses:MakeUp
- item: "食品酒饮"
targetAccount: Assets:Food
- peer: 亲密卡
targetAccount: Expenses:Prpaid
- item: 白条,还款
targetAccount: Liabilities:Baitiao
- item: 京东小金库收益
fullMatch: true
targetAccount: Income:PnL:JD
methodAccount: Assets:EPay:JD
```

京东账单的格式总体上和[支付宝](#支付宝-3)类似。

京东账单在交易类别为`不计收支`时,账户的处理分为两种情况:

1. 一般情况:`收/付款方式`(即`method`匹配的字段) 一般为支出账户, `交易分类`(即 `category` 匹配的字段)一般为收入账户。例如银行卡资金转入京东小金库时,`收/付款方式` 为银行卡,`交易分类` 为小金库; 白条还款时,`收/付款方式` 为银行卡或小金库零用钱,`交易分类` 为白条。

2. 特殊情况:`交易说明`(即`item`匹配的字段)的前缀为`冻结-`或`解冻-`时为`不计收支`的特殊情况。`冻结-`情形下, `收/付款方式`为支出账户; `解冻-`情形下 `收/付款方式`为收入账户但是金额为 0。目前所有和`冻结` , `解冻` 相关的交易会被忽略。

`targetAccount` 与 `methodAccount` 的增减账户关系如下表:

| 收/支 | minusAccount | plusAccount |
| -------- | ------------- | ------------- |
| 收入 | targetAccount | methodAccount |
| 支出 | methodAccount | targetAccount |
| 不计收支 | methodAccount | targetAccount |

## Special Thanks

- [dilfish/atb](https://github.com/dilfish/atb) convert alipay bill to beancount version
27 changes: 27 additions & 0 deletions example/jd/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
defaultMinusAccount: Assets:FIXME
defaultPlusAccount: Expenses:FIXME
defaultCurrency: CNY
title: 测试
jd:
rules:
- method: 京东白条
methodAccount: Liabilities:Baitiao
- method: 小金库零用钱
methodAccount: Assets:EPay:JD
- item: 椰子
targetAccount: Expenses:Food
- item: 京东小金库-转入
peer: 京东金融
targetAccount: Assets:EPay:JD
- category: 美妆个护
targetAccount: Expenses:MakeUp
- item: "食品酒饮"
targetAccount: Assets:Food
- peer: 亲密卡
targetAccount: Expenses:Prpaid
- item: 白条,还款
targetAccount: Liabilities:Baitiao
- item: 京东小金库收益
fullMatch: true
targetAccount: Income:PnL:JD
methodAccount: Assets:EPay:JD
167 changes: 167 additions & 0 deletions example/jd/example-jd-output.beancount
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
option "title" "测试"
option "operating_currency" "CNY"

1970-01-01 open Assets:EPay:JD
1970-01-01 open Assets:FIXME
1970-01-01 open Assets:Food
1970-01-01 open Expenses:FIXME
1970-01-01 open Expenses:Food
1970-01-01 open Expenses:MakeUp
1970-01-01 open Expenses:Prpaid
1970-01-01 open Income:PnL:JD
1970-01-01 open Liabilities:Baitiao

2021-11-17 * "京东金融" "京东小金库-转入"
category: "小金库"
merchantId: "100000000000000000000027"
method: "银行卡"
orderId: "2000000000000079"
payTime: "2021-11-17 23:06:50 +0800 CST"
source: "京东金融"
status: "交易成功"
type: "不计收支"
Assets:EPay:JD 2990.13 CNY
Assets:FIXME -2990.13 CNY

2021-12-11 * "亲密卡" "亲密卡"
category: "线下消费"
merchantId: "160000000000000000000006"
method: "京东白条"
payTime: "2021-12-11 23:51:52 +0800 CST"
source: "亲密卡"
status: "交易成功"
type: "支出"
Expenses:Prpaid 238.18 CNY
Liabilities:Baitiao -238.18 CNY

2021-12-12 * "亲密卡" "亲密卡"
category: "线下消费"
merchantId: "100000000000000000000045"
method: "京东白条"
payTime: "2021-12-12 19:06:00 +0800 CST"
source: "亲密卡"
status: "交易成功"
type: "支出"
Expenses:Prpaid 53.00 CNY
Liabilities:Baitiao -53.00 CNY

2021-12-15 * "京东金融" "白条主动还款"
category: "白条"
merchantId: "107500000000000000000058"
method: "小金库零用钱"
orderId: "2000000000000000000"
payTime: "2021-12-15 12:09:23 +0800 CST"
source: "京东金融"
status: "交易成功"
type: "不计收支"
Liabilities:Baitiao 1125.43 CNY
Assets:EPay:JD -1125.43 CNY

2021-12-15 * "京东平台商户" "退款-freeplus洁面乳150ml"
category: "网购"
merchantId: "2000000000000000954"
method: "京东白条"
orderId: "88438843884"
payTime: "2021-12-15 18:35:00 +0800 CST"
source: "京东平台商户"
status: "交易成功"
type: "收入"
Liabilities:Baitiao 112.98 CNY
Assets:FIXME -112.98 CNY

2021-12-15 * "京东平台商户" "退款-freeplus洁面乳150ml"
category: "网购"
merchantId: "2000000000000000000"
method: "京东白条"
orderId: "88438843884"
payTime: "2021-12-15 19:29:00 +0800 CST"
source: "京东平台商户"
status: "交易成功"
type: "收入"
Liabilities:Baitiao 1.00 CNY
Assets:FIXME -1.00 CNY

2021-12-15 * "Food" "Food"
category: "食品酒饮"
merchantId: "110000000000000000000000"
method: "京东白条"
orderId: "200000000014"
payTime: "2021-12-15 19:35:14 +0800 CST"
source: "Food"
status: "交易成功"
type: "支出"
Expenses:FIXME 79.88 CNY
Liabilities:Baitiao -79.88 CNY

2021-12-16 * "京东平台商户" "退款-freeplus洁面乳150ml"
category: "网购"
merchantId: "1000000000000000000"
method: "京东白条"
orderId: "88438843884"
payTime: "2021-12-16 08:22:00 +0800 CST"
source: "京东平台商户"
status: "交易成功"
type: "收入"
Liabilities:Baitiao 1.00 CNY
Assets:FIXME -1.00 CNY

2021-12-18 * "京东平台商户" "freeplus洁面乳150ml"
category: "美妆个护"
merchantId: "100000000000000000000002"
method: "京东白条"
orderId: "88438843884"
payTime: "2021-12-18 19:45:25 +0800 CST"
source: "京东平台商户"
status: "交易成功"
type: "支出"
Expenses:MakeUp 223.99 CNY
Liabilities:Baitiao -223.99 CNY

2021-12-23 * "Members" "Members Mark 泰国进口 椰子水 1L*6支 椰子汁饮料"
category: "食品酒饮"
merchantId: "110000000000000000000044"
method: "京东白条"
orderId: "234906303557"
payTime: "2021-12-23 12:04:37 +0800 CST"
source: "Members"
status: "交易成功"
type: "支出"
Expenses:Food 91.42 CNY
Liabilities:Baitiao -91.42 CNY

2021-12-28 * "京东小金库" "京东小金库收益"
category: "小金库"
merchantId: "29999999999999999992"
method: "小金库零用钱"
orderId: "20000000000000000002"
payTime: "2021-12-28 12:14:38 +0800 CST"
source: "京东小金库"
status: "交易成功"
type: "收入"
Assets:EPay:JD 0.01 CNY
Income:PnL:JD -0.01 CNY

2021-12-29 * "京东小金库" "京东小金库收益"
category: "小金库"
merchantId: "20000000000000000002"
method: "小金库零用钱"
orderId: "20000000000000000022"
payTime: "2021-12-29 06:37:20 +0800 CST"
source: "京东小金库"
status: "交易成功"
type: "收入"
Assets:EPay:JD 0.01 CNY
Income:PnL:JD -0.01 CNY

2023-12-08 * "京东云余额充值预付款网银账户" "PLUS京典年卡(先享后付)"
category: "其他"
merchantId: "700000000000000"
method: "京东白条"
orderId: "700000000000008"
payTime: "2023-12-08 00:14:40 +0800 CST"
source: "京东云余额充值预付款网银账户"
status: "交易成功"
type: "支出"
Expenses:FIXME 99.00 CNY
Liabilities:Baitiao -99.00 CNY

Loading

0 comments on commit d0cf159

Please sign in to comment.