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]更新README, 增加td银行相关的说明 #110

Merged
merged 2 commits into from
Jun 18, 2023
Merged
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
106 changes: 100 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- 火币-币币交易
- 海通证券
- 中国工商银行
- Toronto-Dominion Bank

目前记账语言支持:

Expand All @@ -24,6 +25,7 @@
huobi huobi
htsec htsec
icbc icbc
td td
```

## 安装
Expand Down Expand Up @@ -105,10 +107,20 @@ double-entry-generator translate \

```bash
double-entry-generator translate \
--config ./example/icbc/config.yaml \
--config ./example/icbc/credit/config.yaml \
--provider icbc \
--output ./example/icbc/example-icbc-credit-output.beancount \
./example/icbc/example-icbc-credit-records.csv
--output ./example/icbc/credit/example-icbc-credit-output.beancount \
./example/icbc/credit/example-icbc-credit-records.csv
```

#### Toronto-Dominion Bank

```bash
double-entry-generator translate \
--config ./example/td/config.yaml \
--provider td \
--output ./example/td/example-td-output.beancount \
./example/td/example-td-records.csv
```

### Ledger
Expand Down Expand Up @@ -160,11 +172,22 @@ double-entry-generator translate \

```bash
double-entry-generator translate \
--config ./example/icbc/config.yaml \
--config ./example/icbc/credit/config.yaml \
--provider icbc \
--target ledger \
--output ./example/icbc/example-icbc-credit-output.ledger \
./example/icbc/example-icbc-credit-records.csv
--output ./example/icbc/credit/example-icbc-credit-output.ledger \
./example/icbc/credit/example-icbc-credit-records.csv
```

#### Toronto-Dominion Bank

```bash
double-entry-generator translate \
--config ./example/td/config.yaml \
--provider td \
--target ledger \
--output ./example/td/example-td-output.ledger \
./example/td/example-td-records.csv
```

## 账单下载与格式问题
Expand Down Expand Up @@ -243,6 +266,19 @@ double-entry-generator translate \

信用卡账单转换后的结果示例:[example-icbc-credit-output.beancount](example/icbc/credit/example-icbc-credit-output.beancount).

### Toronto-Dominion Bank

1. 登录TD 网页版本: https://easyweb.td.com/
2. 点击指定的账户
3. 选择账单范围 -> "Select Download Format" -> Spreadsheet(.csv) -> Download

#### 格式示例

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

+ Beancount 转换的结果示例: [example-td-out.beancount](./example/td/example-td-output.beancount)
+ Ledger 转换的结果示例: [example-td-out.ledger](./example/td/example-td-output.ledger)

## 配置

### 支付宝
Expand Down Expand Up @@ -667,6 +703,64 @@ icbc:
| 收入 | targetAccount | defaultCashAccount |
| 支出 | defaultCashAccount | targetAccount |

### Toronto-Dominion Bank

<details>
<summary>
TD银行配置文件示例
</summary>

```yaml
defaultMinusAccount: Assets:FIXME
defaultPlusAccount: Expenses:FIXME
defaultCashAccount: Assets:DebitCard:TDChequing
defaultCurrency: CAD
title: 测试
td:
rules:
- item: "T T"
targetAccount: Expenses:Grocery
tag: tt_tag
- item: "DOLLARAMA"
targetAccount: Expenses:Grocery
tag: grocery_tag1,cheap_tag2
- item: "DEVELOPM MSP"
targetAccount: Income:Salary
- type: 收入
item: "SEND E-TFR"
targetAccount: Income:FIXME

```

</details></br>

`defaultMinusAccount`, `defaultPlusAccount`, `defaultCashAccount` 和 `defaultCurrency` 是全局的必填默认值。其中 `defaultMinusAccount` 是默认金额减少的账户,`defaultPlusAccount` 是默认金额增加的账户, `defaultCashAccount` 是该配置中默认使用的银行卡账户(等同于支付宝/微信中的 `methodAccount` )。 `defaultCurrency` 是默认货币。

`td` 是 Toronto-Dominion Bank相关的配置。它提供基于规则的匹配。因为TD本身的账单较简单,所以可以指定的规则不多:
- `item`:(交易商品)的完全/包含匹配。
- `type`:(收/支)的完全/包含匹配。

在单条规则中可以使用分隔符 `sep` 填写多个关键字,在同一对象中,每个关键字之间是或的关系。

在单条规则中可以使用 `fullMatch` 来设置字符匹配规则,`true` 表示使用完全匹配(full match),`false` 表示使用包含匹配(partial match),不设置该项则默认使用包含匹配。

在单条规则中可以使用 `tag` 来设置流水的 [Beancount Tag](https://beancount.github.io/docs/beancount_language_syntax.html#tags)或[Ledger Meta Tag](https://ledger-cli.org/doc/ledger3.html#Metadata-tags),使用 `sep` 作为分隔符。

在单条规则中可以使用 `ignore` 来设置是否忽略匹配上该规则的交易,`true` 表示忽略匹配上该规则的交易,`fasle` 则为不忽略,缺省为 `false` 。

匹配成功则使用规则中定义的 `targetAccount` 账户覆盖默认定义账户。

规则匹配的顺序是:从 `rules` 配置中的第一条开始匹配,如果匹配成功仍继续匹配。也就是后面的规则优先级要**高于**前面的规则。

TD账单中的记账金额中存在收入/支出之分,通过这个机制就可以判断银行卡账户在交易中的正负关系。如支付宝配置类似,匹配成功则使用规则中定义的 `targetAccount` 和全局值 `defaultCashAccount` ,并通过确认该笔交易是收入还是支出,决定 `targetAccount` 和 `defaultCashAccount` 的正负关系,来覆盖默认定义的增减账户。

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

| 收/支 | minusAccount | plusAccount |
| ----- | ------------------ | ------------------ |
| 收入 | targetAccount | defaultCashAccount |
| 支出 | defaultCashAccount | targetAccount |

## Special Thanks

- [dilfish/atb](https://github.com/dilfish/atb) convert alipay bill to beancount version