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;
} }

118
ledger.md
View File

@ -1,101 +1,154 @@
--- ---
title: Ledger CLI title: Ledger CLI
category: Ledger category: Ledger
layout: 2017/sheet
updated: 201708
--- ---
### Basic usage
```bash
$ ledger bal $ ledger bal
$ ledger reg $ ledger reg
```
```bash
$ ledger reg grocery # show entries for grocery $ ledger reg grocery # show entries for grocery
$ ledger bal assets # check if im broke $ ledger bal assets # check if im broke
```
```bash
-b 01/01 # --begin -b 01/01 # --begin
-e 01/31 # --end -e 01/31 # --end
-S date # --sort -S date # --sort
-S amount -S amount
```
### Examples ### Examples
```bash
# any/all matches # any/all matches
ledger bal Rent Transportation # any ledger bal Rent Transportation # any
ledger bal Income and Job # all ledger bal Income and Job # all
ledger bal Expenses and not (Drinks or Food) ledger bal Expenses and not (Drinks or Food)
```
```bash
# what did I spend on most? (--sorted) # what did I spend on most? (--sorted)
ledger reg Expenses -S amount ledger reg Expenses -S amount
```
```bash
# how much did I have at this date? (--end) # how much did I have at this date? (--end)
ledger bal -e 01/15 ^Assets ^Liabilities ledger bal -e 01/15 ^Assets ^Liabilities
```
```bash
# how much did I spend and earn this month? # how much did I spend and earn this month?
ledger bal ^Expenses ^Income --invert ledger bal ^Expenses ^Income --invert
```
```bash
# how much was spent over the course of 3 days? (totalled) # 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
ledger reg -b 01/25 -e 01/27 --subtotal grocery ledger reg -b 01/25 -e 01/27 --subtotal grocery
```
Format Format
------ ------
### Basic format
```
2013/01/03 * Rent for January 2013/01/03 * Rent for January
Expenses:Rent $600.00 Expenses:Rent $600.00
Assets:Savings Assets:Savings
```
* = cleared `*` = cleared, `!` = pending
! = 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 2008/01/01 * KFC
Expenses:Food $20 Expenses:Food $20
Assets:Cash $-20 = $500 ; ensures cash is at $500 Assets:Cash $-20 = $500
```
{: data-line="3"}
`Cash $X = $500` ensures Cash is at $500 after the transaction.
### Balance assignment ### Balance assignment
```bash
2008/01/01 * Cash balance 2008/01/01 * Cash balance
Assets:Cash = $500 Assets:Cash = $500
Equity:Adjustments 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
```bash
2008/04/25 * Rent 2008/04/25 * Rent
(Assets:Checking) -$200 (Assets:Checking) -$200
Expenses:Rent Expenses:Rent
```
{: data-line="2"}
### Commodities ### Commodities
```bash
; cost per item ; cost per item
2010/05/31 * Market 2010/05/31 * Market
Assets:Fridge 35 apples @ $0.42 Assets:Fridge 35 apples @ $0.42
Assets:Cash Assets:Cash
```
{: data-line="3"}
```bash
; total cost ; total cost
2010/05/31 * Market 2010/05/31 * Market
Assets:Fridge 35 apples @@ $14.70 Assets:Fridge 35 apples @@ $14.70
Assets:Cash Assets:Cash
```
{: data-line="3"}
```bash
; fixed lot prices ; fixed lot prices
2010/05/31 * Gas 2010/05/31 * Gas
Expenses:Gasoline 11 GAL {=$2.299} Expenses:Gasoline 11 GAL {=$2.299}
Assets:Cash Assets:Cash
```
{: data-line="3"}
### Commodity definitions ### Commodity definitions
```
commodity $ commodity $
note American Dollars note American Dollars
format $1,000.00 format $1,000.00
nomarket nomarket
default default
```
### Budgeting ### Budgeting
```
~ Monthly ~ Monthly
Expenses:Rent $500 Expenses:Rent $500
Expenses:Food $100 Expenses:Food $100
@ -103,9 +156,13 @@ Format
Assets Assets
~ Yearly ~ Yearly
```
; ledger bal --budget Expenses ```bash
; ledger bal --unbudgeted Expenses ledger bal --budget Expenses
ledger bal --unbudgeted Expenses
```
{: .-setup}
### Comments ### Comments
@ -115,29 +172,50 @@ Format
| also line comment | also line comment
* also line comment * also line comment
Querying
--------
### Periods ### Periods
```
[interval] [begin] [end] [interval] [begin] [end]
```
```
interval: interval:
every day|week|month|quarter|year every day|week|month|quarter|year
every N days|weeks|... every N days|weeks|...
daily|weekly|... daily|weekly|...
```
```
begin: begin:
from <spec> from <spec>
end: end:
to <spec> to <spec>
```
```
spec: spec:
2004 2004
2004/10/1 2004/10/1
```
```bash
$ ledger bal|reg --period "until aug" $ ledger bal|reg --period "until aug"
$ ledger bal|reg --period "last oct" $ ledger bal|reg --period "last oct"
$ ledger bal|reg --period "every week" $ ledger bal|reg --period "every week"
```
{: .-setup}
### Register ### Register
```bash
$ ledger reg $ ledger reg
```
{: .-setup}
```bash
-D, --daily -D, --daily
-W, --weekly -W, --weekly
-M, --monthly -M, --monthly
@ -145,12 +223,16 @@ Format
-Y, --yearly -Y, --yearly
-s, --subtotal -s, --subtotal
--start-of-week monday --start-of-week monday
```
```bash
-S, --sort date -S, --sort date
-S, --sort amount -S, --sort amount
```
### Filters ### Filters
```bash
-b, --begin DATE -b, --begin DATE
-e, --end DATE -e, --end DATE
@ -165,6 +247,7 @@ Format
-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
```bash
-n, --collapse # [register] collapse entries -n, --collapse # [register] collapse entries
# [balance] no grand total # [balance] no grand total
-s, --subtotal # [balance] show sub-accounts -s, --subtotal # [balance] show sub-accounts
# [other] show subtotals # [other] show subtotals
--flat --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 2008/01/01=2008/01/14 Client invoice ; estimated date you'll be paid
Assets:Accounts Receivable $100.00 Assets:Accounts Receivable $100.00
Income: Client name Income: Client name
```
{: data-line="1"}
Then, when you receive the payment, you change it to 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:
```bash
2008/01/01=2008/01/15 Client invoice ; actual date money received 2008/01/01=2008/01/15 Client invoice ; actual date money received
Assets:Accounts Receivable $100.00 Assets:Accounts Receivable $100.00
Income: Client name Income: Client name
```
{: data-line="1"}
### See ## References
{: .-one-column}
* http://ledger-cli.org/3.0/doc/ledger3.html * <http://ledger-cli.org/3.0/doc/ledger3.html>
* https://gist.github.com/agaviria/3317397 * <https://gist.github.com/agaviria/3317397>
{: .-also-see}