Skip to content

Commit 51248c0

Browse files
committed
Update doc and docstring
1 parent 4ab12e0 commit 51248c0

File tree

18 files changed

+132
-9
lines changed

18 files changed

+132
-9
lines changed

docs/getting-started/index.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Python 3.9, 3.10, 3.11 or 3.12.
66

7-
These versions are tested via CI/CD. Prior versions of Python may work, just untested.
7+
All of these versions are tested via [CI/CD]. Due to use of [removeprefix()][], not compatible with previous versions of Python.
88

99
## Installation
1010

@@ -48,3 +48,7 @@ Options:
4848
Note: supported financial institutions are ['ja_bank', 'rakuten_bank',
4949
'rakuten_card', 'shinsei_bank', 'sumishin_net_bank']
5050
```
51+
52+
53+
[removeprefix()]: https://docs.python.org/3/library/stdtypes.html#str.removeprefix
54+
[CI/CD]: https://github.com/rlan/beancount-multitool/actions/workflows/tests.yml

docs/index.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ The target audience is someone who is quite hands-on with their tools, in the sa
1515
* The CLI tool saves the user from typing transaction from statements. The tool reads the raw CSV files downloaded from supported financial institutions. It converts the transactions in a CSV file to an importable Beancount file.
1616
* For example, it can label all debit transactions as `Expenses:JP:Unknown:NameOfInstitution`.
1717
* and all credit transaction as `Income:JP:Unknown:NameOfInstitution`.
18-
* The CLI tool uses regular expressions to find recurring expenses. Once found, they are labeled by user-defined account and hashtags, e.g. `Expenses:JP:Food:Grocery` or `Expenses:JP:Food:Restaurant`.
19-
* Outgoing money transfers can be found via regular expressions and be labeled with a reserved hashtag (`#reconcile`). Then an unique UUID string is generated and appended to that Beancount transaction. This UUID can be used on the receiving Beancount transaction to "link" them for reconcilation.
18+
* The CLI tool uses regular expressions to find recurring expenses. Once found, they are labeled by user-defined account and tags, e.g. `Expenses:JP:Food:Grocery` or `Expenses:JP:Food:Restaurant`.
19+
* Outgoing money transfers can be found via regular expressions and be labeled with a reserved tag (`#reconcile`). Then an unique UUID string is generated and appended to that Beancount transaction. This UUID can be used on the receiving Beancount transaction to "link" them for reconcilation.
2020

2121
### What is it not good for?
2222

@@ -38,3 +38,9 @@ If I can only list 3 requirements:
3838

3939

