Ledger

带有命令行报告界面的复式记帐系统。「Double-entry accounting system with a command-line reporting interface」

Github stars Tracking Chart

Ledger:命令行会计

Ledger是一个功能强大的两次记帐系统,可从UNIX命令行访问。由于没有浮华的UI,这可能会推迟一些用户,但是对于那些想要无与伦比的报告访问其数据的用户,几乎没有其他选择。

分类帐使用文本文件进行输入。它读取文件并生成报告;没有其他数据库或存储状态。要使用Ledger,您需要创建一个包含帐户名和交易记录的文件,从命令行运行一些选项来指定输入和请求的报告,并获取输出。输出通常是纯文本,尽管您可以生成图形或html。 Ledger概念简单,功能惊人,并且易于使用。

对于急躁的人

我知道,您只想构建并发挥作用。如果您已安装所有依赖项,则只需执行以下操作:

$ git clone git://github.com/ledger/ledger.git
$ cd ledger && ./acprep update  # Update to the latest, configure, make

现在尝试第一个分类帐命令:

$ ./ledger -f test/input/sample.dat reg

要获得保存日志的帮助,请查看文档wiki(另请参阅此文件末尾的“资源”部分)。 可以在 [ledger/ledger-mode 存储库] 中找到 Ledger 文件的 Emacs 模式,而 vim 插件位于 ledger/vim-ledger 存储库中。

Docker 版本

如果您在计算机或服务器上安装了 Docker,则可以使用该软件的 Docker 版本,而无需安装任何其他依赖项:

$ docker run --rm -v "$PWD"/test/input:/data dcycle/ledger:1 -f /data/sample.dat reg

依存关系

如果您想继续进行这项冒险,则需要一些依赖项。 为您的平台获取它们的最简单方法是运行以下方便的Python脚本:

$ ./acprep dependencies

如果那不能完全解决问题,那么这里是构建当前 master 分支的依赖项:

依赖 版本(或更高版本)
Boost 1.49
GMP 4.2.2
MPFR 2.4.0
utfcpp 2.3.4
gettext 0.17 optional
libedit 20090111-3.0 optional
Python 2.4 optional
doxygen 1.5.7.1 optional, for make docs
graphviz 2.20.3 optional, for make docs
texinfo 4.13 optional, for make docs
lcov 1.6 optional, for make report, used with /./acprep gcov
sloccount 2.26 optional, for make sloc

macOS

您可以使用 HomebrewMacPorts 在 macOS 上轻松安装 Ledger。

1.Homebrew

您可以通过 brew 选项分类帐命令查看在安装 brew 时可以传递的参数。 要安装分类帐,只需键入以下命令:

$ brew install ledger

如果要启动 python,请使用以下命令:

$ ledger python

2. MacPorts

如果像我一样在 macOS 上使用 MacPorts 构建东西,则将运行以下命令:

$ sudo port install -f cmake python37 \
     libiconv zlib gmp \
     mpfr ncurses ncursesw \
     gettext libedit boost-jam \
     boost +st+python37+icu texlive doxygen graphviz \
     texinfo lcov sloccount

Conda

Ledger 也可以通过 conda-forge 渠道通过 Conda 获得:

$ conda install -c conda-forge ledger

Ubuntu

如果要在 Ubuntu 上进行构建,请使用 sudo apt-get install ... 以下软件包(从 Ubuntu 18.04 开始使用):

$ sudo apt-get install build-essential cmake doxygen \
     libboost-system-dev libboost-dev python3-dev gettext git \
     libboost-date-time-dev libboost-filesystem-dev \
     libboost-iostreams-dev libboost-python-dev libboost-regex-dev \
     libboost-test-dev libedit-dev libgmp3-dev libmpfr-dev texinfo tzdata

Debian

Debian 9 (stretch), Debian 10 (buster), Debian testing 和 Debian unstable(sid)包含构建 ledger 所需的所有组件。 您可以使用以下命令安装所有必需的构建依赖项:

