Skip to content

Commit e1152e8

Browse files
committed
Initial commit
0 parents  commit e1152e8

35 files changed

+1758
-0
lines changed

.coveragerc

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[run]
2+
omit = tests/*

.github/workflows/tests.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# This workflow will install Python dependencies and run tests
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3+
4+
name: Tests
5+
6+
on:
7+
push:
8+
branches: [ "main" ]
9+
pull_request:
10+
branches: [ "main" ]
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
build:
17+
18+
runs-on: ubuntu-latest
19+
strategy:
20+
matrix:
21+
python-version: ["3.9", "3.10", "3.11", "3.12"]
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
- name: Install poetry
26+
run: pipx install poetry
27+
- name: Set up Python ${{ matrix.python-version }}
28+
uses: actions/setup-python@v5
29+
with:
30+
python-version: ${{ matrix.python-version }}
31+
cache: 'poetry'
32+
- name: Install dependencies
33+
run: |
34+
poetry install
35+
- name: Test with pytest
36+
run: |
37+
poetry run pytest

.gitignore

+163
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
# Created by https://www.toptal.com/developers/gitignore/api/python
2+
# Edit at https://www.toptal.com/developers/gitignore?templates=python
3+
4+
### Python ###
5+
# Byte-compiled / optimized / DLL files
6+
__pycache__/
7+
*.py[cod]
8+
*$py.class
9+
10+
# C extensions
11+
*.so
12+
13+
# Distribution / packaging
14+
.Python
15+
build/
16+
develop-eggs/
17+
dist/
18+
downloads/
19+
eggs/
20+
.eggs/
21+
lib/
22+
lib64/
23+
parts/
24+
sdist/
25+
var/
26+
wheels/
27+
share/python-wheels/
28+
*.egg-info/
29+
.installed.cfg
30+
*.egg
31+
MANIFEST
32+
33+
# PyInstaller
34+
# Usually these files are written by a python script from a template
35+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
36+
*.manifest
37+
*.spec
38+
39+
# Installer logs
40+
pip-log.txt
41+
pip-delete-this-directory.txt
42+
43+
# Unit test / coverage reports
44+
htmlcov/
45+
.tox/
46+
.nox/
47+
.coverage
48+
.coverage.*
49+
.cache
50+
nosetests.xml
51+
coverage.xml
52+
*.cover
53+
*.py,cover
54+
.hypothesis/
55+
.pytest_cache/
56+
cover/
57+
58+
# Translations
59+
*.mo
60+
*.pot
61+
62+
# Django stuff:
63+
*.log
64+
local_settings.py
65+
db.sqlite3
66+
db.sqlite3-journal
67+
68+
# Flask stuff:
69+
instance/
70+
.webassets-cache
71+
72+
# Scrapy stuff:
73+
.scrapy
74+
75+
# Sphinx documentation
76+
docs/_build/
77+
78+
# PyBuilder
79+
.pybuilder/
80+
target/
81+
82+
# pyenv
83+
# For a library or package, you might want to ignore these files since the code is
84+
# intended to run in multiple environments; otherwise, check them in:
85+
# .python-version
86+
87+
# pipenv
88+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
90+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
91+
# install all needed dependencies.
92+
#Pipfile.lock
93+
94+
# poetry
95+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
96+
# This is especially recommended for binary packages to ensure reproducibility, and is more
97+
# commonly ignored for libraries.
98+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
99+
#poetry.lock
100+
101+
# pdm
102+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
103+
#pdm.lock
104+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
105+
# in version control.
106+
# https://pdm.fming.dev/#use-with-ide
107+
.pdm.toml
108+
109+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
110+
__pypackages__/
111+
112+
# Celery stuff
113+
celerybeat-schedule
114+
celerybeat.pid
115+
116+
# SageMath parsed files
117+
*.sage.py
118+
119+
# Environments
120+
.env
121+
.venv
122+
env/
123+
venv/
124+
ENV/
125+
env.bak/
126+
venv.bak/
127+
128+
# Spyder project settings
129+
.spyderproject
130+
.spyproject
131+
132+
# Rope project settings
133+
.ropeproject
134+
135+
# mkdocs documentation
136+
/site
137+
138+
# mypy
139+
.mypy_cache/
140+
.dmypy.json
141+
dmypy.json
142+
143+
# Pyre type checker
144+
.pyre/
145+
146+
# pytype static type analyzer
147+
.pytype/
148+
149+
# Cython debug symbols
150+
cython_debug/
151+
152+
# PyCharm
153+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
154+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
155+
# and can be added to the global gitignore or merged into this file. For a more nuclear
156+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
157+
#.idea/
158+
159+
### Python Patch ###
160+
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
161+
poetry.toml
162+
163+
# End of https://www.toptal.com/developers/gitignore/api/python

LICENSE

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright (c) 2024 Rick Lan
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Beancount Multitool
2+
3+
![Test badge](https://github.com/rlan/beancount-multitool/actions/workflows/python-app.yml/badge.svg)
4+
![python version required](https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2Frlan%2Fbeancount-multitool%2Fmain%2Fpyproject.toml)
5+
![static coverage badge](https://img.shields.io/badge/Coverage-97%25-blue)
6+
7+
Beancount Multitool is a command-line-interface (CLI) tool that converts financial data from financial institutions to Beancount files.
8+
9+
The following institutions are supported:
10+
11+
* Japan
12+
* [JA Bank JAネットバンク](https://www.jabank.jp/)
13+
* [Rakuten Card 楽天カード](https://www.rakuten-card.co.jp/)
14+
* [Rakuten Bank 楽天銀行](https://www.rakuten-bank.co.jp/)
15+
* [SBI Shinsei Bank 新生銀行](https://www.sbishinseibank.co.jp/)
16+
17+
What these scripts __can__ do:
18+
19+
* Read raw CSV files downloaded from each institution's website.
20+
* Label debit and credit transactions to respective account types.
21+
* Debit: `Expenses:JP:Unknown:NameOfInstitution`
22+
* Credit: `Income:JP:Unknown:NameOfInstitution`
23+
24+
What these scripts __can not__ (yet) do:
25+
26+
* Label transactions with different sub-accounts, e.g., `Expenses:JP:Food:Grocery` or `Expenses:JP:Food:Restaurant`.
27+
28+
Usage:
29+
30+
```txt
31+
$ bean-mt --help
32+
Usage: bean-mt [OPTIONS] NAME CONFIG DATA
33+
34+
Read financial data and output a Beancount file.
35+
36+
NAME is the name of the financial institution, e.g. RakutenBank.
37+
38+
CONFIG is a .toml file with run-time configurations, e.g. config.toml.
39+
40+
DATA is the raw financial data downloaded from NAME, e.g. input.csv.
41+
42+
Options:
43+
--output PATH Resulting Beancount file
44+
--version Show the version and exit.
45+
--help Show this message and exit.
46+
```
47+
48+
Example:
49+
50+
```sh
51+
bean-mt rakuten_bank config.toml 2024-01.csv --output 2024-01.bean
52+
```
53+
54+
Workflow:
55+
56+
1. Download the raw CSV files from a financial institutions.
57+
2. Run `bean-mt`.
58+
3. Include the `output.bean` file in my ledger.
59+
4. Manually edit that Beancount file to my needs.
60+
61+
config.toml:
62+
63+
There is a default config.toml per financial institutions. Examples are in the test [data folder](./tests/data/).
64+
65+
## Installation
66+
67+
```sh
68+
pip install beancount-multitool
69+
```
70+
71+
## Requirements
72+
73+
* Python 3.9 or higher.
74+
75+
## More
76+
77+
* [Todo](./todo.md)
78+
* [Changelog](./changelog.md)
79+
* [Development](./development.md)
80+
81+
## License
82+
83+
MIT License

changelog.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changelog
2+
3+
0.1.0
4+
5+
* Initial version.

development.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Development
2+
3+
Instructions for developers.
4+
5+
## macOS
6+
7+
Install
8+
9+
* [Homebrew](https://brew.sh/)
10+
* [pyenv](https://github.com/pyenv/pyenv) (optional)
11+
* [Poetry](https://github.com/python-poetry/poetry)
12+
13+
## Project
14+
15+
* `git clone`
16+
17+
* Install
18+
19+
```sh
20+
poetry install
21+
```
22+
23+
* Development
24+
25+
Launch virtualenv:
26+
27+
```sh
28+
poetry shell
29+
```
30+
31+
Test:
32+
33+
```sh
34+
pytest
35+
```
36+
37+
Run code coverage:
38+
39+
```sh
40+
pytest --cov --cov-report term
41+
```
42+
43+
* Publish
44+
45+
* https://www.digitalocean.com/community/tutorials/how-to-publish-python-packages-to-pypi-using-poetry-on-ubuntu-22-04

0 commit comments

Comments
 (0)