使用 Beancount 记账

系统信息

c 复制代码
$ cat /etc/os-release  
PRETTY_NAME="Ubuntu 22.04.1 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.1 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

安装及简单使用

c 复制代码
// 目标工具
sudo -H python3 -m pip install beancount 
c 复制代码
辅助工具
fava // 帮助显示
	sudo -H python3 -m pip install  fava
	// 转换 (微信/支付宝/京东/银行) csv 文件 为 Beancount/Ledger 文件
double-entry-generator 
	从github下载
		https://github.com/deb-sig/double-entry-generator
		https://github.com/deb-sig/double-entry-generator.git
c 复制代码
1. 生成 一个名为 example.beancount 的 账本
bean-example > example.beancount
2. 以账本信息搭建web服务器
fava example.bean
3. 查看 账本信息
在web浏览器中输入 http://localhost:5000

其他(待研究)

c 复制代码
三个工具
	beancount 包
		bean-check
		bean-doctor
		bean-example
		bean-format
		treeify
	fava 包
		
	double-entry-generator 工具

特点

c 复制代码
1. 账本为文本格式
	便于版本管理
	数据不再受制于人
3. 无美化界面,需要外挂fava

4. fava 采用bs架构 , 无 cs架构

参考文档

详细log

c 复制代码
$ sudo -H python3 -m pip install beancount
[sudo] password for pop: 
Collecting beancount
  Downloading beancount-3.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (285 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 285.7/285.7 KB 21.4 kB/s eta 0:00:00
Requirement already satisfied: python-dateutil>=2.6.0 in /usr/lib/python3/dist-packages (from beancount) (2.8.1)
Requirement already satisfied: click>=7.0 in /usr/lib/python3/dist-packages (from beancount) (8.0.3)
Collecting regex>=2022.9.13
  Downloading regex-2024.7.24-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (776 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 776.5/776.5 KB 16.5 kB/s eta 0:00:00
Installing collected packages: regex, beancount
Successfully installed beancount-3.0.0 regex-2024.7.24
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
c 复制代码
pop@ou:~/tmp/tatarubook$ bean-check
Usage: bean-check [OPTIONS] FILENAME
Try 'bean-check --help' for help.

Error: Missing argument 'FILENAME'.
c 复制代码
$ pip3 show -f beancount
Name: beancount
Version: 3.0.0
Summary: Command-line Double-Entry Accounting
Home-page: https://beancount.github.io/
Author: 
Author-email: Martin Blais <blais@furius.ca>
License: GPL-2.0-only
Location: /usr/local/lib/python3.10/dist-packages
Requires: click, python-dateutil, regex
Required-by: 
Files:
  ../../../bin/bean-check
  ../../../bin/bean-doctor
  ../../../bin/bean-example
  ../../../bin/bean-format
  ../../../bin/treeify
  beancount-3.0.0.dist-info/INSTALLER
  beancount-3.0.0.dist-info/METADATA
  beancount-3.0.0.dist-info/RECORD
  beancount-3.0.0.dist-info/REQUESTED
  beancount-3.0.0.dist-info/WHEEL
  beancount-3.0.0.dist-info/entry_points.txt
  beancount/VERSION
  beancount/__init__.py
  beancount/__pycache__/__init__.cpython-310.pyc
  beancount/__pycache__/api.cpython-310.pyc
  beancount/__pycache__/loader.cpython-310.pyc
  beancount/api.py
  beancount/core/__init__.py
  beancount/core/__pycache__/__init__.cpython-310.pyc
  beancount/core/__pycache__/account.cpython-310.pyc
  beancount/core/__pycache__/account_types.cpython-310.pyc
  beancount/core/__pycache__/amount.cpython-310.pyc
  beancount/core/__pycache__/compare.cpython-310.pyc
  beancount/core/__pycache__/convert.cpython-310.pyc
  beancount/core/__pycache__/data.cpython-310.pyc
  beancount/core/__pycache__/display_context.cpython-310.pyc
  beancount/core/__pycache__/distribution.cpython-310.pyc
  beancount/core/__pycache__/flags.cpython-310.pyc
  beancount/core/__pycache__/getters.cpython-310.pyc
  beancount/core/__pycache__/interpolate.cpython-310.pyc
  beancount/core/__pycache__/inventory.cpython-310.pyc
  beancount/core/__pycache__/number.cpython-310.pyc
  beancount/core/__pycache__/position.cpython-310.pyc
  beancount/core/__pycache__/prices.cpython-310.pyc
  beancount/core/__pycache__/realization.cpython-310.pyc
  beancount/core/account.py
  beancount/core/account_types.py
  beancount/core/amount.py
  beancount/core/compare.py
  beancount/core/convert.py
  beancount/core/data.py
  beancount/core/display_context.py
  beancount/core/distribution.py
  beancount/core/flags.py
  beancount/core/getters.py
  beancount/core/interpolate.py
  beancount/core/inventory.py
  beancount/core/number.py
  beancount/core/position.py
  beancount/core/prices.py
  beancount/core/realization.py
  beancount/loader.py
  beancount/ops/__init__.py
  beancount/ops/__pycache__/__init__.cpython-310.pyc
  beancount/ops/__pycache__/balance.cpython-310.pyc
  beancount/ops/__pycache__/basicops.cpython-310.pyc
  beancount/ops/__pycache__/compress.cpython-310.pyc
  beancount/ops/__pycache__/documents.cpython-310.pyc
  beancount/ops/__pycache__/find_prices.cpython-310.pyc
  beancount/ops/__pycache__/lifetimes.cpython-310.pyc
  beancount/ops/__pycache__/pad.cpython-310.pyc
  beancount/ops/__pycache__/summarize.cpython-310.pyc
  beancount/ops/__pycache__/validation.cpython-310.pyc
  beancount/ops/balance.py
  beancount/ops/basicops.py
  beancount/ops/compress.py
  beancount/ops/documents.py
  beancount/ops/find_prices.py
  beancount/ops/lifetimes.py
  beancount/ops/pad.py
  beancount/ops/summarize.py
  beancount/ops/validation.py
  beancount/parser/__init__.py
  beancount/parser/__pycache__/__init__.cpython-310.pyc
  beancount/parser/__pycache__/booking.cpython-310.pyc
  beancount/parser/__pycache__/booking_full.cpython-310.pyc
  beancount/parser/__pycache__/booking_method.cpython-310.pyc
  beancount/parser/__pycache__/cmptest.cpython-310.pyc
  beancount/parser/__pycache__/context.cpython-310.pyc
  beancount/parser/__pycache__/grammar.cpython-310.pyc
  beancount/parser/__pycache__/hashsrc.cpython-310.pyc
  beancount/parser/__pycache__/lexer.cpython-310.pyc
  beancount/parser/__pycache__/options.cpython-310.pyc
  beancount/parser/__pycache__/parser.cpython-310.pyc
  beancount/parser/__pycache__/printer.cpython-310.pyc
  beancount/parser/__pycache__/version.cpython-310.pyc
  beancount/parser/_parser.cpython-310-x86_64-linux-gnu.so
  beancount/parser/booking.py
  beancount/parser/booking_full.py
  beancount/parser/booking_method.py
  beancount/parser/cmptest.py
  beancount/parser/context.py
  beancount/parser/decimal.c
  beancount/parser/decimal.h
  beancount/parser/grammar.py
  beancount/parser/grammar.y
  beancount/parser/hashsrc.py
  beancount/parser/lexer.l
  beancount/parser/lexer.py
  beancount/parser/macros.h
  beancount/parser/options.py
  beancount/parser/parser.c
  beancount/parser/parser.h
  beancount/parser/parser.py
  beancount/parser/printer.py
  beancount/parser/tokens.h
  beancount/parser/version.py
  beancount/plugins/__init__.py
  beancount/plugins/__pycache__/__init__.cpython-310.pyc
  beancount/plugins/__pycache__/auto.cpython-310.pyc
  beancount/plugins/__pycache__/auto_accounts.cpython-310.pyc
  beancount/plugins/__pycache__/check_average_cost.cpython-310.pyc
  beancount/plugins/__pycache__/check_closing.cpython-310.pyc
  beancount/plugins/__pycache__/check_commodity.cpython-310.pyc
  beancount/plugins/__pycache__/check_drained.cpython-310.pyc
  beancount/plugins/__pycache__/close_tree.cpython-310.pyc
  beancount/plugins/__pycache__/coherent_cost.cpython-310.pyc
  beancount/plugins/__pycache__/commodity_attr.cpython-310.pyc
  beancount/plugins/__pycache__/currency_accounts.cpython-310.pyc
  beancount/plugins/__pycache__/implicit_prices.cpython-310.pyc
  beancount/plugins/__pycache__/leafonly.cpython-310.pyc
  beancount/plugins/__pycache__/noduplicates.cpython-310.pyc
  beancount/plugins/__pycache__/nounused.cpython-310.pyc
  beancount/plugins/__pycache__/onecommodity.cpython-310.pyc
  beancount/plugins/__pycache__/pedantic.cpython-310.pyc
  beancount/plugins/__pycache__/sellgains.cpython-310.pyc
  beancount/plugins/__pycache__/unique_prices.cpython-310.pyc
  beancount/plugins/auto.py
  beancount/plugins/auto_accounts.py
  beancount/plugins/check_average_cost.py
  beancount/plugins/check_closing.py
  beancount/plugins/check_commodity.py
  beancount/plugins/check_drained.py
  beancount/plugins/close_tree.py
  beancount/plugins/coherent_cost.py
  beancount/plugins/commodity_attr.py
  beancount/plugins/currency_accounts.py
  beancount/plugins/implicit_prices.py
  beancount/plugins/leafonly.py
  beancount/plugins/noduplicates.py
  beancount/plugins/nounused.py
  beancount/plugins/onecommodity.py
  beancount/plugins/pedantic.py
  beancount/plugins/sellgains.py
  beancount/plugins/unique_prices.py
  beancount/projects/__init__.py
  beancount/projects/__pycache__/__init__.cpython-310.pyc
  beancount/projects/__pycache__/export.cpython-310.pyc
  beancount/projects/export.py
  beancount/scripts/__init__.py
  beancount/scripts/__pycache__/__init__.cpython-310.pyc
  beancount/scripts/__pycache__/check.cpython-310.pyc
  beancount/scripts/__pycache__/deps.cpython-310.pyc
  beancount/scripts/__pycache__/directories.cpython-310.pyc
  beancount/scripts/__pycache__/doctor.cpython-310.pyc
  beancount/scripts/__pycache__/example.cpython-310.pyc
  beancount/scripts/__pycache__/format.cpython-310.pyc
  beancount/scripts/check.py
  beancount/scripts/deps.py
  beancount/scripts/directories.py
  beancount/scripts/doctor.py
  beancount/scripts/example.py
  beancount/scripts/format.py
  beancount/tools/__init__.py
  beancount/tools/__pycache__/__init__.cpython-310.pyc
  beancount/tools/__pycache__/treeify.cpython-310.pyc
  beancount/tools/treeify.py
  beancount/utils/__init__.py
  beancount/utils/__pycache__/__init__.cpython-310.pyc
  beancount/utils/__pycache__/bisect_key.cpython-310.pyc
  beancount/utils/__pycache__/date_utils.cpython-310.pyc
  beancount/utils/__pycache__/defdict.cpython-310.pyc
  beancount/utils/__pycache__/encryption.cpython-310.pyc
  beancount/utils/__pycache__/file_utils.cpython-310.pyc
  beancount/utils/__pycache__/import_utils.cpython-310.pyc
  beancount/utils/__pycache__/invariants.cpython-310.pyc
  beancount/utils/__pycache__/memo.cpython-310.pyc
  beancount/utils/__pycache__/misc_utils.cpython-310.pyc
  beancount/utils/__pycache__/pager.cpython-310.pyc
  beancount/utils/__pycache__/snoop.cpython-310.pyc
  beancount/utils/__pycache__/table.cpython-310.pyc
  beancount/utils/__pycache__/test_utils.cpython-310.pyc
  beancount/utils/bisect_key.py
  beancount/utils/date_utils.py
  beancount/utils/defdict.py
  beancount/utils/encryption.py
  beancount/utils/file_utils.py
  beancount/utils/import_utils.py
  beancount/utils/invariants.py
  beancount/utils/memo.py
  beancount/utils/misc_utils.py
  beancount/utils/pager.py
  beancount/utils/snoop.py
  beancount/utils/table.py
  beancount/utils/test_utils.py