docs: more how-to updates

This commit is contained in:
Simon Michael 2014-01-12 17:46:43 -08:00
parent 854f26512a
commit 6ac372217b
2 changed files with 40 additions and 32 deletions

View File

@ -2,45 +2,46 @@
Here's an example of using [account aliases](MANUAL.html#account-aliases). Here's an example of using [account aliases](MANUAL.html#account-aliases).
Say a sole proprietor has a personal.journal: Say a sole proprietor has a `personal.journal`:
1/1 2014/1/2
expenses:food $1 expenses:food $1
assets:cash assets:cash
and a business.journal: and a `business.journal`:
1/1 2014/1/1
expenses:office supplies $1 expenses:office supplies $1
assets:business checking assets:business checking
Here each entity has a simple journal with its own simple chart of So each entity (the business owner, and the business) has their own file with its own simple chart of accounts.
accounts. But at tax reporting time, we need to view these as a single However, at tax reporting time we need to view these as a single entity (at least in the US).
entity. So in unified.journal we adjust the personal account names to fit In `unified.journal`, we include both files, and rewrite the personal
within the business chart of accounts: account names to fit into the business chart of accounts,
alias expenses = equity:draw:personal alias expenses = equity:draw:personal
alias assets:cash = assets:personal cash alias assets:cash = assets:personal cash
include personal.journal include personal.journal
end aliases end aliases
include business.journal include business.journal
giving: Now we can see the data from both files at once, and the personal account names have changed:
$ hledger -f unified.journal print $ hledger -f unified.journal print
2011/01/01 2014/01/01 # from business.journal - no aliases applied
equity:draw:personal:food $1
assets:personal cash $-1
2011/01/01
expenses:office supplies $1 expenses:office supplies $1
assets:business checking $-1 assets:business checking $-1
2014/01/02 # from personal.journal
equity:draw:personal:food $1 # <- was expenses:food
assets:personal cash $-1 # <- was assets:cash
You can also specify aliases on the command line. This could be useful to You can also specify aliases on the command line. This could be useful to
rewrite account names when sharing a report with someone else, such as quickly rewrite account names when sharing a report with someone else, such as
your accountant: your accountant:
$ hledger --alias 'my earning=income:business' $ hledger --alias 'my earning=income:business' ...
Command-line alias options are applied after any alias directives in the Command-line alias options are applied after any alias directives in the
journal. At most one alias directive and one alias option will be applied journal. At most one alias directive and one alias option will be applied

View File

@ -8,28 +8,26 @@ Say we have downloaded `checking.csv` from a bank for the first time:
"2012/3/22","DEPOSIT","50.00" "2012/3/22","DEPOSIT","50.00"
"2012/3/23","TRANSFER TO SAVINGS","-10.00" "2012/3/23","TRANSFER TO SAVINGS","-10.00"
We could create `checking.csv.rules` containing: We tell hledger how to intepret this with a file named `checking.csv.rules`, using the [rules syntax](MANUAL.html#csv-files). Eg:
# skip the first CSV line (headings) # skip the first CSV line (headings)
skip 1 skip 1
# use the first three fields in each CSV record as transaction date, description and amount respectively # use the first three fields in each CSV record as transaction date, description and amount respectively
fields date, description, amount fields date, description, amount
# prepend $ to CSV amounts # prepend $ to CSV amounts
currency $ currency $
# always set the first account to assets:bank:checking # always set the first account to assets:bank:checking
account1 assets:bank:checking account1 assets:bank:checking
# if the CSV record contains SAVINGS, set the second account to assets:bank:savings # if the CSV record contains SAVINGS, set the second account to assets:bank:savings
# (if not set, it will be expenses:unknown or income:unknown) # (if not set, it will be expenses:unknown or income:unknown)
if ~ SAVINGS if ~ SAVINGS
account2 assets:bank:savings account2 assets:bank:savings
[CSV files](MANUAL.html#csv-files) in the manual describes the syntax. Now hledger can read this CSV file as journal data:
Now hledger can read this CSV file:
$ hledger -f checking.csv print $ hledger -f checking.csv print
using conversion rules file checking.csv.rules using conversion rules file checking.csv.rules
@ -42,4 +40,13 @@ Now hledger can read this CSV file:
assets:bank:checking $-10.00 assets:bank:checking $-10.00
We might save this output as `checking.journal`, and/or merge it (manually) into the main journal file. We might save this output as `checking.journal`, and/or merge it (manually) into the main journal file.
We could also run other commands:
$ hledger -f checking.csv balance
using conversion rules file checking.csv.rules
$50.00 assets:bank
$40.00 checking
$10.00 savings
$-50.00 income:unknown
--------------------
0