ledger: update

This commit is contained in:
Rico Sta. Cruz 2017-08-29 04:26:46 +08:00
parent d9c8e5e7d2
commit 5ee9a0793f
No known key found for this signature in database
GPG Key ID: CAAD38AE2962619A
2 changed files with 210 additions and 117 deletions

View File

@ -54,6 +54,7 @@ a:hover {
color: $base-b3; color: $base-b3;
} }
[aria-hidden] { /* prism.js adds area-hidden which it probably shouldn't */
[aria-hidden]:not(.line-highlight) {
display: none !important; display: none !important;
} }

324
ledger.md
View File

@ -1,111 +1,168 @@
--- ---
title: Ledger CLI title: Ledger CLI
category: Ledger category: Ledger
layout: 2017/sheet
updated: 201708
--- ---
$ ledger bal ### Basic usage
$ ledger reg
$ ledger reg grocery # show entries for grocery ```bash
$ ledger bal assets # check if im broke $ ledger bal
$ ledger reg
```
-b 01/01 # --begin ```bash
-e 01/31 # --end $ ledger reg grocery # show entries for grocery
-S date # --sort $ ledger bal assets # check if im broke
-S amount ```
```bash
-b 01/01 # --begin
-e 01/31 # --end
-S date # --sort
-S amount
```
### Examples ### Examples
# any/all matches ```bash
ledger bal Rent Transportation # any # any/all matches
ledger bal Income and Job # all ledger bal Rent Transportation # any
ledger bal Expenses and not (Drinks or Food) ledger bal Income and Job # all
ledger bal Expenses and not (Drinks or Food)
```
# what did I spend on most? (--sorted) ```bash
ledger reg Expenses -S amount # what did I spend on most? (--sorted)
ledger reg Expenses -S amount
```
# how much did I have at this date? (--end) ```bash
ledger bal -e 01/15 ^Assets ^Liabilities # how much did I have at this date? (--end)
ledger bal -e 01/15 ^Assets ^Liabilities
```
# how much did I spend and earn this month? ```bash
ledger bal ^Expenses ^Income --invert # how much did I spend and earn this month?
# how much was spent over the course of 3 days? (totalled) ledger bal ^Expenses ^Income --invert
ledger reg -b 01/25 -e 01/27 --subtotal ```
ledger reg -b 01/25 -e 01/27 --subtotal grocery
```bash
# how much was spent over the course of 3 days? (totalled)
ledger reg -b 01/25 -e 01/27 --subtotal
ledger reg -b 01/25 -e 01/27 --subtotal grocery
```
Format Format
------ ------
2013/01/03 * Rent for January ### Basic format
Expenses:Rent $600.00
Assets:Savings
* = cleared ```
! = pending 2013/01/03 * Rent for January
Expenses:Rent $600.00
Assets:Savings
```
`*` = cleared, `!` = pending
### Secondary dates ### Secondary dates
2008/01/01=2008/01/14 Client invoice ; estimated date you'll be paid ```
2008/01/01=2008/01/14 Client invoice
```
It can mean anything you want, eg, for the estimated date you'll be paid.
### Balance assertions ### Balance assertions
2008/01/01 * KFC ```
Expenses:Food $20 2008/01/01 * KFC
Assets:Cash $-20 = $500 ; ensures cash is at $500 Expenses:Food $20
Assets:Cash $-20 = $500
```
{: data-line="3"}
`Cash $X = $500` ensures Cash is at $500 after the transaction.
### Balance assignment ### Balance assignment
2008/01/01 * Cash balance ```bash
Assets:Cash = $500 2008/01/01 * Cash balance
Equity:Adjustments Assets:Cash = $500
Equity:Adjustments
2008/01/01 * KFC 2008/01/01 * KFC
Expenses:Food $20 Expenses:Food $20
Assets:Cash = $500 ; figures out what's needed to make it $500 Assets:Cash = $500
```
{: data-line="2,7"}
`ACCOUNT = $500` figures out what's needed to make it $500.
### Payables ### Payables
2008/04/25 * Rent ```bash
(Assets:Checking) -$200 2008/04/25 * Rent
Expenses:Rent (Assets:Checking) -$200
Expenses:Rent
```
{: data-line="2"}
### Commodities ### Commodities
; cost per item ```bash
2010/05/31 * Market ; cost per item
Assets:Fridge 35 apples @ $0.42 2010/05/31 * Market
Assets:Cash Assets:Fridge 35 apples @ $0.42
Assets:Cash
```
{: data-line="3"}
; total cost ```bash
2010/05/31 * Market ; total cost
Assets:Fridge 35 apples @@ $14.70 2010/05/31 * Market
Assets:Cash Assets:Fridge 35 apples @@ $14.70
Assets:Cash
```
{: data-line="3"}
; fixed lot prices ```bash
2010/05/31 * Gas ; fixed lot prices
Expenses:Gasoline 11 GAL {=$2.299} 2010/05/31 * Gas
Assets:Cash Expenses:Gasoline 11 GAL {=$2.299}
Assets:Cash
```
{: data-line="3"}
### Commodity definitions ### Commodity definitions
commodity $ ```
note American Dollars commodity $
format $1,000.00 note American Dollars
nomarket format $1,000.00
default nomarket
default
```
### Budgeting ### Budgeting
~ Monthly ```
Expenses:Rent $500 ~ Monthly
Expenses:Food $100 Expenses:Rent $500
Expenses $40 ; everything else Expenses:Food $100
Assets Expenses $40 ; everything else
Assets
~ Yearly ~ Yearly
```
; ledger bal --budget Expenses ```bash
; ledger bal --unbudgeted Expenses ledger bal --budget Expenses
ledger bal --unbudgeted Expenses
```
{: .-setup}
### Comments ### Comments
@ -115,56 +172,82 @@ Format
| also line comment | also line comment
* also line comment * also line comment
Querying
--------
### Periods ### Periods
[interval] [begin] [end] ```
[interval] [begin] [end]
```
interval: ```
every day|week|month|quarter|year interval:
every N days|weeks|... every day|week|month|quarter|year
daily|weekly|... every N days|weeks|...
begin: daily|weekly|...
from <spec> ```
end:
to <spec>
spec:
2004
2004/10/1
$ ledger bal|reg --period "until aug" ```
$ ledger bal|reg --period "last oct" begin:
$ ledger bal|reg --period "every week" from <spec>
end:
to <spec>
```
```
spec:
2004
2004/10/1
```
```bash
$ ledger bal|reg --period "until aug"
$ ledger bal|reg --period "last oct"
$ ledger bal|reg --period "every week"
```
{: .-setup}
### Register ### Register
$ ledger reg ```bash
-D, --daily $ ledger reg
-W, --weekly ```
-M, --monthly {: .-setup}
--quarterly
-Y, --yearly
-s, --subtotal
--start-of-week monday
-S, --sort date ```bash
-S, --sort amount -D, --daily
-W, --weekly
-M, --monthly
--quarterly
-Y, --yearly
-s, --subtotal
--start-of-week monday
```
```bash
-S, --sort date
-S, --sort amount
```
### Filters ### Filters
-b, --begin DATE ```bash
-e, --end DATE -b, --begin DATE
-e, --end DATE
-d payee =~ /pioneer/ -d payee =~ /pioneer/
-C, --cleared # (with *) -C, --cleared # (with *)
-U, --uncleared # (no *) -U, --uncleared # (no *)
--pending # (with !) --pending # (with !)
-R, --real # ignore virtual postings (eg: "(Cash) $-400") -R, --real # ignore virtual postings (eg: "(Cash) $-400")
-L, --actual # no automated postings (eg: "= /^Income/") -L, --actual # no automated postings (eg: "= /^Income/")
-r, --related # show the other side -r, --related # show the other side
# "reg -r savings" shows where it comes from) # "reg -r savings" shows where it comes from)
```
### Queries ### Queries
@ -185,27 +268,36 @@ Example:
### Display ### Display
-n, --collapse # [register] collapse entries ```bash
# [balance] no grand total -n, --collapse # [register] collapse entries
-s, --subtotal # [balance] show sub-accounts # [balance] no grand total
# [other] show subtotals -s, --subtotal # [balance] show sub-accounts
--flat # [other] show subtotals
--flat
```
### Effective dates ### Effective dates
Say you're in business. If you bill a customer, you can enter something like ```bash
2008/01/01=2008/01/14 Client invoice ; estimated date you'll be paid
Assets:Accounts Receivable $100.00
Income: Client name
```
{: data-line="1"}
2008/01/01=2008/01/14 Client invoice ; estimated date you'll be paid Say you're in business. If you bill a customer, you can enter something like above.
Assets:Accounts Receivable $100.00 Then, when you receive the payment, you change it to:
Income: Client name
Then, when you receive the payment, you change it to ```bash
2008/01/01=2008/01/15 Client invoice ; actual date money received
Assets:Accounts Receivable $100.00
Income: Client name
```
{: data-line="1"}
2008/01/01=2008/01/15 Client invoice ; actual date money received ## References
Assets:Accounts Receivable $100.00 {: .-one-column}
Income: Client name
### See * <http://ledger-cli.org/3.0/doc/ledger3.html>
* <https://gist.github.com/agaviria/3317397>
* http://ledger-cli.org/3.0/doc/ledger3.html {: .-also-see}
* https://gist.github.com/agaviria/3317397