$ sudo apt-get install build-essential cmake autopoint texinfo python3-dev \
     zlib1g-dev libbz2-dev libgmp3-dev gettext libmpfr-dev \
     libboost-date-time-dev libboost-filesystem-dev \
     libboost-graph-dev libboost-iostreams-dev \
     libboost-python-dev libboost-regex-dev libboost-test-dev

构建

下一步是为构建环境做准备。而你可以使用cmake。还有make,我已经准备了一个脚本,可以为您做更多的工作。

$ ./acprep update
# or, if you want to use the Boost libraries with suffix -mt, install in
# $HOME/local and build with 2 processes in parallel
$ ./acprep update --boost-suffix=-mt --prefix=$HOME/local -j2

如果配置步骤失败,请阅读 CMakeFiles/CMakeOutput.log 和 CMakeFiles/CMakeError.log 的内容。 另外,请参阅 acprep 的 help 子命令,其中解释了其许多选项。这几乎是我运行的用于配置、构建和测试 Ledger 的唯一命令。

您可以运行make check确认结果,然后进行install安装。

资源

现在您已经启动并运行,这里有一些需要牢记的资源:

如果您有想法要分享,最好的方法是给我发送补丁程序(我更喜欢附件而不是粘贴的文本),或者在 GitHub 上获得一个帐户。 完成后,派生 Ledger 项目,随意魔改,然后通过 GitHub 向我发送拉请求。


(The first version translated by vz on 2020.07.18)

Main metrics

Overview
Name With Ownerledger/ledger
Primary LanguageC++
Program languageEmacs Lisp (Language Count: 11)
PlatformDocker, Linux, Mac
License:Other
所有者活动
Created At2008-05-12 19:39:49
Pushed At2025-06-01 06:07:07
Last Commit At2025-05-31 22:51:42
Release Count36
Last Release Namev3.3.2 (Posted on 2023-03-30 15:41:27)
First Release Namecpp-rewrite-2006 (Posted on 2008-07-23 05:45:21)
用户参与
Stargazers Count5.6k
Watchers Count109
Fork Count513
Commits Count6.9k
Has Issues Enabled
Issues Count1616
Issue Open Count747
Pull Requests Count643
Pull Requests Open Count14
Pull Requests Close Count138
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

Join the chat at https://gitter.im/use-package/Lobby
Build Status master
Status
License
GitHub release

Ledger: Command-Line Accounting

Ledger is a powerful, double-entry accounting system that is accessed from the
UNIX command-line. This may put off some users, since there is no flashy UI,
but for those who want unparalleled reporting access to their data there are
few alternatives.

Ledger uses text files for input. It reads the files and generates reports;
there is no other database or stored state. To use Ledger, you create a
file of your account names and transactions, run from the command line with
some options to specify input and requested reports, and get output.
The output is generally plain text, though you could generate a graph or
html instead. Ledger is simple in concept, surprisingly rich in ability,
and easy to use.

For the Impatient

I know, you just want to build and play. If you have all the dependencies
installed, then simply do this:

$ git clone git://github.com/ledger/ledger.git
$ cd ledger && ./acprep update  # Update to the latest, configure, make

Now try your first ledger command:

$ ./ledger -f test/input/sample.dat reg

For help on keeping your journal have a look at the
[documentation] and the [wiki][] (Also see the “Resources” section at the
end of this file). An Emacs mode for Ledger files can be found in the
[ledger/ledger-mode repository] and a vim plugin is located in the
[ledger/vim-ledger repository].

Docker version

If you have Docker installed on your computer or server, you can use a Docker version of this software, without installing any further dependencies:

$ docker run --rm -v "$PWD"/test/input:/data dcycle/ledger:1 -f /data/sample.dat reg

Dependencies

If you wish to proceed in this venture, you'll need a few dependencies. The
easiest way to get them for your platform is to run this handy Python
script:

$ ./acprep dependencies

If that doesn't completely work, here are the dependencies for building the
current master branch:

Dependency