DEV Community

Lam
Lam

Posted on

Ledger Cli Cheat Sheet

References

Effective dates

2008/01/01=2008/01/14 Client invoice  ;  estimated date you'll be paid
  Assets:Accounts Receivable            $100.00
  Income: Client name
Enter fullscreen mode Exit fullscreen mode

Say you're in business. If you bill a customer, you can enter something like above. Then, when you receive the payment, you change it to:

2008/01/01=2008/01/15 Client invoice ;  actual date money received
  Assets:Accounts Receivable            $100.00
  Income: Client name
Enter fullscreen mode Exit fullscreen mode

Display

-n, --collapse       # [register] collapse entries
                     # [balance] no grand total
-s, --subtotal       # [balance] show sub-accounts
                     # [other] show subtotals
--flat
Enter fullscreen mode Exit fullscreen mode

Queries

^regex$
@payee
%tag
%tag=value
=note
#code
term and term
term or term
not term
\( term \)
Enter fullscreen mode Exit fullscreen mode

Example:

ledger r ^expenses and @Denny's
ledger r food and @Starbucks and not dining
Enter fullscreen mode Exit fullscreen mode

Filters

-b, --begin DATE
-e, --end DATE

-d payee =~ /pioneer/

-C, --cleared    # (with *)
-U, --uncleared  # (no *)
    --pending    # (with !)

-R, --real       # ignore virtual postings (eg: "(Cash)  $-400")
-L, --actual     # no automated postings (eg: "= /^Income/")

-r, --related   # show the other side
                # "reg -r savings" shows where it comes from)
Enter fullscreen mode Exit fullscreen mode

Register

$ ledger reg
Enter fullscreen mode Exit fullscreen mode

{: .-setup}

  -D, --daily
  -W, --weekly
  -M, --monthly
      --quarterly
  -Y, --yearly
  -s, --subtotal
  --start-of-week monday
Enter fullscreen mode Exit fullscreen mode
  -S, --sort date
  -S, --sort amount
Enter fullscreen mode Exit fullscreen mode

Periods

[interval] [begin] [end]
Enter fullscreen mode Exit fullscreen mode
interval:
  every day|week|month|quarter|year
  every N days|weeks|...
  daily|weekly|...
Enter fullscreen mode Exit fullscreen mode
begin:
  from <spec>
end:
  to <spec>
Enter fullscreen mode Exit fullscreen mode
spec:
  2004
  2004/10/1
Enter fullscreen mode Exit fullscreen mode
$ ledger bal|reg --period "until aug"
$ ledger bal|reg --period "last oct"
$ ledger bal|reg --period "every week"
Enter fullscreen mode Exit fullscreen mode

{: .-setup}

Comments

; line comment
# also line comment
% also line comment
| also line comment
* also line comment
Enter fullscreen mode Exit fullscreen mode

Querying

Budgeting

~ Monthly
  Expenses:Rent  $500
  Expenses:Food  $100
  Expenses        $40 ; everything else
  Assets

~ Yearly
Enter fullscreen mode Exit fullscreen mode
ledger bal --budget Expenses
ledger bal --unbudgeted Expenses
Enter fullscreen mode Exit fullscreen mode

{: .-setup}

Commodity definitions

commodity $
  note American Dollars
  format $1,000.00
  nomarket
  default
Enter fullscreen mode Exit fullscreen mode

Top comments (0)