4040
[splitting expenses]: https://beancount.github.io/docs/sharing_expenses_with_beancount.html#splitting-expenses
41+
42+
## What are the innovations?
43+
44+
* Parsing the CSV file from each financial instituation to standard data structure, [Pandas Dataframe](https://pandas.pydata.org/pandas-docs/stable/reference/frame.html).
45+
* [Reserved words](usage/tags.md) in tags injects additional metadata to a Beancount transaction.
46+
* I didn't do a survey of tools out there, just a gut feeling.

docs/institutions/ja_bank.md

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ column_names = {
3232

3333
Note on dates. On inspection of the CSV file, there are no year in dates, e.g. 4月30日. Thus, the tool uses the current year during conversion. So if you are converting data from last year, edit the generate bean file after conversion.
3434

35+
### Regular expressions
36+
3537
The following two columns are concatentated then passed to regular expressions for matching: `Transaction Classification` and `Description`.
3638

3739
## Example: label all transactions as default

docs/institutions/rakuten_bank.md

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Header row:
1414
取引日,入出金(円),取引後残高(円),入出金内容
1515
```
1616

17+
### Regular expressions
18+
1719
Regular expressions uses `入出金内容` for matching.
1820

1921
## Example: label all transactions as default

docs/institutions/rakuten_card.md

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Header row:
1414
"利用日","利用店名・商品名","利用者","支払方法","利用金額","支払手数料","支払総額","10月支払金額","11月繰越残高","新規サイン"
1515
```
1616

17+
### Regular expressions
18+
1719
Regular expressions uses `利用店名・商品名` for matching.
1820

1921
## Example: label all transactions as default

docs/institutions/shinsei_bank.md

+4
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@ English header row:
2121
"Value Date","Description","Debit","Credit","Balance"
2222
```
2323

24+
### Regular expressions
25+
2426
Regular expressions uses `摘要` (or `Description`) for matching.
2527

28+
### On sender memo
29+
2630
The raw CSV file does not contain the sender memo that one enters during outgoing money transfers. This info is recorded in the bank's PDF files, instead. My current workaround is manually copying that text from the PDF to the `摘要` (or `Description`) column in the CSV.
2731

2832
## Example: label all transactions as default

docs/institutions/sumishin_net_bank.md

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Header row:
1414
"日付","内容","出金金額(円)","入金金額(円)","残高(円)","メモ"
1515
```
1616

17+
### Regular expressions
18+
1719
The following two columns are concatentated then passed to regular expressions for matching: `内容` and `メモ`.
1820

1921
## Example: label all transactions as default

docs/usage/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ A typical workflow using the CLI tool with a Beancount ledger:
1010

1111
## What to do next?
1212

13-
* For quick start, choose [one](../institutions/index.md) of the financial institutions. Then modify the label-all-as-default example to match your Beacount ledger accounts..
13+
* For quick start, choose [one](../institutions/index.md) of the financial institutions. Then modify the label-all-as-default example to match your Beacount ledger accounts.
1414
* For a simple example of using regular expression to label accounts, see the regular expression example for [JA Bank](../institutions/ja_bank.md).
1515
* Learn about [configurations](configs.md) of `bean-mt` CLI tool.
1616
* Here are some [examples](examples.md) of common usage.

docs/usage/tags.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Tags
2+
3+
A generic Beancount transaction looks like this:
4+
5+
```txt
6+
{date} * "{payee}" "{narration}" {" ".join({tags})}
7+
for key, value in {metadata}: # aka transaction metadata
8+
{key}: "{value}"
9+
{source_account}
10+
{flag}{account} {amount} {currency}
11+
for key, value in {account_metadata}: # aka account metadata
12+
{key}: "{value}"
13+
```
14+
15+
Tags are user input. Here we define a list of reserved words for tags that injects additional metadata.
16+
17+
* `#reconcile`
18+
* Adds a (random) uuid string to a `uuid` key to transaction metadata of a debit transaction (amount is negative). Example:
19+
20+
```txt
21+
uuid: "603cd901-a734-45d0-a100-dc01c22b5b4b"
22+
```
23+
24+
* Adds a empty string to a `uuid` key to transaction metadata of a credit transaction (amount is positive). Example:
25+
26+
```txt
27+
uuid: ""
28+
```
29+
30+
This is to reconcile duplicate transactions for a money transfer between two accounts. My personal convention is to keep the debit one, copy the UUID, paste the UUID to the credit one and comment the credit one.

mkdocs.yml

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ nav:
3636
- getting-started/index.md
3737
- Usage:
3838
- usage/index.md
39+
- usage/tags.md
3940
- usage/configs.md
4041
- usage/examples.md
4142
- Financial Institutions:

src/beancount_multitool/as_transaction.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ def as_transaction(
2424
str
2525
A beancount transaction entry:
2626
27-
{date} * "{payee}" "{narration}" {" ".join(tags)}
28-
for key, value in metadata:
27+
{date} * "{payee}" "{narration}" {" ".join({tags})}
28+
for key, value in {metadata}:
2929
{key}: "{value}"
3030
{source_account}
3131
{flag}{account} {amount} {currency}
32-
for key, value in metadata:
32+
for key, value in {account_metadata}:
3333
{key}: "{value}"
3434
"""
3535
# Add "#" prefix if does not exist

src/beancount_multitool/get_value.py

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ def get_value(config: dict, section: str, variable: str) -> str:
1616
-------
1717
str
1818
value
19+
20+
Raises
21+
------
22+
KeyError
23+
if "section" key or "variable" key does not exist.
1924
"""
2025
if section in config:
2126
if variable in config[section]:

tests/data/ja_bank/README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Read Me
2+
3+
A test case that has no mappings defined, so all transactions are mapped to the default.
4+
5+
Command:
6+
7+
```sh
8+
bean-mt \
9+
ja_bank \
10+
./config.toml \
11+
./test.csv \
12+
--output output.bean
13+
```

tests/data/rakuten_bank/README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Read Me
2+
3+
A test case that has no mappings defined, so all transactions are mapped to the default.
4+
5+
Command:
6+
7+
```sh
8+
bean-mt \
9+
rakuten_bank \
10+
./config.toml \
11+
./test.csv \
12+
--output output.bean
13+
```

tests/data/rakuten_card/README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Read Me
2+
3+
A test case that has no mappings defined, so all transactions are mapped to the default.
4+
5+
Command:
6+
7+
```sh
8+
bean-mt \
9+
rakuten_card \
10+
./config.toml \
11+
./test.csv \
12+
--output output.bean
13+
```

tests/data/shinsei_bank/README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Read Me
2+
3+
A test case that has no mappings defined, so all transactions are mapped to the default.
4+
5+
Command:
6+
7+
```sh
8+
bean-mt \
9+
shinsei_bank \
10+
./config.toml \
11+
./test.csv \
12+
--output output.bean
13+
```
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Read Me
2+
3+
A test case that has no mappings defined, so all transactions are mapped to the default.
4+
5+
Command:
6+
7+
```sh
8+
bean-mt \
9+
suminshin_net_bank \
10+
./config.toml \
11+
./test.csv \
12+
--output output.bean
13+
```

tests/data2/ja_bank/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Read Me
22

3-
A test case that demostrates a reserved hashtag `#reconcile`. This test case also demonstrates multiple account matches for one expense.
3+
A test case that demostrates a reserved tag `#reconcile`. This test case also demonstrates multiple account matches for one expense.
44

55
Command:
66

@@ -9,5 +9,5 @@ bean-mt \
99
ja_bank \
1010
./config.toml \
1111
./test.csv \
12-
--output out.bean
12+
--output output.bean
1313
```

0 commit comments

Comments
 (0)