Cheat Sheet速查表
跳转到主要内容

Hledger 速查表

本文根据 Devhints / Hledger 翻译。代码示例及版本范围沿用原文。

关于

报表

hledger bal {query}
hledger reg {query}

查询

查询

查询功能适用于所有命令(bal, reg等)。 (文档)

Assets           # An account (regex)
acct:Assets      # same
^Assets          # Starting with Assets (eg, not 'Expenses:Assets')

acctonly:A       # no subaccounts

amt:2000         # amount (in absolute value)
amt:<200         # amount comparison (in absolute value)
amt:<+200        # amount comparison
                 # also: <=, >, >=

desc:REGEX      # description
code:REGEX      # transaction code (check number?)
tag:REGEX
cur:'\$'

real:            # real posts
real:0           # virtual posts

depth:N          # --depth 2
not:...          # eg, not:status:!

按状态/类型筛选

real:1           # -R, --real, no virtuals
status:!         #     --pending
status:*         # -C, --cleared
status:          #     --uncleared

周期

用于指定日期和时间区间(见上文)。

date:2015/01/01
date:2015/01/01-    # -b, --begin
date:-2015/01/01    # -e, --end
date2:PERIODEXPR
-p, --period=...
  -p "2009/01/01"
  -p "2009/01/01 to 2009/12/31"
  -p "2009/01/01to2009/12/31"      # spaces optional
  -p "1/1 to 12/31"
  -p "to 2009"
  -p "weekly"                      # -W, --weekly
  -p "weekly 2009/01/01 to 2009/12/31"

时间区间

适用于所有命令(bal, reg等)。以多列模式显示。在 ledger-cli中,仅支持 reg 。也可通过 -p (周期)进行指定。

-D, --daily
-W, --weekly
-M, --monthly
-Q, --quarterly
-Y, --yearly

智能日期

用于 --period, --begin 以及 --end (-p -b -e).

-p 2015/01/01
-p 2015/01
-p 2015
-p january
-p jan
-p 05/25
-b today
-b yesterday
-e tomorrow
-p this week
-p last month
-p this year

显示格式

    --tree          # only in bal
    --flat

    --depth 2       # collapse those under this depth
    --drop 1        # drop top-level accounts
-B, --cost          # convert to default currency
-E, --empty         # don't strip out $0 accounts
    --date2         # use date2 when available

多列模式

当与时间间隔(例如 --weekly):

-T, --row-total
-N, --no-total

此外:(仅在 bal)

    --cumulative    # show ending balance per period
-I, --historical    # like --cumulative but only for --begin
-A, --average

账户

hledger accounts [--tree]

其他命令

hledger balancesheet       # bs
hledger incomestatement    # is
hledger cashflow           # cf
hledger print
hledger activity
hledger stats

示例

# Current balance
  hledger bal Assets
  hledger balancesheet

  hledger balancesheet Assets [--cleared --cost --empty -e tomorrow]
  # ...discard future stuff; convert foreign currencies

# Monthly changes in assets
  hledger bal Assets Liabilities --monthly --tree --historical [--cleared --cost --empty -e tomorrow]

# Weekly expenses
  hledger bal Expenses --weekly --average --tree -b 'last month' [--cleared --cost --empty -e tomorrow]

另请参阅