From 6ac372217b9ad10696cf26cd59969a8bae773b36 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sun, 12 Jan 2014 17:46:43 -0800 Subject: [PATCH] docs: more how-to updates --- doc/ALIASES.md | 33 +++++++++++++++++---------------- doc/CSV.md | 39 +++++++++++++++++++++++---------------- 2 files changed, 40 insertions(+), 32 deletions(-) diff --git a/doc/ALIASES.md b/doc/ALIASES.md index f5103e964..895f5995c 100644 --- a/doc/ALIASES.md +++ b/doc/ALIASES.md @@ -2,45 +2,46 @@ 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 assets:cash -and a business.journal: +and a `business.journal`: - 1/1 + 2014/1/1 expenses:office supplies $1 assets:business checking -Here each entity has a simple journal with its own simple chart of -accounts. But at tax reporting time, we need to view these as a single -entity. So in unified.journal we adjust the personal account names to fit -within the business chart of accounts: +So each entity (the business owner, and the business) has their own file with its own simple chart of accounts. +However, at tax reporting time we need to view these as a single entity (at least in the US). +In `unified.journal`, we include both files, and rewrite the personal +account names to fit into the business chart of accounts, alias expenses = equity:draw:personal alias assets:cash = assets:personal cash include personal.journal end aliases + 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 - 2011/01/01 - equity:draw:personal:food $1 - assets:personal cash $-1 - - 2011/01/01 + 2014/01/01 # from business.journal - no aliases applied expenses:office supplies $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 -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: - $ hledger --alias 'my earning=income:business' + $ hledger --alias 'my earning=income:business' ... 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 diff --git a/doc/CSV.md b/doc/CSV.md index 58a67b819..4f294b064 100644 --- a/doc/CSV.md +++ b/doc/CSV.md @@ -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/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 1 + # skip the first CSV line (headings) + skip 1 - # use the first three fields in each CSV record as transaction date, description and amount respectively - fields date, description, amount + # use the first three fields in each CSV record as transaction date, description and amount respectively + fields date, description, amount - # prepend $ to CSV amounts - currency $ + # prepend $ to CSV amounts + currency $ - # always set the first account to assets:bank:checking - account1 assets:bank:checking + # always set the first account to assets:bank:checking + account1 assets:bank:checking - # 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 ~ SAVINGS - account2 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 ~ SAVINGS + account2 assets:bank:savings -[CSV files](MANUAL.html#csv-files) in the manual describes the syntax. - -Now hledger can read this CSV file: +Now hledger can read this CSV file as journal data: $ hledger -f checking.csv print using conversion rules file checking.csv.rules @@ -42,4 +40,13 @@ Now hledger can read this CSV file: assets:bank:checking $-10.00 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