Skip to main content

A report generator for beancount financial statement.

Project description

Beancount 财报

Build and Publish - action Lint - action Coverage Status Code scanning - action PyPI version

一个给个人用的财报工具,分析 beancount 账本,自动生成资产负债表。

Demo

Balance Sheet

可以 clone 这个仓库重现这个报告:

git clone https://github.com/e7h4n/beancount-financial-statement
cd beancount-financial-statement
python3 -m venv .
. bin/activate
pip3 install .
bean-statement --year 2021 --month 8 --beancount example/main.bean > /tmp/report.html
open /tmp/report.html

安装

pip install beancount-financial-statement

安装后可以通过命令 bean-statement 来使用。

如何使用

  1. 创建一个额外的 layout.txt 文件来控制资产负债表中各个项目的顺序。

例如:

Assets:Current assets:Cash and cash equivalent
Assets:Current assets:Short-term investment
Assets:Current assets:Account receivables
Assets:Non-current assets:Stock and index fund
Assets:Non-current assets:Equipments
Assets:Non-current assets:Real estate
Liabilities:Current liabilities:Credit card
Liabilities:Current liabilities:Account payable
Liabilities:Non-current liabilities:Loan
Equity:Current equity:Current assets
Equity:Current equity:Current liabilities
Equity:Non-current equity:Non-current assets
Equity:Non-current equity:Non-current liabilities

同时在账本开头设置 layout 文件的位置:

1970-01-01 custom "finance-statement-option" "balance_sheet_layout" "layout.txt"

balance_sheet_layout 是相对于账本主文件的路径。

这样的 layout 会让资产负债表从上到下分别是资产、负债和所有者权益。

Layout 中的每一项,都可以在账本中通过 balance_sheet_categoryequity_category 来指定。

  1. 在账本中给所有的 Assets 和 Liabilities 设置类别。

例如:

2019-01-01 open Assets:US:BofA
  balance_sheet_category: "Assets:Current assets:Cash and cash equivalent"
  equity_category: "Equity:Current equity:Current assets"

以上这个例子的意思是,将 Assets:US:BofA 这项资产,计入 Assets:Current assets:Cash and cash equivalent 这一分类。同时这项资产会参与 Equity:Current equity:Current assets 这项所有者权益的计算。

再看一个负债的例子:

1980-05-12 open Liabilities:US:Chase:Slate                      USD
  balance_sheet_category: "Liabilities:Current liabilities:Credit card"
  equity_category: "Equity:Current equity:Current liabilities"

这个例子的意思是,将 Liabilities:US:Chase:Slate 这项负债,计入 Liabilities:Current liabilities:Credit card 这一分类,同时这项资产会参与 Equity:Current equity:Current liabilities 的计算。

  1. 在账本中配置财报所使用的货币。

在账本开头设置:

1970-01-01 custom "finance-statement-option" "working_currency" "USD"

这样会把生成的报表所有的货币都统一成 working_currency

  1. 执行命令
bean-statement --year 2021 --month 8 --beancount YOUR_LEDGER_FILE_PATH

如何贡献代码

这里有一些常用的 make 命令:

$ make
Some available commands:
 * test         - Run unit tests and test coverage.
 * code-style   - Check code style (pycodestyle).
 * code-lint    - Check code lints (pyflakes, pyline).

可以通过 venv 在本地快速开始一个开发环境:

git clone https://github.com/e7h4n/beancount-financial-statement
cd beancount-financial-statement
python3 -m venv .
. bin/activate
pip install -e '.[test]'

Todo

  • 资产负债表
  • 易于使用的命令行界面
  • 更多的 Test Case
  • 完善 Pydoc
  • 更好的 Code Style
  • 更多的例子
  • 利润表
  • 现金流量表

License

MIT.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

beancount-financial-statement-0.8.5.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file beancount-financial-statement-0.8.5.tar.gz.

File metadata

File hashes

Hashes for beancount-financial-statement-0.8.5.tar.gz
Algorithm Hash digest
SHA256 a03b7b8a49fb5171a1344375f558c59c29b64201a24b6b998ddc1b2ec35b850f
MD5 8db35867864b0cd45c6f865829c16b40
BLAKE2b-256 d25094c4fb52173f038333065805b32395da3f0a74c36d99d4650610977f52e6

See more details on using hashes here.

File details

Details for the file beancount_financial_statement-0.8.5-py3-none-any.whl.

File metadata

File hashes

Hashes for beancount_financial_statement-0.8.5-py3-none-any.whl
Algorithm Hash digest
SHA256 b899226e7f2f3ccbe5cdd9acfc32f3ccf57e1a7ed331534998a62b28af74b9f6
MD5 00b6c25aa81f40a93df49d1fd58dea0d
BLAKE2b-256 ad230d062f382d16e82135e4d6b779ae3214df20513aff511bd1cc14cbf3ee6a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page