packages feed

hledger 1.14.2 → 1.15

raw patch · 69 files changed

+13795/−10909 lines, 69 filesdep +extradep ~hledger-libPVP ok

version bump matches the API change (PVP)

Dependencies added: extra

Dependency ranges changed: hledger-lib

API changes (from Hackage documentation)

- Hledger.Cli.Utils: journalApplyValue :: ReportOpts -> Journal -> IO Journal
+ Hledger.Cli.CliOptions: hiddenflags :: [Flag RawOpts]
+ Hledger.Cli.Commands.Descriptions: descriptions :: CliOpts -> Journal -> IO ()
+ Hledger.Cli.Commands.Descriptions: descriptionsmode :: Mode RawOpts
+ Hledger.Cli.Commands.Diff: diff :: CliOpts -> Journal -> IO ()
+ Hledger.Cli.Commands.Diff: diffmode :: Mode RawOpts
+ Hledger.Cli.Commands.Diff: instance GHC.Classes.Eq Hledger.Cli.Commands.Diff.PostingWithPath
+ Hledger.Cli.Commands.Diff: instance GHC.Show.Show Hledger.Cli.Commands.Diff.PostingWithPath
+ Hledger.Cli.Commands.Notes: notes :: CliOpts -> Journal -> IO ()
+ Hledger.Cli.Commands.Notes: notesmode :: Mode RawOpts
+ Hledger.Cli.Commands.Payees: payees :: CliOpts -> Journal -> IO ()
+ Hledger.Cli.Commands.Payees: payeesmode :: Mode RawOpts
+ Hledger.Cli.Utils: tests_Cli_Utils :: Test ()

Files

CHANGES.md view
@@ -1,6 +1,120 @@ User-visible changes in the hledger command line tool and library.  +# 1.15 2019-09-01++- help: don't require a journal file++- reg: show negative amounts in red, like balance and Ledger+++## General++- There is a new valuation option `--value=TYPE[,COMM]`, with+  backwards-compatible `-B/--cost`, `-V/--market`, `-X/--exchange=COMM`+  variants. These provide control over valuation date (#329), and+  inference of indirect market prices (similar to Ledger's -X) (#131).+  Experimental.+  +- Market valuation (-V/-X/--value) is now much faster (#999):++      +-------------------------------------------++--------------+--------------++      |                                           || hledger-1.14 | hledger-1.15 |+      +===========================================++==============+==============++      | -f examples/10000x1000x10.journal bal -Y  ||         2.43 |         2.44 |+      | -f examples/10000x1000x10.journal bal -YV ||        44.91 |         6.48 |+      | -f examples/10000x1000x10.journal reg -Y  ||         4.60 |         4.15 |+      | -f examples/10000x1000x10.journal reg -YV ||        61.09 |         7.21 |+      +-------------------------------------------++--------------+--------------+++- How date options like `-M` and `-p` interact has been updated and clarified.+  (Jakob Schöttl) (#1008, #1009, #1011)++- Restore `--aux-date` and `--effective` as `--date2` aliases (#1034).+  These Ledger-ish spellings were dropped over the years, to improve+  `--help`'s layout. Now we support them again, as semi-hidden flags+  (`--help` doesn't list them, but they are mentioned in `--date2`'s help).++## commands++- add, web: on Windows, trying to add transactions to a file path+  containing trailing periods (eg `hledger add -f  Documents.\.hledger.journal`) +  now gives an error, since this could cause data loss otherwise (#1056).+  This affects the add command and hledger-web's add form.++- bal: --budget: don't always convert to cost.++- bal: --budget: don't show a percentage when budgeted and actual+  amounts are in different commodities.++- bal/bs/bse: `-H/--historical` or `--cumulative` now disables `-T/--row-total` (#329).+  Multiperiod balance reports which show end balances (eg, `bal -MH` or `bs -M`)+  no longer show a Totals column, since summing end balances generally+  doesn't make sense.++- bs: show end date(s) in title, not transactions date span (#1078)+  Compound balance reports showing ending balances (eg balancesheet),+  now show the ending date (single column) or range of ending+  dates (multi column) in their title. ,, (double comma) is used+  rather than - (hyphen) to suggest a sequence of discrete dates+  rather than a continuous span.++- close: preserve transaction prices (costs) accurately (#1035).+  The generated closing/opening transactions were collapsing/misreporting+  the costs in balances involving multiple costs.+  Now, each separately-priced amount gets its own posting.+  (And only the last of these (for each commodity) gets a balance assertion.)+  Also the equity posting's amount is now always shown explicitly, +  which in multicommodity situations means that multiple equity postings are shown. +  The upshot is that a balance -B report will be unchanged after+  the closing & opening transactions generated by the close command.++- descriptions, payees, notes commands added (Caleb Maclennan)++- Gabriel Ebner's hledger-diff is now a built in command,+  and https://github.com/gebner/hledger-diff is deprecated.++- print: now also canonicalises the display style of balance assertion amounts (#1042)++- reg: fix `--average`, broken since 1.12 (#1003)++- stats: show count of market prices (P directives), and the commodities covered++- tags: add --values flag to list tag values.++- tags: now runs much faster when there many tags++## journal format++- Transactions and postings generated/modified by periodic transaction+  rules and/or transaction modifier rules are now marked with tags+  (`generated-transaction`, `generated-posting`, `modified`) for+  easier troubleshooting and filtering.++## csv format++- When interpolating CSV values, outer whitespace is now stripped.+  This removes a potential snag in amount field assignments (#1051),+  and hopefully is harmless and acceptable otherwise.++- We no longer add inter-field spaces in CSV error messages.+  Some CSV errors would show the problem record, eg:++      2000-01-01,a,"1"+  +  with extra spaces added, eg:++      the CSV record is: "2000-01-01", "a", "1"++  which was inaccurate and not valid RFC-4180 CSV format.++- CSV parse errors are human-readable again (broken since 1.11) (#1038)++- CSV rules now allow the amount to be unassigned, if there is an+  assignment to "balance" (generating a balance assignment in this+  case). (#1000)++ # 1.14.2 2019-03-20  - require easytest <0.3 to fix build issue
Hledger/Cli.hs view
@@ -29,7 +29,8 @@ import Hledger.Cli.Utils import Hledger.Cli.Version -tests_Cli = tests "Cli" [-   tests_Hledger+-- unit tests for code under Hledger.Cli (hledger-lib tests not included)+tests_Cli = tests "Hledger.Cli" [+   tests_Cli_Utils   ,tests_Commands- ]+  ]
Hledger/Cli/CliOptions.hs view
@@ -12,6 +12,7 @@   -- * cmdargs flags & modes   helpflags,   detailedversionflag,+  hiddenflags,   inputflags,   reportflags,   outputflags,@@ -112,7 +113,7 @@  ,flagNone ["version"] (setboolopt "version") "show version information"  ] --- | A hidden flag, just for the hledger executable.+-- | A hidden flag just for the hledger executable. detailedversionflag :: Flag RawOpts detailedversionflag = flagNone ["version+"] (setboolopt "version+") "show version information with extra detail" @@ -121,7 +122,7 @@ inputflags = [   flagReq  ["file","f"]      (\s opts -> Right $ setopt "file" s opts) "FILE" "use a different input file. For stdin, use - (default: $LEDGER_FILE or $HOME/.hledger.journal)"  ,flagReq  ["rules-file"]    (\s opts -> Right $ setopt "rules-file" s opts) "RFILE" "CSV conversion rules file (default: FILE.rules)"- ,flagReq  ["separator"]     (\s opts -> Right $ setopt "separator" s opts) "SEPARATOR" "CSV separator (default: ,)"+ ,flagReq  ["separator"]     (\s opts -> Right $ setopt "separator" s opts) "SEP" "CSV separator (default: ,)"  ,flagReq  ["alias"]         (\s opts -> Right $ setopt "alias" s opts)  "OLD=NEW" "rename accounts named OLD to NEW"  ,flagNone ["anon"]          (setboolopt "anon") "anonymize accounts and payees"  ,flagReq  ["pivot"]         (\s opts -> Right $ setopt "pivot" s opts)  "TAGNAME" "use some other field/tag for account names"@@ -131,6 +132,8 @@ -- | Common report-related flags: --period, --cost, etc. reportflags :: [Flag RawOpts] reportflags = [++  -- report period & interval   flagReq  ["begin","b"]     (\s opts -> Right $ setopt "begin" s opts) "DATE" "include postings/txns on or after this date"  ,flagReq  ["end","e"]       (\s opts -> Right $ setopt "end" s opts) "DATE" "include postings/txns before this date"  ,flagNone ["daily","D"]     (setboolopt "daily") "multiperiod/multicolumn report by day"@@ -138,21 +141,56 @@  ,flagNone ["monthly","M"]   (setboolopt "monthly") "multiperiod/multicolumn report by month"  ,flagNone ["quarterly","Q"] (setboolopt "quarterly") "multiperiod/multicolumn report by quarter"  ,flagNone ["yearly","Y"]    (setboolopt "yearly") "multiperiod/multicolumn report by year"- ,flagReq  ["period","p"]    (\s opts -> Right $ setopt "period" s opts) "PERIODEXP" "set start date, end date, and/or report interval all at once (overrides the flags above)"- ,flagNone ["date2"]         (setboolopt "date2") "match the secondary date instead (see command help for other effects)"+ ,flagReq  ["period","p"]    (\s opts -> Right $ setopt "period" s opts) "PERIODEXP" "set start date, end date, and/or report interval all at once"+ ,flagNone ["date2"]         (setboolopt "date2") "match the secondary date instead. See command help for other effects. (--effective, --aux-date also accepted)"  -- see also hiddenflags +  -- status/realness/depth/zero filters  ,flagNone ["unmarked","U"]  (setboolopt "unmarked") "include only unmarked postings/txns (can combine with -P or -C)"  ,flagNone ["pending","P"]   (setboolopt "pending") "include only pending postings/txns"  ,flagNone ["cleared","C"]   (setboolopt "cleared") "include only cleared postings/txns"  ,flagNone ["real","R"]      (setboolopt "real") "include only non-virtual postings"  ,flagReq  ["depth"]         (\s opts -> Right $ setopt "depth" s opts) "NUM" "(or -NUM): hide accounts/postings deeper than this"  ,flagNone ["empty","E"]     (setboolopt "empty") "show items with zero amount, normally hidden (and vice-versa in hledger-ui/hledger-web)"- ,flagNone ["cost","B"]      (setboolopt "cost") "convert amounts to their cost at transaction time (using the transaction price, if any)"- ,flagNone ["value","V"]     (setboolopt "value") "convert amounts to their market value on the report end date (using the most recent applicable market price, if any)"++  -- valuation+ ,flagNone ["B","cost"]      (setboolopt "B")+   "show amounts converted to their cost, using the transaction price. Equivalent to --value=cost."+ ,flagNone ["V","market"]    (setboolopt "V")+   (unwords+     ["show amounts converted to current market value (single period reports)"+     ,"or period-end market value (multiperiod reports) in their default valuation commodity."+     ,"Equivalent to --value=now / --value=end."+     ])+ ,flagReq ["X","exchange"]   (\s opts -> Right $ setopt "X" s opts) "COMM"+   (unwords+     ["show amounts converted to current (single period reports)"+     ,"or period-end (multiperiod reports) market value in the specified commodity."+     ,"Equivalent to --value=now,COMM / --value=end,COMM."+     ])+ ,flagReq  ["value"]         (\s opts -> Right $ setopt "value" s opts) "TYPE[,COMM]"+   (unlines+     ["TYPE is cost, end, now or YYYY-MM-DD."+     ,"COMM is an optional commodity symbol."+     ,"Shows amounts converted to:"+     ,"- cost using transaction prices, then optionally to COMM using period-end market prices"+     ,"- period-end market value, in default valuation commodity or COMM"+     ,"- current market value, in default valuation commodity or COMM"+     ,"- market value on the given date, in default valuation commodity or COMM"+     ])++  -- generated postings/transactions  ,flagNone ["auto"]          (setboolopt "auto") "apply automated posting rules to modify transactions"  ,flagNone ["forecast"]      (setboolopt "forecast") "apply periodic transaction rules to generate future transactions, to 6 months from now or report end date"+  ] +-- | Common flags that are accepted but not shown in --help,+-- such as --effective, --aux-date.+hiddenflags :: [Flag RawOpts]+hiddenflags = [+  flagNone ["effective","aux-date"] (setboolopt "date2") "Ledger-compatible aliases for --date2"+ ]+ -- | Common output-related flags: --output-file, --output-format... outputflags = [outputFormatFlag, outputFileFlag] outputFormatFlag = flagReq  ["output-format","O"] (\s opts -> Right $ setopt "output-format" s opts) "FMT" "select the output format. Supported formats:\ntxt, csv, html."@@ -231,8 +269,8 @@      --  ]   ,modeGroupFlags = Group {       groupUnnamed = []-     ,groupHidden = []-     ,groupNamed = [generalflagsgroup1]+     ,groupHidden  = hiddenflags+     ,groupNamed   = [generalflagsgroup1]      }   } @@ -244,7 +282,7 @@ -- from a help template and flag/argument specifications. -- Reduces boilerplate a little, though the complicated cmdargs -- flag and argument specs are still required.-hledgerCommandMode :: CommandDoc -> [Flag RawOpts] -> [(String, [Flag RawOpts])] +hledgerCommandMode :: CommandDoc -> [Flag RawOpts] -> [(String, [Flag RawOpts])]   -> [Flag RawOpts] -> ([Arg RawOpts], Maybe (Arg RawOpts)) -> Mode RawOpts hledgerCommandMode doc unnamedflaggroup namedflaggroups hiddenflaggroup argsdescr =   case parseCommandDoc doc of@@ -366,7 +404,7 @@ defaultWidth = 80  -- | Replace any numeric flags (eg -2) with their long form (--depth 2),--- as I'm guessing cmdargs doesn't support this directly.  +-- as I'm guessing cmdargs doesn't support this directly. replaceNumericFlags :: [String] -> [String] replaceNumericFlags = map replace   where@@ -414,10 +452,10 @@       Right _  -> Right ()   -- XXX check registerWidthsFromOpts opts --- | A helper for addon commands: this parses options and arguments from --- the current command line using the given hledger-style cmdargs mode, --- and returns a CliOpts. Or, with --help or -h present, it prints --- long or short help, and exits the program. +-- | A helper for addon commands: this parses options and arguments from+-- the current command line using the given hledger-style cmdargs mode,+-- and returns a CliOpts. Or, with --help or -h present, it prints+-- long or short help, and exits the program. -- When --debug is present, also prints some debug output. -- Note this is not used by the main hledger executable. --@@ -434,7 +472,7 @@ -- hledger options not displayed. -- -- Tips:--- Empty lines in the pre/postamble are removed by cmdargs; +-- Empty lines in the pre/postamble are removed by cmdargs; -- add a space character to preserve them. -- getHledgerCliOpts :: Mode RawOpts -> IO CliOpts@@ -602,7 +640,7 @@ -- or more versions (or two versions that don't look like a -- source/compiled pair), they are all included, with file extensions -- intact.--- +-- hledgerAddons :: IO [String] hledgerAddons = do   -- past bug generator@@ -620,10 +658,10 @@   | takeExtension g `elem` compiledExts = [g] dropRedundantSourceVersion fs = fs -compiledExts = ["",".com",".exe"] +compiledExts = ["",".com",".exe"]  --- | Get all sorted unique filenames in the current user's PATH. +-- | Get all sorted unique filenames in the current user's PATH. -- We do not currently filter out non-file objects or files without execute permission. likelyExecutablesInPath :: IO [String] likelyExecutablesInPath = do@@ -639,8 +677,8 @@  -- | Get the sorted unique filenames of all hledger-* executables in -- the current user's PATH. These are files in any of the PATH directories,--- named hledger-*, with either no extension (and no periods in the name) --- or one of the addonExtensions. +-- named hledger-*, with either no extension (and no periods in the name)+-- or one of the addonExtensions. -- We do not currently filter out non-file objects or files without execute permission. hledgerExecutablesInPath :: IO [String] hledgerExecutablesInPath = filter isHledgerExeName <$> likelyExecutablesInPath
Hledger/Cli/Commands.hs view
@@ -28,9 +28,13 @@   ,module Hledger.Cli.Commands.Checkdupes   ,module Hledger.Cli.Commands.Close   ,module Hledger.Cli.Commands.Commodities+  ,module Hledger.Cli.Commands.Descriptions+  ,module Hledger.Cli.Commands.Diff   ,module Hledger.Cli.Commands.Help   ,module Hledger.Cli.Commands.Import   ,module Hledger.Cli.Commands.Incomestatement+  ,module Hledger.Cli.Commands.Notes+  ,module Hledger.Cli.Commands.Payees   ,module Hledger.Cli.Commands.Prices   ,module Hledger.Cli.Commands.Print   ,module Hledger.Cli.Commands.Printunique@@ -69,10 +73,14 @@ import Hledger.Cli.Commands.Checkdupes import Hledger.Cli.Commands.Close import Hledger.Cli.Commands.Commodities+import Hledger.Cli.Commands.Descriptions+import Hledger.Cli.Commands.Diff import Hledger.Cli.Commands.Files import Hledger.Cli.Commands.Help import Hledger.Cli.Commands.Import import Hledger.Cli.Commands.Incomestatement+import Hledger.Cli.Commands.Notes+import Hledger.Cli.Commands.Payees import Hledger.Cli.Commands.Prices import Hledger.Cli.Commands.Print import Hledger.Cli.Commands.Printunique@@ -82,6 +90,7 @@ import Hledger.Cli.Commands.Roi import Hledger.Cli.Commands.Stats import Hledger.Cli.Commands.Tags+import Hledger.Cli.Utils (tests_Cli_Utils)  -- | The cmdargs subcommand mode (for command-line parsing) -- and IO action (for doing the command's work) for each builtin command.@@ -99,10 +108,14 @@   ,(checkdupesmode         , checkdupes)   ,(closemode              , close)   ,(commoditiesmode        , commodities)+  ,(descriptionsmode        , descriptions)   ,(helpmode               , help')   ,(importmode             , importcmd)   ,(filesmode              , files)+  ,(diffmode               , diff)   ,(incomestatementmode    , incomestatement)+  ,(notesmode              , notes)+  ,(payeesmode             , payees)   ,(pricesmode             , prices)   ,(printmode              , print')   ,(printuniquemode        , printunique)@@ -151,7 +164,7 @@   ," check-dates              check transactions are ordered by date"   ," check-dupes              check for accounts with the same leaf name"   ," close (equity)           generate balance-resetting transactions"-  ,"+diff                     compare account transactions in two journal files"+  ," diff                     compare account transactions in two journal files"   ,"+interest                 generate interest transactions"   ," rewrite                  generate automated postings/diffs (old, use --auto)"   ,""@@ -168,7 +181,10 @@   ," activity                 show postings-per-interval bar charts"   ," balance (b, bal)         show balance changes/end balances/budgets in accounts"   ," commodities              show commodity/currency symbols"+  ," descriptions             show unique transaction descriptions"   ," files                    show input file paths"+  ," notes                    show unique note segments of transaction descriptions"+  ," payees                   show unique payee segments of transaction descriptions"   ," prices                   show market price records"   ," print (p, txns)          show transactions (journal entries)"   ," print-unique             show only transactions with unique descriptions"@@ -256,11 +272,15 @@ --  import System.IO (hSetEncoding, stdout, stderr, utf8) --  hSetEncoding stdout utf8 --  hSetEncoding stderr utf8-  e <- runEasytests args $ EasyTest.tests [tests_Hledger, tests_Commands]+  e <- runEasytests args $ EasyTest.tests [+     tests_Hledger+    ,tests "Hledger.Cli" [+       tests_Cli_Utils+      ,tests_Commands+      ]+    ]   if e then exitFailure else exitSuccess ---- unit tests of hledger command-line executable  tests_Commands = tests "Commands" [    tests_Balance
Hledger/Cli/Commands/Accounts.hs view
@@ -43,7 +43,7 @@   ,flagReq  ["drop"] (\s opts -> Right $ setopt "drop" s opts) "N" "flat mode: omit N leading account name parts"   ]   [generalflagsgroup1]-  []+  hiddenflags   ([], Just $ argsFlag "[QUERY]")  -- | The accounts command.@@ -66,24 +66,24 @@       accts                = dbg5 "accts to show" $ -- no need to nub/sort, accountTree will         if | declared     && not used -> matcheddeclaredaccts            | not declared && used     -> matchedusedaccts-           | otherwise                -> matcheddeclaredaccts ++ matchedusedaccts +           | otherwise                -> matcheddeclaredaccts ++ matchedusedaccts    -- 2. sort them by declaration order and name, at each level of their tree structure       sortedaccts = sortAccountNamesByDeclaration j tree accts -  -- 3. if there's a depth limit, depth-clip and remove any no longer useful items +  -- 3. if there's a depth limit, depth-clip and remove any no longer useful items       clippedaccts =         dbg1 "clippedaccts" $         filter (matchesAccount acctq) $  -- clipping can leave accounts that no longer match the query, remove such         nub $                          -- clipping can leave duplicates (adjacent, hopefully)         filter (not . T.null) $        -- depth:0 can leave nulls-        map (clipAccountName depth) $  -- clip at depth if specified -        sortedaccts +        map (clipAccountName depth) $  -- clip at depth if specified+        sortedaccts -  -- 4. print what remains as a list or tree, maybe applying --drop in the former case +  -- 4. print what remains as a list or tree, maybe applying --drop in the former case   mapM_ (T.putStrLn . render) clippedaccts     where-      render a +      render a         | tree_ ropts = T.replicate (2 * (accountNameLevel a - 1)) " " <> accountLeafName a         | otherwise   = accountNameDrop (drop_ ropts) a 
Hledger/Cli/Commands/Activity.hs view
@@ -2,7 +2,7 @@  {-| -Print a bar chart of posting activity per day, or other report interval. +Print a bar chart of posting activity per day, or other report interval.  -} @@ -22,7 +22,7 @@   $(embedFileRelative "Hledger/Cli/Commands/Activity.txt")   []   [generalflagsgroup1]-  []+  hiddenflags   ([], Just $ argsFlag "[QUERY]")  barchar :: Char
Hledger/Cli/Commands/Add.txt view
@@ -60,3 +60,7 @@ Saved. Starting the next transaction (. or ctrl-D/ctrl-C to quit) Date [2015/05/22]: <CTRL-D> $++On Microsoft Windows, the add command makes sure that no part of the+file path ends with a period, as it can cause data loss on that platform+(cf #1056).
Hledger/Cli/Commands/Balance.hs view
@@ -234,6 +234,7 @@  {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ExtendedDefaultRules #-}+{-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE NamedFieldPuns #-}@@ -295,66 +296,56 @@    ++ outputflags   )   [generalflagsgroup1]-  []+  hiddenflags   ([], Just $ argsFlag "[QUERY]")  -- | The balance command, prints a balance report. balance :: CliOpts -> Journal -> IO ()-balance opts@CliOpts{rawopts_=rawopts,reportopts_=ropts} j = do+balance opts@CliOpts{rawopts_=rawopts,reportopts_=ropts@ReportOpts{..}} j = do   d <- getCurrentDay   case lineFormatFromOpts ropts of     Left err -> error' $ unlines [err]     Right _ -> do-      let format   = outputFormatFromOpts opts-          budget   = boolopt "budget" rawopts-          interval = interval_ ropts-      case (budget, interval) of-        (True, _) -> do-          -- single or multicolumn budget report-          reportspan <- reportSpan j ropts-          let budgetreport     = dbg1 "budgetreport"     $ budgetReport ropts assrt reportspan d j-                where-                  assrt          = not $ ignore_assertions_ $ inputopts_ opts+      let budget      = boolopt "budget" rawopts+          multiperiod = interval_ /= NoInterval+          format      = outputFormatFromOpts opts++      if budget then do  -- single or multi period budget report+        reportspan <- reportSpan j ropts+        let budgetreport     = dbg1 "budgetreport"     $ budgetReport ropts assrt reportspan d j+              where+                assrt          = not $ ignore_assertions_ $ inputopts_ opts+            render = case format of+              "csv"  -> const $ error' "Sorry, CSV output is not yet implemented for this kind of report."  -- TODO+              "html" -> const $ error' "Sorry, HTML output is not yet implemented for this kind of report."  -- TODO+              _      -> budgetReportAsText ropts+        writeOutput opts $ render budgetreport++      else+        if multiperiod then do  -- multi period balance report+          let report = multiBalanceReport ropts (queryFromOpts d ropts) j               render = case format of-                "csv"  -> const $ error' "Sorry, CSV output is not yet implemented for this kind of report."  -- TODO-                "html" -> const $ error' "Sorry, HTML output is not yet implemented for this kind of report."  -- TODO-                _      -> budgetReportAsText ropts-          writeOutput opts $ render budgetreport-          -        (False, NoInterval) -> do-          -- single column balance report+                "csv"  -> (++ "\n") . printCSV . multiBalanceReportAsCsv ropts+                "html" ->  (++ "\n") . TL.unpack . L.renderText . multiBalanceReportAsHtml ropts+                _      -> multiBalanceReportAsText ropts+          writeOutput opts $ render report++        else do  -- single period simple balance report           let report-                | balancetype_ ropts `elem` [HistoricalBalance, CumulativeChange]+                | balancetype_ `elem` [HistoricalBalance, CumulativeChange]                   = let ropts' | flat_ ropts = ropts                                | otherwise   = ropts{accountlistmode_=ALTree}                     in balanceReportFromMultiBalanceReport ropts' (queryFromOpts d ropts) j                           -- for historical balances we must use balanceReportFromMultiBalanceReport (also forces --no-elide)-                | otherwise = balanceReport ropts (queryFromOpts d ropts) j -- simple Ledger-style balance report +                | otherwise = balanceReport ropts (queryFromOpts d ropts) j -- simple Ledger-style balance report               render = case format of                 "csv"  -> \ropts r -> (++ "\n") $ printCSV $ balanceReportAsCsv ropts r                 "html" -> \_ _ -> error' "Sorry, HTML output is not yet implemented for this kind of report."  -- TODO                 _      -> balanceReportAsText           writeOutput opts $ render ropts report-          -        _  -> do-          -- multi column balance report-          let report = multiBalanceReport ropts (queryFromOpts d ropts) j-              render = case format of-                "csv"  -> (++ "\n") . printCSV . multiBalanceReportAsCsv ropts-                "html" ->  (++ "\n") . TL.unpack . L.renderText . multiBalanceReportAsHtml ropts-                _      -> multiBalanceReportAsText ropts-          writeOutput opts $ render report  -- rendering single-column balance reports --- | Find the best commodity to convert to when asked to show the--- market value of this commodity on the given date. That is, the one--- in which it has most recently been market-priced, ie the commodity--- mentioned in the most recent applicable historical price directive--- before this date.--- defaultValuationCommodity :: Journal -> Day -> CommoditySymbol -> Maybe CommoditySymbol--- defaultValuationCommodity j d c = mpamount <$> commodityValue j d c- -- | Render a single-column balance report as CSV. balanceReportAsCsv :: ReportOpts -> BalanceReport -> CSV balanceReportAsCsv opts (items, total) =@@ -467,7 +458,7 @@ -- and will include the final totals row unless --no-total is set. multiBalanceReportAsCsv :: ReportOpts -> MultiBalanceReport -> CSV multiBalanceReportAsCsv opts@ReportOpts{average_, row_total_} (MultiBalanceReport (colspans, items, (coltotals,tot,avg))) =-  maybetranspose $ +  maybetranspose $   ("Account" : map showDateSpan colspans    ++ ["Total"   | row_total_]    ++ ["Average" | average_]@@ -490,7 +481,7 @@   where     maybetranspose | transpose_ opts = transpose                    | otherwise = id-    + -- | Render a multi-column balance report as HTML. multiBalanceReportAsHtml :: ReportOpts -> MultiBalanceReport -> Html () multiBalanceReportAsHtml ropts mbr =@@ -514,7 +505,7 @@   in     (multiBalanceReportHtmlHeadRow ropts headingsrow     ,map (multiBalanceReportHtmlBodyRow ropts) bodyrows-    ,multiBalanceReportHtmlFootRow ropts <$> mtotalsrow -- TODO pad totals row with zeros when there are +    ,multiBalanceReportHtmlFootRow ropts <$> mtotalsrow -- TODO pad totals row with zeros when there are     )  -- | Render one MultiBalanceReport heading row as a HTML table row.@@ -557,8 +548,8 @@ multiBalanceReportHtmlFootRow :: ReportOpts -> [String] -> Html () multiBalanceReportHtmlFootRow _ropts [] = mempty -- TODO pad totals row with zeros when subreport is empty---  multiBalanceReportHtmlFootRow ropts $ ---     "" +--  multiBalanceReportHtmlFootRow ropts $+--     "" --   : repeat nullmixedamt zeros --  ++ (if row_total_ ropts then [nullmixedamt] else []) --  ++ (if average_ ropts   then [nullmixedamt]   else [])@@ -582,48 +573,59 @@  -- | Render a multi-column balance report as plain text suitable for console output. multiBalanceReportAsText :: ReportOpts -> MultiBalanceReport -> String-multiBalanceReportAsText opts r =-    printf "%s in %s:\n\n" desc (showDateSpan $ multiBalanceReportSpan r)-      ++ balanceReportTableAsText opts tabl+multiBalanceReportAsText ropts@ReportOpts{..} r =+    title ++ "\n\n" ++ (balanceReportTableAsText ropts $ balanceReportAsTable ropts r)   where-    tabl = balanceReportAsTable opts r-    desc = case balancetype_ opts of-        PeriodChange -> "Balance changes"-        CumulativeChange -> "Ending balances (cumulative)"-        HistoricalBalance -> "Ending balances (historical)"+    multiperiod = interval_ /= NoInterval+    title = printf "%s in %s%s:"+      (case balancetype_ of+        PeriodChange       -> "Balance changes"+        CumulativeChange   -> "Ending balances (cumulative)"+        HistoricalBalance  -> "Ending balances (historical)")+      (showDateSpan $ multiBalanceReportSpan r)+      (case value_ of+        Just (AtCost _mc)   -> ", valued at cost"+        Just (AtEnd _mc)    -> ", valued at period ends"+        Just (AtNow _mc)    -> ", current value"+        -- XXX duplicates the above+        Just (AtDefault _mc) | multiperiod -> ", valued at period ends"+        Just (AtDefault _mc) -> ", current value"+        Just (AtDate d _mc) -> ", valued at "++showDate d+        Nothing             -> "")  -- | Build a 'Table' from a multi-column balance report. balanceReportAsTable :: ReportOpts -> MultiBalanceReport -> Table String String MixedAmount-balanceReportAsTable opts@ReportOpts{average_, row_total_} (MultiBalanceReport (colspans, items, (coltotals,tot,avg))) =+balanceReportAsTable opts@ReportOpts{average_, row_total_, balancetype_} (MultiBalanceReport (colspans, items, (coltotals,tot,avg))) =    maybetranspose $-   addtotalrow $ +   addtotalrow $    Table      (T.Group NoLine $ map Header accts)      (T.Group NoLine $ map Header colheadings)      (map rowvals items)   where-    mkDate = case balancetype_ opts of+    totalscolumn = row_total_ && not (balancetype_ `elem` [CumulativeChange, HistoricalBalance])+    mkDate = case balancetype_ of        PeriodChange -> showDateSpanMonthAbbrev        _            -> maybe "" (showDate . prevday) . spanEnd     colheadings = map mkDate colspans-                  ++ ["  Total" | row_total_]+                  ++ ["  Total" | totalscolumn]                   ++ ["Average" | average_]     accts = map renderacct items     renderacct (a,a',i,_,_,_)       | tree_ opts = replicate ((i-1)*2) ' ' ++ T.unpack a'       | otherwise  = T.unpack $ maybeAccountNameDrop opts a     rowvals (_,_,_,as,rowtot,rowavg) = as-                             ++ [rowtot | row_total_]+                             ++ [rowtot | totalscolumn]                              ++ [rowavg | average_]     addtotalrow | no_total_ opts = id                 | otherwise      = (+----+ (row "" $                                     coltotals-                                    ++ [tot | row_total_ && not (null coltotals)]+                                    ++ [tot | totalscolumn && not (null coltotals)]                                     ++ [avg | average_   && not (null coltotals)]                                     ))     maybetranspose | transpose_ opts = \(Table rh ch vals) -> Table ch rh (transpose vals)                    | otherwise       = id-                   + -- | Given a table representing a multi-column balance report (for example, -- made using 'balanceReportAsTable'), render it in a format suitable for -- console output.
Hledger/Cli/Commands/Balance.txt view
@@ -94,7 +94,9 @@ %[MIN][.MAX](FIELDNAME)  -   MIN pads with spaces to at least this width (optional)+ -   MAX truncates at this width (optional)+ -   FIELDNAME must be enclosed in parentheses, and can be one of:      -   depth_spacer - a number of spaces equal to the account's depth,@@ -217,6 +219,9 @@      liabilities:debts    ||           0           0          $1      ----------------------++-------------------------------------                           ||           0           0           0 ++Note that --cumulative or --historical/-H disable --row-total/-T, since+summing end balances generally does not make sense.  Multicolumn balance reports display accounts in flat mode by default; to see the hierarchy, use --tree.
Hledger/Cli/Commands/Balancesheet.txt view
@@ -35,7 +35,9 @@ report period. As with multicolumn balance reports, you can alter the report mode with --change/--cumulative/--historical. Normally balancesheet shows historical ending balances, which is what you need-for a balance sheet; note this means it ignores report begin dates.+for a balance sheet; note this means it ignores report begin dates (and+-T/--row-total, since summing end balances generally does not make+sense).  This command also supports output destination and output format selection.
Hledger/Cli/Commands/Checkdates.hs view
@@ -16,7 +16,7 @@   $(embedFileRelative "Hledger/Cli/Commands/Checkdates.txt")   [flagNone ["strict"] (setboolopt "strict") "makes date comparing strict"]   [generalflagsgroup1]-  []+  hiddenflags   ([], Just $ argsFlag "[QUERY]")  checkdates :: CliOpts -> Journal -> IO ()
Hledger/Cli/Commands/Checkdupes.hs view
@@ -3,7 +3,7 @@ module Hledger.Cli.Commands.Checkdupes (   checkdupesmode  ,checkdupes-) +) where  import Data.Function@@ -19,7 +19,7 @@   $(embedFileRelative "Hledger/Cli/Commands/Checkdupes.txt")   []   [generalflagsgroup1]-  []+  hiddenflags   ([], Nothing)  checkdupes _opts j = mapM_ render $ checkdupes' $ accountsNames j
Hledger/Cli/Commands/Close.hs view
@@ -4,10 +4,12 @@ module Hledger.Cli.Commands.Close (   closemode  ,close-) +) where  import Control.Monad (when)+import Data.Function (on)+import Data.List (groupBy) import Data.Maybe import Data.Time.Calendar import System.Console.CmdArgs.Explicit as C@@ -19,15 +21,16 @@   $(embedFileRelative "Hledger/Cli/Commands/Close.txt")   [flagNone ["opening"] (setboolopt "opening") "show just opening transaction"   ,flagNone ["closing"] (setboolopt "closing") "show just closing transaction"+  -- ,flagNone ["explicit","x"] (setboolopt "explicit") "show all amounts explicitly"   ]   [generalflagsgroup1]-  []+  hiddenflags   ([], Just $ argsFlag "[QUERY]")  close CliOpts{rawopts_=rawopts, reportopts_=ropts} j = do   today <- getCurrentDay-  let -      (opening, closing) = +  let+      (opening, closing) =         case (boolopt "opening" rawopts, boolopt "closing" rawopts) of           (False, False) -> (True, True) -- by default show both opening and closing           (o, c) -> (o, c)@@ -36,31 +39,61 @@       openingdate = fromMaybe today $ queryEndDate False q       closingdate = addDays (-1) openingdate       (acctbals,_) = balanceReportFromMultiBalanceReport ropts_ q j-      balancingamt = negate $ sum $ map (\(_,_,_,b) -> normaliseMixedAmountSquashPricesForDisplay b) acctbals+      balancingamt = negate $ sum $ map (\(_,_,_,b) -> normaliseMixedAmount b) acctbals        -- since balance assertion amounts are required to be exact, the       -- amounts in opening/closing transactions should be too (#941)       -- setprec = setFullPrecision-      setprec = setMinimalPrecision-      -- balance assertion amounts will be unpriced, cf #824-      closingps = [posting{paccount=a-                          ,pamount=mixed [setprec $ negate b]-                          ,pbalanceassertion=Just assertion{baamount=setprec b{aquantity=0, aprice=NoPrice}}+      setprec = setNaturalPrecision+      -- balance assertion amounts will be unpriced (#824)+      -- only the last posting in each commodity will have a balance assertion (#1035)+      closingps = [posting{paccount          = a+                          ,pamount           = mixed [setprec $ negate b]+                          ,pbalanceassertion = if islast then Just assertion{baamount=setprec b{aquantity=0, aprice=Nothing}} else Nothing                           }                   | (a,_,_,mb) <- acctbals-                  , b <- amounts $ normaliseMixedAmountSquashPricesForDisplay mb+                    -- the balances in each commodity, and for each transaction price+                  , let bs = amounts $ normaliseMixedAmount mb+                    -- mark the last balance in each commodity+                  , let bs' = concat [reverse $ zip (reverse bs) (True : repeat False)+                                     | bs <- groupBy ((==) `on` acommodity) bs]+                  , (b, islast) <- bs'                   ]-                  ++ [posting{paccount="equity:closing balances", pamount=negate balancingamt}]+                  -- The balancing posting to equity. Allow this one to have a multicommodity amount,+                  -- and don't try to assert its balance.+                  +++                  [posting{paccount = "equity:closing balances"+                          ,pamount  = negate balancingamt+                          }+                  ] -      openingps = [posting{paccount=a-                          ,pamount=mixed [setprec b]-                          ,pbalanceassertion=Just assertion{baamount=setprec b{aprice=NoPrice}}+      openingps = [posting{paccount          = a+                          ,pamount           = mixed [setprec b]+                          ,pbalanceassertion = case mcommoditysum of+                                                 Just s  -> Just assertion{baamount=setprec s{aprice=Nothing}}+                                                 Nothing -> Nothing                           }                   | (a,_,_,mb) <- acctbals-                  , b <- amounts $ normaliseMixedAmountSquashPricesForDisplay mb+                    -- the balances in each commodity, and for each transaction price+                  , let bs = amounts $ normaliseMixedAmount mb+                    -- mark the last balance in each commodity, with the unpriced sum in that commodity+                  , let bs' = concat [reverse $ zip (reverse bs) (Just commoditysum : repeat Nothing)+                                     | bs <- groupBy ((==) `on` acommodity) bs+                                     , let commoditysum = (sum bs)]+                  , (b, mcommoditysum) <- bs'                   ]-                  ++ [posting{paccount="equity:opening balances", pamount=balancingamt}]+                  +++                  [posting{paccount = "equity:opening balances"+                          ,pamount  = balancingamt+                          }+                  ] -  when closing $ putStr $ showTransaction (nulltransaction{tdate=closingdate, tdescription="closing balances", tpostings=closingps})-  when opening $ putStr $ showTransaction (nulltransaction{tdate=openingdate, tdescription="opening balances", tpostings=openingps})+      -- With -x, show all amounts explicitly (ie, also in the balancing equity posting(s)).+      -- print also does it for -B; I think that isn't needed here.+      -- showtxn | boolopt "explicit" rawopts = showTransactionUnelided+      --         | otherwise                  = showTransaction+      showtxn = showTransactionUnelided++  when closing $ putStr $ showtxn (nulltransaction{tdate=closingdate, tdescription="closing balances", tpostings=closingps})+  when opening $ putStr $ showtxn (nulltransaction{tdate=openingdate, tdescription="opening balances", tpostings=openingps}) 
Hledger/Cli/Commands/Close.txt view
@@ -9,7 +9,7 @@  The closing transaction transfers balances to "equity:closing balances". The opening transaction transfers balances from "equity:opening-balances". You can chose to print just one of the transactions by using+balances". You can choose to print just one of the transactions by using the --opening or --closing flag.  If you split your journal files by time (eg yearly), you will typically@@ -40,6 +40,10 @@ balance assertions will depend on these flags. Likewise, if you run this command with --auto, the balance assertions will probably always require --auto.++When account balances have cost information (transaction prices), the+closing/opening transactions will preserve it, so that eg balance -B+reports will not be affected.  Examples: 
+ Hledger/Cli/Commands/Descriptions.hs view
@@ -0,0 +1,44 @@+{-|++The @descriptions@ command lists allpayees seen in transactions.++-}++{-# LANGUAGE MultiWayIf #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE CPP #-}++module Hledger.Cli.Commands.Descriptions (+  descriptionsmode+ ,descriptions+) where++#if !(MIN_VERSION_base(4,11,0))+import Data.Monoid+#endif+import Data.List+import qualified Data.Text.IO as T++import Hledger+import Hledger.Cli.CliOptions+++-- | Command line options for this command.+descriptionsmode = hledgerCommandMode+  $(embedFileRelative "Hledger/Cli/Commands/Descriptions.txt")+  []+  [generalflagsgroup1]+  hiddenflags+  ([], Just $ argsFlag "[QUERY]")++-- | The descriptions command.+descriptions :: CliOpts -> Journal -> IO ()+descriptions CliOpts{reportopts_=ropts} j = do+  d <- getCurrentDay+  let q  = queryFromOpts d ropts+      ts = entriesReport ropts q j+      descriptions = nub $ sort $ map tdescription ts++  mapM_ T.putStrLn descriptions
+ Hledger/Cli/Commands/Descriptions.txt view
@@ -0,0 +1,12 @@+descriptions Show descriptions.++_FLAGS_++This command lists all descriptions that appear in transactions.++Examples:++$ hledger descriptions+Store Name+Gas Station | Petrol+Person A
+ Hledger/Cli/Commands/Diff.hs view
@@ -0,0 +1,126 @@+{-|++The @diff@ command compares two diff.++-}++{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE TemplateHaskell #-}++module Hledger.Cli.Commands.Diff (+  diffmode+ ,diff+) where++import Data.List+import Data.Function+import Data.Ord+import Data.Maybe+import Data.Time+import Data.Either+import qualified Data.Text as T+import System.Exit++import Hledger+import Prelude hiding (putStrLn)+import Hledger.Utils.UTF8IOCompat (putStrLn)+import Hledger.Cli.CliOptions++-- | Command line options for this command.+diffmode = hledgerCommandMode+  $(embedFileRelative "Hledger/Cli/Commands/Diff.txt")+  []+  [generalflagsgroup2]+  []+  ([], Just $ argsFlag "-f FILE1 -f FILE2 FULLACCOUNTTNAME")++data PostingWithPath = PostingWithPath {+                     ppposting :: Posting,+                     pptxnidx :: Int,+                     pppidx :: Int }+                 deriving (Show)++instance Eq PostingWithPath where+    a == b = pptxnidx a == pptxnidx b+          && pppidx a == pppidx b++pptxn :: PostingWithPath -> Transaction+pptxn = fromJust . ptransaction . ppposting++ppamountqty :: PostingWithPath -> Quantity+ppamountqty = aquantity . head . amounts . pamount . ppposting++allPostingsWithPath :: Journal -> [PostingWithPath]+allPostingsWithPath j = do+    (txnidx, txn) <- zip [0..] $ jtxns j+    (pidx, p) <- zip [0..] $ tpostings txn+    return PostingWithPath { ppposting = p, pptxnidx = txnidx, pppidx = pidx }++binBy :: Ord b => (a -> b) -> [a] -> [[a]]+binBy f = groupBy ((==) `on` f) . sortBy (comparing f)++combine :: ([a], [b]) -> [Either a b]+combine (ls, rs) = map Left ls ++ map Right rs++combinedBinBy :: Ord b => (a -> b) -> ([a], [a]) -> [([a], [a])]+combinedBinBy f = map partitionEithers . binBy (either f f) . combine++greedyMaxMatching :: (Eq a, Eq b) => [(a,b)] -> [(a,b)]+greedyMaxMatching = greedyMaxMatching' []++greedyMaxMatching' :: (Eq a, Eq b) => [Either a b] -> [(a,b)] -> [(a,b)]+greedyMaxMatching' alreadyUsed ((l,r):rest)+  | Left l `elem` alreadyUsed || Right r `elem` alreadyUsed+      = greedyMaxMatching' alreadyUsed rest+  | otherwise = (l,r) : greedyMaxMatching' (Left l : Right r : alreadyUsed) rest+greedyMaxMatching' _ [] = []++dateCloseness :: (PostingWithPath, PostingWithPath) -> Integer+dateCloseness = negate . uncurry (diffDays `on` tdate.pptxn)++type Matching = [(PostingWithPath, PostingWithPath)]++matching :: [PostingWithPath] -> [PostingWithPath] -> Matching+matching ppl ppr = do+    (left, right) <- combinedBinBy ppamountqty (ppl, ppr) -- TODO: probably not a correct choice of bins+    greedyMaxMatching $ sortBy (comparing dateCloseness) [ (l,r) | l <- left, r <- right ]++readJournalFile' :: FilePath -> IO Journal+readJournalFile' fn =+    readJournalFile definputopts {ignore_assertions_ = True} fn >>= either error' return++matchingPostings :: AccountName -> Journal -> [PostingWithPath]+matchingPostings acct j = filter ((== acct) . paccount . ppposting) $ allPostingsWithPath j++pickSide :: Side -> (a,a) -> a+pickSide L (l,_) = l+pickSide R (_,r) = r++unmatchedtxns :: Side -> [PostingWithPath] -> Matching -> [Transaction]+unmatchedtxns s pp m =+    map pptxn $ nubBy ((==) `on` pptxnidx) $ pp \\ map (pickSide s) m++-- | The diff command.+diff :: CliOpts -> Journal -> IO ()+diff CliOpts{file_=[f1, f2], reportopts_=ReportOpts{query_=acctName}} _ = do+  j1 <- readJournalFile' f1+  j2 <- readJournalFile' f2++  let acct = T.pack acctName+  let pp1 = matchingPostings acct j1+  let pp2 = matchingPostings acct j2++  let m = matching pp1 pp2++  let unmatchedtxn1 = unmatchedtxns L pp1 m+  let unmatchedtxn2 = unmatchedtxns R pp2 m++  putStrLn "These transactions are in the first file only:\n"+  mapM_ (putStr . showTransaction) unmatchedtxn1++  putStrLn "These transactions are in the second file only:\n"+  mapM_ (putStr . showTransaction) unmatchedtxn2++diff _ _ = do+  putStrLn "Please specify two input files. Usage: hledger diff -f FILE1 -f FILE2 FULLACCOUNTNAME"+  exitFailure
+ Hledger/Cli/Commands/Diff.txt view
@@ -0,0 +1,29 @@+diff+Compares a particular account's transactions in two input files. It+shows any transactions to this account which are in one file but not in+the other.++More precisely, for each posting affecting this account in either file,+it looks for a corresponding posting in the other file which posts the+same amount to the same account (ignoring date, description, etc.) Since+postings not transactions are compared, this also works when multiple+bank transactions have been combined into a single journal entry.++This is useful eg if you have downloaded an account's transactions from+your bank (eg as CSV data). When hledger and your bank disagree about+the account balance, you can compare the bank data with your journal to+find out the cause.++_FLAGS_++Examples:++$ hledger diff -f $LEDGER_FILE -f bank.csv assets:bank:giro +These transactions are in the first file only:++2014/01/01 Opening Balances+    assets:bank:giro              EUR ...+    ...+    equity:opening balances       EUR -...++These transactions are in the second file only:
Hledger/Cli/Commands/Files.hs view
@@ -34,7 +34,7 @@ files CliOpts{rawopts_=rawopts} j = do   let args = listofstringopt "args" rawopts       regex = headMay args-      files = maybe id (filter . regexMatches) regex -              $ map fst +      files = maybe id (filter . regexMatches) regex+              $ map fst               $ jfiles j   mapM_ putStrLn files
Hledger/Cli/Commands/Help.hs view
@@ -46,10 +46,10 @@   []   ([], Just $ argsFlag "[MANUAL]") --- | List or display one of the hledger manuals in various formats. +-- | List or display one of the hledger manuals in various formats. -- You can select a docs viewer with one of the `--info`, `--man`, `--pager`, `--cat` flags. -- Otherwise it will use the first available of: info, man, $PAGER, less, stdout--- (and always stdout if output is non-interactive). +-- (and always stdout if output is non-interactive). help' :: CliOpts -> Journal -> IO () help' opts _ = do   exes <- likelyExecutablesInPath@@ -60,18 +60,18 @@     topic = case args of               [pat] -> headMay [t | t <- docTopics, map toLower pat `isInfixOf` t]               _   -> Nothing-    [info, man, pager, cat] = +    [info, man, pager, cat] =       [runInfoForTopic, runManForTopic, runPagerForTopic pagerprog, printHelpForTopic]     viewer       | boolopt "info"  $ rawopts_ opts = info       | boolopt "man"   $ rawopts_ opts = man       | boolopt "pager" $ rawopts_ opts = pager       | boolopt "cat"   $ rawopts_ opts = cat-      | not interactive                 = cat +      | not interactive                 = cat       | "info"    `elem` exes           = info       | "man"     `elem` exes           = man       | pagerprog `elem` exes           = pager-      | otherwise                       = cat +      | otherwise                       = cat   case topic of     Nothing -> putStrLn $ unlines [        "Please choose a manual by typing \"hledger help MANUAL\" (any substring is ok)."
Hledger/Cli/Commands/Import.hs view
@@ -4,7 +4,7 @@ module Hledger.Cli.Commands.Import (   importmode  ,importcmd-) +) where  import Control.Monad@@ -18,9 +18,9 @@  importmode = hledgerCommandMode   $(embedFileRelative "Hledger/Cli/Commands/Import.txt")-  [flagNone ["dry-run"] (setboolopt "dry-run") "just show the transactions to be imported"] +  [flagNone ["dry-run"] (setboolopt "dry-run") "just show the transactions to be imported"]   [generalflagsgroup1]-  []+  hiddenflags   ([], Just $ argsFlag "FILE [...]")  importcmd opts@CliOpts{rawopts_=rawopts,inputopts_=iopts} j = do@@ -33,7 +33,7 @@     fs -> do       enewj <- readJournalFiles iopts' fs       case enewj of-        Left e     -> error' e +        Left e     -> error' e         Right newj ->           case sortOn tdate $ jtxns newj of             [] -> return ()
Hledger/Cli/Commands/Import.txt view
@@ -17,3 +17,18 @@ see only uncategorised transactions:  $ hledger import --dry ... | hledger -f- print unknown --ignore-assertions++Importing balance assignments++Entries added by import will have their posting amounts made explicit+(like hledger print -x). This means that any balance assignments in+imported files must be evaluated; but, imported files don't get to see+the main file's account balances. As a result, importing entries with+balance assignments (eg from an institution that provides only balances+and not posting amounts) will probably generate incorrect posting+amounts. To avoid this problem, use print instead of import:++$ hledger print IMPORTFILE [--new] >> $LEDGER_FILE++(If you think import should leave amounts implicit like print does,+please test it and send a pull request.)
+ Hledger/Cli/Commands/Notes.hs view
@@ -0,0 +1,44 @@+{-|++The @notes@ command lists allpayees seen in transactions.++-}++{-# LANGUAGE MultiWayIf #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE CPP #-}++module Hledger.Cli.Commands.Notes (+  notesmode+ ,notes+) where++#if !(MIN_VERSION_base(4,11,0))+import Data.Monoid+#endif+import Data.List+import qualified Data.Text.IO as T++import Hledger+import Hledger.Cli.CliOptions+++-- | Command line options for this command.+notesmode = hledgerCommandMode+  $(embedFileRelative "Hledger/Cli/Commands/Notes.txt")+  []+  [generalflagsgroup1]+  hiddenflags+  ([], Just $ argsFlag "[QUERY]")++-- | The notes command.+notes :: CliOpts -> Journal -> IO ()+notes CliOpts{reportopts_=ropts} j = do+  d <- getCurrentDay+  let q  = queryFromOpts d ropts+      ts = entriesReport ropts q j+      notes = nub $ sort $ map transactionNote ts++  mapM_ T.putStrLn notes
+ Hledger/Cli/Commands/Notes.txt view
@@ -0,0 +1,11 @@+notes Show notes.++_FLAGS_++This command lists all notes that appear in transactions.++Examples:++$ hledger notes+Petrol+Snacks
+ Hledger/Cli/Commands/Payees.hs view
@@ -0,0 +1,44 @@+{-|++The @payees@ command lists allpayees seen in transactions.++-}++{-# LANGUAGE MultiWayIf #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE CPP #-}++module Hledger.Cli.Commands.Payees (+  payeesmode+ ,payees+) where++#if !(MIN_VERSION_base(4,11,0))+import Data.Monoid+#endif+import Data.List+import qualified Data.Text.IO as T++import Hledger+import Hledger.Cli.CliOptions+++-- | Command line options for this command.+payeesmode = hledgerCommandMode+  $(embedFileRelative "Hledger/Cli/Commands/Payees.txt")+  []+  [generalflagsgroup1]+  hiddenflags+  ([], Just $ argsFlag "[QUERY]")++-- | The payees command.+payees :: CliOpts -> Journal -> IO ()+payees CliOpts{reportopts_=ropts} j = do+  d <- getCurrentDay+  let q  = queryFromOpts d ropts+      ts = entriesReport ropts q j+      payees = nub $ sort $ map transactionPayee ts++  mapM_ T.putStrLn payees
+ Hledger/Cli/Commands/Payees.txt view
@@ -0,0 +1,12 @@+payees Show payee names.++_FLAGS_++This command lists all payee names that appear in transactions.++Examples:++$ hledger payees+Store Name+Gas Station+Person A
Hledger/Cli/Commands/Prices.hs view
@@ -3,7 +3,7 @@ module Hledger.Cli.Commands.Prices (   pricesmode  ,prices-) +) where  import Data.Maybe@@ -19,29 +19,29 @@   [flagNone ["costs"] (setboolopt "costs") "print transaction prices from postings"   ,flagNone ["inverted-costs"] (setboolopt "inverted-costs") "print transaction inverted prices from postings also"]   [generalflagsgroup1]-  []+  hiddenflags   ([], Just $ argsFlag "[QUERY]") --- XXX the original hledger-prices script always ignored assertions +-- XXX the original hledger-prices script always ignored assertions prices opts j = do   d <- getCurrentDay   let     q          = queryFromOpts d (reportopts_ opts)     ps         = filter (matchesPosting q) $ allPostings j-    mprices    = jmarketprices j+    mprices    = jpricedirectives j     cprices    = concatMap postingCosts ps     icprices   = concatMap postingCosts . mapAmount invertPrice $ ps     allprices  = mprices ++ ifBoolOpt "costs" cprices ++ ifBoolOpt "inverted-costs" icprices-  mapM_ (putStrLn . showPrice) $-    sortOn mpdate $-    filter (matchesMarketPrice q) $+  mapM_ (putStrLn . showPriceDirective) $+    sortOn pddate $+    filter (matchesPriceDirective q) $     allprices   where     ifBoolOpt opt | boolopt opt $ rawopts_ opts = id                   | otherwise = const [] -showPrice :: MarketPrice -> String-showPrice mp = unwords ["P", show $ mpdate mp, T.unpack . quoteCommoditySymbolIfNeeded $ mpcommodity mp, showAmountWithZeroCommodity $ mpamount mp]+showPriceDirective :: PriceDirective -> String+showPriceDirective mp = unwords ["P", show $ pddate mp, T.unpack . quoteCommoditySymbolIfNeeded $ pdcommodity mp, showAmountWithZeroCommodity $ pdamount mp]  divideAmount' :: Quantity -> Amount -> Amount divideAmount' n a = a' where@@ -50,28 +50,31 @@     extPrecision = (1+) . floor . logBase 10 $ (realToFrac n :: Double)     precision' = extPrecision + asprecision (astyle a) +-- XXX++-- | Invert an amount's price for --invert-cost, somehow ? Unclear. invertPrice :: Amount -> Amount invertPrice a =     case aprice a of-        NoPrice -> a-        UnitPrice pa -> invertPrice+        Nothing -> a+        Just (UnitPrice pa) -> invertPrice             -- normalize to TotalPrice-            a { aprice = TotalPrice pa' } where-                pa' = ((1 / aquantity a) `divideAmount` pa) { aprice = NoPrice }-        TotalPrice pa ->-            a { aquantity = aquantity pa * signum (aquantity a), acommodity = acommodity pa, aprice = TotalPrice pa' } where-                pa' = pa { aquantity = abs $ aquantity a, acommodity = acommodity a, aprice = NoPrice, astyle = astyle a }+            a { aprice = Just $ TotalPrice pa' } where+                pa' = ((1 / aquantity a) `divideAmount` pa) { aprice = Nothing }+        Just (TotalPrice pa) ->+            a { aquantity = aquantity pa * signum (aquantity a), acommodity = acommodity pa, aprice = Just $ TotalPrice pa' } where+                pa' = pa { aquantity = abs $ aquantity a, acommodity = acommodity a, aprice = Nothing, astyle = astyle a } -amountCost :: Day -> Amount -> Maybe MarketPrice+amountCost :: Day -> Amount -> Maybe PriceDirective amountCost d a =     case aprice a of-        NoPrice -> Nothing-        UnitPrice pa -> Just-            MarketPrice { mpdate = d, mpcommodity = acommodity a, mpamount = pa }-        TotalPrice pa -> Just-            MarketPrice { mpdate = d, mpcommodity = acommodity a, mpamount = abs (aquantity a) `divideAmount'` pa }+        Nothing -> Nothing+        Just (UnitPrice pa) -> Just+            PriceDirective { pddate = d, pdcommodity = acommodity a, pdamount = pa }+        Just (TotalPrice pa) -> Just+            PriceDirective { pddate = d, pdcommodity = acommodity a, pdamount = abs (aquantity a) `divideAmount'` pa } -postingCosts :: Posting -> [MarketPrice]+postingCosts :: Posting -> [PriceDirective] postingCosts p = mapMaybe (amountCost date) . amounts $ pamount p  where    date = fromMaybe (tdate . fromJust $ ptransaction p) $ pdate p 
Hledger/Cli/Commands/Print.hs view
@@ -37,7 +37,7 @@     "show only newer-dated transactions added in each file since last run"   ] ++ outputflags)   [generalflagsgroup1]-  []+  hiddenflags   ([], Just $ argsFlag "[QUERY]")  -- | Print journal transactions in standard format.@@ -59,14 +59,14 @@   writeOutput opts $ render $ entriesReport ropts' q j  entriesReportAsText :: CliOpts -> EntriesReport -> String-entriesReportAsText opts = concatMap (showTransactionUnelided . gettxn) +entriesReportAsText opts = concatMap (showTransactionUnelided . gettxn)   where-    gettxn | useexplicittxn = id                   -- use fully inferred amounts & txn prices +    gettxn | useexplicittxn = id                   -- use fully inferred amounts & txn prices            | otherwise      = originalTransaction  -- use original as-written amounts/txn prices     -- Original vs inferred transactions/postings were causing problems here, disabling -B (#551).     -- Use the explicit one if -B or -x are active.-    -- This passes tests; does it also mean -B sometimes shows missing amounts unnecessarily ?  -    useexplicittxn = boolopt "explicit" (rawopts_ opts) || cost_ (reportopts_ opts)+    -- This passes tests; does it also mean -B sometimes shows missing amounts unnecessarily ?+    useexplicittxn = boolopt "explicit" (rawopts_ opts) || (valuationTypeIsCost $ reportopts_ opts)  -- Replace this transaction's postings with the original postings if any, but keep the -- current possibly rewritten account names.
Hledger/Cli/Commands/Printunique.hs view
@@ -3,7 +3,7 @@ module Hledger.Cli.Commands.Printunique (   printuniquemode  ,printunique-) +) where  import Data.List@@ -15,7 +15,7 @@   $(embedFileRelative "Hledger/Cli/Commands/Printunique.txt")   []   [generalflagsgroup1]-  []+  hiddenflags   ([], Nothing)  printunique opts j@Journal{jtxns=ts} = do
Hledger/Cli/Commands/Register.hs view
@@ -4,7 +4,9 @@  -} -{-# LANGUAGE CPP, OverloadedStrings #-}+{-# LANGUAGE CPP #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE RecordWildCards #-} {-# LANGUAGE TemplateHaskell #-}  module Hledger.Cli.Commands.Register (@@ -48,12 +50,12 @@      )   ] ++ outputflags)   [generalflagsgroup1]-  []+  hiddenflags   ([], Just $ argsFlag "[QUERY]")  -- | Print a (posting) register report. register :: CliOpts -> Journal -> IO ()-register opts@CliOpts{reportopts_=ropts} j = do+register opts@CliOpts{reportopts_=ropts@ReportOpts{..}} j = do   d <- getCurrentDay   let fmt = outputFormatFromOpts opts       render | fmt=="csv"  = const ((++"\n") . printCSV . postingsReportAsCsv)@@ -173,8 +175,10 @@               BalancedVirtualPosting -> (\s -> "["++s++"]", acctwidth-2)               VirtualPosting         -> (\s -> "("++s++")", acctwidth-2)               _                      -> (id,acctwidth)-      amt = showMixedAmountWithoutPrice $ pamount p-      bal = showMixedAmountWithoutPrice b+      showamt | color_ (reportopts_ opts) = cshowMixedAmountWithoutPrice+              | otherwise                 = showMixedAmountWithoutPrice+      amt = showamt $ pamount p+      bal = showamt b       -- alternate behaviour, show null amounts as 0 instead of blank       -- amt = if null amt' then "0" else amt'       -- bal = if null bal' then "0" else bal'
Hledger/Cli/Commands/Registermatch.hs view
@@ -4,7 +4,7 @@ module Hledger.Cli.Commands.Registermatch (   registermatchmode  ,registermatch-) +) where  import Data.Char (toUpper)@@ -18,7 +18,7 @@   $(embedFileRelative "Hledger/Cli/Commands/Registermatch.txt")   []   [generalflagsgroup1]-  []+  hiddenflags   ([], Just $ argsFlag "DESC")  registermatch :: CliOpts -> Journal -> IO ()
Hledger/Cli/Commands/Rewrite.hs view
@@ -5,7 +5,7 @@ module Hledger.Cli.Commands.Rewrite (   rewritemode  ,rewrite-) +) where  #if !(MIN_VERSION_base(4,11,0))@@ -29,14 +29,14 @@   ,flagNone ["diff"] (setboolopt "diff") "generate diff suitable as an input for patch tool"   ]   [generalflagsgroup1]-  []+  hiddenflags   ([], Just $ argsFlag "[QUERY] --add-posting \"ACCT  AMTEXPR\" ...")  -- TODO regex matching and interpolating matched name in replacement -- TODO interpolating match groups in replacement -- TODO allow using this on unbalanced entries, eg to rewrite while editing -rewrite opts@CliOpts{rawopts_=rawopts,reportopts_=ropts} j@Journal{jtxns=ts} = do +rewrite opts@CliOpts{rawopts_=rawopts,reportopts_=ropts} j@Journal{jtxns=ts} = do   -- rewrite matched transactions   let modifiers = transactionModifierFromOpts opts : jtxnmodifiers j   let j' = j{jtxns=modifyTransactions modifiers ts}@@ -46,7 +46,7 @@ -- | Build a 'TransactionModifier' from any query arguments and --add-posting flags -- provided on the command line, or throw a parse error. transactionModifierFromOpts :: CliOpts -> TransactionModifier-transactionModifierFromOpts CliOpts{rawopts_=rawopts,reportopts_=ropts} = +transactionModifierFromOpts CliOpts{rawopts_=rawopts,reportopts_=ropts} =   TransactionModifier{tmquerytxt=q, tmpostingrules=ps}   where     q = T.pack $ query_ ropts
Hledger/Cli/Commands/Rewrite.txt view
@@ -13,9 +13,9 @@  Examples: -hledger-rewrite.hs ^income --add-posting '(liabilities:tax)  *.33  ; income tax' --add-posting '(reserve:gifts)  $100'-hledger-rewrite.hs expenses:gifts --add-posting '(reserve:gifts)  *-1"'-hledger-rewrite.hs -f rewrites.hledger+$ hledger-rewrite.hs ^income --add-posting '(liabilities:tax)  *.33  ; income tax' --add-posting '(reserve:gifts)  $100'+$ hledger-rewrite.hs expenses:gifts --add-posting '(reserve:gifts)  *-1"'+$ hledger-rewrite.hs -f rewrites.hledger  rewrites.hledger may consist of entries like: 
Hledger/Cli/Commands/Roi.hs view
@@ -6,7 +6,7 @@  -} -module Hledger.Cli.Commands.Roi ( +module Hledger.Cli.Commands.Roi (   roimode   , roi ) where@@ -37,43 +37,43 @@     "query to select profit-and-loss or appreciation/valuation transactions"   ]   [generalflagsgroup1]-  []+  hiddenflags   ([], Just $ argsFlag "[QUERY]") --- One reporting span, -data OneSpan = OneSpan +-- One reporting span,+data OneSpan = OneSpan   Day -- start date, inclusive   Day   -- end date, exclusive   Quantity -- value of investment at the beginning of day on spanBegin_   Quantity  -- value of investment at the end of day on spanEnd_   [(Day,Quantity)] -- all deposits and withdrawals (but not changes of value) in the DateSpan [spanBegin_,spanEnd_)  deriving (Show)-   + roi ::  CliOpts -> Journal -> IO () roi CliOpts{rawopts_=rawopts, reportopts_=ropts} j = do   d <- getCurrentDay-  let +  let     investmentsQuery = queryFromOpts d $ ropts{query_ = stringopt "investment" rawopts,period_=PeriodAll}     pnlQuery         = queryFromOpts d $ ropts{query_ = stringopt "pnl" rawopts,period_=PeriodAll}     showCashFlow      = boolopt "cashflow" rawopts     prettyTables     = pretty_tables_ ropts-    +     trans = dbg3 "investments" $ jtxns $ filterJournalTransactions investmentsQuery j-  -    journalSpan = -        let dates = map transactionDate2 trans in -        DateSpan (Just $ minimum dates) (Just $ addDays 1 $ maximum dates)            -        ++    journalSpan =+        let dates = map transactionDate2 trans in+        DateSpan (Just $ minimum dates) (Just $ addDays 1 $ maximum dates)+     requestedSpan = periodAsDateSpan $ period_ ropts     requestedInterval = interval_ ropts-    -    wholeSpan = spanDefaultsFrom requestedSpan journalSpan  +    wholeSpan = spanDefaultsFrom requestedSpan journalSpan+   when (null trans) $ do     putStrLn "No relevant transactions found. Check your investments query"     exitFailure-  +   let spans = case requestedInterval of         NoInterval -> [wholeSpan]         interval ->@@ -82,23 +82,23 @@    tableBody <- forM spans $ \(DateSpan (Just spanBegin) (Just spanEnd)) -> do     -- Spans are [spanBegin,spanEnd), and spanEnd is 1 day after then actual end date we are interested in-    let +    let       valueBefore =         total trans (And [ investmentsQuery                          , Date (DateSpan Nothing (Just spanBegin))])-    -      valueAfter  = ++      valueAfter  =         total trans (And [investmentsQuery                          , Date (DateSpan Nothing (Just spanEnd))])-        -      cashFlow = ++      cashFlow =         calculateCashFlow trans (And [ Not investmentsQuery                                      , Not pnlQuery                                      , Date (DateSpan (Just spanBegin) (Just spanEnd)) ] )-      -      thisSpan = dbg3 "processing span" $ ++      thisSpan = dbg3 "processing span" $                  OneSpan spanBegin spanEnd valueBefore valueAfter cashFlow-      +     irr <- internalRateOfReturn showCashFlow prettyTables thisSpan     twr <- timeWeightedReturn showCashFlow prettyTables investmentsQuery trans thisSpan     let cashFlowAmt = negate $ sum $ map snd cashFlow@@ -112,28 +112,28 @@            , printf "%0.2f%%" $ smallIsZero irr            , printf "%0.2f%%" $ smallIsZero twr ] -  let table = Table -              (Tbl.Group NoLine (map (Header . show) (take (length tableBody) [1..]))) -              (Tbl.Group DoubleLine +  let table = Table+              (Tbl.Group NoLine (map (Header . show) (take (length tableBody) [1..])))+              (Tbl.Group DoubleLine                [ Tbl.Group SingleLine [Header "Begin", Header "End"]                , Tbl.Group SingleLine [Header "Value (begin)", Header "Cashflow", Header "Value (end)", Header "PnL"]                , Tbl.Group SingleLine [Header "IRR", Header "TWR"]])               tableBody-  +   putStrLn $ Ascii.render prettyTables id id id table  timeWeightedReturn showCashFlow prettyTables investmentsQuery trans (OneSpan spanBegin spanEnd valueBefore valueAfter cashFlow) = do   let initialUnitPrice = 100   let initialUnits = valueBefore / initialUnitPrice-  let cashflow = +  let cashflow =         -- Aggregate all entries for a single day, assuming that intraday interest is negligible         map (\date_cash -> let (dates, cash) = unzip date_cash in (head dates, sum cash))         $ groupBy ((==) `on` fst)-        $ sortOn fst -        $ map (\(d,a) -> (d, negate a)) +        $ sortOn fst+        $ map (\(d,a) -> (d, negate a))         $ filter ((/=0).snd) cashFlow-    -  let units = ++  let units =         tail $         scanl           (\(_, _, _, unitBalance) (date, amt) ->@@ -146,14 +146,14 @@               in (valueOnDate, unitsBoughtOrSold, unitPrice, unitBalance + unitsBoughtOrSold))           (0, 0, 0, initialUnits)           cashflow-  +   let finalUnitBalance = if null units then initialUnits else let (_,_,_,u) = last units in u       finalUnitPrice = valueAfter / finalUnitBalance       totalTWR = roundTo 2 $ (finalUnitPrice - initialUnitPrice)       years = fromIntegral (diffDays spanEnd spanBegin) / 365 :: Double       annualizedTWR = 100*((1+(realToFrac totalTWR/100))**(1/years)-1) :: Double-        -  let s d = show $ roundTo 2 d ++  let s d = show $ roundTo 2 d   when showCashFlow $ do     printf "\nTWR cash flow for %s - %s\n" (showDate spanBegin) (showDate (addDays (-1) spanEnd))     let (dates', amounts') = unzip cashflow@@ -165,27 +165,27 @@         unitPrices = add initialUnitPrice unitPrices'         unitBalances = add initialUnits unitBalances'         valuesOnDate = add 0 valuesOnDate'-        -    putStr $ Ascii.render prettyTables id id id -      (Table ++    putStr $ Ascii.render prettyTables id id id+      (Table        (Tbl.Group NoLine (map (Header . showDate) dates))-       (Tbl.Group DoubleLine [ Tbl.Group SingleLine [Header "Portfolio value", Header "Unit balance"] +       (Tbl.Group DoubleLine [ Tbl.Group SingleLine [Header "Portfolio value", Header "Unit balance"]                          , Tbl.Group SingleLine [Header "Cash", Header "Unit price", Header "Units"]                          , Tbl.Group SingleLine [Header "New Unit Balance"]])-       [ [value, oldBalance, amt, prc, udelta, balance] +       [ [value, oldBalance, amt, prc, udelta, balance]        | value <- map s valuesOnDate        | oldBalance <- map s (0:unitBalances)        | balance <- map s unitBalances        | amt <- map s amounts        | prc <- map s unitPrices        | udelta <- map s unitsBoughtOrSold ])-  +     printf "Final unit price: %s/%s=%s U.\nTotal TWR: %s%%.\nPeriod: %.2f years.\nAnnualized TWR: %.2f%%\n\n" (s valueAfter) (s finalUnitBalance) (s finalUnitPrice) (s totalTWR) years annualizedTWR-  +   return annualizedTWR-   -internalRateOfReturn showCashFlow prettyTables (OneSpan spanBegin spanEnd valueBefore valueAfter cashFlow) = do ++internalRateOfReturn showCashFlow prettyTables (OneSpan spanBegin spanEnd valueBefore valueAfter cashFlow) = do   let prefix = (spanBegin, negate valueBefore)        postfix = (spanEnd, valueAfter)@@ -193,18 +193,18 @@       totalCF = filter ((/=0) . snd) $ prefix : (sortOn fst cashFlow) ++ [postfix]    when showCashFlow $ do-    printf "\nIRR cash flow for %s - %s\n" (showDate spanBegin) (showDate (addDays (-1) spanEnd)) +    printf "\nIRR cash flow for %s - %s\n" (showDate spanBegin) (showDate (addDays (-1) spanEnd))     let (dates, amounts) = unzip totalCF-    putStrLn $ Ascii.render prettyTables id id id -      (Table +    putStrLn $ Ascii.render prettyTables id id id+      (Table        (Tbl.Group NoLine (map (Header . showDate) dates))        (Tbl.Group SingleLine [Header "Amount"])        (map ((:[]) . show) amounts))-                             +   -- 0% is always a solution, so require at least something here-  case ridders +  case ridders #if MIN_VERSION_math_functions(0,3,0)-    (RiddersParam 100 (AbsTol 0.00001)) +    (RiddersParam 100 (AbsTol 0.00001)) #else     0.00001 #endif@@ -227,9 +227,9 @@  total :: [Transaction] -> Query -> Quantity total trans query = unMix $ sumPostings $ filter (matchesPosting query) $ concatMap realPostings trans-    -unMix :: MixedAmount -> Quantity   -unMix a = ++unMix :: MixedAmount -> Quantity+unMix a =   case (normaliseMixedAmount $ costOfMixedAmount a) of     (Mixed [a]) -> aquantity a     _ -> error "MixedAmount failed to normalize"
Hledger/Cli/Commands/Stats.hs view
@@ -35,7 +35,7 @@   [flagReq  ["output-file","o"]   (\s opts -> Right $ setopt "output-file" s opts) "FILE" "write output to FILE."   ]   [generalflagsgroup1]-  []+  hiddenflags   ([], Just $ argsFlag "[QUERY]")  -- like Register.summarisePostings@@ -70,6 +70,7 @@         ,("Payees/descriptions", show $ size $ fromList $ map (tdescription) ts)         ,("Accounts", printf "%d (depth %d)" acctnum acctdepth)         ,("Commodities", printf "%s (%s)" (show $ length cs) (T.intercalate ", " cs))+        ,("Market prices", printf "%s (%s)" (show $ length mktprices) (T.intercalate ", " mktpricecommodities))       -- Transactions this month     : %(monthtxns)s (last month in the same period: %(lastmonthtxns)s)       -- Unmarked transactions      : %(unmarked)s       -- Days since reconciliation   : %(reconcileelapsed)s@@ -106,4 +107,5 @@              acctnum = length as              acctdepth | null as = 0                        | otherwise = maximum $ map accountNameLevel as-+             mktprices = jpricedirectives j+             mktpricecommodities = nub $ sort $ map pdcommodity mktprices
Hledger/Cli/Commands/Stats.txt view
@@ -20,6 +20,7 @@ Payees/descriptions      : 5 Accounts                 : 8 (depth 3) Commodities              : 1 ($)+Market prices            : 12 ($)  This command also supports output destination and output format selection.
Hledger/Cli/Commands/Tags.hs view
@@ -4,32 +4,38 @@ module Hledger.Cli.Commands.Tags (   tagsmode  ,tags-) +) where -import Data.List+import Data.List.Extra (nubSort) import qualified Data.Text as T+import qualified Data.Text.IO as T import Safe+import System.Console.CmdArgs.Explicit as C import Hledger import Hledger.Cli.CliOptions  tagsmode = hledgerCommandMode   $(embedFileRelative "Hledger/Cli/Commands/Tags.txt")-  [] -- [flagNone ["strict"] (setboolopt "strict") "makes date comparing strict"] -- +  [flagNone ["values"] (setboolopt "values") "list tag values instead of tag names"+  ]   [generalflagsgroup1]-  []+  hiddenflags   ([], Just $ argsFlag "[TAGREGEX [QUERY...]]")  tags CliOpts{rawopts_=rawopts,reportopts_=ropts} j = do   d <- getCurrentDay   let     args      = listofstringopt "args" rawopts-    mtagpats  = headMay args+    mtagpat   = headMay args     queryargs = drop 1 args-    q = queryFromOpts d $ ropts{query_ = unwords queryargs} +    values    = boolopt "values" rawopts+    q = queryFromOpts d $ ropts{query_ = unwords queryargs}     txns = filter (q `matchesTransaction`) $ jtxns $ journalSelectingAmountFromOpts ropts j-    tags = -      nub $ sort $ -      (maybe id (filter . regexMatchesCI) mtagpats) $ -      map (T.unpack . fst) $ concatMap transactionAllTags txns-  mapM_ putStrLn tags+    tagsorvalues =+      nubSort $+      [if values then v else t+      | (t,v) <- concatMap transactionAllTags txns+      , maybe True (`regexMatchesCI` T.unpack t) mtagpat+      ]+  mapM_ T.putStrLn tagsorvalues
Hledger/Cli/Commands/Tags.txt view
@@ -2,6 +2,7 @@ List all the tag names used in the journal. With a TAGREGEX argument, only tag names matching the regular expression (case insensitive) are shown. With QUERY arguments, only transactions matching the query are-considered.+considered. With --values flag, the tags' unique values are listed+instead.  _FLAGS_
Hledger/Cli/CompoundBalanceCommand.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE OverloadedStrings, RecordWildCards #-} {-| -Common helpers for making multi-section balance report commands +Common helpers for making multi-section balance report commands like balancesheet, cashflow, and incomestatement.  -}@@ -14,12 +14,14 @@ ) where  import Data.List (foldl')-import Data.Maybe (fromMaybe,catMaybes)+import Data.Maybe import qualified Data.Text as TS import qualified Data.Text.Lazy as TL+import Data.Time.Calendar+import Data.Time.Format import System.Console.CmdArgs.Explicit as C import Hledger.Read.CsvReader (CSV, printCSV)-import Lucid as L+import Lucid as L hiding (value_) import Text.Tabular as T  import Hledger@@ -27,16 +29,16 @@ import Hledger.Cli.CliOptions import Hledger.Cli.Utils (writeOutput) --- | Description of a compound balance report command, +-- | Description of a compound balance report command, -- from which we generate the command's cmdargs mode and IO action.--- A compound balance report command shows one or more sections/subreports, --- each with its own title and subtotals row, in a certain order, +-- A compound balance report command shows one or more sections/subreports,+-- each with its own title and subtotals row, in a certain order, -- plus a grand totals row if there's more than one section. -- Examples are the balancesheet, cashflow and incomestatement commands. ----- Compound balance reports do sign normalisation: they show all account balances +-- Compound balance reports do sign normalisation: they show all account balances -- as normally positive, unlike the ordinary BalanceReport and most hledger commands--- which show income/liability/equity balances as normally negative.  +-- which show income/liability/equity balances as normally negative. -- Each subreport specifies the normal sign of its amounts, and whether -- it should be added to or subtracted from the grand total. --@@ -44,7 +46,7 @@   cbcdoc      :: CommandDoc,          -- ^ the command's name(s) and documentation   cbctitle    :: String,              -- ^ overall report title   cbcqueries  :: [CBCSubreportSpec],  -- ^ subreport details-  cbctype     :: BalanceType          -- ^ the "balance" type (change, cumulative, historical) +  cbctype     :: BalanceType          -- ^ the "balance" type (change, cumulative, historical)                                       --   this report shows (overrides command line flags) } @@ -62,15 +64,15 @@ -- -- * the period (date span) of each column ----- * one or more named, normal-positive multi balance reports, +-- * one or more named, normal-positive multi balance reports, --   with columns corresponding to the above, and a flag indicating --   whether they increased or decreased the overall totals -- -- * a list of overall totals for each column, and their grand total and average ----- It is used in compound balance report commands like balancesheet, +-- It is used in compound balance report commands like balancesheet, -- cashflow and incomestatement.-type CompoundBalanceReport = +type CompoundBalanceReport =   ( String   , [DateSpan]   , [(String, MultiBalanceReport, Bool)]@@ -78,7 +80,7 @@   )  --- | Generate a cmdargs option-parsing mode from a compound balance command +-- | Generate a cmdargs option-parsing mode from a compound balance command -- specification. compoundBalanceCommandMode :: CompoundBalanceCommandSpec -> Mode RawOpts compoundBalanceCommandMode CompoundBalanceCommandSpec{..} =@@ -108,7 +110,7 @@     ,outputFileFlag     ]     [generalflagsgroup1]-    []+    hiddenflags     ([], Just $ argsFlag "[QUERY]")  where    defType :: BalanceType -> String@@ -117,10 +119,10 @@  -- | Generate a runnable command from a compound balance command specification. compoundBalanceCommand :: CompoundBalanceCommandSpec -> (CliOpts -> Journal -> IO ())-compoundBalanceCommand CompoundBalanceCommandSpec{..} opts@CliOpts{reportopts_=ropts, rawopts_=rawopts} j = do+compoundBalanceCommand CompoundBalanceCommandSpec{..} opts@CliOpts{reportopts_=ropts@ReportOpts{..}, rawopts_=rawopts} j = do     d <- getCurrentDay     let-      -- use the default balance type for this report, unless the user overrides  +      -- use the default balance type for this report, unless the user overrides       mBalanceTypeOverride =         case reverse $ filter (`elem` ["change","cumulative","historical"]) $ map fst rawopts of           "historical":_ -> Just HistoricalBalance@@ -128,23 +130,14 @@           "change":_     -> Just PeriodChange           _              -> Nothing       balancetype = fromMaybe cbctype mBalanceTypeOverride-      title = cbctitle ++ " " ++ showDateSpan requestedspan ++ maybe "" (' ':) mtitleclarification-        where-          requestedspan = queryDateSpan (date2_ ropts) userq `spanDefaultsFrom` journalDateSpan (date2_ ropts) j-          -- when user overrides, add an indication to the report title-          mtitleclarification = flip fmap mBalanceTypeOverride $ \t ->-            case t of-              PeriodChange      -> "(Balance Changes)"-              CumulativeChange  -> "(Cumulative Ending Balances)"-              HistoricalBalance -> "(Historical Ending Balances)"       -- Set balance type in the report options.-      -- Also, use tree mode (by default, at least?) if --cumulative/--historical -      -- are used in single column mode, since in that situation we will be using +      -- Also, use tree mode (by default, at least?) if --cumulative/--historical+      -- are used in single column mode, since in that situation we will be using       -- balanceReportFromMultiBalanceReport which does not support eliding boring parents,-      -- and tree mode hides this.. or something.. XXX +      -- and tree mode hides this.. or something.. XXX       ropts'-        | not (flat_ ropts) && -          interval_ ropts==NoInterval && +        | not (flat_ ropts) &&+          interval_==NoInterval &&           balancetype `elem` [CumulativeChange, HistoricalBalance]             = ropts{balancetype_=balancetype, accountlistmode_=ALTree}         | otherwise@@ -152,44 +145,87 @@       userq = queryFromOpts d ropts'       format = outputFormatFromOpts opts -      -- make a CompoundBalanceReport-      subreports = -        map (\CBCSubreportSpec{..} -> +      -- make a CompoundBalanceReport.+      -- For efficiency, generate a price oracle here and reuse it with each subreport.+      priceoracle = journalPriceOracle j+      subreports =+        map (\CBCSubreportSpec{..} ->                 (cbcsubreporttitle                 ,mbrNormaliseSign cbcsubreportnormalsign $ -- <- convert normal-negative to normal-positive-                  compoundBalanceSubreport ropts' userq j cbcsubreportquery cbcsubreportnormalsign+                  compoundBalanceSubreport ropts' userq j priceoracle cbcsubreportquery cbcsubreportnormalsign                 ,cbcsubreportincreasestotal                 ))             cbcqueries-      subtotalrows = -        [(coltotals, increasesoveralltotal) ++      subtotalrows =+        [(coltotals, increasesoveralltotal)         | (_, MultiBalanceReport (_,_,(coltotals,_,_)), increasesoveralltotal) <- subreports         ]+       -- Sum the subreport totals by column. Handle these cases:       -- - no subreports       -- - empty subreports, having no subtotals (#588)-      -- - subreports with a shorter subtotals row than the others  +      -- - subreports with a shorter subtotals row than the others       overalltotals = case subtotalrows of         [] -> ([], nullmixedamt, nullmixedamt)         rs ->           let             numcols = maximum $ map (length.fst) rs  -- partial maximum is ok, rs is non-null-            paddedsignedsubtotalrows = +            paddedsignedsubtotalrows =               [map (if increasesoveralltotal then id else negate) $  -- maybe flip the signs-               take numcols $ as ++ repeat nullmixedamt              -- pad short rows with zeros +               take numcols $ as ++ repeat nullmixedamt              -- pad short rows with zeros               | (as,increasesoveralltotal) <- rs               ]             coltotals = foldl' (zipWith (+)) zeros paddedsignedsubtotalrows  -- sum the columns               where zeros = replicate numcols nullmixedamt             grandtotal = sum coltotals             grandavg | null coltotals = nullmixedamt-                     | otherwise      = fromIntegral (length coltotals) `divideMixedAmount` grandtotal -          in +                     | otherwise      = fromIntegral (length coltotals) `divideMixedAmount` grandtotal+          in             (coltotals, grandtotal, grandavg)+       colspans =         case subreports of           (_, MultiBalanceReport (ds,_,_), _):_ -> ds           [] -> []++      title =+        cbctitle+        ++ " "+        ++ titledatestr+        ++ maybe "" (' ':) mtitleclarification+        ++ valuationdesc+        where++          -- XXX #1078 the title of ending balance reports+          -- (HistoricalBalance) should mention the end date(s) shown as+          -- column heading(s) (not the date span of the transactions).+          -- Also the dates should not be simplified (it should show+          -- "2008/01/01-2008/12/31", not "2008").+          titledatestr+            | balancetype == HistoricalBalance = showEndDates enddates+            | otherwise                        = showDateSpan requestedspan +            where+              enddates = map (addDays (-1)) $ catMaybes $ map spanEnd colspans  -- these spans will always have a definite end date+              requestedspan = queryDateSpan date2_ userq `spanDefaultsFrom` journalDateSpan date2_ j++          -- when user overrides, add an indication to the report title+          mtitleclarification = flip fmap mBalanceTypeOverride $ \t ->+            case t of+              PeriodChange      -> "(Balance Changes)"+              CumulativeChange  -> "(Cumulative Ending Balances)"+              HistoricalBalance -> "(Historical Ending Balances)"++          valuationdesc = case value_ of+            Just (AtCost _mc)   -> ", valued at cost"+            Just (AtEnd _mc)    -> ", valued at period ends"+            Just (AtNow _mc)    -> ", current value"+            Just (AtDefault _mc) | multiperiod   -> ", valued at period ends"+            Just (AtDefault _mc)    -> ", current value"+            Just (AtDate d _mc) -> ", valued at "++showDate d+            Nothing             -> ""+            where+              multiperiod = interval_ /= NoInterval       cbr =         (title         ,colspans@@ -204,25 +240,37 @@         "html" -> (++ "\n") $ TL.unpack $ L.renderText $ compoundBalanceReportAsHtml ropts cbr         _      -> compoundBalanceReportAsText ropts' cbr +-- | Summarise one or more (inclusive) end dates, in a way that's+-- visually different from showDateSpan, suggesting discrete end dates+-- rather than a continuous span.+showEndDates :: [Day] -> String+showEndDates es = case es of+  -- cf showPeriod+  (e:_:_) -> showdate e ++ ",," ++ showdate (last es)+  [e]     -> showdate e+  []      -> ""+  where+    showdate = formatTime defaultTimeLocale "%0C%y/%m/%d" + -- | Run one subreport for a compound balance command in multi-column mode. -- This returns a MultiBalanceReport.-compoundBalanceSubreport :: ReportOpts -> Query -> Journal -> (Journal -> Query) -> NormalSign -> MultiBalanceReport-compoundBalanceSubreport ropts userq j subreportqfn subreportnormalsign = r'+compoundBalanceSubreport :: ReportOpts -> Query -> Journal -> PriceOracle -> (Journal -> Query) -> NormalSign -> MultiBalanceReport+compoundBalanceSubreport ropts@ReportOpts{..} userq j priceoracle subreportqfn subreportnormalsign = r'   where     -- force --empty to ensure same columns in all sections     ropts' = ropts { empty_=True, normalbalance_=Just subreportnormalsign }     -- run the report     q = And [subreportqfn j, userq]-    r@(MultiBalanceReport (dates, rows, totals)) = multiBalanceReport ropts' q j+    r@(MultiBalanceReport (dates, rows, totals)) = multiBalanceReportWith ropts' q j priceoracle     -- if user didn't specify --empty, now remove the all-zero rows, unless they have non-zero subaccounts     -- in this report-    r' | empty_ ropts = r-       | otherwise    = MultiBalanceReport (dates, rows', totals) +    r' | empty_    = r+       | otherwise = MultiBalanceReport (dates, rows', totals)           where             nonzeroaccounts =               dbg1 "nonzeroaccounts" $               catMaybes $ map (\(act,_,_,amts,_,_) ->-                            if not (all isZeroMixedAmount amts) then Just act else Nothing) rows +                            if not (all isZeroMixedAmount amts) then Just act else Nothing) rows             rows' = filter (not . emptyRow) rows               where                 emptyRow (act,_,_,amts,_,_) =@@ -232,34 +280,34 @@ {- Eg: Balance Sheet -             ||  2017/12/31    Total  Average +             ||  2017/12/31    Total  Average =============++===============================- Assets      ||                               + Assets      || -------------++-------------------------------- assets:b    ||           1        1        1 + assets:b    ||           1        1        1 -------------++--------------------------------             ||           1        1        1 +             ||           1        1        1 =============++===============================- Liabilities ||                               + Liabilities || -------------++------------------------------- -------------++--------------------------------             ||                               +             || =============++===============================- Total       ||           1        1        1 + Total       ||           1        1        1  -} compoundBalanceReportAsText :: ReportOpts -> CompoundBalanceReport -> String compoundBalanceReportAsText ropts (title, _colspans, subreports, (coltotals, grandtotal, grandavg)) =-  title ++ "\n\n" ++ +  title ++ "\n\n" ++   balanceReportTableAsText ropts bigtable'   where     singlesubreport = length subreports == 1-    bigtable = +    bigtable =       case map (subreportAsTable ropts singlesubreport) subreports of         []   -> T.empty         r:rs -> foldl' concatTables r rs     bigtable'-      | no_total_ ropts || singlesubreport = +      | no_total_ ropts || singlesubreport =           bigtable       | otherwise =           bigtable@@ -319,11 +367,11 @@             (if row_total_ ropts then (1+) else id) $             (if average_ ropts then (1+) else id) $             maximum $ -- depends on non-null subreports-            map (\(MultiBalanceReport (amtcolheadings, _, _)) -> length amtcolheadings) $ +            map (\(MultiBalanceReport (amtcolheadings, _, _)) -> length amtcolheadings) $             map second3 subreports     addtotals       | no_total_ ropts || length subreports == 1 = id-      | otherwise = (++ +      | otherwise = (++           ["Net:" :            map showMixedAmountOneLineWithoutPrice (              coltotals@@ -337,7 +385,7 @@ compoundBalanceReportAsHtml ropts cbr =   let     (title, colspans, subreports, (coltotals, grandtotal, grandavg)) = cbr-    colspanattr = colspan_ $ TS.pack $ show $ +    colspanattr = colspan_ $ TS.pack $ show $       1 + length colspans + (if row_total_ ropts then 1 else 0) + (if average_ ropts then 1 else 0)     leftattr = style_ "text-align:left"     blankrow = tr_ $ td_ [colspanattr] $ toHtmlRaw ("&nbsp;"::String)@@ -353,7 +401,7 @@      thRow :: [String] -> Html ()     thRow = tr_ . mconcat . map (th_ . toHtml)-    +     -- Make rows for a subreport: its title row, not the headings row,     -- the data rows, any totals row, and a blank row for whitespace.     subreportrows :: (String, MultiBalanceReport, Bool) -> [Html ()]
Hledger/Cli/Main.hs view
@@ -43,7 +43,7 @@ import Data.Char (isDigit) import Data.List import Safe-import System.Console.CmdArgs.Explicit as C+import qualified System.Console.CmdArgs.Explicit as C import System.Environment import System.Exit import System.FilePath@@ -156,6 +156,7 @@   dbgIO "interval from opts" (interval_ $ reportopts_ opts)   dbgIO "query from opts & args" (queryFromOpts d $ reportopts_ opts)   let+    journallesserror = error "journal-less command tried to use the journal"     runHledgerCommand       -- high priority flags and situations. -h, then --help, then --info are highest priority.       | hasHelpFlag argsbeforecmd = dbgIO "" "-h before command, showing general usage" >> printUsage@@ -171,13 +172,15 @@       -- builtin commands       | Just (cmdmode, cmdaction) <- findCommand cmd =         (case cmd of-          "test" -> -- should not read the journal-            cmdaction opts (error "journal-less command tried to use the journal")-          "add" ->  -- should create the journal if missing-            (ensureJournalFileExists =<< (head <$> journalFilePathFromOpts opts)) >>-            withJournalDo opts (cmdaction opts)-          _ ->      -- all other commands: read the journal or fail if missing+           -- these commands should not require or read the journal+          "test" -> cmdaction opts journallesserror+          "help" -> cmdaction opts journallesserror+          -- this command should create the journal if missing+          "add" -> do+            (ensureJournalFileExists =<< (head <$> journalFilePathFromOpts opts))             withJournalDo opts (cmdaction opts)+          -- other commands read the journal and should fail if it's missing+          _ -> withJournalDo opts (cmdaction opts)         )         `orShowHelp` cmdmode @@ -204,7 +207,7 @@ argsToCliOpts args addons = do   let     args'        = moveFlagsAfterCommand $ replaceNumericFlags args-    cmdargsopts  = either usageError id $ process (mainmode addons) args'+    cmdargsopts  = either usageError id $ C.process (mainmode addons) args'     cmdargsopts' = decodeRawOpts cmdargsopts   rawOptsToCliOpts cmdargsopts' 
Hledger/Cli/Utils.hs view
@@ -1,5 +1,6 @@+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE NoOverloadedStrings #-} -- prevent trouble if turned on in ghci {-|  Utilities for top-level modules and ghci. See also Hledger.Read and@@ -12,7 +13,6 @@      withJournalDo,      writeOutput,      journalTransform,-     journalApplyValue,      journalAddForecast,      journalReload,      journalReloadIfChanged,@@ -25,6 +25,7 @@      readFileStrictly,      pivotByOpts,      anonymiseByOpts,+     tests_Cli_Utils,     ) where import Control.Exception as C@@ -59,7 +60,7 @@ import Hledger.Utils  -- | Parse the user's specified journal file(s) as a Journal, maybe apply some--- transformations according to options, and run a hledger command with it. +-- transformations according to options, and run a hledger command with it. -- Or, throw an error. withJournalDo :: CliOpts -> (Journal -> IO a) -> IO a withJournalDo opts cmd = do@@ -71,17 +72,19 @@   >>= mapM (journalTransform opts)   >>= either error' cmd --- | Apply some transformations to the journal if specified by options.--- These include:+-- | Apply some extra post-parse transformations to the journal, if+-- specified by options. These happen after journal validation, but+-- before report calculation. They include: -- -- - adding forecast transactions (--forecast)--- - converting amounts to market value (--value) -- - pivoting account names (--pivot) -- - anonymising (--anonymise).+-- journalTransform :: CliOpts -> Journal -> IO Journal-journalTransform opts@CliOpts{reportopts_=ropts} =+journalTransform opts@CliOpts{reportopts_=_ropts} =       journalAddForecast opts-  >=> journalApplyValue ropts+-- - converting amounts to market value (--value)+  -- >=> journalApplyValue ropts   >=> return . pivotByOpts opts   >=> return . anonymiseByOpts opts @@ -117,21 +120,6 @@   where     anon = T.pack . flip showHex "" . (fromIntegral :: Int -> Word32) . hash --- TODO move journalApplyValue and friends to Hledger.Data.Journal ? They are here because they use ReportOpts---- | If -V/--value was requested, convert all journal amounts to their market value--- as of the report end date. Cf http://hledger.org/manual.html#market-value--- Since 2017/4 we do this early, before commands run, which affects all commands--- and seems to have the same effect as doing it last on the reported values.-journalApplyValue :: ReportOpts -> Journal -> IO Journal-journalApplyValue ropts j = do-    today <- getCurrentDay-    mspecifiedenddate <- specifiedEndDate ropts-    let d = fromMaybe today mspecifiedenddate-        convert | value_ ropts = overJournalAmounts (amountValue j d)-                | otherwise    = id-    return $ convert j- -- | Generate periodic transactions from all periodic transaction rules in the journal. -- These transactions are added to the in-memory Journal (but not the on-disk file). --@@ -144,8 +132,8 @@   today <- getCurrentDay    -- "They start on or after the day following the latest normal transaction in the journal, or today if there are none."-  let DateSpan _ mjournalend = dbg2 "journalspan"   $ journalDateSpan False j  -- ignore secondary dates-      forecaststart          = dbg2 "forecaststart" $ fromMaybe today mjournalend+  let mjournalend   = dbg2 "journalEndDate" $ journalEndDate False j  -- ignore secondary dates+      forecaststart = dbg2 "forecaststart" $ fromMaybe today mjournalend    -- "They end on or before the specified report end date, or 180 days from today if unspecified."   mspecifiedend <-  snd . dbg2 "specifieddates" <$> specifiedStartEndDates ropts@@ -161,10 +149,10 @@       forecasttxns' = (if auto_ iopts then modifyTransactions (jtxnmodifiers j) else id) forecasttxns    return $-    if forecast_ ropts +    if forecast_ ropts       then journalBalanceTransactions' opts j{ jtxns = concat [jtxns j, forecasttxns'] }       else j-  where      +  where     journalBalanceTransactions' opts j =       let assrt = not . ignore_assertions_ $ inputopts_ opts       in@@ -176,7 +164,7 @@ writeOutput opts s = do   f <- outputFileFromOpts opts   (if f == "-" then putStr else writeFile f) s-  + -- -- | Get a journal from the given string and options, or throw an error. -- readJournal :: CliOpts -> String -> IO Journal -- readJournal opts s = readJournal def Nothing s >>= either error' return@@ -231,7 +219,7 @@     | otherwise = (do         utc <- getModificationTime f         let nom = utcTimeToPOSIXSeconds utc-        let clo = TOD (read $ takeWhile (`elem` "0123456789") $ show nom) 0 -- XXX read+        let clo = TOD (read $ takeWhile (`elem` ("0123456789"::String)) $ show nom) 0 -- XXX read         return clo         )         `C.catch` \(_::C.IOException) -> getClockTime@@ -295,3 +283,30 @@ backupNumber f g = case g =~ ("^" ++ f ++ "\\.([0-9]+)$") of                         (_::FilePath, _::FilePath, _::FilePath, [ext::FilePath]) -> readMay ext                         _ -> Nothing++tests_Cli_Utils = tests "Utils" [++  --  tests "journalApplyValue" [+  --    -- Print the time required to convert one of the sample journals' amounts to value.+  --    -- Pretty clunky, but working.+  --    -- XXX sample.journal has no price records, but is always present.+  --    -- Change to eg examples/5000x1000x10.journal to make this useful.+  --    test "time" $ do+  --      ej <- io $ readJournalFile definputopts "examples/3000x1000x10.journal"+  --      case ej of+  --        Left e  -> crash $ T.pack e+  --        Right j -> do+  --          (t,_) <- io $ timeItT $ do+  --            -- Enable -V, and ensure the valuation date is later than+  --            -- all prices for consistent timing.+  --            let ropts = defreportopts{+  --              value_=True,+  --              period_=PeriodTo $ parsedate "3000-01-01"+  --              }+  --            j' <- journalApplyValue ropts j+  --            sum (journalAmounts j') `seq` return ()+  --          io $ printf "[%.3fs] " t+  --          ok+  -- ]++ ]
embeddedfiles/hledger-api.1 view
@@ -1,46 +1,46 @@ -.TH "hledger\-api" "1" "March 2019" "hledger\-api 1.14" "hledger User Manuals"+.TH "hledger-api" "1" "March 2019" "hledger-api 1.14.99" "hledger User Manuals"    .SH NAME .PP-hledger\-api \- web API server for the hledger accounting tool+hledger-api - web API server for the hledger accounting tool .SH SYNOPSIS .PP-\f[C]hledger\-api\ [OPTIONS]\f[]+\f[C]hledger-api [OPTIONS]\f[R] .PD 0 .P .PD-\f[C]hledger\ api\ \-\-\ [OPTIONS]\f[]+\f[C]hledger api -- [OPTIONS]\f[R] .SH DESCRIPTION .PP-hledger is a cross\-platform program for tracking money, time, or any-other commodity, using double\-entry accounting and a simple, editable+hledger is a cross-platform program for tracking money, time, or any+other commodity, using double-entry accounting and a simple, editable file format. hledger is inspired by and largely compatible with ledger(1). .PP-hledger\-api is a simple web API server, intended to support-client\-side web apps operating on hledger data.-It comes with a series of simple client\-side app examples, which drive+hledger-api is a simple web API server, intended to support client-side+web apps operating on hledger data.+It comes with a series of simple client-side app examples, which drive its evolution. .PP Like hledger, it reads data from one or more files in hledger journal,-timeclock, timedot, or CSV format specified with \f[C]\-f\f[], or-\f[C]$LEDGER_FILE\f[], or \f[C]$HOME/.hledger.journal\f[] (on windows,-perhaps \f[C]C:/Users/USER/.hledger.journal\f[]).+timeclock, timedot, or CSV format specified with \f[C]-f\f[R], or+\f[C]$LEDGER_FILE\f[R], or \f[C]$HOME/.hledger.journal\f[R] (on windows,+perhaps \f[C]C:/Users/USER/.hledger.journal\f[R]). For more about this see hledger(1), hledger_journal(5) etc. .PP The server listens on IP address 127.0.0.1, accessible only to local requests, by default.-You can change this with \f[C]\-\-host\f[], eg-\f[C]\-\-host\ 0.0.0.0\f[] to listen on all addresses.-Note there is no other access control, and hledger\-api allows file+You can change this with \f[C]--host\f[R], eg \f[C]--host 0.0.0.0\f[R]+to listen on all addresses.+Note there is no other access control, and hledger-api allows file browsing, so on shared machines you will certainly need to put it behind an authenticating proxy to restrict access. .PP You can change the TCP port it listens on (default: 8001) with-\f[C]\-p\ PORT\f[].+\f[C]-p PORT\f[R]. .PP API methods look like: .IP@@ -52,73 +52,59 @@ /api/v1/commodities /api/v1/accounts /api/v1/accounts/ACCTNAME-\f[]+\f[R] .fi .PP-See \f[C]/api/swagger.json\f[] for a full list in Swagger 2.0 format.-(Or you can run \f[C]hledger\-api\ \-\-swagger\f[] to print this in the+See \f[C]/api/swagger.json\f[R] for a full list in Swagger 2.0 format.+(Or you can run \f[C]hledger-api --swagger\f[R] to print this in the console.) .PP-hledger\-api also serves files, from the current directory by default,-and the \f[C]/\f[] path will also show a directory listing.-This is convenient for serving client\-side web code, in addition to the-server\-side api.+hledger-api also serves files, from the current directory by default,+and the \f[C]/\f[R] path will also show a directory listing.+This is convenient for serving client-side web code, in addition to the+server-side api. .SH OPTIONS .PP-Note: if invoking hledger\-api as a hledger subcommand, write-\f[C]\-\-\f[] before options as shown above.+Note: if invoking hledger-api as a hledger subcommand, write+\f[C]--\f[R] before options as shown above. .TP-.B \f[C]\-f\ \-\-file=FILE\f[]+.B \f[C]-f --file=FILE\f[R] use a different input file.-For stdin, use \- (default: \f[C]$LEDGER_FILE\f[] or-\f[C]$HOME/.hledger.journal\f[])-.RS-.RE+For stdin, use - (default: \f[C]$LEDGER_FILE\f[R] or+\f[C]$HOME/.hledger.journal\f[R]) .TP-.B \f[C]\-d\ \-\-static\-dir=DIR\f[]-serve files from a different directory (default: \f[C]\&.\f[])-.RS-.RE+.B \f[C]-d --static-dir=DIR\f[R]+serve files from a different directory (default: \f[C].\f[R]) .TP-.B \f[C]\-\-host=IPADDR\f[]+.B \f[C]--host=IPADDR\f[R] listen on this IP address (default: 127.0.0.1)-.RS-.RE .TP-.B \f[C]\-p\ \-\-port=PORT\f[]+.B \f[C]-p --port=PORT\f[R] listen on this TCP port (default: 8001)-.RS-.RE .TP-.B \f[C]\-\-swagger\f[]+.B \f[C]--swagger\f[R] print API docs in Swagger 2.0 format, and exit-.RS-.RE .TP-.B \f[C]\-\-version\f[]+.B \f[C]--version\f[R] show version-.RS-.RE .TP-.B \f[C]\-h\ \-\-help\f[]+.B \f[C]-h --help\f[R] show usage-.RS-.RE .SH ENVIRONMENT .PP-\f[B]LEDGER_FILE\f[] The journal file path when not specified with-\f[C]\-f\f[].-Default: \f[C]~/.hledger.journal\f[] (on windows, perhaps-\f[C]C:/Users/USER/.hledger.journal\f[]).+\f[B]LEDGER_FILE\f[R] The journal file path when not specified with+\f[C]-f\f[R].+Default: \f[C]\[ti]/.hledger.journal\f[R] (on windows, perhaps+\f[C]C:/Users/USER/.hledger.journal\f[R]). .SH FILES .PP Reads data from one or more files in hledger journal, timeclock,-timedot, or CSV format specified with \f[C]\-f\f[], or-\f[C]$LEDGER_FILE\f[], or \f[C]$HOME/.hledger.journal\f[] (on windows,-perhaps \f[C]C:/Users/USER/.hledger.journal\f[]).+timedot, or CSV format specified with \f[C]-f\f[R], or+\f[C]$LEDGER_FILE\f[R], or \f[C]$HOME/.hledger.journal\f[R] (on windows,+perhaps \f[C]C:/Users/USER/.hledger.journal\f[R]). .SH BUGS .PP-The need to precede options with \f[C]\-\-\f[] when invoked from hledger+The need to precede options with \f[C]--\f[R] when invoked from hledger is awkward.  
embeddedfiles/hledger-api.info view
@@ -3,8 +3,8 @@  File: hledger-api.info,  Node: Top,  Next: OPTIONS,  Up: (dir) -hledger-api(1) hledger-api 1.14-*******************************+hledger-api(1) hledger-api 1.14.99+**********************************  hledger-api is a simple web API server, intended to support client-side web apps operating on hledger data.  It comes with a series of simple@@ -41,6 +41,7 @@    hledger-api also serves files, from the current directory by default, and the '/' path will also show a directory listing.  This is convenient for serving client-side web code, in addition to the server-side api.+ * Menu:  * OPTIONS::@@ -80,7 +81,7 @@  Tag Table: Node: Top72-Node: OPTIONS1660-Ref: #options1745+Node: OPTIONS1667+Ref: #options1752  End Tag Table
embeddedfiles/hledger-api.txt view
@@ -27,11 +27,11 @@        hledger_journal(5) etc.         The server listens on IP address 127.0.0.1, accessible  only  to  local-       requests,   by   default.    You   can  change  this  with  --host,  eg-       --host 0.0.0.0 to listen on all addresses.   Note  there  is  no  other-       access  control,  and  hledger-api  allows  file browsing, so on shared-       machines you will certainly need to put  it  behind  an  authenticating-       proxy to restrict access.+       requests,  by  default.   You  can  change  this with --host, eg --host+       0.0.0.0 to listen on all addresses.  Note there is no other access con-+       trol,  and  hledger-api allows file browsing, so on shared machines you+       will certainly need  to  put  it  behind  an  authenticating  proxy  to+       restrict access.         You can change the TCP port it listens on (default: 8001) with -p PORT. @@ -117,4 +117,4 @@   -hledger-api 1.14                  March 2019                    hledger-api(1)+hledger-api 1.14.99               March 2019                    hledger-api(1)
embeddedfiles/hledger-ui.1 view
@@ -1,227 +1,161 @@ -.TH "hledger\-ui" "1" "March 2019" "hledger\-ui 1.14" "hledger User Manuals"+.TH "hledger-ui" "1" "August 2019" "hledger-ui 1.15" "hledger User Manuals"    .SH NAME .PP-hledger\-ui \- curses\-style interface for the hledger accounting tool+hledger-ui - curses-style interface for the hledger accounting tool .SH SYNOPSIS .PP-\f[C]hledger\-ui\ [OPTIONS]\ [QUERYARGS]\f[]+\f[C]hledger-ui [OPTIONS] [QUERYARGS]\f[R] .PD 0 .P .PD-\f[C]hledger\ ui\ \-\-\ [OPTIONS]\ [QUERYARGS]\f[]+\f[C]hledger ui -- [OPTIONS] [QUERYARGS]\f[R] .SH DESCRIPTION .PP-hledger is a cross\-platform program for tracking money, time, or any-other commodity, using double\-entry accounting and a simple, editable+hledger is a cross-platform program for tracking money, time, or any+other commodity, using double-entry accounting and a simple, editable file format. hledger is inspired by and largely compatible with ledger(1). .PP-hledger\-ui is hledger\[aq]s curses\-style interface, providing an-efficient full\-window text UI for viewing accounts and transactions,-and some limited data entry capability.-It is easier than hledger\[aq]s command\-line interface, and sometimes+hledger-ui is hledger\[aq]s curses-style interface, providing an+efficient full-window text UI for viewing accounts and transactions, and+some limited data entry capability.+It is easier than hledger\[aq]s command-line interface, and sometimes quicker and more convenient than the web interface. .PP-Note hledger\-ui has some different defaults (experimental):+Note hledger-ui has some different defaults (experimental): .IP \[bu] 2-it generates rule\-based transactions and postings by default-(\-\-forecast and \-\-auto are always on).+it generates rule-based transactions and postings by default (--forecast+and --auto are always on). .IP \[bu] 2 it hides transactions dated in the future by default (change this with-\-\-future or the F key).+--future or the F key). .PP Like hledger, it reads data from one or more files in hledger journal,-timeclock, timedot, or CSV format specified with \f[C]\-f\f[], or-\f[C]$LEDGER_FILE\f[], or \f[C]$HOME/.hledger.journal\f[] (on windows,-perhaps \f[C]C:/Users/USER/.hledger.journal\f[]).+timeclock, timedot, or CSV format specified with \f[C]-f\f[R], or+\f[C]$LEDGER_FILE\f[R], or \f[C]$HOME/.hledger.journal\f[R] (on windows,+perhaps \f[C]C:/Users/USER/.hledger.journal\f[R]). For more about this see hledger(1), hledger_journal(5) etc. .SH OPTIONS .PP-Note: if invoking hledger\-ui as a hledger subcommand, write-\f[C]\-\-\f[] before options as shown above.+Note: if invoking hledger-ui as a hledger subcommand, write \f[C]--\f[R]+before options as shown above. .PP Any QUERYARGS are interpreted as a hledger search query which filters the data. .TP-.B \f[C]\-\-watch\f[]+.B \f[C]--watch\f[R] watch for data and date changes and reload automatically-.RS-.RE .TP-.B \f[C]\-\-theme=default|terminal|greenterm\f[]+.B \f[C]--theme=default|terminal|greenterm\f[R] use this custom display theme-.RS-.RE .TP-.B \f[C]\-\-register=ACCTREGEX\f[]+.B \f[C]--register=ACCTREGEX\f[R] start in the (first) matched account\[aq]s register screen-.RS-.RE .TP-.B \f[C]\-\-change\f[]+.B \f[C]--change\f[R] show period balances (changes) at startup instead of historical balances-.RS-.RE .TP-.B \f[C]\-F\ \-\-flat\f[]+.B \f[C]-F --flat\f[R] show accounts as a list (default)-.RS-.RE .TP-.B \f[C]\-T\ \-\-tree\f[]+.B \f[C]-T --tree\f[R] show accounts as a tree-.RS-.RE .TP-.B \f[C]\-\-future\f[]+.B \f[C]--future\f[R] show transactions dated later than today (normally hidden)-.RS-.RE .PP hledger input options: .TP-.B \f[C]\-f\ FILE\ \-\-file=FILE\f[]+.B \f[C]-f FILE --file=FILE\f[R] use a different input file.-For stdin, use \- (default: \f[C]$LEDGER_FILE\f[] or-\f[C]$HOME/.hledger.journal\f[])-.RS-.RE+For stdin, use - (default: \f[C]$LEDGER_FILE\f[R] or+\f[C]$HOME/.hledger.journal\f[R]) .TP-.B \f[C]\-\-rules\-file=RULESFILE\f[]+.B \f[C]--rules-file=RULESFILE\f[R] Conversion rules file to use when reading CSV (default: FILE.rules)-.RS-.RE .TP-.B \f[C]\-\-separator=CHAR\f[]+.B \f[C]--separator=CHAR\f[R] Field separator to expect when reading CSV (default: \[aq],\[aq])-.RS-.RE .TP-.B \f[C]\-\-alias=OLD=NEW\f[]+.B \f[C]--alias=OLD=NEW\f[R] rename accounts named OLD to NEW-.RS-.RE .TP-.B \f[C]\-\-anon\f[]+.B \f[C]--anon\f[R] anonymize accounts and payees-.RS-.RE .TP-.B \f[C]\-\-pivot\ FIELDNAME\f[]+.B \f[C]--pivot FIELDNAME\f[R] use some other field or tag for the account name-.RS-.RE .TP-.B \f[C]\-I\ \-\-ignore\-assertions\f[]+.B \f[C]-I --ignore-assertions\f[R] ignore any failing balance assertions-.RS-.RE .PP hledger reporting options: .TP-.B \f[C]\-b\ \-\-begin=DATE\f[]+.B \f[C]-b --begin=DATE\f[R] include postings/txns on or after this date-.RS-.RE .TP-.B \f[C]\-e\ \-\-end=DATE\f[]+.B \f[C]-e --end=DATE\f[R] include postings/txns before this date-.RS-.RE .TP-.B \f[C]\-D\ \-\-daily\f[]+.B \f[C]-D --daily\f[R] multiperiod/multicolumn report by day-.RS-.RE .TP-.B \f[C]\-W\ \-\-weekly\f[]+.B \f[C]-W --weekly\f[R] multiperiod/multicolumn report by week-.RS-.RE .TP-.B \f[C]\-M\ \-\-monthly\f[]+.B \f[C]-M --monthly\f[R] multiperiod/multicolumn report by month-.RS-.RE .TP-.B \f[C]\-Q\ \-\-quarterly\f[]+.B \f[C]-Q --quarterly\f[R] multiperiod/multicolumn report by quarter-.RS-.RE .TP-.B \f[C]\-Y\ \-\-yearly\f[]+.B \f[C]-Y --yearly\f[R] multiperiod/multicolumn report by year-.RS-.RE .TP-.B \f[C]\-p\ \-\-period=PERIODEXP\f[]+.B \f[C]-p --period=PERIODEXP\f[R] set start date, end date, and/or reporting interval all at once using-period expressions syntax (overrides the flags above)-.RS-.RE+period expressions syntax .TP-.B \f[C]\-\-date2\f[]+.B \f[C]--date2\f[R] match the secondary date instead (see command help for other effects)-.RS-.RE .TP-.B \f[C]\-U\ \-\-unmarked\f[]-include only unmarked postings/txns (can combine with \-P or \-C)-.RS-.RE+.B \f[C]-U --unmarked\f[R]+include only unmarked postings/txns (can combine with -P or -C) .TP-.B \f[C]\-P\ \-\-pending\f[]+.B \f[C]-P --pending\f[R] include only pending postings/txns-.RS-.RE .TP-.B \f[C]\-C\ \-\-cleared\f[]+.B \f[C]-C --cleared\f[R] include only cleared postings/txns-.RS-.RE .TP-.B \f[C]\-R\ \-\-real\f[]-include only non\-virtual postings-.RS-.RE+.B \f[C]-R --real\f[R]+include only non-virtual postings .TP-.B \f[C]\-NUM\ \-\-depth=NUM\f[]+.B \f[C]-NUM --depth=NUM\f[R] hide/aggregate accounts or postings more than NUM levels deep-.RS-.RE .TP-.B \f[C]\-E\ \-\-empty\f[]-show items with zero amount, normally hidden (and vice\-versa in-hledger\-ui/hledger\-web)-.RS-.RE+.B \f[C]-E --empty\f[R]+show items with zero amount, normally hidden (and vice-versa in+hledger-ui/hledger-web) .TP-.B \f[C]\-B\ \-\-cost\f[]+.B \f[C]-B --cost\f[R] convert amounts to their cost at transaction time (using the transaction price, if any)-.RS-.RE .TP-.B \f[C]\-V\ \-\-value\f[]+.B \f[C]-V --value\f[R] convert amounts to their market value on the report end date (using the most recent applicable market price, if any)-.RS-.RE .TP-.B \f[C]\-\-auto\f[]+.B \f[C]--auto\f[R] apply automated posting rules to modify transactions.-.RS-.RE .TP-.B \f[C]\-\-forecast\f[]+.B \f[C]--forecast\f[R] apply periodic transaction rules to generate future transactions, to 6 months from now or report end date.-.RS-.RE .PP When a reporting option appears more than once in the command line, the last one takes precedence.@@ -230,38 +164,33 @@ .PP hledger help options: .TP-.B \f[C]\-h\ \-\-help\f[]+.B \f[C]-h --help\f[R] show general usage (or after COMMAND, command usage)-.RS-.RE .TP-.B \f[C]\-\-version\f[]+.B \f[C]--version\f[R] show version-.RS-.RE .TP-.B \f[C]\-\-debug[=N]\f[]-show debug output (levels 1\-9, default: 1)-.RS-.RE+.B \f[C]--debug[=N]\f[R]+show debug output (levels 1-9, default: 1) .PP-A \@FILE argument will be expanded to the contents of FILE, which should-contain one command line option/argument per line.-(To prevent this, insert a \f[C]\-\-\f[] argument before.)+A \[at]FILE argument will be expanded to the contents of FILE, which+should contain one command line option/argument per line.+(To prevent this, insert a \f[C]--\f[R] argument before.) .SH KEYS .PP-\f[C]?\f[] shows a help dialog listing all keys.+\f[C]?\f[R] shows a help dialog listing all keys. (Some of these also appear in the quick help at the bottom of each-screen.) Press \f[C]?\f[] again (or \f[C]ESCAPE\f[], or \f[C]LEFT\f[])-to close it.+screen.) Press \f[C]?\f[R] again (or \f[C]ESCAPE\f[R], or+\f[C]LEFT\f[R]) to close it. The following keys work on most screens: .PP-The cursor keys navigate: \f[C]right\f[] (or \f[C]enter\f[]) goes-deeper, \f[C]left\f[] returns to the previous screen,-\f[C]up\f[]/\f[C]down\f[]/\f[C]page\ up\f[]/\f[C]page\ down\f[]/\f[C]home\f[]/\f[C]end\f[]+The cursor keys navigate: \f[C]right\f[R] (or \f[C]enter\f[R]) goes+deeper, \f[C]left\f[R] returns to the previous screen,+\f[C]up\f[R]/\f[C]down\f[R]/\f[C]page up\f[R]/\f[C]page down\f[R]/\f[C]home\f[R]/\f[C]end\f[R] move up and down through lists.-Vi\-style (\f[C]h\f[]/\f[C]j\f[]/\f[C]k\f[]/\f[C]l\f[]) and Emacs\-style-(\f[C]CTRL\-p\f[]/\f[C]CTRL\-n\f[]/\f[C]CTRL\-f\f[]/\f[C]CTRL\-b\f[])+Vi-style (\f[C]h\f[R]/\f[C]j\f[R]/\f[C]k\f[R]/\f[C]l\f[R]) and+Emacs-style+(\f[C]CTRL-p\f[R]/\f[C]CTRL-n\f[R]/\f[C]CTRL-f\f[R]/\f[C]CTRL-b\f[R]) movement keys are also supported. A tip: movement speed is limited by your keyboard repeat rate, to move faster you may want to adjust it.@@ -269,67 +198,67 @@ .PP With shift pressed, the cursor keys adjust the report period, limiting the transactions to be shown (by default, all are shown).-\f[C]shift\-down/up\f[] steps downward and upward through these standard+\f[C]shift-down/up\f[R] steps downward and upward through these standard report period durations: year, quarter, month, week, day.-Then, \f[C]shift\-left/right\f[] moves to the previous/next period.-\f[C]t\f[] sets the report period to today.-With the \f[C]\-\-watch\f[] option, when viewing a "current" period (the-current day, week, month, quarter, or year), the period will move-automatically to track the current date.-To set a non\-standard period, you can use \f[C]/\f[] and a-\f[C]date:\f[] query.+Then, \f[C]shift-left/right\f[R] moves to the previous/next period.+\f[C]t\f[R] sets the report period to today.+With the \f[C]--watch\f[R] option, when viewing a \[dq]current\[dq]+period (the current day, week, month, quarter, or year), the period will+move automatically to track the current date.+To set a non-standard period, you can use \f[C]/\f[R] and a+\f[C]date:\f[R] query. .PP-\f[C]/\f[] lets you set a general filter query limiting the data shown,-using the same query terms as in hledger and hledger\-web.-While editing the query, you can use CTRL\-a/e/d/k, BS, cursor keys;-press \f[C]ENTER\f[] to set it, or \f[C]ESCAPE\f[]to cancel.+\f[C]/\f[R] lets you set a general filter query limiting the data shown,+using the same query terms as in hledger and hledger-web.+While editing the query, you can use CTRL-a/e/d/k, BS, cursor keys;+press \f[C]ENTER\f[R] to set it, or \f[C]ESCAPE\f[R]to cancel. There are also keys for quickly adjusting some common filters like account depth and transaction status (see below).-\f[C]BACKSPACE\f[] or \f[C]DELETE\f[] removes all filters, showing all+\f[C]BACKSPACE\f[R] or \f[C]DELETE\f[R] removes all filters, showing all transactions. .PP-As mentioned above, hledger\-ui shows auto\-generated periodic-transactions, and hides future transactions (auto\-generated or not) by+As mentioned above, hledger-ui shows auto-generated periodic+transactions, and hides future transactions (auto-generated or not) by default.-\f[C]F\f[] toggles showing and hiding these future transactions.-This is similar to using a query like \f[C]date:\-tomorrow\f[], but more+\f[C]F\f[R] toggles showing and hiding these future transactions.+This is similar to using a query like \f[C]date:-tomorrow\f[R], but more convenient. (experimental) .PP-\f[C]ESCAPE\f[] removes all filters and jumps back to the top screen.+\f[C]ESCAPE\f[R] removes all filters and jumps back to the top screen. Or, it cancels a minibuffer edit or help dialog in progress. .PP-\f[C]CTRL\-l\f[] redraws the screen and centers the selection if+\f[C]CTRL-l\f[R] redraws the screen and centers the selection if possible (selections near the top won\[aq]t be centered, since we don\[aq]t scroll above the top). .PP-\f[C]g\f[] reloads from the data file(s) and updates the current screen+\f[C]g\f[R] reloads from the data file(s) and updates the current screen and any previous screens. (With large files, this could cause a noticeable pause.) .PP-\f[C]I\f[] toggles balance assertion checking.+\f[C]I\f[R] toggles balance assertion checking. Disabling balance assertions temporarily can be useful for troubleshooting. .PP-\f[C]a\f[] runs command\-line hledger\[aq]s add command, and reloads the+\f[C]a\f[R] runs command-line hledger\[aq]s add command, and reloads the updated file. This allows some basic data entry. .PP-\f[C]A\f[] is like \f[C]a\f[], but runs the hledger\-iadd tool, which-provides a curses\-style interface.-This key will be available if \f[C]hledger\-iadd\f[] is installed in+\f[C]A\f[R] is like \f[C]a\f[R], but runs the hledger-iadd tool, which+provides a curses-style interface.+This key will be available if \f[C]hledger-iadd\f[R] is installed in $PATH. .PP-\f[C]E\f[] runs $HLEDGER_UI_EDITOR, or $EDITOR, or a default-(\f[C]emacsclient\ \-a\ ""\ \-nw\f[]) on the journal file.+\f[C]E\f[R] runs $HLEDGER_UI_EDITOR, or $EDITOR, or a default+(\f[C]emacsclient -a \[dq]\[dq] -nw\f[R]) on the journal file. With some editors (emacs, vi), the cursor will be positioned at the current transaction when invoked from the register and transaction screens, and at the error location (if possible) when invoked from the error screen. .PP-\f[C]q\f[] quits the application.+\f[C]q\f[R] quits the application. .PP-Additional screen\-specific keys are described below.+Additional screen-specific keys are described below. .SH SCREENS .SS Accounts screen .PP@@ -342,21 +271,21 @@ accounts and the balances from matched transactions. .PP Account names are shown as a flat list by default.-Press \f[C]T\f[] to toggle tree mode.+Press \f[C]T\f[R] to toggle tree mode. In flat mode, account balances are exclusive of subaccounts, except where subaccounts are hidden by a depth limit (see below). In tree mode, all account balances are inclusive of subaccounts. .PP-To see less detail, press a number key, \f[C]1\f[] to \f[C]9\f[], to set-a depth limit.-Or use \f[C]\-\f[] to decrease and \f[C]+\f[]/\f[C]=\f[] to increase the-depth limit.-\f[C]0\f[] shows even less detail, collapsing all accounts to a single+To see less detail, press a number key, \f[C]1\f[R] to \f[C]9\f[R], to+set a depth limit.+Or use \f[C]-\f[R] to decrease and \f[C]+\f[R]/\f[C]=\f[R] to increase+the depth limit.+\f[C]0\f[R] shows even less detail, collapsing all accounts to a single total. To remove the depth limit, set it higher than the maximum account depth,-or press \f[C]ESCAPE\f[].+or press \f[C]ESCAPE\f[R]. .PP-\f[C]H\f[] toggles between showing historical balances or period+\f[C]H\f[R] toggles between showing historical balances or period balances. Historical balances (the default) are ending balances at the end of the report period, taking into account all transactions before that date@@ -368,21 +297,21 @@ they show the change in balance during the report period. They are more useful eg when viewing a time log. .PP-\f[C]U\f[] toggles filtering by unmarked status, including or excluding+\f[C]U\f[R] toggles filtering by unmarked status, including or excluding unmarked postings in the balances.-Similarly, \f[C]P\f[] toggles pending postings, and \f[C]C\f[] toggles+Similarly, \f[C]P\f[R] toggles pending postings, and \f[C]C\f[R] toggles cleared postings. (By default, balances include all postings; if you activate one or two status filters, only those postings are included; and if you activate all three, the filter is removed.) .PP-\f[C]R\f[] toggles real mode, in which virtual postings are ignored.+\f[C]R\f[R] toggles real mode, in which virtual postings are ignored. .PP-\f[C]Z\f[] toggles nonzero mode, in which only accounts with nonzero-balances are shown (hledger\-ui shows zero items by default, unlike-command\-line hledger).+\f[C]Z\f[R] toggles nonzero mode, in which only accounts with nonzero+balances are shown (hledger-ui shows zero items by default, unlike+command-line hledger). .PP-Press \f[C]right\f[] or \f[C]enter\f[] to view an account\[aq]s+Press \f[C]right\f[R] or \f[C]enter\f[R] to view an account\[aq]s transactions register. .SS Register screen .PP@@ -399,7 +328,7 @@ .IP \[bu] 2 the running historical total or period total for the current account, after the transaction.-This can be toggled with \f[C]H\f[].+This can be toggled with \f[C]H\f[R]. Similar to the accounts screen, the historical total is affected by transactions (filtered by the filter query) before the report start date, while the period total is not.@@ -416,23 +345,23 @@ .PD 0 .P .PD-Tree mode/flat mode can be toggled with \f[C]T\f[] here also.+Tree mode/flat mode can be toggled with \f[C]T\f[R] here also. .PP-\f[C]U\f[] toggles filtering by unmarked status, showing or hiding+\f[C]U\f[R] toggles filtering by unmarked status, showing or hiding unmarked transactions.-Similarly, \f[C]P\f[] toggles pending transactions, and \f[C]C\f[]+Similarly, \f[C]P\f[R] toggles pending transactions, and \f[C]C\f[R] toggles cleared transactions. (By default, transactions with all statuses are shown; if you activate one or two status filters, only those transactions are shown; and if you activate all three, the filter is removed.) .PP-\f[C]R\f[] toggles real mode, in which virtual postings are ignored.+\f[C]R\f[R] toggles real mode, in which virtual postings are ignored. .PP-\f[C]Z\f[] toggles nonzero mode, in which only transactions posting a-nonzero change are shown (hledger\-ui shows zero items by default,-unlike command\-line hledger).+\f[C]Z\f[R] toggles nonzero mode, in which only transactions posting a+nonzero change are shown (hledger-ui shows zero items by default, unlike+command-line hledger). .PP-Press \f[C]right\f[] (or \f[C]enter\f[]) to view the selected+Press \f[C]right\f[R] (or \f[C]enter\f[R]) to view the selected transaction in detail. .SS Transaction screen .PP@@ -445,8 +374,8 @@ Simple transactions have two postings, but there can be more (or in certain cases, fewer). .PP-\f[C]up\f[] and \f[C]down\f[] will step through all transactions listed-in the previous account register screen.+\f[C]up\f[R] and \f[C]down\f[R] will step through all transactions+listed in the previous account register screen. In the title bar, the numbers in parentheses show your position within that account register. They will vary depending on which account register you came from@@ -463,40 +392,43 @@ (Or, you can press escape to cancel the reload attempt.) .SH ENVIRONMENT .PP-\f[B]COLUMNS\f[] The screen width to use.+\f[B]COLUMNS\f[R] The screen width to use. Default: the full terminal width. .PP-\f[B]LEDGER_FILE\f[] The journal file path when not specified with-\f[C]\-f\f[].-Default: \f[C]~/.hledger.journal\f[] (on windows, perhaps-\f[C]C:/Users/USER/.hledger.journal\f[]).+\f[B]LEDGER_FILE\f[R] The journal file path when not specified with+\f[C]-f\f[R].+Default: \f[C]\[ti]/.hledger.journal\f[R] (on windows, perhaps+\f[C]C:/Users/USER/.hledger.journal\f[R]). .SH FILES .PP Reads data from one or more files in hledger journal, timeclock,-timedot, or CSV format specified with \f[C]\-f\f[], or-\f[C]$LEDGER_FILE\f[], or \f[C]$HOME/.hledger.journal\f[] (on windows,-perhaps \f[C]C:/Users/USER/.hledger.journal\f[]).+timedot, or CSV format specified with \f[C]-f\f[R], or+\f[C]$LEDGER_FILE\f[R], or \f[C]$HOME/.hledger.journal\f[R] (on windows,+perhaps \f[C]C:/Users/USER/.hledger.journal\f[R]). .SH BUGS .PP-The need to precede options with \f[C]\-\-\f[] when invoked from hledger+The need to precede options with \f[C]--\f[R] when invoked from hledger is awkward. .PP-\f[C]\-f\-\f[] doesn\[aq]t work (hledger\-ui can\[aq]t read from stdin).+\f[C]-f-\f[R] doesn\[aq]t work (hledger-ui can\[aq]t read from stdin). .PP-\f[C]\-V\f[] affects only the accounts screen.+\f[C]-V\f[R] affects only the accounts screen. .PP-When you press \f[C]g\f[], the current and all previous screens are+When you press \f[C]g\f[R], the current and all previous screens are regenerated, which may cause a noticeable pause with large files. Also there is no visual indication that this is in progress. .PP-\f[C]\-\-watch\f[] is not yet fully robust.+\f[C]--watch\f[R] is not yet fully robust. It works well for normal usage, but many file changes in a short time (eg saving the file thousands of times with an editor macro) can cause problems at least on OSX. Symptoms include: unresponsive UI, periodic resetting of the cursor position, momentary display of parse errors, high CPU usage eventually-subsiding, and possibly a small but persistent build\-up of CPU usage+subsiding, and possibly a small but persistent build-up of CPU usage until the program is restarted.+.PP+Also, if you are viewing files mounted from another machine,+\f[C]--watch\f[R] requires that both machine clocks are roughly in step.   .SH "REPORTING BUGS"
embeddedfiles/hledger-ui.info view
@@ -3,7 +3,7 @@  File: hledger-ui.info,  Node: Top,  Next: OPTIONS,  Up: (dir) -hledger-ui(1) hledger-ui 1.14+hledger-ui(1) hledger-ui 1.15 *****************************  hledger-ui is hledger's curses-style interface, providing an efficient@@ -24,6 +24,7 @@ '$LEDGER_FILE', or '$HOME/.hledger.journal' (on windows, perhaps 'C:/Users/USER/.hledger.journal').  For more about this see hledger(1), hledger_journal(5) etc.+ * Menu:  * OPTIONS::@@ -116,7 +117,7 @@ '-p --period=PERIODEXP'       set start date, end date, and/or reporting interval all at once-     using period expressions syntax (overrides the flags above)+     using period expressions syntax '--date2'       match the secondary date instead (see command help for other@@ -398,19 +399,19 @@  Tag Table: Node: Top71-Node: OPTIONS1100-Ref: #options1197-Node: KEYS4616-Ref: #keys4711-Node: SCREENS7967-Ref: #screens8052-Node: Accounts screen8142-Ref: #accounts-screen8270-Node: Register screen10486-Ref: #register-screen10641-Node: Transaction screen12637-Ref: #transaction-screen12795-Node: Error screen13665-Ref: #error-screen13787+Node: OPTIONS1101+Ref: #options1198+Node: KEYS4589+Ref: #keys4684+Node: SCREENS7940+Ref: #screens8025+Node: Accounts screen8115+Ref: #accounts-screen8243+Node: Register screen10459+Ref: #register-screen10614+Node: Transaction screen12610+Ref: #transaction-screen12768+Node: Error screen13638+Ref: #error-screen13760  End Tag Table
embeddedfiles/hledger-ui.txt view
@@ -18,9 +18,9 @@         hledger-ui is hledger's curses-style interface, providing an  efficient        full-window  text  UI  for  viewing accounts and transactions, and some-       limited data entry  capability.   It  is  easier  than  hledger's  com--       mand-line interface, and sometimes quicker and more convenient than the-       web interface.+       limited data entry capability.  It is easier  than  hledger's  command-+       line  interface, and sometimes quicker and more convenient than the web+       interface.         Note hledger-ui has some different defaults (experimental): @@ -114,7 +114,7 @@         -p --period=PERIODEXP               set  start date, end date, and/or reporting interval all at once-              using period expressions syntax (overrides the flags above)+              using period expressions syntax         --date2               match the secondary date instead (see  command  help  for  other@@ -179,22 +179,22 @@        or LEFT) to close it.  The following keys work on most screens:         The cursor keys navigate: right (or enter) goes deeper, left returns to-       the  previous  screen,  up/down/page up/page down/home/end  move up and-       down   through   lists.     Vi-style    (h/j/k/l)    and    Emacs-style-       (CTRL-p/CTRL-n/CTRL-f/CTRL-b) movement keys are also supported.  A tip:-       movement speed is limited by your keyboard repeat rate, to move  faster-       you  may  want to adjust it.  (If you're on a mac, the Karabiner app is-       one way to do that.)+       the  previous  screen,  up/down/page  up/page down/home/end move up and+       down through lists.  Vi-style (h/j/k/l) and  Emacs-style  (CTRL-p/CTRL-+       n/CTRL-f/CTRL-b)  movement  keys  are  also supported.  A tip: movement+       speed is limited by your keyboard repeat rate, to move faster  you  may+       want  to  adjust it.  (If you're on a mac, the Karabiner app is one way+       to do that.)         With shift pressed, the cursor keys adjust the report period,  limiting-       the   transactions   to   be   shown   (by  default,  all  are  shown).-       shift-down/up steps downward and upward through these  standard  report-       period   durations:   year,   quarter,   month,   week,   day.    Then,-       shift-left/right moves to the previous/next period.  t sets the  report-       period  to  today.   With  the --watch option, when viewing a "current"-       period (the current day, week, month, quarter,  or  year),  the  period-       will  move automatically to track the current date.  To set a non-stan--       dard period, you can use / and a date: query.+       the  transactions  to  be  shown  (by  default, all are shown).  shift-+       down/up steps downward and upward through these standard report  period+       durations:  year,  quarter,  month,  week, day.  Then, shift-left/right+       moves to the previous/next period.  t sets the report period to  today.+       With  the  --watch option, when viewing a "current" period (the current+       day, week, month, quarter, or year), the period will move automatically+       to track the current date.  To set a non-standard period, you can use /+       and a date: query.         / lets you set a general filter query limiting the  data  shown,  using        the  same query terms as in hledger and hledger-web.  While editing the@@ -226,15 +226,15 @@        a  runs  command-line  hledger's  add  command, and reloads the updated        file.  This allows some basic data entry. -       A is  like  a,  but  runs  the  hledger-iadd  tool,  which  provides  a-       curses-style  interface.  This key will be available if hledger-iadd is+       A is like a, but runs the hledger-iadd tool, which provides  a  curses-+       style  interface.   This  key  will  be  available  if  hledger-iadd is        installed in $PATH. -       E  runs  $HLEDGER_UI_EDITOR,  or   $EDITOR,   or   a   default   (emac--       sclient -a "" -nw) on the journal file.  With some editors (emacs, vi),-       the cursor will be positioned at the current transaction  when  invoked-       from  the  register  and transaction screens, and at the error location-       (if possible) when invoked from the error screen.+       E runs $HLEDGER_UI_EDITOR, or $EDITOR, or a default (emacsclient -a  ""+       -nw)  on  the  journal file.  With some editors (emacs, vi), the cursor+       will be positioned at the current transaction  when  invoked  from  the+       register  and transaction screens, and at the error location (if possi-+       ble) when invoked from the error screen.         q quits the application. @@ -381,10 +381,13 @@        siding, and possibly a small but persistent build-up of CPU usage until        the program is restarted. +       Also,  if  you  are viewing files mounted from another machine, --watch+       requires that both machine clocks are roughly in step.  + REPORTING BUGS-       Report  bugs at http://bugs.hledger.org (or on the #hledger IRC channel+       Report bugs at http://bugs.hledger.org (or on the #hledger IRC  channel        or hledger mail list)  @@ -398,7 +401,7 @@   SEE ALSO-       hledger(1),     hledger-ui(1),     hledger-web(1),      hledger-api(1),+       hledger(1),      hledger-ui(1),     hledger-web(1),     hledger-api(1),        hledger_csv(5), hledger_journal(5), hledger_timeclock(5), hledger_time-        dot(5), ledger(1) @@ -406,4 +409,4 @@   -hledger-ui 1.14                   March 2019                     hledger-ui(1)+hledger-ui 1.15                   August 2019                    hledger-ui(1)
embeddedfiles/hledger-web.1 view
@@ -1,34 +1,34 @@ -.TH "hledger\-web" "1" "March 2019" "hledger\-web 1.14" "hledger User Manuals"+.TH "hledger-web" "1" "August 2019" "hledger-web 1.15" "hledger User Manuals"    .SH NAME .PP-hledger\-web \- web interface for the hledger accounting tool+hledger-web - web interface for the hledger accounting tool .SH SYNOPSIS .PP-\f[C]hledger\-web\ [OPTIONS]\f[]+\f[C]hledger-web [OPTIONS]\f[R] .PD 0 .P .PD-\f[C]hledger\ web\ \-\-\ [OPTIONS]\f[]+\f[C]hledger web -- [OPTIONS]\f[R] .SH DESCRIPTION .PP-hledger is a cross\-platform program for tracking money, time, or any-other commodity, using double\-entry accounting and a simple, editable+hledger is a cross-platform program for tracking money, time, or any+other commodity, using double-entry accounting and a simple, editable file format. hledger is inspired by and largely compatible with ledger(1). .PP-hledger\-web is hledger\[aq]s web interface.+hledger-web is hledger\[aq]s web interface. It starts a simple web application for browsing and adding transactions, and optionally opens it in a web browser window if possible.-It provides a more user\-friendly UI than the hledger CLI or hledger\-ui+It provides a more user-friendly UI than the hledger CLI or hledger-ui interface, showing more at once (accounts, the current account register,-balance charts) and allowing history\-aware data entry, interactive+balance charts) and allowing history-aware data entry, interactive searching, and bookmarking. .PP-hledger\-web also lets you share a ledger with multiple users, or even+hledger-web also lets you share a ledger with multiple users, or even the public web. There is no access control, so if you need that you should put it behind a suitable web proxy.@@ -37,201 +37,139 @@ on every edit. .PP Like hledger, it reads data from one or more files in hledger journal,-timeclock, timedot, or CSV format specified with \f[C]\-f\f[], or-\f[C]$LEDGER_FILE\f[], or \f[C]$HOME/.hledger.journal\f[] (on windows,-perhaps \f[C]C:/Users/USER/.hledger.journal\f[]).+timeclock, timedot, or CSV format specified with \f[C]-f\f[R], or+\f[C]$LEDGER_FILE\f[R], or \f[C]$HOME/.hledger.journal\f[R] (on windows,+perhaps \f[C]C:/Users/USER/.hledger.journal\f[R]). For more about this see hledger(1), hledger_journal(5) etc. .SH OPTIONS .PP-Command\-line options and arguments may be used to set an initial filter+Command-line options and arguments may be used to set an initial filter on the data. These filter options are not shown in the web UI, but it will be applied in addition to any search query entered there. .PP-Note: if invoking hledger\-web as a hledger subcommand, write-\f[C]\-\-\f[] before options, as shown in the synopsis above.+Note: if invoking hledger-web as a hledger subcommand, write+\f[C]--\f[R] before options, as shown in the synopsis above. .TP-.B \f[C]\-\-serve\f[]-serve and log requests, don\[aq]t browse or auto\-exit-.RS-.RE+.B \f[C]--serve\f[R]+serve and log requests, don\[aq]t browse or auto-exit .TP-.B \f[C]\-\-host=IPADDR\f[]+.B \f[C]--serve-api\f[R]+like --serve, but serve only the JSON web API, without the server-side+web UI+.TP+.B \f[C]--host=IPADDR\f[R] listen on this IP address (default: 127.0.0.1)-.RS-.RE .TP-.B \f[C]\-\-port=PORT\f[]+.B \f[C]--port=PORT\f[R] listen on this TCP port (default: 5000)-.RS-.RE .TP-.B \f[C]\-\-base\-url=URL\f[]+.B \f[C]--base-url=URL\f[R] set the base url (default: http://IPADDR:PORT). You would change this when sharing over the network, or integrating within a larger website.-.RS-.RE .TP-.B \f[C]\-\-file\-url=URL\f[]+.B \f[C]--file-url=URL\f[R] set the static files url (default: BASEURL/static).-hledger\-web normally serves static files itself, but if you wanted to+hledger-web normally serves static files itself, but if you wanted to serve them from another server for efficiency, you would set the url with this.-.RS-.RE .TP-.B \f[C]\-\-capabilities=CAP[,CAP..]\f[]+.B \f[C]--capabilities=CAP[,CAP..]\f[R] enable the view, add, and/or manage capabilities (default: view,add)-.RS-.RE .TP-.B \f[C]\-\-capabilities\-header=HTTPHEADER\f[]+.B \f[C]--capabilities-header=HTTPHEADER\f[R] read capabilities to enable from a HTTP header, like-X\-Sandstorm\-Permissions (default: disabled)-.RS-.RE+X-Sandstorm-Permissions (default: disabled) .PP hledger input options: .TP-.B \f[C]\-f\ FILE\ \-\-file=FILE\f[]+.B \f[C]-f FILE --file=FILE\f[R] use a different input file.-For stdin, use \- (default: \f[C]$LEDGER_FILE\f[] or-\f[C]$HOME/.hledger.journal\f[])-.RS-.RE+For stdin, use - (default: \f[C]$LEDGER_FILE\f[R] or+\f[C]$HOME/.hledger.journal\f[R]) .TP-.B \f[C]\-\-rules\-file=RULESFILE\f[]+.B \f[C]--rules-file=RULESFILE\f[R] Conversion rules file to use when reading CSV (default: FILE.rules)-.RS-.RE .TP-.B \f[C]\-\-separator=CHAR\f[]+.B \f[C]--separator=CHAR\f[R] Field separator to expect when reading CSV (default: \[aq],\[aq])-.RS-.RE .TP-.B \f[C]\-\-alias=OLD=NEW\f[]+.B \f[C]--alias=OLD=NEW\f[R] rename accounts named OLD to NEW-.RS-.RE .TP-.B \f[C]\-\-anon\f[]+.B \f[C]--anon\f[R] anonymize accounts and payees-.RS-.RE .TP-.B \f[C]\-\-pivot\ FIELDNAME\f[]+.B \f[C]--pivot FIELDNAME\f[R] use some other field or tag for the account name-.RS-.RE .TP-.B \f[C]\-I\ \-\-ignore\-assertions\f[]+.B \f[C]-I --ignore-assertions\f[R] ignore any failing balance assertions-.RS-.RE .PP hledger reporting options: .TP-.B \f[C]\-b\ \-\-begin=DATE\f[]+.B \f[C]-b --begin=DATE\f[R] include postings/txns on or after this date-.RS-.RE .TP-.B \f[C]\-e\ \-\-end=DATE\f[]+.B \f[C]-e --end=DATE\f[R] include postings/txns before this date-.RS-.RE .TP-.B \f[C]\-D\ \-\-daily\f[]+.B \f[C]-D --daily\f[R] multiperiod/multicolumn report by day-.RS-.RE .TP-.B \f[C]\-W\ \-\-weekly\f[]+.B \f[C]-W --weekly\f[R] multiperiod/multicolumn report by week-.RS-.RE .TP-.B \f[C]\-M\ \-\-monthly\f[]+.B \f[C]-M --monthly\f[R] multiperiod/multicolumn report by month-.RS-.RE .TP-.B \f[C]\-Q\ \-\-quarterly\f[]+.B \f[C]-Q --quarterly\f[R] multiperiod/multicolumn report by quarter-.RS-.RE .TP-.B \f[C]\-Y\ \-\-yearly\f[]+.B \f[C]-Y --yearly\f[R] multiperiod/multicolumn report by year-.RS-.RE .TP-.B \f[C]\-p\ \-\-period=PERIODEXP\f[]+.B \f[C]-p --period=PERIODEXP\f[R] set start date, end date, and/or reporting interval all at once using-period expressions syntax (overrides the flags above)-.RS-.RE+period expressions syntax .TP-.B \f[C]\-\-date2\f[]+.B \f[C]--date2\f[R] match the secondary date instead (see command help for other effects)-.RS-.RE .TP-.B \f[C]\-U\ \-\-unmarked\f[]-include only unmarked postings/txns (can combine with \-P or \-C)-.RS-.RE+.B \f[C]-U --unmarked\f[R]+include only unmarked postings/txns (can combine with -P or -C) .TP-.B \f[C]\-P\ \-\-pending\f[]+.B \f[C]-P --pending\f[R] include only pending postings/txns-.RS-.RE .TP-.B \f[C]\-C\ \-\-cleared\f[]+.B \f[C]-C --cleared\f[R] include only cleared postings/txns-.RS-.RE .TP-.B \f[C]\-R\ \-\-real\f[]-include only non\-virtual postings-.RS-.RE+.B \f[C]-R --real\f[R]+include only non-virtual postings .TP-.B \f[C]\-NUM\ \-\-depth=NUM\f[]+.B \f[C]-NUM --depth=NUM\f[R] hide/aggregate accounts or postings more than NUM levels deep-.RS-.RE .TP-.B \f[C]\-E\ \-\-empty\f[]-show items with zero amount, normally hidden (and vice\-versa in-hledger\-ui/hledger\-web)-.RS-.RE+.B \f[C]-E --empty\f[R]+show items with zero amount, normally hidden (and vice-versa in+hledger-ui/hledger-web) .TP-.B \f[C]\-B\ \-\-cost\f[]+.B \f[C]-B --cost\f[R] convert amounts to their cost at transaction time (using the transaction price, if any)-.RS-.RE .TP-.B \f[C]\-V\ \-\-value\f[]+.B \f[C]-V --value\f[R] convert amounts to their market value on the report end date (using the most recent applicable market price, if any)-.RS-.RE .TP-.B \f[C]\-\-auto\f[]+.B \f[C]--auto\f[R] apply automated posting rules to modify transactions.-.RS-.RE .TP-.B \f[C]\-\-forecast\f[]+.B \f[C]--forecast\f[R] apply periodic transaction rules to generate future transactions, to 6 months from now or report end date.-.RS-.RE .PP When a reporting option appears more than once in the command line, the last one takes precedence.@@ -240,59 +178,55 @@ .PP hledger help options: .TP-.B \f[C]\-h\ \-\-help\f[]+.B \f[C]-h --help\f[R] show general usage (or after COMMAND, command usage)-.RS-.RE .TP-.B \f[C]\-\-version\f[]+.B \f[C]--version\f[R] show version-.RS-.RE .TP-.B \f[C]\-\-debug[=N]\f[]-show debug output (levels 1\-9, default: 1)-.RS-.RE+.B \f[C]--debug[=N]\f[R]+show debug output (levels 1-9, default: 1) .PP-A \@FILE argument will be expanded to the contents of FILE, which should-contain one command line option/argument per line.-(To prevent this, insert a \f[C]\-\-\f[] argument before.)+A \[at]FILE argument will be expanded to the contents of FILE, which+should contain one command line option/argument per line.+(To prevent this, insert a \f[C]--\f[R] argument before.) .PP-By default, hledger\-web starts the web app in "transient mode" and also-opens it in your default web browser if possible.+By default, hledger-web starts the web app in \[dq]transient mode\[dq]+and also opens it in your default web browser if possible. In this mode the web app will keep running for as long as you have it open in a browser window, and will exit after two minutes of inactivity (no requests and no browser windows viewing it).-With \f[C]\-\-serve\f[], it just runs the web app without exiting, and+With \f[C]--serve\f[R], it just runs the web app without exiting, and logs requests to the console.+With \f[C]--serve-api\f[R], only the JSON web api (see below) is served,+with the usual HTML server-side web UI disabled. .PP By default the server listens on IP address 127.0.0.1, accessible only to local requests.-You can use \f[C]\-\-host\f[] to change this, eg-\f[C]\-\-host\ 0.0.0.0\f[] to listen on all configured addresses.+You can use \f[C]--host\f[R] to change this, eg \f[C]--host 0.0.0.0\f[R]+to listen on all configured addresses. .PP-Similarly, use \f[C]\-\-port\f[] to set a TCP port other than 5000, eg-if you are running multiple hledger\-web instances.+Similarly, use \f[C]--port\f[R] to set a TCP port other than 5000, eg if+you are running multiple hledger-web instances. .PP-You can use \f[C]\-\-base\-url\f[] to change the protocol, hostname,-port and path that appear in hyperlinks, useful eg for integrating-hledger\-web within a larger website.-The default is \f[C]http://HOST:PORT/\f[] using the server\[aq]s-configured host address and TCP port (or \f[C]http://HOST\f[] if PORT is-80).+You can use \f[C]--base-url\f[R] to change the protocol, hostname, port+and path that appear in hyperlinks, useful eg for integrating+hledger-web within a larger website.+The default is \f[C]http://HOST:PORT/\f[R] using the server\[aq]s+configured host address and TCP port (or \f[C]http://HOST\f[R] if PORT+is 80). .PP-With \f[C]\-\-file\-url\f[] you can set a different base url for static-files, eg for better caching or cookie\-less serving on high performance+With \f[C]--file-url\f[R] you can set a different base url for static+files, eg for better caching or cookie-less serving on high performance websites. .SH PERMISSIONS .PP-By default, hledger\-web allows anyone who can reach it to view the+By default, hledger-web allows anyone who can reach it to view the journal and to add new transactions, but not to change existing data. .PP You can restrict who can reach it by .IP \[bu] 2-setting the IP address it listens on (see \f[C]\-\-host\f[] above).+setting the IP address it listens on (see \f[C]--host\f[R] above). By default it listens on 127.0.0.1, accessible to all users on the local machine. .IP \[bu] 2@@ -302,56 +236,62 @@ .PP You can restrict what the users who reach it can do, by .IP \[bu] 2-using the \f[C]\-\-capabilities=CAP[,CAP..]\f[] flag when you start it,+using the \f[C]--capabilities=CAP[,CAP..]\f[R] flag when you start it, enabling one or more of the following capabilities.-The default value is \f[C]view,add\f[]:+The default value is \f[C]view,add\f[R]: .RS 2 .IP \[bu] 2-\f[C]view\f[] \- allows viewing the journal file and all included files+\f[C]view\f[R] - allows viewing the journal file and all included files .IP \[bu] 2-\f[C]add\f[] \- allows adding new transactions to the main journal file+\f[C]add\f[R] - allows adding new transactions to the main journal file .IP \[bu] 2-\f[C]manage\f[] \- allows editing, uploading or downloading the main or+\f[C]manage\f[R] - allows editing, uploading or downloading the main or included files .RE .IP \[bu] 2-using the \f[C]\-\-capabilities\-header=HTTPHEADER\f[] flag to specify a+using the \f[C]--capabilities-header=HTTPHEADER\f[R] flag to specify a HTTP header from which it will read capabilities to enable.-hledger\-web on Sandstorm uses the X\-Sandstorm\-Permissions header to+hledger-web on Sandstorm uses the X-Sandstorm-Permissions header to integrate with Sandstorm\[aq]s permissions. This is disabled by default. .SH EDITING, UPLOADING, DOWNLOADING .PP-If you enable the \f[C]manage\f[] capability mentioned above, you\[aq]ll-see a new "spanner" button to the right of the search form.+If you enable the \f[C]manage\f[R] capability mentioned above,+you\[aq]ll see a new \[dq]spanner\[dq] button to the right of the search+form. Clicking this will let you edit, upload, or download the journal file or any files it includes. .PP Note, unlike any other hledger command, in this mode you (or any visitor) can alter or wipe the data files. .PP-Normally whenever a file is changed in this way, hledger\-web saves a+Normally whenever a file is changed in this way, hledger-web saves a numbered backup (assuming file permissions allow it, the disk is not-full, etc.) hledger\-web is not aware of version control systems,+full, etc.) hledger-web is not aware of version control systems, currently; if you use one, you\[aq]ll have to arrange to commit the changes yourself (eg with a cron job or a file watcher like entr). .PP-Changes which would leave the journal file(s) unparseable or non\-valid+Changes which would leave the journal file(s) unparseable or non-valid (eg with failing balance assertions) are prevented. (Probably.-This needs re\-testing.)+This needs re-testing.) .SH RELOADING .PP-hledger\-web detects changes made to the files by other means (eg if you-edit it directly, outside of hledger\-web), and it will show the new-data when you reload the page or navigate to a new page.-If a change makes a file unparseable, hledger\-web will display an error+hledger-web detects changes made to the files by other means (eg if you+edit it directly, outside of hledger-web), and it will show the new data+when you reload the page or navigate to a new page.+If a change makes a file unparseable, hledger-web will display an error message until the file has been fixed.+.PP+(Note: if you are viewing files mounted from another machine, make sure+that both machine clocks are roughly in step.) .SH JSON API .PP-In addition to the web UI, hledger\-web provides some JSON API routes.-These are similar to the API provided by the hledger\-api tool, but it-may be convenient to have them in hledger\-web also.+In addition to the web UI, hledger-web provides some API routes that+serve JSON in response to GET requests.+Currently these are same ones provided by the hledger-api tool, but+hledger-web will likely receive more attention than hledger-api in+future: .IP .nf \f[C]@@ -361,31 +301,69 @@ /commodities /accounts /accounttransactions/#AccountName-\f[]+\f[R] .fi+.PP+Also, you can append a new transaction to the journal by sending a PUT+request to \f[C]/add\f[R] (hledger-web only).+As with the web UI\[aq]s add form, hledger-web must be started with the+\f[C]add\f[R] capability for this (enabled by default).+.PP+The payload should be a valid hledger transaction as JSON, similar to+what you get from \f[C]/transactions\f[R] or+\f[C]/accounttransactions\f[R].+.PP+Another way to generate test data is with the+\f[C]readJsonFile\f[R]/\f[C]writeJsonFile\f[R] helpers in+Hledger.Web.Json, which read or write any of hledger\[aq]s JSON-capable+types from or to a file.+Eg here we write the first transaction of a sample journal:+.IP+.nf+\f[C]+$ make ghci-web+>>> :m +*Hledger.Web.Json+>>> writeJsonFile \[dq]txn.json\[dq] (head $ jtxns samplejournal)+>>> :q+$ python -m json.tool <txn.json >txn.pretty.json  # optional: make human-readable+\f[R]+.fi+.PP+(sample output & discussion)+.PP+And here\[aq]s how to test adding that with curl:+.IP+.nf+\f[C]+$ curl -s http://127.0.0.1:5000/add -X PUT -H \[aq]Content-Type: application/json\[aq] --data-binary \[at]txn.pretty.json; echo+\f[R]+.fi+.PP+By default, both the server-side HTML UI and the JSON API are served.+Running with \f[C]--serve-api\f[R] disables the former, useful if you+only want to serve the API. .SH ENVIRONMENT .PP-\f[B]LEDGER_FILE\f[] The journal file path when not specified with-\f[C]\-f\f[].-Default: \f[C]~/.hledger.journal\f[] (on windows, perhaps-\f[C]C:/Users/USER/.hledger.journal\f[]).+\f[B]LEDGER_FILE\f[R] The journal file path when not specified with+\f[C]-f\f[R].+Default: \f[C]\[ti]/.hledger.journal\f[R] (on windows, perhaps+\f[C]C:/Users/USER/.hledger.journal\f[R]). .SH FILES .PP Reads data from one or more files in hledger journal, timeclock,-timedot, or CSV format specified with \f[C]\-f\f[], or-\f[C]$LEDGER_FILE\f[], or \f[C]$HOME/.hledger.journal\f[] (on windows,-perhaps \f[C]C:/Users/USER/.hledger.journal\f[]).+timedot, or CSV format specified with \f[C]-f\f[R], or+\f[C]$LEDGER_FILE\f[R], or \f[C]$HOME/.hledger.journal\f[R] (on windows,+perhaps \f[C]C:/Users/USER/.hledger.journal\f[R]). .SH BUGS .PP-The need to precede options with \f[C]\-\-\f[] when invoked from hledger+The need to precede options with \f[C]--\f[R] when invoked from hledger is awkward. .PP-\f[C]\-f\-\f[] doesn\[aq]t work (hledger\-web can\[aq]t read from-stdin).+\f[C]-f-\f[R] doesn\[aq]t work (hledger-web can\[aq]t read from stdin). .PP Query arguments and some hledger options are ignored. .PP-Does not work in text\-mode browsers.+Does not work in text-mode browsers. .PP Does not work well on small screens. 
embeddedfiles/hledger-web.info view
@@ -3,7 +3,7 @@  File: hledger-web.info,  Node: Top,  Next: OPTIONS,  Up: (dir) -hledger-web(1) hledger-web 1.14+hledger-web(1) hledger-web 1.15 *******************************  hledger-web is hledger's web interface.  It starts a simple web@@ -25,6 +25,7 @@ '$LEDGER_FILE', or '$HOME/.hledger.journal' (on windows, perhaps 'C:/Users/USER/.hledger.journal').  For more about this see hledger(1), hledger_journal(5) etc.+ * Menu:  * OPTIONS::@@ -49,6 +50,10 @@ '--serve'       serve and log requests, don't browse or auto-exit+'--serve-api'++     like -serve, but serve only the JSON web API, without the+     server-side web UI '--host=IPADDR'       listen on this IP address (default: 127.0.0.1)@@ -126,7 +131,7 @@ '-p --period=PERIODEXP'       set start date, end date, and/or reporting interval all at once-     using period expressions syntax (overrides the flags above)+     using period expressions syntax '--date2'       match the secondary date instead (see command help for other@@ -192,7 +197,9 @@ web app will keep running for as long as you have it open in a browser window, and will exit after two minutes of inactivity (no requests and no browser windows viewing it).  With '--serve', it just runs the web-app without exiting, and logs requests to the console.+app without exiting, and logs requests to the console.  With+'--serve-api', only the JSON web api (see below) is served, with the+usual HTML server-side web UI disabled.     By default the server listens on IP address 127.0.0.1, accessible only to local requests.  You can use '--host' to change this, eg '--host@@ -281,15 +288,19 @@ file unparseable, hledger-web will display an error message until the file has been fixed. +   (Note: if you are viewing files mounted from another machine, make+sure that both machine clocks are roughly in step.)+  File: hledger-web.info,  Node: JSON API,  Prev: RELOADING,  Up: Top  5 JSON API ********** -In addition to the web UI, hledger-web provides some JSON API routes.-These are similar to the API provided by the hledger-api tool, but it-may be convenient to have them in hledger-web also.+In addition to the web UI, hledger-web provides some API routes that+serve JSON in response to GET requests.  Currently these are same ones+provided by the hledger-api tool, but hledger-web will likely receive+more attention than hledger-api in future:  /accountnames /transactions@@ -298,18 +309,47 @@ /accounts /accounttransactions/#AccountName +   Also, you can append a new transaction to the journal by sending a+PUT request to '/add' (hledger-web only).  As with the web UI's add+form, hledger-web must be started with the 'add' capability for this+(enabled by default).++   The payload should be a valid hledger transaction as JSON, similar to+what you get from '/transactions' or '/accounttransactions'.++   Another way to generate test data is with the+'readJsonFile'/'writeJsonFile' helpers in Hledger.Web.Json, which read+or write any of hledger's JSON-capable types from or to a file.  Eg here+we write the first transaction of a sample journal:++$ make ghci-web+>>> :m +*Hledger.Web.Json+>>> writeJsonFile "txn.json" (head $ jtxns samplejournal)+>>> :q+$ python -m json.tool <txn.json >txn.pretty.json  # optional: make human-readable++   (sample output & discussion)++   And here's how to test adding that with curl:++$ curl -s http://127.0.0.1:5000/add -X PUT -H 'Content-Type: application/json' --data-binary @txn.pretty.json; echo++   By default, both the server-side HTML UI and the JSON API are served.+Running with '--serve-api' disables the former, useful if you only want+to serve the API.+  Tag Table: Node: Top72-Node: OPTIONS1354-Ref: #options1459-Node: PERMISSIONS6549-Ref: #permissions6688-Node: EDITING UPLOADING DOWNLOADING7900-Ref: #editing-uploading-downloading8081-Node: RELOADING8915-Ref: #reloading9049-Node: JSON API9359-Ref: #json-api9453+Node: OPTIONS1355+Ref: #options1460+Node: PERMISSIONS6739+Ref: #permissions6878+Node: EDITING UPLOADING DOWNLOADING8090+Ref: #editing-uploading-downloading8271+Node: RELOADING9105+Ref: #reloading9239+Node: JSON API9672+Ref: #json-api9766  End Tag Table
embeddedfiles/hledger-web.txt view
@@ -46,6 +46,10 @@        --serve               serve and log requests, don't browse or auto-exit +       --serve-api+              like --serve, but serve only  the  JSON  web  API,  without  the+              server-side web UI+        --host=IPADDR               listen on this IP address (default: 127.0.0.1) @@ -53,22 +57,22 @@               listen on this TCP port (default: 5000)         --base-url=URL-              set the  base  url  (default:  http://IPADDR:PORT).   You  would+              set  the  base  url  (default:  http://IPADDR:PORT).   You would               change this when sharing over the network, or integrating within               a larger website.         --file-url=URL               set the static files url (default: BASEURL/static).  hledger-web-              normally  serves static files itself, but if you wanted to serve-              them from another server for efficiency, you would set  the  url+              normally serves static files itself, but if you wanted to  serve+              them  from  another server for efficiency, you would set the url               with this.         --capabilities=CAP[,CAP..]-              enable  the  view,  add,  and/or  manage  capabilities (default:+              enable the  view,  add,  and/or  manage  capabilities  (default:               view,add)         --capabilities-header=HTTPHEADER-              read capabilities to enable from a  HTTP  header,  like  X-Sand-+              read  capabilities  to  enable  from a HTTP header, like X-Sand-               storm-Permissions (default: disabled)         hledger input options:@@ -78,7 +82,7 @@               $LEDGER_FILE or $HOME/.hledger.journal)         --rules-file=RULESFILE-              Conversion  rules  file  to  use  when  reading  CSV   (default:+              Conversion   rules  file  to  use  when  reading  CSV  (default:               FILE.rules)         --separator=CHAR@@ -119,11 +123,11 @@               multiperiod/multicolumn report by year         -p --period=PERIODEXP-              set  start date, end date, and/or reporting interval all at once-              using period expressions syntax (overrides the flags above)+              set start date, end date, and/or reporting interval all at  once+              using period expressions syntax         --date2-              match the secondary date instead (see  command  help  for  other+              match  the  secondary  date  instead (see command help for other               effects)         -U --unmarked@@ -142,21 +146,21 @@               hide/aggregate accounts or postings more than NUM levels deep         -E --empty-              show  items with zero amount, normally hidden (and vice-versa in+              show items with zero amount, normally hidden (and vice-versa  in               hledger-ui/hledger-web)         -B --cost-              convert amounts to their cost at  transaction  time  (using  the+              convert  amounts  to  their  cost at transaction time (using the               transaction price, if any)         -V --value-              convert  amounts  to  their  market value on the report end date+              convert amounts to their market value on  the  report  end  date               (using the most recent applicable market price, if any)         --auto apply automated posting rules to modify transactions.         --forecast-              apply periodic transaction rules  to  generate  future  transac-+              apply  periodic  transaction  rules  to generate future transac-               tions, to 6 months from now or report end date.         When a reporting option appears more than once in the command line, the@@ -176,39 +180,41 @@               show debug output (levels 1-9, default: 1)         A @FILE argument will be expanded to the contents of FILE, which should-       contain  one  command line option/argument per line.  (To prevent this,+       contain one command line option/argument per line.  (To  prevent  this,        insert a -- argument before.)         By default, hledger-web starts the web app in "transient mode" and also        opens it in your default web browser if possible.  In this mode the web        app will keep running for as long as you have it open in a browser win--       dow,  and will exit after two minutes of inactivity (no requests and no-       browser windows viewing it).  With --serve, it just runs  the  web  app-       without exiting, and logs requests to the console.+       dow, and will exit after two minutes of inactivity (no requests and  no+       browser  windows  viewing  it).  With --serve, it just runs the web app+       without exiting, and logs requests to the console.   With  --serve-api,+       only  the  JSON  web  api  (see  below)  is served, with the usual HTML+       server-side web UI disabled. -       By  default the server listens on IP address 127.0.0.1, accessible only-       to  local  requests.   You  can  use  --host   to   change   this,   eg-       --host 0.0.0.0 to listen on all configured addresses.+       By default the server listens on IP address 127.0.0.1, accessible  only+       to  local  requests.   You  can  use  --host  to change this, eg --host+       0.0.0.0 to listen on all configured addresses. -       Similarly,  use --port to set a TCP port other than 5000, eg if you are+       Similarly, use --port to set a TCP port other than 5000, eg if you  are        running multiple hledger-web instances. -       You can use --base-url to change the protocol, hostname, port and  path+       You  can use --base-url to change the protocol, hostname, port and path        that appear in hyperlinks, useful eg for integrating hledger-web within-       a larger website.  The default is http://HOST:PORT/ using the  server's+       a  larger website.  The default is http://HOST:PORT/ using the server's        configured host address and TCP port (or http://HOST if PORT is 80). -       With  --file-url  you can set a different base url for static files, eg+       With --file-url you can set a different base url for static  files,  eg        for better caching or cookie-less serving on high performance websites.  PERMISSIONS-       By  default,  hledger-web  allows  anyone  who can reach it to view the+       By default, hledger-web allows anyone who can  reach  it  to  view  the        journal and to add new transactions, but not to change existing data.         You can restrict who can reach it by -       o setting the IP address it listens on (see --host above).  By  default-         it  listens  on  127.0.0.1,  accessible  to  all  users  on the local+       o setting  the IP address it listens on (see --host above).  By default+         it listens on  127.0.0.1,  accessible  to  all  users  on  the  local          machine.         o putting it behind an authenticating proxy, using eg apache or nginx@@ -218,51 +224,55 @@        You can restrict what the users who reach it can do, by         o using the --capabilities=CAP[,CAP..] flag when you start it, enabling-         one  or  more  of  the  following capabilities.  The default value is+         one or more of the following  capabilities.   The  default  value  is          view,add:           o view - allows viewing the journal file and all included files           o add - allows adding new transactions to the main journal file -         o manage - allows editing,  uploading  or  downloading  the  main  or+         o manage  -  allows  editing,  uploading  or  downloading the main or            included files -       o using  the  --capabilities-header=HTTPHEADER  flag  to specify a HTTP-         header from which it will read capabilities to  enable.   hledger-web-         on  Sandstorm  uses  the  X-Sandstorm-Permissions header to integrate+       o using the --capabilities-header=HTTPHEADER flag  to  specify  a  HTTP+         header  from  which it will read capabilities to enable.  hledger-web+         on Sandstorm uses the  X-Sandstorm-Permissions  header  to  integrate          with Sandstorm's permissions.  This is disabled by default.  EDITING, UPLOADING, DOWNLOADING-       If you enable the manage capability mentioned above, you'll see  a  new-       "spanner"  button  to the right of the search form.  Clicking this will-       let you edit, upload, or download the journal  file  or  any  files  it+       If  you  enable the manage capability mentioned above, you'll see a new+       "spanner" button to the right of the search form.  Clicking  this  will+       let  you  edit,  upload,  or  download the journal file or any files it        includes. -       Note,  unlike any other hledger command, in this mode you (or any visi-+       Note, unlike any other hledger command, in this mode you (or any  visi-        tor) can alter or wipe the data files. -       Normally whenever a file is changed in this way,  hledger-web  saves  a-       numbered  backup  (assuming  file permissions allow it, the disk is not-       full, etc.) hledger-web is not aware of version control  systems,  cur--       rently;  if  you  use one, you'll have to arrange to commit the changes+       Normally  whenever  a  file is changed in this way, hledger-web saves a+       numbered backup (assuming file permissions allow it, the  disk  is  not+       full,  etc.)  hledger-web is not aware of version control systems, cur-+       rently; if you use one, you'll have to arrange to  commit  the  changes        yourself (eg with a cron job or a file watcher like entr). -       Changes which would leave the journal file(s) unparseable or  non-valid-       (eg  with  failing balance assertions) are prevented.  (Probably.  This+       Changes  which would leave the journal file(s) unparseable or non-valid+       (eg with failing balance assertions) are prevented.   (Probably.   This        needs re-testing.)  RELOADING        hledger-web detects changes made to the files by other means (eg if you-       edit  it  directly,  outside  of hledger-web), and it will show the new-       data when you reload the page or navigate to a new page.  If  a  change-       makes  a  file  unparseable,  hledger-web will display an error message+       edit it directly, outside of hledger-web), and it  will  show  the  new+       data  when  you reload the page or navigate to a new page.  If a change+       makes a file unparseable, hledger-web will  display  an  error  message        until the file has been fixed. +       (Note: if you are viewing files mounted from another machine, make sure+       that both machine clocks are roughly in step.)+ JSON API-       In addition to the web UI, hledger-web provides some JSON  API  routes.-       These  are  similar to the API provided by the hledger-api tool, but it-       may be convenient to have them in hledger-web also.+       In addition to the web UI, hledger-web provides some  API  routes  that+       serve  JSON in response to GET requests.  Currently these are same ones+       provided by the hledger-api tool, but hledger-web will  likely  receive+       more attention than hledger-api in future:                /accountnames               /transactions@@ -271,6 +281,35 @@               /accounts               /accounttransactions/#AccountName +       Also,  you can append a new transaction to the journal by sending a PUT+       request to /add (hledger-web only).  As with the  web  UI's  add  form,+       hledger-web  must  be started with the add capability for this (enabled+       by default).++       The payload should be a valid hledger transaction as JSON,  similar  to+       what you get from /transactions or /accounttransactions.++       Another  way  to generate test data is with the readJsonFile/writeJson-+       File helpers in Hledger.Web.Json, which read or write any of  hledger's+       JSON-capable  types  from  or  to  a  file.  Eg here we write the first+       transaction of a sample journal:++              $ make ghci-web+              >>> :m +*Hledger.Web.Json+              >>> writeJsonFile "txn.json" (head $ jtxns samplejournal)+              >>> :q+              $ python -m json.tool <txn.json >txn.pretty.json  # optional: make human-readable++       (sample output & discussion)++       And here's how to test adding that with curl:++              $ curl -s http://127.0.0.1:5000/add -X PUT -H 'Content-Type: application/json' --data-binary @txn.pretty.json; echo++       By default, both the server-side HTML UI and the JSON API  are  served.+       Running  with  --serve-api disables the former, useful if you only want+       to serve the API.+ ENVIRONMENT        LEDGER_FILE The journal file path when not specified with -f.  Default:        ~/.hledger.journal  (on  windows,  perhaps C:/Users/USER/.hledger.jour-@@ -319,4 +358,4 @@   -hledger-web 1.14                  March 2019                    hledger-web(1)+hledger-web 1.15                  August 2019                   hledger-web(1)
embeddedfiles/hledger.1 view
@@ -1,3257 +1,3589 @@ .\"t -.TH "hledger" "1" "March 2019" "hledger 1.14" "hledger User Manuals"----.SH NAME-.PP-hledger \- a command\-line accounting tool-.SH SYNOPSIS-.PP-\f[C]hledger\ [\-f\ FILE]\ COMMAND\ [OPTIONS]\ [ARGS]\f[]-.PD 0-.P-.PD-\f[C]hledger\ [\-f\ FILE]\ ADDONCMD\ \-\-\ [OPTIONS]\ [ARGS]\f[]-.PD 0-.P-.PD-\f[C]hledger\f[]-.SH DESCRIPTION-.PP-hledger is a cross\-platform program for tracking money, time, or any-other commodity, using double\-entry accounting and a simple, editable-file format.-hledger is inspired by and largely compatible with ledger(1).-.PD 0-.P-.PD-Tested on unix, mac, windows, hledger aims to be a reliable, practical-tool for daily use.-.PP-This is hledger's command\-line interface (there are also curses and web-interfaces).-Its basic function is to read a plain text file describing financial-transactions (in accounting terms, a general journal) and print useful-reports on standard output, or export them as CSV.-hledger can also read some other file formats such as CSV files,-translating them to journal format.-Additionally, hledger lists other hledger\-* executables found in the-user's $PATH and can invoke them as subcommands.-.PP-hledger reads data from one or more files in hledger journal, timeclock,-timedot, or CSV format specified with \f[C]\-f\f[], or-\f[C]$LEDGER_FILE\f[], or \f[C]$HOME/.hledger.journal\f[] (on windows,-perhaps \f[C]C:/Users/USER/.hledger.journal\f[]).-If using \f[C]$LEDGER_FILE\f[], note this must be a real environment-variable, not a shell variable.-You can specify standard input with \f[C]\-f\-\f[].-.PP-Transactions are dated movements of money between two (or more) named-accounts, and are recorded with journal entries like this:-.IP-.nf-\f[C]-2015/10/16\ bought\ food-\ expenses:food\ \ \ \ \ \ \ \ \ \ $10-\ assets:cash-\f[]-.fi-.PP-For more about this format, see hledger_journal(5).-.PP-Most users use a text editor to edit the journal, usually with an editor-mode such as ledger\-mode for added convenience.-hledger's interactive add command is another way to record new-transactions.-hledger never changes existing transactions.-.PP-To get started, you can either save some entries like the above in-\f[C]~/.hledger.journal\f[], or run \f[C]hledger\ add\f[] and follow the-prompts.-Then try some commands like \f[C]hledger\ print\f[] or-\f[C]hledger\ balance\f[].-Run \f[C]hledger\f[] with no arguments for a list of commands.-.SH EXAMPLES-.PP-Two simple transactions in hledger journal format:-.IP-.nf-\f[C]-2015/9/30\ gift\ received-\ \ assets:cash\ \ \ $20-\ \ income:gifts--2015/10/16\ farmers\ market-\ \ expenses:food\ \ \ \ $10-\ \ assets:cash-\f[]-.fi-.PP-Some basic reports:-.IP-.nf-\f[C]-$\ hledger\ print-2015/09/30\ gift\ received-\ \ \ \ assets:cash\ \ \ \ \ \ \ \ \ \ \ \ $20-\ \ \ \ income:gifts\ \ \ \ \ \ \ \ \ \ $\-20--2015/10/16\ farmers\ market-\ \ \ \ expenses:food\ \ \ \ \ \ \ \ \ \ \ $10-\ \ \ \ assets:cash\ \ \ \ \ \ \ \ \ \ \ \ $\-10-\f[]-.fi-.IP-.nf-\f[C]-$\ hledger\ accounts\ \-\-tree-assets-\ \ cash-expenses-\ \ food-income-\ \ gifts-\f[]-.fi-.IP-.nf-\f[C]-$\ hledger\ balance-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $10\ \ assets:cash-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $10\ \ expenses:food-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-20\ \ income:gifts-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0-\f[]-.fi-.IP-.nf-\f[C]-$\ hledger\ register\ cash-2015/09/30\ gift\ received\ \ \ assets:cash\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $20\ \ \ \ \ \ \ \ \ \ \ $20-2015/10/16\ farmers\ market\ \ assets:cash\ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-10\ \ \ \ \ \ \ \ \ \ \ $10-\f[]-.fi-.PP-More commands:-.IP-.nf-\f[C]-$\ hledger\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ show\ available\ commands-$\ hledger\ add\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ add\ more\ transactions\ to\ the\ journal\ file-$\ hledger\ balance\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ all\ accounts\ with\ aggregated\ balances-$\ hledger\ balance\ \-\-help\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ show\ detailed\ help\ for\ balance\ command-$\ hledger\ balance\ \-\-depth\ 1\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ only\ top\-level\ accounts-$\ hledger\ register\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ show\ account\ postings,\ with\ running\ total-$\ hledger\ reg\ income\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ show\ postings\ to/from\ income\ accounts-$\ hledger\ reg\ \[aq]assets:some\ bank:checking\[aq]\ #\ show\ postings\ to/from\ this\ checking\ account-$\ hledger\ print\ desc:shop\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ show\ transactions\ with\ shop\ in\ the\ description-$\ hledger\ activity\ \-W\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ show\ transaction\ counts\ per\ week\ as\ a\ bar\ chart-\f[]-.fi-.SH OPTIONS-.SS General options-.PP-To see general usage help, including general options which are supported-by most hledger commands, run \f[C]hledger\ \-h\f[].-.PP-General help options:-.TP-.B \f[C]\-h\ \-\-help\f[]-show general usage (or after COMMAND, command usage)-.RS-.RE-.TP-.B \f[C]\-\-version\f[]-show version-.RS-.RE-.TP-.B \f[C]\-\-debug[=N]\f[]-show debug output (levels 1\-9, default: 1)-.RS-.RE-.PP-General input options:-.TP-.B \f[C]\-f\ FILE\ \-\-file=FILE\f[]-use a different input file.-For stdin, use \- (default: \f[C]$LEDGER_FILE\f[] or-\f[C]$HOME/.hledger.journal\f[])-.RS-.RE-.TP-.B \f[C]\-\-rules\-file=RULESFILE\f[]-Conversion rules file to use when reading CSV (default: FILE.rules)-.RS-.RE-.TP-.B \f[C]\-\-separator=CHAR\f[]-Field separator to expect when reading CSV (default: \[aq],\[aq])-.RS-.RE-.TP-.B \f[C]\-\-alias=OLD=NEW\f[]-rename accounts named OLD to NEW-.RS-.RE-.TP-.B \f[C]\-\-anon\f[]-anonymize accounts and payees-.RS-.RE-.TP-.B \f[C]\-\-pivot\ FIELDNAME\f[]-use some other field or tag for the account name-.RS-.RE-.TP-.B \f[C]\-I\ \-\-ignore\-assertions\f[]-ignore any failing balance assertions-.RS-.RE-.PP-General reporting options:-.TP-.B \f[C]\-b\ \-\-begin=DATE\f[]-include postings/txns on or after this date-.RS-.RE-.TP-.B \f[C]\-e\ \-\-end=DATE\f[]-include postings/txns before this date-.RS-.RE-.TP-.B \f[C]\-D\ \-\-daily\f[]-multiperiod/multicolumn report by day-.RS-.RE-.TP-.B \f[C]\-W\ \-\-weekly\f[]-multiperiod/multicolumn report by week-.RS-.RE-.TP-.B \f[C]\-M\ \-\-monthly\f[]-multiperiod/multicolumn report by month-.RS-.RE-.TP-.B \f[C]\-Q\ \-\-quarterly\f[]-multiperiod/multicolumn report by quarter-.RS-.RE-.TP-.B \f[C]\-Y\ \-\-yearly\f[]-multiperiod/multicolumn report by year-.RS-.RE-.TP-.B \f[C]\-p\ \-\-period=PERIODEXP\f[]-set start date, end date, and/or reporting interval all at once using-period expressions syntax (overrides the flags above)-.RS-.RE-.TP-.B \f[C]\-\-date2\f[]-match the secondary date instead (see command help for other effects)-.RS-.RE-.TP-.B \f[C]\-U\ \-\-unmarked\f[]-include only unmarked postings/txns (can combine with \-P or \-C)-.RS-.RE-.TP-.B \f[C]\-P\ \-\-pending\f[]-include only pending postings/txns-.RS-.RE-.TP-.B \f[C]\-C\ \-\-cleared\f[]-include only cleared postings/txns-.RS-.RE-.TP-.B \f[C]\-R\ \-\-real\f[]-include only non\-virtual postings-.RS-.RE-.TP-.B \f[C]\-NUM\ \-\-depth=NUM\f[]-hide/aggregate accounts or postings more than NUM levels deep-.RS-.RE-.TP-.B \f[C]\-E\ \-\-empty\f[]-show items with zero amount, normally hidden (and vice\-versa in-hledger\-ui/hledger\-web)-.RS-.RE-.TP-.B \f[C]\-B\ \-\-cost\f[]-convert amounts to their cost at transaction time (using the transaction-price, if any)-.RS-.RE-.TP-.B \f[C]\-V\ \-\-value\f[]-convert amounts to their market value on the report end date (using the-most recent applicable market price, if any)-.RS-.RE-.TP-.B \f[C]\-\-auto\f[]-apply automated posting rules to modify transactions.-.RS-.RE-.TP-.B \f[C]\-\-forecast\f[]-apply periodic transaction rules to generate future transactions, to 6-months from now or report end date.-.RS-.RE-.PP-When a reporting option appears more than once in the command line, the-last one takes precedence.-.PP-Some reporting options can also be written as query arguments.-.SS Command options-.PP-To see options for a particular command, including command\-specific-options, run: \f[C]hledger\ COMMAND\ \-h\f[].-.PP-Command\-specific options must be written after the command name, eg:-\f[C]hledger\ print\ \-x\f[].-.PP-Additionally, if the command is an addon, you may need to put its-options after a double\-hyphen, eg:-\f[C]hledger\ ui\ \-\-\ \-\-watch\f[].-Or, you can run the addon executable directly:-\f[C]hledger\-ui\ \-\-watch\f[].-.SS Command arguments-.PP-Most hledger commands accept arguments after the command name, which are-often a query, filtering the data in some way.-.SS Argument files-.PP-You can save a set of command line options/arguments in a file, one per-line, and then reuse them by writing \f[C]\@FILENAME\f[] in a command-line.-To prevent this expansion of \f[C]\@\f[]\-arguments, precede them with a-\f[C]\-\-\f[] argument.-For more, see Save frequently used options.-.SS Special characters in arguments and queries-.PP-In shell command lines, option and argument values which contain-"problematic" characters, ie spaces, and also characters significant to-your shell such as \f[C]<\f[], \f[C]>\f[], \f[C](\f[], \f[C])\f[],-\f[C]|\f[] and \f[C]$\f[], should be escaped by enclosing them in quotes-or by writing backslashes before the characters.-Eg:-.PP-\f[C]hledger\ register\ \-p\ \[aq]last\ year\[aq]\ "accounts\ receivable\ (receivable|payable)"\ amt:\\>100\f[].-.SS More escaping-.PP-Characters significant both to the shell and in regular expressions may-need one extra level of escaping.-These include parentheses, the pipe symbol and the dollar sign.-Eg, to match the dollar symbol, bash users should do:-.PP-\f[C]hledger\ balance\ cur:\[aq]\\$\[aq]\f[]-.PP-or:-.PP-\f[C]hledger\ balance\ cur:\\\\$\f[]-.SS Even more escaping-.PP-When hledger runs an addon executable (eg you type \f[C]hledger\ ui\f[],-hledger runs \f[C]hledger\-ui\f[]), it de\-escapes command\-line options-and arguments once, so you might need to \f[I]triple\f[]\-escape.-Eg in bash, running the ui command and matching the dollar sign,-it\[aq]s:-.PP-\f[C]hledger\ ui\ cur:\[aq]\\\\$\[aq]\f[]-.PP-or:-.PP-\f[C]hledger\ ui\ cur:\\\\\\\\$\f[]-.PP-If you asked why \f[I]four\f[] slashes above, this may help:-.PP-.TS-tab(@);-l l.-T{-unescaped:-T}@T{-\f[C]$\f[]-T}-T{-escaped:-T}@T{-\f[C]\\$\f[]-T}-T{-double\-escaped:-T}@T{-\f[C]\\\\$\f[]-T}-T{-triple\-escaped:-T}@T{-\f[C]\\\\\\\\$\f[]-T}-.TE-.PP-(The number of backslashes in fish shell is left as an exercise for the-reader.)-.PP-You can always avoid the extra escaping for addons by running the addon-directly:-.PP-\f[C]hledger\-ui\ cur:\\\\$\f[]-.SS Less escaping-.PP-Inside an argument file, or in the search field of hledger\-ui or-hledger\-web, or at a GHCI prompt, you need one less level of escaping-than at the command line.-And backslashes may work better than quotes.-Eg:-.PP-\f[C]ghci>\ :main\ balance\ cur:\\$\f[]-.SS Command line tips-.PP-If in doubt, keep things simple:-.IP \[bu] 2-write options after the command (\f[C]hledger\ CMD\ \-OPTIONS\ ARGS\f[])-.IP \[bu] 2-run add\-on executables directly (\f[C]hledger\-ui\ \-OPTIONS\ ARGS\f[])-.IP \[bu] 2-enclose problematic args in single quotes-.IP \[bu] 2-if needed, also add a backslash to escape regexp metacharacters-.PP-To find out exactly how a command line is being parsed, add-\f[C]\-\-debug=2\f[] to troubleshoot.-.SS Unicode characters-.PP-hledger is expected to handle unicode (non\-ascii) characters, but this-requires a well\-configured environment.-.PP-To handle unicode characters in the command line or input data, a system-locale that can decode them must be configured (POSIX\[aq]s default-\f[C]C\f[] locale will not work).-Eg in bash, you could do:-.IP-.nf-\f[C]-export\ LANG=en_US.UTF\-8-\f[]-.fi-.PP-See Troubleshooting for more about this.-.PP-Unicode characters should appear correctly in hledger\[aq]s output.-For the hledger and hledger\-ui tools, this requires that-.IP \[bu] 2-your terminal supports unicode-.IP \[bu] 2-the terminal\[aq]s font includes the required unicode glyphs-.IP \[bu] 2-the terminal is configured to display "wide" characters as double width-(otherwise report alignment will be off)-.SS Input files-.PP-hledger reads transactions from a data file (and the add command writes-to it).-By default this file is \f[C]$HOME/.hledger.journal\f[] (or on Windows,-something like \f[C]C:/Users/USER/.hledger.journal\f[]).-You can override this with the \f[C]$LEDGER_FILE\f[] environment-variable:-.IP-.nf-\f[C]-$\ setenv\ LEDGER_FILE\ ~/finance/2016.journal-$\ hledger\ stats-\f[]-.fi-.PP-or with the \f[C]\-f/\-\-file\f[] option:-.IP-.nf-\f[C]-$\ hledger\ \-f\ /some/file\ stats-\f[]-.fi-.PP-The file name \f[C]\-\f[] (hyphen) means standard input:-.IP-.nf-\f[C]-$\ cat\ some.journal\ |\ hledger\ \-f\--\f[]-.fi-.PP-Usually the data file is in hledger\[aq]s journal format, but it can-also be one of several other formats, listed below.-hledger detects the format automatically based on the file extension, or-if that is not recognised, by trying each built\-in "reader" in turn:-.PP-.TS-tab(@);-lw(10.3n) lw(33.5n) lw(26.2n).-T{-Reader:-T}@T{-Reads:-T}@T{-Used for file extensions:-T}-_-T{-\f[C]journal\f[]-T}@T{-hledger\[aq]s journal format, also some Ledger journals-T}@T{-\f[C]\&.journal\f[] \f[C]\&.j\f[] \f[C]\&.hledger\f[] \f[C]\&.ledger\f[]-T}-T{-\f[C]timeclock\f[]-T}@T{-timeclock files (precise time logging)-T}@T{-\f[C]\&.timeclock\f[]-T}-T{-\f[C]timedot\f[]-T}@T{-timedot files (approximate time logging)-T}@T{-\f[C]\&.timedot\f[]-T}-T{-\f[C]csv\f[]-T}@T{-comma\-separated values (data interchange)-T}@T{-\f[C]\&.csv\f[]-T}-.TE-.PP-If needed (eg to ensure correct error messages when a file has the-"wrong" extension), you can force a specific reader/format by prepending-it to the file path with a colon.-Examples:-.IP-.nf-\f[C]-$\ hledger\ \-f\ csv:/some/csv\-file.dat\ stats-$\ echo\ \[aq]i\ 2009/13/1\ 08:00:00\[aq]\ |\ hledger\ print\ \-ftimeclock:\--\f[]-.fi-.PP-You can also specify multiple \f[C]\-f\f[] options, to read multiple-files as one big journal.-There are some limitations with this:-.IP \[bu] 2-directives in one file will not affect the other files-.IP \[bu] 2-balance assertions will not see any account balances from previous files-.PP-If you need those, either use the include directive, or concatenate the-files, eg: \f[C]cat\ a.journal\ b.journal\ |\ hledger\ \-f\-\ CMD\f[].-.SS Smart dates-.PP-hledger\[aq]s user interfaces accept a flexible "smart date" syntax-(unlike dates in the journal file).-Smart dates allow some english words, can be relative to today\[aq]s-date, and can have less\-significant date parts omitted (defaulting to-1).-.PP-Examples:-.PP-.TS-tab(@);-l l.-T{-\f[C]2004/10/1\f[], \f[C]2004\-01\-01\f[], \f[C]2004.9.1\f[]-T}@T{-exact date, several separators allowed.-Year is 4+ digits, month is 1\-12, day is 1\-31-T}-T{-\f[C]2004\f[]-T}@T{-start of year-T}-T{-\f[C]2004/10\f[]-T}@T{-start of month-T}-T{-\f[C]10/1\f[]-T}@T{-month and day in current year-T}-T{-\f[C]21\f[]-T}@T{-day in current month-T}-T{-\f[C]october,\ oct\f[]-T}@T{-start of month in current year-T}-T{-\f[C]yesterday,\ today,\ tomorrow\f[]-T}@T{-\-1, 0, 1 days from today-T}-T{-\f[C]last/this/next\ day/week/month/quarter/year\f[]-T}@T{-\-1, 0, 1 periods from the current period-T}-T{-\f[C]20181201\f[]-T}@T{-8 digit YYYYMMDD with valid year month and day-T}-T{-\f[C]201812\f[]-T}@T{-6 digit YYYYMM with valid year and month-T}-.TE-.PP-Counterexamples \- malformed digit sequences might give surprising-results:-.PP-.TS-tab(@);-l l.-T{-\f[C]201813\f[]-T}@T{-6 digits with an invalid month is parsed as start of 6\-digit year-T}-T{-\f[C]20181301\f[]-T}@T{-8 digits with an invalid month is parsed as start of 8\-digit year-T}-T{-\f[C]20181232\f[]-T}@T{-8 digits with an invalid day gives an error-T}-T{-\f[C]201801012\f[]-T}@T{-9+ digits beginning with a valid YYYYMMDD gives an error-T}-.TE-.SS Report start & end date-.PP-Most hledger reports show the full span of time represented by the-journal data, by default.-So, the effective report start and end dates will be the earliest and-latest transaction or posting dates found in the journal.-.PP-Often you will want to see a shorter time span, such as the current-month.-You can specify a start and/or end date using \f[C]\-b/\-\-begin\f[],-\f[C]\-e/\-\-end\f[], \f[C]\-p/\-\-period\f[] or a \f[C]date:\f[] query-(described below).-All of these accept the smart date syntax.-One important thing to be aware of when specifying end dates: as in-Ledger, end dates are exclusive, so you need to write the date-\f[I]after\f[] the last day you want to include.-.PP-Examples:-.PP-.TS-tab(@);-l l.-T{-\f[C]\-b\ 2016/3/17\f[]-T}@T{-begin on St.-Patrick\[aq]s day 2016-T}-T{-\f[C]\-e\ 12/1\f[]-T}@T{-end at the start of december 1st of the current year (11/30 will be the-last date included)-T}-T{-\f[C]\-b\ thismonth\f[]-T}@T{-all transactions on or after the 1st of the current month-T}-T{-\f[C]\-p\ thismonth\f[]-T}@T{-all transactions in the current month-T}-T{-\f[C]date:2016/3/17\-\f[]-T}@T{-the above written as queries instead-T}-T{-\f[C]date:\-12/1\f[]-T}@T{-T}-T{-\f[C]date:thismonth\-\f[]-T}@T{-T}-T{-\f[C]date:thismonth\f[]-T}@T{-T}-.TE-.SS Report intervals-.PP-A report interval can be specified so that commands like register,-balance and activity will divide their reports into multiple subperiods.-The basic intervals can be selected with one of \f[C]\-D/\-\-daily\f[],-\f[C]\-W/\-\-weekly\f[], \f[C]\-M/\-\-monthly\f[],-\f[C]\-Q/\-\-quarterly\f[], or \f[C]\-Y/\-\-yearly\f[].-More complex intervals may be specified with a period expression.-Report intervals can not be specified with a query, currently.-.SS Period expressions-.PP-The \f[C]\-p/\-\-period\f[] option accepts period expressions, a-shorthand way of expressing a start date, end date, and/or report-interval all at once.-.PP-Here\[aq]s a basic period expression specifying the first quarter of-2009.-Note, hledger always treats start dates as inclusive and end dates as-exclusive:-.PP-\f[C]\-p\ "from\ 2009/1/1\ to\ 2009/4/1"\f[]-.PP-Keywords like "from" and "to" are optional, and so are the spaces, as-long as you don\[aq]t run two dates together.-"to" can also be written as "\-".-These are equivalent to the above:-.PP-.TS-tab(@);-l.-T{-\f[C]\-p\ "2009/1/1\ 2009/4/1"\f[]-T}-T{-\f[C]\-p2009/1/1to2009/4/1\f[]-T}-T{-\f[C]\-p2009/1/1\-2009/4/1\f[]-T}-.TE-.PP-Dates are smart dates, so if the current year is 2009, the above can-also be written as:-.PP-.TS-tab(@);-l.-T{-\f[C]\-p\ "1/1\ 4/1"\f[]-T}-T{-\f[C]\-p\ "january\-apr"\f[]-T}-T{-\f[C]\-p\ "this\ year\ to\ 4/1"\f[]-T}-.TE-.PP-If you specify only one date, the missing start or end date will be the-earliest or latest transaction in your journal:-.PP-.TS-tab(@);-l l.-T{-\f[C]\-p\ "from\ 2009/1/1"\f[]-T}@T{-everything after january 1, 2009-T}-T{-\f[C]\-p\ "from\ 2009/1"\f[]-T}@T{-the same-T}-T{-\f[C]\-p\ "from\ 2009"\f[]-T}@T{-the same-T}-T{-\f[C]\-p\ "to\ 2009"\f[]-T}@T{-everything before january 1, 2009-T}-.TE-.PP-A single date with no "from" or "to" defines both the start and end date-like so:-.PP-.TS-tab(@);-l l.-T{-\f[C]\-p\ "2009"\f[]-T}@T{-the year 2009; equivalent to "2009/1/1 to 2010/1/1"-T}-T{-\f[C]\-p\ "2009/1"\f[]-T}@T{-the month of jan; equivalent to "2009/1/1 to 2009/2/1"-T}-T{-\f[C]\-p\ "2009/1/1"\f[]-T}@T{-just that day; equivalent to "2009/1/1 to 2009/1/2"-T}-.TE-.PP-The argument of \f[C]\-p\f[] can also begin with, or be, a report-interval expression.-The basic report intervals are \f[C]daily\f[], \f[C]weekly\f[],-\f[C]monthly\f[], \f[C]quarterly\f[], or \f[C]yearly\f[], which have the-same effect as the \f[C]\-D\f[],\f[C]\-W\f[],\f[C]\-M\f[],\f[C]\-Q\f[],-or \f[C]\-Y\f[] flags.-Between report interval and start/end dates (if any), the word-\f[C]in\f[] is optional.-Examples:-.PP-.TS-tab(@);-l.-T{-\f[C]\-p\ "weekly\ from\ 2009/1/1\ to\ 2009/4/1"\f[]-T}-T{-\f[C]\-p\ "monthly\ in\ 2008"\f[]-T}-T{-\f[C]\-p\ "quarterly"\f[]-T}-.TE-.PP-Note that \f[C]weekly\f[], \f[C]monthly\f[], \f[C]quarterly\f[] and-\f[C]yearly\f[] intervals will always start on the first day on week,-month, quarter or year accordingly, and will end on the last day of same-period, even if associated period expression specifies different-explicit start and end date.-.PP-For example:-.PP-.TS-tab(@);-l.-T{-\f[C]\-p\ "weekly\ from\ 2009/1/1\ to\ 2009/4/1"\f[] \-\- starts on-2008/12/29, closest preceeding Monday-T}-T{-\f[C]\-p\ "monthly\ in\ 2008/11/25"\f[] \-\- starts on 2018/11/01-T}-T{-\f[C]\-p\ "quarterly\ from\ 2009\-05\-05\ to\ 2009\-06\-01"\f[] \--starts on 2009/04/01, ends on 2009/06/30, which are first and last days-of Q2 2009-T}-T{-\f[C]\-p\ "yearly\ from\ 2009\-12\-29"\f[] \- starts on 2009/01/01,-first day of 2009-T}-.TE-.PP-The following more complex report intervals are also supported:-\f[C]biweekly\f[], \f[C]bimonthly\f[],-\f[C]every\ day|week|month|quarter|year\f[],-\f[C]every\ N\ days|weeks|months|quarters|years\f[].-.PP-All of these will start on the first day of the requested period and end-on the last one, as described above.-.PP-Examples:-.PP-.TS-tab(@);-l.-T{-\f[C]\-p\ "bimonthly\ from\ 2008"\f[] \-\- periods will have boundaries-on 2008/01/01, 2008/03/01, ...-T}-T{-\f[C]\-p\ "every\ 2\ weeks"\f[] \-\- starts on closest preceeding Monday-T}-T{-\f[C]\-p\ "every\ 5\ month\ from\ 2009/03"\f[] \-\- periods will have-boundaries on 2009/03/01, 2009/08/01, ...-T}-.TE-.PP-If you want intervals that start on arbitrary day of your choosing and-span a week, month or year, you need to use any of the following:-.PP-\f[C]every\ Nth\ day\ of\ week\f[], \f[C]every\ <weekday>\f[],-\f[C]every\ Nth\ day\ [of\ month]\f[],-\f[C]every\ Nth\ weekday\ [of\ month]\f[],-\f[C]every\ MM/DD\ [of\ year]\f[], \f[C]every\ Nth\ MMM\ [of\ year]\f[],-\f[C]every\ MMM\ Nth\ [of\ year]\f[].-.PP-Examples:-.PP-.TS-tab(@);-l.-T{-\f[C]\-p\ "every\ 2nd\ day\ of\ week"\f[] \-\- periods will go from Tue-to Tue-T}-T{-\f[C]\-p\ "every\ Tue"\f[] \-\- same-T}-T{-\f[C]\-p\ "every\ 15th\ day"\f[] \-\- period boundaries will be on 15th-of each month-T}-T{-\f[C]\-p\ "every\ 2nd\ Monday"\f[] \-\- period boundaries will be on-second Monday of each month-T}-T{-\f[C]\-p\ "every\ 11/05"\f[] \-\- yearly periods with boundaries on 5th-of Nov-T}-T{-\f[C]\-p\ "every\ 5th\ Nov"\f[] \-\- same-T}-T{-\f[C]\-p\ "every\ Nov\ 5th"\f[] \-\- same-T}-.TE-.PP-Show historical balances at end of 15th each month (N is exclusive end-date):-.PP-\f[C]hledger\ balance\ \-H\ \-p\ "every\ 16th\ day"\f[]-.PP-Group postings from start of wednesday to end of next tuesday (N is-start date and exclusive end date):-.PP-\f[C]hledger\ register\ checking\ \-p\ "every\ 3rd\ day\ of\ week"\f[]-.SS Depth limiting-.PP-With the \f[C]\-\-depth\ N\f[] option (short form: \f[C]\-N\f[]),-commands like account, balance and register will show only the uppermost-accounts in the account tree, down to level N.-Use this when you want a summary with less detail.-This flag has the same effect as a \f[C]depth:\f[] query argument (so-\f[C]\-2\f[], \f[C]\-\-depth=2\f[] or \f[C]depth:2\f[] are basically-equivalent).-.SS Pivoting-.PP-Normally hledger sums amounts, and organizes them in a hierarchy, based-on account name.-The \f[C]\-\-pivot\ FIELD\f[] option causes it to sum and organize-hierarchy based on the value of some other field instead.-FIELD can be: \f[C]code\f[], \f[C]description\f[], \f[C]payee\f[],-\f[C]note\f[], or the full name (case insensitive) of any tag.-As with account names, values containing \f[C]colon:separated:parts\f[]-will be displayed hierarchically in reports.-.PP-\f[C]\-\-pivot\f[] is a general option affecting all reports; you can-think of hledger transforming the journal before any other processing,-replacing every posting\[aq]s account name with the value of the-specified field on that posting, inheriting it from the transaction or-using a blank value if it\[aq]s not present.-.PP-An example:-.IP-.nf-\f[C]-2016/02/16\ Member\ Fee\ Payment-\ \ \ \ assets:bank\ account\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 2\ EUR-\ \ \ \ income:member\ fees\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \-2\ EUR\ \ ;\ member:\ John\ Doe-\f[]-.fi-.PP-Normal balance report showing account names:-.IP-.nf-\f[C]-$\ hledger\ balance-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 2\ EUR\ \ assets:bank\ account-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \-2\ EUR\ \ income:member\ fees-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0-\f[]-.fi-.PP-Pivoted balance report, using member: tag values instead:-.IP-.nf-\f[C]-$\ hledger\ balance\ \-\-pivot\ member-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 2\ EUR-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \-2\ EUR\ \ John\ Doe-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0-\f[]-.fi-.PP-One way to show only amounts with a member: value (using a query,-described below):-.IP-.nf-\f[C]-$\ hledger\ balance\ \-\-pivot\ member\ tag:member=.-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \-2\ EUR\ \ John\ Doe-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \-2\ EUR-\f[]-.fi-.PP-Another way (the acct: query matches against the pivoted "account-name"):-.IP-.nf-\f[C]-$\ hledger\ balance\ \-\-pivot\ member\ acct:.-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \-2\ EUR\ \ John\ Doe-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \-2\ EUR-\f[]-.fi-.SS Cost-.PP-The \f[C]\-B/\-\-cost\f[] flag converts amounts to their cost at-transaction time, if they have a transaction price specified.-.SS Market value-.PP-The \f[C]\-V/\-\-value\f[] flag converts reported amounts to their-current market value.-.PD 0-.P-.PD-Specifically, when there is a market price (P directive) for the-amount\[aq]s commodity, dated on or before today\[aq]s date (or the-report end date if specified), the amount will be converted to the-price\[aq]s commodity.-.PP-When there are multiple applicable P directives, \-V chooses the most-recent one, or in case of equal dates, the last\-parsed one.-.PP-For example:-.IP-.nf-\f[C]-#\ one\ euro\ is\ worth\ this\ many\ dollars\ from\ nov\ 1-P\ 2016/11/01\ €\ $1.10--#\ purchase\ some\ euros\ on\ nov\ 3-2016/11/3-\ \ \ \ assets:euros\ \ \ \ \ \ \ \ €100-\ \ \ \ assets:checking--#\ the\ euro\ is\ worth\ fewer\ dollars\ by\ dec\ 21-P\ 2016/12/21\ €\ $1.03-\f[]-.fi-.PP-How many euros do I have ?-.IP-.nf-\f[C]-$\ hledger\ \-f\ t.j\ bal\ \-N\ euros-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ €100\ \ assets:euros-\f[]-.fi-.PP-What are they worth at end of nov 3 ?-.IP-.nf-\f[C]-$\ hledger\ \-f\ t.j\ bal\ \-N\ euros\ \-V\ \-e\ 2016/11/4-\ \ \ \ \ \ \ \ \ \ \ \ \ $110.00\ \ assets:euros-\f[]-.fi-.PP-What are they worth after 2016/12/21 ?-(no report end date specified, defaults to today)-.IP-.nf-\f[C]-$\ hledger\ \-f\ t.j\ bal\ \-N\ euros\ \-V-\ \ \ \ \ \ \ \ \ \ \ \ \ $103.00\ \ assets:euros-\f[]-.fi-.PP-Currently, hledger\[aq]s \-V only uses market prices recorded with P-directives, not transaction prices (unlike Ledger).-.PP-Currently, \-V has a limitation in multicolumn balance reports: it uses-the market prices on the report end date for all columns.-(Instead of the prices on each column\[aq]s end date.)-.SS Combining \-B and \-V-.PP-Using \-B/\-\-cost and \-V/\-\-value together is currently allowed, but-the results are probably not meaningful.-Let us know if you find a use for this.-.SS Output destination-.PP-Some commands (print, register, stats, the balance commands) can write-their output to a destination other than the console.-This is controlled by the \f[C]\-o/\-\-output\-file\f[] option.-.IP-.nf-\f[C]-$\ hledger\ balance\ \-o\ \-\ \ \ \ \ #\ write\ to\ stdout\ (the\ default)-$\ hledger\ balance\ \-o\ FILE\ \ #\ write\ to\ FILE-\f[]-.fi-.SS Output format-.PP-Some commands can write their output in other formats.-Eg print and register can output CSV, and the balance commands can-output CSV or HTML.-This is controlled by the \f[C]\-O/\-\-output\-format\f[] option, or by-specifying a \f[C]\&.csv\f[] or \f[C]\&.html\f[] file extension with-\f[C]\-o/\-\-output\-file\f[].-.IP-.nf-\f[C]-$\ hledger\ balance\ \-O\ csv\ \ \ \ \ \ \ #\ write\ CSV\ to\ stdout-$\ hledger\ balance\ \-o\ FILE.csv\ \ #\ write\ CSV\ to\ FILE.csv-\f[]-.fi-.SS Regular expressions-.PP-hledger uses regular expressions in a number of places:-.IP \[bu] 2-query terms, on the command line and in the hledger\-web search form:-\f[C]REGEX\f[], \f[C]desc:REGEX\f[], \f[C]cur:REGEX\f[],-\f[C]tag:...=REGEX\f[]-.IP \[bu] 2-CSV rules conditional blocks: \f[C]if\ REGEX\ ...\f[]-.IP \[bu] 2-account alias directives and options:-\f[C]alias\ /REGEX/\ =\ REPLACEMENT\f[],-\f[C]\-\-alias\ /REGEX/=REPLACEMENT\f[]-.PP-hledger\[aq]s regular expressions come from the regex\-tdfa library.-In general they:-.IP \[bu] 2-are case insensitive-.IP \[bu] 2-are infix matching (do not need to match the entire thing being matched)-.IP \[bu] 2-are POSIX extended regular expressions-.IP \[bu] 2-also support GNU word boundaries (\\<, \\>, \\b, \\B)-.IP \[bu] 2-and parenthesised capturing groups and numeric backreferences in-replacement strings-.IP \[bu] 2-do not support mode modifiers like (?s)-.PP-Some things to note:-.IP \[bu] 2-In the \f[C]alias\f[] directive and \f[C]\-\-alias\f[] option, regular-expressions must be enclosed in forward slashes (\f[C]/REGEX/\f[]).-Elsewhere in hledger, these are not required.-.IP \[bu] 2-In queries, to match a regular expression metacharacter like \f[C]$\f[]-as a literal character, prepend a backslash.-Eg to search for amounts with the dollar sign in hledger\-web, write-\f[C]cur:\\$\f[].-.IP \[bu] 2-On the command line, some metacharacters like \f[C]$\f[] have a special-meaning to the shell and so must be escaped at least once more.-See Special characters.-.SH QUERIES-.PP-One of hledger\[aq]s strengths is being able to quickly report on-precise subsets of your data.-Most commands accept an optional query expression, written as arguments-after the command name, to filter the data by date, account name or-other criteria.-The syntax is similar to a web search: one or more space\-separated-search terms, quotes to enclose whitespace, prefixes to match specific-fields, a not: prefix to negate the match.-.PP-We do not yet support arbitrary boolean combinations of search terms;-instead most commands show transactions/postings/accounts which match-(or negatively match):-.IP \[bu] 2-any of the description terms AND-.IP \[bu] 2-any of the account terms AND-.IP \[bu] 2-any of the status terms AND-.IP \[bu] 2-all the other terms.-.PP-The print command instead shows transactions which:-.IP \[bu] 2-match any of the description terms AND-.IP \[bu] 2-have any postings matching any of the positive account terms AND-.IP \[bu] 2-have no postings matching any of the negative account terms AND-.IP \[bu] 2-match all the other terms.-.PP-The following kinds of search terms can be used.-Remember these can also be prefixed with \f[B]\f[BC]not:\f[B]\f[], eg to-exclude a particular subaccount.-.TP-.B \f[B]\f[BC]REGEX\f[B], \f[BC]acct:REGEX\f[B]\f[]-match account names by this regular expression.-(With no prefix, \f[C]acct:\f[] is assumed.)-.RS-.RE-same as above-.RS-.RE-.TP-.B \f[B]\f[BC]amt:N,\ amt:<N,\ amt:<=N,\ amt:>N,\ amt:>=N\f[B]\f[]-match postings with a single\-commodity amount that is equal to, less-than, or greater than N.-(Multi\-commodity amounts are not tested, and will always match.) The-comparison has two modes: if N is preceded by a + or \- sign (or is 0),-the two signed numbers are compared.-Otherwise, the absolute magnitudes are compared, ignoring sign.-.RS-.RE-.TP-.B \f[B]\f[BC]code:REGEX\f[B]\f[]-match by transaction code (eg check number)-.RS-.RE-.TP-.B \f[B]\f[BC]cur:REGEX\f[B]\f[]-match postings or transactions including any amounts whose-currency/commodity symbol is fully matched by REGEX.-(For a partial match, use \f[C]\&.*REGEX.*\f[]).-Note, to match characters which are regex\-significant, like the dollar-sign (\f[C]$\f[]), you need to prepend \f[C]\\\f[].-And when using the command line you need to add one more level of-quoting to hide it from the shell, so eg do:-\f[C]hledger\ print\ cur:\[aq]\\$\[aq]\f[] or-\f[C]hledger\ print\ cur:\\\\$\f[].-.RS-.RE-.TP-.B \f[B]\f[BC]desc:REGEX\f[B]\f[]-match transaction descriptions.-.RS-.RE-.TP-.B \f[B]\f[BC]date:PERIODEXPR\f[B]\f[]-match dates within the specified period.-PERIODEXPR is a period expression (with no report interval).-Examples: \f[C]date:2016\f[], \f[C]date:thismonth\f[],-\f[C]date:2000/2/1\-2/15\f[], \f[C]date:lastweek\-\f[].-If the \f[C]\-\-date2\f[] command line flag is present, this matches-secondary dates instead.-.RS-.RE-.TP-.B \f[B]\f[BC]date2:PERIODEXPR\f[B]\f[]-match secondary dates within the specified period.-.RS-.RE-.TP-.B \f[B]\f[BC]depth:N\f[B]\f[]-match (or display, depending on command) accounts at or above this depth-.RS-.RE-.TP-.B \f[B]\f[BC]note:REGEX\f[B]\f[]-match transaction notes (part of description right of \f[C]|\f[], or-whole description when there\[aq]s no \f[C]|\f[])-.RS-.RE-.TP-.B \f[B]\f[BC]payee:REGEX\f[B]\f[]-match transaction payee/payer names (part of description left of-\f[C]|\f[], or whole description when there\[aq]s no \f[C]|\f[])-.RS-.RE-.TP-.B \f[B]\f[BC]real:,\ real:0\f[B]\f[]-match real or virtual postings respectively-.RS-.RE-.TP-.B \f[B]\f[BC]status:,\ status:!,\ status:*\f[B]\f[]-match unmarked, pending, or cleared transactions respectively-.RS-.RE-.TP-.B \f[B]\f[BC]tag:REGEX[=REGEX]\f[B]\f[]-match by tag name, and optionally also by tag value.-Note a tag: query is considered to match a transaction if it matches any-of the postings.-Also remember that postings inherit the tags of their parent-transaction.-.RS-.RE-.PP-The following special search term is used automatically in hledger\-web,-only:-.TP-.B \f[B]\f[BC]inacct:ACCTNAME\f[B]\f[]-tells hledger\-web to show the transaction register for this account.-Can be filtered further with \f[C]acct\f[] etc.-.RS-.RE-.PP-Some of these can also be expressed as command\-line options (eg-\f[C]depth:2\f[] is equivalent to \f[C]\-\-depth\ 2\f[]).-Generally you can mix options and query arguments, and the resulting-query will be their intersection (perhaps excluding the-\f[C]\-p/\-\-period\f[] option).-.SH COMMANDS-.PP-hledger provides a number of subcommands; \f[C]hledger\f[] with no-arguments shows a list.-.PP-If you install additional \f[C]hledger\-*\f[] packages, or if you put-programs or scripts named \f[C]hledger\-NAME\f[] in your PATH, these-will also be listed as subcommands.-.PP-Run a subcommand by writing its name as first argument (eg-\f[C]hledger\ incomestatement\f[]).-You can also write one of the standard short aliases displayed in-parentheses in the command list (\f[C]hledger\ b\f[]), or any any-unambiguous prefix of a command name (\f[C]hledger\ inc\f[]).-.PP-Here are all the builtin commands in alphabetical order.-See also \f[C]hledger\f[] for a more organised command list, and-\f[C]hledger\ CMD\ \-h\f[] for detailed command help.-.SS accounts-.PP-accounts, a-.PD 0-.P-.PD-Show account names.-.PP-This command lists account names, either declared with account-directives (\-\-declared), posted to (\-\-used), or both (the default).-With query arguments, only matched account names and account names-referenced by matched postings are shown.-It shows a flat list by default.-With \f[C]\-\-tree\f[], it uses indentation to show the account-hierarchy.-In flat mode you can add \f[C]\-\-drop\ N\f[] to omit the first few-account name components.-Account names can be depth\-clipped with \f[C]depth:N\f[] or-\f[C]\-\-depth\ N\f[] or \f[C]\-N\f[].-.PP-Examples:-.IP-.nf-\f[C]-$\ hledger\ accounts-assets:bank:checking-assets:bank:saving-assets:cash-expenses:food-expenses:supplies-income:gifts-income:salary-liabilities:debts-\f[]-.fi-.SS activity-.PP-activity-.PD 0-.P-.PD-Show an ascii barchart of posting counts per interval.-.PP-The activity command displays an ascii histogram showing transaction-counts by day, week, month or other reporting interval (by day is the-default).-With query arguments, it counts only matched transactions.-.PP-Examples:-.IP-.nf-\f[C]-$\ hledger\ activity\ \-\-quarterly-2008\-01\-01\ **-2008\-04\-01\ *******-2008\-07\-01\ -2008\-10\-01\ **-\f[]-.fi-.SS add-.PP-add-.PD 0-.P-.PD-Prompt for transactions and add them to the journal.-.PP-Many hledger users edit their journals directly with a text editor, or-generate them from CSV.-For more interactive data entry, there is the \f[C]add\f[] command,-which prompts interactively on the console for new transactions, and-appends them to the journal file (if there are multiple-\f[C]\-f\ FILE\f[] options, the first file is used.) Existing-transactions are not changed.-This is the only hledger command that writes to the journal file.-.PP-To use it, just run \f[C]hledger\ add\f[] and follow the prompts.-You can add as many transactions as you like; when you are finished,-enter \f[C]\&.\f[] or press control\-d or control\-c to exit.-.PP-Features:-.IP \[bu] 2-add tries to provide useful defaults, using the most similar (by-description) recent transaction (filtered by the query, if any) as a-template.-.IP \[bu] 2-You can also set the initial defaults with command line arguments.-.IP \[bu] 2-Readline\-style edit keys can be used during data entry.-.IP \[bu] 2-The tab key will auto\-complete whenever possible \- accounts,-descriptions, dates (\f[C]yesterday\f[], \f[C]today\f[],-\f[C]tomorrow\f[]).-If the input area is empty, it will insert the default value.-.IP \[bu] 2-If the journal defines a default commodity, it will be added to any bare-numbers entered.-.IP \[bu] 2-A parenthesised transaction code may be entered following a date.-.IP \[bu] 2-Comments and tags may be entered following a description or amount.-.IP \[bu] 2-If you make a mistake, enter \f[C]<\f[] at any prompt to restart the-transaction.-.IP \[bu] 2-Input prompts are displayed in a different colour when the terminal-supports it.-.PP-Example (see the tutorial for a detailed explanation):-.IP-.nf-\f[C]-$\ hledger\ add-Adding\ transactions\ to\ journal\ file\ /src/hledger/examples/sample.journal-Any\ command\ line\ arguments\ will\ be\ used\ as\ defaults.-Use\ tab\ key\ to\ complete,\ readline\ keys\ to\ edit,\ enter\ to\ accept\ defaults.-An\ optional\ (CODE)\ may\ follow\ transaction\ dates.-An\ optional\ ;\ COMMENT\ may\ follow\ descriptions\ or\ amounts.-If\ you\ make\ a\ mistake,\ enter\ <\ at\ any\ prompt\ to\ restart\ the\ transaction.-To\ end\ a\ transaction,\ enter\ .\ when\ prompted.-To\ quit,\ enter\ .\ at\ a\ date\ prompt\ or\ press\ control\-d\ or\ control\-c.-Date\ [2015/05/22]:\ -Description:\ supermarket-Account\ 1:\ expenses:food-Amount\ \ 1:\ $10-Account\ 2:\ assets:checking-Amount\ \ 2\ [$\-10.0]:\ -Account\ 3\ (or\ .\ or\ enter\ to\ finish\ this\ transaction):\ .-2015/05/22\ supermarket-\ \ \ \ expenses:food\ \ \ \ \ \ \ \ \ \ \ \ \ $10-\ \ \ \ assets:checking\ \ \ \ \ \ \ \ $\-10.0--Save\ this\ transaction\ to\ the\ journal\ ?\ [y]:\ -Saved.-Starting\ the\ next\ transaction\ (.\ or\ ctrl\-D/ctrl\-C\ to\ quit)-Date\ [2015/05/22]:\ <CTRL\-D>\ $-\f[]-.fi-.SS balance-.PP-balance, bal, b-.PD 0-.P-.PD-Show accounts and their balances.-.PP-The balance command is hledger\[aq]s most versatile command.-Note, despite the name, it is not always used for showing real\-world-account balances; the more accounting\-aware balancesheet and-incomestatement may be more convenient for that.-.PP-By default, it displays all accounts, and each account\[aq]s change in-balance during the entire period of the journal.-Balance changes are calculated by adding up the postings in each-account.-You can limit the postings matched, by a query, to see fewer accounts,-changes over a different time period, changes from only cleared-transactions, etc.-.PP-If you include an account\[aq]s complete history of postings in the-report, the balance change is equivalent to the account\[aq]s current-ending balance.-For a real\-world account, typically you won\[aq]t have all transactions-in the journal; instead you\[aq]ll have all transactions after a certain-date, and an "opening balances" transaction setting the correct starting-balance on that date.-Then the balance command will show real\-world account balances.-In some cases the \-H/\-\-historical flag is used to ensure this (more-below).-.PP-The balance command can produce several styles of report:-.SS Classic balance report-.PP-This is the original balance report, as found in Ledger.-It usually looks like this:-.IP-.nf-\f[C]-$\ hledger\ balance-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1\ \ assets-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ \ \ bank:saving-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-2\ \ \ \ cash-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $2\ \ expenses-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ \ \ food-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ \ \ supplies-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-2\ \ income-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1\ \ \ \ gifts-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1\ \ \ \ salary-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ liabilities:debts-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0-\f[]-.fi-.PP-By default, accounts are displayed hierarchically, with subaccounts-indented below their parent.-At each level of the tree, accounts are sorted by account code if any,-then by account name.-Or with \f[C]\-S/\-\-sort\-amount\f[], by their balance amount.-.PP-"Boring" accounts, which contain a single interesting subaccount and no-balance of their own, are elided into the following line for more-compact output.-(Eg above, the "liabilities" account.) Use \f[C]\-\-no\-elide\f[] to-prevent this.-.PP-Account balances are "inclusive" \- they include the balances of any-subaccounts.-.PP-Accounts which have zero balance (and no non\-zero subaccounts) are-omitted.-Use \f[C]\-E/\-\-empty\f[] to show them.-.PP-A final total is displayed by default; use \f[C]\-N/\-\-no\-total\f[] to-suppress it, eg:-.IP-.nf-\f[C]-$\ hledger\ balance\ \-p\ 2008/6\ expenses\ \-\-no\-total-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $2\ \ expenses-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ \ \ food-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ \ \ supplies-\f[]-.fi-.SS Customising the classic balance report-.PP-You can customise the layout of classic balance reports with-\f[C]\-\-format\ FMT\f[]:-.IP-.nf-\f[C]-$\ hledger\ balance\ \-\-format\ "%20(account)\ %12(total)"-\ \ \ \ \ \ \ \ \ \ \ \ \ \ assets\ \ \ \ \ \ \ \ \ \ $\-1-\ \ \ \ \ \ \ \ \ bank:saving\ \ \ \ \ \ \ \ \ \ \ $1-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ cash\ \ \ \ \ \ \ \ \ \ $\-2-\ \ \ \ \ \ \ \ \ \ \ \ expenses\ \ \ \ \ \ \ \ \ \ \ $2-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ food\ \ \ \ \ \ \ \ \ \ \ $1-\ \ \ \ \ \ \ \ \ \ \ \ supplies\ \ \ \ \ \ \ \ \ \ \ $1-\ \ \ \ \ \ \ \ \ \ \ \ \ \ income\ \ \ \ \ \ \ \ \ \ $\-2-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ gifts\ \ \ \ \ \ \ \ \ \ $\-1-\ \ \ \ \ \ \ \ \ \ \ \ \ \ salary\ \ \ \ \ \ \ \ \ \ $\-1-\ \ \ liabilities:debts\ \ \ \ \ \ \ \ \ \ \ $1-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0-\f[]-.fi-.PP-The FMT format string (plus a newline) specifies the formatting applied-to each account/balance pair.-It may contain any suitable text, with data fields interpolated like so:-.PP-\f[C]%[MIN][.MAX](FIELDNAME)\f[]-.IP \[bu] 2-MIN pads with spaces to at least this width (optional)-.IP \[bu] 2-MAX truncates at this width (optional)-.IP \[bu] 2-FIELDNAME must be enclosed in parentheses, and can be one of:-.RS 2-.IP \[bu] 2-\f[C]depth_spacer\f[] \- a number of spaces equal to the account\[aq]s-depth, or if MIN is specified, MIN * depth spaces.-.IP \[bu] 2-\f[C]account\f[] \- the account\[aq]s name-.IP \[bu] 2-\f[C]total\f[] \- the account\[aq]s balance/posted total, right-justified-.RE-.PP-Also, FMT can begin with an optional prefix to control how-multi\-commodity amounts are rendered:-.IP \[bu] 2-\f[C]%_\f[] \- render on multiple lines, bottom\-aligned (the default)-.IP \[bu] 2-\f[C]%^\f[] \- render on multiple lines, top\-aligned-.IP \[bu] 2-\f[C]%,\f[] \- render on one line, comma\-separated-.PP-There are some quirks.-Eg in one\-line mode, \f[C]%(depth_spacer)\f[] has no effect, instead-\f[C]%(account)\f[] has indentation built in.- Experimentation may be needed to get pleasing results.-.PP-Some example formats:-.IP \[bu] 2-\f[C]%(total)\f[] \- the account\[aq]s total-.IP \[bu] 2-\f[C]%\-20.20(account)\f[] \- the account\[aq]s name, left justified,-padded to 20 characters and clipped at 20 characters-.IP \[bu] 2-\f[C]%,%\-50(account)\ \ %25(total)\f[] \- account name padded to 50-characters, total padded to 20 characters, with multiple commodities-rendered on one line-.IP \[bu] 2-\f[C]%20(total)\ \ %2(depth_spacer)%\-(account)\f[] \- the default-format for the single\-column balance report-.SS Colour support-.PP-The balance command shows negative amounts in red, if:-.IP \[bu] 2-the \f[C]TERM\f[] environment variable is not set to \f[C]dumb\f[]-.IP \[bu] 2-the output is not being redirected or piped anywhere-.SS Flat mode-.PP-To see a flat list instead of the default hierarchical display, use-\f[C]\-\-flat\f[].-In this mode, accounts (unless depth\-clipped) show their full names and-"exclusive" balance, excluding any subaccount balances.-In this mode, you can also use \f[C]\-\-drop\ N\f[] to omit the first-few account name components.-.IP-.nf-\f[C]-$\ hledger\ balance\ \-p\ 2008/6\ expenses\ \-N\ \-\-flat\ \-\-drop\ 1-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ food-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ supplies-\f[]-.fi-.SS Depth limited balance reports-.PP-With \f[C]\-\-depth\ N\f[] or \f[C]depth:N\f[] or just \f[C]\-N\f[],-balance reports show accounts only to the specified numeric depth.-This is very useful to summarise a complex set of accounts and get an-overview.-.IP-.nf-\f[C]-$\ hledger\ balance\ \-N\ \-1-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1\ \ assets-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $2\ \ expenses-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-2\ \ income-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ liabilities-\f[]-.fi-.PP-Flat\-mode balance reports, which normally show exclusive balances, show-inclusive balances at the depth limit.-.SS Multicolumn balance report-.PP-Multicolumn or tabular balance reports are a very useful hledger-feature, and usually the preferred style.-They share many of the above features, but they show the report as a-table, with columns representing time periods.-This mode is activated by providing a reporting interval.-.PP-There are three types of multicolumn balance report, showing different-information:-.IP "1." 3-By default: each column shows the sum of postings in that period, ie the-account\[aq]s change of balance in that period.-This is useful eg for a monthly income statement:-.RS 4-.IP-.nf-\f[C]-$\ hledger\ balance\ \-\-quarterly\ income\ expenses\ \-E-Balance\ changes\ in\ 2008:--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ 2008q1\ \ 2008q2\ \ 2008q3\ \ 2008q4\ -===================++=================================-\ expenses:food\ \ \ \ \ ||\ \ \ \ \ \ \ 0\ \ \ \ \ \ $1\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ -\ expenses:supplies\ ||\ \ \ \ \ \ \ 0\ \ \ \ \ \ $1\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ -\ income:gifts\ \ \ \ \ \ ||\ \ \ \ \ \ \ 0\ \ \ \ \ $\-1\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ -\ income:salary\ \ \ \ \ ||\ \ \ \ \ $\-1\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ $\-1\ \ \ \ \ \ $1\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ -\f[]-.fi-.RE-.IP "2." 3-With \f[C]\-\-cumulative\f[]: each column shows the ending balance for-that period, accumulating the changes across periods, starting from 0 at-the report start date:-.RS 4-.IP-.nf-\f[C]-$\ hledger\ balance\ \-\-quarterly\ income\ expenses\ \-E\ \-\-cumulative-Ending\ balances\ (cumulative)\ in\ 2008:--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ 2008/03/31\ \ 2008/06/30\ \ 2008/09/30\ \ 2008/12/31\ -===================++=================================================-\ expenses:food\ \ \ \ \ ||\ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ $1\ \ \ \ \ \ \ \ \ \ $1\ \ \ \ \ \ \ \ \ \ $1\ -\ expenses:supplies\ ||\ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ $1\ \ \ \ \ \ \ \ \ \ $1\ \ \ \ \ \ \ \ \ \ $1\ -\ income:gifts\ \ \ \ \ \ ||\ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ $\-1\ -\ income:salary\ \ \ \ \ ||\ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ $\-1\ -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ \ 0\ -\f[]-.fi-.RE-.IP "3." 3-With \f[C]\-\-historical/\-H\f[]: each column shows the actual-historical ending balance for that period, accumulating the changes-across periods, starting from the actual balance at the report start-date.-This is useful eg for a multi\-period balance sheet, and when you are-showing only the data after a certain start date:-.RS 4-.IP-.nf-\f[C]-$\ hledger\ balance\ ^assets\ ^liabilities\ \-\-quarterly\ \-\-historical\ \-\-begin\ 2008/4/1-Ending\ balances\ (historical)\ in\ 2008/04/01\-2008/12/31:--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ 2008/06/30\ \ 2008/09/30\ \ 2008/12/31\ -======================++=====================================-\ assets:bank:checking\ ||\ \ \ \ \ \ \ \ \ \ $1\ \ \ \ \ \ \ \ \ \ $1\ \ \ \ \ \ \ \ \ \ \ 0\ -\ assets:bank:saving\ \ \ ||\ \ \ \ \ \ \ \ \ \ $1\ \ \ \ \ \ \ \ \ \ $1\ \ \ \ \ \ \ \ \ \ $1\ -\ assets:cash\ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ \ \ \ \ $\-2\ \ \ \ \ \ \ \ \ $\-2\ \ \ \ \ \ \ \ \ $\-2\ -\ liabilities:debts\ \ \ \ ||\ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ $1\ -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ \ 0\ -\f[]-.fi-.RE-.PP-Multicolumn balance reports display accounts in flat mode by default; to-see the hierarchy, use \f[C]\-\-tree\f[].-.PP-With a reporting interval (like \f[C]\-\-quarterly\f[] above), the-report start/end dates will be adjusted if necessary so that they-encompass the displayed report periods.-This is so that the first and last periods will be "full" and comparable-to the others.-.PP-The \f[C]\-E/\-\-empty\f[] flag does two things in multicolumn balance-reports: first, the report will show all columns within the specified-report period (without \-E, leading and trailing columns with all zeroes-are not shown).-Second, all accounts which existed at the report start date will be-considered, not just the ones with activity during the report period-(use \-E to include low\-activity accounts which would otherwise would-be omitted).-.PP-The \f[C]\-T/\-\-row\-total\f[] flag adds an additional column showing-the total for each row.-.PP-The \f[C]\-A/\-\-average\f[] flag adds a column showing the average-value in each row.-.PP-Here\[aq]s an example of all three:-.IP-.nf-\f[C]-$\ hledger\ balance\ \-Q\ income\ expenses\ \-\-tree\ \-ETA-Balance\ changes\ in\ 2008:--\ \ \ \ \ \ \ \ \ \ \ \ ||\ \ 2008q1\ \ 2008q2\ \ 2008q3\ \ 2008q4\ \ \ \ Total\ \ Average\ -============++===================================================-\ expenses\ \ \ ||\ \ \ \ \ \ \ 0\ \ \ \ \ \ $2\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ $2\ \ \ \ \ \ \ $1\ -\ \ \ food\ \ \ \ \ ||\ \ \ \ \ \ \ 0\ \ \ \ \ \ $1\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ $1\ \ \ \ \ \ \ \ 0\ -\ \ \ supplies\ ||\ \ \ \ \ \ \ 0\ \ \ \ \ \ $1\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ $1\ \ \ \ \ \ \ \ 0\ -\ income\ \ \ \ \ ||\ \ \ \ \ $\-1\ \ \ \ \ $\-1\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ \ \ \ \ \ $\-2\ \ \ \ \ \ $\-1\ -\ \ \ gifts\ \ \ \ ||\ \ \ \ \ \ \ 0\ \ \ \ \ $\-1\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ 0\ -\ \ \ salary\ \ \ ||\ \ \ \ \ $\-1\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ 0\ -\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ $\-1\ \ \ \ \ \ $1\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ 0\ --#\ Average\ is\ rounded\ to\ the\ dollar\ here\ since\ all\ journal\ amounts\ are-\f[]-.fi-.PP-Limitations:-.PP-In multicolumn reports the \f[C]\-V/\-\-value\f[] flag uses the market-price on the report end date, for all columns (not the price on each-column\[aq]s end date).-.PP-Eliding of boring parent accounts in tree mode, as in the classic-balance report, is not yet supported in multicolumn reports.-.SS Budget report-.PP-With \f[C]\-\-budget\f[], extra columns are displayed showing budget-goals for each account and period, if any.-Budget goals are defined by periodic transactions.-This is very useful for comparing planned and actual income, expenses,-time usage, etc.-\-\-budget is most often combined with a report interval.-.PP-For example, you can take average monthly expenses in the common expense-categories to construct a minimal monthly budget:-.IP-.nf-\f[C]-;;\ Budget-~\ monthly-\ \ income\ \ $2000-\ \ expenses:food\ \ \ \ $400-\ \ expenses:bus\ \ \ \ \ $50-\ \ expenses:movies\ \ $30-\ \ assets:bank:checking--;;\ Two\ months\ worth\ of\ expenses-2017\-11\-01-\ \ income\ \ $1950-\ \ expenses:food\ \ \ \ $396-\ \ expenses:bus\ \ \ \ \ $49-\ \ expenses:movies\ \ $30-\ \ expenses:supplies\ \ $20-\ \ assets:bank:checking--2017\-12\-01-\ \ income\ \ $2100-\ \ expenses:food\ \ \ \ $412-\ \ expenses:bus\ \ \ \ \ $53-\ \ expenses:gifts\ \ \ $100-\ \ assets:bank:checking-\f[]-.fi-.PP-You can now see a monthly budget report:-.IP-.nf-\f[C]-$\ hledger\ balance\ \-M\ \-\-budget-Budget\ performance\ in\ 2017/11/01\-2017/12/31:--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Nov\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Dec\ -======================++====================================================-\ assets\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ $\-2445\ [\ \ 99%\ of\ $\-2480]\ \ $\-2665\ [\ 107%\ of\ $\-2480]\ -\ assets:bank\ \ \ \ \ \ \ \ \ \ ||\ $\-2445\ [\ \ 99%\ of\ $\-2480]\ \ $\-2665\ [\ 107%\ of\ $\-2480]\ -\ assets:bank:checking\ ||\ $\-2445\ [\ \ 99%\ of\ $\-2480]\ \ $\-2665\ [\ 107%\ of\ $\-2480]\ -\ expenses\ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ $495\ [\ 103%\ of\ \ \ $480]\ \ \ \ $565\ [\ 118%\ of\ \ \ $480]\ -\ expenses:bus\ \ \ \ \ \ \ \ \ ||\ \ \ \ $49\ [\ \ 98%\ of\ \ \ \ $50]\ \ \ \ \ $53\ [\ 106%\ of\ \ \ \ $50]\ -\ expenses:food\ \ \ \ \ \ \ \ ||\ \ \ $396\ [\ \ 99%\ of\ \ \ $400]\ \ \ \ $412\ [\ 103%\ of\ \ \ $400]\ -\ expenses:movies\ \ \ \ \ \ ||\ \ \ \ $30\ [\ 100%\ of\ \ \ \ $30]\ \ \ \ \ \ \ 0\ [\ \ \ 0%\ of\ \ \ \ $30]\ -\ income\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ $1950\ [\ \ 98%\ of\ \ $2000]\ \ \ $2100\ [\ 105%\ of\ \ $2000]\ -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ \ 0\ [\ \ \ \ \ \ \ \ \ \ \ \ \ \ 0]\ \ \ \ \ \ \ 0\ [\ \ \ \ \ \ \ \ \ \ \ \ \ \ 0]\ -\f[]-.fi-.PP-Note this is different from a normal balance report in several ways:-.IP \[bu] 2-Only accounts with budget goals during the report period are shown, by-default.-.IP \[bu] 2-In each column, in square brackets after the actual amount, budgeted-amounts are shown, along with the percentage of budget used.-.IP \[bu] 2-All parent accounts are always shown, even in flat mode.-Eg assets, assets:bank, and expenses above.-.IP \[bu] 2-Amounts always include all subaccounts, budgeted or unbudgeted, even in-flat mode.-.PP-This means that the numbers displayed will not always add up! Eg above,-the \f[C]expenses\f[] actual amount includes the gifts and supplies-transactions, but the \f[C]expenses:gifts\f[] and-\f[C]expenses:supplies\f[] accounts are not shown, as they have no-budget amounts declared.-.PP-This can be confusing.-When you need to make things clearer, use the \f[C]\-E/\-\-empty\f[]-flag, which will reveal all accounts including unbudgeted ones, giving-the full picture.-Eg:-.IP-.nf-\f[C]-$\ hledger\ balance\ \-M\ \-\-budget\ \-\-empty-Budget\ performance\ in\ 2017/11/01\-2017/12/31:--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Nov\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Dec\ -======================++====================================================-\ assets\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ $\-2445\ [\ \ 99%\ of\ $\-2480]\ \ $\-2665\ [\ 107%\ of\ $\-2480]\ -\ assets:bank\ \ \ \ \ \ \ \ \ \ ||\ $\-2445\ [\ \ 99%\ of\ $\-2480]\ \ $\-2665\ [\ 107%\ of\ $\-2480]\ -\ assets:bank:checking\ ||\ $\-2445\ [\ \ 99%\ of\ $\-2480]\ \ $\-2665\ [\ 107%\ of\ $\-2480]\ -\ expenses\ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ $495\ [\ 103%\ of\ \ \ $480]\ \ \ \ $565\ [\ 118%\ of\ \ \ $480]\ -\ expenses:bus\ \ \ \ \ \ \ \ \ ||\ \ \ \ $49\ [\ \ 98%\ of\ \ \ \ $50]\ \ \ \ \ $53\ [\ 106%\ of\ \ \ \ $50]\ -\ expenses:food\ \ \ \ \ \ \ \ ||\ \ \ $396\ [\ \ 99%\ of\ \ \ $400]\ \ \ \ $412\ [\ 103%\ of\ \ \ $400]\ -\ expenses:gifts\ \ \ \ \ \ \ ||\ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $100\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -\ expenses:movies\ \ \ \ \ \ ||\ \ \ \ $30\ [\ 100%\ of\ \ \ \ $30]\ \ \ \ \ \ \ 0\ [\ \ \ 0%\ of\ \ \ \ $30]\ -\ expenses:supplies\ \ \ \ ||\ \ \ \ $20\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -\ income\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ $1950\ [\ \ 98%\ of\ \ $2000]\ \ \ $2100\ [\ 105%\ of\ \ $2000]\ -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ \ 0\ [\ \ \ \ \ \ \ \ \ \ \ \ \ \ 0]\ \ \ \ \ \ \ 0\ [\ \ \ \ \ \ \ \ \ \ \ \ \ \ 0]\ -\f[]-.fi-.PP-You can roll over unspent budgets to next period with-\f[C]\-\-cumulative\f[]:-.IP-.nf-\f[C]-$\ hledger\ balance\ \-M\ \-\-budget\ \-\-cumulative-Budget\ performance\ in\ 2017/11/01\-2017/12/31:--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Nov\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Dec\ -======================++====================================================-\ assets\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ $\-2445\ [\ \ 99%\ of\ $\-2480]\ \ $\-5110\ [\ 103%\ of\ $\-4960]\ -\ assets:bank\ \ \ \ \ \ \ \ \ \ ||\ $\-2445\ [\ \ 99%\ of\ $\-2480]\ \ $\-5110\ [\ 103%\ of\ $\-4960]\ -\ assets:bank:checking\ ||\ $\-2445\ [\ \ 99%\ of\ $\-2480]\ \ $\-5110\ [\ 103%\ of\ $\-4960]\ -\ expenses\ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ $495\ [\ 103%\ of\ \ \ $480]\ \ \ $1060\ [\ 110%\ of\ \ \ $960]\ -\ expenses:bus\ \ \ \ \ \ \ \ \ ||\ \ \ \ $49\ [\ \ 98%\ of\ \ \ \ $50]\ \ \ \ $102\ [\ 102%\ of\ \ \ $100]\ -\ expenses:food\ \ \ \ \ \ \ \ ||\ \ \ $396\ [\ \ 99%\ of\ \ \ $400]\ \ \ \ $808\ [\ 101%\ of\ \ \ $800]\ -\ expenses:movies\ \ \ \ \ \ ||\ \ \ \ $30\ [\ 100%\ of\ \ \ \ $30]\ \ \ \ \ $30\ [\ \ 50%\ of\ \ \ \ $60]\ -\ income\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ $1950\ [\ \ 98%\ of\ \ $2000]\ \ \ $4050\ [\ 101%\ of\ \ $4000]\ -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ \ 0\ [\ \ \ \ \ \ \ \ \ \ \ \ \ \ 0]\ \ \ \ \ \ \ 0\ [\ \ \ \ \ \ \ \ \ \ \ \ \ \ 0]\ -\f[]-.fi-.PP-For more examples, see Budgeting and Forecasting.-.SS Nested budgets-.PP-You can add budgets to any account in your account hierarchy.-If you have budgets on both parent account and some of its children,-then budget(s) of the child account(s) would be added to the budget of-their parent, much like account balances behave.-.PP-In the most simple case this means that once you add a budget to any-account, all its parents would have budget as well.-.PP-To illustrate this, consider the following budget:-.IP-.nf-\f[C]-~\ monthly\ from\ 2019/01-\ \ \ \ expenses:personal\ \ \ \ \ \ \ \ \ \ \ \ \ $1,000.00-\ \ \ \ expenses:personal:electronics\ \ \ \ $100.00-\ \ \ \ liabilities-\f[]-.fi-.PP-With this, monthly budget for electronics is defined to be $100 and-budget for personal expenses is an additional $1000, which implicity-means that budget for both \f[C]expenses:personal\f[] and-\f[C]expenses\f[] is $1100.-.PP-Transactions in \f[C]expenses:personal:electronics\f[] will be counted-both towards its $100 budget and $1100 of \f[C]expenses:personal\f[] ,-and transactions in any other subaccount of \f[C]expenses:personal\f[]-would be counted towards only towards the budget of-\f[C]expenses:personal\f[].-.PP-For example, let\[aq]s consider these transactions:-.IP-.nf-\f[C]-~\ monthly\ from\ 2019/01-\ \ \ \ expenses:personal\ \ \ \ \ \ \ \ \ \ \ \ \ $1,000.00-\ \ \ \ expenses:personal:electronics\ \ \ \ $100.00-\ \ \ \ liabilities--2019/01/01\ Google\ home\ hub-\ \ \ \ expenses:personal:electronics\ \ \ \ \ \ \ \ \ \ $90.00-\ \ \ \ liabilities\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-90.00--2019/01/02\ Phone\ screen\ protector-\ \ \ \ expenses:personal:electronics:upgrades\ \ \ \ \ \ \ \ \ \ $10.00-\ \ \ \ liabilities--2019/01/02\ Weekly\ train\ ticket-\ \ \ \ expenses:personal:train\ tickets\ \ \ \ \ \ \ $153.00-\ \ \ \ liabilities--2019/01/03\ Flowers-\ \ \ \ expenses:personal\ \ \ \ \ \ \ \ \ \ $30.00-\ \ \ \ liabilities-\f[]-.fi-.PP-As you can see, we have transactions in-\f[C]expenses:personal:electronics:upgrades\f[] and-\f[C]expenses:personal:train\ tickets\f[], and since both of these-accounts are without explicitly defined budget, these transactions would-be counted towards budgets of \f[C]expenses:personal:electronics\f[] and-\f[C]expenses:personal\f[] accordingly:-.IP-.nf-\f[C]-$\ hledger\ balance\ \-\-budget\ \-M-Budget\ performance\ in\ 2019/01:--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Jan\ -===============================++===============================-\ expenses\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ $283.00\ [\ \ 26%\ of\ \ $1100.00]\ -\ expenses:personal\ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ $283.00\ [\ \ 26%\ of\ \ $1100.00]\ -\ expenses:personal:electronics\ ||\ \ $100.00\ [\ 100%\ of\ \ \ $100.00]\ -\ liabilities\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ $\-283.00\ [\ \ 26%\ of\ $\-1100.00]\ -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ \ \ \ 0\ [\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0]\ -\f[]-.fi-.PP-And with \f[C]\-\-empty\f[], we can get a better picture of budget-allocation and consumption:-.IP-.nf-\f[C]-$\ hledger\ balance\ \-\-budget\ \-M\ \-\-empty-Budget\ performance\ in\ 2019/01:--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Jan\ -========================================++===============================-\ expenses\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ $283.00\ [\ \ 26%\ of\ \ $1100.00]\ -\ expenses:personal\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ $283.00\ [\ \ 26%\ of\ \ $1100.00]\ -\ expenses:personal:electronics\ \ \ \ \ \ \ \ \ \ ||\ \ $100.00\ [\ 100%\ of\ \ \ $100.00]\ -\ expenses:personal:electronics:upgrades\ ||\ \ \ $10.00\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -\ expenses:personal:train\ tickets\ \ \ \ \ \ \ \ ||\ \ $153.00\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -\ liabilities\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ $\-283.00\ [\ \ 26%\ of\ $\-1100.00]\ -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ \ \ \ 0\ [\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0]\ -\f[]-.fi-.SS Output format-.PP-The balance command supports output destination and output format-selection.-.SS balancesheet-.PP-balancesheet, bs-.PD 0-.P-.PD-This command displays a simple balance sheet, showing historical ending-balances of asset and liability accounts (ignoring any report begin-date).-It assumes that these accounts are under a top\-level \f[C]asset\f[] or-\f[C]liability\f[] account (case insensitive, plural forms also-allowed).-.PP-Note this report shows all account balances with normal positive sign-(like conventional financial statements, unlike balance/print/register)-(experimental).-.PP-Example:-.IP-.nf-\f[C]-$\ hledger\ balancesheet-Balance\ Sheet--Assets:-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1\ \ assets-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ \ \ bank:saving-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-2\ \ \ \ cash-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1--Liabilities:-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ liabilities:debts-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1--Total:-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0-\f[]-.fi-.PP-With a reporting interval, multiple columns will be shown, one for each-report period.-As with multicolumn balance reports, you can alter the report mode with-\f[C]\-\-change\f[]/\f[C]\-\-cumulative\f[]/\f[C]\-\-historical\f[].-Normally balancesheet shows historical ending balances, which is what-you need for a balance sheet; note this means it ignores report begin-dates.-.PP-This command also supports output destination and output format-selection.-.SS balancesheetequity-.PP-balancesheetequity, bse-.PD 0-.P-.PD-Just like balancesheet, but also reports Equity (which it assumes is-under a top\-level \f[C]equity\f[] account).-.PP-Example:-.IP-.nf-\f[C]-$\ hledger\ balancesheetequity-Balance\ Sheet\ With\ Equity--Assets:-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-2\ \ assets-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ \ \ bank:saving-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-3\ \ \ \ cash-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-2--Liabilities:-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ liabilities:debts-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1--Equity:-\ \ \ \ \ \ \ \ \ \ $1\ \ equity:owner-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ $1--Total:-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0-\f[]-.fi-.SS cashflow-.PP-cashflow, cf-.PD 0-.P-.PD-This command displays a simple cashflow statement, showing changes in-"cash" accounts.-It assumes that these accounts are under a top\-level \f[C]asset\f[]-account (case insensitive, plural forms also allowed) and do not contain-\f[C]receivable\f[] or \f[C]A/R\f[] in their name.-Note this report shows all account balances with normal positive sign-(like conventional financial statements, unlike balance/print/register)-(experimental).-.PP-Example:-.IP-.nf-\f[C]-$\ hledger\ cashflow-Cashflow\ Statement--Cash\ flows:-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1\ \ assets-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ \ \ bank:saving-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-2\ \ \ \ cash-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1--Total:-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1-\f[]-.fi-.PP-With a reporting interval, multiple columns will be shown, one for each-report period.-Normally cashflow shows changes in assets per period, though as with-multicolumn balance reports you can alter the report mode with-\f[C]\-\-change\f[]/\f[C]\-\-cumulative\f[]/\f[C]\-\-historical\f[].-.PP-This command also supports output destination and output format-selection.-.SS check\-dates-.PP-check\-dates-.PD 0-.P-.PD-Check that transactions are sorted by increasing date.-With \-\-date2, checks secondary dates instead.-With \-\-strict, dates must also be unique.-With a query, only matched transactions\[aq] dates are checked.-Reads the default journal file, or another specified with \-f.-.SS check\-dupes-.PP-check\-dupes-.PD 0-.P-.PD-Reports account names having the same leaf but different prefixes.-In other words, two or more leaves that are categorized differently.-Reads the default journal file, or another specified as an argument.-.PP-An example: http://stefanorodighiero.net/software/hledger\-dupes.html-.SS close-.PP-close, equity-.PD 0-.P-.PD-Prints a "closing balances" transaction and an "opening balances"-transaction that bring account balances to and from zero, respectively.-Useful for bringing asset/liability balances forward into a new journal-file, or for closing out revenues/expenses to retained earnings at the-end of a period.-.PP-The closing transaction transfers balances to "equity:closing balances".-The opening transaction transfers balances from "equity:opening-balances".-You can chose to print just one of the transactions by using the-\f[C]\-\-opening\f[] or \f[C]\-\-closing\f[] flag.-.PP-If you split your journal files by time (eg yearly), you will typically-run this command at the end of the year, and save the closing-transaction as last entry of the old file, and the opening transaction-as the first entry of the new file.-This makes the files self contained, so that correct balances are-reported no matter which of them are loaded.-Ie, if you load just one file, the balances are initialised correctly;-or if you load several files, the redundant closing/opening transactions-cancel each other out.-(They will show up in print or register reports; you can exclude them-with a query like-\f[C]not:desc:\[aq](opening|closing)\ balances\[aq]\f[].)-.PP-If you\[aq]re running a business, you might also use this command to-"close the books" at the end of an accounting period, transferring-income statement account balances to retained earnings.-(You may want to change the equity account name to something like-"equity:retained earnings".)-.PP-By default, the closing transaction is dated yesterday, the balances are-calculated as of end of yesterday, and the opening transaction is dated-today.-To close on some other date, use:-\f[C]hledger\ close\ \-e\ OPENINGDATE\f[].-Eg, to close/open on the 2018/2019 boundary, use \f[C]\-e\ 2019\f[].-You can also use \-p or \f[C]date:PERIOD\f[] (any starting date is-ignored).-.PP-Both transactions will include balance assertions for the-closed/reopened accounts.-You probably shouldn\[aq]t use status or realness filters (like \-C or-\-R or \f[C]status:\f[]) with this command, or the generated balance-assertions will depend on these flags.-Likewise, if you run this command with \-\-auto, the balance assertions-will probably always require \-\-auto.-.PP-Examples:-.PP-Carrying asset/liability balances into a new file for 2019, all from-command line:-.PP-\f[I]Warning: we use \f[CI]>>\f[I] here to append; be careful not to-type a single \f[CI]>\f[I] which would wipe your journal!\f[]-.IP-.nf-\f[C]-$\ hledger\ close\ \-f\ 2018.journal\ \-e\ 2019\ assets\ liabilities\ \-\-opening\ >>2019.journal-$\ hledger\ close\ \-f\ 2018.journal\ \-e\ 2019\ assets\ liabilities\ \-\-closing\ >>2018.journal-\f[]-.fi-.PP-Now:-.IP-.nf-\f[C]-$\ hledger\ bs\ \-f\ 2019.journal\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ one\ file\ \-\ balances\ are\ correct-$\ hledger\ bs\ \-f\ 2018.journal\ \-f\ 2019.journal\ \ \ #\ two\ files\ \-\ balances\ still\ correct-$\ hledger\ bs\ \-f\ 2018.journal\ not:desc:closing\ \ #\ to\ see\ year\-end\ balances,\ must\ exclude\ closing\ txn-\f[]-.fi-.PP-Transactions spanning the closing date can complicate matters, breaking-balance assertions:-.IP-.nf-\f[C]-2018/12/30\ a\ purchase\ made\ in\ 2018,\ clearing\ the\ following\ year-\ \ \ \ expenses:food\ \ \ \ \ \ \ \ \ \ 5-\ \ \ \ assets:bank:checking\ \ \-5\ \ ;\ [2019/1/2]-\f[]-.fi-.PP-Here\[aq]s one way to resolve that:-.IP-.nf-\f[C]-;\ in\ 2018.journal:-2018/12/30\ a\ purchase\ made\ in\ 2018,\ clearing\ the\ following\ year-\ \ \ \ expenses:food\ \ \ \ \ \ \ \ \ \ 5-\ \ \ \ liabilities:pending--;\ in\ 2019.journal:-2019/1/2\ clearance\ of\ last\ year\[aq]s\ pending\ transactions-\ \ \ \ liabilities:pending\ \ \ \ 5\ =\ 0-\ \ \ \ assets:checking-\f[]-.fi-.SS files-.PP-files-.PD 0-.P-.PD-List all files included in the journal.-With a REGEX argument, only file names matching the regular expression-(case sensitive) are shown.-.SS help-.PP-help-.PD 0-.P-.PD-Show any of the hledger manuals.-.PP-The \f[C]help\f[] command displays any of the main hledger manuals, in-one of several ways.-Run it with no argument to list the manuals, or provide a full or-partial manual name to select one.-.PP-hledger manuals are available in several formats.-hledger help will use the first of these display methods that it finds:-info, man, $PAGER, less, stdout (or when non\-interactive, just stdout).-You can force a particular viewer with the \f[C]\-\-info\f[],-\f[C]\-\-man\f[], \f[C]\-\-pager\f[], \f[C]\-\-cat\f[] flags.-.PP-Examples:-.IP-.nf-\f[C]-$\ hledger\ help-Please\ choose\ a\ manual\ by\ typing\ "hledger\ help\ MANUAL"\ (a\ substring\ is\ ok).-Manuals:\ hledger\ hledger\-ui\ hledger\-web\ hledger\-api\ journal\ csv\ timeclock\ timedot-\f[]-.fi-.IP-.nf-\f[C]-$\ hledger\ help\ h\ \-\-man--hledger(1)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ hledger\ User\ Manuals\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ hledger(1)--NAME-\ \ \ \ \ \ \ hledger\ \-\ a\ command\-line\ accounting\ tool--SYNOPSIS-\ \ \ \ \ \ \ hledger\ [\-f\ FILE]\ COMMAND\ [OPTIONS]\ [ARGS]-\ \ \ \ \ \ \ hledger\ [\-f\ FILE]\ ADDONCMD\ \-\-\ [OPTIONS]\ [ARGS]-\ \ \ \ \ \ \ hledger--DESCRIPTION-\ \ \ \ \ \ \ hledger\ \ is\ \ a\ \ cross\-platform\ \ program\ \ for\ tracking\ money,\ time,\ or\ any-\&...-\f[]-.fi-.SS import-.PP-import-.PD 0-.P-.PD-Read new transactions added to each FILE since last run, and add them to-the main journal file.-Or with \-\-dry\-run, just print the transactions that would be added.-.PP-The input files are specified as arguments \- no need to write \-f-before each one.-So eg to add new transactions from all CSV files to the main journal,-it\[aq]s just: \f[C]hledger\ import\ *.csv\f[]-.PP-New transactions are detected in the same way as print \-\-new: by-assuming transactions are always added to the input files in increasing-date order, and by saving \f[C]\&.latest.FILE\f[] state files.-.PP-The \-\-dry\-run output is in journal format, so you can filter it, eg-to see only uncategorised transactions:-.IP-.nf-\f[C]-$\ hledger\ import\ \-\-dry\ ...\ |\ hledger\ \-f\-\ print\ unknown\ \-\-ignore\-assertions-\f[]-.fi-.SS incomestatement-.PP-incomestatement, is-.PD 0-.P-.PD-This command displays a simple income statement, showing revenues and-expenses during a period.-It assumes that these accounts are under a top\-level \f[C]revenue\f[]-or \f[C]income\f[] or \f[C]expense\f[] account (case insensitive, plural-forms also allowed).-Note this report shows all account balances with normal positive sign-(like conventional financial statements, unlike balance/print/register)-(experimental).-.PP-This command displays a simple income statement.-It currently assumes that you have top\-level accounts named-\f[C]income\f[] (or \f[C]revenue\f[]) and \f[C]expense\f[] (plural forms-also allowed.)-.IP-.nf-\f[C]-$\ hledger\ incomestatement-Income\ Statement--Revenues:-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-2\ \ income-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1\ \ \ \ gifts-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1\ \ \ \ salary-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-2--Expenses:-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $2\ \ expenses-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ \ \ food-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ \ \ supplies-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $2--Total:-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0-\f[]-.fi-.PP-With a reporting interval, multiple columns will be shown, one for each-report period.-Normally incomestatement shows revenues/expenses per period, though as-with multicolumn balance reports you can alter the report mode with-\f[C]\-\-change\f[]/\f[C]\-\-cumulative\f[]/\f[C]\-\-historical\f[].-.PP-This command also supports output destination and output format-selection.-.SS prices-.PP-prices-.PD 0-.P-.PD-Print market price directives from the journal.-With \-\-costs, also print synthetic market prices based on transaction-prices.-With \-\-inverted\-costs, also print inverse prices based on transaction-prices.-Prices (and postings providing prices) can be filtered by a query.-.SS print-.PP-print, txns, p-.PD 0-.P-.PD-Show transaction journal entries, sorted by date.-.PP-The print command displays full journal entries (transactions) from the-journal file in date order, tidily formatted.-With \-\-date2, transactions are sorted by secondary date instead.-.PP-print\[aq]s output is always a valid hledger journal.-.PD 0-.P-.PD-It preserves all transaction information, but it does not preserve-directives or inter\-transaction comments-.IP-.nf-\f[C]-$\ hledger\ print-2008/01/01\ income-\ \ \ \ assets:bank:checking\ \ \ \ \ \ \ \ \ \ \ \ $1-\ \ \ \ income:salary\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1--2008/06/01\ gift-\ \ \ \ assets:bank:checking\ \ \ \ \ \ \ \ \ \ \ \ $1-\ \ \ \ income:gifts\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1--2008/06/02\ save-\ \ \ \ assets:bank:saving\ \ \ \ \ \ \ \ \ \ \ \ \ \ $1-\ \ \ \ assets:bank:checking\ \ \ \ \ \ \ \ \ \ \ $\-1--2008/06/03\ *\ eat\ &\ shop-\ \ \ \ expenses:food\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1-\ \ \ \ expenses:supplies\ \ \ \ \ \ \ \ \ \ \ \ $1-\ \ \ \ assets:cash\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-2--2008/12/31\ *\ pay\ off-\ \ \ \ liabilities:debts\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1-\ \ \ \ assets:bank:checking\ \ \ \ \ \ \ \ \ \ \ $\-1-\f[]-.fi-.PP-Normally, the journal entry\[aq]s explicit or implicit amount style is-preserved.-Ie when an amount is omitted in the journal, it will be omitted in the-output.-You can use the \f[C]\-x\f[]/\f[C]\-\-explicit\f[] flag to make all-amounts explicit, which can be useful for troubleshooting or for making-your journal more readable and robust against data entry errors.-Note, \f[C]\-x\f[] will cause postings with a multi\-commodity amount-(these can arise when a multi\-commodity transaction has an implicit-amount) will be split into multiple single\-commodity postings, for-valid journal output.-.PP-With \f[C]\-B\f[]/\f[C]\-\-cost\f[], amounts with transaction prices are-converted to cost using that price.-This can be used for troubleshooting.-.PP-With \f[C]\-m\f[]/\f[C]\-\-match\f[] and a STR argument, print will show-at most one transaction: the one one whose description is most similar-to STR, and is most recent.-STR should contain at least two characters.-If there is no similar\-enough match, no transaction will be shown.-.PP-With \f[C]\-\-new\f[], for each FILE being read, hledger reads (and-writes) a special state file (\f[C]\&.latest.FILE\f[] in the same-directory), containing the latest transaction date(s) that were seen-last time FILE was read.-When this file is found, only transactions with newer dates (and new-transactions on the latest date) are printed.-This is useful for ignoring already\-seen entries in import data, such-as downloaded CSV files.-Eg:-.IP-.nf-\f[C]-$\ hledger\ \-f\ bank1.csv\ print\ \-\-new-#\ shows\ transactions\ added\ since\ last\ print\ \-\-new\ on\ this\ file-\f[]-.fi-.PP-This assumes that transactions added to FILE always have same or-increasing dates, and that transactions on the same day do not get-reordered.-See also the import command.-.PP-This command also supports output destination and output format-selection.-Here\[aq]s an example of print\[aq]s CSV output:-.IP-.nf-\f[C]-$\ hledger\ print\ \-Ocsv-"txnidx","date","date2","status","code","description","comment","account","amount","commodity","credit","debit","posting\-status","posting\-comment"-"1","2008/01/01","","","","income","","assets:bank:checking","1","$","","1","",""-"1","2008/01/01","","","","income","","income:salary","\-1","$","1","","",""-"2","2008/06/01","","","","gift","","assets:bank:checking","1","$","","1","",""-"2","2008/06/01","","","","gift","","income:gifts","\-1","$","1","","",""-"3","2008/06/02","","","","save","","assets:bank:saving","1","$","","1","",""-"3","2008/06/02","","","","save","","assets:bank:checking","\-1","$","1","","",""-"4","2008/06/03","","*","","eat\ &\ shop","","expenses:food","1","$","","1","",""-"4","2008/06/03","","*","","eat\ &\ shop","","expenses:supplies","1","$","","1","",""-"4","2008/06/03","","*","","eat\ &\ shop","","assets:cash","\-2","$","2","","",""-"5","2008/12/31","","*","","pay\ off","","liabilities:debts","1","$","","1","",""-"5","2008/12/31","","*","","pay\ off","","assets:bank:checking","\-1","$","1","","",""-\f[]-.fi-.IP \[bu] 2-There is one CSV record per posting, with the parent transaction\[aq]s-fields repeated.-.IP \[bu] 2-The "txnidx" (transaction index) field shows which postings belong to-the same transaction.-(This number might change if transactions are reordered within the file,-files are parsed/included in a different order, etc.)-.IP \[bu] 2-The amount is separated into "commodity" (the symbol) and "amount"-(numeric quantity) fields.-.IP \[bu] 2-The numeric amount is repeated in either the "credit" or "debit" column,-for convenience.-(Those names are not accurate in the accounting sense; it just puts-negative amounts under credit and zero or greater amounts under debit.)-.SS print\-unique-.PP-print\-unique-.PD 0-.P-.PD-Print transactions which do not reuse an already\-seen description.-.PP-Example:-.IP-.nf-\f[C]-$\ cat\ unique.journal-1/1\ test-\ (acct:one)\ \ 1-2/2\ test-\ (acct:two)\ \ 2-$\ LEDGER_FILE=unique.journal\ hledger\ print\-unique-(\-f\ option\ not\ supported)-2015/01/01\ test-\ \ \ \ (acct:one)\ \ \ \ \ \ \ \ \ \ \ \ \ 1-\f[]-.fi-.SS register-.PP-register, reg, r-.PD 0-.P-.PD-Show postings and their running total.-.PP-The register command displays postings in date order, one per line, and-their running total.-This is typically used with a query selecting a particular account, to-see that account\[aq]s activity:-.IP-.nf-\f[C]-$\ hledger\ register\ checking-2008/01/01\ income\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ assets:bank:checking\ \ \ \ \ \ \ \ \ \ \ \ $1\ \ \ \ \ \ \ \ \ \ \ $1-2008/06/01\ gift\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ assets:bank:checking\ \ \ \ \ \ \ \ \ \ \ \ $1\ \ \ \ \ \ \ \ \ \ \ $2-2008/06/02\ save\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ assets:bank:checking\ \ \ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ \ \ $1-2008/12/31\ pay\ off\ \ \ \ \ \ \ \ \ \ \ \ \ \ assets:bank:checking\ \ \ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ \ \ \ 0-\f[]-.fi-.PP-With \-\-date2, it shows and sorts by secondary date instead.-.PP-The \f[C]\-\-historical\f[]/\f[C]\-H\f[] flag adds the balance from any-undisplayed prior postings to the running total.-This is useful when you want to see only recent activity, with a-historically accurate running balance:-.IP-.nf-\f[C]-$\ hledger\ register\ checking\ \-b\ 2008/6\ \-\-historical-2008/06/01\ gift\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ assets:bank:checking\ \ \ \ \ \ \ \ \ \ \ \ $1\ \ \ \ \ \ \ \ \ \ \ $2-2008/06/02\ save\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ assets:bank:checking\ \ \ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ \ \ $1-2008/12/31\ pay\ off\ \ \ \ \ \ \ \ \ \ \ \ \ \ assets:bank:checking\ \ \ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ \ \ \ 0-\f[]-.fi-.PP-The \f[C]\-\-depth\f[] option limits the amount of sub\-account detail-displayed.-.PP-The \f[C]\-\-average\f[]/\f[C]\-A\f[] flag shows the running average-posting amount instead of the running total (so, the final number-displayed is the average for the whole report period).-This flag implies \f[C]\-\-empty\f[] (see below).-It is affected by \f[C]\-\-historical\f[].-It works best when showing just one account and one commodity.-.PP-The \f[C]\-\-related\f[]/\f[C]\-r\f[] flag shows the \f[I]other\f[]-postings in the transactions of the postings which would normally be-shown.-.PP-The \f[C]\-\-invert\f[] flag negates all amounts.-For example, it can be used on an income account where amounts are-normally displayed as negative numbers.-It\[aq]s also useful to show postings on the checking account together-with the related account:-.IP-.nf-\f[C]-$\ hledger\ register\ \-\-related\ \-\-invert\ assets:checking-\f[]-.fi-.PP-With a reporting interval, register shows summary postings, one per-interval, aggregating the postings to each account:-.IP-.nf-\f[C]-$\ hledger\ register\ \-\-monthly\ income-2008/01\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ income:salary\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ \ $\-1-2008/06\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ income:gifts\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ \ $\-2-\f[]-.fi-.PP-Periods with no activity, and summary postings with a zero amount, are-not shown by default; use the \f[C]\-\-empty\f[]/\f[C]\-E\f[] flag to-see them:-.IP-.nf-\f[C]-$\ hledger\ register\ \-\-monthly\ income\ \-E-2008/01\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ income:salary\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ \ $\-1-2008/02\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ $\-1-2008/03\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ $\-1-2008/04\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ $\-1-2008/05\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ $\-1-2008/06\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ income:gifts\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ \ $\-2-2008/07\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ $\-2-2008/08\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ $\-2-2008/09\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ $\-2-2008/10\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ $\-2-2008/11\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ $\-2-2008/12\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ $\-2-\f[]-.fi-.PP-Often, you\[aq]ll want to see just one line per interval.-The \f[C]\-\-depth\f[] option helps with this, causing subaccounts to be-aggregated:-.IP-.nf-\f[C]-$\ hledger\ register\ \-\-monthly\ assets\ \-\-depth\ 1h-2008/01\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ assets\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ \ \ \ \ \ \ \ \ \ $1-2008/06\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ assets\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ \ \ \ 0-2008/12\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ assets\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ \ $\-1-\f[]-.fi-.PP-Note when using report intervals, if you specify start/end dates these-will be adjusted outward if necessary to contain a whole number of-intervals.-This ensures that the first and last intervals are full length and-comparable to the others in the report.-.SS Custom register output-.PP-register uses the full terminal width by default, except on windows.-You can override this by setting the \f[C]COLUMNS\f[] environment-variable (not a bash shell variable) or by using the-\f[C]\-\-width\f[]/\f[C]\-w\f[] option.-.PP-The description and account columns normally share the space equally-(about half of (width \- 40) each).-You can adjust this by adding a description width as part of-\-\-width\[aq]s argument, comma\-separated: \f[C]\-\-width\ W,D\f[] .-Here\[aq]s a diagram (won\[aq]t display correctly in \-\-help):-.IP-.nf-\f[C]-<\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\ width\ (W)\ \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\->-date\ (10)\ \ description\ (D)\ \ \ \ \ \ \ account\ (W\-41\-D)\ \ \ \ \ amount\ (12)\ \ \ balance\ (12)-DDDDDDDDDD\ dddddddddddddddddddd\ \ aaaaaaaaaaaaaaaaaaa\ \ AAAAAAAAAAAA\ \ AAAAAAAAAAAA-\f[]-.fi-.PP-and some examples:-.IP-.nf-\f[C]-$\ hledger\ reg\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ use\ terminal\ width\ (or\ 80\ on\ windows)-$\ hledger\ reg\ \-w\ 100\ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ use\ width\ 100-$\ COLUMNS=100\ hledger\ reg\ \ \ \ \ \ \ \ \ #\ set\ with\ one\-time\ environment\ variable-$\ export\ COLUMNS=100;\ hledger\ reg\ #\ set\ till\ session\ end\ (or\ window\ resize)-$\ hledger\ reg\ \-w\ 100,40\ \ \ \ \ \ \ \ \ \ \ #\ set\ overall\ width\ 100,\ description\ width\ 40-$\ hledger\ reg\ \-w\ $COLUMNS,40\ \ \ \ \ \ #\ use\ terminal\ width,\ &\ description\ width\ 40-\f[]-.fi-.PP-This command also supports output destination and output format-selection.-.SS register\-match-.PP-register\-match-.PD 0-.P-.PD-Print the one posting whose transaction description is closest to DESC,-in the style of the register command.-If there are multiple equally good matches, it shows the most recent.-Query options (options, not arguments) can be used to restrict the-search space.-Helps ledger\-autosync detect already\-seen transactions when importing.-.SS rewrite-.PP-rewrite-.PD 0-.P-.PD-Print all transactions, rewriting the postings of matched transactions.-For now the only rewrite available is adding new postings, like print-\-\-auto.-.PP-This is a start at a generic rewriter of transaction entries.-It reads the default journal and prints the transactions, like print,-but adds one or more specified postings to any transactions matching-QUERY.-The posting amounts can be fixed, or a multiplier of the existing-transaction\[aq]s first posting amount.-.PP-Examples:-.IP-.nf-\f[C]-hledger\-rewrite.hs\ ^income\ \-\-add\-posting\ \[aq](liabilities:tax)\ \ *.33\ \ ;\ income\ tax\[aq]\ \-\-add\-posting\ \[aq](reserve:gifts)\ \ $100\[aq]-hledger\-rewrite.hs\ expenses:gifts\ \-\-add\-posting\ \[aq](reserve:gifts)\ \ *\-1"\[aq]-hledger\-rewrite.hs\ \-f\ rewrites.hledger-\f[]-.fi-.PP-rewrites.hledger may consist of entries like:-.IP-.nf-\f[C]-=\ ^income\ amt:<0\ date:2017-\ \ (liabilities:tax)\ \ *0.33\ \ ;\ tax\ on\ income-\ \ (reserve:grocery)\ \ *0.25\ \ ;\ reserve\ 25%\ for\ grocery-\ \ (reserve:)\ \ *0.25\ \ ;\ reserve\ 25%\ for\ grocery-\f[]-.fi-.PP-Note the single quotes to protect the dollar sign from bash, and the two-spaces between account and amount.-.PP-More:-.IP-.nf-\f[C]-$\ hledger\ rewrite\ \-\-\ [QUERY]\ \ \ \ \ \ \ \ \-\-add\-posting\ "ACCT\ \ AMTEXPR"\ ...-$\ hledger\ rewrite\ \-\-\ ^income\ \ \ \ \ \ \ \ \-\-add\-posting\ \[aq](liabilities:tax)\ \ *.33\[aq]-$\ hledger\ rewrite\ \-\-\ expenses:gifts\ \-\-add\-posting\ \[aq](budget:gifts)\ \ *\-1"\[aq]-$\ hledger\ rewrite\ \-\-\ ^income\ \ \ \ \ \ \ \ \-\-add\-posting\ \[aq](budget:foreign\ currency)\ \ *0.25\ JPY;\ diversify\[aq]-\f[]-.fi-.PP-Argument for \f[C]\-\-add\-posting\f[] option is a usual posting of-transaction with an exception for amount specification.-More precisely, you can use \f[C]\[aq]*\[aq]\f[] (star symbol) before-the amount to indicate that that this is a factor for an amount of-original matched posting.-If the amount includes a commodity name, the new posting amount will be-in the new commodity; otherwise, it will be in the matched posting-amount\[aq]s commodity.-.SS Re\-write rules in a file-.PP-During the run this tool will execute so called "Automated Transactions"-found in any journal it process.-I.e instead of specifying this operations in command line you can put-them in a journal file.-.IP-.nf-\f[C]-$\ rewrite\-rules.journal-\f[]-.fi-.PP-Make contents look like this:-.IP-.nf-\f[C]-=\ ^income-\ \ \ \ (liabilities:tax)\ \ *.33--=\ expenses:gifts-\ \ \ \ budget:gifts\ \ *\-1-\ \ \ \ assets:budget\ \ *1-\f[]-.fi-.PP-Note that \f[C]\[aq]=\[aq]\f[] (equality symbol) that is used instead of-date in transactions you usually write.-It indicates the query by which you want to match the posting to add new-ones.-.IP-.nf-\f[C]-$\ hledger\ rewrite\ \-\-\ \-f\ input.journal\ \-f\ rewrite\-rules.journal\ >\ rewritten\-tidy\-output.journal-\f[]-.fi-.PP-This is something similar to the commands pipeline:-.IP-.nf-\f[C]-$\ hledger\ rewrite\ \-\-\ \-f\ input.journal\ \[aq]^income\[aq]\ \-\-add\-posting\ \[aq](liabilities:tax)\ \ *.33\[aq]\ \\-\ \ |\ hledger\ rewrite\ \-\-\ \-f\ \-\ expenses:gifts\ \ \ \ \ \ \-\-add\-posting\ \[aq]budget:gifts\ \ *\-1\[aq]\ \ \ \ \ \ \ \\-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \-\-add\-posting\ \[aq]assets:budget\ \ *1\[aq]\ \ \ \ \ \ \ \\-\ \ >\ rewritten\-tidy\-output.journal-\f[]-.fi-.PP-It is important to understand that relative order of such entries in-journal is important.-You can re\-use result of previously added postings.-.SS Diff output format-.PP-To use this tool for batch modification of your journal files you may-find useful output in form of unified diff.-.IP-.nf-\f[C]-$\ hledger\ rewrite\ \-\-\ \-\-diff\ \-f\ examples/sample.journal\ \[aq]^income\[aq]\ \-\-add\-posting\ \[aq](liabilities:tax)\ \ *.33\[aq]-\f[]-.fi-.PP-Output might look like:-.IP-.nf-\f[C]-\-\-\-\ /tmp/examples/sample.journal-+++\ /tmp/examples/sample.journal-\@\@\ \-18,3\ +18,4\ \@\@-\ 2008/01/01\ income-\-\ \ \ \ assets:bank:checking\ \ $1-+\ \ \ \ assets:bank:checking\ \ \ \ \ \ \ \ \ \ \ \ $1-\ \ \ \ \ income:salary-+\ \ \ \ (liabilities:tax)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0-\@\@\ \-22,3\ +23,4\ \@\@-\ 2008/06/01\ gift-\-\ \ \ \ assets:bank:checking\ \ $1-+\ \ \ \ assets:bank:checking\ \ \ \ \ \ \ \ \ \ \ \ $1-\ \ \ \ \ income:gifts-+\ \ \ \ (liabilities:tax)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0-\f[]-.fi-.PP-If you\[aq]ll pass this through \f[C]patch\f[] tool you\[aq]ll get-transactions containing the posting that matches your query be updated.-Note that multiple files might be update according to list of input-files specified via \f[C]\-\-file\f[] options and \f[C]include\f[]-directives inside of these files.-.PP-Be careful.-Whole transaction being re\-formatted in a style of output from-\f[C]hledger\ print\f[].-.PP-See also:-.PP-https://github.com/simonmichael/hledger/issues/99-.SS rewrite vs. print \-\-auto-.PP-This command predates print \-\-auto, and currently does much the same-thing, but with these differences:-.IP \[bu] 2-with multiple files, rewrite lets rules in any file affect all other-files.-print \-\-auto uses standard directive scoping; rules affect only child-files.-.IP \[bu] 2-rewrite\[aq]s query limits which transactions can be rewritten; all are-printed.-print \-\-auto\[aq]s query limits which transactions are printed.-.IP \[bu] 2-rewrite applies rules specified on command line or in the journal.-print \-\-auto applies rules specified in the journal.-.SS roi-.PP-roi-.PD 0-.P-.PD-Shows the time\-weighted (TWR) and money\-weighted (IRR) rate of return-on your investments.-.PP-This command assumes that you have account(s) that hold nothing but your-investments and whenever you record current appraisal/valuation of these-investments you offset unrealized profit and loss into account(s) that,-again, hold nothing but unrealized profit and loss.-.PP-Any transactions affecting balance of investment account(s) and not-originating from unrealized profit and loss account(s) are assumed to be-your investments or withdrawals.-.PP-At a minimum, you need to supply a query (which could be just an account-name) to select your investments with \f[C]\-\-inv\f[], and another-query to identify your profit and loss transactions with-\f[C]\-\-pnl\f[].-.PP-It will compute and display the internalized rate of return (IRR) and-time\-weighted rate of return (TWR) for your investments for the time-period requested.-Both rates of return are annualized before display, regardless of the-length of reporting interval.-.SS stats-.PP-stats-.PD 0-.P-.PD-Show some journal statistics.-.PP-The stats command displays summary information for the whole journal, or-a matched part of it.-With a reporting interval, it shows a report for each report period.-.PP-Example:-.IP-.nf-\f[C]-$\ hledger\ stats-Main\ journal\ file\ \ \ \ \ \ \ \ :\ /src/hledger/examples/sample.journal-Included\ journal\ files\ \ \ :\ -Transactions\ span\ \ \ \ \ \ \ \ :\ 2008\-01\-01\ to\ 2009\-01\-01\ (366\ days)-Last\ transaction\ \ \ \ \ \ \ \ \ :\ 2008\-12\-31\ (2333\ days\ ago)-Transactions\ \ \ \ \ \ \ \ \ \ \ \ \ :\ 5\ (0.0\ per\ day)-Transactions\ last\ 30\ days:\ 0\ (0.0\ per\ day)-Transactions\ last\ 7\ days\ :\ 0\ (0.0\ per\ day)-Payees/descriptions\ \ \ \ \ \ :\ 5-Accounts\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ :\ 8\ (depth\ 3)-Commodities\ \ \ \ \ \ \ \ \ \ \ \ \ \ :\ 1\ ($)-\f[]-.fi-.PP-This command also supports output destination and output format-selection.-.SS tags-.PP-tags-.PD 0-.P-.PD-List all the tag names used in the journal.-With a TAGREGEX argument, only tag names matching the regular expression-(case insensitive) are shown.-With QUERY arguments, only transactions matching the query are-considered.-.SS test-.PP-test-.PD 0-.P-.PD-Run built\-in unit tests.-.PP-This command runs the unit tests built in to hledger\-lib and hledger,-printing test names and results on stdout.-If any test fails, the exit code will be non\-zero.-.PP-Test names include a group prefix.-If a (exact, case sensitive) group prefix, or a full test name is-provided as the first argument, only that group or test is run.-.PP-If a numeric second argument is provided, it will set the randomness-seed, for repeatable results from tests using randomness (currently none-of them).-.PP-This is mainly used by developers, but it\[aq]s nice to be able to-sanity\-check your installed hledger executable at any time.-All tests are expected to pass \- if you ever see otherwise, something-has gone wrong, please report a bug!-.SH ADD\-ON COMMANDS-.PP-hledger also searches for external add\-on commands, and will include-these in the commands list.-These are programs or scripts in your PATH whose name starts with-\f[C]hledger\-\f[] and ends with a recognised file extension (currently:-no extension, \f[C]bat\f[],\f[C]com\f[],\f[C]exe\f[],-\f[C]hs\f[],\f[C]lhs\f[],\f[C]pl\f[],\f[C]py\f[],\f[C]rb\f[],\f[C]rkt\f[],\f[C]sh\f[]).-.PP-Add\-ons can be invoked like any hledger command, but there are a few-things to be aware of.-Eg if the \f[C]hledger\-web\f[] add\-on is installed,-.IP \[bu] 2-\f[C]hledger\ \-h\ web\f[] shows hledger\[aq]s help, while-\f[C]hledger\ web\ \-h\f[] shows hledger\-web\[aq]s help.-.IP \[bu] 2-Flags specific to the add\-on must have a preceding \f[C]\-\-\f[] to-hide them from hledger.-So \f[C]hledger\ web\ \-\-serve\ \-\-port\ 9000\f[] will be rejected;-you must use \f[C]hledger\ web\ \-\-\ \-\-serve\ \-\-port\ 9000\f[].-.IP \[bu] 2-You can always run add\-ons directly if preferred:-\f[C]hledger\-web\ \-\-serve\ \-\-port\ 9000\f[].-.PP-Add\-ons are a relatively easy way to add local features or experiment-with new ideas.-They can be written in any language, but haskell scripts have a big-advantage: they can use the same hledger (and haskell) library functions-that built\-in commands do, for command\-line options, journal parsing,-reporting, etc.-.PP-Here are some hledger add\-ons available:-.SS Official add\-ons-.PP-These are maintained and released along with hledger.-.SS api-.PP-hledger\-api serves hledger data as a JSON web API.-.SS ui-.PP-hledger\-ui provides an efficient curses\-style interface.-.SS web-.PP-hledger\-web provides a simple web interface.-.SS Third party add\-ons-.PP-These are maintained separately, and usually updated shortly after a-hledger release.-.SS diff-.PP-hledger\-diff shows differences in an account\[aq]s transactions between-one journal file and another.-.SS iadd-.PP-hledger\-iadd is a curses\-style, more interactive replacement for the-add command.-.SS interest-.PP-hledger\-interest generates interest transactions for an account-according to various schemes.-.SS irr-.PP-hledger\-irr calculates the internal rate of return of an investment-account, but it\[aq]s superseded now by the built\-in roi command.-.SS Experimental add\-ons-.PP-These are available in source form in the hledger repo\[aq]s bin/-directory; installing them is pretty easy.-They may be less mature and documented than built\-in commands.-Reading and tweaking these is a good way to start making your own!-.SS autosync-.PP-hledger\-autosync is a symbolic link for easily running-ledger\-autosync, if installed.-ledger\-autosync does deduplicating conversion of OFX data and some CSV-formats, and can also download the data if your bank offers OFX Direct-Connect.-.SS chart-.PP-hledger\-chart.hs is an old pie chart generator, in need of some love.-.SS check-.PP-hledger\-check.hs checks more powerful account balance assertions.-.SH ENVIRONMENT-.PP-\f[B]COLUMNS\f[] The screen width used by the register command.-Default: the full terminal width.-.PP-\f[B]LEDGER_FILE\f[] The journal file path when not specified with-\f[C]\-f\f[].-Default: \f[C]~/.hledger.journal\f[] (on windows, perhaps-\f[C]C:/Users/USER/.hledger.journal\f[]).-.SH FILES-.PP-Reads data from one or more files in hledger journal, timeclock,-timedot, or CSV format specified with \f[C]\-f\f[], or-\f[C]$LEDGER_FILE\f[], or \f[C]$HOME/.hledger.journal\f[] (on windows,-perhaps \f[C]C:/Users/USER/.hledger.journal\f[]).-.SH BUGS-.PP-The need to precede addon command options with \f[C]\-\-\f[] when-invoked from hledger is awkward.-.PP-When input data contains non\-ascii characters, a suitable system locale-must be configured (or there will be an unhelpful error).-Eg on POSIX, set LANG to something other than C.-.PP-In a Microsoft Windows CMD window, non\-ascii characters and colours are-not supported.-.PP-In a Cygwin/MSYS/Mintty window, the tab key is not supported in hledger-add.-.PP-Not all of Ledger\[aq]s journal file syntax is supported.-See file format differences.-.PP-On large data files, hledger is slower and uses more memory than Ledger.-.SH TROUBLESHOOTING-.PP-Here are some issues you might encounter when you run hledger (and-remember you can also seek help from the IRC channel, mail list or bug-tracker):-.PP-\f[B]Successfully installed, but "No command \[aq]hledger\[aq]-found"\f[]-.PD 0-.P-.PD-stack and cabal install binaries into a special directory, which should-be added to your PATH environment variable.-Eg on unix\-like systems, that is ~/.local/bin and ~/.cabal/bin-respectively.-.PP-\f[B]I set a custom LEDGER_FILE, but hledger is still using the default-file\f[]-.PD 0-.P-.PD-\f[C]LEDGER_FILE\f[] should be a real environment variable, not just a-shell variable.-The command \f[C]env\ |\ grep\ LEDGER_FILE\f[] should show it.-You may need to use \f[C]export\f[].-Here\[aq]s an explanation.-.PP-\f[B]"Illegal byte sequence" or "Invalid or incomplete multibyte or wide-character" errors\f[]-.PD 0-.P-.PD-In order to handle non\-ascii letters and symbols (like £), hledger-needs an appropriate locale.-This is usually configured system\-wide; you can also configure it-temporarily.-The locale may need to be one that supports UTF\-8, if you built hledger-with GHC < 7.2 (or possibly always, I\[aq]m not sure yet).-.PP-Here\[aq]s an example of setting the locale temporarily, on ubuntu-gnu/linux:-.IP-.nf-\f[C]-$\ file\ my.journal-my.journal:\ UTF\-8\ Unicode\ text\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ <\-\ the\ file\ is\ UTF8\-encoded-$\ locale\ \-a-C-en_US.utf8\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ <\-\ a\ UTF8\-aware\ locale\ is\ available-POSIX-$\ LANG=en_US.utf8\ hledger\ \-f\ my.journal\ print\ \ \ #\ <\-\ use\ it\ for\ this\ command-\f[]-.fi-.PP-Here\[aq]s one way to set it permanently, there are probably better-ways:-.IP-.nf-\f[C]-$\ echo\ "export\ LANG=en_US.UTF\-8"\ >>~/.bash_profile-$\ bash\ \-\-login-\f[]-.fi-.PP-If we preferred to use eg \f[C]fr_FR.utf8\f[], we might have to install-that first:-.IP-.nf-\f[C]-$\ apt\-get\ install\ language\-pack\-fr-$\ locale\ \-a-C-en_US.utf8-fr_BE.utf8-fr_CA.utf8-fr_CH.utf8-fr_FR.utf8-fr_LU.utf8-POSIX-$\ LANG=fr_FR.utf8\ hledger\ \-f\ my.journal\ print-\f[]-.fi-.PP-Note some platforms allow variant locale spellings, but not all (ubuntu-accepts \f[C]fr_FR.UTF8\f[], mac osx requires exactly-\f[C]fr_FR.UTF\-8\f[]).+.TH "hledger" "1" "August 2019" "hledger 1.15" "hledger User Manuals"++++.SH NAME+.PP+hledger - a command-line accounting tool+.SH SYNOPSIS+.PP+\f[C]hledger [-f FILE] COMMAND [OPTIONS] [ARGS]\f[R]+.PD 0+.P+.PD+\f[C]hledger [-f FILE] ADDONCMD -- [OPTIONS] [ARGS]\f[R]+.PD 0+.P+.PD+\f[C]hledger\f[R]+.SH DESCRIPTION+.PP+hledger is a cross-platform program for tracking money, time, or any+other commodity, using double-entry accounting and a simple, editable+file format.+hledger is inspired by and largely compatible with ledger(1).+.PD 0+.P+.PD+Tested on unix, mac, windows, hledger aims to be a reliable, practical+tool for daily use.+.PP+This is hledger\[cq]s command-line interface (there are also curses and+web interfaces).+Its basic function is to read a plain text file describing financial+transactions (in accounting terms, a general journal) and print useful+reports on standard output, or export them as CSV.+hledger can also read some other file formats such as CSV files,+translating them to journal format.+Additionally, hledger lists other hledger-* executables found in the+user\[cq]s $PATH and can invoke them as subcommands.+.PP+hledger reads data from one or more files in hledger journal, timeclock,+timedot, or CSV format specified with \f[C]-f\f[R], or+\f[C]$LEDGER_FILE\f[R], or \f[C]$HOME/.hledger.journal\f[R] (on windows,+perhaps \f[C]C:/Users/USER/.hledger.journal\f[R]).+If using \f[C]$LEDGER_FILE\f[R], note this must be a real environment+variable, not a shell variable.+You can specify standard input with \f[C]-f-\f[R].+.PP+Transactions are dated movements of money between two (or more) named+accounts, and are recorded with journal entries like this:+.IP+.nf+\f[C]+2015/10/16 bought food+ expenses:food          $10+ assets:cash+\f[R]+.fi+.PP+For more about this format, see hledger_journal(5).+.PP+Most users use a text editor to edit the journal, usually with an editor+mode such as ledger-mode for added convenience.+hledger\[cq]s interactive add command is another way to record new+transactions.+hledger never changes existing transactions.+.PP+To get started, you can either save some entries like the above in+\f[C]\[ti]/.hledger.journal\f[R], or run \f[C]hledger add\f[R] and+follow the prompts.+Then try some commands like \f[C]hledger print\f[R] or+\f[C]hledger balance\f[R].+Run \f[C]hledger\f[R] with no arguments for a list of commands.+.SH EXAMPLES+.PP+Two simple transactions in hledger journal format:+.IP+.nf+\f[C]+2015/9/30 gift received+  assets:cash   $20+  income:gifts++2015/10/16 farmers market+  expenses:food    $10+  assets:cash+\f[R]+.fi+.PP+Some basic reports:+.IP+.nf+\f[C]+$ hledger print+2015/09/30 gift received+    assets:cash            $20+    income:gifts          $-20++2015/10/16 farmers market+    expenses:food           $10+    assets:cash            $-10+\f[R]+.fi+.IP+.nf+\f[C]+$ hledger accounts --tree+assets+  cash+expenses+  food+income+  gifts+\f[R]+.fi+.IP+.nf+\f[C]+$ hledger balance+                 $10  assets:cash+                 $10  expenses:food+                $-20  income:gifts+--------------------+                   0+\f[R]+.fi+.IP+.nf+\f[C]+$ hledger register cash+2015/09/30 gift received   assets:cash               $20           $20+2015/10/16 farmers market  assets:cash              $-10           $10+\f[R]+.fi+.PP+More commands:+.IP+.nf+\f[C]+$ hledger                                 # show available commands+$ hledger add                             # add more transactions to the journal file+$ hledger balance                         # all accounts with aggregated balances+$ hledger balance --help                  # show detailed help for balance command+$ hledger balance --depth 1               # only top-level accounts+$ hledger register                        # show account postings, with running total+$ hledger reg income                      # show postings to/from income accounts+$ hledger reg \[aq]assets:some bank:checking\[aq] # show postings to/from this checking account+$ hledger print desc:shop                 # show transactions with shop in the description+$ hledger activity -W                     # show transaction counts per week as a bar chart+\f[R]+.fi+.SH OPTIONS+.SS General options+.PP+To see general usage help, including general options which are supported+by most hledger commands, run \f[C]hledger -h\f[R].+.PP+General help options:+.TP+.B \f[C]-h --help\f[R]+show general usage (or after COMMAND, command usage)+.TP+.B \f[C]--version\f[R]+show version+.TP+.B \f[C]--debug[=N]\f[R]+show debug output (levels 1-9, default: 1)+.PP+General input options:+.TP+.B \f[C]-f FILE --file=FILE\f[R]+use a different input file.+For stdin, use - (default: \f[C]$LEDGER_FILE\f[R] or+\f[C]$HOME/.hledger.journal\f[R])+.TP+.B \f[C]--rules-file=RULESFILE\f[R]+Conversion rules file to use when reading CSV (default: FILE.rules)+.TP+.B \f[C]--separator=CHAR\f[R]+Field separator to expect when reading CSV (default: \[aq],\[aq])+.TP+.B \f[C]--alias=OLD=NEW\f[R]+rename accounts named OLD to NEW+.TP+.B \f[C]--anon\f[R]+anonymize accounts and payees+.TP+.B \f[C]--pivot FIELDNAME\f[R]+use some other field or tag for the account name+.TP+.B \f[C]-I --ignore-assertions\f[R]+ignore any failing balance assertions+.PP+General reporting options:+.TP+.B \f[C]-b --begin=DATE\f[R]+include postings/txns on or after this date+.TP+.B \f[C]-e --end=DATE\f[R]+include postings/txns before this date+.TP+.B \f[C]-D --daily\f[R]+multiperiod/multicolumn report by day+.TP+.B \f[C]-W --weekly\f[R]+multiperiod/multicolumn report by week+.TP+.B \f[C]-M --monthly\f[R]+multiperiod/multicolumn report by month+.TP+.B \f[C]-Q --quarterly\f[R]+multiperiod/multicolumn report by quarter+.TP+.B \f[C]-Y --yearly\f[R]+multiperiod/multicolumn report by year+.TP+.B \f[C]-p --period=PERIODEXP\f[R]+set start date, end date, and/or reporting interval all at once using+period expressions syntax+.TP+.B \f[C]--date2\f[R]+match the secondary date instead (see command help for other effects)+.TP+.B \f[C]-U --unmarked\f[R]+include only unmarked postings/txns (can combine with -P or -C)+.TP+.B \f[C]-P --pending\f[R]+include only pending postings/txns+.TP+.B \f[C]-C --cleared\f[R]+include only cleared postings/txns+.TP+.B \f[C]-R --real\f[R]+include only non-virtual postings+.TP+.B \f[C]-NUM --depth=NUM\f[R]+hide/aggregate accounts or postings more than NUM levels deep+.TP+.B \f[C]-E --empty\f[R]+show items with zero amount, normally hidden (and vice-versa in+hledger-ui/hledger-web)+.TP+.B \f[C]-B --cost\f[R]+convert amounts to their cost at transaction time (using the transaction+price, if any)+.TP+.B \f[C]-V --value\f[R]+convert amounts to their market value on the report end date (using the+most recent applicable market price, if any)+.TP+.B \f[C]--auto\f[R]+apply automated posting rules to modify transactions.+.TP+.B \f[C]--forecast\f[R]+apply periodic transaction rules to generate future transactions, to 6+months from now or report end date.+.PP+When a reporting option appears more than once in the command line, the+last one takes precedence.+.PP+Some reporting options can also be written as query arguments.+.SS Command options+.PP+To see options for a particular command, including command-specific+options, run: \f[C]hledger COMMAND -h\f[R].+.PP+Command-specific options must be written after the command name, eg:+\f[C]hledger print -x\f[R].+.PP+Additionally, if the command is an addon, you may need to put its+options after a double-hyphen, eg: \f[C]hledger ui -- --watch\f[R].+Or, you can run the addon executable directly:+\f[C]hledger-ui --watch\f[R].+.SS Command arguments+.PP+Most hledger commands accept arguments after the command name, which are+often a query, filtering the data in some way.+.SS Argument files+.PP+You can save a set of command line options/arguments in a file, one per+line, and then reuse them by writing \f[C]\[at]FILENAME\f[R] in a+command line.+To prevent this expansion of \f[C]\[at]\f[R]-arguments, precede them+with a \f[C]--\f[R] argument.+For more, see Save frequently used options.+.SS Special characters in arguments and queries+.PP+In shell command lines, option and argument values which contain+\[dq]problematic\[dq] characters, ie spaces, and also characters+significant to your shell such as \f[C]<\f[R], \f[C]>\f[R], \f[C](\f[R],+\f[C])\f[R], \f[C]|\f[R] and \f[C]$\f[R], should be escaped by enclosing+them in quotes or by writing backslashes before the characters.+Eg:+.PP+\f[C]hledger register -p \[aq]last year\[aq] \[dq]accounts receivable (receivable|payable)\[dq] amt:\[rs]>100\f[R].+.SS More escaping+.PP+Characters significant both to the shell and in regular expressions may+need one extra level of escaping.+These include parentheses, the pipe symbol and the dollar sign.+Eg, to match the dollar symbol, bash users should do:+.PP+\f[C]hledger balance cur:\[aq]\[rs]$\[aq]\f[R]+.PP+or:+.PP+\f[C]hledger balance cur:\[rs]\[rs]$\f[R]+.SS Even more escaping+.PP+When hledger runs an addon executable (eg you type \f[C]hledger ui\f[R],+hledger runs \f[C]hledger-ui\f[R]), it de-escapes command-line options+and arguments once, so you might need to \f[I]triple\f[R]-escape.+Eg in bash, running the ui command and matching the dollar sign,+it\[aq]s:+.PP+\f[C]hledger ui cur:\[aq]\[rs]\[rs]$\[aq]\f[R]+.PP+or:+.PP+\f[C]hledger ui cur:\[rs]\[rs]\[rs]\[rs]$\f[R]+.PP+If you asked why \f[I]four\f[R] slashes above, this may help:+.PP+.TS+tab(@);+l l.+T{+unescaped:+T}@T{+\f[C]$\f[R]+T}+T{+escaped:+T}@T{+\f[C]\[rs]$\f[R]+T}+T{+double-escaped:+T}@T{+\f[C]\[rs]\[rs]$\f[R]+T}+T{+triple-escaped:+T}@T{+\f[C]\[rs]\[rs]\[rs]\[rs]$\f[R]+T}+.TE+.PP+(The number of backslashes in fish shell is left as an exercise for the+reader.)+.PP+You can always avoid the extra escaping for addons by running the addon+directly:+.PP+\f[C]hledger-ui cur:\[rs]\[rs]$\f[R]+.SS Less escaping+.PP+Inside an argument file, or in the search field of hledger-ui or+hledger-web, or at a GHCI prompt, you need one less level of escaping+than at the command line.+And backslashes may work better than quotes.+Eg:+.PP+\f[C]ghci> :main balance cur:\[rs]$\f[R]+.SS Command line tips+.PP+If in doubt, keep things simple:+.IP \[bu] 2+write options after the command (\f[C]hledger CMD -OPTIONS ARGS\f[R])+.IP \[bu] 2+run add-on executables directly (\f[C]hledger-ui -OPTIONS ARGS\f[R])+.IP \[bu] 2+enclose problematic args in single quotes+.IP \[bu] 2+if needed, also add a backslash to escape regexp metacharacters+.PP+To find out exactly how a command line is being parsed, add+\f[C]--debug=2\f[R] to troubleshoot.+.SS Unicode characters+.PP+hledger is expected to handle non-ascii characters correctly:+.IP \[bu] 2+they should be parsed correctly in input files and on the command line,+by all hledger tools (add, iadd, hledger-web\[aq]s search/add/edit+forms, etc.)+.IP \[bu] 2+they should be displayed correctly by all hledger tools, and on-screen+alignment should be preserved.+.PP+This requires a well-configured environment.+Here are some tips:+.IP \[bu] 2+A system locale must be configured, and it must be one that can decode+the characters being used.+In bash, you can set a locale like this:+\f[C]export LANG=en_US.UTF-8\f[R].+There are some more details in Troubleshooting.+This step is essential - without it, hledger will quit on encountering a+non-ascii character (as with all GHC-compiled programs).+.IP \[bu] 2+your terminal software (eg Terminal.app, iTerm, CMD.exe, xterm..) must+support unicode+.IP \[bu] 2+the terminal must be using a font which includes the required unicode+glyphs+.IP \[bu] 2+the terminal should be configured to display wide characters as double+width (for report alignment)+.IP \[bu] 2+on Windows, for best results you should run hledger in the same kind of+environment in which it was built.+Eg hledger built in the standard CMD.EXE environment (like the binaries+on our download page) might show display problems when run in a cygwin+or msys terminal, and vice versa.+(See eg #961).+.SS Input files+.PP+hledger reads transactions from a data file (and the add command writes+to it).+By default this file is \f[C]$HOME/.hledger.journal\f[R] (or on Windows,+something like \f[C]C:/Users/USER/.hledger.journal\f[R]).+You can override this with the \f[C]$LEDGER_FILE\f[R] environment+variable:+.IP+.nf+\f[C]+$ setenv LEDGER_FILE \[ti]/finance/2016.journal+$ hledger stats+\f[R]+.fi+.PP+or with the \f[C]-f/--file\f[R] option:+.IP+.nf+\f[C]+$ hledger -f /some/file stats+\f[R]+.fi+.PP+The file name \f[C]-\f[R] (hyphen) means standard input:+.IP+.nf+\f[C]+$ cat some.journal | hledger -f-+\f[R]+.fi+.PP+Usually the data file is in hledger\[aq]s journal format, but it can+also be one of several other formats, listed below.+hledger detects the format automatically based on the file extension, or+if that is not recognised, by trying each built-in \[dq]reader\[dq] in+turn:+.PP+.TS+tab(@);+lw(7.6n) lw(31.2n) lw(31.2n).+T{+Reader:+T}@T{+Reads:+T}@T{+Used for file extensions:+T}+_+T{+\f[C]journal\f[R]+T}@T{+hledger\[aq]s journal format, also some Ledger journals+T}@T{+\f[C].journal\f[R] \f[C].j\f[R] \f[C].hledger\f[R] \f[C].ledger\f[R]+T}+T{+\f[C]timeclock\f[R]+T}@T{+timeclock files (precise time logging)+T}@T{+\f[C].timeclock\f[R]+T}+T{+\f[C]timedot\f[R]+T}@T{+timedot files (approximate time logging)+T}@T{+\f[C].timedot\f[R]+T}+T{+\f[C]csv\f[R]+T}@T{+comma-separated values (data interchange)+T}@T{+\f[C].csv\f[R]+T}+.TE+.PP+If needed (eg to ensure correct error messages when a file has the+\[dq]wrong\[dq] extension), you can force a specific reader/format by+prepending it to the file path with a colon.+Examples:+.IP+.nf+\f[C]+$ hledger -f csv:/some/csv-file.dat stats+$ echo \[aq]i 2009/13/1 08:00:00\[aq] | hledger print -ftimeclock:-+\f[R]+.fi+.PP+You can also specify multiple \f[C]-f\f[R] options, to read multiple+files as one big journal.+There are some limitations with this:+.IP \[bu] 2+directives in one file will not affect the other files+.IP \[bu] 2+balance assertions will not see any account balances from previous files+.PP+If you need those, either use the include directive, or concatenate the+files, eg: \f[C]cat a.journal b.journal | hledger -f- CMD\f[R].+.SS Smart dates+.PP+hledger\[aq]s user interfaces accept a flexible \[dq]smart date\[dq]+syntax (unlike dates in the journal file).+Smart dates allow some english words, can be relative to today\[aq]s+date, and can have less-significant date parts omitted (defaulting to+1).+.PP+Examples:+.PP+.TS+tab(@);+l l.+T{+\f[C]2004/10/1\f[R], \f[C]2004-01-01\f[R], \f[C]2004.9.1\f[R]+T}@T{+exact date, several separators allowed.+Year is 4+ digits, month is 1-12, day is 1-31+T}+T{+\f[C]2004\f[R]+T}@T{+start of year+T}+T{+\f[C]2004/10\f[R]+T}@T{+start of month+T}+T{+\f[C]10/1\f[R]+T}@T{+month and day in current year+T}+T{+\f[C]21\f[R]+T}@T{+day in current month+T}+T{+\f[C]october, oct\f[R]+T}@T{+start of month in current year+T}+T{+\f[C]yesterday, today, tomorrow\f[R]+T}@T{+-1, 0, 1 days from today+T}+T{+\f[C]last/this/next day/week/month/quarter/year\f[R]+T}@T{+-1, 0, 1 periods from the current period+T}+T{+\f[C]20181201\f[R]+T}@T{+8 digit YYYYMMDD with valid year month and day+T}+T{+\f[C]201812\f[R]+T}@T{+6 digit YYYYMM with valid year and month+T}+.TE+.PP+Counterexamples - malformed digit sequences might give surprising+results:+.PP+.TS+tab(@);+l l.+T{+\f[C]201813\f[R]+T}@T{+6 digits with an invalid month is parsed as start of 6-digit year+T}+T{+\f[C]20181301\f[R]+T}@T{+8 digits with an invalid month is parsed as start of 8-digit year+T}+T{+\f[C]20181232\f[R]+T}@T{+8 digits with an invalid day gives an error+T}+T{+\f[C]201801012\f[R]+T}@T{+9+ digits beginning with a valid YYYYMMDD gives an error+T}+.TE+.SS Report start & end date+.PP+Most hledger reports show the full span of time represented by the+journal data, by default.+So, the effective report start and end dates will be the earliest and+latest transaction or posting dates found in the journal.+.PP+Often you will want to see a shorter time span, such as the current+month.+You can specify a start and/or end date using \f[C]-b/--begin\f[R],+\f[C]-e/--end\f[R], \f[C]-p/--period\f[R] or a \f[C]date:\f[R] query+(described below).+All of these accept the smart date syntax.+.PP+Some notes:+.IP \[bu] 2+As in Ledger, end dates are exclusive, so you need to write the date+\f[I]after\f[R] the last day you want to include.+.IP \[bu] 2+As noted in reporting options: among start/end dates specified with+\f[I]options\f[R], the last (i.e.+right-most) option takes precedence.+.IP \[bu] 2+The effective report start and end dates are the intersection of the+start/end dates from options and that from \f[C]date:\f[R] queries.+That is, \f[C]date:2019-01 date:2019 -p\[aq]2000 to 2030\[aq]\f[R]+yields January 2019, the smallest common time span.+.PP+Examples:+.PP+.TS+tab(@);+l l.+T{+\f[C]-b 2016/3/17\f[R]+T}@T{+begin on St.+Patrick\[aq]s day 2016+T}+T{+\f[C]-e 12/1\f[R]+T}@T{+end at the start of december 1st of the current year (11/30 will be the+last date included)+T}+T{+\f[C]-b thismonth\f[R]+T}@T{+all transactions on or after the 1st of the current month+T}+T{+\f[C]-p thismonth\f[R]+T}@T{+all transactions in the current month+T}+T{+\f[C]date:2016/3/17-\f[R]+T}@T{+the above written as queries instead+T}+T{+\f[C]date:-12/1\f[R]+T}@T{+T}+T{+\f[C]date:thismonth-\f[R]+T}@T{+T}+T{+\f[C]date:thismonth\f[R]+T}@T{+T}+.TE+.SS Report intervals+.PP+A report interval can be specified so that commands like register,+balance and activity will divide their reports into multiple subperiods.+The basic intervals can be selected with one of \f[C]-D/--daily\f[R],+\f[C]-W/--weekly\f[R], \f[C]-M/--monthly\f[R], \f[C]-Q/--quarterly\f[R],+or \f[C]-Y/--yearly\f[R].+More complex intervals may be specified with a period expression.+Report intervals can not be specified with a query.+.SS Period expressions+.PP+The \f[C]-p/--period\f[R] option accepts period expressions, a shorthand+way of expressing a start date, end date, and/or report interval all at+once.+.PP+Here\[aq]s a basic period expression specifying the first quarter of+2009.+Note, hledger always treats start dates as inclusive and end dates as+exclusive:+.PP+\f[C]-p \[dq]from 2009/1/1 to 2009/4/1\[dq]\f[R]+.PP+Keywords like \[dq]from\[dq] and \[dq]to\[dq] are optional, and so are+the spaces, as long as you don\[aq]t run two dates together.+\[dq]to\[dq] can also be written as \[dq]-\[dq].+These are equivalent to the above:+.PP+.TS+tab(@);+l.+T{+\f[C]-p \[dq]2009/1/1 2009/4/1\[dq]\f[R]+T}+T{+\f[C]-p2009/1/1to2009/4/1\f[R]+T}+T{+\f[C]-p2009/1/1-2009/4/1\f[R]+T}+.TE+.PP+Dates are smart dates, so if the current year is 2009, the above can+also be written as:+.PP+.TS+tab(@);+l.+T{+\f[C]-p \[dq]1/1 4/1\[dq]\f[R]+T}+T{+\f[C]-p \[dq]january-apr\[dq]\f[R]+T}+T{+\f[C]-p \[dq]this year to 4/1\[dq]\f[R]+T}+.TE+.PP+If you specify only one date, the missing start or end date will be the+earliest or latest transaction in your journal:+.PP+.TS+tab(@);+l l.+T{+\f[C]-p \[dq]from 2009/1/1\[dq]\f[R]+T}@T{+everything after january 1, 2009+T}+T{+\f[C]-p \[dq]from 2009/1\[dq]\f[R]+T}@T{+the same+T}+T{+\f[C]-p \[dq]from 2009\[dq]\f[R]+T}@T{+the same+T}+T{+\f[C]-p \[dq]to 2009\[dq]\f[R]+T}@T{+everything before january 1, 2009+T}+.TE+.PP+A single date with no \[dq]from\[dq] or \[dq]to\[dq] defines both the+start and end date like so:+.PP+.TS+tab(@);+l l.+T{+\f[C]-p \[dq]2009\[dq]\f[R]+T}@T{+the year 2009; equivalent to \[dq]2009/1/1 to 2010/1/1\[dq]+T}+T{+\f[C]-p \[dq]2009/1\[dq]\f[R]+T}@T{+the month of jan; equivalent to \[dq]2009/1/1 to 2009/2/1\[dq]+T}+T{+\f[C]-p \[dq]2009/1/1\[dq]\f[R]+T}@T{+just that day; equivalent to \[dq]2009/1/1 to 2009/1/2\[dq]+T}+.TE+.PP+The argument of \f[C]-p\f[R] can also begin with, or be, a report+interval expression.+The basic report intervals are \f[C]daily\f[R], \f[C]weekly\f[R],+\f[C]monthly\f[R], \f[C]quarterly\f[R], or \f[C]yearly\f[R], which have+the same effect as the+\f[C]-D\f[R],\f[C]-W\f[R],\f[C]-M\f[R],\f[C]-Q\f[R], or \f[C]-Y\f[R]+flags.+Between report interval and start/end dates (if any), the word+\f[C]in\f[R] is optional.+Examples:+.PP+.TS+tab(@);+l.+T{+\f[C]-p \[dq]weekly from 2009/1/1 to 2009/4/1\[dq]\f[R]+T}+T{+\f[C]-p \[dq]monthly in 2008\[dq]\f[R]+T}+T{+\f[C]-p \[dq]quarterly\[dq]\f[R]+T}+.TE+.PP+Note that \f[C]weekly\f[R], \f[C]monthly\f[R], \f[C]quarterly\f[R] and+\f[C]yearly\f[R] intervals will always start on the first day on week,+month, quarter or year accordingly, and will end on the last day of same+period, even if associated period expression specifies different+explicit start and end date.+.PP+For example:+.PP+.TS+tab(@);+l.+T{+\f[C]-p \[dq]weekly from 2009/1/1 to 2009/4/1\[dq]\f[R] -- starts on+2008/12/29, closest preceeding Monday+T}+T{+\f[C]-p \[dq]monthly in 2008/11/25\[dq]\f[R] -- starts on 2018/11/01+T}+T{+\f[C]-p \[dq]quarterly from 2009-05-05 to 2009-06-01\[dq]\f[R] - starts+on 2009/04/01, ends on 2009/06/30, which are first and last days of Q2+2009+T}+T{+\f[C]-p \[dq]yearly from 2009-12-29\[dq]\f[R] - starts on 2009/01/01,+first day of 2009+T}+.TE+.PP+The following more complex report intervals are also supported:+\f[C]biweekly\f[R], \f[C]bimonthly\f[R],+\f[C]every day|week|month|quarter|year\f[R],+\f[C]every N days|weeks|months|quarters|years\f[R].+.PP+All of these will start on the first day of the requested period and end+on the last one, as described above.+.PP+Examples:+.PP+.TS+tab(@);+l.+T{+\f[C]-p \[dq]bimonthly from 2008\[dq]\f[R] -- periods will have+boundaries on 2008/01/01, 2008/03/01, ...+T}+T{+\f[C]-p \[dq]every 2 weeks\[dq]\f[R] -- starts on closest preceeding+Monday+T}+T{+\f[C]-p \[dq]every 5 month from 2009/03\[dq]\f[R] -- periods will have+boundaries on 2009/03/01, 2009/08/01, ...+T}+.TE+.PP+If you want intervals that start on arbitrary day of your choosing and+span a week, month or year, you need to use any of the following:+.PP+\f[C]every Nth day of week\f[R], \f[C]every <weekday>\f[R],+\f[C]every Nth day [of month]\f[R],+\f[C]every Nth weekday [of month]\f[R], \f[C]every MM/DD [of year]\f[R],+\f[C]every Nth MMM [of year]\f[R], \f[C]every MMM Nth [of year]\f[R].+.PP+Examples:+.PP+.TS+tab(@);+l.+T{+\f[C]-p \[dq]every 2nd day of week\[dq]\f[R] -- periods will go from Tue+to Tue+T}+T{+\f[C]-p \[dq]every Tue\[dq]\f[R] -- same+T}+T{+\f[C]-p \[dq]every 15th day\[dq]\f[R] -- period boundaries will be on+15th of each month+T}+T{+\f[C]-p \[dq]every 2nd Monday\[dq]\f[R] -- period boundaries will be on+second Monday of each month+T}+T{+\f[C]-p \[dq]every 11/05\[dq]\f[R] -- yearly periods with boundaries on+5th of Nov+T}+T{+\f[C]-p \[dq]every 5th Nov\[dq]\f[R] -- same+T}+T{+\f[C]-p \[dq]every Nov 5th\[dq]\f[R] -- same+T}+.TE+.PP+Show historical balances at end of 15th each month (N is exclusive end+date):+.PP+\f[C]hledger balance -H -p \[dq]every 16th day\[dq]\f[R]+.PP+Group postings from start of wednesday to end of next tuesday (N is+start date and exclusive end date):+.PP+\f[C]hledger register checking -p \[dq]every 3rd day of week\[dq]\f[R]+.SS Depth limiting+.PP+With the \f[C]--depth N\f[R] option (short form: \f[C]-N\f[R]), commands+like account, balance and register will show only the uppermost accounts+in the account tree, down to level N.+Use this when you want a summary with less detail.+This flag has the same effect as a \f[C]depth:\f[R] query argument (so+\f[C]-2\f[R], \f[C]--depth=2\f[R] or \f[C]depth:2\f[R] are basically+equivalent).+.SS Pivoting+.PP+Normally hledger sums amounts, and organizes them in a hierarchy, based+on account name.+The \f[C]--pivot FIELD\f[R] option causes it to sum and organize+hierarchy based on the value of some other field instead.+FIELD can be: \f[C]code\f[R], \f[C]description\f[R], \f[C]payee\f[R],+\f[C]note\f[R], or the full name (case insensitive) of any tag.+As with account names, values containing \f[C]colon:separated:parts\f[R]+will be displayed hierarchically in reports.+.PP+\f[C]--pivot\f[R] is a general option affecting all reports; you can+think of hledger transforming the journal before any other processing,+replacing every posting\[aq]s account name with the value of the+specified field on that posting, inheriting it from the transaction or+using a blank value if it\[aq]s not present.+.PP+An example:+.IP+.nf+\f[C]+2016/02/16 Member Fee Payment+    assets:bank account                    2 EUR+    income:member fees                    -2 EUR  ; member: John Doe+\f[R]+.fi+.PP+Normal balance report showing account names:+.IP+.nf+\f[C]+$ hledger balance+               2 EUR  assets:bank account+              -2 EUR  income:member fees+--------------------+                   0+\f[R]+.fi+.PP+Pivoted balance report, using member: tag values instead:+.IP+.nf+\f[C]+$ hledger balance --pivot member+               2 EUR+              -2 EUR  John Doe+--------------------+                   0+\f[R]+.fi+.PP+One way to show only amounts with a member: value (using a query,+described below):+.IP+.nf+\f[C]+$ hledger balance --pivot member tag:member=.+              -2 EUR  John Doe+--------------------+              -2 EUR+\f[R]+.fi+.PP+Another way (the acct: query matches against the pivoted \[dq]account+name\[dq]):+.IP+.nf+\f[C]+$ hledger balance --pivot member acct:.+              -2 EUR  John Doe+--------------------+              -2 EUR+\f[R]+.fi+.SS Valuation+.SS -B: Cost+.PP+The \f[C]-B/--cost\f[R] flag converts amounts to their cost (or selling+price) at transaction time, if they have a transaction price specified.+This flag is equivalent to \f[C]--value=cost\f[R], described below.+.SS -V: Market value+.PP+The \f[C]-V/--market\f[R] flag converts reported amounts to their market+value in a default valuation commodity, using the historical market+prices in effect on a default valuation date.+.PP+For single period reports, the valuation date is today.+For multiperiod reports, it is the last day of each subperiod.+.PP+The valuation commodity will be the one referenced in the latest+applicable market price dated on or before the valuation date.+If most of your P declarations lead to a single home currency, this will+usually be what you want.+.PP+Unlike the similar flag in Ledger, it does not infer market prices from+transaction prices.+In hledger, -B uses transaction prices, -V and -X use market prices.+.PP+It is equivalent to \f[C]--value=now\f[R] or \f[C]--value=end\f[R].+.PP+Here\[aq]s a quick example:+.IP+.nf+\f[C]+# one euro is worth this many dollars from nov 1+P 2016/11/01 \[Eu] $1.10++# purchase some euros on nov 3+2016/11/3+    assets:euros        \[Eu]100+    assets:checking++# the euro is worth fewer dollars by dec 21+P 2016/12/21 \[Eu] $1.03+\f[R]+.fi+.PP+How many euros do I have ?+.IP+.nf+\f[C]+$ hledger -f t.j bal -N euros+                \[Eu]100  assets:euros+\f[R]+.fi+.PP+What are they worth at end of nov 3 ?+.IP+.nf+\f[C]+$ hledger -f t.j bal -N euros -V -e 2016/11/4+             $110.00  assets:euros+\f[R]+.fi+.PP+What are they worth after 2016/12/21 ?+(no report end date specified, defaults to today)+.IP+.nf+\f[C]+$ hledger -f t.j bal -N euros -V+             $103.00  assets:euros+\f[R]+.fi+.SS -X: Market value in specified commodity+.PP+The \f[C]-X/--exchange\f[R] option is like \f[C]-V/--market\f[R] except+it takes a commodity symbol argument, so that you can select a different+target commodity.+It is similar to the same option in Ledger, with the same caveat+mentioned for \f[C]-V\f[R]/\f[C]--value\f[R] above.+It is equivalent to \f[C]--value=now,COMM\f[R] or+\f[C]--value=end,COMM\f[R]; for more details, read on.+.SS --value+.PP+\f[I](experimental, added 201905)\f[R]+.PP+\f[C]-B\f[R], \f[C]-V\f[R] and \f[C]-X\f[R] are special cases of the+more general \f[C]--value\f[R] option:+.IP+.nf+\f[C]+ --value=TYPE[,COMM]  TYPE is cost, end, now or YYYY-MM-DD.+                      COMM is an optional commodity symbol.+                      Shows amounts converted to:+                      - cost commodity using transaction prices (then optionally to COMM using market prices at period end(s))+                      - default valuation commodity (or COMM) using market prices at period end(s)+                      - default valuation commodity (or COMM) using current market prices+                      - default valuation commodity (or COMM) using market prices at some date+\f[R]+.fi+.SS Valuation type+.PP+TYPE is one of these keywords, or their first letter, or a date (which+must be 8 digits with \f[C]-\f[R] or \f[C]/\f[R] or \f[C].\f[R]+separators):+.TP+.B \f[C]--value=cost\f[R]+Convert amounts to cost, using the prices recorded in transactions.+\f[C]-B\f[R]/\f[C]--cost\f[R] is equivalent to this.+.TP+.B \f[C]--value=end\f[R]+Convert amounts to their value in default valuation commodity using+market prices on the last day of the report period (or of each subperiod+in a multiperiod report).+When no report period is specified, uses the journal\[aq]s last+transaction date.+.TP+.B \f[C]--value=now\f[R]+Convert amounts to their value in default valuation commodity using+current market prices (as of when report is generated).+\f[C]-V\f[R]/\f[C]--market\f[R] is equivalent to this.+.TP+.B \f[C]--value=YYYY-MM-DD\f[R]+Convert amounts to their value in default valuation commodity using+market prices on this date.+Eg \f[C]--value=2019-04-25\f[R].+.SS Valuation commodity+.PP+The default valuation commodity is the commodity mentioned in the most+recent applicable market price declaration.+When all your price declarations lead to a single home currency, this+will usually do what you want.+.PP+To select a different valuation commodity: write the commodity symbol+after the valuation type, separated by a comma (eg:+\f[B]\f[CB]--value=now,EUR\f[B]\f[R]).+This will use, in this preferred order:+.IP \[bu] 2+declared prices (from source commodity to valuation commodity)+.IP \[bu] 2+reverse prices (declared prices from valuation to source commodity,+inverted)+.IP \[bu] 2+indirect prices (prices calculated from the shortest chain of declared+or reverse prices from source to valuation commodity).+.SS --value examples+.PP+Here are the effects of \f[C]--value\f[R] as seen with \f[C]print\f[R]:+.IP+.nf+\f[C]+P 2000-01-01 A  1 B+P 2000-02-01 A  2 B+P 2000-03-01 A  3 B+P 2000-04-01 A  4 B++2000-01-01+  (a)      1 A \[at] 5 B++2000-02-01+  (a)      1 A \[at] 6 B++2000-03-01+  (a)      1 A \[at] 7 B+\f[R]+.fi+.PP+Show the cost of each posting:+.IP+.nf+\f[C]+$ hledger -f- print --value=cost+2000/01/01+    (a)             5 B++2000/02/01+    (a)             6 B++2000/03/01+    (a)             7 B+\f[R]+.fi+.PP+Show the value as of the last day of the report period (2000-02-29):+.IP+.nf+\f[C]+$ hledger -f- print --value=end date:2000/01-2000/03+2000-01-01+    (a)             2 B++2000-02-01+    (a)             2 B+\f[R]+.fi+.PP+With no report period specified, that shows the value as of the last day+of the journal (2000-03-01):+.IP+.nf+\f[C]+$ hledger -f- print --value=end+2000/01/01+    (a)             3 B++2000/02/01+    (a)             3 B++2000/03/01+    (a)             3 B+\f[R]+.fi+.PP+Show the current value (the 2000-04-01 price is still in effect today):+.IP+.nf+\f[C]+$ hledger -f- print --value=now+2000-01-01+    (a)             4 B++2000-02-01+    (a)             4 B++2000-03-01+    (a)             4 B+\f[R]+.fi+.PP+Show the value on 2000/01/15:+.IP+.nf+\f[C]+$ hledger -f- print --value=2000-01-15+2000/01/01+    (a)             1 B++2000/02/01+    (a)             1 B++2000/03/01+    (a)             1 B+\f[R]+.fi+.PP+You may need to explicitly set a commodity\[aq]s display style, when+reverse prices are used.+Eg this output might be surprising:+.IP+.nf+\f[C]+P 2000-01-01 A 2B++2000-01-01+  a  1B+  b+\f[R]+.fi+.IP+.nf+\f[C]+$ hledger print -x -X A+2000/01/01+    a               0+    b               0+\f[R]+.fi+.PP+Explanation: because there\[aq]s no amount or commodity directive+specifying a display style for A, 0.5A gets the default style, which+shows no decimal digits.+Because the displayed amount looks like zero, the commodity symbol and+minus sign are not displayed either.+Adding a commodity directive sets a more useful display style for A:+.IP+.nf+\f[C]+P 2000-01-01 A 2B+commodity 0.00A++2000-01-01+  a  1B+  b+\f[R]+.fi+.IP+.nf+\f[C]+$ hledger print -X A+2000/01/01+    a           0.50A+    b          -0.50A+\f[R]+.fi+.SS Effect of --value on reports+.PP+Below is how \f[C]--value\f[R] affects each of hledger\[aq]s reports,+currently.+You\[aq]re not expected to remember all this, but when troubleshooting a+report, look here.+If you find problems - useless reports, misbehaving reports, or error+messages being printed - please report them (with reproducible examples)+eg at #329.+.PP+.TS+tab(@);+lw(12.5n) lw(13.6n) lw(25.4n) lw(18.4n).+T{+Report type+T}@T{+\f[C]--value\f[R] \f[C]cost\f[R]\ +T}@T{+\f[C]--value\f[R] \f[C]end\f[R]\ +T}@T{+\f[C]--value\f[R] \f[C]DATE\f[R]/\f[C]now\f[R]\ +T}+_+T{+\f[B]print\f[R]+T}@T{+T}@T{+T}@T{+T}+T{+posting amounts+T}@T{+cost, as recorded in transaction+T}@T{+market value at report end+T}@T{+market value at DATE+T}+T{+balance assertions/assignments+T}@T{+show unvalued+T}@T{+show unvalued+T}@T{+show unvalued+T}+T{+\f[B]register\f[R]+T}@T{+T}@T{+T}@T{+T}+T{+starting balance with -H+T}@T{+cost of starting balance+T}@T{+market value at day before report start+T}@T{+market value at DATE+T}+T{+posting amounts+T}@T{+cost+T}@T{+market value at report end+T}@T{+market value at DATE+T}+T{+posting amounts, multiperiod+T}@T{+summarised cost+T}@T{+market value each summary posting at period end+T}@T{+market value each summary posting at DATE+T}+T{+running total/average+T}@T{+sum/average of the displayed values+T}@T{+sum/average of the displayed values+T}@T{+sum/average of the displayed values+T}+T{+\f[B]balance (bs, cf, is..)\f[R]+T}@T{+T}@T{+T}@T{+T}+T{+starting balances with -H+T}@T{+costs of starting balances+T}@T{+market value at day before report start of sum of previous postings+T}@T{+market value at DATE of sum of previous postings+T}+T{+balances, simple balance report+T}@T{+summed costs+T}@T{+market value at period end of sum of postings+T}@T{+market value at DATE of sum of postings+T}+T{+balances, multiperiod report+T}@T{+summed costs+T}@T{+market value at period end of sum of postings+T}@T{+market value at DATE of sum of postings+T}+T{+budget amounts with --budget+T}@T{+costs of budget amounts+T}@T{+budget-setting periodic txns are valued at period end+T}@T{+budget-setting periodic txns are valued at DATE+T}+T{+column/row/grand totals/averages+T}@T{+sum/average of the displayed values+T}@T{+market value at period end of sum/average of postings+T}@T{+market value at DATE of sum/average of postings+T}+.TE+.SS Combining -B, -V, -X, --value+.PP+The rightmost of these flags wins.+.SS Output destination+.PP+Some commands (print, register, stats, the balance commands) can write+their output to a destination other than the console.+This is controlled by the \f[C]-o/--output-file\f[R] option.+.IP+.nf+\f[C]+$ hledger balance -o -     # write to stdout (the default)+$ hledger balance -o FILE  # write to FILE+\f[R]+.fi+.SS Output format+.PP+Some commands can write their output in other formats.+Eg print and register can output CSV, and the balance commands can+output CSV or HTML.+This is controlled by the \f[C]-O/--output-format\f[R] option, or by+specifying a \f[C].csv\f[R] or \f[C].html\f[R] file extension with+\f[C]-o/--output-file\f[R].+.IP+.nf+\f[C]+$ hledger balance -O csv       # write CSV to stdout+$ hledger balance -o FILE.csv  # write CSV to FILE.csv+\f[R]+.fi+.SS Regular expressions+.PP+hledger uses regular expressions in a number of places:+.IP \[bu] 2+query terms, on the command line and in the hledger-web search form:+\f[C]REGEX\f[R], \f[C]desc:REGEX\f[R], \f[C]cur:REGEX\f[R],+\f[C]tag:...=REGEX\f[R]+.IP \[bu] 2+CSV rules conditional blocks: \f[C]if REGEX ...\f[R]+.IP \[bu] 2+account alias directives and options:+\f[C]alias /REGEX/ = REPLACEMENT\f[R],+\f[C]--alias /REGEX/=REPLACEMENT\f[R]+.PP+hledger\[aq]s regular expressions come from the regex-tdfa library.+In general they:+.IP \[bu] 2+are case insensitive+.IP \[bu] 2+are infix matching (do not need to match the entire thing being matched)+.IP \[bu] 2+are POSIX extended regular expressions+.IP \[bu] 2+also support GNU word boundaries (\[rs]<, \[rs]>, \[rs]b, \[rs]B)+.IP \[bu] 2+and parenthesised capturing groups and numeric backreferences in+replacement strings+.IP \[bu] 2+do not support mode modifiers like (?s)+.PP+Some things to note:+.IP \[bu] 2+In the \f[C]alias\f[R] directive and \f[C]--alias\f[R] option, regular+expressions must be enclosed in forward slashes (\f[C]/REGEX/\f[R]).+Elsewhere in hledger, these are not required.+.IP \[bu] 2+In queries, to match a regular expression metacharacter like \f[C]$\f[R]+as a literal character, prepend a backslash.+Eg to search for amounts with the dollar sign in hledger-web, write+\f[C]cur:\[rs]$\f[R].+.IP \[bu] 2+On the command line, some metacharacters like \f[C]$\f[R] have a special+meaning to the shell and so must be escaped at least once more.+See Special characters.+.SH QUERIES+.PP+One of hledger\[aq]s strengths is being able to quickly report on+precise subsets of your data.+Most commands accept an optional query expression, written as arguments+after the command name, to filter the data by date, account name or+other criteria.+The syntax is similar to a web search: one or more space-separated+search terms, quotes to enclose whitespace, prefixes to match specific+fields, a not: prefix to negate the match.+.PP+We do not yet support arbitrary boolean combinations of search terms;+instead most commands show transactions/postings/accounts which match+(or negatively match):+.IP \[bu] 2+any of the description terms AND+.IP \[bu] 2+any of the account terms AND+.IP \[bu] 2+any of the status terms AND+.IP \[bu] 2+all the other terms.+.PP+The print command instead shows transactions which:+.IP \[bu] 2+match any of the description terms AND+.IP \[bu] 2+have any postings matching any of the positive account terms AND+.IP \[bu] 2+have no postings matching any of the negative account terms AND+.IP \[bu] 2+match all the other terms.+.PP+The following kinds of search terms can be used.+Remember these can also be prefixed with \f[B]\f[CB]not:\f[B]\f[R], eg+to exclude a particular subaccount.+.TP+.B \f[B]\f[CB]REGEX\f[B], \f[CB]acct:REGEX\f[B]\f[R]+match account names by this regular expression.+(With no prefix, \f[C]acct:\f[R] is assumed.)+same as above+.TP+.B \f[B]\f[CB]amt:N, amt:<N, amt:<=N, amt:>N, amt:>=N\f[B]\f[R]+match postings with a single-commodity amount that is equal to, less+than, or greater than N.+(Multi-commodity amounts are not tested, and will always match.) The+comparison has two modes: if N is preceded by a + or - sign (or is 0),+the two signed numbers are compared.+Otherwise, the absolute magnitudes are compared, ignoring sign.+.TP+.B \f[B]\f[CB]code:REGEX\f[B]\f[R]+match by transaction code (eg check number)+.TP+.B \f[B]\f[CB]cur:REGEX\f[B]\f[R]+match postings or transactions including any amounts whose+currency/commodity symbol is fully matched by REGEX.+(For a partial match, use \f[C].*REGEX.*\f[R]).+Note, to match characters which are regex-significant, like the dollar+sign (\f[C]$\f[R]), you need to prepend \f[C]\[rs]\f[R].+And when using the command line you need to add one more level of+quoting to hide it from the shell, so eg do:+\f[C]hledger print cur:\[aq]\[rs]$\[aq]\f[R] or+\f[C]hledger print cur:\[rs]\[rs]$\f[R].+.TP+.B \f[B]\f[CB]desc:REGEX\f[B]\f[R]+match transaction descriptions.+.TP+.B \f[B]\f[CB]date:PERIODEXPR\f[B]\f[R]+match dates within the specified period.+PERIODEXPR is a period expression (with no report interval).+Examples: \f[C]date:2016\f[R], \f[C]date:thismonth\f[R],+\f[C]date:2000/2/1-2/15\f[R], \f[C]date:lastweek-\f[R].+If the \f[C]--date2\f[R] command line flag is present, this matches+secondary dates instead.+.TP+.B \f[B]\f[CB]date2:PERIODEXPR\f[B]\f[R]+match secondary dates within the specified period.+.TP+.B \f[B]\f[CB]depth:N\f[B]\f[R]+match (or display, depending on command) accounts at or above this depth+.TP+.B \f[B]\f[CB]note:REGEX\f[B]\f[R]+match transaction notes (part of description right of \f[C]|\f[R], or+whole description when there\[aq]s no \f[C]|\f[R])+.TP+.B \f[B]\f[CB]payee:REGEX\f[B]\f[R]+match transaction payee/payer names (part of description left of+\f[C]|\f[R], or whole description when there\[aq]s no \f[C]|\f[R])+.TP+.B \f[B]\f[CB]real:, real:0\f[B]\f[R]+match real or virtual postings respectively+.TP+.B \f[B]\f[CB]status:, status:!, status:*\f[B]\f[R]+match unmarked, pending, or cleared transactions respectively+.TP+.B \f[B]\f[CB]tag:REGEX[=REGEX]\f[B]\f[R]+match by tag name, and optionally also by tag value.+Note a tag: query is considered to match a transaction if it matches any+of the postings.+Also remember that postings inherit the tags of their parent+transaction.+.PP+The following special search term is used automatically in hledger-web,+only:+.TP+.B \f[B]\f[CB]inacct:ACCTNAME\f[B]\f[R]+tells hledger-web to show the transaction register for this account.+Can be filtered further with \f[C]acct\f[R] etc.+.PP+Some of these can also be expressed as command-line options (eg+\f[C]depth:2\f[R] is equivalent to \f[C]--depth 2\f[R]).+Generally you can mix options and query arguments, and the resulting+query will be their intersection (perhaps excluding the+\f[C]-p/--period\f[R] option).+.SH COMMANDS+.PP+hledger provides a number of subcommands; \f[C]hledger\f[R] with no+arguments shows a list.+.PP+If you install additional \f[C]hledger-*\f[R] packages, or if you put+programs or scripts named \f[C]hledger-NAME\f[R] in your PATH, these+will also be listed as subcommands.+.PP+Run a subcommand by writing its name as first argument (eg+\f[C]hledger incomestatement\f[R]).+You can also write one of the standard short aliases displayed in+parentheses in the command list (\f[C]hledger b\f[R]), or any any+unambiguous prefix of a command name (\f[C]hledger inc\f[R]).+.PP+Here are all the builtin commands in alphabetical order.+See also \f[C]hledger\f[R] for a more organised command list, and+\f[C]hledger CMD -h\f[R] for detailed command help.+.SS accounts+.PP+accounts, a+.PD 0+.P+.PD+Show account names.+.PP+This command lists account names, either declared with account+directives (--declared), posted to (--used), or both (the default).+With query arguments, only matched account names and account names+referenced by matched postings are shown.+It shows a flat list by default.+With \f[C]--tree\f[R], it uses indentation to show the account+hierarchy.+In flat mode you can add \f[C]--drop N\f[R] to omit the first few+account name components.+Account names can be depth-clipped with \f[C]depth:N\f[R] or+\f[C]--depth N\f[R] or \f[C]-N\f[R].+.PP+Examples:+.IP+.nf+\f[C]+$ hledger accounts+assets:bank:checking+assets:bank:saving+assets:cash+expenses:food+expenses:supplies+income:gifts+income:salary+liabilities:debts+\f[R]+.fi+.SS activity+.PP+activity+.PD 0+.P+.PD+Show an ascii barchart of posting counts per interval.+.PP+The activity command displays an ascii histogram showing transaction+counts by day, week, month or other reporting interval (by day is the+default).+With query arguments, it counts only matched transactions.+.PP+Examples:+.IP+.nf+\f[C]+$ hledger activity --quarterly+2008-01-01 **+2008-04-01 *******+2008-07-01 +2008-10-01 **+\f[R]+.fi+.SS add+.PP+add+.PD 0+.P+.PD+Prompt for transactions and add them to the journal.+.PP+Many hledger users edit their journals directly with a text editor, or+generate them from CSV.+For more interactive data entry, there is the \f[C]add\f[R] command,+which prompts interactively on the console for new transactions, and+appends them to the journal file (if there are multiple+\f[C]-f FILE\f[R] options, the first file is used.) Existing+transactions are not changed.+This is the only hledger command that writes to the journal file.+.PP+To use it, just run \f[C]hledger add\f[R] and follow the prompts.+You can add as many transactions as you like; when you are finished,+enter \f[C].\f[R] or press control-d or control-c to exit.+.PP+Features:+.IP \[bu] 2+add tries to provide useful defaults, using the most similar (by+description) recent transaction (filtered by the query, if any) as a+template.+.IP \[bu] 2+You can also set the initial defaults with command line arguments.+.IP \[bu] 2+Readline-style edit keys can be used during data entry.+.IP \[bu] 2+The tab key will auto-complete whenever possible - accounts,+descriptions, dates (\f[C]yesterday\f[R], \f[C]today\f[R],+\f[C]tomorrow\f[R]).+If the input area is empty, it will insert the default value.+.IP \[bu] 2+If the journal defines a default commodity, it will be added to any bare+numbers entered.+.IP \[bu] 2+A parenthesised transaction code may be entered following a date.+.IP \[bu] 2+Comments and tags may be entered following a description or amount.+.IP \[bu] 2+If you make a mistake, enter \f[C]<\f[R] at any prompt to restart the+transaction.+.IP \[bu] 2+Input prompts are displayed in a different colour when the terminal+supports it.+.PP+Example (see the tutorial for a detailed explanation):+.IP+.nf+\f[C]+$ hledger add+Adding transactions to journal file /src/hledger/examples/sample.journal+Any command line arguments will be used as defaults.+Use tab key to complete, readline keys to edit, enter to accept defaults.+An optional (CODE) may follow transaction dates.+An optional ; COMMENT may follow descriptions or amounts.+If you make a mistake, enter < at any prompt to restart the transaction.+To end a transaction, enter . when prompted.+To quit, enter . at a date prompt or press control-d or control-c.+Date [2015/05/22]: +Description: supermarket+Account 1: expenses:food+Amount  1: $10+Account 2: assets:checking+Amount  2 [$-10.0]: +Account 3 (or . or enter to finish this transaction): .+2015/05/22 supermarket+    expenses:food             $10+    assets:checking        $-10.0++Save this transaction to the journal ? [y]: +Saved.+Starting the next transaction (. or ctrl-D/ctrl-C to quit)+Date [2015/05/22]: <CTRL-D> $+\f[R]+.fi+.PP+On Microsoft Windows, the add command makes sure that no part of the+file path ends with a period, as it can cause data loss on that platform+(cf #1056).+.SS balance+.PP+balance, bal, b+.PD 0+.P+.PD+Show accounts and their balances.+.PP+The balance command is hledger\[aq]s most versatile command.+Note, despite the name, it is not always used for showing real-world+account balances; the more accounting-aware balancesheet and+incomestatement may be more convenient for that.+.PP+By default, it displays all accounts, and each account\[aq]s change in+balance during the entire period of the journal.+Balance changes are calculated by adding up the postings in each+account.+You can limit the postings matched, by a query, to see fewer accounts,+changes over a different time period, changes from only cleared+transactions, etc.+.PP+If you include an account\[aq]s complete history of postings in the+report, the balance change is equivalent to the account\[aq]s current+ending balance.+For a real-world account, typically you won\[aq]t have all transactions+in the journal; instead you\[aq]ll have all transactions after a certain+date, and an \[dq]opening balances\[dq] transaction setting the correct+starting balance on that date.+Then the balance command will show real-world account balances.+In some cases the -H/--historical flag is used to ensure this (more+below).+.PP+The balance command can produce several styles of report:+.SS Classic balance report+.PP+This is the original balance report, as found in Ledger.+It usually looks like this:+.IP+.nf+\f[C]+$ hledger balance+                 $-1  assets+                  $1    bank:saving+                 $-2    cash+                  $2  expenses+                  $1    food+                  $1    supplies+                 $-2  income+                 $-1    gifts+                 $-1    salary+                  $1  liabilities:debts+--------------------+                   0+\f[R]+.fi+.PP+By default, accounts are displayed hierarchically, with subaccounts+indented below their parent.+At each level of the tree, accounts are sorted by account code if any,+then by account name.+Or with \f[C]-S/--sort-amount\f[R], by their balance amount.+.PP+\[dq]Boring\[dq] accounts, which contain a single interesting subaccount+and no balance of their own, are elided into the following line for more+compact output.+(Eg above, the \[dq]liabilities\[dq] account.) Use \f[C]--no-elide\f[R]+to prevent this.+.PP+Account balances are \[dq]inclusive\[dq] - they include the balances of+any subaccounts.+.PP+Accounts which have zero balance (and no non-zero subaccounts) are+omitted.+Use \f[C]-E/--empty\f[R] to show them.+.PP+A final total is displayed by default; use \f[C]-N/--no-total\f[R] to+suppress it, eg:+.IP+.nf+\f[C]+$ hledger balance -p 2008/6 expenses --no-total+                  $2  expenses+                  $1    food+                  $1    supplies+\f[R]+.fi+.SS Customising the classic balance report+.PP+You can customise the layout of classic balance reports with+\f[C]--format FMT\f[R]:+.IP+.nf+\f[C]+$ hledger balance --format \[dq]%20(account) %12(total)\[dq]+              assets          $-1+         bank:saving           $1+                cash          $-2+            expenses           $2+                food           $1+            supplies           $1+              income          $-2+               gifts          $-1+              salary          $-1+   liabilities:debts           $1+---------------------------------+                                0+\f[R]+.fi+.PP+The FMT format string (plus a newline) specifies the formatting applied+to each account/balance pair.+It may contain any suitable text, with data fields interpolated like so:+.PP+\f[C]%[MIN][.MAX](FIELDNAME)\f[R]+.IP \[bu] 2+MIN pads with spaces to at least this width (optional)+.IP \[bu] 2+MAX truncates at this width (optional)+.IP \[bu] 2+FIELDNAME must be enclosed in parentheses, and can be one of:+.RS 2+.IP \[bu] 2+\f[C]depth_spacer\f[R] - a number of spaces equal to the account\[aq]s+depth, or if MIN is specified, MIN * depth spaces.+.IP \[bu] 2+\f[C]account\f[R] - the account\[aq]s name+.IP \[bu] 2+\f[C]total\f[R] - the account\[aq]s balance/posted total, right+justified+.RE+.PP+Also, FMT can begin with an optional prefix to control how+multi-commodity amounts are rendered:+.IP \[bu] 2+\f[C]%_\f[R] - render on multiple lines, bottom-aligned (the default)+.IP \[bu] 2+\f[C]%\[ha]\f[R] - render on multiple lines, top-aligned+.IP \[bu] 2+\f[C]%,\f[R] - render on one line, comma-separated+.PP+There are some quirks.+Eg in one-line mode, \f[C]%(depth_spacer)\f[R] has no effect, instead+\f[C]%(account)\f[R] has indentation built in.+Experimentation may be needed to get pleasing results.+.PP+Some example formats:+.IP \[bu] 2+\f[C]%(total)\f[R] - the account\[aq]s total+.IP \[bu] 2+\f[C]%-20.20(account)\f[R] - the account\[aq]s name, left justified,+padded to 20 characters and clipped at 20 characters+.IP \[bu] 2+\f[C]%,%-50(account)  %25(total)\f[R] - account name padded to 50+characters, total padded to 20 characters, with multiple commodities+rendered on one line+.IP \[bu] 2+\f[C]%20(total)  %2(depth_spacer)%-(account)\f[R] - the default format+for the single-column balance report+.SS Colour support+.PP+The balance command shows negative amounts in red, if:+.IP \[bu] 2+the \f[C]TERM\f[R] environment variable is not set to \f[C]dumb\f[R]+.IP \[bu] 2+the output is not being redirected or piped anywhere+.SS Flat mode+.PP+To see a flat list instead of the default hierarchical display, use+\f[C]--flat\f[R].+In this mode, accounts (unless depth-clipped) show their full names and+\[dq]exclusive\[dq] balance, excluding any subaccount balances.+In this mode, you can also use \f[C]--drop N\f[R] to omit the first few+account name components.+.IP+.nf+\f[C]+$ hledger balance -p 2008/6 expenses -N --flat --drop 1+                  $1  food+                  $1  supplies+\f[R]+.fi+.SS Depth limited balance reports+.PP+With \f[C]--depth N\f[R] or \f[C]depth:N\f[R] or just \f[C]-N\f[R],+balance reports show accounts only to the specified numeric depth.+This is very useful to summarise a complex set of accounts and get an+overview.+.IP+.nf+\f[C]+$ hledger balance -N -1+                 $-1  assets+                  $2  expenses+                 $-2  income+                  $1  liabilities+\f[R]+.fi+.PP+Flat-mode balance reports, which normally show exclusive balances, show+inclusive balances at the depth limit.+.SS Multicolumn balance report+.PP+Multicolumn or tabular balance reports are a very useful hledger+feature, and usually the preferred style.+They share many of the above features, but they show the report as a+table, with columns representing time periods.+This mode is activated by providing a reporting interval.+.PP+There are three types of multicolumn balance report, showing different+information:+.IP "1." 3+By default: each column shows the sum of postings in that period, ie the+account\[aq]s change of balance in that period.+This is useful eg for a monthly income statement:+.RS 4+.IP+.nf+\f[C]+$ hledger balance --quarterly income expenses -E+Balance changes in 2008:++                   ||  2008q1  2008q2  2008q3  2008q4 +===================++=================================+ expenses:food     ||       0      $1       0       0 + expenses:supplies ||       0      $1       0       0 + income:gifts      ||       0     $-1       0       0 + income:salary     ||     $-1       0       0       0 +-------------------++---------------------------------+                   ||     $-1      $1       0       0 +\f[R]+.fi+.RE+.IP "2." 3+With \f[C]--cumulative\f[R]: each column shows the ending balance for+that period, accumulating the changes across periods, starting from 0 at+the report start date:+.RS 4+.IP+.nf+\f[C]+$ hledger balance --quarterly income expenses -E --cumulative+Ending balances (cumulative) in 2008:++                   ||  2008/03/31  2008/06/30  2008/09/30  2008/12/31 +===================++=================================================+ expenses:food     ||           0          $1          $1          $1 + expenses:supplies ||           0          $1          $1          $1 + income:gifts      ||           0         $-1         $-1         $-1 + income:salary     ||         $-1         $-1         $-1         $-1 +-------------------++-------------------------------------------------+                   ||         $-1           0           0           0 +\f[R]+.fi+.RE+.IP "3." 3+With \f[C]--historical/-H\f[R]: each column shows the actual historical+ending balance for that period, accumulating the changes across periods,+starting from the actual balance at the report start date.+This is useful eg for a multi-period balance sheet, and when you are+showing only the data after a certain start date:+.RS 4+.IP+.nf+\f[C]+$ hledger balance \[ha]assets \[ha]liabilities --quarterly --historical --begin 2008/4/1+Ending balances (historical) in 2008/04/01-2008/12/31:++                      ||  2008/06/30  2008/09/30  2008/12/31 +======================++=====================================+ assets:bank:checking ||          $1          $1           0 + assets:bank:saving   ||          $1          $1          $1 + assets:cash          ||         $-2         $-2         $-2 + liabilities:debts    ||           0           0          $1 +----------------------++-------------------------------------+                      ||           0           0           0 +\f[R]+.fi+.RE+.PP+Note that \f[C]--cumulative\f[R] or \f[C]--historical/-H\f[R] disable+\f[C]--row-total/-T\f[R], since summing end balances generally does not+make sense.+.PP+Multicolumn balance reports display accounts in flat mode by default; to+see the hierarchy, use \f[C]--tree\f[R].+.PP+With a reporting interval (like \f[C]--quarterly\f[R] above), the report+start/end dates will be adjusted if necessary so that they encompass the+displayed report periods.+This is so that the first and last periods will be \[dq]full\[dq] and+comparable to the others.+.PP+The \f[C]-E/--empty\f[R] flag does two things in multicolumn balance+reports: first, the report will show all columns within the specified+report period (without -E, leading and trailing columns with all zeroes+are not shown).+Second, all accounts which existed at the report start date will be+considered, not just the ones with activity during the report period+(use -E to include low-activity accounts which would otherwise would be+omitted).+.PP+The \f[C]-T/--row-total\f[R] flag adds an additional column showing the+total for each row.+.PP+The \f[C]-A/--average\f[R] flag adds a column showing the average value+in each row.+.PP+Here\[aq]s an example of all three:+.IP+.nf+\f[C]+$ hledger balance -Q income expenses --tree -ETA+Balance changes in 2008:++            ||  2008q1  2008q2  2008q3  2008q4    Total  Average +============++===================================================+ expenses   ||       0      $2       0       0       $2       $1 +   food     ||       0      $1       0       0       $1        0 +   supplies ||       0      $1       0       0       $1        0 + income     ||     $-1     $-1       0       0      $-2      $-1 +   gifts    ||       0     $-1       0       0      $-1        0 +   salary   ||     $-1       0       0       0      $-1        0 +------------++---------------------------------------------------+            ||     $-1      $1       0       0        0        0 ++# Average is rounded to the dollar here since all journal amounts are+\f[R]+.fi+.PP+Limitations:+.PP+In multicolumn reports the \f[C]-V/--value\f[R] flag uses the market+price on the report end date, for all columns (not the price on each+column\[aq]s end date).+.PP+Eliding of boring parent accounts in tree mode, as in the classic+balance report, is not yet supported in multicolumn reports.+.SS Budget report+.PP+With \f[C]--budget\f[R], extra columns are displayed showing budget+goals for each account and period, if any.+Budget goals are defined by periodic transactions.+This is very useful for comparing planned and actual income, expenses,+time usage, etc.+--budget is most often combined with a report interval.+.PP+For example, you can take average monthly expenses in the common expense+categories to construct a minimal monthly budget:+.IP+.nf+\f[C]+;; Budget+\[ti] monthly+  income  $2000+  expenses:food    $400+  expenses:bus     $50+  expenses:movies  $30+  assets:bank:checking++;; Two months worth of expenses+2017-11-01+  income  $1950+  expenses:food    $396+  expenses:bus     $49+  expenses:movies  $30+  expenses:supplies  $20+  assets:bank:checking++2017-12-01+  income  $2100+  expenses:food    $412+  expenses:bus     $53+  expenses:gifts   $100+  assets:bank:checking+\f[R]+.fi+.PP+You can now see a monthly budget report:+.IP+.nf+\f[C]+$ hledger balance -M --budget+Budget performance in 2017/11/01-2017/12/31:++                      ||                      Nov                       Dec +======================++====================================================+ assets               || $-2445 [  99% of $-2480]  $-2665 [ 107% of $-2480] + assets:bank          || $-2445 [  99% of $-2480]  $-2665 [ 107% of $-2480] + assets:bank:checking || $-2445 [  99% of $-2480]  $-2665 [ 107% of $-2480] + expenses             ||   $495 [ 103% of   $480]    $565 [ 118% of   $480] + expenses:bus         ||    $49 [  98% of    $50]     $53 [ 106% of    $50] + expenses:food        ||   $396 [  99% of   $400]    $412 [ 103% of   $400] + expenses:movies      ||    $30 [ 100% of    $30]       0 [   0% of    $30] + income               ||  $1950 [  98% of  $2000]   $2100 [ 105% of  $2000] +----------------------++----------------------------------------------------+                      ||      0 [              0]       0 [              0] +\f[R]+.fi+.PP+Note this is different from a normal balance report in several ways:+.IP \[bu] 2+Only accounts with budget goals during the report period are shown, by+default.+.IP \[bu] 2+In each column, in square brackets after the actual amount, budgeted+amounts are shown, along with the percentage of budget used.+.IP \[bu] 2+All parent accounts are always shown, even in flat mode.+Eg assets, assets:bank, and expenses above.+.IP \[bu] 2+Amounts always include all subaccounts, budgeted or unbudgeted, even in+flat mode.+.PP+This means that the numbers displayed will not always add up! Eg above,+the \f[C]expenses\f[R] actual amount includes the gifts and supplies+transactions, but the \f[C]expenses:gifts\f[R] and+\f[C]expenses:supplies\f[R] accounts are not shown, as they have no+budget amounts declared.+.PP+This can be confusing.+When you need to make things clearer, use the \f[C]-E/--empty\f[R] flag,+which will reveal all accounts including unbudgeted ones, giving the+full picture.+Eg:+.IP+.nf+\f[C]+$ hledger balance -M --budget --empty+Budget performance in 2017/11/01-2017/12/31:++                      ||                      Nov                       Dec +======================++====================================================+ assets               || $-2445 [  99% of $-2480]  $-2665 [ 107% of $-2480] + assets:bank          || $-2445 [  99% of $-2480]  $-2665 [ 107% of $-2480] + assets:bank:checking || $-2445 [  99% of $-2480]  $-2665 [ 107% of $-2480] + expenses             ||   $495 [ 103% of   $480]    $565 [ 118% of   $480] + expenses:bus         ||    $49 [  98% of    $50]     $53 [ 106% of    $50] + expenses:food        ||   $396 [  99% of   $400]    $412 [ 103% of   $400] + expenses:gifts       ||      0                      $100                   + expenses:movies      ||    $30 [ 100% of    $30]       0 [   0% of    $30] + expenses:supplies    ||    $20                         0                   + income               ||  $1950 [  98% of  $2000]   $2100 [ 105% of  $2000] +----------------------++----------------------------------------------------+                      ||      0 [              0]       0 [              0] +\f[R]+.fi+.PP+You can roll over unspent budgets to next period with+\f[C]--cumulative\f[R]:+.IP+.nf+\f[C]+$ hledger balance -M --budget --cumulative+Budget performance in 2017/11/01-2017/12/31:++                      ||                      Nov                       Dec +======================++====================================================+ assets               || $-2445 [  99% of $-2480]  $-5110 [ 103% of $-4960] + assets:bank          || $-2445 [  99% of $-2480]  $-5110 [ 103% of $-4960] + assets:bank:checking || $-2445 [  99% of $-2480]  $-5110 [ 103% of $-4960] + expenses             ||   $495 [ 103% of   $480]   $1060 [ 110% of   $960] + expenses:bus         ||    $49 [  98% of    $50]    $102 [ 102% of   $100] + expenses:food        ||   $396 [  99% of   $400]    $808 [ 101% of   $800] + expenses:movies      ||    $30 [ 100% of    $30]     $30 [  50% of    $60] + income               ||  $1950 [  98% of  $2000]   $4050 [ 101% of  $4000] +----------------------++----------------------------------------------------+                      ||      0 [              0]       0 [              0] +\f[R]+.fi+.PP+For more examples, see Budgeting and Forecasting.+.SS Nested budgets+.PP+You can add budgets to any account in your account hierarchy.+If you have budgets on both parent account and some of its children,+then budget(s) of the child account(s) would be added to the budget of+their parent, much like account balances behave.+.PP+In the most simple case this means that once you add a budget to any+account, all its parents would have budget as well.+.PP+To illustrate this, consider the following budget:+.IP+.nf+\f[C]+\[ti] monthly from 2019/01+    expenses:personal             $1,000.00+    expenses:personal:electronics    $100.00+    liabilities+\f[R]+.fi+.PP+With this, monthly budget for electronics is defined to be $100 and+budget for personal expenses is an additional $1000, which implicity+means that budget for both \f[C]expenses:personal\f[R] and+\f[C]expenses\f[R] is $1100.+.PP+Transactions in \f[C]expenses:personal:electronics\f[R] will be counted+both towards its $100 budget and $1100 of \f[C]expenses:personal\f[R] ,+and transactions in any other subaccount of \f[C]expenses:personal\f[R]+would be counted towards only towards the budget of+\f[C]expenses:personal\f[R].+.PP+For example, let\[aq]s consider these transactions:+.IP+.nf+\f[C]+\[ti] monthly from 2019/01+    expenses:personal             $1,000.00+    expenses:personal:electronics    $100.00+    liabilities++2019/01/01 Google home hub+    expenses:personal:electronics          $90.00+    liabilities                           $-90.00++2019/01/02 Phone screen protector+    expenses:personal:electronics:upgrades          $10.00+    liabilities++2019/01/02 Weekly train ticket+    expenses:personal:train tickets       $153.00+    liabilities++2019/01/03 Flowers+    expenses:personal          $30.00+    liabilities+\f[R]+.fi+.PP+As you can see, we have transactions in+\f[C]expenses:personal:electronics:upgrades\f[R] and+\f[C]expenses:personal:train tickets\f[R], and since both of these+accounts are without explicitly defined budget, these transactions would+be counted towards budgets of \f[C]expenses:personal:electronics\f[R]+and \f[C]expenses:personal\f[R] accordingly:+.IP+.nf+\f[C]+$ hledger balance --budget -M+Budget performance in 2019/01:++                               ||                           Jan +===============================++===============================+ expenses                      ||  $283.00 [  26% of  $1100.00] + expenses:personal             ||  $283.00 [  26% of  $1100.00] + expenses:personal:electronics ||  $100.00 [ 100% of   $100.00] + liabilities                   || $-283.00 [  26% of $-1100.00] +-------------------------------++-------------------------------+                               ||        0 [                 0] +\f[R]+.fi+.PP+And with \f[C]--empty\f[R], we can get a better picture of budget+allocation and consumption:+.IP+.nf+\f[C]+$ hledger balance --budget -M --empty+Budget performance in 2019/01:++                                        ||                           Jan +========================================++===============================+ expenses                               ||  $283.00 [  26% of  $1100.00] + expenses:personal                      ||  $283.00 [  26% of  $1100.00] + expenses:personal:electronics          ||  $100.00 [ 100% of   $100.00] + expenses:personal:electronics:upgrades ||   $10.00                      + expenses:personal:train tickets        ||  $153.00                      + liabilities                            || $-283.00 [  26% of $-1100.00] +----------------------------------------++-------------------------------+                                        ||        0 [                 0] +\f[R]+.fi+.SS Output format+.PP+The balance command supports output destination and output format+selection.+.SS balancesheet+.PP+balancesheet, bs+.PD 0+.P+.PD+This command displays a simple balance sheet, showing historical ending+balances of asset and liability accounts (ignoring any report begin+date).+It assumes that these accounts are under a top-level \f[C]asset\f[R] or+\f[C]liability\f[R] account (case insensitive, plural forms also+allowed).+.PP+Note this report shows all account balances with normal positive sign+(like conventional financial statements, unlike balance/print/register)+(experimental).+.PP+Example:+.IP+.nf+\f[C]+$ hledger balancesheet+Balance Sheet++Assets:+                 $-1  assets+                  $1    bank:saving+                 $-2    cash+--------------------+                 $-1++Liabilities:+                  $1  liabilities:debts+--------------------+                  $1++Total:+--------------------+                   0+\f[R]+.fi+.PP+With a reporting interval, multiple columns will be shown, one for each+report period.+As with multicolumn balance reports, you can alter the report mode with+\f[C]--change\f[R]/\f[C]--cumulative\f[R]/\f[C]--historical\f[R].+Normally balancesheet shows historical ending balances, which is what+you need for a balance sheet; note this means it ignores report begin+dates (and \f[C]-T/--row-total\f[R], since summing end balances+generally does not make sense).+.PP+This command also supports output destination and output format+selection.+.SS balancesheetequity+.PP+balancesheetequity, bse+.PD 0+.P+.PD+Just like balancesheet, but also reports Equity (which it assumes is+under a top-level \f[C]equity\f[R] account).+.PP+Example:+.IP+.nf+\f[C]+$ hledger balancesheetequity+Balance Sheet With Equity++Assets:+                 $-2  assets+                  $1    bank:saving+                 $-3    cash+--------------------+                 $-2++Liabilities:+                  $1  liabilities:debts+--------------------+                  $1++Equity:+          $1  equity:owner+--------------------+          $1++Total:+--------------------+                   0+\f[R]+.fi+.SS cashflow+.PP+cashflow, cf+.PD 0+.P+.PD+This command displays a simple cashflow statement, showing changes in+\[dq]cash\[dq] accounts.+It assumes that these accounts are under a top-level \f[C]asset\f[R]+account (case insensitive, plural forms also allowed) and do not contain+\f[C]receivable\f[R] or \f[C]A/R\f[R] in their name.+Note this report shows all account balances with normal positive sign+(like conventional financial statements, unlike balance/print/register)+(experimental).+.PP+Example:+.IP+.nf+\f[C]+$ hledger cashflow+Cashflow Statement++Cash flows:+                 $-1  assets+                  $1    bank:saving+                 $-2    cash+--------------------+                 $-1++Total:+--------------------+                 $-1+\f[R]+.fi+.PP+With a reporting interval, multiple columns will be shown, one for each+report period.+Normally cashflow shows changes in assets per period, though as with+multicolumn balance reports you can alter the report mode with+\f[C]--change\f[R]/\f[C]--cumulative\f[R]/\f[C]--historical\f[R].+.PP+This command also supports output destination and output format+selection.+.SS check-dates+.PP+check-dates+.PD 0+.P+.PD+Check that transactions are sorted by increasing date.+With --date2, checks secondary dates instead.+With --strict, dates must also be unique.+With a query, only matched transactions\[aq] dates are checked.+Reads the default journal file, or another specified with -f.+.SS check-dupes+.PP+check-dupes+.PD 0+.P+.PD+Reports account names having the same leaf but different prefixes.+In other words, two or more leaves that are categorized differently.+Reads the default journal file, or another specified as an argument.+.PP+An example: http://stefanorodighiero.net/software/hledger-dupes.html+.SS close+.PP+close, equity+.PD 0+.P+.PD+Prints a \[dq]closing balances\[dq] transaction and an \[dq]opening+balances\[dq] transaction that bring account balances to and from zero,+respectively.+Useful for bringing asset/liability balances forward into a new journal+file, or for closing out revenues/expenses to retained earnings at the+end of a period.+.PP+The closing transaction transfers balances to \[dq]equity:closing+balances\[dq].+The opening transaction transfers balances from \[dq]equity:opening+balances\[dq].+You can choose to print just one of the transactions by using the+\f[C]--opening\f[R] or \f[C]--closing\f[R] flag.+.PP+If you split your journal files by time (eg yearly), you will typically+run this command at the end of the year, and save the closing+transaction as last entry of the old file, and the opening transaction+as the first entry of the new file.+This makes the files self contained, so that correct balances are+reported no matter which of them are loaded.+Ie, if you load just one file, the balances are initialised correctly;+or if you load several files, the redundant closing/opening transactions+cancel each other out.+(They will show up in print or register reports; you can exclude them+with a query like+\f[C]not:desc:\[aq](opening|closing) balances\[aq]\f[R].)+.PP+If you\[aq]re running a business, you might also use this command to+\[dq]close the books\[dq] at the end of an accounting period,+transferring income statement account balances to retained earnings.+(You may want to change the equity account name to something like+\[dq]equity:retained earnings\[dq].)+.PP+By default, the closing transaction is dated yesterday, the balances are+calculated as of end of yesterday, and the opening transaction is dated+today.+To close on some other date, use:+\f[C]hledger close -e OPENINGDATE\f[R].+Eg, to close/open on the 2018/2019 boundary, use \f[C]-e 2019\f[R].+You can also use -p or \f[C]date:PERIOD\f[R] (any starting date is+ignored).+.PP+Both transactions will include balance assertions for the+closed/reopened accounts.+You probably shouldn\[aq]t use status or realness filters (like -C or -R+or \f[C]status:\f[R]) with this command, or the generated balance+assertions will depend on these flags.+Likewise, if you run this command with --auto, the balance assertions+will probably always require --auto.+.PP+When account balances have cost information (transaction prices), the+closing/opening transactions will preserve it, so that eg balance -B+reports will not be affected.+.PP+Examples:+.PP+Carrying asset/liability balances into a new file for 2019, all from+command line:+.PP+\f[I]Warning: we use \f[CI]>>\f[I] here to append; be careful not to+type a single \f[CI]>\f[I] which would wipe your journal!\f[R]+.IP+.nf+\f[C]+$ hledger close -f 2018.journal -e 2019 assets liabilities --opening >>2019.journal+$ hledger close -f 2018.journal -e 2019 assets liabilities --closing >>2018.journal+\f[R]+.fi+.PP+Now:+.IP+.nf+\f[C]+$ hledger bs -f 2019.journal                   # one file - balances are correct+$ hledger bs -f 2018.journal -f 2019.journal   # two files - balances still correct+$ hledger bs -f 2018.journal not:desc:closing  # to see year-end balances, must exclude closing txn+\f[R]+.fi+.PP+Transactions spanning the closing date can complicate matters, breaking+balance assertions:+.IP+.nf+\f[C]+2018/12/30 a purchase made in 2018, clearing the following year+    expenses:food          5+    assets:bank:checking  -5  ; [2019/1/2]+\f[R]+.fi+.PP+Here\[aq]s one way to resolve that:+.IP+.nf+\f[C]+; in 2018.journal:+2018/12/30 a purchase made in 2018, clearing the following year+    expenses:food          5+    liabilities:pending++; in 2019.journal:+2019/1/2 clearance of last year\[aq]s pending transactions+    liabilities:pending    5 = 0+    assets:checking+\f[R]+.fi+.SS files+.PP+files+.PD 0+.P+.PD+List all files included in the journal.+With a REGEX argument, only file names matching the regular expression+(case sensitive) are shown.+.SS help+.PP+help+.PD 0+.P+.PD+Show any of the hledger manuals.+.PP+The \f[C]help\f[R] command displays any of the main hledger manuals, in+one of several ways.+Run it with no argument to list the manuals, or provide a full or+partial manual name to select one.+.PP+hledger manuals are available in several formats.+hledger help will use the first of these display methods that it finds:+info, man, $PAGER, less, stdout (or when non-interactive, just stdout).+You can force a particular viewer with the \f[C]--info\f[R],+\f[C]--man\f[R], \f[C]--pager\f[R], \f[C]--cat\f[R] flags.+.PP+Examples:+.IP+.nf+\f[C]+$ hledger help+Please choose a manual by typing \[dq]hledger help MANUAL\[dq] (a substring is ok).+Manuals: hledger hledger-ui hledger-web hledger-api journal csv timeclock timedot+\f[R]+.fi+.IP+.nf+\f[C]+$ hledger help h --man++hledger(1)                    hledger User Manuals                    hledger(1)++NAME+       hledger - a command-line accounting tool++SYNOPSIS+       hledger [-f FILE] COMMAND [OPTIONS] [ARGS]+       hledger [-f FILE] ADDONCMD -- [OPTIONS] [ARGS]+       hledger++DESCRIPTION+       hledger  is  a  cross-platform  program  for tracking money, time, or any+\&...+\f[R]+.fi+.SS import+.PP+import+.PD 0+.P+.PD+Read new transactions added to each FILE since last run, and add them to+the main journal file.+Or with --dry-run, just print the transactions that would be added.+.PP+The input files are specified as arguments - no need to write -f before+each one.+So eg to add new transactions from all CSV files to the main journal,+it\[aq]s just: \f[C]hledger import *.csv\f[R]+.PP+New transactions are detected in the same way as print --new: by+assuming transactions are always added to the input files in increasing+date order, and by saving \f[C].latest.FILE\f[R] state files.+.PP+The --dry-run output is in journal format, so you can filter it, eg to+see only uncategorised transactions:+.IP+.nf+\f[C]+$ hledger import --dry ... | hledger -f- print unknown --ignore-assertions+\f[R]+.fi+.SS Importing balance assignments+.PP+Entries added by import will have their posting amounts made explicit+(like \f[C]hledger print -x\f[R]).+This means that any balance assignments in imported files must be+evaluated; but, imported files don\[aq]t get to see the main file\[aq]s+account balances.+As a result, importing entries with balance assignments (eg from an+institution that provides only balances and not posting amounts) will+probably generate incorrect posting amounts.+To avoid this problem, use print instead of import:+.IP+.nf+\f[C]+$ hledger print IMPORTFILE [--new] >> $LEDGER_FILE+\f[R]+.fi+.PP+(If you think import should leave amounts implicit like print does,+please test it and send a pull request.)+.SS incomestatement+.PP+incomestatement, is+.PD 0+.P+.PD+This command displays a simple income statement, showing revenues and+expenses during a period.+It assumes that these accounts are under a top-level \f[C]revenue\f[R]+or \f[C]income\f[R] or \f[C]expense\f[R] account (case insensitive,+plural forms also allowed).+Note this report shows all account balances with normal positive sign+(like conventional financial statements, unlike balance/print/register)+(experimental).+.PP+This command displays a simple income statement.+It currently assumes that you have top-level accounts named+\f[C]income\f[R] (or \f[C]revenue\f[R]) and \f[C]expense\f[R] (plural+forms also allowed.)+.IP+.nf+\f[C]+$ hledger incomestatement+Income Statement++Revenues:+                 $-2  income+                 $-1    gifts+                 $-1    salary+--------------------+                 $-2++Expenses:+                  $2  expenses+                  $1    food+                  $1    supplies+--------------------+                  $2++Total:+--------------------+                   0+\f[R]+.fi+.PP+With a reporting interval, multiple columns will be shown, one for each+report period.+Normally incomestatement shows revenues/expenses per period, though as+with multicolumn balance reports you can alter the report mode with+\f[C]--change\f[R]/\f[C]--cumulative\f[R]/\f[C]--historical\f[R].+.PP+This command also supports output destination and output format+selection.+.SS prices+.PP+prices+.PD 0+.P+.PD+Print market price directives from the journal.+With --costs, also print synthetic market prices based on transaction+prices.+With --inverted-costs, also print inverse prices based on transaction+prices.+Prices (and postings providing prices) can be filtered by a query.+.SS print+.PP+print, txns, p+.PD 0+.P+.PD+Show transaction journal entries, sorted by date.+.PP+The print command displays full journal entries (transactions) from the+journal file in date order, tidily formatted.+With --date2, transactions are sorted by secondary date instead.+.PP+print\[aq]s output is always a valid hledger journal.+.PD 0+.P+.PD+It preserves all transaction information, but it does not preserve+directives or inter-transaction comments+.IP+.nf+\f[C]+$ hledger print+2008/01/01 income+    assets:bank:checking            $1+    income:salary                  $-1++2008/06/01 gift+    assets:bank:checking            $1+    income:gifts                   $-1++2008/06/02 save+    assets:bank:saving              $1+    assets:bank:checking           $-1++2008/06/03 * eat & shop+    expenses:food                $1+    expenses:supplies            $1+    assets:cash                 $-2++2008/12/31 * pay off+    liabilities:debts               $1+    assets:bank:checking           $-1+\f[R]+.fi+.PP+Normally, the journal entry\[aq]s explicit or implicit amount style is+preserved.+Ie when an amount is omitted in the journal, it will be omitted in the+output.+You can use the \f[C]-x\f[R]/\f[C]--explicit\f[R] flag to make all+amounts explicit, which can be useful for troubleshooting or for making+your journal more readable and robust against data entry errors.+Note, \f[C]-x\f[R] will cause postings with a multi-commodity amount+(these can arise when a multi-commodity transaction has an implicit+amount) will be split into multiple single-commodity postings, for valid+journal output.+.PP+With \f[C]-B\f[R]/\f[C]--cost\f[R], amounts with transaction prices are+converted to cost using that price.+This can be used for troubleshooting.+.PP+With \f[C]-m\f[R]/\f[C]--match\f[R] and a STR argument, print will show+at most one transaction: the one one whose description is most similar+to STR, and is most recent.+STR should contain at least two characters.+If there is no similar-enough match, no transaction will be shown.+.PP+With \f[C]--new\f[R], for each FILE being read, hledger reads (and+writes) a special state file (\f[C].latest.FILE\f[R] in the same+directory), containing the latest transaction date(s) that were seen+last time FILE was read.+When this file is found, only transactions with newer dates (and new+transactions on the latest date) are printed.+This is useful for ignoring already-seen entries in import data, such as+downloaded CSV files.+Eg:+.IP+.nf+\f[C]+$ hledger -f bank1.csv print --new+# shows transactions added since last print --new on this file+\f[R]+.fi+.PP+This assumes that transactions added to FILE always have same or+increasing dates, and that transactions on the same day do not get+reordered.+See also the import command.+.PP+This command also supports output destination and output format+selection.+Here\[aq]s an example of print\[aq]s CSV output:+.IP+.nf+\f[C]+$ hledger print -Ocsv+\[dq]txnidx\[dq],\[dq]date\[dq],\[dq]date2\[dq],\[dq]status\[dq],\[dq]code\[dq],\[dq]description\[dq],\[dq]comment\[dq],\[dq]account\[dq],\[dq]amount\[dq],\[dq]commodity\[dq],\[dq]credit\[dq],\[dq]debit\[dq],\[dq]posting-status\[dq],\[dq]posting-comment\[dq]+\[dq]1\[dq],\[dq]2008/01/01\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]income\[dq],\[dq]\[dq],\[dq]assets:bank:checking\[dq],\[dq]1\[dq],\[dq]$\[dq],\[dq]\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq]+\[dq]1\[dq],\[dq]2008/01/01\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]income\[dq],\[dq]\[dq],\[dq]income:salary\[dq],\[dq]-1\[dq],\[dq]$\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq]+\[dq]2\[dq],\[dq]2008/06/01\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]gift\[dq],\[dq]\[dq],\[dq]assets:bank:checking\[dq],\[dq]1\[dq],\[dq]$\[dq],\[dq]\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq]+\[dq]2\[dq],\[dq]2008/06/01\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]gift\[dq],\[dq]\[dq],\[dq]income:gifts\[dq],\[dq]-1\[dq],\[dq]$\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq]+\[dq]3\[dq],\[dq]2008/06/02\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]save\[dq],\[dq]\[dq],\[dq]assets:bank:saving\[dq],\[dq]1\[dq],\[dq]$\[dq],\[dq]\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq]+\[dq]3\[dq],\[dq]2008/06/02\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]save\[dq],\[dq]\[dq],\[dq]assets:bank:checking\[dq],\[dq]-1\[dq],\[dq]$\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq]+\[dq]4\[dq],\[dq]2008/06/03\[dq],\[dq]\[dq],\[dq]*\[dq],\[dq]\[dq],\[dq]eat & shop\[dq],\[dq]\[dq],\[dq]expenses:food\[dq],\[dq]1\[dq],\[dq]$\[dq],\[dq]\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq]+\[dq]4\[dq],\[dq]2008/06/03\[dq],\[dq]\[dq],\[dq]*\[dq],\[dq]\[dq],\[dq]eat & shop\[dq],\[dq]\[dq],\[dq]expenses:supplies\[dq],\[dq]1\[dq],\[dq]$\[dq],\[dq]\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq]+\[dq]4\[dq],\[dq]2008/06/03\[dq],\[dq]\[dq],\[dq]*\[dq],\[dq]\[dq],\[dq]eat & shop\[dq],\[dq]\[dq],\[dq]assets:cash\[dq],\[dq]-2\[dq],\[dq]$\[dq],\[dq]2\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq]+\[dq]5\[dq],\[dq]2008/12/31\[dq],\[dq]\[dq],\[dq]*\[dq],\[dq]\[dq],\[dq]pay off\[dq],\[dq]\[dq],\[dq]liabilities:debts\[dq],\[dq]1\[dq],\[dq]$\[dq],\[dq]\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq]+\[dq]5\[dq],\[dq]2008/12/31\[dq],\[dq]\[dq],\[dq]*\[dq],\[dq]\[dq],\[dq]pay off\[dq],\[dq]\[dq],\[dq]assets:bank:checking\[dq],\[dq]-1\[dq],\[dq]$\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq]+\f[R]+.fi+.IP \[bu] 2+There is one CSV record per posting, with the parent transaction\[aq]s+fields repeated.+.IP \[bu] 2+The \[dq]txnidx\[dq] (transaction index) field shows which postings+belong to the same transaction.+(This number might change if transactions are reordered within the file,+files are parsed/included in a different order, etc.)+.IP \[bu] 2+The amount is separated into \[dq]commodity\[dq] (the symbol) and+\[dq]amount\[dq] (numeric quantity) fields.+.IP \[bu] 2+The numeric amount is repeated in either the \[dq]credit\[dq] or+\[dq]debit\[dq] column, for convenience.+(Those names are not accurate in the accounting sense; it just puts+negative amounts under credit and zero or greater amounts under debit.)+.SS print-unique+.PP+print-unique+.PD 0+.P+.PD+Print transactions which do not reuse an already-seen description.+.PP+Example:+.IP+.nf+\f[C]+$ cat unique.journal+1/1 test+ (acct:one)  1+2/2 test+ (acct:two)  2+$ LEDGER_FILE=unique.journal hledger print-unique+(-f option not supported)+2015/01/01 test+    (acct:one)             1+\f[R]+.fi+.SS register+.PP+register, reg, r+.PD 0+.P+.PD+Show postings and their running total.+.PP+The register command displays postings in date order, one per line, and+their running total.+This is typically used with a query selecting a particular account, to+see that account\[aq]s activity:+.IP+.nf+\f[C]+$ hledger register checking+2008/01/01 income               assets:bank:checking            $1           $1+2008/06/01 gift                 assets:bank:checking            $1           $2+2008/06/02 save                 assets:bank:checking           $-1           $1+2008/12/31 pay off              assets:bank:checking           $-1            0+\f[R]+.fi+.PP+With --date2, it shows and sorts by secondary date instead.+.PP+The \f[C]--historical\f[R]/\f[C]-H\f[R] flag adds the balance from any+undisplayed prior postings to the running total.+This is useful when you want to see only recent activity, with a+historically accurate running balance:+.IP+.nf+\f[C]+$ hledger register checking -b 2008/6 --historical+2008/06/01 gift                 assets:bank:checking            $1           $2+2008/06/02 save                 assets:bank:checking           $-1           $1+2008/12/31 pay off              assets:bank:checking           $-1            0+\f[R]+.fi+.PP+The \f[C]--depth\f[R] option limits the amount of sub-account detail+displayed.+.PP+The \f[C]--average\f[R]/\f[C]-A\f[R] flag shows the running average+posting amount instead of the running total (so, the final number+displayed is the average for the whole report period).+This flag implies \f[C]--empty\f[R] (see below).+It is affected by \f[C]--historical\f[R].+It works best when showing just one account and one commodity.+.PP+The \f[C]--related\f[R]/\f[C]-r\f[R] flag shows the \f[I]other\f[R]+postings in the transactions of the postings which would normally be+shown.+.PP+The \f[C]--invert\f[R] flag negates all amounts.+For example, it can be used on an income account where amounts are+normally displayed as negative numbers.+It\[aq]s also useful to show postings on the checking account together+with the related account:+.IP+.nf+\f[C]+$ hledger register --related --invert assets:checking+\f[R]+.fi+.PP+With a reporting interval, register shows summary postings, one per+interval, aggregating the postings to each account:+.IP+.nf+\f[C]+$ hledger register --monthly income+2008/01                 income:salary                          $-1          $-1+2008/06                 income:gifts                           $-1          $-2+\f[R]+.fi+.PP+Periods with no activity, and summary postings with a zero amount, are+not shown by default; use the \f[C]--empty\f[R]/\f[C]-E\f[R] flag to see+them:+.IP+.nf+\f[C]+$ hledger register --monthly income -E+2008/01                 income:salary                          $-1          $-1+2008/02                                                          0          $-1+2008/03                                                          0          $-1+2008/04                                                          0          $-1+2008/05                                                          0          $-1+2008/06                 income:gifts                           $-1          $-2+2008/07                                                          0          $-2+2008/08                                                          0          $-2+2008/09                                                          0          $-2+2008/10                                                          0          $-2+2008/11                                                          0          $-2+2008/12                                                          0          $-2+\f[R]+.fi+.PP+Often, you\[aq]ll want to see just one line per interval.+The \f[C]--depth\f[R] option helps with this, causing subaccounts to be+aggregated:+.IP+.nf+\f[C]+$ hledger register --monthly assets --depth 1h+2008/01                 assets                                  $1           $1+2008/06                 assets                                 $-1            0+2008/12                 assets                                 $-1          $-1+\f[R]+.fi+.PP+Note when using report intervals, if you specify start/end dates these+will be adjusted outward if necessary to contain a whole number of+intervals.+This ensures that the first and last intervals are full length and+comparable to the others in the report.+.SS Custom register output+.PP+register uses the full terminal width by default, except on windows.+You can override this by setting the \f[C]COLUMNS\f[R] environment+variable (not a bash shell variable) or by using the+\f[C]--width\f[R]/\f[C]-w\f[R] option.+.PP+The description and account columns normally share the space equally+(about half of (width - 40) each).+You can adjust this by adding a description width as part of+--width\[aq]s argument, comma-separated: \f[C]--width W,D\f[R] .+Here\[aq]s a diagram (won\[aq]t display correctly in --help):+.IP+.nf+\f[C]+<--------------------------------- width (W) ---------------------------------->+date (10)  description (D)       account (W-41-D)     amount (12)   balance (12)+DDDDDDDDDD dddddddddddddddddddd  aaaaaaaaaaaaaaaaaaa  AAAAAAAAAAAA  AAAAAAAAAAAA+\f[R]+.fi+.PP+and some examples:+.IP+.nf+\f[C]+$ hledger reg                     # use terminal width (or 80 on windows)+$ hledger reg -w 100              # use width 100+$ COLUMNS=100 hledger reg         # set with one-time environment variable+$ export COLUMNS=100; hledger reg # set till session end (or window resize)+$ hledger reg -w 100,40           # set overall width 100, description width 40+$ hledger reg -w $COLUMNS,40      # use terminal width, & description width 40+\f[R]+.fi+.PP+This command also supports output destination and output format+selection.+.SS register-match+.PP+register-match+.PD 0+.P+.PD+Print the one posting whose transaction description is closest to DESC,+in the style of the register command.+If there are multiple equally good matches, it shows the most recent.+Query options (options, not arguments) can be used to restrict the+search space.+Helps ledger-autosync detect already-seen transactions when importing.+.SS rewrite+.PP+rewrite+.PD 0+.P+.PD+Print all transactions, rewriting the postings of matched transactions.+For now the only rewrite available is adding new postings, like print+--auto.+.PP+This is a start at a generic rewriter of transaction entries.+It reads the default journal and prints the transactions, like print,+but adds one or more specified postings to any transactions matching+QUERY.+The posting amounts can be fixed, or a multiplier of the existing+transaction\[aq]s first posting amount.+.PP+Examples:+.IP+.nf+\f[C]+$ hledger-rewrite.hs \[ha]income --add-posting \[aq](liabilities:tax)  *.33  ; income tax\[aq] --add-posting \[aq](reserve:gifts)  $100\[aq]+$ hledger-rewrite.hs expenses:gifts --add-posting \[aq](reserve:gifts)  *-1\[dq]\[aq]+$ hledger-rewrite.hs -f rewrites.hledger+\f[R]+.fi+.PP+rewrites.hledger may consist of entries like:+.IP+.nf+\f[C]+= \[ha]income amt:<0 date:2017+  (liabilities:tax)  *0.33  ; tax on income+  (reserve:grocery)  *0.25  ; reserve 25% for grocery+  (reserve:)  *0.25  ; reserve 25% for grocery+\f[R]+.fi+.PP+Note the single quotes to protect the dollar sign from bash, and the two+spaces between account and amount.+.PP+More:+.IP+.nf+\f[C]+$ hledger rewrite -- [QUERY]        --add-posting \[dq]ACCT  AMTEXPR\[dq] ...+$ hledger rewrite -- \[ha]income        --add-posting \[aq](liabilities:tax)  *.33\[aq]+$ hledger rewrite -- expenses:gifts --add-posting \[aq](budget:gifts)  *-1\[dq]\[aq]+$ hledger rewrite -- \[ha]income        --add-posting \[aq](budget:foreign currency)  *0.25 JPY; diversify\[aq]+\f[R]+.fi+.PP+Argument for \f[C]--add-posting\f[R] option is a usual posting of+transaction with an exception for amount specification.+More precisely, you can use \f[C]\[aq]*\[aq]\f[R] (star symbol) before+the amount to indicate that that this is a factor for an amount of+original matched posting.+If the amount includes a commodity name, the new posting amount will be+in the new commodity; otherwise, it will be in the matched posting+amount\[aq]s commodity.+.SS Re-write rules in a file+.PP+During the run this tool will execute so called \[dq]Automated+Transactions\[dq] found in any journal it process.+I.e instead of specifying this operations in command line you can put+them in a journal file.+.IP+.nf+\f[C]+$ rewrite-rules.journal+\f[R]+.fi+.PP+Make contents look like this:+.IP+.nf+\f[C]+= \[ha]income+    (liabilities:tax)  *.33++= expenses:gifts+    budget:gifts  *-1+    assets:budget  *1+\f[R]+.fi+.PP+Note that \f[C]\[aq]=\[aq]\f[R] (equality symbol) that is used instead+of date in transactions you usually write.+It indicates the query by which you want to match the posting to add new+ones.+.IP+.nf+\f[C]+$ hledger rewrite -- -f input.journal -f rewrite-rules.journal > rewritten-tidy-output.journal+\f[R]+.fi+.PP+This is something similar to the commands pipeline:+.IP+.nf+\f[C]+$ hledger rewrite -- -f input.journal \[aq]\[ha]income\[aq] --add-posting \[aq](liabilities:tax)  *.33\[aq] \[rs]+  | hledger rewrite -- -f - expenses:gifts      --add-posting \[aq]budget:gifts  *-1\[aq]       \[rs]+                                                --add-posting \[aq]assets:budget  *1\[aq]       \[rs]+  > rewritten-tidy-output.journal+\f[R]+.fi+.PP+It is important to understand that relative order of such entries in+journal is important.+You can re-use result of previously added postings.+.SS Diff output format+.PP+To use this tool for batch modification of your journal files you may+find useful output in form of unified diff.+.IP+.nf+\f[C]+$ hledger rewrite -- --diff -f examples/sample.journal \[aq]\[ha]income\[aq] --add-posting \[aq](liabilities:tax)  *.33\[aq]+\f[R]+.fi+.PP+Output might look like:+.IP+.nf+\f[C]+--- /tmp/examples/sample.journal++++ /tmp/examples/sample.journal+\[at]\[at] -18,3 +18,4 \[at]\[at]+ 2008/01/01 income+-    assets:bank:checking  $1++    assets:bank:checking            $1+     income:salary++    (liabilities:tax)                0+\[at]\[at] -22,3 +23,4 \[at]\[at]+ 2008/06/01 gift+-    assets:bank:checking  $1++    assets:bank:checking            $1+     income:gifts++    (liabilities:tax)                0+\f[R]+.fi+.PP+If you\[aq]ll pass this through \f[C]patch\f[R] tool you\[aq]ll get+transactions containing the posting that matches your query be updated.+Note that multiple files might be update according to list of input+files specified via \f[C]--file\f[R] options and \f[C]include\f[R]+directives inside of these files.+.PP+Be careful.+Whole transaction being re-formatted in a style of output from+\f[C]hledger print\f[R].+.PP+See also:+.PP+https://github.com/simonmichael/hledger/issues/99+.SS rewrite vs. print --auto+.PP+This command predates print --auto, and currently does much the same+thing, but with these differences:+.IP \[bu] 2+with multiple files, rewrite lets rules in any file affect all other+files.+print --auto uses standard directive scoping; rules affect only child+files.+.IP \[bu] 2+rewrite\[aq]s query limits which transactions can be rewritten; all are+printed.+print --auto\[aq]s query limits which transactions are printed.+.IP \[bu] 2+rewrite applies rules specified on command line or in the journal.+print --auto applies rules specified in the journal.+.SS roi+.PP+roi+.PD 0+.P+.PD+Shows the time-weighted (TWR) and money-weighted (IRR) rate of return on+your investments.+.PP+This command assumes that you have account(s) that hold nothing but your+investments and whenever you record current appraisal/valuation of these+investments you offset unrealized profit and loss into account(s) that,+again, hold nothing but unrealized profit and loss.+.PP+Any transactions affecting balance of investment account(s) and not+originating from unrealized profit and loss account(s) are assumed to be+your investments or withdrawals.+.PP+At a minimum, you need to supply a query (which could be just an account+name) to select your investments with \f[C]--inv\f[R], and another query+to identify your profit and loss transactions with \f[C]--pnl\f[R].+.PP+It will compute and display the internalized rate of return (IRR) and+time-weighted rate of return (TWR) for your investments for the time+period requested.+Both rates of return are annualized before display, regardless of the+length of reporting interval.+.SS stats+.PP+stats+.PD 0+.P+.PD+Show some journal statistics.+.PP+The stats command displays summary information for the whole journal, or+a matched part of it.+With a reporting interval, it shows a report for each report period.+.PP+Example:+.IP+.nf+\f[C]+$ hledger stats+Main journal file        : /src/hledger/examples/sample.journal+Included journal files   : +Transactions span        : 2008-01-01 to 2009-01-01 (366 days)+Last transaction         : 2008-12-31 (2333 days ago)+Transactions             : 5 (0.0 per day)+Transactions last 30 days: 0 (0.0 per day)+Transactions last 7 days : 0 (0.0 per day)+Payees/descriptions      : 5+Accounts                 : 8 (depth 3)+Commodities              : 1 ($)+Market prices            : 12 ($)+\f[R]+.fi+.PP+This command also supports output destination and output format+selection.+.SS tags+.PP+tags+.PD 0+.P+.PD+List all the tag names used in the journal.+With a TAGREGEX argument, only tag names matching the regular expression+(case insensitive) are shown.+With QUERY arguments, only transactions matching the query are+considered.+With --values flag, the tags\[aq] unique values are listed instead.+.SS test+.PP+test+.PD 0+.P+.PD+Run built-in unit tests.+.PP+This command runs the unit tests built in to hledger-lib and hledger,+printing test names and results on stdout.+If any test fails, the exit code will be non-zero.+.PP+Test names include a group prefix.+If a (exact, case sensitive) group prefix, or a full test name is+provided as the first argument, only that group or test is run.+.PP+If a numeric second argument is provided, it will set the randomness+seed, for repeatable results from tests using randomness (currently none+of them).+.PP+This is mainly used by developers, but it\[aq]s nice to be able to+sanity-check your installed hledger executable at any time.+All tests are expected to pass - if you ever see otherwise, something+has gone wrong, please report a bug!+.SH ADD-ON COMMANDS+.PP+hledger also searches for external add-on commands, and will include+these in the commands list.+These are programs or scripts in your PATH whose name starts with+\f[C]hledger-\f[R] and ends with a recognised file extension (currently:+no extension, \f[C]bat\f[R],\f[C]com\f[R],\f[C]exe\f[R],+\f[C]hs\f[R],\f[C]lhs\f[R],\f[C]pl\f[R],\f[C]py\f[R],\f[C]rb\f[R],\f[C]rkt\f[R],\f[C]sh\f[R]).+.PP+Add-ons can be invoked like any hledger command, but there are a few+things to be aware of.+Eg if the \f[C]hledger-web\f[R] add-on is installed,+.IP \[bu] 2+\f[C]hledger -h web\f[R] shows hledger\[aq]s help, while+\f[C]hledger web -h\f[R] shows hledger-web\[aq]s help.+.IP \[bu] 2+Flags specific to the add-on must have a preceding \f[C]--\f[R] to hide+them from hledger.+So \f[C]hledger web --serve --port 9000\f[R] will be rejected; you must+use \f[C]hledger web -- --serve --port 9000\f[R].+.IP \[bu] 2+You can always run add-ons directly if preferred:+\f[C]hledger-web --serve --port 9000\f[R].+.PP+Add-ons are a relatively easy way to add local features or experiment+with new ideas.+They can be written in any language, but haskell scripts have a big+advantage: they can use the same hledger (and haskell) library functions+that built-in commands do, for command-line options, journal parsing,+reporting, etc.+.PP+Here are some hledger add-ons available:+.SS Official add-ons+.PP+These are maintained and released along with hledger.+.SS api+.PP+hledger-api serves hledger data as a JSON web API.+.SS ui+.PP+hledger-ui provides an efficient curses-style interface.+.SS web+.PP+hledger-web provides a simple web interface.+.SS Third party add-ons+.PP+These are maintained separately, and usually updated shortly after a+hledger release.+.SS diff+.PP+hledger-diff shows differences in an account\[aq]s transactions between+one journal file and another.+.SS iadd+.PP+hledger-iadd is a curses-style, more interactive replacement for the add+command.+.SS interest+.PP+hledger-interest generates interest transactions for an account+according to various schemes.+.SS irr+.PP+hledger-irr calculates the internal rate of return of an investment+account, but it\[aq]s superseded now by the built-in roi command.+.SS Experimental add-ons+.PP+These are available in source form in the hledger repo\[aq]s bin/+directory; installing them is pretty easy.+They may be less mature and documented than built-in commands.+Reading and tweaking these is a good way to start making your own!+.SS autosync+.PP+hledger-autosync is a symbolic link for easily running ledger-autosync,+if installed.+ledger-autosync does deduplicating conversion of OFX data and some CSV+formats, and can also download the data if your bank offers OFX Direct+Connect.+.SS chart+.PP+hledger-chart.hs is an old pie chart generator, in need of some love.+.SS check+.PP+hledger-check.hs checks more powerful account balance assertions.+.SH ENVIRONMENT+.PP+\f[B]COLUMNS\f[R] The screen width used by the register command.+Default: the full terminal width.+.PP+\f[B]LEDGER_FILE\f[R] The journal file path when not specified with+\f[C]-f\f[R].+Default: \f[C]\[ti]/.hledger.journal\f[R] (on windows, perhaps+\f[C]C:/Users/USER/.hledger.journal\f[R]).+.SH FILES+.PP+Reads data from one or more files in hledger journal, timeclock,+timedot, or CSV format specified with \f[C]-f\f[R], or+\f[C]$LEDGER_FILE\f[R], or \f[C]$HOME/.hledger.journal\f[R] (on windows,+perhaps \f[C]C:/Users/USER/.hledger.journal\f[R]).+.SH LIMITATIONS+.PP+The need to precede addon command options with \f[C]--\f[R] when invoked+from hledger is awkward.+.PP+When input data contains non-ascii characters, a suitable system locale+must be configured (or there will be an unhelpful error).+Eg on POSIX, set LANG to something other than C.+.PP+In a Microsoft Windows CMD window, non-ascii characters and colours are+not supported.+.PP+On Windows, non-ascii characters may not display correctly when running+a hledger built in CMD in MSYS/CYGWIN, or vice-versa.+.PP+In a Cygwin/MSYS/Mintty window, the tab key is not supported in hledger+add.+.PP+Not all of Ledger\[aq]s journal file syntax is supported.+See file format differences.+.PP+On large data files, hledger is slower and uses more memory than Ledger.+.SH TROUBLESHOOTING+.PP+Here are some issues you might encounter when you run hledger (and+remember you can also seek help from the IRC channel, mail list or bug+tracker):+.PP+\f[B]Successfully installed, but \[dq]No command \[aq]hledger\[aq]+found\[dq]\f[R]+.PD 0+.P+.PD+stack and cabal install binaries into a special directory, which should+be added to your PATH environment variable.+Eg on unix-like systems, that is \[ti]/.local/bin and \[ti]/.cabal/bin+respectively.+.PP+\f[B]I set a custom LEDGER_FILE, but hledger is still using the default+file\f[R]+.PD 0+.P+.PD+\f[C]LEDGER_FILE\f[R] should be a real environment variable, not just a+shell variable.+The command \f[C]env | grep LEDGER_FILE\f[R] should show it.+You may need to use \f[C]export\f[R].+Here\[aq]s an explanation.+.PP+\f[B]\[dq]Illegal byte sequence\[dq] or \[dq]Invalid or incomplete+multibyte or wide character\[dq] errors\f[R]+.PD 0+.P+.PD+In order to handle non-ascii letters and symbols (like \[Po]), hledger+needs an appropriate locale.+This is usually configured system-wide; you can also configure it+temporarily.+The locale may need to be one that supports UTF-8, if you built hledger+with GHC < 7.2 (or possibly always, I\[aq]m not sure yet).+.PP+Here\[aq]s an example of setting the locale temporarily, on ubuntu+gnu/linux:+.IP+.nf+\f[C]+$ file my.journal+my.journal: UTF-8 Unicode text                 # <- the file is UTF8-encoded+$ locale -a+C+en_US.utf8                             # <- a UTF8-aware locale is available+POSIX+$ LANG=en_US.utf8 hledger -f my.journal print   # <- use it for this command+\f[R]+.fi+.PP+Here\[aq]s one way to set it permanently, there are probably better+ways:+.IP+.nf+\f[C]+$ echo \[dq]export LANG=en_US.UTF-8\[dq] >>\[ti]/.bash_profile+$ bash --login+\f[R]+.fi+.PP+If we preferred to use eg \f[C]fr_FR.utf8\f[R], we might have to install+that first:+.IP+.nf+\f[C]+$ apt-get install language-pack-fr+$ locale -a+C+en_US.utf8+fr_BE.utf8+fr_CA.utf8+fr_CH.utf8+fr_FR.utf8+fr_LU.utf8+POSIX+$ LANG=fr_FR.utf8 hledger -f my.journal print+\f[R]+.fi+.PP+Note some platforms allow variant locale spellings, but not all (ubuntu+accepts \f[C]fr_FR.UTF8\f[R], mac osx requires exactly+\f[C]fr_FR.UTF-8\f[R]).   .SH "REPORTING BUGS"
embeddedfiles/hledger.info view
@@ -3,7 +3,7 @@  File: hledger.info,  Node: Top,  Next: EXAMPLES,  Up: (dir) -hledger(1) hledger 1.14+hledger(1) hledger 1.15 ***********************  This is hledger's command-line interface (there are also curses and web@@ -40,6 +40,7 @@ '~/.hledger.journal', or run 'hledger add' and follow the prompts.  Then try some commands like 'hledger print' or 'hledger balance'.  Run 'hledger' with no arguments for a list of commands.+ * Menu:  * EXAMPLES::@@ -129,9 +130,7 @@ * Period expressions:: * Depth limiting:: * Pivoting::-* Cost::-* Market value::-* Combining -B and -V::+* Valuation:: * Output destination:: * Output format:: * Regular expressions::@@ -208,7 +207,7 @@ '-p --period=PERIODEXP'       set start date, end date, and/or reporting interval all at once-     using period expressions syntax (overrides the flags above)+     using period expressions syntax '--date2'       match the secondary date instead (see command help for other@@ -303,6 +302,7 @@     'hledger register -p 'last year' "accounts receivable (receivable|payable)" amt:\>100'.+ * Menu:  * More escaping::@@ -393,25 +393,39 @@ 2.7 Unicode characters ====================== -hledger is expected to handle unicode (non-ascii) characters, but this-requires a well-configured environment.+hledger is expected to handle non-ascii characters correctly: -   To handle unicode characters in the command line or input data, a-system locale that can decode them must be configured (POSIX's default-'C' locale will not work).  Eg in bash, you could do:+   * they should be parsed correctly in input files and on the command+     line, by all hledger tools (add, iadd, hledger-web's+     search/add/edit forms, etc.) -export LANG=en_US.UTF-8+   * they should be displayed correctly by all hledger tools, and+     on-screen alignment should be preserved. -   See Troubleshooting for more about this.+   This requires a well-configured environment.  Here are some tips: -   Unicode characters should appear correctly in hledger's output.  For-the hledger and hledger-ui tools, this requires that+   * A system locale must be configured, and it must be one that can+     decode the characters being used.  In bash, you can set a locale+     like this: 'export LANG=en_US.UTF-8'.  There are some more details+     in Troubleshooting.  This step is essential - without it, hledger+     will quit on encountering a non-ascii character (as with all+     GHC-compiled programs). -   * your terminal supports unicode-   * the terminal's font includes the required unicode glyphs-   * the terminal is configured to display "wide" characters as double-     width (otherwise report alignment will be off)+   * your terminal software (eg Terminal.app, iTerm, CMD.exe, xterm..)+     must support unicode +   * the terminal must be using a font which includes the required+     unicode glyphs++   * the terminal should be configured to display wide characters as+     double width (for report alignment)++   * on Windows, for best results you should run hledger in the same+     kind of environment in which it was built.  Eg hledger built in the+     standard CMD.EXE environment (like the binaries on our download+     page) might show display problems when run in a cygwin or msys+     terminal, and vice versa.  (See eg #961).+  File: hledger.info,  Node: Input files,  Next: Smart dates,  Prev: Unicode characters,  Up: OPTIONS @@ -439,16 +453,16 @@ format automatically based on the file extension, or if that is not recognised, by trying each built-in "reader" in turn: -Reader:     Reads:                              Used for file extensions:------------------------------------------------------------------------------'journal'   hledger's journal format, also      '.journal' '.j'-            some Ledger journals                '.hledger' '.ledger'-'timeclock' timeclock files (precise time       '.timeclock'-            logging)-'timedot'   timedot files (approximate time     '.timedot'-            logging)-'csv'       comma-separated values (data        '.csv'-            interchange)+Reader:  Reads:                           Used for file extensions:+---------------------------------------------------------------------------+'journal'hledger's journal format, also   '.journal' '.j' '.hledger'+         some Ledger journals             '.ledger'+'timeclock'timeclock files (precise time  '.timeclock'+         logging)+'timedot'timedot files (approximate       '.timedot'+         time logging)+'csv'    comma-separated values (data     '.csv'+         interchange)     If needed (eg to ensure correct error messages when a file has the "wrong" extension), you can force a specific reader/format by prepending@@ -514,10 +528,19 @@    Often you will want to see a shorter time span, such as the current month.  You can specify a start and/or end date using '-b/--begin', '-e/--end', '-p/--period' or a 'date:' query (described below).  All of-these accept the smart date syntax.  One important thing to be aware of-when specifying end dates: as in Ledger, end dates are exclusive, so you-need to write the date _after_ the last day you want to include.+these accept the smart date syntax. +   Some notes:++   * As in Ledger, end dates are exclusive, so you need to write the+     date _after_ the last day you want to include.+   * As noted in reporting options: among start/end dates specified with+     _options_, the last (i.e.  right-most) option takes precedence.+   * The effective report start and end dates are the intersection of+     the start/end dates from options and that from 'date:' queries.+     That is, 'date:2019-01 date:2019 -p'2000 to 2030'' yields January+     2019, the smallest common time span.+    Examples:  '-b 2016/3/17'      begin on St.  Patrick's day 2016@@ -540,7 +563,7 @@ The basic intervals can be selected with one of '-D/--daily', '-W/--weekly', '-M/--monthly', '-Q/--quarterly', or '-Y/--yearly'.  More complex intervals may be specified with a period expression.  Report-intervals can not be specified with a query, currently.+intervals can not be specified with a query.   File: hledger.info,  Node: Period expressions,  Next: Depth limiting,  Prev: Report intervals,  Up: OPTIONS@@ -663,7 +686,7 @@ (so '-2', '--depth=2' or 'depth:2' are basically equivalent).  -File: hledger.info,  Node: Pivoting,  Next: Cost,  Prev: Depth limiting,  Up: OPTIONS+File: hledger.info,  Node: Pivoting,  Next: Valuation,  Prev: Depth limiting,  Up: OPTIONS  2.14 Pivoting =============@@ -720,32 +743,55 @@               -2 EUR  -File: hledger.info,  Node: Cost,  Next: Market value,  Prev: Pivoting,  Up: OPTIONS+File: hledger.info,  Node: Valuation,  Next: Output destination,  Prev: Pivoting,  Up: OPTIONS -2.15 Cost-=========+2.15 Valuation+============== -The '-B/--cost' flag converts amounts to their cost at transaction time,-if they have a transaction price specified.+* Menu: +* -B Cost::+* -V Market value::+* -X Market value in specified commodity::+* --value::+* Combining -B -V -X --value::+ -File: hledger.info,  Node: Market value,  Next: Combining -B and -V,  Prev: Cost,  Up: OPTIONS+File: hledger.info,  Node: -B Cost,  Next: -V Market value,  Up: Valuation -2.16 Market value-=================+2.15.1 -B: Cost+--------------- -The '-V/--value' flag converts reported amounts to their current market-value.-Specifically, when there is a market price (P directive) for the-amount's commodity, dated on or before today's date (or the report end-date if specified), the amount will be converted to the price's-commodity.+The '-B/--cost' flag converts amounts to their cost (or selling price)+at transaction time, if they have a transaction price specified.  This+flag is equivalent to '--value=cost', described below. -   When there are multiple applicable P directives, -V chooses the most-recent one, or in case of equal dates, the last-parsed one.++File: hledger.info,  Node: -V Market value,  Next: -X Market value in specified commodity,  Prev: -B Cost,  Up: Valuation -   For example:+2.15.2 -V: Market value+----------------------- +The '-V/--market' flag converts reported amounts to their market value+in a default valuation commodity, using the historical market prices in+effect on a default valuation date.++   For single period reports, the valuation date is today.  For+multiperiod reports, it is the last day of each subperiod.++   The valuation commodity will be the one referenced in the latest+applicable market price dated on or before the valuation date.  If most+of your P declarations lead to a single home currency, this will usually+be what you want.++   Unlike the similar flag in Ledger, it does not infer market prices+from transaction prices.  In hledger, -B uses transaction prices, -V and+-X use market prices.++   It is equivalent to '--value=now' or '--value=end'.++   Here's a quick example:+ # one euro is worth this many dollars from nov 1 P 2016/11/01 € $1.10 @@ -773,27 +819,275 @@ $ hledger -f t.j bal -N euros -V              $103.00  assets:euros -   Currently, hledger's -V only uses market prices recorded with P-directives, not transaction prices (unlike Ledger).++File: hledger.info,  Node: -X Market value in specified commodity,  Next: --value,  Prev: -V Market value,  Up: Valuation -   Currently, -V has a limitation in multicolumn balance reports: it-uses the market prices on the report end date for all columns.  (Instead-of the prices on each column's end date.)+2.15.3 -X: Market value in specified commodity+---------------------------------------------- +The '-X/--exchange' option is like '-V/--market' except it takes a+commodity symbol argument, so that you can select a different target+commodity.  It is similar to the same option in Ledger, with the same+caveat mentioned for '-V'/'--value' above.  It is equivalent to+'--value=now,COMM' or '--value=end,COMM'; for more details, read on.+ -File: hledger.info,  Node: Combining -B and -V,  Next: Output destination,  Prev: Market value,  Up: OPTIONS+File: hledger.info,  Node: --value,  Next: Combining -B -V -X --value,  Prev: -X Market value in specified commodity,  Up: Valuation -2.17 Combining -B and -V-========================+2.15.4 -value+------------- -Using -B/-cost and -V/-value together is currently allowed, but the-results are probably not meaningful.  Let us know if you find a use for-this.+_(experimental, added 201905)_ +   '-B', '-V' and '-X' are special cases of the more general '--value'+option:++ --value=TYPE[,COMM]  TYPE is cost, end, now or YYYY-MM-DD.+                      COMM is an optional commodity symbol.+                      Shows amounts converted to:+                      - cost commodity using transaction prices (then optionally to COMM using market prices at period end(s))+                      - default valuation commodity (or COMM) using market prices at period end(s)+                      - default valuation commodity (or COMM) using current market prices+                      - default valuation commodity (or COMM) using market prices at some date++* Menu:++* Valuation type::+* Valuation commodity::+* --value examples::+* Effect of --value on reports::+ -File: hledger.info,  Node: Output destination,  Next: Output format,  Prev: Combining -B and -V,  Up: OPTIONS+File: hledger.info,  Node: Valuation type,  Next: Valuation commodity,  Up: --value -2.18 Output destination+2.15.4.1 Valuation type+.......................++TYPE is one of these keywords, or their first letter, or a date (which+must be 8 digits with '-' or '/' or '.' separators):++'--value=cost'++     Convert amounts to cost, using the prices recorded in transactions.+     '-B'/'--cost' is equivalent to this.+'--value=end'++     Convert amounts to their value in default valuation commodity using+     market prices on the last day of the report period (or of each+     subperiod in a multiperiod report).  When no report period is+     specified, uses the journal's last transaction date.+'--value=now'++     Convert amounts to their value in default valuation commodity using+     current market prices (as of when report is generated).+     '-V'/'--market' is equivalent to this.+'--value=YYYY-MM-DD'++     Convert amounts to their value in default valuation commodity using+     market prices on this date.  Eg '--value=2019-04-25'.+++File: hledger.info,  Node: Valuation commodity,  Next: --value examples,  Prev: Valuation type,  Up: --value++2.15.4.2 Valuation commodity+............................++The default valuation commodity is the commodity mentioned in the most+recent applicable market price declaration.  When all your price+declarations lead to a single home currency, this will usually do what+you want.++   To select a different valuation commodity: write the commodity symbol+after the valuation type, separated by a comma (eg:+*'--value=now,EUR'*).  This will use, in this preferred order:++   * declared prices (from source commodity to valuation commodity)+   * reverse prices (declared prices from valuation to source commodity,+     inverted)+   * indirect prices (prices calculated from the shortest chain of+     declared or reverse prices from source to valuation commodity).+++File: hledger.info,  Node: --value examples,  Next: Effect of --value on reports,  Prev: Valuation commodity,  Up: --value++2.15.4.3 -value examples+........................++Here are the effects of '--value' as seen with 'print':++P 2000-01-01 A  1 B+P 2000-02-01 A  2 B+P 2000-03-01 A  3 B+P 2000-04-01 A  4 B++2000-01-01+  (a)      1 A @ 5 B++2000-02-01+  (a)      1 A @ 6 B++2000-03-01+  (a)      1 A @ 7 B++   Show the cost of each posting:++$ hledger -f- print --value=cost+2000/01/01+    (a)             5 B++2000/02/01+    (a)             6 B++2000/03/01+    (a)             7 B++   Show the value as of the last day of the report period (2000-02-29):++$ hledger -f- print --value=end date:2000/01-2000/03+2000-01-01+    (a)             2 B++2000-02-01+    (a)             2 B++   With no report period specified, that shows the value as of the last+day of the journal (2000-03-01):++$ hledger -f- print --value=end+2000/01/01+    (a)             3 B++2000/02/01+    (a)             3 B++2000/03/01+    (a)             3 B++   Show the current value (the 2000-04-01 price is still in effect+today):++$ hledger -f- print --value=now+2000-01-01+    (a)             4 B++2000-02-01+    (a)             4 B++2000-03-01+    (a)             4 B++   Show the value on 2000/01/15:++$ hledger -f- print --value=2000-01-15+2000/01/01+    (a)             1 B++2000/02/01+    (a)             1 B++2000/03/01+    (a)             1 B++   You may need to explicitly set a commodity's display style, when+reverse prices are used.  Eg this output might be surprising:++P 2000-01-01 A 2B++2000-01-01+  a  1B+  b++$ hledger print -x -X A+2000/01/01+    a               0+    b               0++   Explanation: because there's no amount or commodity directive+specifying a display style for A, 0.5A gets the default style, which+shows no decimal digits.  Because the displayed amount looks like zero,+the commodity symbol and minus sign are not displayed either.  Adding a+commodity directive sets a more useful display style for A:++P 2000-01-01 A 2B+commodity 0.00A++2000-01-01+  a  1B+  b++$ hledger print -X A+2000/01/01+    a           0.50A+    b          -0.50A+++File: hledger.info,  Node: Effect of --value on reports,  Prev: --value examples,  Up: --value++2.15.4.4 Effect of -value on reports+....................................++Below is how '--value' affects each of hledger's reports, currently.+You're not expected to remember all this, but when troubleshooting a+report, look here.  If you find problems - useless reports, misbehaving+reports, or error messages being printed - please report them (with+reproducible examples) eg at #329.++Report type   '--value'      '--value' 'end'            '--value'+              'cost'                                    'DATE'/'now' +----------------------------------------------------------------------------+*print*+posting       cost, as       market value at report     market value at+amounts       recorded in    end                        DATE+              transaction+balance       show           show unvalued              show unvalued+assertions/assignmentsunvalued+*register*+starting      cost of        market value at day        market value at+balance       starting       before report start        DATE+with -H       balance+posting       cost           market value at report     market value at+amounts                      end                        DATE+posting       summarised     market value each          market value each+amounts,      cost           summary posting at         summary posting+multiperiod                  period end                 at DATE+running       sum/average    sum/average of the         sum/average of+total/average of the         displayed values           the displayed+              displayed                                 values+              values+*balance+(bs, cf,+is..)*+starting      costs of       market value at day        market value at+balances      starting       before report start of     DATE of sum of+with -H       balances       sum of previous postings   previous postings+balances,     summed costs   market value at period     market value at+simple                       end of sum of postings     DATE of sum of+balance                                                 postings+report+balances,     summed costs   market value at period     market value at+multiperiod                  end of sum of postings     DATE of sum of+report                                                  postings+budget        costs of       budget-setting periodic    budget-setting+amounts       budget         txns are valued at         periodic txns are+with          amounts        period end                 valued at DATE+-budget+column/row/grandsum/average  market value at period     market value at+totals/averagesof the        end of sum/average of      DATE of+              displayed      postings                   sum/average of+              values                                    postings+++File: hledger.info,  Node: Combining -B -V -X --value,  Prev: --value,  Up: Valuation++2.15.5 Combining -B, -V, -X, -value+-----------------------------------++The rightmost of these flags wins.+++File: hledger.info,  Node: Output destination,  Next: Output format,  Prev: Valuation,  Up: OPTIONS++2.16 Output destination =======================  Some commands (print, register, stats, the balance commands) can write@@ -806,7 +1100,7 @@  File: hledger.info,  Node: Output format,  Next: Regular expressions,  Prev: Output destination,  Up: OPTIONS -2.19 Output format+2.17 Output format ==================  Some commands can write their output in other formats.  Eg print and@@ -820,7 +1114,7 @@  File: hledger.info,  Node: Regular expressions,  Prev: Output format,  Up: OPTIONS -2.20 Regular expressions+2.18 Regular expressions ========================  hledger uses regular expressions in a number of places:@@ -987,6 +1281,7 @@    Here are all the builtin commands in alphabetical order.  See also 'hledger' for a more organised command list, and 'hledger CMD -h' for detailed command help.+ * Menu:  * accounts::@@ -1132,6 +1427,10 @@ Starting the next transaction (. or ctrl-D/ctrl-C to quit) Date [2015/05/22]: <CTRL-D> $ +   On Microsoft Windows, the add command makes sure that no part of the+file path ends with a period, as it can cause data loss on that platform+(cf #1056).+  File: hledger.info,  Node: balance,  Next: balancesheet,  Prev: add,  Up: COMMANDS @@ -1162,6 +1461,7 @@ is used to ensure this (more below).     The balance command can produce several styles of report:+ * Menu:  * Classic balance report::@@ -1250,7 +1550,9 @@    '%[MIN][.MAX](FIELDNAME)'     * MIN pads with spaces to at least this width (optional)+    * MAX truncates at this width (optional)+    * FIELDNAME must be enclosed in parentheses, and can be one of:          * 'depth_spacer' - a number of spaces equal to the account's@@ -1390,6 +1692,10 @@      ----------------------++-------------------------------------                            ||           0           0           0  +   Note that '--cumulative' or '--historical/-H' disable+'--row-total/-T', since summing end balances generally does not make+sense.+    Multicolumn balance reports display accounts in flat mode by default; to see the hierarchy, use '--tree'. @@ -1557,6 +1863,7 @@                       ||      0 [              0]       0 [              0]      For more examples, see Budgeting and Forecasting.+ * Menu:  * Nested budgets::@@ -1696,7 +2003,9 @@ each report period.  As with multicolumn balance reports, you can alter the report mode with '--change'/'--cumulative'/'--historical'.  Normally balancesheet shows historical ending balances, which is what you need-for a balance sheet; note this means it ignores report begin dates.+for a balance sheet; note this means it ignores report begin dates (and+'-T/--row-total', since summing end balances generally does not make+sense).     This command also supports output destination and output format selection.@@ -1815,7 +2124,7 @@     The closing transaction transfers balances to "equity:closing balances".  The opening transaction transfers balances from-"equity:opening balances".  You can chose to print just one of the+"equity:opening balances".  You can choose to print just one of the transactions by using the '--opening' or '--closing' flag.     If you split your journal files by time (eg yearly), you will@@ -1849,6 +2158,10 @@ this command with -auto, the balance assertions will probably always require -auto. +   When account balances have cost information (transaction prices), the+closing/opening transactions will preserve it, so that eg balance -B+reports will not be affected.+    Examples:     Carrying asset/liability balances into a new file for 2019, all from@@ -1959,7 +2272,30 @@  $ hledger import --dry ... | hledger -f- print unknown --ignore-assertions +* Menu:++* Importing balance assignments::+ +File: hledger.info,  Node: Importing balance assignments,  Up: import++4.13.1 Importing balance assignments+------------------------------------++Entries added by import will have their posting amounts made explicit+(like 'hledger print -x').  This means that any balance assignments in+imported files must be evaluated; but, imported files don't get to see+the main file's account balances.  As a result, importing entries with+balance assignments (eg from an institution that provides only balances+and not posting amounts) will probably generate incorrect posting+amounts.  To avoid this problem, use print instead of import:++$ hledger print IMPORTFILE [--new] >> $LEDGER_FILE++   (If you think import should leave amounts implicit like print does,+please test it and send a pull request.)++ File: hledger.info,  Node: incomestatement,  Next: prices,  Prev: import,  Up: COMMANDS  4.14 incomestatement@@ -2225,6 +2561,7 @@ these will be adjusted outward if necessary to contain a whole number of intervals.  This ensures that the first and last intervals are full length and comparable to the others in the report.+ * Menu:  * Custom register output::@@ -2292,9 +2629,9 @@     Examples: -hledger-rewrite.hs ^income --add-posting '(liabilities:tax)  *.33  ; income tax' --add-posting '(reserve:gifts)  $100'-hledger-rewrite.hs expenses:gifts --add-posting '(reserve:gifts)  *-1"'-hledger-rewrite.hs -f rewrites.hledger+$ hledger-rewrite.hs ^income --add-posting '(liabilities:tax)  *.33  ; income tax' --add-posting '(reserve:gifts)  $100'+$ hledger-rewrite.hs expenses:gifts --add-posting '(reserve:gifts)  *-1"'+$ hledger-rewrite.hs -f rewrites.hledger     rewrites.hledger may consist of entries like: @@ -2483,6 +2820,7 @@ Payees/descriptions      : 5 Accounts                 : 8 (depth 3) Commodities              : 1 ($)+Market prices            : 12 ($)     This command also supports output destination and output format selection.@@ -2497,7 +2835,8 @@ List all the tag names used in the journal.  With a TAGREGEX argument, only tag names matching the regular expression (case insensitive) are shown.  With QUERY arguments, only transactions matching the query are-considered.+considered.  With -values flag, the tags' unique values are listed+instead.   File: hledger.info,  Node: test,  Prev: tags,  Up: COMMANDS@@ -2557,6 +2896,7 @@ options, journal parsing, reporting, etc.     Here are some hledger add-ons available:+ * Menu:  * Official add-ons::@@ -2570,6 +2910,7 @@ ====================  These are maintained and released along with hledger.+ * Menu:  * api::@@ -2608,6 +2949,7 @@  These are maintained separately, and usually updated shortly after a hledger release.+ * Menu:  * diff::@@ -2661,6 +3003,7 @@ installing them is pretty easy.  They may be less mature and documented than built-in commands.  Reading and tweaking these is a good way to start making your own!+ * Menu:  * autosync::@@ -2697,160 +3040,176 @@  Tag Table: Node: Top68-Node: EXAMPLES1884-Ref: #examples1984-Node: OPTIONS3630-Ref: #options3732-Node: General options4167-Ref: #general-options4292-Node: Command options6974-Ref: #command-options7125-Node: Command arguments7523-Ref: #command-arguments7677-Node: Argument files7798-Ref: #argument-files7974-Node: Special characters in arguments and queries8240-Ref: #special-characters-in-arguments-and-queries8474-Node: More escaping8924-Ref: #more-escaping9086-Node: Even more escaping9382-Ref: #even-more-escaping9576-Node: Less escaping10247-Ref: #less-escaping10409-Node: Command line tips10654-Ref: #command-line-tips10840-Node: Unicode characters11217-Ref: #unicode-characters11373-Node: Input files12098-Ref: #input-files12234-Node: Smart dates14204-Ref: #smart-dates14345-Node: Report start & end date15751-Ref: #report-start-end-date15923-Node: Report intervals16989-Ref: #report-intervals17154-Node: Period expressions17555-Ref: #period-expressions17715-Node: Depth limiting21672-Ref: #depth-limiting21816-Node: Pivoting22158-Ref: #pivoting22276-Node: Cost23952-Ref: #cost24060-Node: Market value24178-Ref: #market-value24313-Node: Combining -B and -V25679-Ref: #combining--b-and--v25842-Node: Output destination25989-Ref: #output-destination26151-Node: Output format26434-Ref: #output-format26586-Node: Regular expressions26971-Ref: #regular-expressions27108-Node: QUERIES28469-Ref: #queries28571-Node: COMMANDS32533-Ref: #commands32645-Node: accounts33645-Ref: #accounts33743-Node: activity34442-Ref: #activity34552-Node: add34935-Ref: #add35034-Node: balance37621-Ref: #balance37732-Node: Classic balance report39173-Ref: #classic-balance-report39346-Node: Customising the classic balance report40715-Ref: #customising-the-classic-balance-report40943-Node: Colour support43017-Ref: #colour-support43184-Node: Flat mode43357-Ref: #flat-mode43505-Node: Depth limited balance reports43918-Ref: #depth-limited-balance-reports44118-Node: Multicolumn balance report44574-Ref: #multicolumn-balance-report44772-Node: Budget report49952-Ref: #budget-report50095-Node: Nested budgets55296-Ref: #nested-budgets55408-Ref: #output-format-158888-Node: balancesheet58966-Ref: #balancesheet59102-Node: balancesheetequity60336-Ref: #balancesheetequity60485-Node: cashflow61046-Ref: #cashflow61174-Node: check-dates62202-Ref: #check-dates62329-Node: check-dupes62608-Ref: #check-dupes62732-Node: close63025-Ref: #close63133-Node: files66546-Ref: #files66647-Node: help66794-Ref: #help66894-Node: import67987-Ref: #import68101-Node: incomestatement68845-Ref: #incomestatement68979-Node: prices70315-Ref: #prices70430-Node: print70709-Ref: #print70819-Node: print-unique75312-Ref: #print-unique75438-Node: register75723-Ref: #register75850-Node: Custom register output80021-Ref: #custom-register-output80150-Node: register-match81412-Ref: #register-match81546-Node: rewrite81897-Ref: #rewrite82012-Node: Re-write rules in a file83861-Ref: #re-write-rules-in-a-file83995-Node: Diff output format85205-Ref: #diff-output-format85374-Node: rewrite vs print --auto86466-Ref: #rewrite-vs.-print---auto86645-Node: roi87201-Ref: #roi87299-Node: stats88311-Ref: #stats88410-Node: tags89164-Ref: #tags89262-Node: test89492-Ref: #test89576-Node: ADD-ON COMMANDS90337-Ref: #add-on-commands90447-Node: Official add-ons91734-Ref: #official-add-ons91874-Node: api91961-Ref: #api92050-Node: ui92102-Ref: #ui92201-Node: web92259-Ref: #web92348-Node: Third party add-ons92394-Ref: #third-party-add-ons92569-Node: diff92704-Ref: #diff92801-Node: iadd92900-Ref: #iadd93014-Node: interest93097-Ref: #interest93218-Node: irr93313-Ref: #irr93411-Node: Experimental add-ons93542-Ref: #experimental-add-ons93694-Node: autosync93974-Ref: #autosync94085-Node: chart94324-Ref: #chart94443-Node: check94514-Ref: #check94616+Node: EXAMPLES1885+Ref: #examples1985+Node: OPTIONS3631+Ref: #options3733+Node: General options4132+Ref: #general-options4257+Node: Command options6911+Ref: #command-options7062+Node: Command arguments7460+Ref: #command-arguments7614+Node: Argument files7735+Ref: #argument-files7911+Node: Special characters in arguments and queries8177+Ref: #special-characters-in-arguments-and-queries8411+Node: More escaping8862+Ref: #more-escaping9024+Node: Even more escaping9320+Ref: #even-more-escaping9514+Node: Less escaping10185+Ref: #less-escaping10347+Node: Command line tips10592+Ref: #command-line-tips10778+Node: Unicode characters11155+Ref: #unicode-characters11311+Node: Input files12723+Ref: #input-files12859+Node: Smart dates14788+Ref: #smart-dates14929+Node: Report start & end date16335+Ref: #report-start-end-date16507+Node: Report intervals17931+Ref: #report-intervals18096+Node: Period expressions18486+Ref: #period-expressions18646+Node: Depth limiting22603+Ref: #depth-limiting22747+Node: Pivoting23089+Ref: #pivoting23212+Node: Valuation24888+Ref: #valuation25017+Node: -B Cost25145+Ref: #b-cost25256+Node: -V Market value25454+Ref: #v-market-value25628+Node: -X Market value in specified commodity27034+Ref: #x-market-value-in-specified-commodity27254+Node: --value27594+Ref: #value27759+Node: Valuation type28560+Ref: #valuation-type28696+Node: Valuation commodity29581+Ref: #valuation-commodity29752+Node: --value examples30452+Ref: #value-examples30629+Node: Effect of --value on reports32612+Ref: #effect-of---value-on-reports32785+Node: Combining -B -V -X --value35476+Ref: #combining--b--v--x---value35638+Node: Output destination35674+Ref: #output-destination35826+Node: Output format36109+Ref: #output-format36261+Node: Regular expressions36646+Ref: #regular-expressions36783+Node: QUERIES38144+Ref: #queries38246+Node: COMMANDS42208+Ref: #commands42320+Node: accounts43321+Ref: #accounts43419+Node: activity44118+Ref: #activity44228+Node: add44611+Ref: #add44710+Node: balance47455+Ref: #balance47566+Node: Classic balance report49008+Ref: #classic-balance-report49181+Node: Customising the classic balance report50550+Ref: #customising-the-classic-balance-report50778+Node: Colour support52854+Ref: #colour-support53021+Node: Flat mode53194+Ref: #flat-mode53342+Node: Depth limited balance reports53755+Ref: #depth-limited-balance-reports53955+Node: Multicolumn balance report54411+Ref: #multicolumn-balance-report54609+Node: Budget report59923+Ref: #budget-report60066+Node: Nested budgets65268+Ref: #nested-budgets65380+Ref: #output-format-168860+Node: balancesheet68938+Ref: #balancesheet69074+Node: balancesheetequity70389+Ref: #balancesheetequity70538+Node: cashflow71099+Ref: #cashflow71227+Node: check-dates72255+Ref: #check-dates72382+Node: check-dupes72661+Ref: #check-dupes72785+Node: close73078+Ref: #close73186+Node: files76773+Ref: #files76874+Node: help77021+Ref: #help77121+Node: import78214+Ref: #import78328+Node: Importing balance assignments79116+Ref: #importing-balance-assignments79264+Node: incomestatement79913+Ref: #incomestatement80047+Node: prices81383+Ref: #prices81498+Node: print81777+Ref: #print81887+Node: print-unique86380+Ref: #print-unique86506+Node: register86791+Ref: #register86918+Node: Custom register output91090+Ref: #custom-register-output91219+Node: register-match92481+Ref: #register-match92615+Node: rewrite92966+Ref: #rewrite93081+Node: Re-write rules in a file94936+Ref: #re-write-rules-in-a-file95070+Node: Diff output format96280+Ref: #diff-output-format96449+Node: rewrite vs print --auto97541+Ref: #rewrite-vs.-print---auto97720+Node: roi98276+Ref: #roi98374+Node: stats99386+Ref: #stats99485+Node: tags100273+Ref: #tags100371+Node: test100665+Ref: #test100749+Node: ADD-ON COMMANDS101510+Ref: #add-on-commands101620+Node: Official add-ons102908+Ref: #official-add-ons103048+Node: api103136+Ref: #api103225+Node: ui103277+Ref: #ui103376+Node: web103434+Ref: #web103523+Node: Third party add-ons103569+Ref: #third-party-add-ons103744+Node: diff103880+Ref: #diff103977+Node: iadd104076+Ref: #iadd104190+Node: interest104273+Ref: #interest104394+Node: irr104489+Ref: #irr104587+Node: Experimental add-ons104718+Ref: #experimental-add-ons104870+Node: autosync105151+Ref: #autosync105262+Node: chart105501+Ref: #chart105620+Node: check105691+Ref: #check105793  End Tag Table
embeddedfiles/hledger.txt view
@@ -173,7 +173,7 @@         -p --period=PERIODEXP               set  start date, end date, and/or reporting interval all at once-              using period expressions syntax (overrides the flags above)+              using period expressions syntax         --date2               match the secondary date instead (see  command  help  for  other@@ -244,7 +244,7 @@        shell such as <, >, (, ), | and $, should be escaped by enclosing  them        in quotes or by writing backslashes before the characters.  Eg: -       hledger register -p 'last year' "accounts receivable (receiv-+       hledger   register   -p   'last  year'  "accounts  receivable  (receiv-        able|payable)" amt:\>100.     More escaping@@ -310,27 +310,39 @@        to troubleshoot.     Unicode characters-       hledger is expected to handle unicode (non-ascii) characters, but  this-       requires a well-configured environment.+       hledger is expected to handle non-ascii characters correctly: -       To  handle unicode characters in the command line or input data, a sys--       tem locale that can decode them must be configured (POSIX's  default  C-       locale will not work).  Eg in bash, you could do:+       o they should be parsed correctly in input files  and  on  the  command+         line,  by all hledger tools (add, iadd, hledger-web's search/add/edit+         forms, etc.) -              export LANG=en_US.UTF-8+       o they should be displayed correctly by  all  hledger  tools,  and  on-+         screen alignment should be preserved. -       See Troubleshooting for more about this.+       This requires a well-configured environment.  Here are some tips: -       Unicode  characters  should  appear correctly in hledger's output.  For-       the hledger and hledger-ui tools, this requires that+       o A  system  locale  must  be  configured,  and it must be one that can+         decode the characters being used.  In bash, you can set a locale like+         this:  export LANG=en_US.UTF-8.  There are some more details in Trou-+         bleshooting.  This step is essential - without it, hledger will  quit+         on  encountering a non-ascii character (as with all GHC-compiled pro-+         grams). -       o your terminal supports unicode+       o your terminal software (eg  Terminal.app,  iTerm,  CMD.exe,  xterm..)+         must support unicode -       o the terminal's font includes the required unicode glyphs+       o the terminal must be using a font which includes the required unicode+         glyphs -       o the terminal is configured to display  "wide"  characters  as  double-         width (otherwise report alignment will be off)+       o the terminal should be configured to display wide characters as  dou-+         ble width (for report alignment) +       o on  Windows, for best results you should run hledger in the same kind+         of environment in which it was built.  Eg hledger built in the  stan-+         dard  CMD.EXE  environment  (like  the binaries on our download page)+         might show display problems when run in a cygwin  or  msys  terminal,+         and vice versa.  (See eg #961).+    Input files        hledger reads transactions from a data file (and the add command writes        to it).  By default this file is $HOME/.hledger.journal (or on Windows,@@ -354,16 +366,16 @@        recognised, by trying each built-in "reader" in turn:  -       Reader:      Reads:                               Used for file extensions:+       Reader:    Reads:                            Used for file extensions:        ------------------------------------------------------------------------------       journal      hledger's  journal  format,  also    .journal    .j    .hledger-                    some Ledger journals                 .ledger-       timeclock    timeclock   files  (precise  time    .timeclock-                    logging)-       timedot      timedot files  (approximate  time    .timedot-                    logging)-       csv          comma-separated    values   (data    .csv-                    interchange)+       journal    hledger's  journal format, also   .journal .j .hledger .ledger+                  some Ledger journals+       time-      timeclock  files  (precise time   .timeclock+       clock      logging)+       timedot    timedot files (approximate time   .timedot+                  logging)+       csv        comma-separated   values  (data   .csv+                  interchange)         If needed (eg to ensure correct error messages  when  a  file  has  the        "wrong"  extension), you can force a specific reader/format by prepend-@@ -392,55 +404,66 @@        Examples:  -       2004/10/1,     2004-01-01,            exact  date, several sepa--       2004.9.1                              rators allowed.   Year  is-                                             4+  digits, month is 1-12,-                                             day is 1-31-       2004                                  start of year--       2004/10                               start of month-       10/1                                  month and day  in  current-                                             year-       21                                    day in current month-       october, oct                          start  of month in current-                                             year-       yesterday, today, tomorrow            -1, 0, 1 days from today-       last/this/next day/week/month/quar-   -1, 0, 1 periods from  the-       ter/year                              current period-       20181201                              8   digit   YYYYMMDD  with-                                             valid year month and day-       201812                                6 digit YYYYMM with  valid-                                             year and month+       2004/10/1,     2004-01-01,   exact  date, several sepa-+       2004.9.1                     rators allowed.   Year  is+                                    4+  digits, month is 1-12,+                                    day is 1-31+       2004                         start of year+       2004/10                      start of month+       10/1                         month and day  in  current+                                    year+       21                           day in current month+       october, oct                 start  of month in current+                                    year+       yesterday, today, tomorrow   -1, 0, 1 days from today+       last/this/next               -1,  0, 1 periods from the+       day/week/month/quar-         current period+       ter/year+       20181201                     8  digit   YYYYMMDD   with+                                    valid year month and day+       201812                       6  digit YYYYMM with valid+                                    year and month -       Counterexamples  -  malformed  digit  sequences  might  give surprising+       Counterexamples -  malformed  digit  sequences  might  give  surprising        results:  -       201813      6 digits with  an  invalid-                   month  is  parsed as start+       201813      6  digits  with an invalid+                   month is parsed  as  start                    of 6-digit year-       20181301    8 digits with  an  invalid-                   month  is  parsed as start+       20181301    8  digits  with an invalid+                   month is parsed  as  start                    of 8-digit year-       20181232    8 digits with  an  invalid+       20181232    8  digits  with an invalid                    day gives an error        201801012   9+ digits beginning with a                    valid  YYYYMMDD  gives  an                    error     Report start & end date-       Most  hledger  reports  show  the  full span of time represented by the+       Most hledger reports show the full span  of  time  represented  by  the        journal data, by default.  So, the effective report start and end dates-       will  be  the earliest and latest transaction or posting dates found in+       will be the earliest and latest transaction or posting dates  found  in        the journal. -       Often you will want to see a shorter time span,  such  as  the  current-       month.   You  can  specify  a  start  and/or end date using -b/--begin,+       Often  you  will  want  to see a shorter time span, such as the current+       month.  You can specify a  start  and/or  end  date  using  -b/--begin,        -e/--end, -p/--period or a date: query (described below).  All of these-       accept  the smart date syntax.  One important thing to be aware of when-       specifying end dates: as in Ledger, end dates  are  exclusive,  so  you-       need to write the date after the last day you want to include.+       accept the smart date syntax. +       Some notes:++       o As in Ledger, end dates are exclusive, so you need to write the  date+         after the last day you want to include.++       o As  noted  in reporting options: among start/end dates specified with+         options, the last (i.e.  right-most) option takes precedence.++       o The effective report start and end dates are the intersection of  the+         start/end  dates  from options and that from date: queries.  That is,+         date:2019-01 date:2019 -p'2000 to  2030'  yields  January  2019,  the+         smallest common time span.+        Examples:  @@ -467,7 +490,7 @@        The   basic   intervals   can  be  selected  with  one  of  -D/--daily,        -W/--weekly, -M/--monthly, -Q/--quarterly, or -Y/--yearly.   More  com-        plex  intervals  may  be  specified  with  a period expression.  Report-       intervals can not be specified with a query, currently.+       intervals can not be specified with a query.     Period expressions        The -p/--period option accepts period expressions, a shorthand  way  of@@ -538,44 +561,43 @@        For example:  -       -p "weekly from 2009/1/1 to 2009/4/1"+       -p "weekly from 2009/1/1  to  2009/4/1"        --  starts  on 2008/12/29, closest pre-        ceeding Monday        -p "monthly in 2008/11/25" -- starts on        2018/11/01-       -p "quar--       terly from 2009-05-05 to 2009-06-01"  --       starts    on    2009/04/01,   ends   on-       2009/06/30, which are  first  and  last-       days of Q2 2009+       -p   "quarterly   from   2009-05-05  to+       2009-06-01"  -  starts  on  2009/04/01,+       ends on 2009/06/30, which are first and+       last days of Q2 2009        -p "yearly from 2009-12-29" - starts on        2009/01/01, first day of 2009         The  following  more  complex  report  intervals  are  also  supported:-       biweekly,         bimonthly,         every day|week|month|quarter|year,-       every N days|weeks|months|quarters|years.+       biweekly,  bimonthly,  every   day|week|month|quarter|year,   every   N+       days|weeks|months|quarters|years. -       All of these will start on the first day of the  requested  period  and+       All  of  these  will start on the first day of the requested period and        end on the last one, as described above.         Examples:  -       -p "bimonthly from 2008"   --   periods+       -p "bimonthly  from  2008"  --  periods        will  have  boundaries  on  2008/01/01,        2008/03/01, ...        -p "every 2 weeks" -- starts on closest        preceeding Monday-       -p "every 5 month from 2009/03"      --+       -p  "every  5  month  from  2009/03" --        periods   will   have   boundaries   on        2009/03/01, 2009/08/01, ... -       If you want intervals that start on arbitrary day of your choosing  and+       If  you want intervals that start on arbitrary day of your choosing and        span a week, month or year, you need to use any of the following: -       every Nth day of week,    every <weekday>,    every Nth day [of month],-       every Nth weekday [of month],                    every MM/DD [of year],-       every Nth MMM [of year], every MMM Nth [of year].+       every Nth day of week, every <weekday>, every Nth day [of month], every+       Nth weekday [of month], every MM/DD [of year], every Nth MMM [of year],+       every MMM Nth [of year].         Examples: @@ -583,44 +605,44 @@        -p "every 2nd day of week"  --  periods        will go from Tue to Tue        -p "every Tue" -- same-       -p "every 15th day"  --  period  bound-+       -p  "every  15th  day" -- period bound-        aries will be on 15th of each month-       -p "every 2nd Monday"  -- period bound--       aries will be on second Monday of  each+       -p "every 2nd Monday" -- period  bound-+       aries  will be on second Monday of each        month        -p "every 11/05" -- yearly periods with        boundaries on 5th of Nov        -p "every 5th Nov" -- same        -p "every Nov 5th" -- same -       Show historical balances at end of 15th each month (N is exclusive  end+       Show  historical balances at end of 15th each month (N is exclusive end        date):         hledger balance -H -p "every 16th day" -       Group  postings  from  start  of wednesday to end of next tuesday (N is+       Group postings from start of wednesday to end of  next  tuesday  (N  is        start date and exclusive end date):         hledger register checking -p "every 3rd day of week"     Depth limiting        With the --depth N option (short form: -N), commands like account, bal--       ance  and register will show only the uppermost accounts in the account-       tree, down to level N.  Use this when you  want  a  summary  with  less-       detail.   This  flag has the same effect as a depth: query argument (so+       ance and register will show only the uppermost accounts in the  account+       tree,  down  to  level  N.   Use this when you want a summary with less+       detail.  This flag has the same effect as a depth: query  argument  (so        -2, --depth=2 or depth:2 are basically equivalent).     Pivoting        Normally hledger sums amounts, and organizes them in a hierarchy, based-       on  account  name.  The --pivot FIELD option causes it to sum and orga--       nize hierarchy based on the value of some other field  instead.   FIELD+       on account name.  The --pivot FIELD option causes it to sum  and  orga-+       nize  hierarchy  based on the value of some other field instead.  FIELD        can be: code, description, payee, note, or the full name (case insensi-        tive) of any tag.  As with account names, values containing colon:sepa-        rated:parts will be displayed hierarchically in reports. -       --pivot  is  a  general  option affecting all reports; you can think of+       --pivot is a general option affecting all reports;  you  can  think  of        hledger transforming the journal before any other processing, replacing-       every  posting's  account name with the value of the specified field on+       every posting's account name with the value of the specified  field  on        that posting, inheriting it from the transaction or using a blank value        if it's not present. @@ -646,7 +668,7 @@               --------------------                                  0 -       One  way  to  show  only  amounts  with a member: value (using a query,+       One way to show only amounts with  a  member:  value  (using  a  query,        described below):                $ hledger balance --pivot member tag:member=.@@ -654,7 +676,7 @@               --------------------                             -2 EUR -       Another way (the acct:  query  matches  against  the  pivoted  "account+       Another  way  (the  acct:  query  matches  against the pivoted "account        name"):                $ hledger balance --pivot member acct:.@@ -662,62 +684,282 @@               --------------------                             -2 EUR -   Cost-       The  -B/--cost flag converts amounts to their cost at transaction time,-       if they have a transaction price specified.+   Valuation+   -B: Cost+       The -B/--cost flag converts amounts to their cost (or selling price) at+       transaction  time,  if  they  have a transaction price specified.  This+       flag is equivalent to --value=cost, described below. -   Market value-       The -V/--value flag converts reported amounts to their  current  market-       value.-       Specifically,  when  there  is  a  market  price  (P directive) for the-       amount's commodity, dated on or before today's date (or the report  end-       date if specified), the amount will be converted to the price's commod--       ity.+   -V: Market value+       The -V/--market flag converts reported amounts to their market value in+       a  default  valuation  commodity, using the historical market prices in+       effect on a default valuation date. -       When there are multiple applicable P directives, -V  chooses  the  most-       recent one, or in case of equal dates, the last-parsed one.+       For single period reports, the valuation date  is  today.   For  multi-+       period reports, it is the last day of each subperiod. -       For example:+       The valuation commodity will be the one referenced in the latest appli-+       cable market price dated on or before the valuation date.  If  most  of+       your  P  declarations lead to a single home currency, this will usually+       be what you want. +       Unlike the similar flag in Ledger, it does not infer market prices from+       transaction  prices.  In hledger, -B uses transaction prices, -V and -X+       use market prices.++       It is equivalent to --value=now or --value=end.++       Here's a quick example:+               # one euro is worth this many dollars from nov 1-              P 2016/11/01  $1.10+              P 2016/11/01 EUR $1.10                # purchase some euros on nov 3               2016/11/3-                  assets:euros        100+                  assets:euros        EUR100                   assets:checking                # the euro is worth fewer dollars by dec 21-              P 2016/12/21  $1.03+              P 2016/12/21 EUR $1.03         How many euros do I have ?                $ hledger -f t.j bal -N euros-                              100  assets:euros+                              EUR100  assets:euros         What are they worth at end of nov 3 ?                $ hledger -f t.j bal -N euros -V -e 2016/11/4                            $110.00  assets:euros -       What  are they worth after 2016/12/21 ?  (no report end date specified,+       What are they worth after 2016/12/21 ?  (no report end date  specified,        defaults to today)                $ hledger -f t.j bal -N euros -V                            $103.00  assets:euros -       Currently, hledger's -V only uses market prices recorded with P  direc--       tives, not transaction prices (unlike Ledger).+   -X: Market value in specified commodity+       The  -X/--exchange option is like -V/--market except it takes a commod-+       ity symbol argument, so that you can select a different target  commod-+       ity.   It is similar to the same option in Ledger, with the same caveat+       mentioned for -V/--value above.  It is equivalent  to  --value=now,COMM+       or --value=end,COMM; for more details, read on. -       Currently,  -V has a limitation in multicolumn balance reports: it uses-       the market prices on the report end date for all columns.  (Instead  of-       the prices on each column's end date.)+   --value+       (experimental, added 201905) -   Combining -B and -V-       Using  -B/--cost  and -V/--value together is currently allowed, but the-       results are probably not meaningful.  Let us know if you find a use for-       this.+       -B, -V and -X are special cases of the more general --value option: +               --value=TYPE[,COMM]  TYPE is cost, end, now or YYYY-MM-DD.+                                    COMM is an optional commodity symbol.+                                    Shows amounts converted to:+                                    - cost commodity using transaction prices (then optionally to COMM using market prices at period end(s))+                                    - default valuation commodity (or COMM) using market prices at period end(s)+                                    - default valuation commodity (or COMM) using current market prices+                                    - default valuation commodity (or COMM) using market prices at some date++   Valuation type+       TYPE  is one of these keywords, or their first letter, or a date (which+       must be 8 digits with - or / or .  separators):++       --value=cost+              Convert amounts to cost, using the prices recorded  in  transac-+              tions.  -B/--cost is equivalent to this.++       --value=end+              Convert  amounts  to  their value in default valuation commodity+              using market prices on the last day of the report period (or  of+              each  subperiod in a multiperiod report).  When no report period+              is specified, uses the journal's last transaction date.++       --value=now+              Convert amounts to their value in  default  valuation  commodity+              using  current  market  prices (as of when report is generated).+              -V/--market is equivalent to this.++       --value=YYYY-MM-DD+              Convert amounts to their value in  default  valuation  commodity+              using market prices on this date.  Eg --value=2019-04-25.++   Valuation commodity+       The  default valuation commodity is the commodity mentioned in the most+       recent applicable market price declaration.  When all your price decla-+       rations  lead  to a single home currency, this will usually do what you+       want.++       To select a different valuation commodity: write the  commodity  symbol+       after  the  valuation type, separated by a comma (eg: --value=now,EUR).+       This will use, in this preferred order:++       o declared prices (from source commodity to valuation commodity)++       o reverse prices (declared prices from valuation to  source  commodity,+         inverted)++       o indirect  prices  (prices  calculated  from  the  shortest  chain  of+         declared or reverse prices from source to valuation commodity).++   --value examples+       Here are the effects of --value as seen with print:++              P 2000-01-01 A  1 B+              P 2000-02-01 A  2 B+              P 2000-03-01 A  3 B+              P 2000-04-01 A  4 B++              2000-01-01+                (a)      1 A @ 5 B++              2000-02-01+                (a)      1 A @ 6 B++              2000-03-01+                (a)      1 A @ 7 B++       Show the cost of each posting:++              $ hledger -f- print --value=cost+              2000/01/01+                  (a)             5 B++              2000/02/01+                  (a)             6 B++              2000/03/01+                  (a)             7 B++       Show the value as of the last day of the report period (2000-02-29):++              $ hledger -f- print --value=end date:2000/01-2000/03+              2000-01-01+                  (a)             2 B++              2000-02-01+                  (a)             2 B++       With no report period specified, that shows the value as  of  the  last+       day of the journal (2000-03-01):++              $ hledger -f- print --value=end+              2000/01/01+                  (a)             3 B++              2000/02/01+                  (a)             3 B++              2000/03/01+                  (a)             3 B++       Show the current value (the 2000-04-01 price is still in effect today):++              $ hledger -f- print --value=now+              2000-01-01+                  (a)             4 B++              2000-02-01+                  (a)             4 B++              2000-03-01+                  (a)             4 B++       Show the value on 2000/01/15:++              $ hledger -f- print --value=2000-01-15+              2000/01/01+                  (a)             1 B++              2000/02/01+                  (a)             1 B++              2000/03/01+                  (a)             1 B++       You may need to  explicitly  set  a  commodity's  display  style,  when+       reverse prices are used.  Eg this output might be surprising:++              P 2000-01-01 A 2B++              2000-01-01+                a  1B+                b++              $ hledger print -x -X A+              2000/01/01+                  a               0+                  b               0++       Explanation:  because there's no amount or commodity directive specify-+       ing a display style for A, 0.5A gets the default style, which shows  no+       decimal digits.  Because the displayed amount looks like zero, the com-+       modity symbol and minus sign are not displayed either.  Adding  a  com-+       modity directive sets a more useful display style for A:++              P 2000-01-01 A 2B+              commodity 0.00A++              2000-01-01+                a  1B+                b++              $ hledger print -X A+              2000/01/01+                  a           0.50A+                  b          -0.50A++   Effect of --value on reports+       Below  is  how  --value  affects  each of hledger's reports, currently.+       You're not expected to remember all this, but  when  troubleshooting  a+       report, look here.  If you find problems - useless reports, misbehaving+       reports, or error messages being printed -  please  report  them  (with+       reproducible examples) eg at #329.+++       Report type     --value cost     --value end                 --value DATE/now+       ---------------------------------------------------------------------------------+       print+       posting         cost,       as   market  value  at  report   market   value  at+       amounts         recorded    in   end                         DATE+                       transaction+       balance         show unvalued    show unvalued               show unvalued+       asser-+       tions/assign-+       ments+       register+       starting bal-   cost of start-   market   value   at   day   market  value   at+       ance with -H    ing balance      before report start         DATE+       posting         cost             market  value  at  report   market   value  at+       amounts                          end                         DATE+       posting         summarised       market value each summary   market value  each+       amounts, mul-   cost             posting at period end       summary posting at+       tiperiod                                                     DATE+       running         sum/average of   sum/average of  the  dis-   sum/average of the+       total/average   the  displayed   played values               displayed values+                       values+       balance  (bs,+       cf, is..)++++       starting bal-   costs       of   market   value   at   day   market   value  at+       ances with -H   starting  bal-   before  report  start  of   DATE  of  sum   of+                       ances            sum of previous postings    previous postings+       balances,       summed costs     market  value  at  period   market  value   at+       simple   bal-                    end of sum of postings      DATE   of  sum  of+       ance report                                                  postings+       balances,       summed costs     market  value  at  period   market   value  at+       multiperiod                      end of sum of postings      DATE  of  sum   of+       report                                                       postings+       budget          costs  of bud-   budget-setting   periodic   budget-setting+       amounts  with   get amounts      txns are valued at period   periodic  txns are+       --budget                         end                         valued at DATE+       col-            sum/average of   market  value  at  period   market   value  at+       umn/row/grand   the  displayed   end  of  sum/average   of   DATE of  sum/aver-+       totals/aver-    values           postings                    age of postings+       ages++   Combining -B, -V, -X, --value+       The rightmost of these flags wins.+    Output destination        Some  commands (print, register, stats, the balance commands) can write        their output to a destination other than the  console.   This  is  con-@@ -813,8 +1055,7 @@         REGEX, acct:REGEX               match account names by this regular expression.  (With  no  pre--              fix, acct: is assumed.)-       same as above+              fix, acct: is assumed.)  same as above         amt:N, amt:<N, amt:<=N, amt:>N, amt:>=N               match  postings with a single-commodity amount that is equal to,@@ -833,8 +1074,8 @@               tial match, use .*REGEX.*).  Note, to match characters which are               regex-significant, like the dollar sign ($), you need to prepend               \.  And when using the command line you need  to  add  one  more-              level  of  quoting  to  hide  it  from  the  shell,  so  eg  do:-              hledger print cur:'\$' or hledger print cur:\\$.+              level  of  quoting  to hide it from the shell, so eg do: hledger+              print cur:'\$' or hledger print cur:\\$.         desc:REGEX               match transaction descriptions.@@ -893,13 +1134,13 @@        scripts  named  hledger-NAME in your PATH, these will also be listed as        subcommands. -       Run  a  subcommand  by  writing  its  name  as   first   argument   (eg-       hledger incomestatement).  You can also write one of the standard short-       aliases displayed in parentheses in the command  list  (hledger b),  or-       any any unambiguous prefix of a command name (hledger inc).+       Run a subcommand by writing its name  as  first  argument  (eg  hledger+       incomestatement).  You can also write one of the standard short aliases+       displayed in parentheses in the command list (hledger b),  or  any  any+       unambiguous prefix of a command name (hledger inc).         Here  are  all  the  builtin  commands in alphabetical order.  See also-       hledger for a more  organised  command  list,  and  hledger CMD -h  for+       hledger for a more organised command  list,  and  hledger  CMD  -h  for        detailed command help.     accounts@@ -950,8 +1191,8 @@        Many hledger users edit their journals directly with a text editor,  or        generate  them from CSV.  For more interactive data entry, there is the        add command, which prompts interactively on the console for new  trans--       actions,  and  appends  them to the journal file (if there are multiple-       -f FILE options, the first file is used.) Existing transactions are not+       actions, and appends them to the journal file (if there are multiple -f+       FILE options, the first file is used.) Existing  transactions  are  not        changed.   This  is the only hledger command that writes to the journal        file. @@ -1013,6 +1254,10 @@               Starting the next transaction (. or ctrl-D/ctrl-C to quit)               Date [2015/05/22]: <CTRL-D> $ +       On  Microsoft  Windows,  the add command makes sure that no part of the+       file path ends with a period, as it can cause data loss on  that  plat-+       form (cf #1056).+    balance        balance, bal, b        Show accounts and their balances.@@ -1082,8 +1327,8 @@                                 $1    supplies     Customising the classic balance report-       You  can  customise  the  layout of classic balance reports with --for--       mat FMT:+       You  can  customise the layout of classic balance reports with --format+       FMT:                $ hledger balance --format "%20(account) %12(total)"                             assets          $-1@@ -1128,21 +1373,21 @@        o %, - render on one line, comma-separated         There are some quirks.  Eg in one-line  mode,  %(depth_spacer)  has  no-       effect, instead %(account) has indentation built in.-        Experimentation may be needed to get pleasing results.+       effect,  instead  %(account) has indentation built in.  Experimentation+       may be needed to get pleasing results.         Some example formats:         o %(total) - the account's total -       o %-20.20(account)  -  the account's name, left justified, padded to 20+       o %-20.20(account) - the account's name, left justified, padded  to  20          characters and clipped at 20 characters -       o %,%-50(account)  %25(total) - account name padded to  50  characters,-         total  padded to 20 characters, with multiple commodities rendered on+       o %,%-50(account)   %25(total)  - account name padded to 50 characters,+         total padded to 20 characters, with multiple commodities rendered  on          one line -       o %20(total)  %2(depth_spacer)%-(account) - the default format for  the+       o %20(total)   %2(depth_spacer)%-(account) - the default format for the          single-column balance report     Colour support@@ -1153,9 +1398,9 @@        o the output is not being redirected or piped anywhere     Flat mode-       To  see  a  flat  list instead of the default hierarchical display, use-       --flat.  In this mode, accounts (unless depth-clipped) show their  full-       names  and  "exclusive" balance, excluding any subaccount balances.  In+       To see a flat list instead of the  default  hierarchical  display,  use+       --flat.   In this mode, accounts (unless depth-clipped) show their full+       names and "exclusive" balance, excluding any subaccount  balances.   In        this mode, you can also use --drop N to omit the first few account name        components. @@ -1164,8 +1409,8 @@                                 $1  supplies     Depth limited balance reports-       With  --depth N  or  depth:N  or just -N, balance reports show accounts-       only to the specified numeric depth.  This is very useful to  summarise+       With --depth N or depth:N or just -N,  balance  reports  show  accounts+       only  to the specified numeric depth.  This is very useful to summarise        a complex set of accounts and get an overview.                $ hledger balance -N -1@@ -1178,17 +1423,17 @@        inclusive balances at the depth limit.     Multicolumn balance report-       Multicolumn or tabular balance reports are a very useful  hledger  fea--       ture,  and  usually  the preferred style.  They share many of the above-       features, but they show the report as a table, with columns  represent--       ing  time  periods.   This  mode  is activated by providing a reporting+       Multicolumn  or  tabular balance reports are a very useful hledger fea-+       ture, and usually the preferred style.  They share many  of  the  above+       features,  but they show the report as a table, with columns represent-+       ing time periods.  This mode is  activated  by  providing  a  reporting        interval. -       There are three types of multicolumn balance report, showing  different+       There  are three types of multicolumn balance report, showing different        information:         1. By default: each column shows the sum of postings in that period, ie-          the account's change of balance in that period.  This is  useful  eg+          the  account's  change of balance in that period.  This is useful eg           for a monthly income statement:                    $ hledger balance --quarterly income expenses -E@@ -1203,8 +1448,8 @@                   -------------------++---------------------------------                                      ||     $-1      $1       0       0 -       2. With  --cumulative:  each  column  shows the ending balance for that-          period, accumulating the changes across periods, starting from 0  at+       2. With --cumulative: each column shows the  ending  balance  for  that+          period,  accumulating the changes across periods, starting from 0 at           the report start date:                    $ hledger balance --quarterly income expenses -E --cumulative@@ -1220,8 +1465,8 @@                                      ||         $-1           0           0           0         3. With --historical/-H: each column shows the actual historical ending-          balance for that period, accumulating the  changes  across  periods,-          starting  from the actual balance at the report start date.  This is+          balance  for  that  period, accumulating the changes across periods,+          starting from the actual balance at the report start date.  This  is           useful eg for a multi-period balance sheet, and when you are showing           only the data after a certain start date: @@ -1237,6 +1482,9 @@                   ----------------------++-------------------------------------                                         ||           0           0           0 +       Note that --cumulative or --historical/-H disable --row-total/-T, since+       summing end balances generally does not make sense.+        Multicolumn  balance  reports display accounts in flat mode by default;        to see the hierarchy, use --tree. @@ -1522,7 +1770,9 @@        report  period.  As with multicolumn balance reports, you can alter the        report mode  with  --change/--cumulative/--historical.   Normally  bal-        ancesheet  shows historical ending balances, which is what you need for-       a balance sheet; note this means it ignores report begin dates.+       a balance sheet; note this means it ignores  report  begin  dates  (and+       -T/--row-total,  since  summing  end  balances  generally does not make+       sense).         This command also supports output destination and output format  selec-        tion.@@ -1616,7 +1866,7 @@         The closing transaction  transfers  balances  to  "equity:closing  bal-        ances".   The opening transaction transfers balances from "equity:open--       ing balances".  You can chose to print just one of the transactions  by+       ing balances".  You can choose to print just one of the transactions by        using the --opening or --closing flag.         If you split your journal files by time (eg yearly), you will typically@@ -1638,7 +1888,7 @@         By default, the closing transaction is dated  yesterday,  the  balances        are  calculated  as of end of yesterday, and the opening transaction is-       dated today.  To close on some other date, use:  hledger close -e OPEN-+       dated today.  To close on some other date, use: hledger close -e  OPEN-        INGDATE.   Eg,  to  close/open  on the 2018/2019 boundary, use -e 2019.        You can also use -p or date:PERIOD (any starting date is ignored). @@ -1649,6 +1899,10 @@        run this command with --auto,  the  balance  assertions  will  probably        always require --auto. +       When  account  balances have cost information (transaction prices), the+       closing/opening transactions will preserve it, so that  eg  balance  -B+       reports will not be affected.+        Examples:         Carrying  asset/liability  balances  into a new file for 2019, all from@@ -1744,17 +1998,31 @@                $ hledger import --dry ... | hledger -f- print unknown --ignore-assertions +   Importing balance assignments+       Entries  added  by import will have their posting amounts made explicit+       (like hledger print -x).  This means that any  balance  assignments  in+       imported  files must be evaluated; but, imported files don't get to see+       the main file's account balances.  As a result, importing entries  with+       balance assignments (eg from an institution that provides only balances+       and not posting  amounts)  will  probably  generate  incorrect  posting+       amounts.  To avoid this problem, use print instead of import:++              $ hledger print IMPORTFILE [--new] >> $LEDGER_FILE++       (If  you  think  import  should leave amounts implicit like print does,+       please test it and send a pull request.)+    incomestatement        incomestatement, is-       This  command  displays a simple income statement, showing revenues and-       expenses during a period.  It assumes that these accounts are  under  a-       top-level  revenue or income or expense account (case insensitive, plu--       ral forms also allowed).  Note this report shows all  account  balances-       with  normal  positive  sign  (like  conventional financial statements,+       This command displays a simple income statement, showing  revenues  and+       expenses  during  a period.  It assumes that these accounts are under a+       top-level revenue or income or expense account (case insensitive,  plu-+       ral  forms  also allowed).  Note this report shows all account balances+       with normal positive  sign  (like  conventional  financial  statements,        unlike balance/print/register) (experimental). -       This command displays a simple income statement.  It currently  assumes-       that  you have top-level accounts named income (or revenue) and expense+       This  command displays a simple income statement.  It currently assumes+       that you have top-level accounts named income (or revenue) and  expense        (plural forms also allowed.)                $ hledger incomestatement@@ -1779,19 +2047,19 @@                                  0         With a reporting interval, multiple columns will be shown, one for each-       report  period.   Normally  incomestatement shows revenues/expenses per-       period, though as with multicolumn balance reports you  can  alter  the+       report period.  Normally incomestatement  shows  revenues/expenses  per+       period,  though  as  with multicolumn balance reports you can alter the        report mode with --change/--cumulative/--historical. -       This  command also supports output destination and output format selec-+       This command also supports output destination and output format  selec-        tion.     prices        prices-       Print market price directives from the  journal.   With  --costs,  also-       print  synthetic  market  prices  based  on  transaction  prices.  With+       Print  market  price  directives  from the journal.  With --costs, also+       print synthetic  market  prices  based  on  transaction  prices.   With        --inverted-costs,  also  print  inverse  prices  based  on  transaction-       prices.   Prices  (and  postings providing prices) can be filtered by a+       prices.  Prices (and postings providing prices) can be  filtered  by  a        query.     print@@ -1799,11 +2067,11 @@        Show transaction journal entries, sorted by date.         The print command displays full journal entries (transactions) from the-       journal  file  in date order, tidily formatted.  With --date2, transac-+       journal file in date order, tidily formatted.  With  --date2,  transac-        tions are sorted by secondary date instead.         print's output is always a valid hledger journal.-       It preserves all transaction information,  but  it  does  not  preserve+       It  preserves  all  transaction  information,  but it does not preserve        directives or inter-transaction comments                $ hledger print@@ -1829,39 +2097,39 @@                   assets:bank:checking           $-1         Normally, the journal entry's explicit or implicit amount style is pre--       served.  Ie when an amount is omitted in the journal, it will be  omit--       ted  in  the  output.   You  can use the -x/--explicit flag to make all+       served.   Ie when an amount is omitted in the journal, it will be omit-+       ted in the output.  You can use the  -x/--explicit  flag  to  make  all        amounts explicit, which can be useful for troubleshooting or for making        your journal more readable and robust against data entry errors.  Note,-       -x will cause postings with a multi-commodity amount (these  can  arise-       when  a  multi-commodity  transaction  has  an implicit amount) will be-       split into multiple single-commodity postings, for valid  journal  out-+       -x  will  cause postings with a multi-commodity amount (these can arise+       when a multi-commodity transaction has  an  implicit  amount)  will  be+       split  into  multiple single-commodity postings, for valid journal out-        put. -       With  -B/--cost,  amounts with transaction prices are converted to cost+       With -B/--cost, amounts with transaction prices are converted  to  cost        using that price.  This can be used for troubleshooting. -       With -m/--match and a STR argument, print will show at most one  trans--       action:  the  one  one whose description is most similar to STR, and is-       most recent.  STR should contain at least two characters.  If there  is+       With  -m/--match and a STR argument, print will show at most one trans-+       action: the one one whose description is most similar to  STR,  and  is+       most  recent.  STR should contain at least two characters.  If there is        no similar-enough match, no transaction will be shown.         With --new, for each FILE being read, hledger reads (and writes) a spe--       cial state file (.latest.FILE in the same  directory),  containing  the-       latest  transaction  date(s)  that  were  seen last time FILE was read.-       When this file is found, only transactions with newer  dates  (and  new-       transactions  on  the  latest  date)  are  printed.  This is useful for-       ignoring already-seen entries in import data, such  as  downloaded  CSV+       cial  state  file  (.latest.FILE in the same directory), containing the+       latest transaction date(s) that were seen  last  time  FILE  was  read.+       When  this  file  is found, only transactions with newer dates (and new+       transactions on the latest date)  are  printed.   This  is  useful  for+       ignoring  already-seen  entries  in import data, such as downloaded CSV        files.  Eg:                $ hledger -f bank1.csv print --new               # shows transactions added since last print --new on this file -       This  assumes  that  transactions  added  to  FILE  always have same or-       increasing dates, and that transactions on the  same  day  do  not  get+       This assumes that transactions  added  to  FILE  always  have  same  or+       increasing  dates,  and  that  transactions  on the same day do not get        reordered.  See also the import command. -       This  command also supports output destination and output format selec-+       This command also supports output destination and output format  selec-        tion.  Here's an example of print's CSV output:                $ hledger print -Ocsv@@ -1878,20 +2146,20 @@               "5","2008/12/31","","*","","pay off","","liabilities:debts","1","$","","1","",""               "5","2008/12/31","","*","","pay off","","assets:bank:checking","-1","$","1","","","" -       o There is one CSV record per posting, with  the  parent  transaction's+       o There  is  one  CSV record per posting, with the parent transaction's          fields repeated.         o The "txnidx" (transaction index) field shows which postings belong to-         the same transaction.  (This number might change if transactions  are-         reordered  within  the file, files are parsed/included in a different+         the  same transaction.  (This number might change if transactions are+         reordered within the file, files are parsed/included in  a  different          order, etc.) -       o The amount is separated into "commodity" (the  symbol)  and  "amount"+       o The  amount  is  separated into "commodity" (the symbol) and "amount"          (numeric quantity) fields.         o The numeric amount is repeated in either the "credit" or "debit" col--         umn, for convenience.  (Those names are not accurate in the  account--         ing  sense;  it  just  puts negative amounts under credit and zero or+         umn,  for convenience.  (Those names are not accurate in the account-+         ing sense; it just puts negative amounts under  credit  and  zero  or          greater amounts under debit.)     print-unique@@ -1915,7 +2183,7 @@        Show postings and their running total.         The register command displays postings in date order, one per line, and-       their  running  total.  This is typically used with a query selecting a+       their running total.  This is typically used with a query  selecting  a        particular account, to see that account's activity:                $ hledger register checking@@ -1926,8 +2194,8 @@         With --date2, it shows and sorts by secondary date instead. -       The --historical/-H flag adds the balance from  any  undisplayed  prior-       postings  to  the  running  total.  This is useful when you want to see+       The  --historical/-H  flag  adds the balance from any undisplayed prior+       postings to the running total.  This is useful when  you  want  to  see        only recent activity, with a historically accurate running balance:                $ hledger register checking -b 2008/6 --historical@@ -1937,30 +2205,30 @@         The --depth option limits the amount of sub-account detail displayed. -       The --average/-A flag shows the running average posting amount  instead+       The  --average/-A flag shows the running average posting amount instead        of the running total (so, the final number displayed is the average for-       the whole report period).  This flag implies --empty (see  below).   It-       is  affected  by  --historical.   It  works  best when showing just one+       the  whole  report period).  This flag implies --empty (see below).  It+       is affected by --historical.  It  works  best  when  showing  just  one        account and one commodity. -       The --related/-r flag shows the other postings in the  transactions  of+       The  --related/-r  flag shows the other postings in the transactions of        the postings which would normally be shown. -       The  --invert flag negates all amounts.  For example, it can be used on+       The --invert flag negates all amounts.  For example, it can be used  on        an income account where amounts are normally displayed as negative num--       bers.   It's  also  useful  to  show  postings  on the checking account+       bers.  It's also useful  to  show  postings  on  the  checking  account        together with the related account:                $ hledger register --related --invert assets:checking -       With a reporting interval, register shows  summary  postings,  one  per+       With  a  reporting  interval,  register shows summary postings, one per        interval, aggregating the postings to each account:                $ hledger register --monthly income               2008/01                 income:salary                          $-1          $-1               2008/06                 income:gifts                           $-1          $-2 -       Periods  with no activity, and summary postings with a zero amount, are+       Periods with no activity, and summary postings with a zero amount,  are        not shown by default; use the --empty/-E flag to see them:                $ hledger register --monthly income -E@@ -1977,7 +2245,7 @@               2008/11                                                          0          $-2               2008/12                                                          0          $-2 -       Often, you'll want to see just one  line  per  interval.   The  --depth+       Often,  you'll  want  to  see  just one line per interval.  The --depth        option helps with this, causing subaccounts to be aggregated:                $ hledger register --monthly assets --depth 1h@@ -1985,19 +2253,19 @@               2008/06                 assets                                 $-1            0               2008/12                 assets                                 $-1          $-1 -       Note  when using report intervals, if you specify start/end dates these-       will be adjusted outward if necessary to  contain  a  whole  number  of-       intervals.   This  ensures  that  the first and last intervals are full+       Note when using report intervals, if you specify start/end dates  these+       will  be  adjusted  outward  if  necessary to contain a whole number of+       intervals.  This ensures that the first and  last  intervals  are  full        length and comparable to the others in the report.     Custom register output-       register uses the full terminal width by default,  except  on  windows.-       You  can override this by setting the COLUMNS environment variable (not+       register  uses  the  full terminal width by default, except on windows.+       You can override this by setting the COLUMNS environment variable  (not        a bash shell variable) or by using the --width/-w option. -       The description and account columns normally share  the  space  equally-       (about  half  of  (width  - 40) each).  You can adjust this by adding a-       description width  as  part  of  --width's  argument,  comma-separated:+       The  description  and  account columns normally share the space equally+       (about half of (width - 40) each).  You can adjust  this  by  adding  a+       description  width  as  part  of  --width's  argument, comma-separated:        --width W,D .  Here's a diagram (won't display correctly in --help):                <--------------------------------- width (W) ---------------------------------->@@ -2013,34 +2281,34 @@               $ hledger reg -w 100,40           # set overall width 100, description width 40               $ hledger reg -w $COLUMNS,40      # use terminal width, & description width 40 -       This  command also supports output destination and output format selec-+       This command also supports output destination and output format  selec-        tion.     register-match        register-match        Print the one posting whose transaction description is closest to DESC,-       in  the  style  of the register command.  If there are multiple equally-       good matches, it shows the most recent.  Query  options  (options,  not-       arguments)   can   be   used  to  restrict  the  search  space.   Helps-       ledger-autosync detect already-seen transactions when importing.+       in the style of the register command.  If there  are  multiple  equally+       good  matches,  it  shows the most recent.  Query options (options, not+       arguments) can be used to restrict the  search  space.   Helps  ledger-+       autosync detect already-seen transactions when importing.     rewrite        rewrite        Print all transactions, rewriting the postings of matched transactions.-       For  now  the only rewrite available is adding new postings, like print+       For now the only rewrite available is adding new postings,  like  print        --auto.         This is a start at a generic rewriter of transaction entries.  It reads-       the  default  journal and prints the transactions, like print, but adds+       the default journal and prints the transactions, like print,  but  adds        one or more specified postings to any transactions matching QUERY.  The-       posting  amounts can be fixed, or a multiplier of the existing transac-+       posting amounts can be fixed, or a multiplier of the existing  transac-        tion's first posting amount.         Examples: -              hledger-rewrite.hs ^income --add-posting '(liabilities:tax)  *.33  ; income tax' --add-posting '(reserve:gifts)  $100'-              hledger-rewrite.hs expenses:gifts --add-posting '(reserve:gifts)  *-1"'-              hledger-rewrite.hs -f rewrites.hledger+              $ hledger-rewrite.hs ^income --add-posting '(liabilities:tax)  *.33  ; income tax' --add-posting '(reserve:gifts)  $100'+              $ hledger-rewrite.hs expenses:gifts --add-posting '(reserve:gifts)  *-1"'+              $ hledger-rewrite.hs -f rewrites.hledger         rewrites.hledger may consist of entries like: @@ -2049,7 +2317,7 @@                 (reserve:grocery)  *0.25  ; reserve 25% for grocery                 (reserve:)  *0.25  ; reserve 25% for grocery -       Note the single quotes to protect the dollar sign from  bash,  and  the+       Note  the  single  quotes to protect the dollar sign from bash, and the        two spaces between account and amount.         More:@@ -2059,16 +2327,16 @@               $ hledger rewrite -- expenses:gifts --add-posting '(budget:gifts)  *-1"'               $ hledger rewrite -- ^income        --add-posting '(budget:foreign currency)  *0.25 JPY; diversify' -       Argument  for  --add-posting  option  is a usual posting of transaction-       with an exception for amount specification.  More  precisely,  you  can+       Argument for --add-posting option is a  usual  posting  of  transaction+       with  an  exception  for amount specification.  More precisely, you can        use '*' (star symbol) before the amount to indicate that that this is a-       factor for an amount  of  original  matched  posting.   If  the  amount-       includes  a  commodity  name, the new posting amount will be in the new-       commodity; otherwise, it will be in the matched posting  amount's  com-+       factor  for  an  amount  of  original  matched  posting.  If the amount+       includes a commodity name, the new posting amount will be  in  the  new+       commodity;  otherwise,  it will be in the matched posting amount's com-        modity.     Re-write rules in a file-       During  the  run  this  tool will execute so called "Automated Transac-+       During the run this tool will execute  so  called  "Automated  Transac-        tions" found in any journal it process.  I.e instead of specifying this        operations in command line you can put them in a journal file. @@ -2083,7 +2351,7 @@                   budget:gifts  *-1                   assets:budget  *1 -       Note  that '=' (equality symbol) that is used instead of date in trans-+       Note that '=' (equality symbol) that is used instead of date in  trans-        actions you usually write.  It indicates the query by which you want to        match the posting to add new ones. @@ -2096,12 +2364,12 @@                                                               --add-posting 'assets:budget  *1'       \                 > rewritten-tidy-output.journal -       It  is  important  to understand that relative order of such entries in-       journal is important.  You can re-use result of previously added  post-+       It is important to understand that relative order of  such  entries  in+       journal  is important.  You can re-use result of previously added post-        ings.     Diff output format-       To  use  this tool for batch modification of your journal files you may+       To use this tool for batch modification of your journal files  you  may        find useful output in form of unified diff.                $ hledger rewrite -- --diff -f examples/sample.journal '^income' --add-posting '(liabilities:tax)  *.33'@@ -2125,10 +2393,10 @@         If you'll pass this through patch tool you'll get transactions contain-        ing the posting that matches your query be updated.  Note that multiple-       files might be update according to list of input  files  specified  via+       files  might  be  update according to list of input files specified via        --file options and include directives inside of these files. -       Be  careful.  Whole transaction being re-formatted in a style of output+       Be careful.  Whole transaction being re-formatted in a style of  output        from hledger print.         See also:@@ -2136,48 +2404,48 @@        https://github.com/simonmichael/hledger/issues/99     rewrite vs. print --auto-       This command predates print --auto, and currently does  much  the  same+       This  command  predates  print --auto, and currently does much the same        thing, but with these differences: -       o with  multiple files, rewrite lets rules in any file affect all other-         files.  print --auto uses standard directive  scoping;  rules  affect+       o with multiple files, rewrite lets rules in any file affect all  other+         files.   print  --auto  uses standard directive scoping; rules affect          only child files. -       o rewrite's  query  limits which transactions can be rewritten; all are+       o rewrite's query limits which transactions can be rewritten;  all  are          printed.  print --auto's query limits which transactions are printed. -       o rewrite  applies  rules  specified on command line or in the journal.+       o rewrite applies rules specified on command line or  in  the  journal.          print --auto applies rules specified in the journal.     roi        roi-       Shows the time-weighted (TWR) and money-weighted (IRR) rate  of  return+       Shows  the  time-weighted (TWR) and money-weighted (IRR) rate of return        on your investments. -       This  command  assumes  that  you have account(s) that hold nothing but+       This command assumes that you have account(s)  that  hold  nothing  but        your investments and whenever you record current appraisal/valuation of        these investments you offset unrealized profit and loss into account(s)        that, again, hold nothing but unrealized profit and loss. -       Any transactions affecting balance of  investment  account(s)  and  not-       originating  from  unrealized profit and loss account(s) are assumed to+       Any  transactions  affecting  balance  of investment account(s) and not+       originating from unrealized profit and loss account(s) are  assumed  to        be your investments or withdrawals. -       At a minimum, you need to supply  a  query  (which  could  be  just  an-       account  name) to select your investments with --inv, and another query+       At  a  minimum,  you  need  to  supply  a query (which could be just an+       account name) to select your investments with --inv, and another  query        to identify your profit and loss transactions with --pnl. -       It will compute and display the internalized rate of return  (IRR)  and-       time-weighted  rate  of  return (TWR) for your investments for the time-       period requested.  Both rates of return are annualized before  display,+       It  will  compute and display the internalized rate of return (IRR) and+       time-weighted rate of return (TWR) for your investments  for  the  time+       period  requested.  Both rates of return are annualized before display,        regardless of the length of reporting interval.     stats        stats        Show some journal statistics. -       The  stats  command displays summary information for the whole journal,-       or a matched part of it.  With a reporting interval, it shows a  report+       The stats command displays summary information for the  whole  journal,+       or  a matched part of it.  With a reporting interval, it shows a report        for each report period.         Example:@@ -2193,16 +2461,18 @@               Payees/descriptions      : 5               Accounts                 : 8 (depth 3)               Commodities              : 1 ($)+              Market prices            : 12 ($) -       This  command also supports output destination and output format selec-+       This command also supports output destination and output format  selec-        tion.     tags        tags-       List all the tag names used in the journal.  With a TAGREGEX  argument,-       only  tag  names matching the regular expression (case insensitive) are-       shown.  With QUERY arguments, only transactions matching the query  are-       considered.+       List  all the tag names used in the journal.  With a TAGREGEX argument,+       only tag names matching the regular expression (case  insensitive)  are+       shown.   With QUERY arguments, only transactions matching the query are+       considered.  With --values flag, the tags'  unique  values  are  listed+       instead.     test        test@@ -2220,8 +2490,8 @@        seed, for repeatable results from  tests  using  randomness  (currently        none of them). -       This  is  mainly  used  by developers, but it's nice to be able to san--       ity-check your installed hledger executable at any time.  All tests are+       This  is mainly used by developers, but it's nice to be able to sanity-+       check your installed hledger executable at any  time.   All  tests  are        expected to pass - if you ever see otherwise, something has gone wrong,        please report a bug! @@ -2234,15 +2504,15 @@        Add-ons  can  be  invoked like any hledger command, but there are a few        things to be aware of.  Eg if the hledger-web add-on is installed, -       o hledger -h web  shows  hledger's  help,  while  hledger web -h  shows+       o hledger -h web shows hledger's  help,  while  hledger  web  -h  shows          hledger-web's help.         o Flags  specific  to  the add-on must have a preceding -- to hide them          from hledger.  So hledger web --serve --port 9000 will  be  rejected;          you must use hledger web -- --serve --port 9000. -       o You    can    always    run    add-ons    directly    if   preferred:-         hledger-web --serve --port 9000.+       o You can always run add-ons directly if preferred: hledger-web --serve+         --port 9000.         Add-ons are a relatively easy way to add local features  or  experiment        with  new  ideas.   They  can  be  written in any language, but haskell@@ -2316,7 +2586,7 @@        $HOME/.hledger.journal          (on          windows,           perhaps        C:/Users/USER/.hledger.journal). -BUGS+LIMITATIONS        The  need  to  precede  addon command options with -- when invoked from        hledger is awkward. @@ -2327,36 +2597,39 @@        In a Microsoft Windows CMD window, non-ascii characters and colours are        not supported. +       On Windows, non-ascii characters may not display correctly when running+       a hledger built in CMD in MSYS/CYGWIN, or vice-versa.+        In a Cygwin/MSYS/Mintty window, the tab key is not supported in hledger        add. -       Not all of Ledger's journal file syntax is supported.  See file  format+       Not  all of Ledger's journal file syntax is supported.  See file format        differences. -       On  large  data  files,  hledger  is  slower  and uses more memory than+       On large data files, hledger  is  slower  and  uses  more  memory  than        Ledger.  TROUBLESHOOTING-       Here are some issues you might encounter  when  you  run  hledger  (and-       remember  you can also seek help from the IRC channel, mail list or bug+       Here  are  some  issues  you  might encounter when you run hledger (and+       remember you can also seek help from the IRC channel, mail list or  bug        tracker):         Successfully installed, but "No command 'hledger' found"        stack and cabal install binaries into a special directory, which should-       be  added  to your PATH environment variable.  Eg on unix-like systems,+       be added to your PATH environment variable.  Eg on  unix-like  systems,        that is ~/.local/bin and ~/.cabal/bin respectively.         I set a custom LEDGER_FILE, but hledger is still using the default file-       LEDGER_FILE  should  be  a  real environment variable, not just a shell-       variable.  The command env | grep LEDGER_FILE should show it.  You  may+       LEDGER_FILE should be a real environment variable,  not  just  a  shell+       variable.   The command env | grep LEDGER_FILE should show it.  You may        need to use export.  Here's an explanation. -       "Illegal  byte  sequence"  or  "Invalid or incomplete multibyte or wide+       "Illegal byte sequence" or "Invalid or  incomplete  multibyte  or  wide        character" errors        In order to handle non-ascii letters and symbols (like ), hledger needs        an appropriate locale.  This is usually configured system-wide; you can        also configure it temporarily.  The locale may need to be one that sup--       ports  UTF-8,  if you built hledger with GHC < 7.2 (or possibly always,+       ports UTF-8, if you built hledger with GHC < 7.2 (or  possibly  always,        I'm not sure yet).         Here's  an  example  of  setting  the  locale  temporarily,  on  ubuntu@@ -2375,7 +2648,7 @@               $ echo "export LANG=en_US.UTF-8" >>~/.bash_profile               $ bash --login -       If  we  preferred  to  use eg fr_FR.utf8, we might have to install that+       If we preferred to use eg fr_FR.utf8, we might  have  to  install  that        first:                $ apt-get install language-pack-fr@@ -2396,7 +2669,7 @@   REPORTING BUGS-       Report  bugs at http://bugs.hledger.org (or on the #hledger IRC channel+       Report bugs at http://bugs.hledger.org (or on the #hledger IRC  channel        or hledger mail list)  @@ -2410,7 +2683,7 @@   SEE ALSO-       hledger(1),     hledger-ui(1),     hledger-web(1),      hledger-api(1),+       hledger(1),      hledger-ui(1),     hledger-web(1),     hledger-api(1),        hledger_csv(5), hledger_journal(5), hledger_timeclock(5), hledger_time-        dot(5), ledger(1) @@ -2418,4 +2691,4 @@   -hledger 1.14                      March 2019                        hledger(1)+hledger 1.15                      August 2019                       hledger(1)
embeddedfiles/hledger_csv.5 view
@@ -1,17 +1,17 @@ -.TH "hledger_csv" "5" "March 2019" "hledger 1.14" "hledger User Manuals"+.TH "hledger_csv" "5" "August 2019" "hledger 1.15" "hledger User Manuals"    .SH NAME .PP-CSV \- how hledger reads CSV data, and the CSV rules file format+CSV - how hledger reads CSV data, and the CSV rules file format .SH DESCRIPTION .PP-hledger can read CSV (comma\-separated value) files as if they were+hledger can read CSV (comma-separated value) files as if they were journal files, automatically converting each CSV record into a transaction.-(To learn about \f[I]writing\f[] CSV, see CSV output.)+(To learn about \f[I]writing\f[R] CSV, see CSV output.) .PP Converting CSV to transactions requires some special conversion rules. These do several things:@@ -24,58 +24,57 @@ they can add refinements based on patterns in the CSV data, eg categorizing transactions with more detailed account names. .PP-When reading a CSV file named \f[C]FILE.csv\f[], hledger looks for a-conversion rules file named \f[C]FILE.csv.rules\f[] in the same+When reading a CSV file named \f[C]FILE.csv\f[R], hledger looks for a+conversion rules file named \f[C]FILE.csv.rules\f[R] in the same directory.-You can override this with the \f[C]\-\-rules\-file\f[] option.-If the rules file does not exist, hledger will auto\-create one with-some example rules, which you\[aq]ll need to adjust.+You can override this with the \f[C]--rules-file\f[R] option.+If the rules file does not exist, hledger will auto-create one with some+example rules, which you\[aq]ll need to adjust. .PP-At minimum, the rules file must identify the \f[C]date\f[] and-\f[C]amount\f[] fields.-It may also be necessary to specify the date format, and the number of-header lines to skip.+At minimum, the rules file must identify the date and amount fields.+It\[aq]s often necessary to specify the date format, and the number of+header lines to skip, also. Eg: .IP .nf \f[C]-fields\ date,\ _,\ _,\ amount-date\-format\ \ %d/%m/%Y-skip\ 1-\f[]+fields date, _, _, amount+date-format  %d/%m/%Y+skip 1+\f[R] .fi .PP A more complete example: .IP .nf \f[C]-#\ hledger\ CSV\ rules\ for\ amazon.com\ order\ history+# hledger CSV rules for amazon.com order history -#\ sample:-#\ "Date","Type","To/From","Name","Status","Amount","Fees","Transaction\ ID"-#\ "Jul\ 29,\ 2012","Payment","To","Adapteva,\ Inc.","Completed","$25.00","$0.00","17LA58JSK6PRD4HDGLNJQPI1PB9N8DKPVHL"+# sample:+# \[dq]Date\[dq],\[dq]Type\[dq],\[dq]To/From\[dq],\[dq]Name\[dq],\[dq]Status\[dq],\[dq]Amount\[dq],\[dq]Fees\[dq],\[dq]Transaction ID\[dq]+# \[dq]Jul 29, 2012\[dq],\[dq]Payment\[dq],\[dq]To\[dq],\[dq]Adapteva, Inc.\[dq],\[dq]Completed\[dq],\[dq]$25.00\[dq],\[dq]$0.00\[dq],\[dq]17LA58JSK6PRD4HDGLNJQPI1PB9N8DKPVHL\[dq] -#\ skip\ one\ header\ line-skip\ 1+# skip one header line+skip 1 -#\ name\ the\ csv\ fields\ (and\ assign\ the\ transaction\[aq]s\ date,\ amount\ and\ code)-fields\ date,\ _,\ toorfrom,\ name,\ amzstatus,\ amount,\ fees,\ code+# name the csv fields (and assign the transaction\[aq]s date, amount and code)+fields date, _, toorfrom, name, amzstatus, amount, fees, code -#\ how\ to\ parse\ the\ date-date\-format\ %b\ %\-d,\ %Y+# how to parse the date+date-format %b %-d, %Y -#\ combine\ two\ fields\ to\ make\ the\ description-description\ %toorfrom\ %name+# combine two fields to make the description+description %toorfrom %name -#\ save\ these\ fields\ as\ tags-comment\ \ \ \ \ status:%amzstatus,\ fees:%fees+# save these fields as tags+comment     status:%amzstatus, fees:%fees -#\ set\ the\ base\ account\ for\ all\ transactions-account1\ \ \ \ assets:amazon+# set the base account for all transactions+account1    assets:amazon -#\ flip\ the\ sign\ on\ the\ amount-amount\ \ \ \ \ \ \-%amount-\f[]+# flip the sign on the amount+amount      -%amount+\f[R] .fi .PP For more examples, see Convert CSV files.@@ -83,11 +82,11 @@ .PP The following seven kinds of rule can appear in the rules file, in any order.-Blank lines and lines beginning with \f[C]#\f[] or \f[C];\f[] are+Blank lines and lines beginning with \f[C]#\f[R] or \f[C];\f[R] are ignored. .SS skip .PP-\f[C]skip\f[]\f[I]\f[CI]N\f[I]\f[]+\f[C]skip\f[R]\f[I]\f[CI]N\f[I]\f[R] .PP Skip this number of CSV records at the beginning. You\[aq]ll need this whenever your CSV data contains header lines.@@ -95,122 +94,126 @@ .IP .nf \f[C]-#\ ignore\ the\ first\ CSV\ line-skip\ 1-\f[]+# ignore the first CSV line+skip 1+\f[R] .fi-.SS date\-format+.SS date-format .PP-\f[C]date\-format\f[]\f[I]\f[CI]DATEFMT\f[I]\f[]+\f[C]date-format\f[R]\f[I]\f[CI]DATEFMT\f[I]\f[R] .PP-When your CSV date fields are not formatted like \f[C]YYYY/MM/DD\f[] (or-\f[C]YYYY\-MM\-DD\f[] or \f[C]YYYY.MM.DD\f[]), you\[aq]ll need to+When your CSV date fields are not formatted like \f[C]YYYY/MM/DD\f[R]+(or \f[C]YYYY-MM-DD\f[R] or \f[C]YYYY.MM.DD\f[R]), you\[aq]ll need to specify the format.-DATEFMT is a strptime\-like date parsing pattern, which must parse the+DATEFMT is a strptime-like date parsing pattern, which must parse the date field values completely. Examples: .IP .nf \f[C]-#\ for\ dates\ like\ "11/06/2013":-date\-format\ %m/%d/%Y-\f[]+# for dates like \[dq]11/06/2013\[dq]:+date-format %m/%d/%Y+\f[R] .fi .IP .nf \f[C]-#\ for\ dates\ like\ "6/11/2013"\ (note\ the\ \-\ to\ make\ leading\ zeros\ optional):-date\-format\ %\-d/%\-m/%Y-\f[]+# for dates like \[dq]6/11/2013\[dq] (note the - to make leading zeros optional):+date-format %-d/%-m/%Y+\f[R] .fi .IP .nf \f[C]-#\ for\ dates\ like\ "2013\-Nov\-06":-date\-format\ %Y\-%h\-%d-\f[]+# for dates like \[dq]2013-Nov-06\[dq]:+date-format %Y-%h-%d+\f[R] .fi .IP .nf \f[C]-#\ for\ dates\ like\ "11/6/2013\ 11:32\ PM":-date\-format\ %\-m/%\-d/%Y\ %l:%M\ %p-\f[]+# for dates like \[dq]11/6/2013 11:32 PM\[dq]:+date-format %-m/%-d/%Y %l:%M %p+\f[R] .fi .SS field list .PP-\f[C]fields\f[]\f[I]\f[CI]FIELDNAME1\f[I]\f[],-\f[I]\f[CI]FIELDNAME2\f[I]\f[]...+\f[C]fields\f[R]\f[I]\f[CI]FIELDNAME1\f[I]\f[R],+\f[I]\f[CI]FIELDNAME2\f[I]\f[R]... .PP This (a) names the CSV fields, in order (names may not contain whitespace; uninteresting names may be left blank), and (b) assigns them to journal entry fields if you use any of these standard field names:-\f[C]date\f[], \f[C]date2\f[], \f[C]status\f[], \f[C]code\f[],-\f[C]description\f[], \f[C]comment\f[], \f[C]account1\f[],-\f[C]account2\f[], \f[C]amount\f[], \f[C]amount\-in\f[],-\f[C]amount\-out\f[], \f[C]currency\f[], \f[C]balance\f[].+\f[C]date\f[R], \f[C]date2\f[R], \f[C]status\f[R], \f[C]code\f[R],+\f[C]description\f[R], \f[C]comment\f[R], \f[C]account1\f[R],+\f[C]account2\f[R], \f[C]amount\f[R], \f[C]amount-in\f[R],+\f[C]amount-out\f[R], \f[C]currency\f[R], \f[C]balance\f[R],+\f[C]balance1\f[R], \f[C]balance2\f[R]. Eg: .IP .nf \f[C]-#\ use\ the\ 1st,\ 2nd\ and\ 4th\ CSV\ fields\ as\ the\ entry\[aq]s\ date,\ description\ and\ amount,-#\ and\ give\ the\ 7th\ and\ 8th\ fields\ meaningful\ names\ for\ later\ reference:+# use the 1st, 2nd and 4th CSV fields as the entry\[aq]s date, description and amount,+# and give the 7th and 8th fields meaningful names for later reference: #-#\ CSV\ field:-#\ \ \ \ \ \ 1\ \ \ \ \ 2\ \ \ \ \ \ \ \ \ \ \ \ 3\ 4\ \ \ \ \ \ \ 5\ 6\ 7\ \ \ \ \ \ \ \ \ \ 8-#\ entry\ field:-fields\ date,\ description,\ ,\ amount,\ ,\ ,\ somefield,\ anotherfield-\f[]+# CSV field:+#      1     2            3 4       5 6 7          8+# entry field:+fields date, description, , amount, , , somefield, anotherfield+\f[R] .fi .SS field assignment .PP-\f[I]\f[CI]ENTRYFIELDNAME\f[I]\f[] \f[I]\f[CI]FIELDVALUE\f[I]\f[]+\f[I]\f[CI]ENTRYFIELDNAME\f[I]\f[R] \f[I]\f[CI]FIELDVALUE\f[I]\f[R] .PP This sets a journal entry field (one of the standard names above) to the given text value, which can include CSV field values interpolated by-name (\f[C]%CSVFIELDNAME\f[]) or 1\-based position (\f[C]%N\f[]).- Eg:+name (\f[C]%CSVFIELDNAME\f[R]) or 1-based position (\f[C]%N\f[R]).+Eg: .IP .nf \f[C]-#\ set\ the\ amount\ to\ the\ 4th\ CSV\ field\ with\ "USD\ "\ prepended-amount\ USD\ %4-\f[]+# set the amount to the 4th CSV field with \[dq]USD \[dq] prepended+amount USD %4+\f[R] .fi .IP .nf \f[C]-#\ combine\ three\ fields\ to\ make\ a\ comment\ (containing\ two\ tags)-comment\ note:\ %somefield\ \-\ %anotherfield,\ date:\ %1-\f[]+# combine three fields to make a comment (containing two tags)+comment note: %somefield - %anotherfield, date: %1+\f[R] .fi .PP Field assignments can be used instead of or in addition to a field list.+.PP+Note, interpolation strips any outer whitespace, so a CSV value like+\f[C]\[dq] 1 \[dq]\f[R] becomes \f[C]1\f[R] when interpolated (#1051). .SS conditional block .PP-\f[C]if\f[] \f[I]\f[CI]PATTERN\f[I]\f[]+\f[C]if\f[R] \f[I]\f[CI]PATTERN\f[I]\f[R] .PD 0 .P .PD-\ \ \ \ \f[I]\f[CI]FIELDASSIGNMENTS\f[I]\f[]...+\ \ \ \ \f[I]\f[CI]FIELDASSIGNMENTS\f[I]\f[R]... .PP-\f[C]if\f[]+\f[C]if\f[R] .PD 0 .P .PD-\f[I]\f[CI]PATTERN\f[I]\f[]+\f[I]\f[CI]PATTERN\f[I]\f[R] .PD 0 .P .PD-\f[I]\f[CI]PATTERN\f[I]\f[]...+\f[I]\f[CI]PATTERN\f[I]\f[R]... .PD 0 .P .PD-\ \ \ \ \f[I]\f[CI]FIELDASSIGNMENTS\f[I]\f[]...+\ \ \ \ \f[I]\f[CI]FIELDASSIGNMENTS\f[I]\f[R]... .PP This applies one or more field assignments, only to those CSV records matched by one of the PATTERNs.-The patterns are case\-insensitive regular expressions which match+The patterns are case-insensitive regular expressions which match anywhere within the whole CSV record (it\[aq]s not yet possible to match within a specific field). When there are multiple patterns they can be written on separate lines,@@ -221,46 +224,46 @@ .IP .nf \f[C]-#\ if\ the\ CSV\ record\ contains\ "groceries",\ set\ account2\ to\ "expenses:groceries"-if\ groceries-\ account2\ expenses:groceries-\f[]+# if the CSV record contains \[dq]groceries\[dq], set account2 to \[dq]expenses:groceries\[dq]+if groceries+ account2 expenses:groceries+\f[R] .fi .IP .nf \f[C]-#\ if\ the\ CSV\ record\ contains\ any\ of\ these\ patterns,\ set\ account2\ and\ comment\ as\ shown+# if the CSV record contains any of these patterns, set account2 and comment as shown if-monthly\ service\ fee-atm\ transaction\ fee-banking\ thru\ software-\ account2\ expenses:business:banking-\ comment\ \ XXX\ deductible\ ?\ check\ it-\f[]+monthly service fee+atm transaction fee+banking thru software+ account2 expenses:business:banking+ comment  XXX deductible ? check it+\f[R] .fi .SS include .PP-\f[C]include\f[]\f[I]\f[CI]RULESFILE\f[I]\f[]+\f[C]include\f[R]\f[I]\f[CI]RULESFILE\f[I]\f[R] .PP Include another rules file at this point.-\f[C]RULESFILE\f[] is either an absolute file path or a path relative to-the current file\[aq]s directory.+\f[C]RULESFILE\f[R] is either an absolute file path or a path relative+to the current file\[aq]s directory. Eg: .IP .nf \f[C]-#\ rules\ reused\ with\ several\ CSV\ files-include\ common.rules-\f[]+# rules reused with several CSV files+include common.rules+\f[R] .fi-.SS newest\-first+.SS newest-first .PP-\f[C]newest\-first\f[]+\f[C]newest-first\f[R] .PP Consider adding this rule if all of the following are true: you might be processing just one day of data, your CSV records are in reverse chronological order (newest first), and you care about preserving the-order of same\-day transactions.+order of same-day transactions. It usually isn\[aq]t needed, because hledger autodetects the CSV order, but when all CSV records have the same date it will assume they are oldest first.@@ -268,50 +271,82 @@ .SS CSV ordering .PP The generated journal entries will be sorted by date.-The order of same\-day entries will be preserved (except in the special-case where you might need \f[C]newest\-first\f[], see above).+The order of same-day entries will be preserved (except in the special+case where you might need \f[C]newest-first\f[R], see above). .SS CSV accounts .PP-Each journal entry will have two postings, to \f[C]account1\f[] and-\f[C]account2\f[] respectively.+Each journal entry will have two postings, to \f[C]account1\f[R] and+\f[C]account2\f[R] respectively. It\[aq]s not yet possible to generate entries with more than two postings.-It\[aq]s conventional and recommended to use \f[C]account1\f[] for the+It\[aq]s conventional and recommended to use \f[C]account1\f[R] for the account whose CSV we are reading. .SS CSV amounts .PP-The \f[C]amount\f[] field sets the amount of the \f[C]account1\f[]-posting.-.PP-If the CSV has debit/credit amounts in separate fields, assign to the-\f[C]amount\-in\f[] and \f[C]amount\-out\f[] pseudo fields instead.-(Whichever one has a value will be used, with appropriate sign.-If both contain a value, it may not work so well.)-.PP-If an amount value is parenthesised, it will be de\-parenthesised and-sign\-flipped.+A transaction amount must be set, in one of these ways:+.IP \[bu] 2+with an \f[C]amount\f[R] field assignment, which sets the first+posting\[aq]s amount+.IP \[bu] 2+(When the CSV has debit and credit amounts in separate fields:)+.PD 0+.P+.PD+with field assignments for the \f[C]amount-in\f[R] and+\f[C]amount-out\f[R] pseudo fields (both of them).+Whichever one has a value will be used, with appropriate sign.+If both contain a value, it might not work so well.+.IP \[bu] 2+or implicitly by means of a balance assignment (see below). .PP+There is some special handling for sign in amounts:+.IP \[bu] 2+If an amount value is parenthesised, it will be de-parenthesised and+sign-flipped.+.IP \[bu] 2 If an amount value begins with a double minus sign, those will cancel out and be removed. .PP-If the CSV has the currency symbol in a separate field, assign that to-the \f[C]currency\f[] pseudo field to have it prepended to the amount.-Or, you can use a field assignment to \f[C]amount\f[] that interpolates-both CSV fields (giving more control, eg to put the currency symbol on-the right).-.SS CSV balance assertions+If the currency/commodity symbol is provided as a separate CSV field,+assign it to the \f[C]currency\f[R] pseudo field; the symbol will be+prepended to the amount (TODO: when there is an amount).+Or, you can use an \f[C]amount\f[R] field assignment for more control,+eg:+.IP+.nf+\f[C]+fields date,description,currency,amount+amount %amount %currency+\f[R]+.fi+.SS CSV balance assertions/assignments .PP-If the CSV includes a running balance, you can assign that to the-\f[C]balance\f[] pseudo field; whenever the running balance value is-non\-empty, it will be asserted as the balance after the-\f[C]account1\f[] posting.+If the CSV includes a running balance, you can assign that to one of the+pseudo fields \f[C]balance\f[R] (or \f[C]balance1\f[R]) or+\f[C]balance2\f[R].+This will generate a balance assertion (or if the amount is left empty,+a balance assignment), on the first or second posting, whenever the+running balance field is non-empty.+(TODO: #1000) .SS Reading multiple CSV files .PP-You can read multiple CSV files at once using multiple \f[C]\-f\f[]+You can read multiple CSV files at once using multiple \f[C]-f\f[R] arguments on the command line, and hledger will look for a-correspondingly\-named rules file for each.-Note if you use the \f[C]\-\-rules\-file\f[] option, this one rules file+correspondingly-named rules file for each.+Note if you use the \f[C]--rules-file\f[R] option, this one rules file will be used for all the CSV files being read.+.SS Valid CSV+.PP+hledger follows RFC 4180, with the addition of a customisable separator+character.+.PP+Some things to note:+.PP+When quoting fields,+.IP \[bu] 2+you must use double quotes, not single quotes+.IP \[bu] 2+spaces outside the quotes are not allowed.   .SH "REPORTING BUGS"
embeddedfiles/hledger_csv.info view
@@ -3,7 +3,7 @@  File: hledger_csv.info,  Node: Top,  Next: CSV RULES,  Up: (dir) -hledger_csv(5) hledger 1.14+hledger_csv(5) hledger 1.15 ***************************  hledger can read CSV (comma-separated value) files as if they were@@ -25,9 +25,9 @@ does not exist, hledger will auto-create one with some example rules, which you'll need to adjust. -   At minimum, the rules file must identify the 'date' and 'amount'-fields.  It may also be necessary to specify the date format, and the-number of header lines to skip.  Eg:+   At minimum, the rules file must identify the date and amount fields.+It's often necessary to specify the date format, and the number of+header lines to skip, also.  Eg:  fields date, _, _, amount date-format  %d/%m/%Y@@ -63,6 +63,7 @@ amount      -%amount     For more examples, see Convert CSV files.+ * Menu:  * CSV RULES::@@ -76,6 +77,7 @@  The following seven kinds of rule can appear in the rules file, in any order.  Blank lines and lines beginning with '#' or ';' are ignored.+ * Menu:  * skip::@@ -137,8 +139,8 @@ whitespace; uninteresting names may be left blank), and (b) assigns them to journal entry fields if you use any of these standard field names: 'date', 'date2', 'status', 'code', 'description', 'comment', 'account1',-'account2', 'amount', 'amount-in', 'amount-out', 'currency', 'balance'.-Eg:+'account2', 'amount', 'amount-in', 'amount-out', 'currency', 'balance',+'balance1', 'balance2'.  Eg:  # use the 1st, 2nd and 4th CSV fields as the entry's date, description and amount, # and give the 7th and 8th fields meaningful names for later reference:@@ -169,6 +171,9 @@    Field assignments can be used instead of or in addition to a field list. +   Note, interpolation strips any outer whitespace, so a CSV value like+'" 1 "' becomes '1' when interpolated (#1051).+  File: hledger_csv.info,  Node: conditional block,  Next: include,  Prev: field assignment,  Up: CSV RULES @@ -244,8 +249,9 @@ * CSV ordering:: * CSV accounts:: * CSV amounts::-* CSV balance assertions::+* CSV balance assertions/assignments:: * Reading multiple CSV files::+* Valid CSV::   File: hledger_csv.info,  Node: CSV ordering,  Next: CSV accounts,  Up: CSV TIPS@@ -269,42 +275,53 @@ the account whose CSV we are reading.  -File: hledger_csv.info,  Node: CSV amounts,  Next: CSV balance assertions,  Prev: CSV accounts,  Up: CSV TIPS+File: hledger_csv.info,  Node: CSV amounts,  Next: CSV balance assertions/assignments,  Prev: CSV accounts,  Up: CSV TIPS  2.3 CSV amounts =============== -The 'amount' field sets the amount of the 'account1' posting.+A transaction amount must be set, in one of these ways: -   If the CSV has debit/credit amounts in separate fields, assign to the-'amount-in' and 'amount-out' pseudo fields instead.  (Whichever one has-a value will be used, with appropriate sign.  If both contain a value,-it may not work so well.)+   * with an 'amount' field assignment, which sets the first posting's+     amount -   If an amount value is parenthesised, it will be de-parenthesised and-sign-flipped.+   * (When the CSV has debit and credit amounts in separate fields:)+     with field assignments for the 'amount-in' and 'amount-out' pseudo+     fields (both of them).  Whichever one has a value will be used,+     with appropriate sign.  If both contain a value, it might not work+     so well. -   If an amount value begins with a double minus sign, those will cancel-out and be removed.+   * or implicitly by means of a balance assignment (see below). -   If the CSV has the currency symbol in a separate field, assign that-to the 'currency' pseudo field to have it prepended to the amount.  Or,-you can use a field assignment to 'amount' that interpolates both CSV-fields (giving more control, eg to put the currency symbol on the-right).+   There is some special handling for sign in amounts: +   * If an amount value is parenthesised, it will be de-parenthesised+     and sign-flipped.+   * If an amount value begins with a double minus sign, those will+     cancel out and be removed.++   If the currency/commodity symbol is provided as a separate CSV field,+assign it to the 'currency' pseudo field; the symbol will be prepended+to the amount (TODO: when there is an amount).  Or, you can use an+'amount' field assignment for more control, eg:++fields date,description,currency,amount+amount %amount %currency+ -File: hledger_csv.info,  Node: CSV balance assertions,  Next: Reading multiple CSV files,  Prev: CSV amounts,  Up: CSV TIPS+File: hledger_csv.info,  Node: CSV balance assertions/assignments,  Next: Reading multiple CSV files,  Prev: CSV amounts,  Up: CSV TIPS -2.4 CSV balance assertions-==========================+2.4 CSV balance assertions/assignments+====================================== -If the CSV includes a running balance, you can assign that to the-'balance' pseudo field; whenever the running balance value is non-empty,-it will be asserted as the balance after the 'account1' posting.+If the CSV includes a running balance, you can assign that to one of the+pseudo fields 'balance' (or 'balance1') or 'balance2'.  This will+generate a balance assertion (or if the amount is left empty, a balance+assignment), on the first or second posting, whenever the running+balance field is non-empty.  (TODO: #1000)  -File: hledger_csv.info,  Node: Reading multiple CSV files,  Prev: CSV balance assertions,  Up: CSV TIPS+File: hledger_csv.info,  Node: Reading multiple CSV files,  Next: Valid CSV,  Prev: CSV balance assertions/assignments,  Up: CSV TIPS  2.5 Reading multiple CSV files ==============================@@ -315,35 +332,53 @@ one rules file will be used for all the CSV files being read.  +File: hledger_csv.info,  Node: Valid CSV,  Prev: Reading multiple CSV files,  Up: CSV TIPS++2.6 Valid CSV+=============++hledger follows RFC 4180, with the addition of a customisable separator+character.++   Some things to note:++   When quoting fields,++   * you must use double quotes, not single quotes+   * spaces outside the quotes are not allowed.++ Tag Table: Node: Top72-Node: CSV RULES2163-Ref: #csv-rules2271-Node: skip2533-Ref: #skip2627-Node: date-format2799-Ref: #date-format2926-Node: field list3476-Ref: #field-list3613-Node: field assignment4318-Ref: #field-assignment4473-Node: conditional block4977-Ref: #conditional-block5131-Node: include6027-Ref: #include6157-Node: newest-first6388-Ref: #newest-first6502-Node: CSV TIPS6913-Ref: #csv-tips7007-Node: CSV ordering7125-Ref: #csv-ordering7243-Node: CSV accounts7424-Ref: #csv-accounts7562-Node: CSV amounts7816-Ref: #csv-amounts7962-Node: CSV balance assertions8737-Ref: #csv-balance-assertions8919-Node: Reading multiple CSV files9124-Ref: #reading-multiple-csv-files9294+Node: CSV RULES2161+Ref: #csv-rules2269+Node: skip2532+Ref: #skip2626+Node: date-format2798+Ref: #date-format2925+Node: field list3475+Ref: #field-list3612+Node: field assignment4342+Ref: #field-assignment4497+Node: conditional block5121+Ref: #conditional-block5275+Node: include6171+Ref: #include6301+Node: newest-first6532+Ref: #newest-first6646+Node: CSV TIPS7057+Ref: #csv-tips7151+Node: CSV ordering7295+Ref: #csv-ordering7413+Node: CSV accounts7594+Ref: #csv-accounts7732+Node: CSV amounts7986+Ref: #csv-amounts8144+Node: CSV balance assertions/assignments9224+Ref: #csv-balance-assertionsassignments9442+Node: Reading multiple CSV files9763+Ref: #reading-multiple-csv-files9963+Node: Valid CSV10237+Ref: #valid-csv10360  End Tag Table
embeddedfiles/hledger_csv.txt view
@@ -29,8 +29,8 @@        you'll need to adjust.         At minimum, the rules file must identify the date  and  amount  fields.-       It  may also be necessary to specify the date format, and the number of-       header lines to skip.  Eg:+       It's  often  necessary  to  specify  the date format, and the number of+       header lines to skip, also.  Eg:                fields date, _, _, amount               date-format  %d/%m/%Y@@ -83,10 +83,10 @@    date-format        date-formatDATEFMT -       When your CSV  date  fields  are  not  formatted  like  YYYY/MM/DD  (or-       YYYY-MM-DD  or YYYY.MM.DD), you'll need to specify the format.  DATEFMT-       is a strptime-like date parsing pattern,  which  must  parse  the  date-       field values completely.  Examples:+       When your CSV date fields are not formatted like YYYY/MM/DD  (or  YYYY-+       MM-DD  or YYYY.MM.DD), you'll need to specify the format.  DATEFMT is a+       strptime-like date parsing pattern, which must  parse  the  date  field+       values completely.  Examples:                # for dates like "11/06/2013":               date-format %m/%d/%Y@@ -107,7 +107,8 @@        space; uninteresting names may be left blank), and (b) assigns them  to        journal  entry  fields  if  you  use any of these standard field names:        date, date2, status, code, description,  comment,  account1,  account2,-       amount, amount-in, amount-out, currency, balance.  Eg:+       amount,  amount-in,  amount-out, currency, balance, balance1, balance2.+       Eg:                # use the 1st, 2nd and 4th CSV fields as the entry's date, description and amount,               # and give the 7th and 8th fields meaningful names for later reference:@@ -120,10 +121,9 @@    field assignment        ENTRYFIELDNAME FIELDVALUE -       This  sets  a  journal entry field (one of the standard names above) to-       the given text value, which can include CSV field  values  interpolated-       by name (%CSVFIELDNAME) or 1-based position (%N).-        Eg:+       This sets a journal entry field (one of the standard  names  above)  to+       the  given  text value, which can include CSV field values interpolated+       by name (%CSVFIELDNAME) or 1-based position (%N).  Eg:                # set the amount to the 4th CSV field with "USD " prepended               amount USD %4@@ -131,9 +131,12 @@               # combine three fields to make a comment (containing two tags)               comment note: %somefield - %anotherfield, date: %1 -       Field  assignments  can  be  used  instead of or in addition to a field+       Field assignments can be used instead of or  in  addition  to  a  field        list. +       Note,  interpolation strips any outer whitespace, so a CSV value like "+       1 " becomes 1 when interpolated (#1051).+    conditional block        if PATTERN            FIELDASSIGNMENTS...@@ -195,39 +198,63 @@        the account whose CSV we are reading.     CSV amounts-       The amount field sets the amount of the account1 posting.+       A transaction amount must be set, in one of these ways: -       If the CSV has debit/credit amounts in separate fields, assign  to  the-       amount-in  and  amount-out pseudo fields instead.  (Whichever one has a-       value will be used, with appropriate sign.  If both contain a value, it-       may not work so well.)+       o with an amount field  assignment,  which  sets  the  first  posting's+         amount -       If  an  amount  value is parenthesised, it will be de-parenthesised and-       sign-flipped.+       o (When the CSV has debit and credit amounts in separate fields:)+       with  field  assignments for the amount-in and amount-out pseudo fields+       (both of them).  Whichever one has a value will be used, with appropri-+       ate sign.  If both contain a value, it might not work so well. -       If an amount value begins with a double minus sign, those  will  cancel-       out and be removed.+       o or implicitly by means of a balance assignment (see below). -       If  the CSV has the currency symbol in a separate field, assign that to-       the currency pseudo field to have it prepended to the amount.  Or,  you-       can  use a field assignment to amount that interpolates both CSV fields-       (giving more control, eg to put the currency symbol on the right).+       There is some special handling for sign in amounts: -   CSV balance assertions-       If the CSV includes a running balance, you can assign that to the  bal--       ance  pseudo field; whenever the running balance value is non-empty, it-       will be asserted as the balance after the account1 posting.+       o If  an amount value is parenthesised, it will be de-parenthesised and+         sign-flipped. +       o If an amount value begins with a double minus sign, those will cancel+         out and be removed.++       If  the  currency/commodity symbol is provided as a separate CSV field,+       assign it to the currency pseudo field; the symbol will be prepended to+       the  amount (TODO: when there is an amount).  Or, you can use an amount+       field assignment for more control, eg:++              fields date,description,currency,amount+              amount %amount %currency++   CSV balance assertions/assignments+       If the CSV includes a running balance, you can assign that  to  one  of+       the  pseudo fields balance (or balance1) or balance2.  This will gener-+       ate a balance assertion (or if the amount  is  left  empty,  a  balance+       assignment),  on the first or second posting, whenever the running bal-+       ance field is non-empty.  (TODO: #1000)+    Reading multiple CSV files        You can read multiple CSV files at once using multiple -f arguments  on        the  command  line,  and  hledger will look for a correspondingly-named        rules file for each.  Note if you use the --rules-file option, this one        rules file will be used for all the CSV files being read. +   Valid CSV+       hledger follows RFC 4180, with the addition of a customisable separator+       character. +       Some things to note: +       When quoting fields,++       o you must use double quotes, not single quotes++       o spaces outside the quotes are not allowed.+++ REPORTING BUGS-       Report  bugs at http://bugs.hledger.org (or on the #hledger IRC channel+       Report bugs at http://bugs.hledger.org (or on the #hledger IRC  channel        or hledger mail list)  @@ -241,7 +268,7 @@   SEE ALSO-       hledger(1),     hledger-ui(1),     hledger-web(1),      hledger-api(1),+       hledger(1),      hledger-ui(1),     hledger-web(1),     hledger-api(1),        hledger_csv(5), hledger_journal(5), hledger_timeclock(5), hledger_time-        dot(5), ledger(1) @@ -249,4 +276,4 @@   -hledger 1.14                      March 2019                    hledger_csv(5)+hledger 1.15                      August 2019                   hledger_csv(5)
embeddedfiles/hledger_journal.5 view
@@ -1,1753 +1,1822 @@ .\"t -.TH "hledger_journal" "5" "March 2019" "hledger 1.14" "hledger User Manuals"----.SH NAME-.PP-Journal \- hledger\[aq]s default file format, representing a General-Journal-.SH DESCRIPTION-.PP-hledger\[aq]s usual data source is a plain text file containing journal-entries in hledger journal format.-This file represents a standard accounting general journal.-I use file names ending in \f[C]\&.journal\f[], but that\[aq]s not-required.-The journal file contains a number of transaction entries, each-describing a transfer of money (or any commodity) between two or more-named accounts, in a simple format readable by both hledger and humans.-.PP-hledger\[aq]s journal format is a compatible subset, mostly, of-ledger\[aq]s journal format, so hledger can work with compatible ledger-journal files as well.-It\[aq]s safe, and encouraged, to run both hledger and ledger on the-same journal file, eg to validate the results you\[aq]re getting.-.PP-You can use hledger without learning any more about this file; just use-the add or web commands to create and update it.-Many users, though, also edit the journal file directly with a text-editor, perhaps assisted by the helper modes for emacs or vim.-.PP-Here\[aq]s an example:-.IP-.nf-\f[C]-;\ A\ sample\ journal\ file.\ This\ is\ a\ comment.--2008/01/01\ income\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ;\ <\-\ transaction\[aq]s\ first\ line\ starts\ in\ column\ 0,\ contains\ date\ and\ description-\ \ \ \ assets:bank:checking\ \ $1\ \ \ \ ;\ <\-\ posting\ lines\ start\ with\ whitespace,\ each\ contains\ an\ account\ name-\ \ \ \ income:salary\ \ \ \ \ \ \ \ $\-1\ \ \ \ ;\ \ \ \ followed\ by\ at\ least\ two\ spaces\ and\ an\ amount--2008/06/01\ gift-\ \ \ \ assets:bank:checking\ \ $1\ \ \ \ ;\ <\-\ at\ least\ two\ postings\ in\ a\ transaction-\ \ \ \ income:gifts\ \ \ \ \ \ \ \ \ $\-1\ \ \ \ ;\ <\-\ their\ amounts\ must\ balance\ to\ 0--2008/06/02\ save-\ \ \ \ assets:bank:saving\ \ \ \ $1-\ \ \ \ assets:bank:checking\ \ \ \ \ \ \ \ ;\ <\-\ one\ amount\ may\ be\ omitted;\ here\ $\-1\ is\ inferred--2008/06/03\ eat\ &\ shop\ \ \ \ \ \ \ \ \ \ \ ;\ <\-\ description\ can\ be\ anything-\ \ \ \ expenses:food\ \ \ \ \ \ \ \ \ $1-\ \ \ \ expenses:supplies\ \ \ \ \ $1\ \ \ \ ;\ <\-\ this\ transaction\ debits\ two\ expense\ accounts-\ \ \ \ assets:cash\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ;\ <\-\ $\-2\ inferred--2008/10/01\ take\ a\ loan-\ \ \ \ assets:bank:checking\ \ $1-\ \ \ \ liabilities:debts\ \ \ \ $\-1--2008/12/31\ *\ pay\ off\ \ \ \ \ \ \ \ \ \ \ \ ;\ <\-\ an\ optional\ *\ or\ !\ after\ the\ date\ means\ "cleared"\ (or\ anything\ you\ want)-\ \ \ \ liabilities:debts\ \ \ \ \ $1-\ \ \ \ assets:bank:checking-\f[]-.fi-.SH FILE FORMAT-.SS Transactions-.PP-Transactions are movements of some quantity of commodities between named-accounts.-Each transaction is represented by a journal entry beginning with a-simple date in column 0.-This can be followed by any of the following, separated by spaces:-.IP \[bu] 2-(optional) a status character (empty, \f[C]!\f[], or \f[C]*\f[])-.IP \[bu] 2-(optional) a transaction code (any short number or text, enclosed in-parentheses)-.IP \[bu] 2-(optional) a transaction description (any remaining text until end of-line or a semicolon)-.IP \[bu] 2-(optional) a transaction comment (any remaining text following a-semicolon until end of line)-.PP-Then comes zero or more (but usually at least 2) indented lines-representing...-.SS Postings-.PP-A posting is an addition of some amount to, or removal of some amount-from, an account.-Each posting line begins with at least one space or tab (2 or 4 spaces-is common), followed by:-.IP \[bu] 2-(optional) a status character (empty, \f[C]!\f[], or \f[C]*\f[]),-followed by a space-.IP \[bu] 2-(required) an account name (any text, optionally containing \f[B]single-spaces\f[], until end of line or a double space)-.IP \[bu] 2-(optional) \f[B]two or more spaces\f[] or tabs followed by an amount.-.PP-Positive amounts are being added to the account, negative amounts are-being removed.-.PP-The amounts within a transaction must always sum up to zero.-As a convenience, one amount may be left blank; it will be inferred so-as to balance the transaction.-.PP-Be sure to note the unusual two\-space delimiter between account name-and amount.-This makes it easy to write account names containing spaces.-But if you accidentally leave only one space (or tab) before the amount,-the amount will be considered part of the account name.-.SS Dates-.SS Simple dates-.PP-Within a journal file, transaction dates use Y/M/D (or Y\-M\-D or Y.M.D)-Leading zeros are optional.-The year may be omitted, in which case it will be inferred from the-context \- the current transaction, the default year set with a default-year directive, or the current date when the command is run.-Some examples: \f[C]2010/01/31\f[], \f[C]1/31\f[],-\f[C]2010\-01\-31\f[], \f[C]2010.1.31\f[].-.SS Secondary dates-.PP-Real\-life transactions sometimes involve more than one date \- eg the-date you write a cheque, and the date it clears in your bank.-When you want to model this, eg for more accurate balances, you can-specify individual posting dates, which I recommend.-Or, you can use the secondary dates (aka auxiliary/effective dates)-feature, supported for compatibility with Ledger.-.PP-A secondary date can be written after the primary date, separated by an-equals sign.-The primary date, on the left, is used by default; the secondary date,-on the right, is used when the \f[C]\-\-date2\f[] flag is specified-(\f[C]\-\-aux\-date\f[] or \f[C]\-\-effective\f[] also work).-.PP-The meaning of secondary dates is up to you, but it\[aq]s best to follow-a consistent rule.-Eg write the bank\[aq]s clearing date as primary, and when needed, the-date the transaction was initiated as secondary.-.PP-Here\[aq]s an example.-Note that a secondary date will use the year of the primary date if-unspecified.-.IP-.nf-\f[C]-2010/2/23=2/19\ movie\ ticket-\ \ expenses:cinema\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $10-\ \ assets:checking-\f[]-.fi-.IP-.nf-\f[C]-$\ hledger\ register\ checking-2010/02/23\ movie\ ticket\ \ \ \ \ \ \ \ \ assets:checking\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-10\ \ \ \ \ \ \ \ \ $\-10-\f[]-.fi-.IP-.nf-\f[C]-$\ hledger\ register\ checking\ \-\-date2-2010/02/19\ movie\ ticket\ \ \ \ \ \ \ \ \ assets:checking\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-10\ \ \ \ \ \ \ \ \ $\-10-\f[]-.fi-.PP-Secondary dates require some effort; you must use them consistently in-your journal entries and remember whether to use or not use the-\f[C]\-\-date2\f[] flag for your reports.-They are included in hledger for Ledger compatibility, but posting dates-are a more powerful and less confusing alternative.-.SS Posting dates-.PP-You can give individual postings a different date from their parent-transaction, by adding a posting comment containing a tag (see below)-like \f[C]date:DATE\f[].-This is probably the best way to control posting dates precisely.-Eg in this example the expense should appear in May reports, and the-deduction from checking should be reported on 6/1 for easy bank-reconciliation:-.IP-.nf-\f[C]-2015/5/30-\ \ \ \ expenses:food\ \ \ \ \ $10\ \ \ ;\ food\ purchased\ on\ saturday\ 5/30-\ \ \ \ assets:checking\ \ \ \ \ \ \ \ \ ;\ bank\ cleared\ it\ on\ monday,\ date:6/1-\f[]-.fi-.IP-.nf-\f[C]-$\ hledger\ \-f\ t.j\ register\ food-2015/05/30\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ expenses:food\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $10\ \ \ \ \ \ \ \ \ \ \ $10-\f[]-.fi-.IP-.nf-\f[C]-$\ hledger\ \-f\ t.j\ register\ checking-2015/06/01\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ assets:checking\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-10\ \ \ \ \ \ \ \ \ \ $\-10-\f[]-.fi-.PP-DATE should be a simple date; if the year is not specified it will use-the year of the transaction\[aq]s date.-You can set the secondary date similarly, with \f[C]date2:DATE2\f[].-The \f[C]date:\f[] or \f[C]date2:\f[] tags must have a valid simple date-value if they are present, eg a \f[C]date:\f[] tag with no value is not-allowed.-.PP-Ledger\[aq]s earlier, more compact bracketed date syntax is also-supported: \f[C][DATE]\f[], \f[C][DATE=DATE2]\f[] or \f[C][=DATE2]\f[].-hledger will attempt to parse any square\-bracketed sequence of the-\f[C]0123456789/\-.=\f[] characters in this way.-With this syntax, DATE infers its year from the transaction and DATE2-infers its year from DATE.-.SS Status-.PP-Transactions, or individual postings within a transaction, can have a-status mark, which is a single character before the transaction-description or posting account name, separated from it by a space,-indicating one of three statuses:-.PP-.TS-tab(@);-l l.-T{-mark \ -T}@T{-status-T}-_-T{-\ -T}@T{-unmarked-T}-T{-\f[C]!\f[]-T}@T{-pending-T}-T{-\f[C]*\f[]-T}@T{-cleared-T}-.TE-.PP-When reporting, you can filter by status with the-\f[C]\-U/\-\-unmarked\f[], \f[C]\-P/\-\-pending\f[], and-\f[C]\-C/\-\-cleared\f[] flags; or the \f[C]status:\f[],-\f[C]status:!\f[], and \f[C]status:*\f[] queries; or the U, P, C keys in-hledger\-ui.-.PP-Note, in Ledger and in older versions of hledger, the "unmarked" state-is called "uncleared".-As of hledger 1.3 we have renamed it to unmarked for clarity.-.PP-To replicate Ledger and old hledger\[aq]s behaviour of also matching-pending, combine \-U and \-P.-.PP-Status marks are optional, but can be helpful eg for reconciling with-real\-world accounts.-Some editor modes provide highlighting and shortcuts for working with-status.-Eg in Emacs ledger\-mode, you can toggle transaction status with C\-c-C\-e, or posting status with C\-c C\-c.-.PP-What "uncleared", "pending", and "cleared" actually mean is up to you.-Here\[aq]s one suggestion:-.PP-.TS-tab(@);-lw(9.9n) lw(60.1n).-T{-status-T}@T{-meaning-T}-_-T{-uncleared-T}@T{-recorded but not yet reconciled; needs review-T}-T{-pending-T}@T{-tentatively reconciled (if needed, eg during a big reconciliation)-T}-T{-cleared-T}@T{-complete, reconciled as far as possible, and considered correct-T}-.TE-.PP-With this scheme, you would use \f[C]\-PC\f[] to see the current balance-at your bank, \f[C]\-U\f[] to see things which will probably hit your-bank soon (like uncashed checks), and no flags to see the most-up\-to\-date state of your finances.-.SS Description-.PP-A transaction\[aq]s description is the rest of the line following the-date and status mark (or until a comment begins).-Sometimes called the "narration" in traditional bookkeeping, it can be-used for whatever you wish, or left blank.-Transaction descriptions can be queried, unlike comments.-.SS Payee and note-.PP-You can optionally include a \f[C]|\f[] (pipe) character in a-description to subdivide it into a payee/payer name on the left and-additional notes on the right.-This may be worthwhile if you need to do more precise querying and-pivoting by payee.-.SS Account names-.PP-Account names typically have several parts separated by a full colon,-from which hledger derives a hierarchical chart of accounts.-They can be anything you like, but in finance there are traditionally-five top\-level accounts: \f[C]assets\f[], \f[C]liabilities\f[],-\f[C]income\f[], \f[C]expenses\f[], and \f[C]equity\f[].-.PP-Account names may contain single spaces, eg:-\f[C]assets:accounts\ receivable\f[].-Because of this, they must always be followed by \f[B]two or more-spaces\f[] (or newline).-.PP-Account names can be aliased.-.SS Amounts-.PP-After the account name, there is usually an amount.-Important: between account name and amount, there must be \f[B]two or-more spaces\f[].-.PP-Amounts consist of a number and (usually) a currency symbol or commodity-name.-Some examples:-.PP-\f[C]2.00001\f[]-.PD 0-.P-.PD-\f[C]$1\f[]-.PD 0-.P-.PD-\f[C]4000\ AAPL\f[]-.PD 0-.P-.PD-\f[C]3\ "green\ apples"\f[]-.PD 0-.P-.PD-\f[C]\-$1,000,000.00\f[]-.PD 0-.P-.PD-\f[C]INR\ 9,99,99,999.00\f[]-.PD 0-.P-.PD-\f[C]EUR\ \-2.000.000,00\f[]-.PD 0-.P-.PD-\f[C]1\ 999\ 999.9455\f[]-.PD 0-.P-.PD-\f[C]EUR\ 1E3\f[]-.PD 0-.P-.PD-\f[C]1000E\-6s\f[]-.PP-As you can see, the amount format is somewhat flexible:-.IP \[bu] 2-amounts are a number (the "quantity") and optionally a currency-symbol/commodity name (the "commodity").-.IP \[bu] 2-the commodity is a symbol, word, or phrase, on the left or right, with-or without a separating space.-If the commodity contains numbers, spaces or non\-word punctuation it-must be enclosed in double quotes.-.IP \[bu] 2-negative amounts with a commodity on the left can have the minus sign-before or after it-.IP \[bu] 2-digit groups (thousands, or any other grouping) can be separated by-space or comma or period and should be used as separator between all-groups-.IP \[bu] 2-decimal part can be separated by comma or period and should be different-from digit groups separator-.IP \[bu] 2-scientific E\-notation is allowed.-Be careful not to use a digit group separator character in scientific-notation, as it\[aq]s not supported and it might get mistaken for a-decimal point.-(Declaring the digit group separator character explicitly with a-commodity directive will prevent this.)-.PP-You can use any of these variations when recording data.-However, there is some ambiguous way of representing numbers like-\f[C]$1.000\f[] and \f[C]$1,000\f[] both may mean either one thousand or-one dollar.-By default hledger will assume that this is sole delimiter is used only-for decimals.-On the other hand commodity format declared prior to that line will help-to resolve that ambiguity differently:-.IP-.nf-\f[C]-commodity\ $1,000.00--2017/12/25\ New\ life\ of\ Scrooge-\ \ \ \ expenses:gifts\ \ $1,000-\ \ \ \ assets-\f[]-.fi-.PP-Though journal may contain mixed styles to represent amount, when-hledger displays amounts, it will choose a consistent format for each-commodity.-(Except for price amounts, which are always formatted as written).-The display format is chosen as follows:-.IP \[bu] 2-if there is a commodity directive specifying the format, that is used-.IP \[bu] 2-otherwise the format is inferred from the first posting amount in that-commodity in the journal, and the precision (number of decimal places)-will be the maximum from all posting amounts in that commmodity-.IP \[bu] 2-or if there are no such amounts in the journal, a default format is used-(like \f[C]$1000.00\f[]).-.PP-Price amounts and amounts in \f[C]D\f[] directives usually don\[aq]t-affect amount format inference, but in some situations they can do so-indirectly.-(Eg when D\[aq]s default commodity is applied to a commodity\-less-amount, or when an amountless posting is balanced using a price\[aq]s-commodity, or when \-V is used.) If you find this causing problems, set-the desired format with a commodity directive.-.SS Virtual Postings-.PP-When you parenthesise the account name in a posting, we call that a-\f[I]virtual posting\f[], which means:-.IP \[bu] 2-it is ignored when checking that the transaction is balanced-.IP \[bu] 2-it is excluded from reports when the \f[C]\-\-real/\-R\f[] flag is used,-or the \f[C]real:1\f[] query.-.PP-You could use this, eg, to set an account\[aq]s opening balance without-needing to use the \f[C]equity:opening\ balances\f[] account:-.IP-.nf-\f[C]-1/1\ special\ unbalanced\ posting\ to\ set\ initial\ balance-\ \ (assets:checking)\ \ \ $1000-\f[]-.fi-.PP-When the account name is bracketed, we call it a \f[I]balanced virtual-posting\f[].-This is like an ordinary virtual posting except the balanced virtual-postings in a transaction must balance to 0, like the real postings (but-separately from them).-Balanced virtual postings are also excluded by \f[C]\-\-real/\-R\f[] or-\f[C]real:1\f[].-.IP-.nf-\f[C]-1/1\ buy\ food\ with\ cash,\ and\ update\ some\ budget\-tracking\ subaccounts\ elsewhere-\ \ expenses:food\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $10-\ \ assets:cash\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-10-\ \ [assets:checking:available]\ \ \ \ \ $10-\ \ [assets:checking:budget:food]\ \ $\-10-\f[]-.fi-.PP-Virtual postings have some legitimate uses, but those are few.-You can usually find an equivalent journal entry using real postings,-which is more correct and provides better error checking.-.SS Balance Assertions-.PP-hledger supports Ledger\-style balance assertions in journal files.-These look like, for example, \f[C]=\ EXPECTEDBALANCE\f[] following a-posting\[aq]s amount.-Eg here we assert the expected dollar balance in accounts a and b after-each posting:-.IP-.nf-\f[C]-2013/1/1-\ \ a\ \ \ $1\ \ =$1-\ \ b\ \ \ \ \ \ \ =$\-1--2013/1/2-\ \ a\ \ \ $1\ \ =$2-\ \ b\ \ $\-1\ \ =$\-2-\f[]-.fi-.PP-After reading a journal file, hledger will check all balance assertions-and report an error if any of them fail.-Balance assertions can protect you from, eg, inadvertently disrupting-reconciled balances while cleaning up old entries.-You can disable them temporarily with the-\f[C]\-I/\-\-ignore\-assertions\f[] flag, which can be useful for-troubleshooting or for reading Ledger files.-.SS Assertions and ordering-.PP-hledger sorts an account\[aq]s postings and assertions first by date and-then (for postings on the same day) by parse order.-Note this is different from Ledger, which sorts assertions only by parse-order.-(Also, Ledger assertions do not see the accumulated effect of repeated-postings to the same account within a transaction.)-.PP-So, hledger balance assertions keep working if you reorder-differently\-dated transactions within the journal.-But if you reorder same\-dated transactions or postings, assertions-might break and require updating.-This order dependence does bring an advantage: precise control over the-order of postings and assertions within a day, so you can assert-intra\-day balances.-.SS Assertions and included files-.PP-With included files, things are a little more complicated.-Including preserves the ordering of postings and assertions.-If you have multiple postings to an account on the same day, split-across different files, and you also want to assert the account\[aq]s-balance on the same day, you\[aq]ll have to put the assertion in the-right file.-.SS Assertions and multiple \-f options-.PP-Balance assertions don\[aq]t work well across files specified with-multiple \-f options.-Use include or concatenate the files instead.-.SS Assertions and commodities-.PP-The asserted balance must be a simple single\-commodity amount, and in-fact the assertion checks only this commodity\[aq]s balance within the-(possibly multi\-commodity) account balance.-.PD 0-.P-.PD-This is how assertions work in Ledger also.-We could call this a "partial" balance assertion.-.PP-To assert the balance of more than one commodity in an account, you can-write multiple postings, each asserting one commodity\[aq]s balance.-.PP-You can make a stronger "total" balance assertion by writing a double-equals sign (\f[C]==\ EXPECTEDBALANCE\f[]).-This asserts that there are no other unasserted commodities in the-account (or, that their balance is 0).-.IP-.nf-\f[C]-2013/1/1-\ \ a\ \ \ $1-\ \ a\ \ \ \ 1€-\ \ b\ \ $\-1-\ \ c\ \ \ \-1€--2013/1/2\ \ ;\ These\ assertions\ succeed-\ \ a\ \ \ \ 0\ \ =\ \ $1-\ \ a\ \ \ \ 0\ \ =\ \ \ 1€-\ \ b\ \ \ \ 0\ ==\ $\-1-\ \ c\ \ \ \ 0\ ==\ \ \-1€--2013/1/3\ \ ;\ This\ assertion\ fails\ as\ \[aq]a\[aq]\ also\ contains\ 1€-\ \ a\ \ \ \ 0\ ==\ \ $1-\f[]-.fi-.PP-It\[aq]s not yet possible to make a complete assertion about a balance-that has multiple commodities.-One workaround is to isolate each commodity into its own subaccount:-.IP-.nf-\f[C]-2013/1/1-\ \ a:usd\ \ \ $1-\ \ a:euro\ \ \ 1€-\ \ b--2013/1/2-\ \ a\ \ \ \ \ \ \ \ 0\ ==\ \ 0-\ \ a:usd\ \ \ \ 0\ ==\ $1-\ \ a:euro\ \ \ 0\ ==\ \ 1€-\f[]-.fi-.SS Assertions and prices-.PP-Balance assertions ignore transaction prices, and should normally be-written without one:-.IP-.nf-\f[C]-2019/1/1-\ \ (a)\ \ \ \ \ $1\ \@\ €1\ =\ $1-\f[]-.fi-.PP-We do allow prices to be written there, however, and print shows them,-even though they don\[aq]t affect whether the assertion passes or fails.-This is for backward compatibility (hledger\[aq]s close command used to-generate balance assertions with prices), and because balance-\f[I]assignments\f[] do use them (see below).-.SS Assertions and subaccounts-.PP-The balance assertions above (\f[C]=\f[] and \f[C]==\f[]) do not count-the balance from subaccounts; they check the account\[aq]s exclusive-balance only.-You can assert the balance including subaccounts by writing \f[C]=*\f[]-or \f[C]==*\f[], eg:-.IP-.nf-\f[C]-2019/1/1-\ \ equity:opening\ balances-\ \ checking:a\ \ \ \ \ \ \ 5-\ \ checking:b\ \ \ \ \ \ \ 5-\ \ checking\ \ \ \ \ \ \ \ \ 1\ \ ==*\ 11-\f[]-.fi-.SS Assertions and virtual postings-.PP-Balance assertions are checked against all postings, both real and-virtual.-They are not affected by the \f[C]\-\-real/\-R\f[] flag or-\f[C]real:\f[] query.-.SS Assertions and precision-.PP-Balance assertions compare the exactly calculated amounts, which are not-always what is shown by reports.-Eg a commodity directive may limit the display precision, but this will-not affect balance assertions.-Balance assertion failure messages show exact amounts.-.SS Balance Assignments-.PP-Ledger\-style balance assignments are also supported.-These are like balance assertions, but with no posting amount on the-left side of the equals sign; instead it is calculated automatically so-as to satisfy the assertion.-This can be a convenience during data entry, eg when setting opening-balances:-.IP-.nf-\f[C]-;\ starting\ a\ new\ journal,\ set\ asset\ account\ balances\ -2016/1/1\ opening\ balances-\ \ assets:checking\ \ \ \ \ \ \ \ \ \ \ \ =\ $409.32-\ \ assets:savings\ \ \ \ \ \ \ \ \ \ \ \ \ =\ $735.24-\ \ assets:cash\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ =\ $42-\ \ equity:opening\ balances-\f[]-.fi-.PP-or when adjusting a balance to reality:-.IP-.nf-\f[C]-;\ no\ cash\ left;\ update\ balance,\ record\ any\ untracked\ spending\ as\ a\ generic\ expense-2016/1/15-\ \ assets:cash\ \ \ \ =\ $0-\ \ expenses:misc-\f[]-.fi-.PP-The calculated amount depends on the account\[aq]s balance in the-commodity at that point (which depends on the previously\-dated postings-of the commodity to that account since the last balance assertion or-assignment).-Note that using balance assignments makes your journal a little less-explicit; to know the exact amount posted, you have to run hledger or do-the calculations yourself, instead of just reading it.-.SS Balance assignments and prices-.PP-A transaction price in a balance assignment will cause the calculated-amount to have that price attached:-.IP-.nf-\f[C]-2019/1/1-\ \ (a)\ \ \ \ \ \ \ \ \ \ \ \ \ =\ $1\ \@\ €2-\f[]-.fi-.IP-.nf-\f[C]-$\ hledger\ print\ \-\-explicit-2019/01/01-\ \ \ \ (a)\ \ \ \ \ \ \ \ \ $1\ \@\ €2\ =\ $1\ \@\ €2-\f[]-.fi-.SS Transaction prices-.PP-Within a transaction, you can note an amount\[aq]s price in another-commodity.-This can be used to document the cost (in a purchase) or selling price-(in a sale).-For example, transaction prices are useful to record purchases of a-foreign currency.-Note transaction prices are fixed at the time of the transaction, and do-not change over time.-See also market prices, which represent prevailing exchange rates on a-certain date.-.PP-There are several ways to record a transaction price:-.IP "1." 3-Write the price per unit, as \f[C]\@\ UNITPRICE\f[] after the amount:-.RS 4-.IP-.nf-\f[C]-2009/1/1-\ \ assets:euros\ \ \ \ \ €100\ \@\ $1.35\ \ ;\ one\ hundred\ euros\ purchased\ at\ $1.35\ each-\ \ assets:dollars\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ;\ balancing\ amount\ is\ \-$135.00-\f[]-.fi-.RE-.IP "2." 3-Write the total price, as \f[C]\@\@\ TOTALPRICE\f[] after the amount:-.RS 4-.IP-.nf-\f[C]-2009/1/1-\ \ assets:euros\ \ \ \ \ €100\ \@\@\ $135\ \ ;\ one\ hundred\ euros\ purchased\ at\ $135\ for\ the\ lot-\ \ assets:dollars-\f[]-.fi-.RE-.IP "3." 3-Specify amounts for all postings, using exactly two commodities, and let-hledger infer the price that balances the transaction:-.RS 4-.IP-.nf-\f[C]-2009/1/1-\ \ assets:euros\ \ \ \ \ €100\ \ \ \ \ \ \ \ \ \ ;\ one\ hundred\ euros\ purchased-\ \ assets:dollars\ \ $\-135\ \ \ \ \ \ \ \ \ \ ;\ for\ $135-\f[]-.fi-.RE-.PP-(Ledger users: Ledger uses a different syntax for fixed prices,-\f[C]{=UNITPRICE}\f[], which hledger currently ignores).-.PP-Use the \f[C]\-B/\-\-cost\f[] flag to convert amounts to their-transaction price\[aq]s commodity, if any.-(mnemonic: "B" is from "cost Basis", as in Ledger).-Eg here is how \-B affects the balance report for the example above:-.IP-.nf-\f[C]-$\ hledger\ bal\ \-N\ \-\-flat-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-135\ \ assets:dollars-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ €100\ \ assets:euros-$\ hledger\ bal\ \-N\ \-\-flat\ \-B-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-135\ \ assets:dollars-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $135\ \ assets:euros\ \ \ \ #\ <\-\ the\ euros\[aq]\ cost-\f[]-.fi-.PP-Note \-B is sensitive to the order of postings when a transaction price-is inferred: the inferred price will be in the commodity of the last-amount.-So if example 3\[aq]s postings are reversed, while the transaction is-equivalent, \-B shows something different:-.IP-.nf-\f[C]-2009/1/1-\ \ assets:dollars\ \ $\-135\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ;\ 135\ dollars\ sold-\ \ assets:euros\ \ \ \ \ €100\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ;\ for\ 100\ euros-\f[]-.fi-.IP-.nf-\f[C]-$\ hledger\ bal\ \-N\ \-\-flat\ \-B-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ €\-100\ \ assets:dollars\ \ #\ <\-\ the\ dollars\[aq]\ selling\ price-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ €100\ \ assets:euros-\f[]-.fi-.SS Comments-.PP-Lines in the journal beginning with a semicolon (\f[C];\f[]) or hash-(\f[C]#\f[]) or star (\f[C]*\f[]) are comments, and will be ignored.-(Star comments cause org\-mode nodes to be ignored, allowing emacs users-to fold and navigate their journals with org\-mode or orgstruct\-mode.)-.PP-You can attach comments to a transaction by writing them after the-description and/or indented on the following lines (before the-postings).-Similarly, you can attach comments to an individual posting by writing-them after the amount and/or indented on the following lines.-Transaction and posting comments must begin with a semicolon-(\f[C];\f[]).-.PP-Some examples:-.IP-.nf-\f[C]-#\ a\ file\ comment--;\ also\ a\ file\ comment--comment-This\ is\ a\ multiline\ file\ comment,-which\ continues\ until\ a\ line-where\ the\ "end\ comment"\ string-appears\ on\ its\ own\ (or\ end\ of\ file).-end\ comment--2012/5/14\ something\ \ ;\ a\ transaction\ comment-\ \ \ \ ;\ the\ transaction\ comment,\ continued-\ \ \ \ posting1\ \ 1\ \ ;\ a\ comment\ for\ posting\ 1-\ \ \ \ posting2-\ \ \ \ ;\ a\ comment\ for\ posting\ 2-\ \ \ \ ;\ another\ comment\ line\ for\ posting\ 2-;\ a\ file\ comment\ (because\ not\ indented)-\f[]-.fi-.PP-You can also comment larger regions of a file using \f[C]comment\f[] and-\f[C]end\ comment\f[] directives.-.SS Tags-.PP-Tags are a way to add extra labels or labelled data to postings and-transactions, which you can then search or pivot on.-.PP-A simple tag is a word (which may contain hyphens) followed by a full-colon, written inside a transaction or posting comment line:-.IP-.nf-\f[C]-2017/1/16\ bought\ groceries\ \ \ \ ;\ sometag:-\f[]-.fi-.PP-Tags can have a value, which is the text after the colon, up to the next-comma or end of line, with leading/trailing whitespace removed:-.IP-.nf-\f[C]-\ \ \ \ expenses:food\ \ \ \ $10\ \ \ ;\ a\-posting\-tag:\ the\ tag\ value-\f[]-.fi-.PP-Note this means hledger\[aq]s tag values can not contain commas or-newlines.-Ending at commas means you can write multiple short tags on one line,-comma separated:-.IP-.nf-\f[C]-\ \ \ \ assets:checking\ \ \ \ \ \ \ ;\ a\ comment\ containing\ tag1:,\ tag2:\ some\ value\ ...-\f[]-.fi-.PP-Here,-.IP \[bu] 2-"\f[C]a\ comment\ containing\f[]" is just comment text, not a tag-.IP \[bu] 2-"\f[C]tag1\f[]" is a tag with no value-.IP \[bu] 2-"\f[C]tag2\f[]" is another tag, whose value is-"\f[C]some\ value\ ...\f[]"-.PP-Tags in a transaction comment affect the transaction and all of its-postings, while tags in a posting comment affect only that posting.-For example, the following transaction has three tags (\f[C]A\f[],-\f[C]TAG2\f[], \f[C]third\-tag\f[]) and the posting has four (those plus-\f[C]posting\-tag\f[]):-.IP-.nf-\f[C]-1/1\ a\ transaction\ \ ;\ A:,\ TAG2:-\ \ \ \ ;\ third\-tag:\ a\ third\ transaction\ tag,\ <\-\ with\ a\ value-\ \ \ \ (a)\ \ $1\ \ ;\ posting\-tag:-\f[]-.fi-.PP-Tags are like Ledger\[aq]s metadata feature, except hledger\[aq]s tag-values are simple strings.-.SS Directives-.PP-A directive is a line in the journal beginning with a special keyword,-that influences how the journal is processed.-hledger\[aq]s directives are based on a subset of Ledger\[aq]s, but-there are many differences (and also some differences between hledger-versions).-.PP-Directives\[aq] behaviour and interactions can get a little bit complex,-so here is a table summarising the directives and their effects, with-links to more detailed docs.-.PP-.TS-tab(@);-lw(7.8n) lw(8.6n) lw(7.0n) lw(27.8n) lw(18.8n).-T{-directive-T}@T{-end directive-T}@T{-subdirectives-T}@T{-purpose-T}@T{-can affect (as of 2018/06)-T}-_-T{-\f[C]account\f[]-T}@T{-T}@T{-any text-T}@T{-document account names, declare account types & display order-T}@T{-all entries in all files, before or after-T}-T{-\f[C]alias\f[]-T}@T{-\f[C]end\ aliases\f[]-T}@T{-T}@T{-rewrite account names-T}@T{-following inline/included entries until end of current file or end-directive-T}-T{-\f[C]apply\ account\f[]-T}@T{-\f[C]end\ apply\ account\f[]-T}@T{-T}@T{-prepend a common parent to account names-T}@T{-following inline/included entries until end of current file or end-directive-T}-T{-\f[C]comment\f[]-T}@T{-\f[C]end\ comment\f[]-T}@T{-T}@T{-ignore part of journal-T}@T{-following inline/included entries until end of current file or end-directive-T}-T{-\f[C]commodity\f[]-T}@T{-T}@T{-\f[C]format\f[]-T}@T{-declare a commodity and its number notation & display style-T}@T{-number notation: following entries in that commodity in all files;-display style: amounts of that commodity in reports-T}-T{-\f[C]D\f[]-T}@T{-T}@T{-T}@T{-declare a commodity, number notation & display style for commodityless-amounts-T}@T{-commodity: all commodityless entries in all files; number notation:-following commodityless entries and entries in that commodity in all-files; display style: amounts of that commodity in reports-T}-T{-\f[C]include\f[]-T}@T{-T}@T{-T}@T{-include entries/directives from another file-T}@T{-what the included directives affect-T}-T{-\f[C]P\f[]-T}@T{-T}@T{-T}@T{-declare a market price for a commodity-T}@T{-amounts of that commodity in reports, when \-V is used-T}-T{-\f[C]Y\f[]-T}@T{-T}@T{-T}@T{-declare a year for yearless dates-T}@T{-following inline/included entries until end of current file-T}-.TE-.PP-And some definitions:-.PP-.TS-tab(@);-lw(8.9n) lw(61.1n).-T{-subdirective-T}@T{-optional indented directive line immediately following a parent-directive-T}-T{-number notation-T}@T{-how to interpret numbers when parsing journal entries (the identity of-the decimal separator character).-(Currently each commodity can have its own notation, even in the same-file.)-T}-T{-display style-T}@T{-how to display amounts of a commodity in reports (symbol side and-spacing, digit groups, decimal separator, decimal places)-T}-T{-directive scope-T}@T{-which entries and (when there are multiple files) which files are-affected by a directive-T}-.TE-.PP-As you can see, directives vary in which journal entries and files they-affect, and whether they are focussed on input (parsing) or output-(reports).-Some directives have multiple effects.-.PP-If you have a journal made up of multiple files, or pass multiple \-f-options on the command line, note that directives which affect input-typically last only until the end of their defining file.-This provides more simplicity and predictability, eg reports are not-changed by writing file options in a different order.-It can be surprising at times though.-.SS Comment blocks-.PP-A line containing just \f[C]comment\f[] starts a commented region of the-file, and a line containing just \f[C]end\ comment\f[] (or the end of-the current file) ends it.-See also comments.-.SS Including other files-.PP-You can pull in the content of additional files by writing an include-directive, like this:-.IP-.nf-\f[C]-include\ path/to/file.journal-\f[]-.fi-.PP-If the path does not begin with a slash, it is relative to the current-file.-The include file path may contain common glob patterns (e.g.-\f[C]*\f[]).-.PP-The \f[C]include\f[] directive can only be used in journal files.-It can include journal, timeclock or timedot files, but not CSV files.-.SS Default year-.PP-You can set a default year to be used for subsequent dates which-don\[aq]t specify a year.-This is a line beginning with \f[C]Y\f[] followed by the year.-Eg:-.IP-.nf-\f[C]-Y2009\ \ \ \ \ \ ;\ set\ default\ year\ to\ 2009--12/15\ \ \ \ \ \ ;\ equivalent\ to\ 2009/12/15-\ \ expenses\ \ 1-\ \ assets--Y2010\ \ \ \ \ \ ;\ change\ default\ year\ to\ 2010--2009/1/30\ \ ;\ specifies\ the\ year,\ not\ affected-\ \ expenses\ \ 1-\ \ assets--1/31\ \ \ \ \ \ \ ;\ equivalent\ to\ 2010/1/31-\ \ expenses\ \ 1-\ \ assets-\f[]-.fi-.SS Declaring commodities-.PP-The \f[C]commodity\f[] directive declares commodities which may be used-in the journal (though currently we do not enforce this).-It may be written on a single line, like this:-.IP-.nf-\f[C]-;\ commodity\ EXAMPLEAMOUNT--;\ display\ AAAA\ amounts\ with\ the\ symbol\ on\ the\ right,\ space\-separated,-;\ using\ period\ as\ decimal\ point,\ with\ four\ decimal\ places,\ and-;\ separating\ thousands\ with\ comma.-commodity\ 1,000.0000\ AAAA-\f[]-.fi-.PP-or on multiple lines, using the "format" subdirective.-In this case the commodity symbol appears twice and should be the same-in both places:-.IP-.nf-\f[C]-;\ commodity\ SYMBOL-;\ \ \ format\ EXAMPLEAMOUNT--;\ display\ indian\ rupees\ with\ currency\ name\ on\ the\ left,-;\ thousands,\ lakhs\ and\ crores\ comma\-separated,-;\ period\ as\ decimal\ point,\ and\ two\ decimal\ places.-commodity\ INR-\ \ format\ INR\ 9,99,99,999.00-\f[]-.fi-.PP-Commodity directives have a second purpose: they define the standard-display format for amounts in the commodity.-Normally the display format is inferred from journal entries, but this-can be unpredictable; declaring it with a commodity directive overrides-this and removes ambiguity.-Towards this end, amounts in commodity directives must always be written-with a decimal point (a period or comma, followed by 0 or more decimal-digits).-.SS Default commodity-.PP-The \f[C]D\f[] directive sets a default commodity (and display format),-to be used for amounts without a commodity symbol (ie, plain numbers).-(Note this differs from Ledger\[aq]s default commodity directive.) The-commodity and display format will be applied to all subsequent-commodity\-less amounts, or until the next \f[C]D\f[] directive.-.IP-.nf-\f[C]-#\ commodity\-less\ amounts\ should\ be\ treated\ as\ dollars-#\ (and\ displayed\ with\ symbol\ on\ the\ left,\ thousands\ separators\ and\ two\ decimal\ places)-D\ $1,000.00--1/1-\ \ a\ \ \ \ \ 5\ \ \ \ ;\ <\-\ commodity\-less\ amount,\ becomes\ $1-\ \ b-\f[]-.fi-.PP-As with the \f[C]commodity\f[] directive, the amount must always be-written with a decimal point.-.SS Market prices-.PP-The \f[C]P\f[] directive declares a market price, which is an exchange-rate between two commodities on a certain date.-(In Ledger, they are called "historical prices".) These are often-obtained from a stock exchange, cryptocurrency exchange, or the foreign-exchange market.-.PP-Here is the format:-.IP-.nf-\f[C]-P\ DATE\ COMMODITYA\ COMMODITYBAMOUNT-\f[]-.fi-.IP \[bu] 2-DATE is a simple date-.IP \[bu] 2-COMMODITYA is the symbol of the commodity being priced-.IP \[bu] 2-COMMODITYBAMOUNT is an amount (symbol and quantity) in a second-commodity, giving the price in commodity B of one unit of commodity A.-.PP-These two market price directives say that one euro was worth 1.35 US-dollars during 2009, and $1.40 from 2010 onward:-.IP-.nf-\f[C]-P\ 2009/1/1\ €\ $1.35-P\ 2010/1/1\ €\ $1.40-\f[]-.fi-.PP-The \f[C]\-V/\-\-value\f[] flag can be used to convert reported amounts-to another commodity using these prices.-.SS Declaring accounts-.PP-\f[C]account\f[] directives can be used to pre\-declare accounts.-Though not required, they can provide several benefits:-.IP \[bu] 2-They can document your intended chart of accounts, providing a-reference.-.IP \[bu] 2-They can store extra information about accounts (account numbers, notes,-etc.)-.IP \[bu] 2-They can help hledger know your accounts\[aq] types (asset, liability,-equity, revenue, expense), useful for reports like balancesheet and-incomestatement.-.IP \[bu] 2-They control account display order in reports, allowing non\-alphabetic-sorting (eg Revenues to appear above Expenses).-.IP \[bu] 2-They help with account name completion in the add command,-hledger\-iadd, hledger\-web, ledger\-mode etc.-.PP-The simplest form is just the word \f[C]account\f[] followed by a-hledger\-style account name, eg:-.IP-.nf-\f[C]-account\ assets:bank:checking-\f[]-.fi-.SS Account comments-.PP-Comments, beginning with a semicolon, optionally including tags, can be-written after the account name, and/or on following lines.-Eg:-.IP-.nf-\f[C]-account\ assets:bank:checking\ \ ;\ a\ comment-\ \ ;\ another\ comment-\ \ ;\ acctno:12345,\ a\ tag-\f[]-.fi-.PP-Tip: comments on the same line require hledger 1.12+.-If you need your journal to be compatible with older hledger versions,-write comments on the next line instead.-.SS Account subdirectives-.PP-We also allow (and ignore) Ledger\-style indented subdirectives, just-for compatibility.:-.IP-.nf-\f[C]-account\ assets:bank:checking-\ \ format\ blah\ blah\ \ ;\ <\-\ subdirective,\ ignored-\f[]-.fi-.PP-Here is the full syntax of account directives:-.IP-.nf-\f[C]-account\ ACCTNAME\ \ [ACCTTYPE]\ [;COMMENT]-\ \ [;COMMENTS]-\ \ [LEDGER\-STYLE\ SUBDIRECTIVES,\ IGNORED]-\f[]-.fi-.SS Account types-.PP-hledger recognises five types (or classes) of account: Asset, Liability,-Equity, Revenue, Expense.-This is used by a few accounting\-aware reports such as balancesheet,-incomestatement and cashflow.-.SS Auto\-detected account types-.PP-If you name your top\-level accounts with some variation of-\f[C]assets\f[], \f[C]liabilities\f[]/\f[C]debts\f[], \f[C]equity\f[],-\f[C]revenues\f[]/\f[C]income\f[], or \f[C]expenses\f[], their types are-detected automatically.-.SS Account types declared with tags-.PP-More generally, you can declare an account\[aq]s type with an account-directive, by writing a \f[C]type:\f[] tag in a comment, followed by one-of the words \f[C]Asset\f[], \f[C]Liability\f[], \f[C]Equity\f[],-\f[C]Revenue\f[], \f[C]Expense\f[], or one of the letters \f[C]ALERX\f[]-(case insensitive):-.IP-.nf-\f[C]-account\ assets\ \ \ \ \ \ \ ;\ type:Asset-account\ liabilities\ \ ;\ type:Liability-account\ equity\ \ \ \ \ \ \ ;\ type:Equity-account\ revenues\ \ \ \ \ ;\ type:Revenue-account\ expenses\ \ \ \ \ ;\ type:Expenses-\f[]-.fi-.SS Account types declared with account type codes-.PP-Or, you can write one of those letters separated from the account name-by two or more spaces, but this should probably be considered deprecated-as of hledger 1.13:-.IP-.nf-\f[C]-account\ assets\ \ \ \ \ \ \ A-account\ liabilities\ \ L-account\ equity\ \ \ \ \ \ \ E-account\ revenues\ \ \ \ \ R-account\ expenses\ \ \ \ \ X-\f[]-.fi-.SS Overriding auto\-detected types-.PP-If you ever override the types of those auto\-detected english account-names mentioned above, you might need to help the reports a bit.-Eg:-.IP-.nf-\f[C]-;\ make\ "liabilities"\ not\ have\ the\ liability\ type\ \-\ who\ knows\ why-account\ liabilities\ \ \ ;\ type:E--;\ we\ need\ to\ ensure\ some\ other\ account\ has\ the\ liability\ type,\ -;\ otherwise\ balancesheet\ would\ still\ show\ "liabilities"\ under\ Liabilities\ -account\ \-\ \ \ \ \ \ \ \ \ \ \ \ \ ;\ type:L-\f[]-.fi-.SS Account display order-.PP-Account directives also set the order in which accounts are displayed,-eg in reports, the hledger\-ui accounts screen, and the hledger\-web-sidebar.-By default accounts are listed in alphabetical order.-But if you have these account directives in the journal:-.IP-.nf-\f[C]-account\ assets-account\ liabilities-account\ equity-account\ revenues-account\ expenses-\f[]-.fi-.PP-you\[aq]ll see those accounts displayed in declaration order, not-alphabetically:-.IP-.nf-\f[C]-$\ hledger\ accounts\ \-1-assets-liabilities-equity-revenues-expenses-\f[]-.fi-.PP-Undeclared accounts, if any, are displayed last, in alphabetical order.-.PP-Note that sorting is done at each level of the account tree (within each-group of sibling accounts under the same parent).-And currently, this directive:-.IP-.nf-\f[C]-account\ other:zoo-\f[]-.fi-.PP-would influence the position of \f[C]zoo\f[] among \f[C]other\f[]\[aq]s-subaccounts, but not the position of \f[C]other\f[] among the top\-level-accounts.-This means: \- you will sometimes declare parent accounts (eg-\f[C]account\ other\f[] above) that you don\[aq]t intend to post to,-just to customize their display order \- sibling accounts stay together-(you couldn\[aq]t display \f[C]x:y\f[] in between \f[C]a:b\f[] and-\f[C]a:c\f[]).-.SS Rewriting accounts-.PP-You can define account alias rules which rewrite your account names, or-parts of them, before generating reports.-This can be useful for:-.IP \[bu] 2-expanding shorthand account names to their full form, allowing easier-data entry and a less verbose journal-.IP \[bu] 2-adapting old journals to your current chart of accounts-.IP \[bu] 2-experimenting with new account organisations, like a new hierarchy or-combining two accounts into one-.IP \[bu] 2-customising reports-.PP-Account aliases also rewrite account names in account directives.-They do not affect account names being entered via hledger add or-hledger\-web.-.PP-See also Cookbook: Rewrite account names.-.SS Basic aliases-.PP-To set an account alias, use the \f[C]alias\f[] directive in your-journal file.-This affects all subsequent journal entries in the current file or its-included files.-The spaces around the = are optional:-.IP-.nf-\f[C]-alias\ OLD\ =\ NEW-\f[]-.fi-.PP-Or, you can use the \f[C]\-\-alias\ \[aq]OLD=NEW\[aq]\f[] option on the-command line.-This affects all entries.-It\[aq]s useful for trying out aliases interactively.-.PP-OLD and NEW are case sensitive full account names.-hledger will replace any occurrence of the old account name with the new-one.-Subaccounts are also affected.-Eg:-.IP-.nf-\f[C]-alias\ checking\ =\ assets:bank:wells\ fargo:checking-#\ rewrites\ "checking"\ to\ "assets:bank:wells\ fargo:checking",\ or\ "checking:a"\ to\ "assets:bank:wells\ fargo:checking:a"-\f[]-.fi-.SS Regex aliases-.PP-There is also a more powerful variant that uses a regular expression,-indicated by the forward slashes:-.IP-.nf-\f[C]-alias\ /REGEX/\ =\ REPLACEMENT-\f[]-.fi-.PP-or \f[C]\-\-alias\ \[aq]/REGEX/=REPLACEMENT\[aq]\f[].-.PP-REGEX is a case\-insensitive regular expression.-Anywhere it matches inside an account name, the matched part will be-replaced by REPLACEMENT.-If REGEX contains parenthesised match groups, these can be referenced by-the usual numeric backreferences in REPLACEMENT.-Eg:-.IP-.nf-\f[C]-alias\ /^(.+):bank:([^:]+)(.*)/\ =\ \\1:\\2\ \\3-#\ rewrites\ "assets:bank:wells\ fargo:checking"\ to\ \ "assets:wells\ fargo\ checking"-\f[]-.fi-.PP-Also note that REPLACEMENT continues to the end of line (or on command-line, to end of option argument), so it can contain trailing whitespace.-.SS Multiple aliases-.PP-You can define as many aliases as you like using directives or-command\-line options.-Aliases are recursive \- each alias sees the result of applying previous-ones.-(This is different from Ledger, where aliases are non\-recursive by-default).-Aliases are applied in the following order:-.IP "1." 3-alias directives, most recently seen first (recent directives take-precedence over earlier ones; directives not yet seen are ignored)-.IP "2." 3-alias options, in the order they appear on the command line-.SS \f[C]end\ aliases\f[]-.PP-You can clear (forget) all currently defined aliases with the-\f[C]end\ aliases\f[] directive:-.IP-.nf-\f[C]-end\ aliases-\f[]-.fi-.SS Default parent account-.PP-You can specify a parent account which will be prepended to all accounts-within a section of the journal.-Use the \f[C]apply\ account\f[] and \f[C]end\ apply\ account\f[]-directives like so:-.IP-.nf-\f[C]-apply\ account\ home--2010/1/1-\ \ \ \ food\ \ \ \ $10-\ \ \ \ cash--end\ apply\ account-\f[]-.fi-.PP-which is equivalent to:-.IP-.nf-\f[C]-2010/01/01-\ \ \ \ home:food\ \ \ \ \ \ \ \ \ \ \ $10-\ \ \ \ home:cash\ \ \ \ \ \ \ \ \ \ $\-10-\f[]-.fi-.PP-If \f[C]end\ apply\ account\f[] is omitted, the effect lasts to the end-of the file.-Included files are also affected, eg:-.IP-.nf-\f[C]-apply\ account\ business-include\ biz.journal-end\ apply\ account-apply\ account\ personal-include\ personal.journal-\f[]-.fi-.PP-Prior to hledger 1.0, legacy \f[C]account\f[] and \f[C]end\f[] spellings-were also supported.-.PP-A default parent account also affects account directives.-It does not affect account names being entered via hledger add or-hledger\-web.-If account aliases are present, they are applied after the default-parent account.-.SS Periodic transactions-.PP-Periodic transaction rules describe transactions that recur.-They allow you to generate future transactions for forecasting, without-having to write them out explicitly in the journal (with-\f[C]\-\-forecast\f[]).-Secondly, they also can be used to define budget goals (with-\f[C]\-\-budget\f[]).-.PP-A periodic transaction rule looks like a normal journal entry, with the-date replaced by a tilde (\f[C]~\f[]) followed by a period expression-(mnemonic: \f[C]~\f[] looks like a recurring sine wave.):-.IP-.nf-\f[C]-~\ monthly-\ \ \ \ expenses:rent\ \ \ \ \ \ \ \ \ \ $2000-\ \ \ \ assets:bank:checking-\f[]-.fi-.PP-There is an additional constraint on the period expression: the start-date must fall on a natural boundary of the interval.-Eg \f[C]monthly\ from\ 2018/1/1\f[] is valid, but-\f[C]monthly\ from\ 2018/1/15\f[] is not.-.PP-Partial or relative dates (M/D, D, tomorrow, last week) in the period-expression can work (useful or not).-They will be relative to today\[aq]s date, unless a Y default year-directive is in effect, in which case they will be relative to Y/1/1.-.SS Two spaces after the period expression-.PP-If the period expression is followed by a transaction description, these-must be separated by \f[B]two or more spaces\f[].-This helps hledger know where the period expression ends, so that-descriptions can not accidentally alter their meaning, as in this-example:-.IP-.nf-\f[C]-;\ 2\ or\ more\ spaces\ needed\ here,\ so\ the\ period\ is\ not\ understood\ as\ "every\ 2\ months\ in\ 2020"-;\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||-;\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ vv-~\ every\ 2\ months\ \ in\ 2020,\ we\ will\ review-\ \ \ \ assets:bank:checking\ \ \ $1500-\ \ \ \ income:acme\ inc-\f[]-.fi-.SS Forecasting with periodic transactions-.PP-With the \f[C]\-\-forecast\f[] flag, each periodic transaction rule-generates future transactions recurring at the specified interval.-These are not saved in the journal, but appear in all reports.-They will look like normal transactions, but with an extra tag named-\f[C]recur\f[], whose value is the generating period expression.-.PP-Forecast transactions start on the first occurrence, and end on the last-occurrence, of their interval within the forecast period.-The forecast period:-.IP \[bu] 2-begins on the later of-.RS 2-.IP \[bu] 2-the report start date if specified with \-b/\-p/date:-.IP \[bu] 2-the day after the latest normal (non\-periodic) transaction in the-journal, or today if there are no normal transactions.-.RE-.IP \[bu] 2-ends on the report end date if specified with \-e/\-p/date:, or 180 days-from today.-.PP-where "today" means the current date at report time.-The "later of" rule ensures that forecast transactions do not overlap-normal transactions in time; they will begin only after normal-transactions end.-.PP-Forecasting can be useful for estimating balances into the future, and-experimenting with different scenarios.-Note the start date logic means that forecasted transactions are-automatically replaced by normal transactions as you add those.-.PP-Forecasting can also help with data entry: describe most of your-transactions with periodic rules, and every so often copy the output of-\f[C]print\ \-\-forecast\f[] to the journal.-.PP-You can generate one\-time transactions too: just write a period-expression specifying a date with no report interval.-(You could also write a normal transaction with a future date, but-remember this disables forecast transactions on previous dates.)-.SS Budgeting with periodic transactions-.PP-With the \f[C]\-\-budget\f[] flag, currently supported by the balance-command, each periodic transaction rule declares recurring budget goals-for the specified accounts.-Eg the first example above declares a goal of spending $2000 on rent-(and also, a goal of depositing $2000 into checking) every month.-Goals and actual performance can then be compared in budget reports.-.PP-For more details, see: balance: Budget report and Cookbook: Budgeting-and Forecasting.-.PP-.SS Transaction modifiers-.PP-Transaction modifier rules describe changes that should be applied-automatically to certain transactions.-They can be enabled by using the \f[C]\-\-auto\f[] flag.-Currently, just one kind of change is possible: adding extra postings.-These rule\-generated postings are known as "automated postings" or-"auto postings".-.PP-A transaction modifier rule looks quite like a normal transaction,-except the first line is an equals sign followed by a query that matches-certain postings (mnemonic: \f[C]=\f[] suggests matching).-And each "posting" is actually a posting\-generating rule:-.IP-.nf-\f[C]-=\ QUERY-\ \ \ \ ACCT\ \ AMT-\ \ \ \ ACCT\ \ [AMT]-\ \ \ \ ...-\f[]-.fi-.PP-These posting rules look like normal postings, except the amount can be:-.IP \[bu] 2-a normal amount with a commodity symbol, eg \f[C]$2\f[].-This will be used as\-is.-.IP \[bu] 2-a number, eg \f[C]2\f[].-The commodity symbol (if any) from the matched posting will be added to-this.-.IP \[bu] 2-a numeric multiplier, eg \f[C]*2\f[] (a star followed by a number N).-The matched posting\[aq]s amount (and total price, if any) will be-multiplied by N.-.IP \[bu] 2-a multiplier with a commodity symbol, eg \f[C]*$2\f[] (a star, number N,-and symbol S).-The matched posting\[aq]s amount will be multiplied by N, and its-commodity symbol will be replaced with S.-.PP-Some examples:-.IP-.nf-\f[C]-;\ every\ time\ I\ buy\ food,\ schedule\ a\ dollar\ donation-=\ expenses:food-\ \ \ \ (liabilities:charity)\ \ \ $\-1--;\ when\ I\ buy\ a\ gift,\ also\ deduct\ that\ amount\ from\ a\ budget\ envelope\ subaccount-=\ expenses:gifts-\ \ \ \ assets:checking:gifts\ \ *\-1-\ \ \ \ assets:checking\ \ \ \ \ \ \ \ \ *1--2017/12/1-\ \ expenses:food\ \ \ \ $10-\ \ assets:checking--2017/12/14-\ \ expenses:gifts\ \ \ $20-\ \ assets:checking-\f[]-.fi-.IP-.nf-\f[C]-$\ hledger\ print\ \-\-auto-2017/12/01-\ \ \ \ expenses:food\ \ \ \ \ \ \ \ \ \ \ \ \ \ $10-\ \ \ \ assets:checking-\ \ \ \ (liabilities:charity)\ \ \ \ \ \ $\-1--2017/12/14-\ \ \ \ expenses:gifts\ \ \ \ \ \ \ \ \ \ \ \ \ $20-\ \ \ \ assets:checking-\ \ \ \ assets:checking:gifts\ \ \ \ \ \-$20-\ \ \ \ assets:checking\ \ \ \ \ \ \ \ \ \ \ \ $20-\f[]-.fi-.SS Auto postings and transaction balancing / inferred amounts / balance-assertions-.PP-Currently, transaction modifiers are applied / auto postings are added:-.IP \[bu] 2-after missing amounts are inferred, and transactions are checked for-balancedness,-.IP \[bu] 2-but before balance assertions are checked.-.PP-Note this means that journal entries must be balanced both before and-after auto postings are added.-This changed in hledger 1.12+; see #893 for background.-.SH EDITOR SUPPORT-.PP-Helper modes exist for popular text editors, which make working with-journal files easier.-They add colour, formatting, tab completion, and helpful commands, and-are quite recommended if you edit your journal with a text editor.-They include ledger\-mode or hledger\-mode for Emacs, vim\-ledger for-Vim, hledger\-vscode for Visual Studio Code, and others.+.TH "hledger_journal" "5" "August 2019" "hledger 1.15" "hledger User Manuals"++++.SH NAME+.PP+Journal - hledger\[aq]s default file format, representing a General+Journal+.SH DESCRIPTION+.PP+hledger\[aq]s usual data source is a plain text file containing journal+entries in hledger journal format.+This file represents a standard accounting general journal.+I use file names ending in \f[C].journal\f[R], but that\[aq]s not+required.+The journal file contains a number of transaction entries, each+describing a transfer of money (or any commodity) between two or more+named accounts, in a simple format readable by both hledger and humans.+.PP+hledger\[aq]s journal format is a compatible subset, mostly, of+ledger\[aq]s journal format, so hledger can work with compatible ledger+journal files as well.+It\[aq]s safe, and encouraged, to run both hledger and ledger on the+same journal file, eg to validate the results you\[aq]re getting.+.PP+You can use hledger without learning any more about this file; just use+the add or web commands to create and update it.+Many users, though, also edit the journal file directly with a text+editor, perhaps assisted by the helper modes for emacs or vim.+.PP+Here\[aq]s an example:+.IP+.nf+\f[C]+; A sample journal file. This is a comment.++2008/01/01 income             ; <- transaction\[aq]s first line starts in column 0, contains date and description+    assets:bank:checking  $1  ; <- posting lines start with whitespace, each contains an account name+    income:salary        $-1  ;    followed by at least two spaces and an amount++2008/06/01 gift+    assets:bank:checking  $1  ; <- at least two postings in a transaction+    income:gifts         $-1  ; <- their amounts must balance to 0++2008/06/02 save+    assets:bank:saving    $1+    assets:bank:checking      ; <- one amount may be omitted; here $-1 is inferred++2008/06/03 eat & shop         ; <- description can be anything+    expenses:food         $1+    expenses:supplies     $1  ; <- this transaction debits two expense accounts+    assets:cash               ; <- $-2 inferred++2008/10/01 take a loan+    assets:bank:checking  $1+    liabilities:debts    $-1++2008/12/31 * pay off          ; <- an optional * or ! after the date means \[dq]cleared\[dq] (or anything you want)+    liabilities:debts     $1+    assets:bank:checking+\f[R]+.fi+.SH FILE FORMAT+.SS Transactions+.PP+Transactions are movements of some quantity of commodities between named+accounts.+Each transaction is represented by a journal entry beginning with a+simple date in column 0.+This can be followed by any of the following, separated by spaces:+.IP \[bu] 2+(optional) a status character (empty, \f[C]!\f[R], or \f[C]*\f[R])+.IP \[bu] 2+(optional) a transaction code (any short number or text, enclosed in+parentheses)+.IP \[bu] 2+(optional) a transaction description (any remaining text until end of+line or a semicolon)+.IP \[bu] 2+(optional) a transaction comment (any remaining text following a+semicolon until end of line)+.PP+Then comes zero or more (but usually at least 2) indented lines+representing...+.SS Postings+.PP+A posting is an addition of some amount to, or removal of some amount+from, an account.+Each posting line begins with at least one space or tab (2 or 4 spaces+is common), followed by:+.IP \[bu] 2+(optional) a status character (empty, \f[C]!\f[R], or \f[C]*\f[R]),+followed by a space+.IP \[bu] 2+(required) an account name (any text, optionally containing \f[B]single+spaces\f[R], until end of line or a double space)+.IP \[bu] 2+(optional) \f[B]two or more spaces\f[R] or tabs followed by an amount.+.PP+Positive amounts are being added to the account, negative amounts are+being removed.+.PP+The amounts within a transaction must always sum up to zero.+As a convenience, one amount may be left blank; it will be inferred so+as to balance the transaction.+.PP+Be sure to note the unusual two-space delimiter between account name and+amount.+This makes it easy to write account names containing spaces.+But if you accidentally leave only one space (or tab) before the amount,+the amount will be considered part of the account name.+.SS Dates+.SS Simple dates+.PP+Within a journal file, transaction dates use Y/M/D (or Y-M-D or Y.M.D)+Leading zeros are optional.+The year may be omitted, in which case it will be inferred from the+context - the current transaction, the default year set with a default+year directive, or the current date when the command is run.+Some examples: \f[C]2010/01/31\f[R], \f[C]1/31\f[R],+\f[C]2010-01-31\f[R], \f[C]2010.1.31\f[R].+.SS Secondary dates+.PP+Real-life transactions sometimes involve more than one date - eg the+date you write a cheque, and the date it clears in your bank.+When you want to model this, eg for more accurate balances, you can+specify individual posting dates, which I recommend.+Or, you can use the secondary dates (aka auxiliary/effective dates)+feature, supported for compatibility with Ledger.+.PP+A secondary date can be written after the primary date, separated by an+equals sign.+The primary date, on the left, is used by default; the secondary date,+on the right, is used when the \f[C]--date2\f[R] flag is specified+(\f[C]--aux-date\f[R] or \f[C]--effective\f[R] also work).+.PP+The meaning of secondary dates is up to you, but it\[aq]s best to follow+a consistent rule.+Eg write the bank\[aq]s clearing date as primary, and when needed, the+date the transaction was initiated as secondary.+.PP+Here\[aq]s an example.+Note that a secondary date will use the year of the primary date if+unspecified.+.IP+.nf+\f[C]+2010/2/23=2/19 movie ticket+  expenses:cinema                   $10+  assets:checking+\f[R]+.fi+.IP+.nf+\f[C]+$ hledger register checking+2010/02/23 movie ticket         assets:checking                $-10         $-10+\f[R]+.fi+.IP+.nf+\f[C]+$ hledger register checking --date2+2010/02/19 movie ticket         assets:checking                $-10         $-10+\f[R]+.fi+.PP+Secondary dates require some effort; you must use them consistently in+your journal entries and remember whether to use or not use the+\f[C]--date2\f[R] flag for your reports.+They are included in hledger for Ledger compatibility, but posting dates+are a more powerful and less confusing alternative.+.SS Posting dates+.PP+You can give individual postings a different date from their parent+transaction, by adding a posting comment containing a tag (see below)+like \f[C]date:DATE\f[R].+This is probably the best way to control posting dates precisely.+Eg in this example the expense should appear in May reports, and the+deduction from checking should be reported on 6/1 for easy bank+reconciliation:+.IP+.nf+\f[C]+2015/5/30+    expenses:food     $10  ; food purchased on saturday 5/30+    assets:checking        ; bank cleared it on monday, date:6/1+\f[R]+.fi+.IP+.nf+\f[C]+$ hledger -f t.j register food+2015/05/30                      expenses:food                  $10           $10+\f[R]+.fi+.IP+.nf+\f[C]+$ hledger -f t.j register checking+2015/06/01                      assets:checking               $-10          $-10+\f[R]+.fi+.PP+DATE should be a simple date; if the year is not specified it will use+the year of the transaction\[aq]s date.+You can set the secondary date similarly, with \f[C]date2:DATE2\f[R].+The \f[C]date:\f[R] or \f[C]date2:\f[R] tags must have a valid simple+date value if they are present, eg a \f[C]date:\f[R] tag with no value+is not allowed.+.PP+Ledger\[aq]s earlier, more compact bracketed date syntax is also+supported: \f[C][DATE]\f[R], \f[C][DATE=DATE2]\f[R] or+\f[C][=DATE2]\f[R].+hledger will attempt to parse any square-bracketed sequence of the+\f[C]0123456789/-.=\f[R] characters in this way.+With this syntax, DATE infers its year from the transaction and DATE2+infers its year from DATE.+.SS Status+.PP+Transactions, or individual postings within a transaction, can have a+status mark, which is a single character before the transaction+description or posting account name, separated from it by a space,+indicating one of three statuses:+.PP+.TS+tab(@);+l l.+T{+mark \ +T}@T{+status+T}+_+T{+\ +T}@T{+unmarked+T}+T{+\f[C]!\f[R]+T}@T{+pending+T}+T{+\f[C]*\f[R]+T}@T{+cleared+T}+.TE+.PP+When reporting, you can filter by status with the+\f[C]-U/--unmarked\f[R], \f[C]-P/--pending\f[R], and+\f[C]-C/--cleared\f[R] flags; or the \f[C]status:\f[R],+\f[C]status:!\f[R], and \f[C]status:*\f[R] queries; or the U, P, C keys+in hledger-ui.+.PP+Note, in Ledger and in older versions of hledger, the \[dq]unmarked\[dq]+state is called \[dq]uncleared\[dq].+As of hledger 1.3 we have renamed it to unmarked for clarity.+.PP+To replicate Ledger and old hledger\[aq]s behaviour of also matching+pending, combine -U and -P.+.PP+Status marks are optional, but can be helpful eg for reconciling with+real-world accounts.+Some editor modes provide highlighting and shortcuts for working with+status.+Eg in Emacs ledger-mode, you can toggle transaction status with C-c C-e,+or posting status with C-c C-c.+.PP+What \[dq]uncleared\[dq], \[dq]pending\[dq], and \[dq]cleared\[dq]+actually mean is up to you.+Here\[aq]s one suggestion:+.PP+.TS+tab(@);+lw(9.9n) lw(60.1n).+T{+status+T}@T{+meaning+T}+_+T{+uncleared+T}@T{+recorded but not yet reconciled; needs review+T}+T{+pending+T}@T{+tentatively reconciled (if needed, eg during a big reconciliation)+T}+T{+cleared+T}@T{+complete, reconciled as far as possible, and considered correct+T}+.TE+.PP+With this scheme, you would use \f[C]-PC\f[R] to see the current balance+at your bank, \f[C]-U\f[R] to see things which will probably hit your+bank soon (like uncashed checks), and no flags to see the most+up-to-date state of your finances.+.SS Description+.PP+A transaction\[aq]s description is the rest of the line following the+date and status mark (or until a comment begins).+Sometimes called the \[dq]narration\[dq] in traditional bookkeeping, it+can be used for whatever you wish, or left blank.+Transaction descriptions can be queried, unlike comments.+.SS Payee and note+.PP+You can optionally include a \f[C]|\f[R] (pipe) character in+descriptions to subdivide the description into separate fields for+payee/payer name on the left (up to the first \f[C]|\f[R]) and an+additional note field on the right (after the first \f[C]|\f[R]).+This may be worthwhile if you need to do more precise querying and+pivoting by payee or by note.+.SS Account names+.PP+Account names typically have several parts separated by a full colon,+from which hledger derives a hierarchical chart of accounts.+They can be anything you like, but in finance there are traditionally+five top-level accounts: \f[C]assets\f[R], \f[C]liabilities\f[R],+\f[C]income\f[R], \f[C]expenses\f[R], and \f[C]equity\f[R].+.PP+Account names may contain single spaces, eg:+\f[C]assets:accounts receivable\f[R].+Because of this, they must always be followed by \f[B]two or more+spaces\f[R] (or newline).+.PP+Account names can be aliased.+.SS Amounts+.PP+After the account name, there is usually an amount.+Important: between account name and amount, there must be \f[B]two or+more spaces\f[R].+.PP+Amounts consist of a number and (usually) a currency symbol or commodity+name.+Some examples:+.PP+\f[C]2.00001\f[R]+.PD 0+.P+.PD+\f[C]$1\f[R]+.PD 0+.P+.PD+\f[C]4000 AAPL\f[R]+.PD 0+.P+.PD+\f[C]3 \[dq]green apples\[dq]\f[R]+.PD 0+.P+.PD+\f[C]-$1,000,000.00\f[R]+.PD 0+.P+.PD+\f[C]INR 9,99,99,999.00\f[R]+.PD 0+.P+.PD+\f[C]EUR -2.000.000,00\f[R]+.PD 0+.P+.PD+\f[C]1 999 999.9455\f[R]+.PD 0+.P+.PD+\f[C]EUR 1E3\f[R]+.PD 0+.P+.PD+\f[C]1000E-6s\f[R]+.PP+As you can see, the amount format is somewhat flexible:+.IP \[bu] 2+amounts are a number (the \[dq]quantity\[dq]) and optionally a currency+symbol/commodity name (the \[dq]commodity\[dq]).+.IP \[bu] 2+the commodity is a symbol, word, or phrase, on the left or right, with+or without a separating space.+If the commodity contains numbers, spaces or non-word punctuation it+must be enclosed in double quotes.+.IP \[bu] 2+negative amounts with a commodity on the left can have the minus sign+before or after it+.IP \[bu] 2+digit groups (thousands, or any other grouping) can be separated by+space or comma or period and should be used as separator between all+groups+.IP \[bu] 2+decimal part can be separated by comma or period and should be different+from digit groups separator+.IP \[bu] 2+scientific E-notation is allowed.+Be careful not to use a digit group separator character in scientific+notation, as it\[aq]s not supported and it might get mistaken for a+decimal point.+(Declaring the digit group separator character explicitly with a+commodity directive will prevent this.)+.PP+You can use any of these variations when recording data.+However, there is some ambiguous way of representing numbers like+\f[C]$1.000\f[R] and \f[C]$1,000\f[R] both may mean either one thousand+or one dollar.+By default hledger will assume that this is sole delimiter is used only+for decimals.+On the other hand commodity format declared prior to that line will help+to resolve that ambiguity differently:+.IP+.nf+\f[C]+commodity $1,000.00++2017/12/25 New life of Scrooge+    expenses:gifts  $1,000+    assets+\f[R]+.fi+.PP+Though journal may contain mixed styles to represent amount, when+hledger displays amounts, it will choose a consistent format for each+commodity.+(Except for price amounts, which are always formatted as written).+The display format is chosen as follows:+.IP \[bu] 2+if there is a commodity directive specifying the format, that is used+.IP \[bu] 2+otherwise the format is inferred from the first posting amount in that+commodity in the journal, and the precision (number of decimal places)+will be the maximum from all posting amounts in that commmodity+.IP \[bu] 2+or if there are no such amounts in the journal, a default format is used+(like \f[C]$1000.00\f[R]).+.PP+Price amounts and amounts in \f[C]D\f[R] directives usually don\[aq]t+affect amount format inference, but in some situations they can do so+indirectly.+(Eg when D\[aq]s default commodity is applied to a commodity-less+amount, or when an amountless posting is balanced using a price\[aq]s+commodity, or when -V is used.) If you find this causing problems, set+the desired format with a commodity directive.+.SS Virtual Postings+.PP+When you parenthesise the account name in a posting, we call that a+\f[I]virtual posting\f[R], which means:+.IP \[bu] 2+it is ignored when checking that the transaction is balanced+.IP \[bu] 2+it is excluded from reports when the \f[C]--real/-R\f[R] flag is used,+or the \f[C]real:1\f[R] query.+.PP+You could use this, eg, to set an account\[aq]s opening balance without+needing to use the \f[C]equity:opening balances\f[R] account:+.IP+.nf+\f[C]+1/1 special unbalanced posting to set initial balance+  (assets:checking)   $1000+\f[R]+.fi+.PP+When the account name is bracketed, we call it a \f[I]balanced virtual+posting\f[R].+This is like an ordinary virtual posting except the balanced virtual+postings in a transaction must balance to 0, like the real postings (but+separately from them).+Balanced virtual postings are also excluded by \f[C]--real/-R\f[R] or+\f[C]real:1\f[R].+.IP+.nf+\f[C]+1/1 buy food with cash, and update some budget-tracking subaccounts elsewhere+  expenses:food                   $10+  assets:cash                    $-10+  [assets:checking:available]     $10+  [assets:checking:budget:food]  $-10+\f[R]+.fi+.PP+Virtual postings have some legitimate uses, but those are few.+You can usually find an equivalent journal entry using real postings,+which is more correct and provides better error checking.+.SS Balance Assertions+.PP+hledger supports Ledger-style balance assertions in journal files.+These look like, for example, \f[C]= EXPECTEDBALANCE\f[R] following a+posting\[aq]s amount.+Eg here we assert the expected dollar balance in accounts a and b after+each posting:+.IP+.nf+\f[C]+2013/1/1+  a   $1  =$1+  b       =$-1++2013/1/2+  a   $1  =$2+  b  $-1  =$-2+\f[R]+.fi+.PP+After reading a journal file, hledger will check all balance assertions+and report an error if any of them fail.+Balance assertions can protect you from, eg, inadvertently disrupting+reconciled balances while cleaning up old entries.+You can disable them temporarily with the+\f[C]-I/--ignore-assertions\f[R] flag, which can be useful for+troubleshooting or for reading Ledger files.+.SS Assertions and ordering+.PP+hledger sorts an account\[aq]s postings and assertions first by date and+then (for postings on the same day) by parse order.+Note this is different from Ledger, which sorts assertions only by parse+order.+(Also, Ledger assertions do not see the accumulated effect of repeated+postings to the same account within a transaction.)+.PP+So, hledger balance assertions keep working if you reorder+differently-dated transactions within the journal.+But if you reorder same-dated transactions or postings, assertions might+break and require updating.+This order dependence does bring an advantage: precise control over the+order of postings and assertions within a day, so you can assert+intra-day balances.+.SS Assertions and included files+.PP+With included files, things are a little more complicated.+Including preserves the ordering of postings and assertions.+If you have multiple postings to an account on the same day, split+across different files, and you also want to assert the account\[aq]s+balance on the same day, you\[aq]ll have to put the assertion in the+right file.+.SS Assertions and multiple -f options+.PP+Balance assertions don\[aq]t work well across files specified with+multiple -f options.+Use include or concatenate the files instead.+.SS Assertions and commodities+.PP+The asserted balance must be a simple single-commodity amount, and in+fact the assertion checks only this commodity\[aq]s balance within the+(possibly multi-commodity) account balance.+.PD 0+.P+.PD+This is how assertions work in Ledger also.+We could call this a \[dq]partial\[dq] balance assertion.+.PP+To assert the balance of more than one commodity in an account, you can+write multiple postings, each asserting one commodity\[aq]s balance.+.PP+You can make a stronger \[dq]total\[dq] balance assertion by writing a+double equals sign (\f[C]== EXPECTEDBALANCE\f[R]).+This asserts that there are no other unasserted commodities in the+account (or, that their balance is 0).+.IP+.nf+\f[C]+2013/1/1+  a   $1+  a    1\[Eu]+  b  $-1+  c   -1\[Eu]++2013/1/2  ; These assertions succeed+  a    0  =  $1+  a    0  =   1\[Eu]+  b    0 == $-1+  c    0 ==  -1\[Eu]++2013/1/3  ; This assertion fails as \[aq]a\[aq] also contains 1\[Eu]+  a    0 ==  $1+\f[R]+.fi+.PP+It\[aq]s not yet possible to make a complete assertion about a balance+that has multiple commodities.+One workaround is to isolate each commodity into its own subaccount:+.IP+.nf+\f[C]+2013/1/1+  a:usd   $1+  a:euro   1\[Eu]+  b++2013/1/2+  a        0 ==  0+  a:usd    0 == $1+  a:euro   0 ==  1\[Eu]+\f[R]+.fi+.SS Assertions and prices+.PP+Balance assertions ignore transaction prices, and should normally be+written without one:+.IP+.nf+\f[C]+2019/1/1+  (a)     $1 \[at] \[Eu]1 = $1+\f[R]+.fi+.PP+We do allow prices to be written there, however, and print shows them,+even though they don\[aq]t affect whether the assertion passes or fails.+This is for backward compatibility (hledger\[aq]s close command used to+generate balance assertions with prices), and because balance+\f[I]assignments\f[R] do use them (see below).+.SS Assertions and subaccounts+.PP+The balance assertions above (\f[C]=\f[R] and \f[C]==\f[R]) do not count+the balance from subaccounts; they check the account\[aq]s exclusive+balance only.+You can assert the balance including subaccounts by writing \f[C]=*\f[R]+or \f[C]==*\f[R], eg:+.IP+.nf+\f[C]+2019/1/1+  equity:opening balances+  checking:a       5+  checking:b       5+  checking         1  ==* 11+\f[R]+.fi+.SS Assertions and virtual postings+.PP+Balance assertions are checked against all postings, both real and+virtual.+They are not affected by the \f[C]--real/-R\f[R] flag or \f[C]real:\f[R]+query.+.SS Assertions and precision+.PP+Balance assertions compare the exactly calculated amounts, which are not+always what is shown by reports.+Eg a commodity directive may limit the display precision, but this will+not affect balance assertions.+Balance assertion failure messages show exact amounts.+.SS Balance Assignments+.PP+Ledger-style balance assignments are also supported.+These are like balance assertions, but with no posting amount on the+left side of the equals sign; instead it is calculated automatically so+as to satisfy the assertion.+This can be a convenience during data entry, eg when setting opening+balances:+.IP+.nf+\f[C]+; starting a new journal, set asset account balances +2016/1/1 opening balances+  assets:checking            = $409.32+  assets:savings             = $735.24+  assets:cash                 = $42+  equity:opening balances+\f[R]+.fi+.PP+or when adjusting a balance to reality:+.IP+.nf+\f[C]+; no cash left; update balance, record any untracked spending as a generic expense+2016/1/15+  assets:cash    = $0+  expenses:misc+\f[R]+.fi+.PP+The calculated amount depends on the account\[aq]s balance in the+commodity at that point (which depends on the previously-dated postings+of the commodity to that account since the last balance assertion or+assignment).+Note that using balance assignments makes your journal a little less+explicit; to know the exact amount posted, you have to run hledger or do+the calculations yourself, instead of just reading it.+.SS Balance assignments and prices+.PP+A transaction price in a balance assignment will cause the calculated+amount to have that price attached:+.IP+.nf+\f[C]+2019/1/1+  (a)             = $1 \[at] \[Eu]2+\f[R]+.fi+.IP+.nf+\f[C]+$ hledger print --explicit+2019/01/01+    (a)         $1 \[at] \[Eu]2 = $1 \[at] \[Eu]2+\f[R]+.fi+.SS Transaction prices+.PP+Within a transaction, you can note an amount\[aq]s price in another+commodity.+This can be used to document the cost (in a purchase) or selling price+(in a sale).+For example, transaction prices are useful to record purchases of a+foreign currency.+Note transaction prices are fixed at the time of the transaction, and do+not change over time.+See also market prices, which represent prevailing exchange rates on a+certain date.+.PP+There are several ways to record a transaction price:+.IP "1." 3+Write the price per unit, as \f[C]\[at] UNITPRICE\f[R] after the amount:+.RS 4+.IP+.nf+\f[C]+2009/1/1+  assets:euros     \[Eu]100 \[at] $1.35  ; one hundred euros purchased at $1.35 each+  assets:dollars                 ; balancing amount is -$135.00+\f[R]+.fi+.RE+.IP "2." 3+Write the total price, as \f[C]\[at]\[at] TOTALPRICE\f[R] after the+amount:+.RS 4+.IP+.nf+\f[C]+2009/1/1+  assets:euros     \[Eu]100 \[at]\[at] $135  ; one hundred euros purchased at $135 for the lot+  assets:dollars+\f[R]+.fi+.RE+.IP "3." 3+Specify amounts for all postings, using exactly two commodities, and let+hledger infer the price that balances the transaction:+.RS 4+.IP+.nf+\f[C]+2009/1/1+  assets:euros     \[Eu]100          ; one hundred euros purchased+  assets:dollars  $-135          ; for $135+\f[R]+.fi+.RE+.PP+(Ledger users: Ledger uses a different syntax for fixed prices,+\f[C]{=UNITPRICE}\f[R], which hledger currently ignores).+.PP+Use the \f[C]-B/--cost\f[R] flag to convert amounts to their transaction+price\[aq]s commodity, if any.+(mnemonic: \[dq]B\[dq] is from \[dq]cost Basis\[dq], as in Ledger).+Eg here is how -B affects the balance report for the example above:+.IP+.nf+\f[C]+$ hledger bal -N --flat+               $-135  assets:dollars+                \[Eu]100  assets:euros+$ hledger bal -N --flat -B+               $-135  assets:dollars+                $135  assets:euros    # <- the euros\[aq] cost+\f[R]+.fi+.PP+Note -B is sensitive to the order of postings when a transaction price+is inferred: the inferred price will be in the commodity of the last+amount.+So if example 3\[aq]s postings are reversed, while the transaction is+equivalent, -B shows something different:+.IP+.nf+\f[C]+2009/1/1+  assets:dollars  $-135              ; 135 dollars sold+  assets:euros     \[Eu]100              ; for 100 euros+\f[R]+.fi+.IP+.nf+\f[C]+$ hledger bal -N --flat -B+               \[Eu]-100  assets:dollars  # <- the dollars\[aq] selling price+                \[Eu]100  assets:euros+\f[R]+.fi+.SS Comments+.PP+Lines in the journal beginning with a semicolon (\f[C];\f[R]) or hash+(\f[C]#\f[R]) or star (\f[C]*\f[R]) are comments, and will be ignored.+(Star comments cause org-mode nodes to be ignored, allowing emacs users+to fold and navigate their journals with org-mode or orgstruct-mode.)+.PP+You can attach comments to a transaction by writing them after the+description and/or indented on the following lines (before the+postings).+Similarly, you can attach comments to an individual posting by writing+them after the amount and/or indented on the following lines.+Transaction and posting comments must begin with a semicolon+(\f[C];\f[R]).+.PP+Some examples:+.IP+.nf+\f[C]+# a file comment++; also a file comment++comment+This is a multiline file comment,+which continues until a line+where the \[dq]end comment\[dq] string+appears on its own (or end of file).+end comment++2012/5/14 something  ; a transaction comment+    ; the transaction comment, continued+    posting1  1  ; a comment for posting 1+    posting2+    ; a comment for posting 2+    ; another comment line for posting 2+; a file comment (because not indented)+\f[R]+.fi+.PP+You can also comment larger regions of a file using \f[C]comment\f[R]+and \f[C]end comment\f[R] directives.+.SS Tags+.PP+Tags are a way to add extra labels or labelled data to postings and+transactions, which you can then search or pivot on.+.PP+A simple tag is a word (which may contain hyphens) followed by a full+colon, written inside a transaction or posting comment line:+.IP+.nf+\f[C]+2017/1/16 bought groceries  ; sometag:+\f[R]+.fi+.PP+Tags can have a value, which is the text after the colon, up to the next+comma or end of line, with leading/trailing whitespace removed:+.IP+.nf+\f[C]+    expenses:food    $10 ; a-posting-tag: the tag value+\f[R]+.fi+.PP+Note this means hledger\[aq]s tag values can not contain commas or+newlines.+Ending at commas means you can write multiple short tags on one line,+comma separated:+.IP+.nf+\f[C]+    assets:checking  ; a comment containing tag1:, tag2: some value ...+\f[R]+.fi+.PP+Here,+.IP \[bu] 2+\[dq]\f[C]a comment containing\f[R]\[dq] is just comment text, not a tag+.IP \[bu] 2+\[dq]\f[C]tag1\f[R]\[dq] is a tag with no value+.IP \[bu] 2+\[dq]\f[C]tag2\f[R]\[dq] is another tag, whose value is+\[dq]\f[C]some value ...\f[R]\[dq]+.PP+Tags in a transaction comment affect the transaction and all of its+postings, while tags in a posting comment affect only that posting.+For example, the following transaction has three tags (\f[C]A\f[R],+\f[C]TAG2\f[R], \f[C]third-tag\f[R]) and the posting has four (those+plus \f[C]posting-tag\f[R]):+.IP+.nf+\f[C]+1/1 a transaction  ; A:, TAG2:+    ; third-tag: a third transaction tag, <- with a value+    (a)  $1  ; posting-tag:+\f[R]+.fi+.PP+Tags are like Ledger\[aq]s metadata feature, except hledger\[aq]s tag+values are simple strings.+.SS Directives+.PP+A directive is a line in the journal beginning with a special keyword,+that influences how the journal is processed.+hledger\[aq]s directives are based on a subset of Ledger\[aq]s, but+there are many differences (and also some differences between hledger+versions).+.PP+Directives\[aq] behaviour and interactions can get a little bit complex,+so here is a table summarising the directives and their effects, with+links to more detailed docs.+.PP+.TS+tab(@);+lw(7.8n) lw(8.6n) lw(7.0n) lw(27.8n) lw(18.8n).+T{+directive+T}@T{+end directive+T}@T{+subdirectives+T}@T{+purpose+T}@T{+can affect (as of 2018/06)+T}+_+T{+\f[C]account\f[R]+T}@T{+T}@T{+any text+T}@T{+document account names, declare account types & display order+T}@T{+all entries in all files, before or after+T}+T{+\f[C]alias\f[R]+T}@T{+\f[C]end aliases\f[R]+T}@T{+T}@T{+rewrite account names+T}@T{+following inline/included entries until end of current file or end+directive+T}+T{+\f[C]apply account\f[R]+T}@T{+\f[C]end apply account\f[R]+T}@T{+T}@T{+prepend a common parent to account names+T}@T{+following inline/included entries until end of current file or end+directive+T}+T{+\f[C]comment\f[R]+T}@T{+\f[C]end comment\f[R]+T}@T{+T}@T{+ignore part of journal+T}@T{+following inline/included entries until end of current file or end+directive+T}+T{+\f[C]commodity\f[R]+T}@T{+T}@T{+\f[C]format\f[R]+T}@T{+declare a commodity and its number notation & display style+T}@T{+number notation: following entries in that commodity in all files;+display style: amounts of that commodity in reports+T}+T{+\f[C]D\f[R]+T}@T{+T}@T{+T}@T{+declare a commodity, number notation & display style for commodityless+amounts+T}@T{+commodity: all commodityless entries in all files; number notation:+following commodityless entries and entries in that commodity in all+files; display style: amounts of that commodity in reports+T}+T{+\f[C]include\f[R]+T}@T{+T}@T{+T}@T{+include entries/directives from another file+T}@T{+what the included directives affect+T}+T{+\f[C]P\f[R]+T}@T{+T}@T{+T}@T{+declare a market price for a commodity+T}@T{+amounts of that commodity in reports, when -V is used+T}+T{+\f[C]Y\f[R]+T}@T{+T}@T{+T}@T{+declare a year for yearless dates+T}@T{+following inline/included entries until end of current file+T}+.TE+.PP+And some definitions:+.PP+.TS+tab(@);+lw(8.9n) lw(61.1n).+T{+subdirective+T}@T{+optional indented directive line immediately following a parent+directive+T}+T{+number notation+T}@T{+how to interpret numbers when parsing journal entries (the identity of+the decimal separator character).+(Currently each commodity can have its own notation, even in the same+file.)+T}+T{+display style+T}@T{+how to display amounts of a commodity in reports (symbol side and+spacing, digit groups, decimal separator, decimal places)+T}+T{+directive scope+T}@T{+which entries and (when there are multiple files) which files are+affected by a directive+T}+.TE+.PP+As you can see, directives vary in which journal entries and files they+affect, and whether they are focussed on input (parsing) or output+(reports).+Some directives have multiple effects.+.PP+If you have a journal made up of multiple files, or pass multiple -f+options on the command line, note that directives which affect input+typically last only until the end of their defining file.+This provides more simplicity and predictability, eg reports are not+changed by writing file options in a different order.+It can be surprising at times though.+.SS Comment blocks+.PP+A line containing just \f[C]comment\f[R] starts a commented region of+the file, and a line containing just \f[C]end comment\f[R] (or the end+of the current file) ends it.+See also comments.+.SS Including other files+.PP+You can pull in the content of additional files by writing an include+directive, like this:+.IP+.nf+\f[C]+include path/to/file.journal+\f[R]+.fi+.PP+If the path does not begin with a slash, it is relative to the current+file.+The include file path may contain common glob patterns (e.g.+\f[C]*\f[R]).+.PP+The \f[C]include\f[R] directive can only be used in journal files.+It can include journal, timeclock or timedot files, but not CSV files.+.SS Default year+.PP+You can set a default year to be used for subsequent dates which+don\[aq]t specify a year.+This is a line beginning with \f[C]Y\f[R] followed by the year.+Eg:+.IP+.nf+\f[C]+Y2009  ; set default year to 2009++12/15  ; equivalent to 2009/12/15+  expenses  1+  assets++Y2010  ; change default year to 2010++2009/1/30  ; specifies the year, not affected+  expenses  1+  assets++1/31   ; equivalent to 2010/1/31+  expenses  1+  assets+\f[R]+.fi+.SS Declaring commodities+.PP+The \f[C]commodity\f[R] directive declares commodities which may be used+in the journal, and their display format.+.PP+It may be written on a single line, like this:+.IP+.nf+\f[C]+; commodity EXAMPLEAMOUNT++; display AAAA amounts with the symbol on the right, space-separated,+; using period as decimal point, with four decimal places, and+; separating thousands with comma.+commodity 1,000.0000 AAAA+\f[R]+.fi+.PP+or on multiple lines, using the \[dq]format\[dq] subdirective.+In this case the commodity symbol appears twice and should be the same+in both places:+.IP+.nf+\f[C]+; commodity SYMBOL+;   format EXAMPLEAMOUNT++; display indian rupees with currency name on the left,+; thousands, lakhs and crores comma-separated,+; period as decimal point, and two decimal places.+commodity INR+  format INR 9,99,99,999.00+\f[R]+.fi+.PP+Declaring commodites may be useful as documentation, but currently we do+not enforce that only declared commodities may be used.+This directive is mainly useful for customising the preferred display+format for a commodity.+.PP+Normally the display format is inferred from journal entries, but this+can be unpredictable; declaring it with a commodity directive overrides+this and removes ambiguity.+Towards this end, amounts in commodity directives must always be written+with a decimal point (a period or comma, followed by 0 or more decimal+digits).+.PP+Commodity directives do not affect how amounts are parsed; the parser+will read multiple formats.+.SS Default commodity+.PP+The \f[C]D\f[R] directive sets a default commodity (and display format),+to be used for amounts without a commodity symbol (ie, plain numbers).+(Note this differs from Ledger\[aq]s default commodity directive.) The+commodity and display format will be applied to all subsequent+commodity-less amounts, or until the next \f[C]D\f[R] directive.+.IP+.nf+\f[C]+# commodity-less amounts should be treated as dollars+# (and displayed with symbol on the left, thousands separators and two decimal places)+D $1,000.00++1/1+  a     5  ; <- commodity-less amount, becomes $1+  b+\f[R]+.fi+.PP+As with the \f[C]commodity\f[R] directive, the amount must always be+written with a decimal point.+.SS Market prices+.PP+The \f[C]P\f[R] directive declares a market price, which is an exchange+rate between two commodities on a certain date.+(In Ledger, they are called \[dq]historical prices\[dq].) These are+often obtained from a stock exchange, cryptocurrency exchange, or the+foreign exchange market.+.PP+Here is the format:+.IP+.nf+\f[C]+P DATE COMMODITYA COMMODITYBAMOUNT+\f[R]+.fi+.IP \[bu] 2+DATE is a simple date+.IP \[bu] 2+COMMODITYA is the symbol of the commodity being priced+.IP \[bu] 2+COMMODITYBAMOUNT is an amount (symbol and quantity) in a second+commodity, giving the price in commodity B of one unit of commodity A.+.PP+These two market price directives say that one euro was worth 1.35 US+dollars during 2009, and $1.40 from 2010 onward:+.IP+.nf+\f[C]+P 2009/1/1 \[Eu] $1.35+P 2010/1/1 \[Eu] $1.40+\f[R]+.fi+.PP+The \f[C]-V/--value\f[R] flag can be used to convert reported amounts to+another commodity using these prices.+.SS Declaring accounts+.PP+\f[C]account\f[R] directives can be used to pre-declare accounts.+Though not required, they can provide several benefits:+.IP \[bu] 2+They can document your intended chart of accounts, providing a+reference.+.IP \[bu] 2+They can store extra information about accounts (account numbers, notes,+etc.)+.IP \[bu] 2+They can help hledger know your accounts\[aq] types (asset, liability,+equity, revenue, expense), useful for reports like balancesheet and+incomestatement.+.IP \[bu] 2+They control account display order in reports, allowing non-alphabetic+sorting (eg Revenues to appear above Expenses).+.IP \[bu] 2+They help with account name completion in the add command, hledger-iadd,+hledger-web, ledger-mode etc.+.PP+The simplest form is just the word \f[C]account\f[R] followed by a+hledger-style account name, eg:+.IP+.nf+\f[C]+account assets:bank:checking+\f[R]+.fi+.SS Account comments+.PP+Comments, beginning with a semicolon, optionally including tags, can be+written after the account name, and/or on following lines.+Eg:+.IP+.nf+\f[C]+account assets:bank:checking  ; a comment+  ; another comment+  ; acctno:12345, a tag+\f[R]+.fi+.PP+Tip: comments on the same line require hledger 1.12+.+If you need your journal to be compatible with older hledger versions,+write comments on the next line instead.+.SS Account subdirectives+.PP+We also allow (and ignore) Ledger-style indented subdirectives, just for+compatibility.:+.IP+.nf+\f[C]+account assets:bank:checking+  format blah blah  ; <- subdirective, ignored+\f[R]+.fi+.PP+Here is the full syntax of account directives:+.IP+.nf+\f[C]+account ACCTNAME  [ACCTTYPE] [;COMMENT]+  [;COMMENTS]+  [LEDGER-STYLE SUBDIRECTIVES, IGNORED]+\f[R]+.fi+.SS Account types+.PP+hledger recognises five types (or classes) of account: Asset, Liability,+Equity, Revenue, Expense.+This is used by a few accounting-aware reports such as balancesheet,+incomestatement and cashflow.+.SS Auto-detected account types+.PP+If you name your top-level accounts with some variation of+\f[C]assets\f[R], \f[C]liabilities\f[R]/\f[C]debts\f[R],+\f[C]equity\f[R], \f[C]revenues\f[R]/\f[C]income\f[R], or+\f[C]expenses\f[R], their types are detected automatically.+.SS Account types declared with tags+.PP+More generally, you can declare an account\[aq]s type with an account+directive, by writing a \f[C]type:\f[R] tag in a comment, followed by+one of the words \f[C]Asset\f[R], \f[C]Liability\f[R], \f[C]Equity\f[R],+\f[C]Revenue\f[R], \f[C]Expense\f[R], or one of the letters+\f[C]ALERX\f[R] (case insensitive):+.IP+.nf+\f[C]+account assets       ; type:Asset+account liabilities  ; type:Liability+account equity       ; type:Equity+account revenues     ; type:Revenue+account expenses     ; type:Expenses+\f[R]+.fi+.SS Account types declared with account type codes+.PP+Or, you can write one of those letters separated from the account name+by two or more spaces, but this should probably be considered deprecated+as of hledger 1.13:+.IP+.nf+\f[C]+account assets       A+account liabilities  L+account equity       E+account revenues     R+account expenses     X+\f[R]+.fi+.SS Overriding auto-detected types+.PP+If you ever override the types of those auto-detected english account+names mentioned above, you might need to help the reports a bit.+Eg:+.IP+.nf+\f[C]+; make \[dq]liabilities\[dq] not have the liability type - who knows why+account liabilities  ; type:E++; we need to ensure some other account has the liability type, +; otherwise balancesheet would still show \[dq]liabilities\[dq] under Liabilities +account -            ; type:L+\f[R]+.fi+.SS Account display order+.PP+Account directives also set the order in which accounts are displayed,+eg in reports, the hledger-ui accounts screen, and the hledger-web+sidebar.+By default accounts are listed in alphabetical order.+But if you have these account directives in the journal:+.IP+.nf+\f[C]+account assets+account liabilities+account equity+account revenues+account expenses+\f[R]+.fi+.PP+you\[aq]ll see those accounts displayed in declaration order, not+alphabetically:+.IP+.nf+\f[C]+$ hledger accounts -1+assets+liabilities+equity+revenues+expenses+\f[R]+.fi+.PP+Undeclared accounts, if any, are displayed last, in alphabetical order.+.PP+Note that sorting is done at each level of the account tree (within each+group of sibling accounts under the same parent).+And currently, this directive:+.IP+.nf+\f[C]+account other:zoo+\f[R]+.fi+.PP+would influence the position of \f[C]zoo\f[R] among+\f[C]other\f[R]\[aq]s subaccounts, but not the position of+\f[C]other\f[R] among the top-level accounts.+This means: - you will sometimes declare parent accounts (eg+\f[C]account other\f[R] above) that you don\[aq]t intend to post to,+just to customize their display order - sibling accounts stay together+(you couldn\[aq]t display \f[C]x:y\f[R] in between \f[C]a:b\f[R] and+\f[C]a:c\f[R]).+.SS Rewriting accounts+.PP+You can define account alias rules which rewrite your account names, or+parts of them, before generating reports.+This can be useful for:+.IP \[bu] 2+expanding shorthand account names to their full form, allowing easier+data entry and a less verbose journal+.IP \[bu] 2+adapting old journals to your current chart of accounts+.IP \[bu] 2+experimenting with new account organisations, like a new hierarchy or+combining two accounts into one+.IP \[bu] 2+customising reports+.PP+Account aliases also rewrite account names in account directives.+They do not affect account names being entered via hledger add or+hledger-web.+.PP+See also Cookbook: Rewrite account names.+.SS Basic aliases+.PP+To set an account alias, use the \f[C]alias\f[R] directive in your+journal file.+This affects all subsequent journal entries in the current file or its+included files.+The spaces around the = are optional:+.IP+.nf+\f[C]+alias OLD = NEW+\f[R]+.fi+.PP+Or, you can use the \f[C]--alias \[aq]OLD=NEW\[aq]\f[R] option on the+command line.+This affects all entries.+It\[aq]s useful for trying out aliases interactively.+.PP+OLD and NEW are case sensitive full account names.+hledger will replace any occurrence of the old account name with the new+one.+Subaccounts are also affected.+Eg:+.IP+.nf+\f[C]+alias checking = assets:bank:wells fargo:checking+# rewrites \[dq]checking\[dq] to \[dq]assets:bank:wells fargo:checking\[dq], or \[dq]checking:a\[dq] to \[dq]assets:bank:wells fargo:checking:a\[dq]+\f[R]+.fi+.SS Regex aliases+.PP+There is also a more powerful variant that uses a regular expression,+indicated by the forward slashes:+.IP+.nf+\f[C]+alias /REGEX/ = REPLACEMENT+\f[R]+.fi+.PP+or \f[C]--alias \[aq]/REGEX/=REPLACEMENT\[aq]\f[R].+.PP+REGEX is a case-insensitive regular expression.+Anywhere it matches inside an account name, the matched part will be+replaced by REPLACEMENT.+If REGEX contains parenthesised match groups, these can be referenced by+the usual numeric backreferences in REPLACEMENT.+Eg:+.IP+.nf+\f[C]+alias /\[ha](.+):bank:([\[ha]:]+)(.*)/ = \[rs]1:\[rs]2 \[rs]3+# rewrites \[dq]assets:bank:wells fargo:checking\[dq] to  \[dq]assets:wells fargo checking\[dq]+\f[R]+.fi+.PP+Also note that REPLACEMENT continues to the end of line (or on command+line, to end of option argument), so it can contain trailing whitespace.+.SS Combining aliases+.PP+You can define as many aliases as you like, using journal directives+and/or command line options.+.PP+Recursive aliases - where an account name is rewritten by one alias,+then by another alias, and so on - are allowed.+Each alias sees the effect of previously applied aliases.+.PP+In such cases it can be important to understand which aliases will be+applied and in which order.+For (each account name in) each journal entry, we apply:+.IP "1." 3+\f[C]alias\f[R] directives preceding the journal entry, most recently+parsed first (ie, reading upward from the journal entry, bottom to top)+.IP "2." 3+\f[C]--alias\f[R] options, in the order they appeared on the command+line (left to right).+.PP+In other words, for (an account name in) a given journal entry:+.IP \[bu] 2+the nearest alias declaration before/above the entry is applied first+.IP \[bu] 2+the next alias before/above that will be be applied next, and so on+.IP \[bu] 2+aliases defined after/below the entry do not affect it.+.PP+This gives nearby aliases precedence over distant ones, and helps+provide semantic stability - aliases will keep working the same way+independent of which files are being read and in which order.+.PP+In case of trouble, adding \f[C]--debug=6\f[R] to the command line will+show which aliases are being applied when.+.SS \f[C]end aliases\f[R]+.PP+You can clear (forget) all currently defined aliases with the+\f[C]end aliases\f[R] directive:+.IP+.nf+\f[C]+end aliases+\f[R]+.fi+.SS Default parent account+.PP+You can specify a parent account which will be prepended to all accounts+within a section of the journal.+Use the \f[C]apply account\f[R] and \f[C]end apply account\f[R]+directives like so:+.IP+.nf+\f[C]+apply account home++2010/1/1+    food    $10+    cash++end apply account+\f[R]+.fi+.PP+which is equivalent to:+.IP+.nf+\f[C]+2010/01/01+    home:food           $10+    home:cash          $-10+\f[R]+.fi+.PP+If \f[C]end apply account\f[R] is omitted, the effect lasts to the end+of the file.+Included files are also affected, eg:+.IP+.nf+\f[C]+apply account business+include biz.journal+end apply account+apply account personal+include personal.journal+\f[R]+.fi+.PP+Prior to hledger 1.0, legacy \f[C]account\f[R] and \f[C]end\f[R]+spellings were also supported.+.PP+A default parent account also affects account directives.+It does not affect account names being entered via hledger add or+hledger-web.+If account aliases are present, they are applied after the default+parent account.+.SS Periodic transactions+.PP+Periodic transaction rules describe transactions that recur.+They allow you to generate future transactions for forecasting, without+having to write them out explicitly in the journal (with+\f[C]--forecast\f[R]).+Secondly, they also can be used to define budget goals (with+\f[C]--budget\f[R]).+.PP+A periodic transaction rule looks like a normal journal entry, with the+date replaced by a tilde (\f[C]\[ti]\f[R]) followed by a period+expression (mnemonic: \f[C]\[ti]\f[R] looks like a recurring sine+wave.):+.IP+.nf+\f[C]+\[ti] monthly+    expenses:rent          $2000+    assets:bank:checking+\f[R]+.fi+.PP+There is an additional constraint on the period expression: the start+date must fall on a natural boundary of the interval.+Eg \f[C]monthly from 2018/1/1\f[R] is valid, but+\f[C]monthly from 2018/1/15\f[R] is not.+.PP+Partial or relative dates (M/D, D, tomorrow, last week) in the period+expression can work (useful or not).+They will be relative to today\[aq]s date, unless a Y default year+directive is in effect, in which case they will be relative to Y/1/1.+.SS Two spaces after the period expression+.PP+If the period expression is followed by a transaction description, these+must be separated by \f[B]two or more spaces\f[R].+This helps hledger know where the period expression ends, so that+descriptions can not accidentally alter their meaning, as in this+example:+.IP+.nf+\f[C]+; 2 or more spaces needed here, so the period is not understood as \[dq]every 2 months in 2020\[dq]+;               ||+;               vv+\[ti] every 2 months  in 2020, we will review+    assets:bank:checking   $1500+    income:acme inc+\f[R]+.fi+.SS Forecasting with periodic transactions+.PP+With the \f[C]--forecast\f[R] flag, each periodic transaction rule+generates future transactions recurring at the specified interval.+These are not saved in the journal, but appear in all reports.+They will look like normal transactions, but with an extra tag:+.IP \[bu] 2+\f[C]generated-transaction:\[ti] PERIODICEXPR\f[R] - shows that this was+generated by a periodic transaction rule, and the period+.PP+There is also a hidden tag, with an underscore prefix, which does not+appear in hledger\[aq]s output:+.IP \[bu] 2+\f[C]_generated-transaction:\[ti] PERIODICEXPR\f[R]+.PP+This can be used to match transactions generated \[dq]just now\[dq],+rather than generated in the past and saved to the journal.+.PP+Forecast transactions start on the first occurrence, and end on the last+occurrence, of their interval within the forecast period.+The forecast period:+.IP \[bu] 2+begins on the later of+.RS 2+.IP \[bu] 2+the report start date if specified with -b/-p/date:+.IP \[bu] 2+the day after the latest normal (non-periodic) transaction in the+journal, or today if there are no normal transactions.+.RE+.IP \[bu] 2+ends on the report end date if specified with -e/-p/date:, or 180 days+from today.+.PP+where \[dq]today\[dq] means the current date at report time.+The \[dq]later of\[dq] rule ensures that forecast transactions do not+overlap normal transactions in time; they will begin only after normal+transactions end.+.PP+Forecasting can be useful for estimating balances into the future, and+experimenting with different scenarios.+Note the start date logic means that forecasted transactions are+automatically replaced by normal transactions as you add those.+.PP+Forecasting can also help with data entry: describe most of your+transactions with periodic rules, and every so often copy the output of+\f[C]print --forecast\f[R] to the journal.+.PP+You can generate one-time transactions too: just write a period+expression specifying a date with no report interval.+(You could also write a normal transaction with a future date, but+remember this disables forecast transactions on previous dates.)+.SS Budgeting with periodic transactions+.PP+With the \f[C]--budget\f[R] flag, currently supported by the balance+command, each periodic transaction rule declares recurring budget goals+for the specified accounts.+Eg the first example above declares a goal of spending $2000 on rent+(and also, a goal of depositing $2000 into checking) every month.+Goals and actual performance can then be compared in budget reports.+.PP+For more details, see: balance: Budget report and Cookbook: Budgeting+and Forecasting.+.PP+.SS Auto postings / transaction modifiers+.PP+Transaction modifier rules, AKA auto posting rules, describe changes to+be applied automatically to certain matched transactions.+Currently just one kind of change is possible - adding extra postings,+which we call \[dq]automated postings\[dq] or just \[dq]auto+postings\[dq].+These rules become active when you use the \f[C]--auto\f[R] flag.+.PP+A transaction modifier rule looks much like a normal transaction except+the first line is an equals sign followed by a query that matches+certain postings (mnemonic: \f[C]=\f[R] suggests matching).+And each \[dq]posting\[dq] is actually a posting-generating rule:+.IP+.nf+\f[C]+= QUERY+    ACCT  AMT+    ACCT  [AMT]+    ...+\f[R]+.fi+.PP+These posting-generating rules look like normal postings, except the+amount can be:+.IP \[bu] 2+a normal amount with a commodity symbol, eg \f[C]$2\f[R].+This will be used as-is.+.IP \[bu] 2+a number, eg \f[C]2\f[R].+The commodity symbol (if any) from the matched posting will be added to+this.+.IP \[bu] 2+a numeric multiplier, eg \f[C]*2\f[R] (a star followed by a number N).+The matched posting\[aq]s amount (and total price, if any) will be+multiplied by N.+.IP \[bu] 2+a multiplier with a commodity symbol, eg \f[C]*$2\f[R] (a star, number+N, and symbol S).+The matched posting\[aq]s amount will be multiplied by N, and its+commodity symbol will be replaced with S.+.PP+These rules have global effect - a rule appearing anywhere in your data+can potentially affect any transaction, including transactions recorded+above it or in another file.+.PP+Some examples:+.IP+.nf+\f[C]+; every time I buy food, schedule a dollar donation+= expenses:food+    (liabilities:charity)   $-1++; when I buy a gift, also deduct that amount from a budget envelope subaccount+= expenses:gifts+    assets:checking:gifts  *-1+    assets:checking         *1++2017/12/1+  expenses:food    $10+  assets:checking++2017/12/14+  expenses:gifts   $20+  assets:checking+\f[R]+.fi+.IP+.nf+\f[C]+$ hledger print --auto+2017/12/01+    expenses:food              $10+    assets:checking+    (liabilities:charity)      $-1++2017/12/14+    expenses:gifts             $20+    assets:checking+    assets:checking:gifts     -$20+    assets:checking            $20+\f[R]+.fi+.SS Auto postings and dates+.PP+A posting date (or secondary date) in the matched posting, or (taking+precedence) a posting date in the auto posting rule itself, will also be+used in the generated posting.+.SS Auto postings and transaction balancing / inferred amounts / balance assertions+.PP+Currently, transaction modifiers are applied / auto postings are added:+.IP \[bu] 2+after missing amounts are inferred, and transactions are checked for+balancedness,+.IP \[bu] 2+but before balance assertions are checked.+.PP+Note this means that journal entries must be balanced both before and+after auto postings are added.+This changed in hledger 1.12+; see #893 for background.+.SS Auto posting tags+.PP+Postings added by transaction modifiers will have some extra tags:+.IP \[bu] 2+\f[C]generated-posting:= QUERY\f[R] - shows this was generated by an+auto posting rule, and the query+.IP \[bu] 2+\f[C]_generated-posting:= QUERY\f[R] - a hidden tag, which does not+appear in hledger\[aq]s output.+This can be used to match postings generated \[dq]just now\[dq], rather+than generated in the past and saved to the journal.+.PP+Also, any transaction that has been changed by transaction modifier+rules will have these tags added:+.IP \[bu] 2+\f[C]modified:\f[R] - this transaction was modified+.IP \[bu] 2+\f[C]_modified:\f[R] - a hidden tag not appearing in the comment; this+transaction was modified \[dq]just now\[dq].+.SH EDITOR SUPPORT+.PP+Helper modes exist for popular text editors, which make working with+journal files easier.+They add colour, formatting, tab completion, and helpful commands, and+are quite recommended if you edit your journal with a text editor.+They include ledger-mode or hledger-mode for Emacs, vim-ledger for Vim,+hledger-vscode for Visual Studio Code, and others. See the [[Cookbook]] at hledger.org for the latest information.  
embeddedfiles/hledger_journal.info view
@@ -4,7 +4,7 @@  File: hledger_journal.info,  Node: Top,  Next: FILE FORMAT,  Up: (dir) -hledger_journal(5) hledger 1.14+hledger_journal(5) hledger 1.15 *******************************  hledger's usual data source is a plain text file containing journal@@ -29,28 +29,28 @@  ; A sample journal file. This is a comment. -2008/01/01 income               ; <- transaction's first line starts in column 0, contains date and description-    assets:bank:checking  $1    ; <- posting lines start with whitespace, each contains an account name-    income:salary        $-1    ;    followed by at least two spaces and an amount+2008/01/01 income             ; <- transaction's first line starts in column 0, contains date and description+    assets:bank:checking  $1  ; <- posting lines start with whitespace, each contains an account name+    income:salary        $-1  ;    followed by at least two spaces and an amount  2008/06/01 gift-    assets:bank:checking  $1    ; <- at least two postings in a transaction-    income:gifts         $-1    ; <- their amounts must balance to 0+    assets:bank:checking  $1  ; <- at least two postings in a transaction+    income:gifts         $-1  ; <- their amounts must balance to 0  2008/06/02 save     assets:bank:saving    $1-    assets:bank:checking        ; <- one amount may be omitted; here $-1 is inferred+    assets:bank:checking      ; <- one amount may be omitted; here $-1 is inferred -2008/06/03 eat & shop           ; <- description can be anything+2008/06/03 eat & shop         ; <- description can be anything     expenses:food         $1-    expenses:supplies     $1    ; <- this transaction debits two expense accounts-    assets:cash                 ; <- $-2 inferred+    expenses:supplies     $1  ; <- this transaction debits two expense accounts+    assets:cash               ; <- $-2 inferred  2008/10/01 take a loan     assets:bank:checking  $1     liabilities:debts    $-1 -2008/12/31 * pay off            ; <- an optional * or ! after the date means "cleared" (or anything you want)+2008/12/31 * pay off          ; <- an optional * or ! after the date means "cleared" (or anything you want)     liabilities:debts     $1     assets:bank:checking @@ -82,7 +82,7 @@ * Tags:: * Directives:: * Periodic transactions::-* Transaction modifiers::+* Auto postings / transaction modifiers::   File: hledger_journal.info,  Node: Transactions,  Next: Postings,  Up: FILE FORMAT@@ -214,8 +214,8 @@ easy bank reconciliation:  2015/5/30-    expenses:food     $10   ; food purchased on saturday 5/30-    assets:checking         ; bank cleared it on monday, date:6/1+    expenses:food     $10  ; food purchased on saturday 5/30+    assets:checking        ; bank cleared it on monday, date:6/1  $ hledger -f t.j register food 2015/05/30                      expenses:food                  $10           $10@@ -296,6 +296,7 @@ "narration" in traditional bookkeeping, it can be used for whatever you wish, or left blank.  Transaction descriptions can be queried, unlike comments.+ * Menu:  * Payee and note::@@ -306,10 +307,11 @@ 1.5.1 Payee and note -------------------- -You can optionally include a '|' (pipe) character in a description to-subdivide it into a payee/payer name on the left and additional notes on-the right.  This may be worthwhile if you need to do more precise-querying and pivoting by payee.+You can optionally include a '|' (pipe) character in descriptions to+subdivide the description into separate fields for payee/payer name on+the left (up to the first '|') and an additional note field on the right+(after the first '|').  This may be worthwhile if you need to do more+precise querying and pivoting by payee or by note.   File: hledger_journal.info,  Node: Account names,  Next: Amounts,  Prev: Description,  Up: FILE FORMAT@@ -467,6 +469,7 @@ while cleaning up old entries.  You can disable them temporarily with the '-I/--ignore-assertions' flag, which can be useful for troubleshooting or for reading Ledger files.+ * Menu:  * Assertions and ordering::@@ -655,6 +658,7 @@ assignment).  Note that using balance assignments makes your journal a little less explicit; to know the exact amount posted, you have to run hledger or do the calculations yourself, instead of just reading it.+ * Menu:  * Balance assignments and prices::@@ -731,8 +735,8 @@ transaction is equivalent, -B shows something different:  2009/1/1-  assets:dollars  $-135               ; 135 dollars sold-  assets:euros     €100               ; for 100 euros+  assets:dollars  $-135              ; 135 dollars sold+  assets:euros     €100              ; for 100 euros  $ hledger bal -N --flat -B                €-100  assets:dollars  # <- the dollars' selling price@@ -791,18 +795,18 @@    A simple tag is a word (which may contain hyphens) followed by a full colon, written inside a transaction or posting comment line: -2017/1/16 bought groceries    ; sometag:+2017/1/16 bought groceries  ; sometag:     Tags can have a value, which is the text after the colon, up to the next comma or end of line, with leading/trailing whitespace removed: -    expenses:food    $10   ; a-posting-tag: the tag value+    expenses:food    $10 ; a-posting-tag: the tag value     Note this means hledger's tag values can not contain commas or newlines.  Ending at commas means you can write multiple short tags on one line, comma separated: -    assets:checking       ; a comment containing tag1:, tag2: some value ...+    assets:checking  ; a comment containing tag1:, tag2: some value ...     Here, @@ -914,6 +918,7 @@ more simplicity and predictability, eg reports are not changed by writing file options in a different order.  It can be surprising at times though.+ * Menu:  * Comment blocks::@@ -964,19 +969,19 @@ specify a year.  This is a line beginning with 'Y' followed by the year. Eg: -Y2009      ; set default year to 2009+Y2009  ; set default year to 2009 -12/15      ; equivalent to 2009/12/15+12/15  ; equivalent to 2009/12/15   expenses  1   assets -Y2010      ; change default year to 2010+Y2010  ; change default year to 2010  2009/1/30  ; specifies the year, not affected   expenses  1   assets -1/31       ; equivalent to 2010/1/31+1/31   ; equivalent to 2010/1/31   expenses  1   assets @@ -987,9 +992,10 @@ ----------------------------  The 'commodity' directive declares commodities which may be used in the-journal (though currently we do not enforce this).  It may be written on-a single line, like this:+journal, and their display format. +   It may be written on a single line, like this:+ ; commodity EXAMPLEAMOUNT  ; display AAAA amounts with the symbol on the right, space-separated,@@ -1010,14 +1016,20 @@ commodity INR   format INR 9,99,99,999.00 -   Commodity directives have a second purpose: they define the standard-display format for amounts in the commodity.  Normally the display-format is inferred from journal entries, but this can be unpredictable;-declaring it with a commodity directive overrides this and removes-ambiguity.  Towards this end, amounts in commodity directives must-always be written with a decimal point (a period or comma, followed by 0-or more decimal digits).+   Declaring commodites may be useful as documentation, but currently we+do not enforce that only declared commodities may be used.  This+directive is mainly useful for customising the preferred display format+for a commodity. +   Normally the display format is inferred from journal entries, but+this can be unpredictable; declaring it with a commodity directive+overrides this and removes ambiguity.  Towards this end, amounts in+commodity directives must always be written with a decimal point (a+period or comma, followed by 0 or more decimal digits).++   Commodity directives do not affect how amounts are parsed; the parser+will read multiple formats.+  File: hledger_journal.info,  Node: Default commodity,  Next: Market prices,  Prev: Declaring commodities,  Up: Directives @@ -1035,7 +1047,7 @@ D $1,000.00  1/1-  a     5    ; <- commodity-less amount, becomes $1+  a     5  ; <- commodity-less amount, becomes $1   b     As with the 'commodity' directive, the amount must always be written@@ -1178,11 +1190,11 @@ need to help the reports a bit.  Eg:  ; make "liabilities" not have the liability type - who knows why-account liabilities   ; type:E+account liabilities  ; type:E  ; we need to ensure some other account has the liability type,  ; otherwise balancesheet would still show "liabilities" under Liabilities -account -             ; type:L+account -            ; type:L   File: hledger_journal.info,  Node: Account display order,  Prev: Account types,  Up: Declaring accounts@@ -1248,11 +1260,12 @@ hledger-web.     See also Cookbook: Rewrite account names.+ * Menu:  * Basic aliases:: * Regex aliases::-* Multiple aliases::+* Combining aliases:: * end aliases::  @@ -1279,7 +1292,7 @@ # rewrites "checking" to "assets:bank:wells fargo:checking", or "checking:a" to "assets:bank:wells fargo:checking:a"  -File: hledger_journal.info,  Node: Regex aliases,  Next: Multiple aliases,  Prev: Basic aliases,  Up: Rewriting accounts+File: hledger_journal.info,  Node: Regex aliases,  Next: Combining aliases,  Prev: Basic aliases,  Up: Rewriting accounts  1.14.8.2 Regex aliases ......................@@ -1304,23 +1317,44 @@ whitespace.  -File: hledger_journal.info,  Node: Multiple aliases,  Next: end aliases,  Prev: Regex aliases,  Up: Rewriting accounts+File: hledger_journal.info,  Node: Combining aliases,  Next: end aliases,  Prev: Regex aliases,  Up: Rewriting accounts -1.14.8.3 Multiple aliases-.........................+1.14.8.3 Combining aliases+.......................... -You can define as many aliases as you like using directives or-command-line options.  Aliases are recursive - each alias sees the-result of applying previous ones.  (This is different from Ledger, where-aliases are non-recursive by default).  Aliases are applied in the-following order:+You can define as many aliases as you like, using journal directives+and/or command line options. -  1. alias directives, most recently seen first (recent directives take-     precedence over earlier ones; directives not yet seen are ignored)-  2. alias options, in the order they appear on the command line+   Recursive aliases - where an account name is rewritten by one alias,+then by another alias, and so on - are allowed.  Each alias sees the+effect of previously applied aliases. +   In such cases it can be important to understand which aliases will be+applied and in which order.  For (each account name in) each journal+entry, we apply:++  1. 'alias' directives preceding the journal entry, most recently+     parsed first (ie, reading upward from the journal entry, bottom to+     top)+  2. '--alias' options, in the order they appeared on the command line+     (left to right).++   In other words, for (an account name in) a given journal entry:++   * the nearest alias declaration before/above the entry is applied+     first+   * the next alias before/above that will be be applied next, and so on+   * aliases defined after/below the entry do not affect it.++   This gives nearby aliases precedence over distant ones, and helps+provide semantic stability - aliases will keep working the same way+independent of which files are being read and in which order.++   In case of trouble, adding '--debug=6' to the command line will show+which aliases are being applied when.+ -File: hledger_journal.info,  Node: end aliases,  Prev: Multiple aliases,  Up: Rewriting accounts+File: hledger_journal.info,  Node: end aliases,  Prev: Combining aliases,  Up: Rewriting accounts  1.14.8.4 'end aliases' ......................@@ -1372,7 +1406,7 @@ parent account.  -File: hledger_journal.info,  Node: Periodic transactions,  Next: Transaction modifiers,  Prev: Directives,  Up: FILE FORMAT+File: hledger_journal.info,  Node: Periodic transactions,  Next: Auto postings / transaction modifiers,  Prev: Directives,  Up: FILE FORMAT  1.15 Periodic transactions ==========================@@ -1398,6 +1432,7 @@ expression can work (useful or not).  They will be relative to today's date, unless a Y default year directive is in effect, in which case they will be relative to Y/1/1.+ * Menu:  * Two spaces after the period expression::@@ -1431,9 +1466,19 @@ With the '--forecast' flag, each periodic transaction rule generates future transactions recurring at the specified interval.  These are not saved in the journal, but appear in all reports.  They will look like-normal transactions, but with an extra tag named 'recur', whose value is-the generating period expression.+normal transactions, but with an extra tag: +   * 'generated-transaction:~ PERIODICEXPR' - shows that this was+     generated by a periodic transaction rule, and the period++   There is also a hidden tag, with an underscore prefix, which does not+appear in hledger's output:++   * '_generated-transaction:~ PERIODICEXPR'++   This can be used to match transactions generated "just now", rather+than generated in the past and saved to the journal.+    Forecast transactions start on the first occurrence, and end on the last occurrence, of their interval within the forecast period.  The forecast period:@@ -1482,18 +1527,18 @@ and Forecasting.  -File: hledger_journal.info,  Node: Transaction modifiers,  Prev: Periodic transactions,  Up: FILE FORMAT+File: hledger_journal.info,  Node: Auto postings / transaction modifiers,  Prev: Periodic transactions,  Up: FILE FORMAT -1.16 Transaction modifiers-==========================+1.16 Auto postings / transaction modifiers+========================================== -Transaction modifier rules describe changes that should be applied-automatically to certain transactions.  They can be enabled by using the-'--auto' flag.  Currently, just one kind of change is possible: adding-extra postings.  These rule-generated postings are known as "automated-postings" or "auto postings".+Transaction modifier rules, AKA auto posting rules, describe changes to+be applied automatically to certain matched transactions.  Currently+just one kind of change is possible - adding extra postings, which we+call "automated postings" or just "auto postings".  These rules become+active when you use the '--auto' flag. -   A transaction modifier rule looks quite like a normal transaction,+   A transaction modifier rule looks much like a normal transaction except the first line is an equals sign followed by a query that matches certain postings (mnemonic: '=' suggests matching).  And each "posting" is actually a posting-generating rule:@@ -1503,8 +1548,8 @@     ACCT  [AMT]     ... -   These posting rules look like normal postings, except the amount can-be:+   These posting-generating rules look like normal postings, except the+amount can be:     * a normal amount with a commodity symbol, eg '$2'.  This will be      used as-is.@@ -1517,6 +1562,10 @@      and symbol S). The matched posting's amount will be multiplied by      N, and its commodity symbol will be replaced with S. +   These rules have global effect - a rule appearing anywhere in your+data can potentially affect any transaction, including transactions+recorded above it or in another file.+    Some examples:  ; every time I buy food, schedule a dollar donation@@ -1550,12 +1599,24 @@  * Menu: +* Auto postings and dates:: * Auto postings and transaction balancing / inferred amounts / balance assertions::+* Auto posting tags::  -File: hledger_journal.info,  Node: Auto postings and transaction balancing / inferred amounts / balance assertions,  Up: Transaction modifiers+File: hledger_journal.info,  Node: Auto postings and dates,  Next: Auto postings and transaction balancing / inferred amounts / balance assertions,  Up: Auto postings / transaction modifiers -1.16.1 Auto postings and transaction balancing / inferred amounts /+1.16.1 Auto postings and dates+------------------------------++A posting date (or secondary date) in the matched posting, or (taking+precedence) a posting date in the auto posting rule itself, will also be+used in the generated posting.+++File: hledger_journal.info,  Node: Auto postings and transaction balancing / inferred amounts / balance assertions,  Next: Auto posting tags,  Prev: Auto postings and dates,  Up: Auto postings / transaction modifiers++1.16.2 Auto postings and transaction balancing / inferred amounts / -------------------------------------------------------------------  balance assertions Currently, transaction modifiers are applied / auto@@ -1570,6 +1631,28 @@ for background.  +File: hledger_journal.info,  Node: Auto posting tags,  Prev: Auto postings and transaction balancing / inferred amounts / balance assertions,  Up: Auto postings / transaction modifiers++1.16.3 Auto posting tags+------------------------++Postings added by transaction modifiers will have some extra tags:++   * 'generated-posting:= QUERY' - shows this was generated by an auto+     posting rule, and the query+   * '_generated-posting:= QUERY' - a hidden tag, which does not appear+     in hledger's output.  This can be used to match postings generated+     "just now", rather than generated in the past and saved to the+     journal.++   Also, any transaction that has been changed by transaction modifier+rules will have these tags added:++   * 'modified:' - this transaction was modified+   * '_modified:' - a hidden tag not appearing in the comment; this+     transaction was modified "just now".++ File: hledger_journal.info,  Node: EDITOR SUPPORT,  Prev: FILE FORMAT,  Up: Top  2 EDITOR SUPPORT@@ -1585,109 +1668,113 @@  Tag Table: Node: Top76-Node: FILE FORMAT2372-Ref: #file-format2496-Node: Transactions2783-Ref: #transactions2904-Node: Postings3588-Ref: #postings3715-Node: Dates4710-Ref: #dates4825-Node: Simple dates4890-Ref: #simple-dates5016-Node: Secondary dates5382-Ref: #secondary-dates5536-Node: Posting dates7099-Ref: #posting-dates7228-Node: Status8602-Ref: #status8722-Node: Description10430-Ref: #description10568-Node: Payee and note10887-Ref: #payee-and-note11001-Node: Account names11243-Ref: #account-names11386-Node: Amounts11873-Ref: #amounts12009-Node: Virtual Postings15026-Ref: #virtual-postings15185-Node: Balance Assertions16405-Ref: #balance-assertions16580-Node: Assertions and ordering17538-Ref: #assertions-and-ordering17724-Node: Assertions and included files18424-Ref: #assertions-and-included-files18665-Node: Assertions and multiple -f options18998-Ref: #assertions-and-multiple--f-options19252-Node: Assertions and commodities19384-Ref: #assertions-and-commodities19614-Node: Assertions and prices20770-Ref: #assertions-and-prices20982-Node: Assertions and subaccounts21422-Ref: #assertions-and-subaccounts21649-Node: Assertions and virtual postings21973-Ref: #assertions-and-virtual-postings22213-Node: Assertions and precision22355-Ref: #assertions-and-precision22546-Node: Balance Assignments22813-Ref: #balance-assignments22994-Node: Balance assignments and prices24158-Ref: #balance-assignments-and-prices24330-Node: Transaction prices24554-Ref: #transaction-prices24723-Node: Comments26991-Ref: #comments27125-Node: Tags28295-Ref: #tags28413-Node: Directives29815-Ref: #directives29958-Node: Comment blocks35565-Ref: #comment-blocks35710-Node: Including other files35886-Ref: #including-other-files36066-Node: Default year36474-Ref: #default-year36643-Node: Declaring commodities37066-Ref: #declaring-commodities37249-Node: Default commodity38476-Ref: #default-commodity38652-Node: Market prices39288-Ref: #market-prices39453-Node: Declaring accounts40294-Ref: #declaring-accounts40470-Node: Account comments41395-Ref: #account-comments41558-Node: Account subdirectives41953-Ref: #account-subdirectives42148-Node: Account types42461-Ref: #account-types42645-Node: Account display order44289-Ref: #account-display-order44459-Node: Rewriting accounts45588-Ref: #rewriting-accounts45773-Node: Basic aliases46507-Ref: #basic-aliases46653-Node: Regex aliases47357-Ref: #regex-aliases47528-Node: Multiple aliases48246-Ref: #multiple-aliases48421-Node: end aliases48919-Ref: #end-aliases49066-Node: Default parent account49167-Ref: #default-parent-account49333-Node: Periodic transactions50217-Ref: #periodic-transactions50399-Node: Two spaces after the period expression51524-Ref: #two-spaces-after-the-period-expression51769-Node: Forecasting with periodic transactions52254-Ref: #forecasting-with-periodic-transactions52544-Node: Budgeting with periodic transactions54231-Ref: #budgeting-with-periodic-transactions54470-Node: Transaction modifiers54929-Ref: #transaction-modifiers55092-Node: Auto postings and transaction balancing / inferred amounts / balance assertions57076-Ref: #auto-postings-and-transaction-balancing-inferred-amounts-balance-assertions57377-Node: EDITOR SUPPORT57755-Ref: #editor-support57873+Node: FILE FORMAT2352+Ref: #file-format2476+Node: Transactions2779+Ref: #transactions2900+Node: Postings3584+Ref: #postings3711+Node: Dates4706+Ref: #dates4821+Node: Simple dates4886+Ref: #simple-dates5012+Node: Secondary dates5378+Ref: #secondary-dates5532+Node: Posting dates7095+Ref: #posting-dates7224+Node: Status8596+Ref: #status8716+Node: Description10424+Ref: #description10562+Node: Payee and note10882+Ref: #payee-and-note10996+Node: Account names11331+Ref: #account-names11474+Node: Amounts11961+Ref: #amounts12097+Node: Virtual Postings15114+Ref: #virtual-postings15273+Node: Balance Assertions16493+Ref: #balance-assertions16668+Node: Assertions and ordering17627+Ref: #assertions-and-ordering17813+Node: Assertions and included files18513+Ref: #assertions-and-included-files18754+Node: Assertions and multiple -f options19087+Ref: #assertions-and-multiple--f-options19341+Node: Assertions and commodities19473+Ref: #assertions-and-commodities19703+Node: Assertions and prices20859+Ref: #assertions-and-prices21071+Node: Assertions and subaccounts21511+Ref: #assertions-and-subaccounts21738+Node: Assertions and virtual postings22062+Ref: #assertions-and-virtual-postings22302+Node: Assertions and precision22444+Ref: #assertions-and-precision22635+Node: Balance Assignments22902+Ref: #balance-assignments23083+Node: Balance assignments and prices24248+Ref: #balance-assignments-and-prices24420+Node: Transaction prices24644+Ref: #transaction-prices24813+Node: Comments27079+Ref: #comments27213+Node: Tags28383+Ref: #tags28501+Node: Directives29894+Ref: #directives30037+Node: Comment blocks35645+Ref: #comment-blocks35790+Node: Including other files35966+Ref: #including-other-files36146+Node: Default year36554+Ref: #default-year36723+Node: Declaring commodities37130+Ref: #declaring-commodities37313+Node: Default commodity38742+Ref: #default-commodity38918+Node: Market prices39552+Ref: #market-prices39717+Node: Declaring accounts40558+Ref: #declaring-accounts40734+Node: Account comments41659+Ref: #account-comments41822+Node: Account subdirectives42217+Ref: #account-subdirectives42412+Node: Account types42725+Ref: #account-types42909+Node: Account display order44551+Ref: #account-display-order44721+Node: Rewriting accounts45850+Ref: #rewriting-accounts46035+Node: Basic aliases46771+Ref: #basic-aliases46917+Node: Regex aliases47621+Ref: #regex-aliases47793+Node: Combining aliases48511+Ref: #combining-aliases48689+Node: end aliases49965+Ref: #end-aliases50113+Node: Default parent account50214+Ref: #default-parent-account50380+Node: Periodic transactions51264+Ref: #periodic-transactions51462+Node: Two spaces after the period expression52588+Ref: #two-spaces-after-the-period-expression52833+Node: Forecasting with periodic transactions53318+Ref: #forecasting-with-periodic-transactions53608+Node: Budgeting with periodic transactions55634+Ref: #budgeting-with-periodic-transactions55873+Node: Auto postings / transaction modifiers56332+Ref: #auto-postings-transaction-modifiers56543+Node: Auto postings and dates58772+Ref: #auto-postings-and-dates59029+Node: Auto postings and transaction balancing / inferred amounts / balance assertions59204+Ref: #auto-postings-and-transaction-balancing-inferred-amounts-balance-assertions59579+Node: Auto posting tags59957+Ref: #auto-posting-tags60196+Node: EDITOR SUPPORT60861+Ref: #editor-support60979  End Tag Table
embeddedfiles/hledger_journal.txt view
@@ -30,28 +30,28 @@                ; A sample journal file. This is a comment. -              2008/01/01 income               ; <- transaction's first line starts in column 0, contains date and description-                  assets:bank:checking  $1    ; <- posting lines start with whitespace, each contains an account name-                  income:salary        $-1    ;    followed by at least two spaces and an amount+              2008/01/01 income             ; <- transaction's first line starts in column 0, contains date and description+                  assets:bank:checking  $1  ; <- posting lines start with whitespace, each contains an account name+                  income:salary        $-1  ;    followed by at least two spaces and an amount                2008/06/01 gift-                  assets:bank:checking  $1    ; <- at least two postings in a transaction-                  income:gifts         $-1    ; <- their amounts must balance to 0+                  assets:bank:checking  $1  ; <- at least two postings in a transaction+                  income:gifts         $-1  ; <- their amounts must balance to 0                2008/06/02 save                   assets:bank:saving    $1-                  assets:bank:checking        ; <- one amount may be omitted; here $-1 is inferred+                  assets:bank:checking      ; <- one amount may be omitted; here $-1 is inferred -              2008/06/03 eat & shop           ; <- description can be anything+              2008/06/03 eat & shop         ; <- description can be anything                   expenses:food         $1-                  expenses:supplies     $1    ; <- this transaction debits two expense accounts-                  assets:cash                 ; <- $-2 inferred+                  expenses:supplies     $1  ; <- this transaction debits two expense accounts+                  assets:cash               ; <- $-2 inferred                2008/10/01 take a loan                   assets:bank:checking  $1                   liabilities:debts    $-1 -              2008/12/31 * pay off            ; <- an optional * or ! after the date means "cleared" (or anything you want)+              2008/12/31 * pay off          ; <- an optional * or ! after the date means "cleared" (or anything you want)                   liabilities:debts     $1                   assets:bank:checking @@ -154,8 +154,8 @@        easy bank reconciliation:                2015/5/30-                  expenses:food     $10   ; food purchased on saturday 5/30-                  assets:checking         ; bank cleared it on monday, date:6/1+                  expenses:food     $10  ; food purchased on saturday 5/30+                  assets:checking        ; bank cleared it on monday, date:6/1                $ hledger -f t.j register food               2015/05/30                      expenses:food                  $10           $10@@ -229,18 +229,19 @@        comments.     Payee and note-       You  can  optionally  include  a | (pipe) character in a description to-       subdivide it into a payee/payer name on the left and  additional  notes-       on  the  right.   This may be worthwhile if you need to do more precise-       querying and pivoting by payee.+       You can optionally include a | (pipe) character in descriptions to sub-+       divide the description into separate fields for payee/payer name on the+       left  (up  to  the  first  |) and an additional note field on the right+       (after the first |).  This may be worthwhile if you  need  to  do  more+       precise querying and pivoting by payee or by note.     Account names-       Account names typically have several parts separated by a  full  colon,-       from  which hledger derives a hierarchical chart of accounts.  They can-       be anything you like, but  in  finance  there  are  traditionally  five-       top-level  accounts: assets, liabilities, income, expenses, and equity.+       Account  names  typically have several parts separated by a full colon,+       from which hledger derives a hierarchical chart of accounts.  They  can+       be  anything you like, but in finance there are traditionally five top-+       level accounts: assets, liabilities, income, expenses, and equity. -       Account names may contain single  spaces,  eg:  assets:accounts receiv-+       Account names may contain single spaces,  eg:  assets:accounts  receiv-        able.   Because  of  this,  they must always be followed by two or more        spaces (or newline). @@ -384,12 +385,12 @@        Ledger assertions do not see the accumulated effect of  repeated  post-        ings to the same account within a transaction.) -       So,  hledger  balance  assertions  keep  working if you reorder differ--       ently-dated transactions  within  the  journal.   But  if  you  reorder-       same-dated transactions or postings, assertions might break and require-       updating.  This order dependence does bring an advantage: precise  con--       trol over the order of postings and assertions within a day, so you can-       assert intra-day balances.+       So, hledger balance assertions keep working if you reorder differently-+       dated transactions within the journal.  But if you  reorder  same-dated+       transactions  or postings, assertions might break and require updating.+       This order dependence does bring an advantage: precise control over the+       order of postings and assertions within a day, so you can assert intra-+       day balances.     Assertions and included files        With included files, things are a little more  complicated.   Including@@ -418,17 +419,17 @@                2013/1/1                 a   $1-                a    1+                a    1EUR                 b  $-1-                c   -1+                c   -1EUR                2013/1/2  ; These assertions succeed                 a    0  =  $1-                a    0  =   1+                a    0  =   1EUR                 b    0 == $-1-                c    0 ==  -1+                c    0 ==  -1EUR -              2013/1/3  ; This assertion fails as 'a' also contains 1+              2013/1/3  ; This assertion fails as 'a' also contains 1EUR                 a    0 ==  $1         It's not yet possible to make a complete assertion about a balance that@@ -437,20 +438,20 @@                2013/1/1                 a:usd   $1-                a:euro   1+                a:euro   1EUR                 b                2013/1/2                 a        0 ==  0                 a:usd    0 == $1-                a:euro   0 ==  1+                a:euro   0 ==  1EUR     Assertions and prices        Balance  assertions  ignore  transaction prices, and should normally be        written without one:                2019/1/1-                (a)     $1 @ 1 = $1+                (a)     $1 @ EUR1 = $1         We do allow prices to be written there, however, and print shows  them,        even  though  they  don't affect whether the assertion passes or fails.@@ -512,11 +513,11 @@        amount to have that price attached:                2019/1/1-                (a)             = $1 @ 2+                (a)             = $1 @ EUR2                $ hledger print --explicit               2019/01/01-                  (a)         $1 @ 2 = $1 @ 2+                  (a)         $1 @ EUR2 = $1 @ EUR2     Transaction prices        Within a transaction, you can note an amount's price in another commod-@@ -532,20 +533,20 @@        1. Write the price per unit, as @ UNITPRICE after the amount:                    2009/1/1-                    assets:euros     100 @ $1.35  ; one hundred euros purchased at $1.35 each+                    assets:euros     EUR100 @ $1.35  ; one hundred euros purchased at $1.35 each                     assets:dollars                 ; balancing amount is -$135.00         2. Write the total price, as @@ TOTALPRICE after the amount:                    2009/1/1-                    assets:euros     100 @@ $135  ; one hundred euros purchased at $135 for the lot+                    assets:euros     EUR100 @@ $135  ; one hundred euros purchased at $135 for the lot                     assets:dollars         3. Specify amounts for all postings, using exactly two commodities, and           let hledger infer the price that balances the transaction:                    2009/1/1-                    assets:euros     100          ; one hundred euros purchased+                    assets:euros     EUR100          ; one hundred euros purchased                     assets:dollars  $-135          ; for $135         (Ledger users: Ledger uses a different syntax for fixed prices, {=UNIT-@@ -557,7 +558,7 @@                $ hledger bal -N --flat                              $-135  assets:dollars-                              100  assets:euros+                              EUR100  assets:euros               $ hledger bal -N --flat -B                              $-135  assets:dollars                               $135  assets:euros    # <- the euros' cost@@ -568,12 +569,12 @@        is equivalent, -B shows something different:                2009/1/1-                assets:dollars  $-135               ; 135 dollars sold-                assets:euros     100               ; for 100 euros+                assets:dollars  $-135              ; 135 dollars sold+                assets:euros     EUR100              ; for 100 euros                $ hledger bal -N --flat -B-                             -100  assets:dollars  # <- the dollars' selling price-                              100  assets:euros+                             EUR-100  assets:dollars  # <- the dollars' selling price+                              EUR100  assets:euros     Comments        Lines in the journal beginning with a semicolon (;) or hash (#) or star@@ -608,8 +609,8 @@                   ; another comment line for posting 2               ; a file comment (because not indented) -       You can also comment  larger  regions  of  a  file  using  comment  and-       end comment directives.+       You can also comment larger regions of a file  using  comment  and  end+       comment directives.     Tags        Tags  are  a  way  to add extra labels or labelled data to postings and@@ -618,18 +619,18 @@        A simple tag is a word (which may contain hyphens) followed by  a  full        colon, written inside a transaction or posting comment line: -              2017/1/16 bought groceries    ; sometag:+              2017/1/16 bought groceries  ; sometag:         Tags  can  have  a  value, which is the text after the colon, up to the        next comma or end of line, with leading/trailing whitespace removed: -                  expenses:food    $10   ; a-posting-tag: the tag value+                  expenses:food    $10 ; a-posting-tag: the tag value         Note this means hledger's tag values can not  contain  commas  or  new-        lines.  Ending at commas means you can write multiple short tags on one        line, comma separated: -                  assets:checking       ; a comment containing tag1:, tag2: some value ...+                  assets:checking  ; a comment containing tag1:, tag2: some value ...         Here, @@ -641,8 +642,8 @@         Tags in a transaction comment affect the transaction  and  all  of  its        postings,  while  tags  in  a posting comment affect only that posting.-       For example,  the  following  transaction  has  three  tags  (A,  TAG2,-       third-tag) and the posting has four (those plus posting-tag):+       For example, the following transaction has three tags (A, TAG2,  third-+       tag) and the posting has four (those plus posting-tag):                1/1 a transaction  ; A:, TAG2:                   ; third-tag: a third transaction tag, <- with a value@@ -662,61 +663,60 @@        links to more detailed docs.  -       direc-          end                 subdi-    purpose                        can affect  (as  of-       tive            directive           rec-                                     2018/06)-                                           tives-       --------------------------------------------------------------------------------------------------       account                             any       document   account    names,   all entries in  all-                                           text      declare account types & dis-   files,   before  or-                                                     play order                     after-+       direc-     end         subdi-    purpose                        can affect  (as  of+       tive       directive   rec-                                     2018/06)+                              tives+       ------------------------------------------------------------------------------------   -       alias           end aliases                   rewrite account names          following-                                                                                    inline/included-                                                                                    entries  until  end-                                                                                    of current file  or-                                                                                    end directive-       apply account   end apply account             prepend  a  common parent to   following-                                                     account names                  inline/included-                                                                                    entries  until  end-                                                                                    of  current file or-                                                                                    end directive-       comment         end comment                   ignore part of journal         following-                                                                                    inline/included-                                                                                    entries  until  end-                                                                                    of  current file or-                                                                                    end directive-       commodity                           format    declare a commodity and  its   number    notation:-                                                     number  notation  &  display   following   entries-                                                     style                          in  that  commodity-                                                                                    in  all files; dis--                                                                                    play style: amounts-                                                                                    of  that  commodity-                                                                                    in reports-       D                                             declare a commodity,  number   commodity: all com--                                                     notation & display style for   modityless  entries-                                                     commodityless amounts          in all files;  num--                                                                                    ber  notation: fol--                                                                                    lowing   commodity--                                                                                    less   entries  and-                                                                                    entries   in   that-                                                                                    commodity   in  all-                                                                                    files;      display-                                                                                    style:  amounts  of-                                                                                    that  commodity  in-                                                                                    reports-       include                                       include   entries/directives   what  the  included-                                                     from another file              directives affect-       P                                             declare a market price for a   amounts   of   that-                                                     commodity                      commodity        in-                                                                                    reports, when -V is-                                                                                    used-       Y                                             declare  a year for yearless   following-                                                     dates                          inline/included-                                                                                    entries  until  end-                                                                                    of current file+       account                any       document   account    names,   all entries in  all+                              text      declare account types & dis-   files,   before  or+                                        play order                     after+       alias      end                   rewrite account names          following+                  aliases                                              inline/included+                                                                       entries  until  end+                                                                       of current file  or+                                                                       end directive+       apply      end apply             prepend  a  common parent to   following+       account    account               account names                  inline/included+                                                                       entries  until  end+                                                                       of  current file or+                                                                       end directive+       comment    end  com-             ignore part of journal         following+                  ment                                                 inline/included+                                                                       entries  until  end+                                                                       of current file  or+                                                                       end directive+       commod-                format    declare a commodity and  its   number    notation:+       ity                              number  notation  &  display   following   entries+                                        style                          in  that  commodity+                                                                       in  all files; dis-+                                                                       play style: amounts+                                                                       of  that  commodity+                                                                       in reports+       D                                declare a commodity,  number   commodity: all com-+                                        notation & display style for   modityless  entries+                                        commodityless amounts          in all files;  num-+                                                                       ber  notation: fol-+                                                                       lowing   commodity-+                                                                       less   entries  and+                                                                       entries   in   that+                                                                       commodity   in  all+                                                                       files;      display+                                                                       style:  amounts  of+                                                                       that  commodity  in+                                                                       reports+       include                          include   entries/directives   what  the  included+                                        from another file              directives affect+       P                                declare a market price for a   amounts   of   that+                                        commodity                      commodity        in+                                                                       reports, when -V is+                                                                       used+       Y                                declare  a year for yearless   following+                                        dates                          inline/included+                                                                       entries  until  end+                                                                       of current file         And some definitions: @@ -766,27 +766,28 @@        specify a year.  This is a line beginning with Y followed by the  year.        Eg: -              Y2009      ; set default year to 2009+              Y2009  ; set default year to 2009 -              12/15      ; equivalent to 2009/12/15+              12/15  ; equivalent to 2009/12/15                 expenses  1                 assets -              Y2010      ; change default year to 2010+              Y2010  ; change default year to 2010                2009/1/30  ; specifies the year, not affected                 expenses  1                 assets -              1/31       ; equivalent to 2010/1/31+              1/31   ; equivalent to 2010/1/31                 expenses  1                 assets     Declaring commodities        The  commodity  directive declares commodities which may be used in the-       journal (though currently we do not enforce this).  It may  be  written-       on a single line, like this:+       journal, and their display format. +       It may be written on a single line, like this:+               ; commodity EXAMPLEAMOUNT                ; display AAAA amounts with the symbol on the right, space-separated,@@ -794,8 +795,8 @@               ; separating thousands with comma.               commodity 1,000.0000 AAAA -       or  on  multiple  lines, using the "format" subdirective.  In this case-       the commodity symbol appears twice and  should  be  the  same  in  both+       or on multiple lines, using the "format" subdirective.   In  this  case+       the  commodity  symbol  appears  twice  and  should be the same in both        places:                ; commodity SYMBOL@@ -807,19 +808,25 @@               commodity INR                 format INR 9,99,99,999.00 -       Commodity  directives  have  a second purpose: they define the standard-       display format for amounts in the commodity.  Normally the display for--       mat  is  inferred  from journal entries, but this can be unpredictable;-       declaring it with a commodity  directive  overrides  this  and  removes-       ambiguity.   Towards  this  end,  amounts  in commodity directives must-       always be written with a decimal point (a period or comma, followed  by-       0 or more decimal digits).+       Declaring commodites may be useful as documentation, but  currently  we+       do not enforce that only declared commodities may be used.  This direc-+       tive is mainly useful for customising the preferred display format  for+       a commodity. +       Normally  the display format is inferred from journal entries, but this+       can be unpredictable; declaring it with a commodity directive overrides+       this  and  removes  ambiguity.   Towards this end, amounts in commodity+       directives must always be written with a decimal  point  (a  period  or+       comma, followed by 0 or more decimal digits).++       Commodity  directives  do not affect how amounts are parsed; the parser+       will read multiple formats.+    Default commodity-       The  D  directive  sets a default commodity (and display format), to be+       The D directive sets a default commodity (and display  format),  to  be        used for amounts without a commodity symbol (ie, plain numbers).  (Note-       this  differs from Ledger's default commodity directive.) The commodity-       and display format will be applied  to  all  subsequent  commodity-less+       this differs from Ledger's default commodity directive.) The  commodity+       and  display  format  will  be applied to all subsequent commodity-less        amounts, or until the next D directive.                # commodity-less amounts should be treated as dollars@@ -827,16 +834,16 @@               D $1,000.00                1/1-                a     5    ; <- commodity-less amount, becomes $1+                a     5  ; <- commodity-less amount, becomes $1                 b         As with the commodity directive, the amount must always be written with        a decimal point.     Market prices-       The P directive declares a market price,  which  is  an  exchange  rate+       The  P  directive  declares  a  market price, which is an exchange rate        between two commodities on a certain date.  (In Ledger, they are called-       "historical prices".) These are often obtained from a  stock  exchange,+       "historical  prices".)  These are often obtained from a stock exchange,        cryptocurrency exchange, or the foreign exchange market.         Here is the format:@@ -847,39 +854,39 @@         o COMMODITYA is the symbol of the commodity being priced -       o COMMODITYBAMOUNT  is an amount (symbol and quantity) in a second com-+       o COMMODITYBAMOUNT is an amount (symbol and quantity) in a second  com-          modity, giving the price in commodity B of one unit of commodity A. -       These two market price directives say that one euro was worth  1.35  US+       These  two  market price directives say that one euro was worth 1.35 US        dollars during 2009, and $1.40 from 2010 onward: -              P 2009/1/1  $1.35-              P 2010/1/1  $1.40+              P 2009/1/1 EUR $1.35+              P 2010/1/1 EUR $1.40 -       The  -V/--value flag can be used to convert reported amounts to another+       The -V/--value flag can be used to convert reported amounts to  another        commodity using these prices.     Declaring accounts-       account directives can be used to  pre-declare  accounts.   Though  not+       account  directives  can  be  used to pre-declare accounts.  Though not        required, they can provide several benefits:         o They can document your intended chart of accounts, providing a refer-          ence. -       o They can store extra information  about  accounts  (account  numbers,+       o They  can  store  extra  information about accounts (account numbers,          notes, etc.) -       o They  can  help  hledger know your accounts' types (asset, liability,-         equity, revenue, expense), useful for reports like  balancesheet  and+       o They can help hledger know your accounts'  types  (asset,  liability,+         equity,  revenue,  expense), useful for reports like balancesheet and          incomestatement. -       o They  control  account  display order in reports, allowing non-alpha-+       o They control account display order in  reports,  allowing  non-alpha-          betic sorting (eg Revenues to appear above Expenses). -       o They  help  with  account  name  completion  in  the   add   command,-         hledger-iadd, hledger-web, ledger-mode etc.+       o They  help  with account name completion in the add command, hledger-+         iadd, hledger-web, ledger-mode etc. -       The  simplest form is just the word account followed by a hledger-style+       The simplest form is just the word account followed by a  hledger-style        account name, eg:                account assets:bank:checking@@ -897,7 +904,7 @@        the next line instead.     Account subdirectives-       We  also  allow  (and ignore) Ledger-style indented subdirectives, just+       We also allow (and ignore) Ledger-style  indented  subdirectives,  just        for compatibility.:                account assets:bank:checking@@ -910,18 +917,18 @@                 [LEDGER-STYLE SUBDIRECTIVES, IGNORED]     Account types-       hledger recognises five types (or classes) of account:  Asset,  Liabil--       ity,  Equity, Revenue, Expense.  This is used by a few accounting-aware+       hledger  recognises  five types (or classes) of account: Asset, Liabil-+       ity, Equity, Revenue, Expense.  This is used by a few  accounting-aware        reports such as balancesheet, incomestatement and cashflow.     Auto-detected account types        If you name your top-level accounts with some variation of assets, lia--       bilities/debts,  equity,  revenues/income, or expenses, their types are+       bilities/debts, equity, revenues/income, or expenses, their  types  are        detected automatically.     Account types declared with tags-       More generally, you can declare  an  account's  type  with  an  account-       directive,  by writing a type: tag in a comment, followed by one of the+       More  generally,  you  can  declare  an  account's type with an account+       directive, by writing a type: tag in a comment, followed by one of  the        words Asset, Liability, Equity, Revenue, Expense, or one of the letters        ALERX (case insensitive): @@ -932,8 +939,8 @@               account expenses     ; type:Expenses     Account types declared with account type codes-       Or,  you can write one of those letters separated from the account name-       by two or more spaces, but this should probably  be  considered  depre-+       Or, you can write one of those letters separated from the account  name+       by  two  or  more spaces, but this should probably be considered depre-        cated as of hledger 1.13:                account assets       A@@ -943,19 +950,19 @@               account expenses     X     Overriding auto-detected types-       If  you  ever override the types of those auto-detected english account+       If you ever override the types of those auto-detected  english  account        names mentioned above, you might need to help the reports a bit.  Eg:                ; make "liabilities" not have the liability type - who knows why-              account liabilities   ; type:E+              account liabilities  ; type:E                ; we need to ensure some other account has the liability type,               ; otherwise balancesheet would still show "liabilities" under Liabilities-              account -             ; type:L+              account -            ; type:L     Account display order-       Account directives also set the order in which accounts are  displayed,-       eg  in  reports,  the  hledger-ui  accounts screen, and the hledger-web+       Account  directives also set the order in which accounts are displayed,+       eg in reports, the hledger-ui  accounts  screen,  and  the  hledger-web        sidebar.  By default accounts are listed in alphabetical order.  But if        you have these account directives in the journal: @@ -977,16 +984,16 @@         Undeclared accounts, if any, are displayed last, in alphabetical order. -       Note  that  sorting  is  done at each level of the account tree (within-       each group of sibling accounts under the same parent).  And  currently,+       Note that sorting is done at each level of  the  account  tree  (within+       each  group of sibling accounts under the same parent).  And currently,        this directive:                account other:zoo -       would  influence the position of zoo among other's subaccounts, but not-       the position of other among the top-level accounts.  This means: -  you-       will  sometimes  declare  parent accounts (eg account other above) that-       you don't intend to post to, just to customize their  display  order  -+       would influence the position of zoo among other's subaccounts, but  not+       the  position of other among the top-level accounts.  This means: - you+       will sometimes declare parent accounts (eg account  other  above)  that+       you  don't  intend  to post to, just to customize their display order -        sibling accounts stay together (you couldn't display x:y in between a:b        and a:c). @@ -1005,14 +1012,14 @@        o customising reports         Account aliases also rewrite account names in account directives.  They-       do  not  affect  account  names  being  entered  via  hledger  add   or-       hledger-web.+       do  not  affect account names being entered via hledger add or hledger-+       web.         See also Cookbook: Rewrite account names.     Basic aliases-       To  set an account alias, use the alias directive in your journal file.-       This affects all subsequent journal entries in the current file or  its+       To set an account alias, use the alias directive in your journal  file.+       This  affects all subsequent journal entries in the current file or its        included files.  The spaces around the = are optional:                alias OLD = NEW@@ -1020,54 +1027,75 @@        Or, you can use the --alias 'OLD=NEW' option on the command line.  This        affects all entries.  It's useful for trying out aliases interactively. -       OLD  and  NEW  are  case  sensitive  full  account names.  hledger will-       replace any occurrence of the old account name with the new one.   Sub-+       OLD and NEW are  case  sensitive  full  account  names.   hledger  will+       replace  any occurrence of the old account name with the new one.  Sub-        accounts are also affected.  Eg:                alias checking = assets:bank:wells fargo:checking               # rewrites "checking" to "assets:bank:wells fargo:checking", or "checking:a" to "assets:bank:wells fargo:checking:a"     Regex aliases-       There  is  also a more powerful variant that uses a regular expression,+       There is also a more powerful variant that uses a  regular  expression,        indicated by the forward slashes:                alias /REGEX/ = REPLACEMENT         or --alias '/REGEX/=REPLACEMENT'. -       REGEX is a case-insensitive regular expression.   Anywhere  it  matches-       inside  an  account name, the matched part will be replaced by REPLACE--       MENT.  If REGEX contains parenthesised match groups, these can be  ref-+       REGEX  is  a  case-insensitive regular expression.  Anywhere it matches+       inside an account name, the matched part will be replaced  by  REPLACE-+       MENT.   If REGEX contains parenthesised match groups, these can be ref-        erenced by the usual numeric backreferences in REPLACEMENT.  Eg:                alias /^(.+):bank:([^:]+)(.*)/ = \1:\2 \3               # rewrites "assets:bank:wells fargo:checking" to  "assets:wells fargo checking" -       Also  note that REPLACEMENT continues to the end of line (or on command-       line, to end of option argument), so it  can  contain  trailing  white-+       Also note that REPLACEMENT continues to the end of line (or on  command+       line,  to  end  of  option argument), so it can contain trailing white-        space. -   Multiple aliases-       You  can  define  as  many aliases as you like using directives or com--       mand-line options.  Aliases are recursive - each alias sees the  result-       of  applying  previous  ones.   (This  is  different from Ledger, where-       aliases are non-recursive by default).  Aliases are applied in the fol--       lowing order:+   Combining aliases+       You can define as many aliases as you like,  using  journal  directives+       and/or command line options. -       1. alias  directives,  most recently seen first (recent directives take-          precedence over earlier ones; directives not yet seen are ignored)+       Recursive  aliases  -  where an account name is rewritten by one alias,+       then by another alias, and so on - are allowed.  Each  alias  sees  the+       effect of previously applied aliases. -       2. alias options, in the order they appear on the command line+       In  such  cases it can be important to understand which aliases will be+       applied and in which order.  For (each account name  in)  each  journal+       entry, we apply: +       1. alias  directives  preceding the journal entry, most recently parsed+          first (ie, reading upward from the journal entry, bottom to top)++       2. --alias options, in the order they  appeared  on  the  command  line+          (left to right).++       In other words, for (an account name in) a given journal entry:++       o the nearest alias declaration before/above the entry is applied first++       o the next alias before/above that will be be applied next, and so on++       o aliases defined after/below the entry do not affect it.++       This gives nearby aliases precedence over distant ones, and helps  pro-+       vide  semantic stability - aliases will keep working the same way inde-+       pendent of which files are being read and in which order.++       In case of trouble, adding --debug=6 to  the  command  line  will  show+       which aliases are being applied when.+    end aliases-       You  can  clear  (forget)  all  currently  defined  aliases  with   the-       end aliases directive:+       You  can  clear  (forget)  all  currently  defined aliases with the end+       aliases directive:                end aliases     Default parent account-       You  can  specify  a  parent  account  which  will  be prepended to all-       accounts within a section of the journal.  Use  the  apply account  and+       You can specify a  parent  account  which  will  be  prepended  to  all+       accounts  within  a  section of the journal.  Use the apply account and        end apply account directives like so:                apply account home@@ -1084,7 +1112,7 @@                   home:food           $10                   home:cash          $-10 -       If  end apply account  is  omitted,  the effect lasts to the end of the+       If end apply account is omitted, the effect lasts to  the  end  of  the        file.  Included files are also affected, eg:                apply account business@@ -1093,18 +1121,18 @@               apply account personal               include personal.journal -       Prior to hledger 1.0, legacy account and end spellings were  also  sup-+       Prior  to  hledger 1.0, legacy account and end spellings were also sup-        ported. -       A  default parent account also affects account directives.  It does not-       affect account names being entered via hledger add or hledger-web.   If-       account  aliases are present, they are applied after the default parent+       A default parent account also affects account directives.  It does  not+       affect  account names being entered via hledger add or hledger-web.  If+       account aliases are present, they are applied after the default  parent        account.     Periodic transactions-       Periodic transaction rules  describe  transactions  that  recur.   They+       Periodic  transaction  rules  describe  transactions  that recur.  They        allow you to generate future transactions for forecasting, without hav--       ing to write them out explicitly  in  the  journal  (with  --forecast).+       ing  to  write  them  out  explicitly in the journal (with --forecast).        Secondly, they also can be used to define budget goals (with --budget).         A periodic transaction rule looks like a normal journal entry, with the@@ -1115,17 +1143,17 @@                   expenses:rent          $2000                   assets:bank:checking -       There is an additional constraint on the period expression:  the  start-       date   must   fall   on   a  natural  boundary  of  the  interval.   Eg-       monthly from 2018/1/1 is valid, but monthly from 2018/1/15 is not.+       There  is  an additional constraint on the period expression: the start+       date must fall on a natural boundary of the interval.  Eg monthly  from+       2018/1/1 is valid, but monthly from 2018/1/15 is not. -       Partial or relative dates (M/D, D, tomorrow, last week) in  the  period-       expression  can work (useful or not).  They will be relative to today's-       date, unless a Y default year directive is in  effect,  in  which  case+       Partial  or  relative dates (M/D, D, tomorrow, last week) in the period+       expression can work (useful or not).  They will be relative to  today's+       date,  unless  a  Y  default year directive is in effect, in which case        they will be relative to Y/1/1.     Two spaces after the period expression-       If  the  period  expression  is  followed by a transaction description,+       If the period expression is  followed  by  a  transaction  description,        these must be separated by two or more spaces.  This helps hledger know        where the period expression ends, so that descriptions can not acciden-        tally alter their meaning, as in this example:@@ -1138,90 +1166,104 @@                   income:acme inc     Forecasting with periodic transactions-       With the --forecast flag,  each  periodic  transaction  rule  generates+       With  the  --forecast  flag,  each  periodic transaction rule generates        future transactions recurring at the specified interval.  These are not-       saved in the journal, but appear in all reports.  They will  look  like-       normal  transactions, but with an extra tag named recur, whose value is-       the generating period expression.+       saved  in  the journal, but appear in all reports.  They will look like+       normal transactions, but with an extra tag: -       Forecast transactions start on the first occurrence,  and  end  on  the-       last  occurrence,  of  their  interval within the forecast period.  The+       o generated-transaction:~ PERIODICEXPR - shows that this was  generated+         by a periodic transaction rule, and the period++       There  is  also a hidden tag, with an underscore prefix, which does not+       appear in hledger's output:++       o _generated-transaction:~ PERIODICEXPR++       This can be used to match transactions  generated  "just  now",  rather+       than generated in the past and saved to the journal.++       Forecast  transactions  start  on  the first occurrence, and end on the+       last occurrence, of their interval within  the  forecast  period.   The        forecast period:         o begins on the later of           o the report start date if specified with -b/-p/date: -         o the day after the latest normal (non-periodic) transaction  in  the+         o the  day  after the latest normal (non-periodic) transaction in the            journal, or today if there are no normal transactions. -       o ends  on  the  report  end date if specified with -e/-p/date:, or 180+       o ends on the report end date if specified  with  -e/-p/date:,  or  180          days from today. -       where "today" means the current date at report time.   The  "later  of"-       rule  ensures that forecast transactions do not overlap normal transac-+       where  "today"  means  the current date at report time.  The "later of"+       rule ensures that forecast transactions do not overlap normal  transac-        tions in time; they will begin only after normal transactions end. -       Forecasting can be useful for estimating balances into the future,  and-       experimenting  with  different  scenarios.   Note  the start date logic+       Forecasting  can be useful for estimating balances into the future, and+       experimenting with different scenarios.   Note  the  start  date  logic        means that forecasted transactions are automatically replaced by normal        transactions as you add those.         Forecasting can also help with data entry: describe most of your trans--       actions with periodic rules, and every so  often  copy  the  output  of+       actions  with  periodic  rules,  and  every so often copy the output of        print --forecast to the journal.         You can generate one-time transactions too: just write a period expres--       sion specifying a date with no report interval.  (You could also  write-       a  normal  transaction  with  a future date, but remember this disables+       sion  specifying a date with no report interval.  (You could also write+       a normal transaction with a future date,  but  remember  this  disables        forecast transactions on previous dates.)     Budgeting with periodic transactions-       With the --budget flag, currently supported  by  the  balance  command,-       each  periodic transaction rule declares recurring budget goals for the-       specified accounts.  Eg the first example  above  declares  a  goal  of-       spending  $2000  on  rent  (and  also,  a goal of depositing $2000 into-       checking) every month.  Goals and actual performance can then  be  com-+       With  the  --budget  flag,  currently supported by the balance command,+       each periodic transaction rule declares recurring budget goals for  the+       specified  accounts.   Eg  the  first  example above declares a goal of+       spending $2000 on rent (and also,  a  goal  of  depositing  $2000  into+       checking)  every  month.  Goals and actual performance can then be com-        pared in budget reports. -       For  more  details, see: balance: Budget report and Cookbook: Budgeting+       For more details, see: balance: Budget report and  Cookbook:  Budgeting        and Forecasting.  -   Transaction modifiers-       Transaction modifier rules describe  changes  that  should  be  applied-       automatically  to  certain  transactions.  They can be enabled by using-       the --auto flag.  Currently, just  one  kind  of  change  is  possible:-       adding  extra  postings.   These  rule-generated  postings are known as-       "automated postings" or "auto postings".+   Auto postings / transaction modifiers+       Transaction modifier rules, AKA auto posting rules, describe changes to+       be applied automatically to certain  matched  transactions.   Currently+       just  one  kind of change is possible - adding extra postings, which we+       call "automated postings" or just "auto postings".  These rules  become+       active when you use the --auto flag. -       A transaction modifier rule looks  quite  like  a  normal  transaction,-       except  the  first  line  is  an  equals  sign followed by a query that-       matches certain postings (mnemonic: =  suggests  matching).   And  each-       "posting" is actually a posting-generating rule:+       A transaction modifier rule looks much like a normal transaction except+       the first line is an equals sign followed by a query that matches  cer-+       tain  postings  (mnemonic: = suggests matching).  And each "posting" is+       actually a posting-generating rule:                = QUERY                   ACCT  AMT                   ACCT  [AMT]                   ... -       These  posting  rules  look like normal postings, except the amount can-       be:+       These posting-generating rules look like normal  postings,  except  the+       amount can be: -       o a normal amount with a commodity symbol, eg $2.  This  will  be  used+       o a  normal  amount  with a commodity symbol, eg $2.  This will be used          as-is.         o a number, eg 2.  The commodity symbol (if any) from the matched post-          ing will be added to this. -       o a numeric multiplier, eg *2 (a star followed by  a  number  N).   The+       o a  numeric  multiplier,  eg  *2 (a star followed by a number N).  The          matched posting's amount (and total price, if any) will be multiplied          by N. -       o a multiplier with a commodity symbol, eg *$2 (a star, number  N,  and+       o a  multiplier  with a commodity symbol, eg *$2 (a star, number N, and          symbol S).  The matched posting's amount will be multiplied by N, and          its commodity symbol will be replaced with S. +       These rules have global effect - a rule appearing anywhere in your data+       can potentially affect any transaction, including transactions recorded+       above it or in another file.+        Some examples:                ; every time I buy food, schedule a dollar donation@@ -1253,9 +1295,13 @@                   assets:checking:gifts     -$20                   assets:checking            $20 -   Auto postings and transaction balancing / inferred amounts / balance-       assertions+   Auto postings and dates+       A  posting  date (or secondary date) in the matched posting, or (taking+       precedence) a posting date in the auto posting rule itself,  will  also+       be used in the generated posting. +   Auto postings and transaction balancing / inferred amounts / balance asser-+       tions        Currently, transaction modifiers are applied / auto postings are added:         o after  missing amounts are inferred, and transactions are checked for@@ -1267,19 +1313,37 @@        after auto postings are added.  This changed in hledger 1.12+; see #893        for background. +   Auto posting tags+       Postings added by transaction modifiers will have some extra tags:++       o generated-posting:= QUERY - shows this was generated by an auto post-+         ing rule, and the query++       o _generated-posting:=  QUERY  - a hidden tag, which does not appear in+         hledger's output.  This can be used to match postings generated "just+         now", rather than generated in the past and saved to the journal.++       Also,  any  transaction  that  has been changed by transaction modifier+       rules will have these tags added:++       o modified: - this transaction was modified++       o _modified: - a hidden tag not appearing in the comment; this transac-+         tion was modified "just now".+ EDITOR SUPPORT-       Helper modes exist for popular text editors, which  make  working  with+       Helper  modes  exist  for popular text editors, which make working with        journal files easier.  They add colour, formatting, tab completion, and-       helpful commands, and are quite recommended if you  edit  your  journal-       with  a  text  editor.   They  include  ledger-mode or hledger-mode for-       Emacs, vim-ledger for Vim, hledger-vscode for Visual Studio  Code,  and-       others.   See  the  [[Cookbook]] at hledger.org for the latest informa-+       helpful  commands,  and  are quite recommended if you edit your journal+       with a text editor.   They  include  ledger-mode  or  hledger-mode  for+       Emacs,  vim-ledger  for Vim, hledger-vscode for Visual Studio Code, and+       others.  See the [[Cookbook]] at hledger.org for  the  latest  informa-        tion.    REPORTING BUGS-       Report bugs at http://bugs.hledger.org (or on the #hledger IRC  channel+       Report  bugs at http://bugs.hledger.org (or on the #hledger IRC channel        or hledger mail list)  @@ -1293,7 +1357,7 @@   SEE ALSO-       hledger(1),      hledger-ui(1),     hledger-web(1),     hledger-api(1),+       hledger(1),     hledger-ui(1),     hledger-web(1),      hledger-api(1),        hledger_csv(5), hledger_journal(5), hledger_timeclock(5), hledger_time-        dot(5), ledger(1) @@ -1301,4 +1365,4 @@   -hledger 1.14                      March 2019                hledger_journal(5)+hledger 1.15                      August 2019               hledger_journal(5)
embeddedfiles/hledger_timeclock.5 view
@@ -1,74 +1,74 @@ -.TH "hledger_timeclock" "5" "March 2019" "hledger 1.14" "hledger User Manuals"+.TH "hledger_timeclock" "5" "August 2019" "hledger 1.15" "hledger User Manuals"    .SH NAME .PP-Timeclock \- the time logging format of timeclock.el, as read by hledger+Timeclock - the time logging format of timeclock.el, as read by hledger .SH DESCRIPTION .PP hledger can read timeclock files. As with Ledger, these are (a subset of) timeclock.el\[aq]s format,-containing clock\-in and clock\-out entries as in the example below.+containing clock-in and clock-out entries as in the example below. The date is a simple date.-The time format is HH:MM[:SS][+\-ZZZZ].+The time format is HH:MM[:SS][+-ZZZZ]. Seconds and timezone are optional. The timezone, if present, must be four digits and is ignored (currently the time is always interpreted as a local time). .IP .nf \f[C]-i\ 2015/03/30\ 09:00:00\ some:account\ name\ \ optional\ description\ after\ two\ spaces-o\ 2015/03/30\ 09:20:00-i\ 2015/03/31\ 22:21:45\ another\ account-o\ 2015/04/01\ 02:00:34-\f[]+i 2015/03/30 09:00:00 some:account name  optional description after two spaces+o 2015/03/30 09:20:00+i 2015/03/31 22:21:45 another account+o 2015/04/01 02:00:34+\f[R] .fi .PP-hledger treats each clock\-in/clock\-out pair as a transaction posting+hledger treats each clock-in/clock-out pair as a transaction posting some number of hours to an account. Or if the session spans more than one day, it is split into several transactions, one for each day.-For the above time log, \f[C]hledger\ print\f[] generates these journal+For the above time log, \f[C]hledger print\f[R] generates these journal entries: .IP .nf \f[C]-$\ hledger\ \-f\ t.timeclock\ print-2015/03/30\ *\ optional\ description\ after\ two\ spaces-\ \ \ \ (some:account\ name)\ \ \ \ \ \ \ \ \ 0.33h+$ hledger -f t.timeclock print+2015/03/30 * optional description after two spaces+    (some:account name)         0.33h -2015/03/31\ *\ 22:21\-23:59-\ \ \ \ (another\ account)\ \ \ \ \ \ \ \ \ 1.64h+2015/03/31 * 22:21-23:59+    (another account)         1.64h -2015/04/01\ *\ 00:00\-02:00-\ \ \ \ (another\ account)\ \ \ \ \ \ \ \ \ 2.01h-\f[]+2015/04/01 * 00:00-02:00+    (another account)         2.01h+\f[R] .fi .PP Here is a sample.timeclock to download and some queries to try: .IP .nf \f[C]-$\ hledger\ \-f\ sample.timeclock\ balance\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ current\ time\ balances-$\ hledger\ \-f\ sample.timeclock\ register\ \-p\ 2009/3\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ sessions\ in\ march\ 2009-$\ hledger\ \-f\ sample.timeclock\ register\ \-p\ weekly\ \-\-depth\ 1\ \-\-empty\ \ #\ time\ summary\ by\ week-\f[]+$ hledger -f sample.timeclock balance                               # current time balances+$ hledger -f sample.timeclock register -p 2009/3                    # sessions in march 2009+$ hledger -f sample.timeclock register -p weekly --depth 1 --empty  # time summary by week+\f[R] .fi .PP To generate time logs, ie to clock in and clock out, you could: .IP \[bu] 2-use emacs and the built\-in timeclock.el, or the extended-timeclock\-x.el and perhaps the extras in ledgerutils.el+use emacs and the built-in timeclock.el, or the extended timeclock-x.el+and perhaps the extras in ledgerutils.el .IP \[bu] 2 at the command line, use these bash aliases:-\f[C]shell\ \ \ alias\ ti="echo\ i\ `date\ \[aq]+%Y\-%m\-%d\ %H:%M:%S\[aq]`\ \\$*\ >>$TIMELOG"\ \ \ alias\ to="echo\ o\ `date\ \[aq]+%Y\-%m\-%d\ %H:%M:%S\[aq]`\ >>$TIMELOG"\f[]+\f[C]shell   alias ti=\[dq]echo i \[ga]date \[aq]+%Y-%m-%d %H:%M:%S\[aq]\[ga] \[rs]$* >>$TIMELOG\[dq]   alias to=\[dq]echo o \[ga]date \[aq]+%Y-%m-%d %H:%M:%S\[aq]\[ga] >>$TIMELOG\[dq]\f[R] .IP \[bu] 2-or use the old \f[C]ti\f[] and \f[C]to\f[] scripts in the ledger 2.x+or use the old \f[C]ti\f[R] and \f[C]to\f[R] scripts in the ledger 2.x repository.-These rely on a "timeclock" executable which I think is just the ledger-2 executable renamed.+These rely on a \[dq]timeclock\[dq] executable which I think is just the+ledger 2 executable renamed.   .SH "REPORTING BUGS"
embeddedfiles/hledger_timeclock.info view
@@ -4,7 +4,7 @@  File: hledger_timeclock.info,  Node: Top,  Up: (dir) -hledger_timeclock(5) hledger 1.14+hledger_timeclock(5) hledger 1.15 *********************************  hledger can read timeclock files.  As with Ledger, these are (a subset@@ -48,6 +48,7 @@    * at the command line, use these bash aliases: 'shell alias ti="echo      i `date '+%Y-%m-%d %H:%M:%S'` \$* >>$TIMELOG" alias to="echo o      `date '+%Y-%m-%d %H:%M:%S'` >>$TIMELOG"'+    * or use the old 'ti' and 'to' scripts in the ledger 2.x repository.      These rely on a "timeclock" executable which I think is just the      ledger 2 executable renamed.
embeddedfiles/hledger_timeclock.txt view
@@ -42,11 +42,12 @@         To generate time logs, ie to clock in and clock out, you could: -       o use emacs and  the  built-in  timeclock.el,  or  the  extended  time--         clock-x.el and perhaps the extras in ledgerutils.el+       o use emacs and the built-in timeclock.el, or the  extended  timeclock-+         x.el and perhaps the extras in ledgerutils.el -       o at     the     command     line,     use    these    bash    aliases:-         shell   alias ti="echo i `date '+%Y-%m-%d %H:%M:%S'` \$* >>$TIMELOG"   alias to="echo o `date '+%Y-%m-%d %H:%M:%S'` >>$TIMELOG"+       o at the command line, use these bash aliases: shell   alias ti="echo i+         `date '+%Y-%m-%d %H:%M:%S'` \$* >>$TIMELOG"   alias to="echo o  `date+         '+%Y-%m-%d %H:%M:%S'` >>$TIMELOG"         o or use the old ti and to scripts in the ledger 2.x repository.  These          rely on a "timeclock" executable which I think is just the  ledger  2@@ -77,4 +78,4 @@   -hledger 1.14                      March 2019              hledger_timeclock(5)+hledger 1.15                      August 2019             hledger_timeclock(5)
embeddedfiles/hledger_timedot.5 view
@@ -1,32 +1,32 @@ -.TH "hledger_timedot" "5" "March 2019" "hledger 1.14" "hledger User Manuals"+.TH "hledger_timedot" "5" "August 2019" "hledger 1.15" "hledger User Manuals"    .SH NAME .PP-Timedot \- hledger\[aq]s human\-friendly time logging format+Timedot - hledger\[aq]s human-friendly time logging format .SH DESCRIPTION .PP Timedot is a plain text format for logging dated, categorised quantities (of time, usually), supported by hledger. It is convenient for approximate and retroactive time logging, eg when-the real\-time clock\-in/out required with a timeclock file is too-precise or too interruptive.+the real-time clock-in/out required with a timeclock file is too precise+or too interruptive. It can be formatted like a bar chart, making clear at a glance where time was spent. .PP-Though called "timedot", this format is read by hledger as commodityless-quantities, so it could be used to represent dated quantities other than-time.+Though called \[dq]timedot\[dq], this format is read by hledger as+commodityless quantities, so it could be used to represent dated+quantities other than time. In the docs below we\[aq]ll assume it\[aq]s time. .SH FILE FORMAT .PP A timedot file contains a series of day entries. A day entry begins with a date, and is followed by category/quantity pairs, one per line.-Dates are hledger\-style simple dates (see hledger_journal(5)).-Categories are hledger\-style account names, optionally indented.+Dates are hledger-style simple dates (see hledger_journal(5)).+Categories are hledger-style account names, optionally indented. As in a hledger journal, there must be at least two spaces between the category (account name) and the quantity. .PP@@ -41,9 +41,9 @@ Eg: 1.5 .IP \[bu] 2 an integral or decimal number immediately followed by a unit symbol-\f[C]s\f[], \f[C]m\f[], \f[C]h\f[], \f[C]d\f[], \f[C]w\f[], \f[C]mo\f[],-or \f[C]y\f[], representing seconds, minutes, hours, days weeks, months-or years respectively.+\f[C]s\f[R], \f[C]m\f[R], \f[C]h\f[R], \f[C]d\f[R], \f[C]w\f[R],+\f[C]mo\f[R], or \f[C]y\f[R], representing seconds, minutes, hours, days+weeks, months or years respectively. Eg: 90m. The following equivalencies are assumed, currently: 1m = 60s, 1h = 60m, 1d = 24h, 1w = 7d, 1mo = 30d, 1y=365d.@@ -53,16 +53,16 @@ .IP .nf \f[C]-#\ on\ this\ day,\ 6h\ was\ spent\ on\ client\ work,\ 1.5h\ on\ haskell\ FOSS\ work,\ etc.+# on this day, 6h was spent on client work, 1.5h on haskell FOSS work, etc. 2016/2/1-inc:client1\ \ \ ....\ ....\ ....\ ....\ ....\ ....-fos:haskell\ \ \ ....\ ..\ -biz:research\ \ .+inc:client1   .... .... .... .... .... ....+fos:haskell   .... .. +biz:research  .  2016/2/2-inc:client1\ \ \ ....\ ....-biz:research\ \ .-\f[]+inc:client1   .... ....+biz:research  .+\f[R] .fi .PP Or with numbers:@@ -70,42 +70,42 @@ .nf \f[C] 2016/2/3-inc:client1\ \ \ 4-fos:hledger\ \ \ 3-biz:research\ \ 1-\f[]+inc:client1   4+fos:hledger   3+biz:research  1+\f[R] .fi .PP Reporting: .IP .nf \f[C]-$\ hledger\ \-f\ t.timedot\ print\ date:2016/2/2-2016/02/02\ *-\ \ \ \ (inc:client1)\ \ \ \ \ \ \ \ \ \ 2.00+$ hledger -f t.timedot print date:2016/2/2+2016/02/02 *+    (inc:client1)          2.00 -2016/02/02\ *-\ \ \ \ (biz:research)\ \ \ \ \ \ \ \ \ \ 0.25-\f[]+2016/02/02 *+    (biz:research)          0.25+\f[R] .fi .IP .nf \f[C]-$\ hledger\ \-f\ t.timedot\ bal\ \-\-daily\ \-\-tree-Balance\ changes\ in\ 2016/02/01\-2016/02/03:+$ hledger -f t.timedot bal --daily --tree+Balance changes in 2016/02/01-2016/02/03: -\ \ \ \ \ \ \ \ \ \ \ \ ||\ \ 2016/02/01d\ \ 2016/02/02d\ \ 2016/02/03d\ +            ||  2016/02/01d  2016/02/02d  2016/02/03d  ============++========================================-\ biz\ \ \ \ \ \ \ \ ||\ \ \ \ \ \ \ \ \ 0.25\ \ \ \ \ \ \ \ \ 0.25\ \ \ \ \ \ \ \ \ 1.00\ -\ \ \ research\ ||\ \ \ \ \ \ \ \ \ 0.25\ \ \ \ \ \ \ \ \ 0.25\ \ \ \ \ \ \ \ \ 1.00\ -\ fos\ \ \ \ \ \ \ \ ||\ \ \ \ \ \ \ \ \ 1.50\ \ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ 3.00\ -\ \ \ haskell\ \ ||\ \ \ \ \ \ \ \ \ 1.50\ \ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ \ \ 0\ -\ \ \ hledger\ \ ||\ \ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ 3.00\ -\ inc\ \ \ \ \ \ \ \ ||\ \ \ \ \ \ \ \ \ 6.00\ \ \ \ \ \ \ \ \ 2.00\ \ \ \ \ \ \ \ \ 4.00\ -\ \ \ client1\ \ ||\ \ \ \ \ \ \ \ \ 6.00\ \ \ \ \ \ \ \ \ 2.00\ \ \ \ \ \ \ \ \ 4.00\ -\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ \ \ \ \ 7.75\ \ \ \ \ \ \ \ \ 2.25\ \ \ \ \ \ \ \ \ 8.00\ -\f[]+ biz        ||         0.25         0.25         1.00 +   research ||         0.25         0.25         1.00 + fos        ||         1.50            0         3.00 +   haskell  ||         1.50            0            0 +   hledger  ||            0            0         3.00 + inc        ||         6.00         2.00         4.00 +   client1  ||         6.00         2.00         4.00 +------------++----------------------------------------+            ||         7.75         2.25         8.00 +\f[R] .fi .PP I prefer to use period for separating account components.@@ -114,20 +114,20 @@ .nf \f[C] 2016/2/4-fos.hledger.timedot\ \ 4-fos.ledger\ \ \ \ \ \ \ \ \ \ \ ..-\f[]+fos.hledger.timedot  4+fos.ledger           ..+\f[R] .fi .IP .nf \f[C]-$\ hledger\ \-f\ t.timedot\ \-\-alias\ /\\\\./=:\ bal\ date:2016/2/4-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 4.50\ \ fos-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 4.00\ \ \ \ hledger:timedot-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0.50\ \ \ \ ledger-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 4.50-\f[]+$ hledger -f t.timedot --alias /\[rs]\[rs]./=: bal date:2016/2/4+                4.50  fos+                4.00    hledger:timedot+                0.50    ledger+--------------------+                4.50+\f[R] .fi .PP Here is a sample.timedot.
embeddedfiles/hledger_timedot.info view
@@ -4,7 +4,7 @@  File: hledger_timedot.info,  Node: Top,  Next: FILE FORMAT,  Up: (dir) -hledger_timedot(5) hledger 1.14+hledger_timedot(5) hledger 1.15 *******************************  Timedot is a plain text format for logging dated, categorised quantities@@ -17,6 +17,7 @@    Though called "timedot", this format is read by hledger as commodityless quantities, so it could be used to represent dated quantities other than time.  In the docs below we'll assume it's time.+ * Menu:  * FILE FORMAT::@@ -110,7 +111,7 @@  Tag Table: Node: Top76-Node: FILE FORMAT807-Ref: #file-format908+Node: FILE FORMAT808+Ref: #file-format909  End Tag Table
embeddedfiles/hledger_timedot.txt view
@@ -9,10 +9,10 @@ DESCRIPTION        Timedot  is  a plain text format for logging dated, categorised quanti-        ties (of time, usually), supported by hledger.  It  is  convenient  for-       approximate  and  retroactive  time  logging,  eg  when  the  real-time-       clock-in/out required with a timeclock  file  is  too  precise  or  too-       interruptive.   It can be formatted like a bar chart, making clear at a-       glance where time was spent.+       approximate  and retroactive time logging, eg when the real-time clock-+       in/out required with a timeclock file is too precise or  too  interrup-+       tive.   It  can be formatted like a bar chart, making clear at a glance+       where time was spent.         Though called "timedot", this format is read by hledger  as  commodity-        less  quantities,  so  it  could  be used to represent dated quantities@@ -124,4 +124,4 @@   -hledger 1.14                      March 2019                hledger_timedot(5)+hledger 1.15                      August 2019               hledger_timedot(5)
hledger.1 view
@@ -1,3257 +1,3589 @@ .\"t -.TH "hledger" "1" "March 2019" "hledger 1.14" "hledger User Manuals"----.SH NAME-.PP-hledger \- a command\-line accounting tool-.SH SYNOPSIS-.PP-\f[C]hledger\ [\-f\ FILE]\ COMMAND\ [OPTIONS]\ [ARGS]\f[]-.PD 0-.P-.PD-\f[C]hledger\ [\-f\ FILE]\ ADDONCMD\ \-\-\ [OPTIONS]\ [ARGS]\f[]-.PD 0-.P-.PD-\f[C]hledger\f[]-.SH DESCRIPTION-.PP-hledger is a cross\-platform program for tracking money, time, or any-other commodity, using double\-entry accounting and a simple, editable-file format.-hledger is inspired by and largely compatible with ledger(1).-.PD 0-.P-.PD-Tested on unix, mac, windows, hledger aims to be a reliable, practical-tool for daily use.-.PP-This is hledger's command\-line interface (there are also curses and web-interfaces).-Its basic function is to read a plain text file describing financial-transactions (in accounting terms, a general journal) and print useful-reports on standard output, or export them as CSV.-hledger can also read some other file formats such as CSV files,-translating them to journal format.-Additionally, hledger lists other hledger\-* executables found in the-user's $PATH and can invoke them as subcommands.-.PP-hledger reads data from one or more files in hledger journal, timeclock,-timedot, or CSV format specified with \f[C]\-f\f[], or-\f[C]$LEDGER_FILE\f[], or \f[C]$HOME/.hledger.journal\f[] (on windows,-perhaps \f[C]C:/Users/USER/.hledger.journal\f[]).-If using \f[C]$LEDGER_FILE\f[], note this must be a real environment-variable, not a shell variable.-You can specify standard input with \f[C]\-f\-\f[].-.PP-Transactions are dated movements of money between two (or more) named-accounts, and are recorded with journal entries like this:-.IP-.nf-\f[C]-2015/10/16\ bought\ food-\ expenses:food\ \ \ \ \ \ \ \ \ \ $10-\ assets:cash-\f[]-.fi-.PP-For more about this format, see hledger_journal(5).-.PP-Most users use a text editor to edit the journal, usually with an editor-mode such as ledger\-mode for added convenience.-hledger's interactive add command is another way to record new-transactions.-hledger never changes existing transactions.-.PP-To get started, you can either save some entries like the above in-\f[C]~/.hledger.journal\f[], or run \f[C]hledger\ add\f[] and follow the-prompts.-Then try some commands like \f[C]hledger\ print\f[] or-\f[C]hledger\ balance\f[].-Run \f[C]hledger\f[] with no arguments for a list of commands.-.SH EXAMPLES-.PP-Two simple transactions in hledger journal format:-.IP-.nf-\f[C]-2015/9/30\ gift\ received-\ \ assets:cash\ \ \ $20-\ \ income:gifts--2015/10/16\ farmers\ market-\ \ expenses:food\ \ \ \ $10-\ \ assets:cash-\f[]-.fi-.PP-Some basic reports:-.IP-.nf-\f[C]-$\ hledger\ print-2015/09/30\ gift\ received-\ \ \ \ assets:cash\ \ \ \ \ \ \ \ \ \ \ \ $20-\ \ \ \ income:gifts\ \ \ \ \ \ \ \ \ \ $\-20--2015/10/16\ farmers\ market-\ \ \ \ expenses:food\ \ \ \ \ \ \ \ \ \ \ $10-\ \ \ \ assets:cash\ \ \ \ \ \ \ \ \ \ \ \ $\-10-\f[]-.fi-.IP-.nf-\f[C]-$\ hledger\ accounts\ \-\-tree-assets-\ \ cash-expenses-\ \ food-income-\ \ gifts-\f[]-.fi-.IP-.nf-\f[C]-$\ hledger\ balance-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $10\ \ assets:cash-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $10\ \ expenses:food-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-20\ \ income:gifts-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0-\f[]-.fi-.IP-.nf-\f[C]-$\ hledger\ register\ cash-2015/09/30\ gift\ received\ \ \ assets:cash\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $20\ \ \ \ \ \ \ \ \ \ \ $20-2015/10/16\ farmers\ market\ \ assets:cash\ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-10\ \ \ \ \ \ \ \ \ \ \ $10-\f[]-.fi-.PP-More commands:-.IP-.nf-\f[C]-$\ hledger\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ show\ available\ commands-$\ hledger\ add\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ add\ more\ transactions\ to\ the\ journal\ file-$\ hledger\ balance\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ all\ accounts\ with\ aggregated\ balances-$\ hledger\ balance\ \-\-help\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ show\ detailed\ help\ for\ balance\ command-$\ hledger\ balance\ \-\-depth\ 1\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ only\ top\-level\ accounts-$\ hledger\ register\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ show\ account\ postings,\ with\ running\ total-$\ hledger\ reg\ income\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ show\ postings\ to/from\ income\ accounts-$\ hledger\ reg\ \[aq]assets:some\ bank:checking\[aq]\ #\ show\ postings\ to/from\ this\ checking\ account-$\ hledger\ print\ desc:shop\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ show\ transactions\ with\ shop\ in\ the\ description-$\ hledger\ activity\ \-W\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ show\ transaction\ counts\ per\ week\ as\ a\ bar\ chart-\f[]-.fi-.SH OPTIONS-.SS General options-.PP-To see general usage help, including general options which are supported-by most hledger commands, run \f[C]hledger\ \-h\f[].-.PP-General help options:-.TP-.B \f[C]\-h\ \-\-help\f[]-show general usage (or after COMMAND, command usage)-.RS-.RE-.TP-.B \f[C]\-\-version\f[]-show version-.RS-.RE-.TP-.B \f[C]\-\-debug[=N]\f[]-show debug output (levels 1\-9, default: 1)-.RS-.RE-.PP-General input options:-.TP-.B \f[C]\-f\ FILE\ \-\-file=FILE\f[]-use a different input file.-For stdin, use \- (default: \f[C]$LEDGER_FILE\f[] or-\f[C]$HOME/.hledger.journal\f[])-.RS-.RE-.TP-.B \f[C]\-\-rules\-file=RULESFILE\f[]-Conversion rules file to use when reading CSV (default: FILE.rules)-.RS-.RE-.TP-.B \f[C]\-\-separator=CHAR\f[]-Field separator to expect when reading CSV (default: \[aq],\[aq])-.RS-.RE-.TP-.B \f[C]\-\-alias=OLD=NEW\f[]-rename accounts named OLD to NEW-.RS-.RE-.TP-.B \f[C]\-\-anon\f[]-anonymize accounts and payees-.RS-.RE-.TP-.B \f[C]\-\-pivot\ FIELDNAME\f[]-use some other field or tag for the account name-.RS-.RE-.TP-.B \f[C]\-I\ \-\-ignore\-assertions\f[]-ignore any failing balance assertions-.RS-.RE-.PP-General reporting options:-.TP-.B \f[C]\-b\ \-\-begin=DATE\f[]-include postings/txns on or after this date-.RS-.RE-.TP-.B \f[C]\-e\ \-\-end=DATE\f[]-include postings/txns before this date-.RS-.RE-.TP-.B \f[C]\-D\ \-\-daily\f[]-multiperiod/multicolumn report by day-.RS-.RE-.TP-.B \f[C]\-W\ \-\-weekly\f[]-multiperiod/multicolumn report by week-.RS-.RE-.TP-.B \f[C]\-M\ \-\-monthly\f[]-multiperiod/multicolumn report by month-.RS-.RE-.TP-.B \f[C]\-Q\ \-\-quarterly\f[]-multiperiod/multicolumn report by quarter-.RS-.RE-.TP-.B \f[C]\-Y\ \-\-yearly\f[]-multiperiod/multicolumn report by year-.RS-.RE-.TP-.B \f[C]\-p\ \-\-period=PERIODEXP\f[]-set start date, end date, and/or reporting interval all at once using-period expressions syntax (overrides the flags above)-.RS-.RE-.TP-.B \f[C]\-\-date2\f[]-match the secondary date instead (see command help for other effects)-.RS-.RE-.TP-.B \f[C]\-U\ \-\-unmarked\f[]-include only unmarked postings/txns (can combine with \-P or \-C)-.RS-.RE-.TP-.B \f[C]\-P\ \-\-pending\f[]-include only pending postings/txns-.RS-.RE-.TP-.B \f[C]\-C\ \-\-cleared\f[]-include only cleared postings/txns-.RS-.RE-.TP-.B \f[C]\-R\ \-\-real\f[]-include only non\-virtual postings-.RS-.RE-.TP-.B \f[C]\-NUM\ \-\-depth=NUM\f[]-hide/aggregate accounts or postings more than NUM levels deep-.RS-.RE-.TP-.B \f[C]\-E\ \-\-empty\f[]-show items with zero amount, normally hidden (and vice\-versa in-hledger\-ui/hledger\-web)-.RS-.RE-.TP-.B \f[C]\-B\ \-\-cost\f[]-convert amounts to their cost at transaction time (using the transaction-price, if any)-.RS-.RE-.TP-.B \f[C]\-V\ \-\-value\f[]-convert amounts to their market value on the report end date (using the-most recent applicable market price, if any)-.RS-.RE-.TP-.B \f[C]\-\-auto\f[]-apply automated posting rules to modify transactions.-.RS-.RE-.TP-.B \f[C]\-\-forecast\f[]-apply periodic transaction rules to generate future transactions, to 6-months from now or report end date.-.RS-.RE-.PP-When a reporting option appears more than once in the command line, the-last one takes precedence.-.PP-Some reporting options can also be written as query arguments.-.SS Command options-.PP-To see options for a particular command, including command\-specific-options, run: \f[C]hledger\ COMMAND\ \-h\f[].-.PP-Command\-specific options must be written after the command name, eg:-\f[C]hledger\ print\ \-x\f[].-.PP-Additionally, if the command is an addon, you may need to put its-options after a double\-hyphen, eg:-\f[C]hledger\ ui\ \-\-\ \-\-watch\f[].-Or, you can run the addon executable directly:-\f[C]hledger\-ui\ \-\-watch\f[].-.SS Command arguments-.PP-Most hledger commands accept arguments after the command name, which are-often a query, filtering the data in some way.-.SS Argument files-.PP-You can save a set of command line options/arguments in a file, one per-line, and then reuse them by writing \f[C]\@FILENAME\f[] in a command-line.-To prevent this expansion of \f[C]\@\f[]\-arguments, precede them with a-\f[C]\-\-\f[] argument.-For more, see Save frequently used options.-.SS Special characters in arguments and queries-.PP-In shell command lines, option and argument values which contain-"problematic" characters, ie spaces, and also characters significant to-your shell such as \f[C]<\f[], \f[C]>\f[], \f[C](\f[], \f[C])\f[],-\f[C]|\f[] and \f[C]$\f[], should be escaped by enclosing them in quotes-or by writing backslashes before the characters.-Eg:-.PP-\f[C]hledger\ register\ \-p\ \[aq]last\ year\[aq]\ "accounts\ receivable\ (receivable|payable)"\ amt:\\>100\f[].-.SS More escaping-.PP-Characters significant both to the shell and in regular expressions may-need one extra level of escaping.-These include parentheses, the pipe symbol and the dollar sign.-Eg, to match the dollar symbol, bash users should do:-.PP-\f[C]hledger\ balance\ cur:\[aq]\\$\[aq]\f[]-.PP-or:-.PP-\f[C]hledger\ balance\ cur:\\\\$\f[]-.SS Even more escaping-.PP-When hledger runs an addon executable (eg you type \f[C]hledger\ ui\f[],-hledger runs \f[C]hledger\-ui\f[]), it de\-escapes command\-line options-and arguments once, so you might need to \f[I]triple\f[]\-escape.-Eg in bash, running the ui command and matching the dollar sign,-it\[aq]s:-.PP-\f[C]hledger\ ui\ cur:\[aq]\\\\$\[aq]\f[]-.PP-or:-.PP-\f[C]hledger\ ui\ cur:\\\\\\\\$\f[]-.PP-If you asked why \f[I]four\f[] slashes above, this may help:-.PP-.TS-tab(@);-l l.-T{-unescaped:-T}@T{-\f[C]$\f[]-T}-T{-escaped:-T}@T{-\f[C]\\$\f[]-T}-T{-double\-escaped:-T}@T{-\f[C]\\\\$\f[]-T}-T{-triple\-escaped:-T}@T{-\f[C]\\\\\\\\$\f[]-T}-.TE-.PP-(The number of backslashes in fish shell is left as an exercise for the-reader.)-.PP-You can always avoid the extra escaping for addons by running the addon-directly:-.PP-\f[C]hledger\-ui\ cur:\\\\$\f[]-.SS Less escaping-.PP-Inside an argument file, or in the search field of hledger\-ui or-hledger\-web, or at a GHCI prompt, you need one less level of escaping-than at the command line.-And backslashes may work better than quotes.-Eg:-.PP-\f[C]ghci>\ :main\ balance\ cur:\\$\f[]-.SS Command line tips-.PP-If in doubt, keep things simple:-.IP \[bu] 2-write options after the command (\f[C]hledger\ CMD\ \-OPTIONS\ ARGS\f[])-.IP \[bu] 2-run add\-on executables directly (\f[C]hledger\-ui\ \-OPTIONS\ ARGS\f[])-.IP \[bu] 2-enclose problematic args in single quotes-.IP \[bu] 2-if needed, also add a backslash to escape regexp metacharacters-.PP-To find out exactly how a command line is being parsed, add-\f[C]\-\-debug=2\f[] to troubleshoot.-.SS Unicode characters-.PP-hledger is expected to handle unicode (non\-ascii) characters, but this-requires a well\-configured environment.-.PP-To handle unicode characters in the command line or input data, a system-locale that can decode them must be configured (POSIX\[aq]s default-\f[C]C\f[] locale will not work).-Eg in bash, you could do:-.IP-.nf-\f[C]-export\ LANG=en_US.UTF\-8-\f[]-.fi-.PP-See Troubleshooting for more about this.-.PP-Unicode characters should appear correctly in hledger\[aq]s output.-For the hledger and hledger\-ui tools, this requires that-.IP \[bu] 2-your terminal supports unicode-.IP \[bu] 2-the terminal\[aq]s font includes the required unicode glyphs-.IP \[bu] 2-the terminal is configured to display "wide" characters as double width-(otherwise report alignment will be off)-.SS Input files-.PP-hledger reads transactions from a data file (and the add command writes-to it).-By default this file is \f[C]$HOME/.hledger.journal\f[] (or on Windows,-something like \f[C]C:/Users/USER/.hledger.journal\f[]).-You can override this with the \f[C]$LEDGER_FILE\f[] environment-variable:-.IP-.nf-\f[C]-$\ setenv\ LEDGER_FILE\ ~/finance/2016.journal-$\ hledger\ stats-\f[]-.fi-.PP-or with the \f[C]\-f/\-\-file\f[] option:-.IP-.nf-\f[C]-$\ hledger\ \-f\ /some/file\ stats-\f[]-.fi-.PP-The file name \f[C]\-\f[] (hyphen) means standard input:-.IP-.nf-\f[C]-$\ cat\ some.journal\ |\ hledger\ \-f\--\f[]-.fi-.PP-Usually the data file is in hledger\[aq]s journal format, but it can-also be one of several other formats, listed below.-hledger detects the format automatically based on the file extension, or-if that is not recognised, by trying each built\-in "reader" in turn:-.PP-.TS-tab(@);-lw(10.3n) lw(33.5n) lw(26.2n).-T{-Reader:-T}@T{-Reads:-T}@T{-Used for file extensions:-T}-_-T{-\f[C]journal\f[]-T}@T{-hledger\[aq]s journal format, also some Ledger journals-T}@T{-\f[C]\&.journal\f[] \f[C]\&.j\f[] \f[C]\&.hledger\f[] \f[C]\&.ledger\f[]-T}-T{-\f[C]timeclock\f[]-T}@T{-timeclock files (precise time logging)-T}@T{-\f[C]\&.timeclock\f[]-T}-T{-\f[C]timedot\f[]-T}@T{-timedot files (approximate time logging)-T}@T{-\f[C]\&.timedot\f[]-T}-T{-\f[C]csv\f[]-T}@T{-comma\-separated values (data interchange)-T}@T{-\f[C]\&.csv\f[]-T}-.TE-.PP-If needed (eg to ensure correct error messages when a file has the-"wrong" extension), you can force a specific reader/format by prepending-it to the file path with a colon.-Examples:-.IP-.nf-\f[C]-$\ hledger\ \-f\ csv:/some/csv\-file.dat\ stats-$\ echo\ \[aq]i\ 2009/13/1\ 08:00:00\[aq]\ |\ hledger\ print\ \-ftimeclock:\--\f[]-.fi-.PP-You can also specify multiple \f[C]\-f\f[] options, to read multiple-files as one big journal.-There are some limitations with this:-.IP \[bu] 2-directives in one file will not affect the other files-.IP \[bu] 2-balance assertions will not see any account balances from previous files-.PP-If you need those, either use the include directive, or concatenate the-files, eg: \f[C]cat\ a.journal\ b.journal\ |\ hledger\ \-f\-\ CMD\f[].-.SS Smart dates-.PP-hledger\[aq]s user interfaces accept a flexible "smart date" syntax-(unlike dates in the journal file).-Smart dates allow some english words, can be relative to today\[aq]s-date, and can have less\-significant date parts omitted (defaulting to-1).-.PP-Examples:-.PP-.TS-tab(@);-l l.-T{-\f[C]2004/10/1\f[], \f[C]2004\-01\-01\f[], \f[C]2004.9.1\f[]-T}@T{-exact date, several separators allowed.-Year is 4+ digits, month is 1\-12, day is 1\-31-T}-T{-\f[C]2004\f[]-T}@T{-start of year-T}-T{-\f[C]2004/10\f[]-T}@T{-start of month-T}-T{-\f[C]10/1\f[]-T}@T{-month and day in current year-T}-T{-\f[C]21\f[]-T}@T{-day in current month-T}-T{-\f[C]october,\ oct\f[]-T}@T{-start of month in current year-T}-T{-\f[C]yesterday,\ today,\ tomorrow\f[]-T}@T{-\-1, 0, 1 days from today-T}-T{-\f[C]last/this/next\ day/week/month/quarter/year\f[]-T}@T{-\-1, 0, 1 periods from the current period-T}-T{-\f[C]20181201\f[]-T}@T{-8 digit YYYYMMDD with valid year month and day-T}-T{-\f[C]201812\f[]-T}@T{-6 digit YYYYMM with valid year and month-T}-.TE-.PP-Counterexamples \- malformed digit sequences might give surprising-results:-.PP-.TS-tab(@);-l l.-T{-\f[C]201813\f[]-T}@T{-6 digits with an invalid month is parsed as start of 6\-digit year-T}-T{-\f[C]20181301\f[]-T}@T{-8 digits with an invalid month is parsed as start of 8\-digit year-T}-T{-\f[C]20181232\f[]-T}@T{-8 digits with an invalid day gives an error-T}-T{-\f[C]201801012\f[]-T}@T{-9+ digits beginning with a valid YYYYMMDD gives an error-T}-.TE-.SS Report start & end date-.PP-Most hledger reports show the full span of time represented by the-journal data, by default.-So, the effective report start and end dates will be the earliest and-latest transaction or posting dates found in the journal.-.PP-Often you will want to see a shorter time span, such as the current-month.-You can specify a start and/or end date using \f[C]\-b/\-\-begin\f[],-\f[C]\-e/\-\-end\f[], \f[C]\-p/\-\-period\f[] or a \f[C]date:\f[] query-(described below).-All of these accept the smart date syntax.-One important thing to be aware of when specifying end dates: as in-Ledger, end dates are exclusive, so you need to write the date-\f[I]after\f[] the last day you want to include.-.PP-Examples:-.PP-.TS-tab(@);-l l.-T{-\f[C]\-b\ 2016/3/17\f[]-T}@T{-begin on St.-Patrick\[aq]s day 2016-T}-T{-\f[C]\-e\ 12/1\f[]-T}@T{-end at the start of december 1st of the current year (11/30 will be the-last date included)-T}-T{-\f[C]\-b\ thismonth\f[]-T}@T{-all transactions on or after the 1st of the current month-T}-T{-\f[C]\-p\ thismonth\f[]-T}@T{-all transactions in the current month-T}-T{-\f[C]date:2016/3/17\-\f[]-T}@T{-the above written as queries instead-T}-T{-\f[C]date:\-12/1\f[]-T}@T{-T}-T{-\f[C]date:thismonth\-\f[]-T}@T{-T}-T{-\f[C]date:thismonth\f[]-T}@T{-T}-.TE-.SS Report intervals-.PP-A report interval can be specified so that commands like register,-balance and activity will divide their reports into multiple subperiods.-The basic intervals can be selected with one of \f[C]\-D/\-\-daily\f[],-\f[C]\-W/\-\-weekly\f[], \f[C]\-M/\-\-monthly\f[],-\f[C]\-Q/\-\-quarterly\f[], or \f[C]\-Y/\-\-yearly\f[].-More complex intervals may be specified with a period expression.-Report intervals can not be specified with a query, currently.-.SS Period expressions-.PP-The \f[C]\-p/\-\-period\f[] option accepts period expressions, a-shorthand way of expressing a start date, end date, and/or report-interval all at once.-.PP-Here\[aq]s a basic period expression specifying the first quarter of-2009.-Note, hledger always treats start dates as inclusive and end dates as-exclusive:-.PP-\f[C]\-p\ "from\ 2009/1/1\ to\ 2009/4/1"\f[]-.PP-Keywords like "from" and "to" are optional, and so are the spaces, as-long as you don\[aq]t run two dates together.-"to" can also be written as "\-".-These are equivalent to the above:-.PP-.TS-tab(@);-l.-T{-\f[C]\-p\ "2009/1/1\ 2009/4/1"\f[]-T}-T{-\f[C]\-p2009/1/1to2009/4/1\f[]-T}-T{-\f[C]\-p2009/1/1\-2009/4/1\f[]-T}-.TE-.PP-Dates are smart dates, so if the current year is 2009, the above can-also be written as:-.PP-.TS-tab(@);-l.-T{-\f[C]\-p\ "1/1\ 4/1"\f[]-T}-T{-\f[C]\-p\ "january\-apr"\f[]-T}-T{-\f[C]\-p\ "this\ year\ to\ 4/1"\f[]-T}-.TE-.PP-If you specify only one date, the missing start or end date will be the-earliest or latest transaction in your journal:-.PP-.TS-tab(@);-l l.-T{-\f[C]\-p\ "from\ 2009/1/1"\f[]-T}@T{-everything after january 1, 2009-T}-T{-\f[C]\-p\ "from\ 2009/1"\f[]-T}@T{-the same-T}-T{-\f[C]\-p\ "from\ 2009"\f[]-T}@T{-the same-T}-T{-\f[C]\-p\ "to\ 2009"\f[]-T}@T{-everything before january 1, 2009-T}-.TE-.PP-A single date with no "from" or "to" defines both the start and end date-like so:-.PP-.TS-tab(@);-l l.-T{-\f[C]\-p\ "2009"\f[]-T}@T{-the year 2009; equivalent to "2009/1/1 to 2010/1/1"-T}-T{-\f[C]\-p\ "2009/1"\f[]-T}@T{-the month of jan; equivalent to "2009/1/1 to 2009/2/1"-T}-T{-\f[C]\-p\ "2009/1/1"\f[]-T}@T{-just that day; equivalent to "2009/1/1 to 2009/1/2"-T}-.TE-.PP-The argument of \f[C]\-p\f[] can also begin with, or be, a report-interval expression.-The basic report intervals are \f[C]daily\f[], \f[C]weekly\f[],-\f[C]monthly\f[], \f[C]quarterly\f[], or \f[C]yearly\f[], which have the-same effect as the \f[C]\-D\f[],\f[C]\-W\f[],\f[C]\-M\f[],\f[C]\-Q\f[],-or \f[C]\-Y\f[] flags.-Between report interval and start/end dates (if any), the word-\f[C]in\f[] is optional.-Examples:-.PP-.TS-tab(@);-l.-T{-\f[C]\-p\ "weekly\ from\ 2009/1/1\ to\ 2009/4/1"\f[]-T}-T{-\f[C]\-p\ "monthly\ in\ 2008"\f[]-T}-T{-\f[C]\-p\ "quarterly"\f[]-T}-.TE-.PP-Note that \f[C]weekly\f[], \f[C]monthly\f[], \f[C]quarterly\f[] and-\f[C]yearly\f[] intervals will always start on the first day on week,-month, quarter or year accordingly, and will end on the last day of same-period, even if associated period expression specifies different-explicit start and end date.-.PP-For example:-.PP-.TS-tab(@);-l.-T{-\f[C]\-p\ "weekly\ from\ 2009/1/1\ to\ 2009/4/1"\f[] \-\- starts on-2008/12/29, closest preceeding Monday-T}-T{-\f[C]\-p\ "monthly\ in\ 2008/11/25"\f[] \-\- starts on 2018/11/01-T}-T{-\f[C]\-p\ "quarterly\ from\ 2009\-05\-05\ to\ 2009\-06\-01"\f[] \--starts on 2009/04/01, ends on 2009/06/30, which are first and last days-of Q2 2009-T}-T{-\f[C]\-p\ "yearly\ from\ 2009\-12\-29"\f[] \- starts on 2009/01/01,-first day of 2009-T}-.TE-.PP-The following more complex report intervals are also supported:-\f[C]biweekly\f[], \f[C]bimonthly\f[],-\f[C]every\ day|week|month|quarter|year\f[],-\f[C]every\ N\ days|weeks|months|quarters|years\f[].-.PP-All of these will start on the first day of the requested period and end-on the last one, as described above.-.PP-Examples:-.PP-.TS-tab(@);-l.-T{-\f[C]\-p\ "bimonthly\ from\ 2008"\f[] \-\- periods will have boundaries-on 2008/01/01, 2008/03/01, ...-T}-T{-\f[C]\-p\ "every\ 2\ weeks"\f[] \-\- starts on closest preceeding Monday-T}-T{-\f[C]\-p\ "every\ 5\ month\ from\ 2009/03"\f[] \-\- periods will have-boundaries on 2009/03/01, 2009/08/01, ...-T}-.TE-.PP-If you want intervals that start on arbitrary day of your choosing and-span a week, month or year, you need to use any of the following:-.PP-\f[C]every\ Nth\ day\ of\ week\f[], \f[C]every\ <weekday>\f[],-\f[C]every\ Nth\ day\ [of\ month]\f[],-\f[C]every\ Nth\ weekday\ [of\ month]\f[],-\f[C]every\ MM/DD\ [of\ year]\f[], \f[C]every\ Nth\ MMM\ [of\ year]\f[],-\f[C]every\ MMM\ Nth\ [of\ year]\f[].-.PP-Examples:-.PP-.TS-tab(@);-l.-T{-\f[C]\-p\ "every\ 2nd\ day\ of\ week"\f[] \-\- periods will go from Tue-to Tue-T}-T{-\f[C]\-p\ "every\ Tue"\f[] \-\- same-T}-T{-\f[C]\-p\ "every\ 15th\ day"\f[] \-\- period boundaries will be on 15th-of each month-T}-T{-\f[C]\-p\ "every\ 2nd\ Monday"\f[] \-\- period boundaries will be on-second Monday of each month-T}-T{-\f[C]\-p\ "every\ 11/05"\f[] \-\- yearly periods with boundaries on 5th-of Nov-T}-T{-\f[C]\-p\ "every\ 5th\ Nov"\f[] \-\- same-T}-T{-\f[C]\-p\ "every\ Nov\ 5th"\f[] \-\- same-T}-.TE-.PP-Show historical balances at end of 15th each month (N is exclusive end-date):-.PP-\f[C]hledger\ balance\ \-H\ \-p\ "every\ 16th\ day"\f[]-.PP-Group postings from start of wednesday to end of next tuesday (N is-start date and exclusive end date):-.PP-\f[C]hledger\ register\ checking\ \-p\ "every\ 3rd\ day\ of\ week"\f[]-.SS Depth limiting-.PP-With the \f[C]\-\-depth\ N\f[] option (short form: \f[C]\-N\f[]),-commands like account, balance and register will show only the uppermost-accounts in the account tree, down to level N.-Use this when you want a summary with less detail.-This flag has the same effect as a \f[C]depth:\f[] query argument (so-\f[C]\-2\f[], \f[C]\-\-depth=2\f[] or \f[C]depth:2\f[] are basically-equivalent).-.SS Pivoting-.PP-Normally hledger sums amounts, and organizes them in a hierarchy, based-on account name.-The \f[C]\-\-pivot\ FIELD\f[] option causes it to sum and organize-hierarchy based on the value of some other field instead.-FIELD can be: \f[C]code\f[], \f[C]description\f[], \f[C]payee\f[],-\f[C]note\f[], or the full name (case insensitive) of any tag.-As with account names, values containing \f[C]colon:separated:parts\f[]-will be displayed hierarchically in reports.-.PP-\f[C]\-\-pivot\f[] is a general option affecting all reports; you can-think of hledger transforming the journal before any other processing,-replacing every posting\[aq]s account name with the value of the-specified field on that posting, inheriting it from the transaction or-using a blank value if it\[aq]s not present.-.PP-An example:-.IP-.nf-\f[C]-2016/02/16\ Member\ Fee\ Payment-\ \ \ \ assets:bank\ account\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 2\ EUR-\ \ \ \ income:member\ fees\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \-2\ EUR\ \ ;\ member:\ John\ Doe-\f[]-.fi-.PP-Normal balance report showing account names:-.IP-.nf-\f[C]-$\ hledger\ balance-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 2\ EUR\ \ assets:bank\ account-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \-2\ EUR\ \ income:member\ fees-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0-\f[]-.fi-.PP-Pivoted balance report, using member: tag values instead:-.IP-.nf-\f[C]-$\ hledger\ balance\ \-\-pivot\ member-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 2\ EUR-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \-2\ EUR\ \ John\ Doe-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0-\f[]-.fi-.PP-One way to show only amounts with a member: value (using a query,-described below):-.IP-.nf-\f[C]-$\ hledger\ balance\ \-\-pivot\ member\ tag:member=.-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \-2\ EUR\ \ John\ Doe-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \-2\ EUR-\f[]-.fi-.PP-Another way (the acct: query matches against the pivoted "account-name"):-.IP-.nf-\f[C]-$\ hledger\ balance\ \-\-pivot\ member\ acct:.-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \-2\ EUR\ \ John\ Doe-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \-2\ EUR-\f[]-.fi-.SS Cost-.PP-The \f[C]\-B/\-\-cost\f[] flag converts amounts to their cost at-transaction time, if they have a transaction price specified.-.SS Market value-.PP-The \f[C]\-V/\-\-value\f[] flag converts reported amounts to their-current market value.-.PD 0-.P-.PD-Specifically, when there is a market price (P directive) for the-amount\[aq]s commodity, dated on or before today\[aq]s date (or the-report end date if specified), the amount will be converted to the-price\[aq]s commodity.-.PP-When there are multiple applicable P directives, \-V chooses the most-recent one, or in case of equal dates, the last\-parsed one.-.PP-For example:-.IP-.nf-\f[C]-#\ one\ euro\ is\ worth\ this\ many\ dollars\ from\ nov\ 1-P\ 2016/11/01\ €\ $1.10--#\ purchase\ some\ euros\ on\ nov\ 3-2016/11/3-\ \ \ \ assets:euros\ \ \ \ \ \ \ \ €100-\ \ \ \ assets:checking--#\ the\ euro\ is\ worth\ fewer\ dollars\ by\ dec\ 21-P\ 2016/12/21\ €\ $1.03-\f[]-.fi-.PP-How many euros do I have ?-.IP-.nf-\f[C]-$\ hledger\ \-f\ t.j\ bal\ \-N\ euros-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ €100\ \ assets:euros-\f[]-.fi-.PP-What are they worth at end of nov 3 ?-.IP-.nf-\f[C]-$\ hledger\ \-f\ t.j\ bal\ \-N\ euros\ \-V\ \-e\ 2016/11/4-\ \ \ \ \ \ \ \ \ \ \ \ \ $110.00\ \ assets:euros-\f[]-.fi-.PP-What are they worth after 2016/12/21 ?-(no report end date specified, defaults to today)-.IP-.nf-\f[C]-$\ hledger\ \-f\ t.j\ bal\ \-N\ euros\ \-V-\ \ \ \ \ \ \ \ \ \ \ \ \ $103.00\ \ assets:euros-\f[]-.fi-.PP-Currently, hledger\[aq]s \-V only uses market prices recorded with P-directives, not transaction prices (unlike Ledger).-.PP-Currently, \-V has a limitation in multicolumn balance reports: it uses-the market prices on the report end date for all columns.-(Instead of the prices on each column\[aq]s end date.)-.SS Combining \-B and \-V-.PP-Using \-B/\-\-cost and \-V/\-\-value together is currently allowed, but-the results are probably not meaningful.-Let us know if you find a use for this.-.SS Output destination-.PP-Some commands (print, register, stats, the balance commands) can write-their output to a destination other than the console.-This is controlled by the \f[C]\-o/\-\-output\-file\f[] option.-.IP-.nf-\f[C]-$\ hledger\ balance\ \-o\ \-\ \ \ \ \ #\ write\ to\ stdout\ (the\ default)-$\ hledger\ balance\ \-o\ FILE\ \ #\ write\ to\ FILE-\f[]-.fi-.SS Output format-.PP-Some commands can write their output in other formats.-Eg print and register can output CSV, and the balance commands can-output CSV or HTML.-This is controlled by the \f[C]\-O/\-\-output\-format\f[] option, or by-specifying a \f[C]\&.csv\f[] or \f[C]\&.html\f[] file extension with-\f[C]\-o/\-\-output\-file\f[].-.IP-.nf-\f[C]-$\ hledger\ balance\ \-O\ csv\ \ \ \ \ \ \ #\ write\ CSV\ to\ stdout-$\ hledger\ balance\ \-o\ FILE.csv\ \ #\ write\ CSV\ to\ FILE.csv-\f[]-.fi-.SS Regular expressions-.PP-hledger uses regular expressions in a number of places:-.IP \[bu] 2-query terms, on the command line and in the hledger\-web search form:-\f[C]REGEX\f[], \f[C]desc:REGEX\f[], \f[C]cur:REGEX\f[],-\f[C]tag:...=REGEX\f[]-.IP \[bu] 2-CSV rules conditional blocks: \f[C]if\ REGEX\ ...\f[]-.IP \[bu] 2-account alias directives and options:-\f[C]alias\ /REGEX/\ =\ REPLACEMENT\f[],-\f[C]\-\-alias\ /REGEX/=REPLACEMENT\f[]-.PP-hledger\[aq]s regular expressions come from the regex\-tdfa library.-In general they:-.IP \[bu] 2-are case insensitive-.IP \[bu] 2-are infix matching (do not need to match the entire thing being matched)-.IP \[bu] 2-are POSIX extended regular expressions-.IP \[bu] 2-also support GNU word boundaries (\\<, \\>, \\b, \\B)-.IP \[bu] 2-and parenthesised capturing groups and numeric backreferences in-replacement strings-.IP \[bu] 2-do not support mode modifiers like (?s)-.PP-Some things to note:-.IP \[bu] 2-In the \f[C]alias\f[] directive and \f[C]\-\-alias\f[] option, regular-expressions must be enclosed in forward slashes (\f[C]/REGEX/\f[]).-Elsewhere in hledger, these are not required.-.IP \[bu] 2-In queries, to match a regular expression metacharacter like \f[C]$\f[]-as a literal character, prepend a backslash.-Eg to search for amounts with the dollar sign in hledger\-web, write-\f[C]cur:\\$\f[].-.IP \[bu] 2-On the command line, some metacharacters like \f[C]$\f[] have a special-meaning to the shell and so must be escaped at least once more.-See Special characters.-.SH QUERIES-.PP-One of hledger\[aq]s strengths is being able to quickly report on-precise subsets of your data.-Most commands accept an optional query expression, written as arguments-after the command name, to filter the data by date, account name or-other criteria.-The syntax is similar to a web search: one or more space\-separated-search terms, quotes to enclose whitespace, prefixes to match specific-fields, a not: prefix to negate the match.-.PP-We do not yet support arbitrary boolean combinations of search terms;-instead most commands show transactions/postings/accounts which match-(or negatively match):-.IP \[bu] 2-any of the description terms AND-.IP \[bu] 2-any of the account terms AND-.IP \[bu] 2-any of the status terms AND-.IP \[bu] 2-all the other terms.-.PP-The print command instead shows transactions which:-.IP \[bu] 2-match any of the description terms AND-.IP \[bu] 2-have any postings matching any of the positive account terms AND-.IP \[bu] 2-have no postings matching any of the negative account terms AND-.IP \[bu] 2-match all the other terms.-.PP-The following kinds of search terms can be used.-Remember these can also be prefixed with \f[B]\f[BC]not:\f[B]\f[], eg to-exclude a particular subaccount.-.TP-.B \f[B]\f[BC]REGEX\f[B], \f[BC]acct:REGEX\f[B]\f[]-match account names by this regular expression.-(With no prefix, \f[C]acct:\f[] is assumed.)-.RS-.RE-same as above-.RS-.RE-.TP-.B \f[B]\f[BC]amt:N,\ amt:<N,\ amt:<=N,\ amt:>N,\ amt:>=N\f[B]\f[]-match postings with a single\-commodity amount that is equal to, less-than, or greater than N.-(Multi\-commodity amounts are not tested, and will always match.) The-comparison has two modes: if N is preceded by a + or \- sign (or is 0),-the two signed numbers are compared.-Otherwise, the absolute magnitudes are compared, ignoring sign.-.RS-.RE-.TP-.B \f[B]\f[BC]code:REGEX\f[B]\f[]-match by transaction code (eg check number)-.RS-.RE-.TP-.B \f[B]\f[BC]cur:REGEX\f[B]\f[]-match postings or transactions including any amounts whose-currency/commodity symbol is fully matched by REGEX.-(For a partial match, use \f[C]\&.*REGEX.*\f[]).-Note, to match characters which are regex\-significant, like the dollar-sign (\f[C]$\f[]), you need to prepend \f[C]\\\f[].-And when using the command line you need to add one more level of-quoting to hide it from the shell, so eg do:-\f[C]hledger\ print\ cur:\[aq]\\$\[aq]\f[] or-\f[C]hledger\ print\ cur:\\\\$\f[].-.RS-.RE-.TP-.B \f[B]\f[BC]desc:REGEX\f[B]\f[]-match transaction descriptions.-.RS-.RE-.TP-.B \f[B]\f[BC]date:PERIODEXPR\f[B]\f[]-match dates within the specified period.-PERIODEXPR is a period expression (with no report interval).-Examples: \f[C]date:2016\f[], \f[C]date:thismonth\f[],-\f[C]date:2000/2/1\-2/15\f[], \f[C]date:lastweek\-\f[].-If the \f[C]\-\-date2\f[] command line flag is present, this matches-secondary dates instead.-.RS-.RE-.TP-.B \f[B]\f[BC]date2:PERIODEXPR\f[B]\f[]-match secondary dates within the specified period.-.RS-.RE-.TP-.B \f[B]\f[BC]depth:N\f[B]\f[]-match (or display, depending on command) accounts at or above this depth-.RS-.RE-.TP-.B \f[B]\f[BC]note:REGEX\f[B]\f[]-match transaction notes (part of description right of \f[C]|\f[], or-whole description when there\[aq]s no \f[C]|\f[])-.RS-.RE-.TP-.B \f[B]\f[BC]payee:REGEX\f[B]\f[]-match transaction payee/payer names (part of description left of-\f[C]|\f[], or whole description when there\[aq]s no \f[C]|\f[])-.RS-.RE-.TP-.B \f[B]\f[BC]real:,\ real:0\f[B]\f[]-match real or virtual postings respectively-.RS-.RE-.TP-.B \f[B]\f[BC]status:,\ status:!,\ status:*\f[B]\f[]-match unmarked, pending, or cleared transactions respectively-.RS-.RE-.TP-.B \f[B]\f[BC]tag:REGEX[=REGEX]\f[B]\f[]-match by tag name, and optionally also by tag value.-Note a tag: query is considered to match a transaction if it matches any-of the postings.-Also remember that postings inherit the tags of their parent-transaction.-.RS-.RE-.PP-The following special search term is used automatically in hledger\-web,-only:-.TP-.B \f[B]\f[BC]inacct:ACCTNAME\f[B]\f[]-tells hledger\-web to show the transaction register for this account.-Can be filtered further with \f[C]acct\f[] etc.-.RS-.RE-.PP-Some of these can also be expressed as command\-line options (eg-\f[C]depth:2\f[] is equivalent to \f[C]\-\-depth\ 2\f[]).-Generally you can mix options and query arguments, and the resulting-query will be their intersection (perhaps excluding the-\f[C]\-p/\-\-period\f[] option).-.SH COMMANDS-.PP-hledger provides a number of subcommands; \f[C]hledger\f[] with no-arguments shows a list.-.PP-If you install additional \f[C]hledger\-*\f[] packages, or if you put-programs or scripts named \f[C]hledger\-NAME\f[] in your PATH, these-will also be listed as subcommands.-.PP-Run a subcommand by writing its name as first argument (eg-\f[C]hledger\ incomestatement\f[]).-You can also write one of the standard short aliases displayed in-parentheses in the command list (\f[C]hledger\ b\f[]), or any any-unambiguous prefix of a command name (\f[C]hledger\ inc\f[]).-.PP-Here are all the builtin commands in alphabetical order.-See also \f[C]hledger\f[] for a more organised command list, and-\f[C]hledger\ CMD\ \-h\f[] for detailed command help.-.SS accounts-.PP-accounts, a-.PD 0-.P-.PD-Show account names.-.PP-This command lists account names, either declared with account-directives (\-\-declared), posted to (\-\-used), or both (the default).-With query arguments, only matched account names and account names-referenced by matched postings are shown.-It shows a flat list by default.-With \f[C]\-\-tree\f[], it uses indentation to show the account-hierarchy.-In flat mode you can add \f[C]\-\-drop\ N\f[] to omit the first few-account name components.-Account names can be depth\-clipped with \f[C]depth:N\f[] or-\f[C]\-\-depth\ N\f[] or \f[C]\-N\f[].-.PP-Examples:-.IP-.nf-\f[C]-$\ hledger\ accounts-assets:bank:checking-assets:bank:saving-assets:cash-expenses:food-expenses:supplies-income:gifts-income:salary-liabilities:debts-\f[]-.fi-.SS activity-.PP-activity-.PD 0-.P-.PD-Show an ascii barchart of posting counts per interval.-.PP-The activity command displays an ascii histogram showing transaction-counts by day, week, month or other reporting interval (by day is the-default).-With query arguments, it counts only matched transactions.-.PP-Examples:-.IP-.nf-\f[C]-$\ hledger\ activity\ \-\-quarterly-2008\-01\-01\ **-2008\-04\-01\ *******-2008\-07\-01\ -2008\-10\-01\ **-\f[]-.fi-.SS add-.PP-add-.PD 0-.P-.PD-Prompt for transactions and add them to the journal.-.PP-Many hledger users edit their journals directly with a text editor, or-generate them from CSV.-For more interactive data entry, there is the \f[C]add\f[] command,-which prompts interactively on the console for new transactions, and-appends them to the journal file (if there are multiple-\f[C]\-f\ FILE\f[] options, the first file is used.) Existing-transactions are not changed.-This is the only hledger command that writes to the journal file.-.PP-To use it, just run \f[C]hledger\ add\f[] and follow the prompts.-You can add as many transactions as you like; when you are finished,-enter \f[C]\&.\f[] or press control\-d or control\-c to exit.-.PP-Features:-.IP \[bu] 2-add tries to provide useful defaults, using the most similar (by-description) recent transaction (filtered by the query, if any) as a-template.-.IP \[bu] 2-You can also set the initial defaults with command line arguments.-.IP \[bu] 2-Readline\-style edit keys can be used during data entry.-.IP \[bu] 2-The tab key will auto\-complete whenever possible \- accounts,-descriptions, dates (\f[C]yesterday\f[], \f[C]today\f[],-\f[C]tomorrow\f[]).-If the input area is empty, it will insert the default value.-.IP \[bu] 2-If the journal defines a default commodity, it will be added to any bare-numbers entered.-.IP \[bu] 2-A parenthesised transaction code may be entered following a date.-.IP \[bu] 2-Comments and tags may be entered following a description or amount.-.IP \[bu] 2-If you make a mistake, enter \f[C]<\f[] at any prompt to restart the-transaction.-.IP \[bu] 2-Input prompts are displayed in a different colour when the terminal-supports it.-.PP-Example (see the tutorial for a detailed explanation):-.IP-.nf-\f[C]-$\ hledger\ add-Adding\ transactions\ to\ journal\ file\ /src/hledger/examples/sample.journal-Any\ command\ line\ arguments\ will\ be\ used\ as\ defaults.-Use\ tab\ key\ to\ complete,\ readline\ keys\ to\ edit,\ enter\ to\ accept\ defaults.-An\ optional\ (CODE)\ may\ follow\ transaction\ dates.-An\ optional\ ;\ COMMENT\ may\ follow\ descriptions\ or\ amounts.-If\ you\ make\ a\ mistake,\ enter\ <\ at\ any\ prompt\ to\ restart\ the\ transaction.-To\ end\ a\ transaction,\ enter\ .\ when\ prompted.-To\ quit,\ enter\ .\ at\ a\ date\ prompt\ or\ press\ control\-d\ or\ control\-c.-Date\ [2015/05/22]:\ -Description:\ supermarket-Account\ 1:\ expenses:food-Amount\ \ 1:\ $10-Account\ 2:\ assets:checking-Amount\ \ 2\ [$\-10.0]:\ -Account\ 3\ (or\ .\ or\ enter\ to\ finish\ this\ transaction):\ .-2015/05/22\ supermarket-\ \ \ \ expenses:food\ \ \ \ \ \ \ \ \ \ \ \ \ $10-\ \ \ \ assets:checking\ \ \ \ \ \ \ \ $\-10.0--Save\ this\ transaction\ to\ the\ journal\ ?\ [y]:\ -Saved.-Starting\ the\ next\ transaction\ (.\ or\ ctrl\-D/ctrl\-C\ to\ quit)-Date\ [2015/05/22]:\ <CTRL\-D>\ $-\f[]-.fi-.SS balance-.PP-balance, bal, b-.PD 0-.P-.PD-Show accounts and their balances.-.PP-The balance command is hledger\[aq]s most versatile command.-Note, despite the name, it is not always used for showing real\-world-account balances; the more accounting\-aware balancesheet and-incomestatement may be more convenient for that.-.PP-By default, it displays all accounts, and each account\[aq]s change in-balance during the entire period of the journal.-Balance changes are calculated by adding up the postings in each-account.-You can limit the postings matched, by a query, to see fewer accounts,-changes over a different time period, changes from only cleared-transactions, etc.-.PP-If you include an account\[aq]s complete history of postings in the-report, the balance change is equivalent to the account\[aq]s current-ending balance.-For a real\-world account, typically you won\[aq]t have all transactions-in the journal; instead you\[aq]ll have all transactions after a certain-date, and an "opening balances" transaction setting the correct starting-balance on that date.-Then the balance command will show real\-world account balances.-In some cases the \-H/\-\-historical flag is used to ensure this (more-below).-.PP-The balance command can produce several styles of report:-.SS Classic balance report-.PP-This is the original balance report, as found in Ledger.-It usually looks like this:-.IP-.nf-\f[C]-$\ hledger\ balance-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1\ \ assets-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ \ \ bank:saving-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-2\ \ \ \ cash-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $2\ \ expenses-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ \ \ food-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ \ \ supplies-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-2\ \ income-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1\ \ \ \ gifts-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1\ \ \ \ salary-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ liabilities:debts-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0-\f[]-.fi-.PP-By default, accounts are displayed hierarchically, with subaccounts-indented below their parent.-At each level of the tree, accounts are sorted by account code if any,-then by account name.-Or with \f[C]\-S/\-\-sort\-amount\f[], by their balance amount.-.PP-"Boring" accounts, which contain a single interesting subaccount and no-balance of their own, are elided into the following line for more-compact output.-(Eg above, the "liabilities" account.) Use \f[C]\-\-no\-elide\f[] to-prevent this.-.PP-Account balances are "inclusive" \- they include the balances of any-subaccounts.-.PP-Accounts which have zero balance (and no non\-zero subaccounts) are-omitted.-Use \f[C]\-E/\-\-empty\f[] to show them.-.PP-A final total is displayed by default; use \f[C]\-N/\-\-no\-total\f[] to-suppress it, eg:-.IP-.nf-\f[C]-$\ hledger\ balance\ \-p\ 2008/6\ expenses\ \-\-no\-total-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $2\ \ expenses-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ \ \ food-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ \ \ supplies-\f[]-.fi-.SS Customising the classic balance report-.PP-You can customise the layout of classic balance reports with-\f[C]\-\-format\ FMT\f[]:-.IP-.nf-\f[C]-$\ hledger\ balance\ \-\-format\ "%20(account)\ %12(total)"-\ \ \ \ \ \ \ \ \ \ \ \ \ \ assets\ \ \ \ \ \ \ \ \ \ $\-1-\ \ \ \ \ \ \ \ \ bank:saving\ \ \ \ \ \ \ \ \ \ \ $1-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ cash\ \ \ \ \ \ \ \ \ \ $\-2-\ \ \ \ \ \ \ \ \ \ \ \ expenses\ \ \ \ \ \ \ \ \ \ \ $2-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ food\ \ \ \ \ \ \ \ \ \ \ $1-\ \ \ \ \ \ \ \ \ \ \ \ supplies\ \ \ \ \ \ \ \ \ \ \ $1-\ \ \ \ \ \ \ \ \ \ \ \ \ \ income\ \ \ \ \ \ \ \ \ \ $\-2-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ gifts\ \ \ \ \ \ \ \ \ \ $\-1-\ \ \ \ \ \ \ \ \ \ \ \ \ \ salary\ \ \ \ \ \ \ \ \ \ $\-1-\ \ \ liabilities:debts\ \ \ \ \ \ \ \ \ \ \ $1-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0-\f[]-.fi-.PP-The FMT format string (plus a newline) specifies the formatting applied-to each account/balance pair.-It may contain any suitable text, with data fields interpolated like so:-.PP-\f[C]%[MIN][.MAX](FIELDNAME)\f[]-.IP \[bu] 2-MIN pads with spaces to at least this width (optional)-.IP \[bu] 2-MAX truncates at this width (optional)-.IP \[bu] 2-FIELDNAME must be enclosed in parentheses, and can be one of:-.RS 2-.IP \[bu] 2-\f[C]depth_spacer\f[] \- a number of spaces equal to the account\[aq]s-depth, or if MIN is specified, MIN * depth spaces.-.IP \[bu] 2-\f[C]account\f[] \- the account\[aq]s name-.IP \[bu] 2-\f[C]total\f[] \- the account\[aq]s balance/posted total, right-justified-.RE-.PP-Also, FMT can begin with an optional prefix to control how-multi\-commodity amounts are rendered:-.IP \[bu] 2-\f[C]%_\f[] \- render on multiple lines, bottom\-aligned (the default)-.IP \[bu] 2-\f[C]%^\f[] \- render on multiple lines, top\-aligned-.IP \[bu] 2-\f[C]%,\f[] \- render on one line, comma\-separated-.PP-There are some quirks.-Eg in one\-line mode, \f[C]%(depth_spacer)\f[] has no effect, instead-\f[C]%(account)\f[] has indentation built in.- Experimentation may be needed to get pleasing results.-.PP-Some example formats:-.IP \[bu] 2-\f[C]%(total)\f[] \- the account\[aq]s total-.IP \[bu] 2-\f[C]%\-20.20(account)\f[] \- the account\[aq]s name, left justified,-padded to 20 characters and clipped at 20 characters-.IP \[bu] 2-\f[C]%,%\-50(account)\ \ %25(total)\f[] \- account name padded to 50-characters, total padded to 20 characters, with multiple commodities-rendered on one line-.IP \[bu] 2-\f[C]%20(total)\ \ %2(depth_spacer)%\-(account)\f[] \- the default-format for the single\-column balance report-.SS Colour support-.PP-The balance command shows negative amounts in red, if:-.IP \[bu] 2-the \f[C]TERM\f[] environment variable is not set to \f[C]dumb\f[]-.IP \[bu] 2-the output is not being redirected or piped anywhere-.SS Flat mode-.PP-To see a flat list instead of the default hierarchical display, use-\f[C]\-\-flat\f[].-In this mode, accounts (unless depth\-clipped) show their full names and-"exclusive" balance, excluding any subaccount balances.-In this mode, you can also use \f[C]\-\-drop\ N\f[] to omit the first-few account name components.-.IP-.nf-\f[C]-$\ hledger\ balance\ \-p\ 2008/6\ expenses\ \-N\ \-\-flat\ \-\-drop\ 1-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ food-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ supplies-\f[]-.fi-.SS Depth limited balance reports-.PP-With \f[C]\-\-depth\ N\f[] or \f[C]depth:N\f[] or just \f[C]\-N\f[],-balance reports show accounts only to the specified numeric depth.-This is very useful to summarise a complex set of accounts and get an-overview.-.IP-.nf-\f[C]-$\ hledger\ balance\ \-N\ \-1-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1\ \ assets-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $2\ \ expenses-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-2\ \ income-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ liabilities-\f[]-.fi-.PP-Flat\-mode balance reports, which normally show exclusive balances, show-inclusive balances at the depth limit.-.SS Multicolumn balance report-.PP-Multicolumn or tabular balance reports are a very useful hledger-feature, and usually the preferred style.-They share many of the above features, but they show the report as a-table, with columns representing time periods.-This mode is activated by providing a reporting interval.-.PP-There are three types of multicolumn balance report, showing different-information:-.IP "1." 3-By default: each column shows the sum of postings in that period, ie the-account\[aq]s change of balance in that period.-This is useful eg for a monthly income statement:-.RS 4-.IP-.nf-\f[C]-$\ hledger\ balance\ \-\-quarterly\ income\ expenses\ \-E-Balance\ changes\ in\ 2008:--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ 2008q1\ \ 2008q2\ \ 2008q3\ \ 2008q4\ -===================++=================================-\ expenses:food\ \ \ \ \ ||\ \ \ \ \ \ \ 0\ \ \ \ \ \ $1\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ -\ expenses:supplies\ ||\ \ \ \ \ \ \ 0\ \ \ \ \ \ $1\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ -\ income:gifts\ \ \ \ \ \ ||\ \ \ \ \ \ \ 0\ \ \ \ \ $\-1\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ -\ income:salary\ \ \ \ \ ||\ \ \ \ \ $\-1\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ $\-1\ \ \ \ \ \ $1\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ -\f[]-.fi-.RE-.IP "2." 3-With \f[C]\-\-cumulative\f[]: each column shows the ending balance for-that period, accumulating the changes across periods, starting from 0 at-the report start date:-.RS 4-.IP-.nf-\f[C]-$\ hledger\ balance\ \-\-quarterly\ income\ expenses\ \-E\ \-\-cumulative-Ending\ balances\ (cumulative)\ in\ 2008:--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ 2008/03/31\ \ 2008/06/30\ \ 2008/09/30\ \ 2008/12/31\ -===================++=================================================-\ expenses:food\ \ \ \ \ ||\ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ $1\ \ \ \ \ \ \ \ \ \ $1\ \ \ \ \ \ \ \ \ \ $1\ -\ expenses:supplies\ ||\ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ $1\ \ \ \ \ \ \ \ \ \ $1\ \ \ \ \ \ \ \ \ \ $1\ -\ income:gifts\ \ \ \ \ \ ||\ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ $\-1\ -\ income:salary\ \ \ \ \ ||\ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ $\-1\ -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ \ 0\ -\f[]-.fi-.RE-.IP "3." 3-With \f[C]\-\-historical/\-H\f[]: each column shows the actual-historical ending balance for that period, accumulating the changes-across periods, starting from the actual balance at the report start-date.-This is useful eg for a multi\-period balance sheet, and when you are-showing only the data after a certain start date:-.RS 4-.IP-.nf-\f[C]-$\ hledger\ balance\ ^assets\ ^liabilities\ \-\-quarterly\ \-\-historical\ \-\-begin\ 2008/4/1-Ending\ balances\ (historical)\ in\ 2008/04/01\-2008/12/31:--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ 2008/06/30\ \ 2008/09/30\ \ 2008/12/31\ -======================++=====================================-\ assets:bank:checking\ ||\ \ \ \ \ \ \ \ \ \ $1\ \ \ \ \ \ \ \ \ \ $1\ \ \ \ \ \ \ \ \ \ \ 0\ -\ assets:bank:saving\ \ \ ||\ \ \ \ \ \ \ \ \ \ $1\ \ \ \ \ \ \ \ \ \ $1\ \ \ \ \ \ \ \ \ \ $1\ -\ assets:cash\ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ \ \ \ \ $\-2\ \ \ \ \ \ \ \ \ $\-2\ \ \ \ \ \ \ \ \ $\-2\ -\ liabilities:debts\ \ \ \ ||\ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ $1\ -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ \ 0\ -\f[]-.fi-.RE-.PP-Multicolumn balance reports display accounts in flat mode by default; to-see the hierarchy, use \f[C]\-\-tree\f[].-.PP-With a reporting interval (like \f[C]\-\-quarterly\f[] above), the-report start/end dates will be adjusted if necessary so that they-encompass the displayed report periods.-This is so that the first and last periods will be "full" and comparable-to the others.-.PP-The \f[C]\-E/\-\-empty\f[] flag does two things in multicolumn balance-reports: first, the report will show all columns within the specified-report period (without \-E, leading and trailing columns with all zeroes-are not shown).-Second, all accounts which existed at the report start date will be-considered, not just the ones with activity during the report period-(use \-E to include low\-activity accounts which would otherwise would-be omitted).-.PP-The \f[C]\-T/\-\-row\-total\f[] flag adds an additional column showing-the total for each row.-.PP-The \f[C]\-A/\-\-average\f[] flag adds a column showing the average-value in each row.-.PP-Here\[aq]s an example of all three:-.IP-.nf-\f[C]-$\ hledger\ balance\ \-Q\ income\ expenses\ \-\-tree\ \-ETA-Balance\ changes\ in\ 2008:--\ \ \ \ \ \ \ \ \ \ \ \ ||\ \ 2008q1\ \ 2008q2\ \ 2008q3\ \ 2008q4\ \ \ \ Total\ \ Average\ -============++===================================================-\ expenses\ \ \ ||\ \ \ \ \ \ \ 0\ \ \ \ \ \ $2\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ $2\ \ \ \ \ \ \ $1\ -\ \ \ food\ \ \ \ \ ||\ \ \ \ \ \ \ 0\ \ \ \ \ \ $1\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ $1\ \ \ \ \ \ \ \ 0\ -\ \ \ supplies\ ||\ \ \ \ \ \ \ 0\ \ \ \ \ \ $1\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ $1\ \ \ \ \ \ \ \ 0\ -\ income\ \ \ \ \ ||\ \ \ \ \ $\-1\ \ \ \ \ $\-1\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ \ \ \ \ \ $\-2\ \ \ \ \ \ $\-1\ -\ \ \ gifts\ \ \ \ ||\ \ \ \ \ \ \ 0\ \ \ \ \ $\-1\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ 0\ -\ \ \ salary\ \ \ ||\ \ \ \ \ $\-1\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ 0\ -\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ $\-1\ \ \ \ \ \ $1\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ 0\ --#\ Average\ is\ rounded\ to\ the\ dollar\ here\ since\ all\ journal\ amounts\ are-\f[]-.fi-.PP-Limitations:-.PP-In multicolumn reports the \f[C]\-V/\-\-value\f[] flag uses the market-price on the report end date, for all columns (not the price on each-column\[aq]s end date).-.PP-Eliding of boring parent accounts in tree mode, as in the classic-balance report, is not yet supported in multicolumn reports.-.SS Budget report-.PP-With \f[C]\-\-budget\f[], extra columns are displayed showing budget-goals for each account and period, if any.-Budget goals are defined by periodic transactions.-This is very useful for comparing planned and actual income, expenses,-time usage, etc.-\-\-budget is most often combined with a report interval.-.PP-For example, you can take average monthly expenses in the common expense-categories to construct a minimal monthly budget:-.IP-.nf-\f[C]-;;\ Budget-~\ monthly-\ \ income\ \ $2000-\ \ expenses:food\ \ \ \ $400-\ \ expenses:bus\ \ \ \ \ $50-\ \ expenses:movies\ \ $30-\ \ assets:bank:checking--;;\ Two\ months\ worth\ of\ expenses-2017\-11\-01-\ \ income\ \ $1950-\ \ expenses:food\ \ \ \ $396-\ \ expenses:bus\ \ \ \ \ $49-\ \ expenses:movies\ \ $30-\ \ expenses:supplies\ \ $20-\ \ assets:bank:checking--2017\-12\-01-\ \ income\ \ $2100-\ \ expenses:food\ \ \ \ $412-\ \ expenses:bus\ \ \ \ \ $53-\ \ expenses:gifts\ \ \ $100-\ \ assets:bank:checking-\f[]-.fi-.PP-You can now see a monthly budget report:-.IP-.nf-\f[C]-$\ hledger\ balance\ \-M\ \-\-budget-Budget\ performance\ in\ 2017/11/01\-2017/12/31:--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Nov\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Dec\ -======================++====================================================-\ assets\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ $\-2445\ [\ \ 99%\ of\ $\-2480]\ \ $\-2665\ [\ 107%\ of\ $\-2480]\ -\ assets:bank\ \ \ \ \ \ \ \ \ \ ||\ $\-2445\ [\ \ 99%\ of\ $\-2480]\ \ $\-2665\ [\ 107%\ of\ $\-2480]\ -\ assets:bank:checking\ ||\ $\-2445\ [\ \ 99%\ of\ $\-2480]\ \ $\-2665\ [\ 107%\ of\ $\-2480]\ -\ expenses\ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ $495\ [\ 103%\ of\ \ \ $480]\ \ \ \ $565\ [\ 118%\ of\ \ \ $480]\ -\ expenses:bus\ \ \ \ \ \ \ \ \ ||\ \ \ \ $49\ [\ \ 98%\ of\ \ \ \ $50]\ \ \ \ \ $53\ [\ 106%\ of\ \ \ \ $50]\ -\ expenses:food\ \ \ \ \ \ \ \ ||\ \ \ $396\ [\ \ 99%\ of\ \ \ $400]\ \ \ \ $412\ [\ 103%\ of\ \ \ $400]\ -\ expenses:movies\ \ \ \ \ \ ||\ \ \ \ $30\ [\ 100%\ of\ \ \ \ $30]\ \ \ \ \ \ \ 0\ [\ \ \ 0%\ of\ \ \ \ $30]\ -\ income\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ $1950\ [\ \ 98%\ of\ \ $2000]\ \ \ $2100\ [\ 105%\ of\ \ $2000]\ -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ \ 0\ [\ \ \ \ \ \ \ \ \ \ \ \ \ \ 0]\ \ \ \ \ \ \ 0\ [\ \ \ \ \ \ \ \ \ \ \ \ \ \ 0]\ -\f[]-.fi-.PP-Note this is different from a normal balance report in several ways:-.IP \[bu] 2-Only accounts with budget goals during the report period are shown, by-default.-.IP \[bu] 2-In each column, in square brackets after the actual amount, budgeted-amounts are shown, along with the percentage of budget used.-.IP \[bu] 2-All parent accounts are always shown, even in flat mode.-Eg assets, assets:bank, and expenses above.-.IP \[bu] 2-Amounts always include all subaccounts, budgeted or unbudgeted, even in-flat mode.-.PP-This means that the numbers displayed will not always add up! Eg above,-the \f[C]expenses\f[] actual amount includes the gifts and supplies-transactions, but the \f[C]expenses:gifts\f[] and-\f[C]expenses:supplies\f[] accounts are not shown, as they have no-budget amounts declared.-.PP-This can be confusing.-When you need to make things clearer, use the \f[C]\-E/\-\-empty\f[]-flag, which will reveal all accounts including unbudgeted ones, giving-the full picture.-Eg:-.IP-.nf-\f[C]-$\ hledger\ balance\ \-M\ \-\-budget\ \-\-empty-Budget\ performance\ in\ 2017/11/01\-2017/12/31:--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Nov\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Dec\ -======================++====================================================-\ assets\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ $\-2445\ [\ \ 99%\ of\ $\-2480]\ \ $\-2665\ [\ 107%\ of\ $\-2480]\ -\ assets:bank\ \ \ \ \ \ \ \ \ \ ||\ $\-2445\ [\ \ 99%\ of\ $\-2480]\ \ $\-2665\ [\ 107%\ of\ $\-2480]\ -\ assets:bank:checking\ ||\ $\-2445\ [\ \ 99%\ of\ $\-2480]\ \ $\-2665\ [\ 107%\ of\ $\-2480]\ -\ expenses\ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ $495\ [\ 103%\ of\ \ \ $480]\ \ \ \ $565\ [\ 118%\ of\ \ \ $480]\ -\ expenses:bus\ \ \ \ \ \ \ \ \ ||\ \ \ \ $49\ [\ \ 98%\ of\ \ \ \ $50]\ \ \ \ \ $53\ [\ 106%\ of\ \ \ \ $50]\ -\ expenses:food\ \ \ \ \ \ \ \ ||\ \ \ $396\ [\ \ 99%\ of\ \ \ $400]\ \ \ \ $412\ [\ 103%\ of\ \ \ $400]\ -\ expenses:gifts\ \ \ \ \ \ \ ||\ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $100\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -\ expenses:movies\ \ \ \ \ \ ||\ \ \ \ $30\ [\ 100%\ of\ \ \ \ $30]\ \ \ \ \ \ \ 0\ [\ \ \ 0%\ of\ \ \ \ $30]\ -\ expenses:supplies\ \ \ \ ||\ \ \ \ $20\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -\ income\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ $1950\ [\ \ 98%\ of\ \ $2000]\ \ \ $2100\ [\ 105%\ of\ \ $2000]\ -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ \ 0\ [\ \ \ \ \ \ \ \ \ \ \ \ \ \ 0]\ \ \ \ \ \ \ 0\ [\ \ \ \ \ \ \ \ \ \ \ \ \ \ 0]\ -\f[]-.fi-.PP-You can roll over unspent budgets to next period with-\f[C]\-\-cumulative\f[]:-.IP-.nf-\f[C]-$\ hledger\ balance\ \-M\ \-\-budget\ \-\-cumulative-Budget\ performance\ in\ 2017/11/01\-2017/12/31:--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Nov\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Dec\ -======================++====================================================-\ assets\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ $\-2445\ [\ \ 99%\ of\ $\-2480]\ \ $\-5110\ [\ 103%\ of\ $\-4960]\ -\ assets:bank\ \ \ \ \ \ \ \ \ \ ||\ $\-2445\ [\ \ 99%\ of\ $\-2480]\ \ $\-5110\ [\ 103%\ of\ $\-4960]\ -\ assets:bank:checking\ ||\ $\-2445\ [\ \ 99%\ of\ $\-2480]\ \ $\-5110\ [\ 103%\ of\ $\-4960]\ -\ expenses\ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ $495\ [\ 103%\ of\ \ \ $480]\ \ \ $1060\ [\ 110%\ of\ \ \ $960]\ -\ expenses:bus\ \ \ \ \ \ \ \ \ ||\ \ \ \ $49\ [\ \ 98%\ of\ \ \ \ $50]\ \ \ \ $102\ [\ 102%\ of\ \ \ $100]\ -\ expenses:food\ \ \ \ \ \ \ \ ||\ \ \ $396\ [\ \ 99%\ of\ \ \ $400]\ \ \ \ $808\ [\ 101%\ of\ \ \ $800]\ -\ expenses:movies\ \ \ \ \ \ ||\ \ \ \ $30\ [\ 100%\ of\ \ \ \ $30]\ \ \ \ \ $30\ [\ \ 50%\ of\ \ \ \ $60]\ -\ income\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ $1950\ [\ \ 98%\ of\ \ $2000]\ \ \ $4050\ [\ 101%\ of\ \ $4000]\ -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ \ 0\ [\ \ \ \ \ \ \ \ \ \ \ \ \ \ 0]\ \ \ \ \ \ \ 0\ [\ \ \ \ \ \ \ \ \ \ \ \ \ \ 0]\ -\f[]-.fi-.PP-For more examples, see Budgeting and Forecasting.-.SS Nested budgets-.PP-You can add budgets to any account in your account hierarchy.-If you have budgets on both parent account and some of its children,-then budget(s) of the child account(s) would be added to the budget of-their parent, much like account balances behave.-.PP-In the most simple case this means that once you add a budget to any-account, all its parents would have budget as well.-.PP-To illustrate this, consider the following budget:-.IP-.nf-\f[C]-~\ monthly\ from\ 2019/01-\ \ \ \ expenses:personal\ \ \ \ \ \ \ \ \ \ \ \ \ $1,000.00-\ \ \ \ expenses:personal:electronics\ \ \ \ $100.00-\ \ \ \ liabilities-\f[]-.fi-.PP-With this, monthly budget for electronics is defined to be $100 and-budget for personal expenses is an additional $1000, which implicity-means that budget for both \f[C]expenses:personal\f[] and-\f[C]expenses\f[] is $1100.-.PP-Transactions in \f[C]expenses:personal:electronics\f[] will be counted-both towards its $100 budget and $1100 of \f[C]expenses:personal\f[] ,-and transactions in any other subaccount of \f[C]expenses:personal\f[]-would be counted towards only towards the budget of-\f[C]expenses:personal\f[].-.PP-For example, let\[aq]s consider these transactions:-.IP-.nf-\f[C]-~\ monthly\ from\ 2019/01-\ \ \ \ expenses:personal\ \ \ \ \ \ \ \ \ \ \ \ \ $1,000.00-\ \ \ \ expenses:personal:electronics\ \ \ \ $100.00-\ \ \ \ liabilities--2019/01/01\ Google\ home\ hub-\ \ \ \ expenses:personal:electronics\ \ \ \ \ \ \ \ \ \ $90.00-\ \ \ \ liabilities\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-90.00--2019/01/02\ Phone\ screen\ protector-\ \ \ \ expenses:personal:electronics:upgrades\ \ \ \ \ \ \ \ \ \ $10.00-\ \ \ \ liabilities--2019/01/02\ Weekly\ train\ ticket-\ \ \ \ expenses:personal:train\ tickets\ \ \ \ \ \ \ $153.00-\ \ \ \ liabilities--2019/01/03\ Flowers-\ \ \ \ expenses:personal\ \ \ \ \ \ \ \ \ \ $30.00-\ \ \ \ liabilities-\f[]-.fi-.PP-As you can see, we have transactions in-\f[C]expenses:personal:electronics:upgrades\f[] and-\f[C]expenses:personal:train\ tickets\f[], and since both of these-accounts are without explicitly defined budget, these transactions would-be counted towards budgets of \f[C]expenses:personal:electronics\f[] and-\f[C]expenses:personal\f[] accordingly:-.IP-.nf-\f[C]-$\ hledger\ balance\ \-\-budget\ \-M-Budget\ performance\ in\ 2019/01:--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Jan\ -===============================++===============================-\ expenses\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ $283.00\ [\ \ 26%\ of\ \ $1100.00]\ -\ expenses:personal\ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ $283.00\ [\ \ 26%\ of\ \ $1100.00]\ -\ expenses:personal:electronics\ ||\ \ $100.00\ [\ 100%\ of\ \ \ $100.00]\ -\ liabilities\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ $\-283.00\ [\ \ 26%\ of\ $\-1100.00]\ -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ \ \ \ 0\ [\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0]\ -\f[]-.fi-.PP-And with \f[C]\-\-empty\f[], we can get a better picture of budget-allocation and consumption:-.IP-.nf-\f[C]-$\ hledger\ balance\ \-\-budget\ \-M\ \-\-empty-Budget\ performance\ in\ 2019/01:--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Jan\ -========================================++===============================-\ expenses\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ $283.00\ [\ \ 26%\ of\ \ $1100.00]\ -\ expenses:personal\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ $283.00\ [\ \ 26%\ of\ \ $1100.00]\ -\ expenses:personal:electronics\ \ \ \ \ \ \ \ \ \ ||\ \ $100.00\ [\ 100%\ of\ \ \ $100.00]\ -\ expenses:personal:electronics:upgrades\ ||\ \ \ $10.00\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -\ expenses:personal:train\ tickets\ \ \ \ \ \ \ \ ||\ \ $153.00\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ -\ liabilities\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ $\-283.00\ [\ \ 26%\ of\ $\-1100.00]\ -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ \ \ \ \ \ \ \ 0\ [\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0]\ -\f[]-.fi-.SS Output format-.PP-The balance command supports output destination and output format-selection.-.SS balancesheet-.PP-balancesheet, bs-.PD 0-.P-.PD-This command displays a simple balance sheet, showing historical ending-balances of asset and liability accounts (ignoring any report begin-date).-It assumes that these accounts are under a top\-level \f[C]asset\f[] or-\f[C]liability\f[] account (case insensitive, plural forms also-allowed).-.PP-Note this report shows all account balances with normal positive sign-(like conventional financial statements, unlike balance/print/register)-(experimental).-.PP-Example:-.IP-.nf-\f[C]-$\ hledger\ balancesheet-Balance\ Sheet--Assets:-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1\ \ assets-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ \ \ bank:saving-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-2\ \ \ \ cash-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1--Liabilities:-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ liabilities:debts-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1--Total:-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0-\f[]-.fi-.PP-With a reporting interval, multiple columns will be shown, one for each-report period.-As with multicolumn balance reports, you can alter the report mode with-\f[C]\-\-change\f[]/\f[C]\-\-cumulative\f[]/\f[C]\-\-historical\f[].-Normally balancesheet shows historical ending balances, which is what-you need for a balance sheet; note this means it ignores report begin-dates.-.PP-This command also supports output destination and output format-selection.-.SS balancesheetequity-.PP-balancesheetequity, bse-.PD 0-.P-.PD-Just like balancesheet, but also reports Equity (which it assumes is-under a top\-level \f[C]equity\f[] account).-.PP-Example:-.IP-.nf-\f[C]-$\ hledger\ balancesheetequity-Balance\ Sheet\ With\ Equity--Assets:-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-2\ \ assets-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ \ \ bank:saving-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-3\ \ \ \ cash-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-2--Liabilities:-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ liabilities:debts-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1--Equity:-\ \ \ \ \ \ \ \ \ \ $1\ \ equity:owner-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ $1--Total:-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0-\f[]-.fi-.SS cashflow-.PP-cashflow, cf-.PD 0-.P-.PD-This command displays a simple cashflow statement, showing changes in-"cash" accounts.-It assumes that these accounts are under a top\-level \f[C]asset\f[]-account (case insensitive, plural forms also allowed) and do not contain-\f[C]receivable\f[] or \f[C]A/R\f[] in their name.-Note this report shows all account balances with normal positive sign-(like conventional financial statements, unlike balance/print/register)-(experimental).-.PP-Example:-.IP-.nf-\f[C]-$\ hledger\ cashflow-Cashflow\ Statement--Cash\ flows:-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1\ \ assets-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ \ \ bank:saving-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-2\ \ \ \ cash-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1--Total:-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1-\f[]-.fi-.PP-With a reporting interval, multiple columns will be shown, one for each-report period.-Normally cashflow shows changes in assets per period, though as with-multicolumn balance reports you can alter the report mode with-\f[C]\-\-change\f[]/\f[C]\-\-cumulative\f[]/\f[C]\-\-historical\f[].-.PP-This command also supports output destination and output format-selection.-.SS check\-dates-.PP-check\-dates-.PD 0-.P-.PD-Check that transactions are sorted by increasing date.-With \-\-date2, checks secondary dates instead.-With \-\-strict, dates must also be unique.-With a query, only matched transactions\[aq] dates are checked.-Reads the default journal file, or another specified with \-f.-.SS check\-dupes-.PP-check\-dupes-.PD 0-.P-.PD-Reports account names having the same leaf but different prefixes.-In other words, two or more leaves that are categorized differently.-Reads the default journal file, or another specified as an argument.-.PP-An example: http://stefanorodighiero.net/software/hledger\-dupes.html-.SS close-.PP-close, equity-.PD 0-.P-.PD-Prints a "closing balances" transaction and an "opening balances"-transaction that bring account balances to and from zero, respectively.-Useful for bringing asset/liability balances forward into a new journal-file, or for closing out revenues/expenses to retained earnings at the-end of a period.-.PP-The closing transaction transfers balances to "equity:closing balances".-The opening transaction transfers balances from "equity:opening-balances".-You can chose to print just one of the transactions by using the-\f[C]\-\-opening\f[] or \f[C]\-\-closing\f[] flag.-.PP-If you split your journal files by time (eg yearly), you will typically-run this command at the end of the year, and save the closing-transaction as last entry of the old file, and the opening transaction-as the first entry of the new file.-This makes the files self contained, so that correct balances are-reported no matter which of them are loaded.-Ie, if you load just one file, the balances are initialised correctly;-or if you load several files, the redundant closing/opening transactions-cancel each other out.-(They will show up in print or register reports; you can exclude them-with a query like-\f[C]not:desc:\[aq](opening|closing)\ balances\[aq]\f[].)-.PP-If you\[aq]re running a business, you might also use this command to-"close the books" at the end of an accounting period, transferring-income statement account balances to retained earnings.-(You may want to change the equity account name to something like-"equity:retained earnings".)-.PP-By default, the closing transaction is dated yesterday, the balances are-calculated as of end of yesterday, and the opening transaction is dated-today.-To close on some other date, use:-\f[C]hledger\ close\ \-e\ OPENINGDATE\f[].-Eg, to close/open on the 2018/2019 boundary, use \f[C]\-e\ 2019\f[].-You can also use \-p or \f[C]date:PERIOD\f[] (any starting date is-ignored).-.PP-Both transactions will include balance assertions for the-closed/reopened accounts.-You probably shouldn\[aq]t use status or realness filters (like \-C or-\-R or \f[C]status:\f[]) with this command, or the generated balance-assertions will depend on these flags.-Likewise, if you run this command with \-\-auto, the balance assertions-will probably always require \-\-auto.-.PP-Examples:-.PP-Carrying asset/liability balances into a new file for 2019, all from-command line:-.PP-\f[I]Warning: we use \f[CI]>>\f[I] here to append; be careful not to-type a single \f[CI]>\f[I] which would wipe your journal!\f[]-.IP-.nf-\f[C]-$\ hledger\ close\ \-f\ 2018.journal\ \-e\ 2019\ assets\ liabilities\ \-\-opening\ >>2019.journal-$\ hledger\ close\ \-f\ 2018.journal\ \-e\ 2019\ assets\ liabilities\ \-\-closing\ >>2018.journal-\f[]-.fi-.PP-Now:-.IP-.nf-\f[C]-$\ hledger\ bs\ \-f\ 2019.journal\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ one\ file\ \-\ balances\ are\ correct-$\ hledger\ bs\ \-f\ 2018.journal\ \-f\ 2019.journal\ \ \ #\ two\ files\ \-\ balances\ still\ correct-$\ hledger\ bs\ \-f\ 2018.journal\ not:desc:closing\ \ #\ to\ see\ year\-end\ balances,\ must\ exclude\ closing\ txn-\f[]-.fi-.PP-Transactions spanning the closing date can complicate matters, breaking-balance assertions:-.IP-.nf-\f[C]-2018/12/30\ a\ purchase\ made\ in\ 2018,\ clearing\ the\ following\ year-\ \ \ \ expenses:food\ \ \ \ \ \ \ \ \ \ 5-\ \ \ \ assets:bank:checking\ \ \-5\ \ ;\ [2019/1/2]-\f[]-.fi-.PP-Here\[aq]s one way to resolve that:-.IP-.nf-\f[C]-;\ in\ 2018.journal:-2018/12/30\ a\ purchase\ made\ in\ 2018,\ clearing\ the\ following\ year-\ \ \ \ expenses:food\ \ \ \ \ \ \ \ \ \ 5-\ \ \ \ liabilities:pending--;\ in\ 2019.journal:-2019/1/2\ clearance\ of\ last\ year\[aq]s\ pending\ transactions-\ \ \ \ liabilities:pending\ \ \ \ 5\ =\ 0-\ \ \ \ assets:checking-\f[]-.fi-.SS files-.PP-files-.PD 0-.P-.PD-List all files included in the journal.-With a REGEX argument, only file names matching the regular expression-(case sensitive) are shown.-.SS help-.PP-help-.PD 0-.P-.PD-Show any of the hledger manuals.-.PP-The \f[C]help\f[] command displays any of the main hledger manuals, in-one of several ways.-Run it with no argument to list the manuals, or provide a full or-partial manual name to select one.-.PP-hledger manuals are available in several formats.-hledger help will use the first of these display methods that it finds:-info, man, $PAGER, less, stdout (or when non\-interactive, just stdout).-You can force a particular viewer with the \f[C]\-\-info\f[],-\f[C]\-\-man\f[], \f[C]\-\-pager\f[], \f[C]\-\-cat\f[] flags.-.PP-Examples:-.IP-.nf-\f[C]-$\ hledger\ help-Please\ choose\ a\ manual\ by\ typing\ "hledger\ help\ MANUAL"\ (a\ substring\ is\ ok).-Manuals:\ hledger\ hledger\-ui\ hledger\-web\ hledger\-api\ journal\ csv\ timeclock\ timedot-\f[]-.fi-.IP-.nf-\f[C]-$\ hledger\ help\ h\ \-\-man--hledger(1)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ hledger\ User\ Manuals\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ hledger(1)--NAME-\ \ \ \ \ \ \ hledger\ \-\ a\ command\-line\ accounting\ tool--SYNOPSIS-\ \ \ \ \ \ \ hledger\ [\-f\ FILE]\ COMMAND\ [OPTIONS]\ [ARGS]-\ \ \ \ \ \ \ hledger\ [\-f\ FILE]\ ADDONCMD\ \-\-\ [OPTIONS]\ [ARGS]-\ \ \ \ \ \ \ hledger--DESCRIPTION-\ \ \ \ \ \ \ hledger\ \ is\ \ a\ \ cross\-platform\ \ program\ \ for\ tracking\ money,\ time,\ or\ any-\&...-\f[]-.fi-.SS import-.PP-import-.PD 0-.P-.PD-Read new transactions added to each FILE since last run, and add them to-the main journal file.-Or with \-\-dry\-run, just print the transactions that would be added.-.PP-The input files are specified as arguments \- no need to write \-f-before each one.-So eg to add new transactions from all CSV files to the main journal,-it\[aq]s just: \f[C]hledger\ import\ *.csv\f[]-.PP-New transactions are detected in the same way as print \-\-new: by-assuming transactions are always added to the input files in increasing-date order, and by saving \f[C]\&.latest.FILE\f[] state files.-.PP-The \-\-dry\-run output is in journal format, so you can filter it, eg-to see only uncategorised transactions:-.IP-.nf-\f[C]-$\ hledger\ import\ \-\-dry\ ...\ |\ hledger\ \-f\-\ print\ unknown\ \-\-ignore\-assertions-\f[]-.fi-.SS incomestatement-.PP-incomestatement, is-.PD 0-.P-.PD-This command displays a simple income statement, showing revenues and-expenses during a period.-It assumes that these accounts are under a top\-level \f[C]revenue\f[]-or \f[C]income\f[] or \f[C]expense\f[] account (case insensitive, plural-forms also allowed).-Note this report shows all account balances with normal positive sign-(like conventional financial statements, unlike balance/print/register)-(experimental).-.PP-This command displays a simple income statement.-It currently assumes that you have top\-level accounts named-\f[C]income\f[] (or \f[C]revenue\f[]) and \f[C]expense\f[] (plural forms-also allowed.)-.IP-.nf-\f[C]-$\ hledger\ incomestatement-Income\ Statement--Revenues:-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-2\ \ income-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1\ \ \ \ gifts-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1\ \ \ \ salary-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-2--Expenses:-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $2\ \ expenses-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ \ \ food-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ \ \ supplies-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $2--Total:-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0-\f[]-.fi-.PP-With a reporting interval, multiple columns will be shown, one for each-report period.-Normally incomestatement shows revenues/expenses per period, though as-with multicolumn balance reports you can alter the report mode with-\f[C]\-\-change\f[]/\f[C]\-\-cumulative\f[]/\f[C]\-\-historical\f[].-.PP-This command also supports output destination and output format-selection.-.SS prices-.PP-prices-.PD 0-.P-.PD-Print market price directives from the journal.-With \-\-costs, also print synthetic market prices based on transaction-prices.-With \-\-inverted\-costs, also print inverse prices based on transaction-prices.-Prices (and postings providing prices) can be filtered by a query.-.SS print-.PP-print, txns, p-.PD 0-.P-.PD-Show transaction journal entries, sorted by date.-.PP-The print command displays full journal entries (transactions) from the-journal file in date order, tidily formatted.-With \-\-date2, transactions are sorted by secondary date instead.-.PP-print\[aq]s output is always a valid hledger journal.-.PD 0-.P-.PD-It preserves all transaction information, but it does not preserve-directives or inter\-transaction comments-.IP-.nf-\f[C]-$\ hledger\ print-2008/01/01\ income-\ \ \ \ assets:bank:checking\ \ \ \ \ \ \ \ \ \ \ \ $1-\ \ \ \ income:salary\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1--2008/06/01\ gift-\ \ \ \ assets:bank:checking\ \ \ \ \ \ \ \ \ \ \ \ $1-\ \ \ \ income:gifts\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1--2008/06/02\ save-\ \ \ \ assets:bank:saving\ \ \ \ \ \ \ \ \ \ \ \ \ \ $1-\ \ \ \ assets:bank:checking\ \ \ \ \ \ \ \ \ \ \ $\-1--2008/06/03\ *\ eat\ &\ shop-\ \ \ \ expenses:food\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1-\ \ \ \ expenses:supplies\ \ \ \ \ \ \ \ \ \ \ \ $1-\ \ \ \ assets:cash\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-2--2008/12/31\ *\ pay\ off-\ \ \ \ liabilities:debts\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1-\ \ \ \ assets:bank:checking\ \ \ \ \ \ \ \ \ \ \ $\-1-\f[]-.fi-.PP-Normally, the journal entry\[aq]s explicit or implicit amount style is-preserved.-Ie when an amount is omitted in the journal, it will be omitted in the-output.-You can use the \f[C]\-x\f[]/\f[C]\-\-explicit\f[] flag to make all-amounts explicit, which can be useful for troubleshooting or for making-your journal more readable and robust against data entry errors.-Note, \f[C]\-x\f[] will cause postings with a multi\-commodity amount-(these can arise when a multi\-commodity transaction has an implicit-amount) will be split into multiple single\-commodity postings, for-valid journal output.-.PP-With \f[C]\-B\f[]/\f[C]\-\-cost\f[], amounts with transaction prices are-converted to cost using that price.-This can be used for troubleshooting.-.PP-With \f[C]\-m\f[]/\f[C]\-\-match\f[] and a STR argument, print will show-at most one transaction: the one one whose description is most similar-to STR, and is most recent.-STR should contain at least two characters.-If there is no similar\-enough match, no transaction will be shown.-.PP-With \f[C]\-\-new\f[], for each FILE being read, hledger reads (and-writes) a special state file (\f[C]\&.latest.FILE\f[] in the same-directory), containing the latest transaction date(s) that were seen-last time FILE was read.-When this file is found, only transactions with newer dates (and new-transactions on the latest date) are printed.-This is useful for ignoring already\-seen entries in import data, such-as downloaded CSV files.-Eg:-.IP-.nf-\f[C]-$\ hledger\ \-f\ bank1.csv\ print\ \-\-new-#\ shows\ transactions\ added\ since\ last\ print\ \-\-new\ on\ this\ file-\f[]-.fi-.PP-This assumes that transactions added to FILE always have same or-increasing dates, and that transactions on the same day do not get-reordered.-See also the import command.-.PP-This command also supports output destination and output format-selection.-Here\[aq]s an example of print\[aq]s CSV output:-.IP-.nf-\f[C]-$\ hledger\ print\ \-Ocsv-"txnidx","date","date2","status","code","description","comment","account","amount","commodity","credit","debit","posting\-status","posting\-comment"-"1","2008/01/01","","","","income","","assets:bank:checking","1","$","","1","",""-"1","2008/01/01","","","","income","","income:salary","\-1","$","1","","",""-"2","2008/06/01","","","","gift","","assets:bank:checking","1","$","","1","",""-"2","2008/06/01","","","","gift","","income:gifts","\-1","$","1","","",""-"3","2008/06/02","","","","save","","assets:bank:saving","1","$","","1","",""-"3","2008/06/02","","","","save","","assets:bank:checking","\-1","$","1","","",""-"4","2008/06/03","","*","","eat\ &\ shop","","expenses:food","1","$","","1","",""-"4","2008/06/03","","*","","eat\ &\ shop","","expenses:supplies","1","$","","1","",""-"4","2008/06/03","","*","","eat\ &\ shop","","assets:cash","\-2","$","2","","",""-"5","2008/12/31","","*","","pay\ off","","liabilities:debts","1","$","","1","",""-"5","2008/12/31","","*","","pay\ off","","assets:bank:checking","\-1","$","1","","",""-\f[]-.fi-.IP \[bu] 2-There is one CSV record per posting, with the parent transaction\[aq]s-fields repeated.-.IP \[bu] 2-The "txnidx" (transaction index) field shows which postings belong to-the same transaction.-(This number might change if transactions are reordered within the file,-files are parsed/included in a different order, etc.)-.IP \[bu] 2-The amount is separated into "commodity" (the symbol) and "amount"-(numeric quantity) fields.-.IP \[bu] 2-The numeric amount is repeated in either the "credit" or "debit" column,-for convenience.-(Those names are not accurate in the accounting sense; it just puts-negative amounts under credit and zero or greater amounts under debit.)-.SS print\-unique-.PP-print\-unique-.PD 0-.P-.PD-Print transactions which do not reuse an already\-seen description.-.PP-Example:-.IP-.nf-\f[C]-$\ cat\ unique.journal-1/1\ test-\ (acct:one)\ \ 1-2/2\ test-\ (acct:two)\ \ 2-$\ LEDGER_FILE=unique.journal\ hledger\ print\-unique-(\-f\ option\ not\ supported)-2015/01/01\ test-\ \ \ \ (acct:one)\ \ \ \ \ \ \ \ \ \ \ \ \ 1-\f[]-.fi-.SS register-.PP-register, reg, r-.PD 0-.P-.PD-Show postings and their running total.-.PP-The register command displays postings in date order, one per line, and-their running total.-This is typically used with a query selecting a particular account, to-see that account\[aq]s activity:-.IP-.nf-\f[C]-$\ hledger\ register\ checking-2008/01/01\ income\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ assets:bank:checking\ \ \ \ \ \ \ \ \ \ \ \ $1\ \ \ \ \ \ \ \ \ \ \ $1-2008/06/01\ gift\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ assets:bank:checking\ \ \ \ \ \ \ \ \ \ \ \ $1\ \ \ \ \ \ \ \ \ \ \ $2-2008/06/02\ save\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ assets:bank:checking\ \ \ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ \ \ $1-2008/12/31\ pay\ off\ \ \ \ \ \ \ \ \ \ \ \ \ \ assets:bank:checking\ \ \ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ \ \ \ 0-\f[]-.fi-.PP-With \-\-date2, it shows and sorts by secondary date instead.-.PP-The \f[C]\-\-historical\f[]/\f[C]\-H\f[] flag adds the balance from any-undisplayed prior postings to the running total.-This is useful when you want to see only recent activity, with a-historically accurate running balance:-.IP-.nf-\f[C]-$\ hledger\ register\ checking\ \-b\ 2008/6\ \-\-historical-2008/06/01\ gift\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ assets:bank:checking\ \ \ \ \ \ \ \ \ \ \ \ $1\ \ \ \ \ \ \ \ \ \ \ $2-2008/06/02\ save\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ assets:bank:checking\ \ \ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ \ \ $1-2008/12/31\ pay\ off\ \ \ \ \ \ \ \ \ \ \ \ \ \ assets:bank:checking\ \ \ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ \ \ \ 0-\f[]-.fi-.PP-The \f[C]\-\-depth\f[] option limits the amount of sub\-account detail-displayed.-.PP-The \f[C]\-\-average\f[]/\f[C]\-A\f[] flag shows the running average-posting amount instead of the running total (so, the final number-displayed is the average for the whole report period).-This flag implies \f[C]\-\-empty\f[] (see below).-It is affected by \f[C]\-\-historical\f[].-It works best when showing just one account and one commodity.-.PP-The \f[C]\-\-related\f[]/\f[C]\-r\f[] flag shows the \f[I]other\f[]-postings in the transactions of the postings which would normally be-shown.-.PP-The \f[C]\-\-invert\f[] flag negates all amounts.-For example, it can be used on an income account where amounts are-normally displayed as negative numbers.-It\[aq]s also useful to show postings on the checking account together-with the related account:-.IP-.nf-\f[C]-$\ hledger\ register\ \-\-related\ \-\-invert\ assets:checking-\f[]-.fi-.PP-With a reporting interval, register shows summary postings, one per-interval, aggregating the postings to each account:-.IP-.nf-\f[C]-$\ hledger\ register\ \-\-monthly\ income-2008/01\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ income:salary\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ \ $\-1-2008/06\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ income:gifts\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ \ $\-2-\f[]-.fi-.PP-Periods with no activity, and summary postings with a zero amount, are-not shown by default; use the \f[C]\-\-empty\f[]/\f[C]\-E\f[] flag to-see them:-.IP-.nf-\f[C]-$\ hledger\ register\ \-\-monthly\ income\ \-E-2008/01\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ income:salary\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ \ $\-1-2008/02\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ $\-1-2008/03\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ $\-1-2008/04\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ $\-1-2008/05\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ $\-1-2008/06\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ income:gifts\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ \ $\-2-2008/07\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ $\-2-2008/08\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ $\-2-2008/09\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ $\-2-2008/10\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ $\-2-2008/11\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ $\-2-2008/12\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0\ \ \ \ \ \ \ \ \ \ $\-2-\f[]-.fi-.PP-Often, you\[aq]ll want to see just one line per interval.-The \f[C]\-\-depth\f[] option helps with this, causing subaccounts to be-aggregated:-.IP-.nf-\f[C]-$\ hledger\ register\ \-\-monthly\ assets\ \-\-depth\ 1h-2008/01\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ assets\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $1\ \ \ \ \ \ \ \ \ \ \ $1-2008/06\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ assets\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ \ \ \ 0-2008/12\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ assets\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $\-1\ \ \ \ \ \ \ \ \ \ $\-1-\f[]-.fi-.PP-Note when using report intervals, if you specify start/end dates these-will be adjusted outward if necessary to contain a whole number of-intervals.-This ensures that the first and last intervals are full length and-comparable to the others in the report.-.SS Custom register output-.PP-register uses the full terminal width by default, except on windows.-You can override this by setting the \f[C]COLUMNS\f[] environment-variable (not a bash shell variable) or by using the-\f[C]\-\-width\f[]/\f[C]\-w\f[] option.-.PP-The description and account columns normally share the space equally-(about half of (width \- 40) each).-You can adjust this by adding a description width as part of-\-\-width\[aq]s argument, comma\-separated: \f[C]\-\-width\ W,D\f[] .-Here\[aq]s a diagram (won\[aq]t display correctly in \-\-help):-.IP-.nf-\f[C]-<\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\ width\ (W)\ \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\->-date\ (10)\ \ description\ (D)\ \ \ \ \ \ \ account\ (W\-41\-D)\ \ \ \ \ amount\ (12)\ \ \ balance\ (12)-DDDDDDDDDD\ dddddddddddddddddddd\ \ aaaaaaaaaaaaaaaaaaa\ \ AAAAAAAAAAAA\ \ AAAAAAAAAAAA-\f[]-.fi-.PP-and some examples:-.IP-.nf-\f[C]-$\ hledger\ reg\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ use\ terminal\ width\ (or\ 80\ on\ windows)-$\ hledger\ reg\ \-w\ 100\ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ use\ width\ 100-$\ COLUMNS=100\ hledger\ reg\ \ \ \ \ \ \ \ \ #\ set\ with\ one\-time\ environment\ variable-$\ export\ COLUMNS=100;\ hledger\ reg\ #\ set\ till\ session\ end\ (or\ window\ resize)-$\ hledger\ reg\ \-w\ 100,40\ \ \ \ \ \ \ \ \ \ \ #\ set\ overall\ width\ 100,\ description\ width\ 40-$\ hledger\ reg\ \-w\ $COLUMNS,40\ \ \ \ \ \ #\ use\ terminal\ width,\ &\ description\ width\ 40-\f[]-.fi-.PP-This command also supports output destination and output format-selection.-.SS register\-match-.PP-register\-match-.PD 0-.P-.PD-Print the one posting whose transaction description is closest to DESC,-in the style of the register command.-If there are multiple equally good matches, it shows the most recent.-Query options (options, not arguments) can be used to restrict the-search space.-Helps ledger\-autosync detect already\-seen transactions when importing.-.SS rewrite-.PP-rewrite-.PD 0-.P-.PD-Print all transactions, rewriting the postings of matched transactions.-For now the only rewrite available is adding new postings, like print-\-\-auto.-.PP-This is a start at a generic rewriter of transaction entries.-It reads the default journal and prints the transactions, like print,-but adds one or more specified postings to any transactions matching-QUERY.-The posting amounts can be fixed, or a multiplier of the existing-transaction\[aq]s first posting amount.-.PP-Examples:-.IP-.nf-\f[C]-hledger\-rewrite.hs\ ^income\ \-\-add\-posting\ \[aq](liabilities:tax)\ \ *.33\ \ ;\ income\ tax\[aq]\ \-\-add\-posting\ \[aq](reserve:gifts)\ \ $100\[aq]-hledger\-rewrite.hs\ expenses:gifts\ \-\-add\-posting\ \[aq](reserve:gifts)\ \ *\-1"\[aq]-hledger\-rewrite.hs\ \-f\ rewrites.hledger-\f[]-.fi-.PP-rewrites.hledger may consist of entries like:-.IP-.nf-\f[C]-=\ ^income\ amt:<0\ date:2017-\ \ (liabilities:tax)\ \ *0.33\ \ ;\ tax\ on\ income-\ \ (reserve:grocery)\ \ *0.25\ \ ;\ reserve\ 25%\ for\ grocery-\ \ (reserve:)\ \ *0.25\ \ ;\ reserve\ 25%\ for\ grocery-\f[]-.fi-.PP-Note the single quotes to protect the dollar sign from bash, and the two-spaces between account and amount.-.PP-More:-.IP-.nf-\f[C]-$\ hledger\ rewrite\ \-\-\ [QUERY]\ \ \ \ \ \ \ \ \-\-add\-posting\ "ACCT\ \ AMTEXPR"\ ...-$\ hledger\ rewrite\ \-\-\ ^income\ \ \ \ \ \ \ \ \-\-add\-posting\ \[aq](liabilities:tax)\ \ *.33\[aq]-$\ hledger\ rewrite\ \-\-\ expenses:gifts\ \-\-add\-posting\ \[aq](budget:gifts)\ \ *\-1"\[aq]-$\ hledger\ rewrite\ \-\-\ ^income\ \ \ \ \ \ \ \ \-\-add\-posting\ \[aq](budget:foreign\ currency)\ \ *0.25\ JPY;\ diversify\[aq]-\f[]-.fi-.PP-Argument for \f[C]\-\-add\-posting\f[] option is a usual posting of-transaction with an exception for amount specification.-More precisely, you can use \f[C]\[aq]*\[aq]\f[] (star symbol) before-the amount to indicate that that this is a factor for an amount of-original matched posting.-If the amount includes a commodity name, the new posting amount will be-in the new commodity; otherwise, it will be in the matched posting-amount\[aq]s commodity.-.SS Re\-write rules in a file-.PP-During the run this tool will execute so called "Automated Transactions"-found in any journal it process.-I.e instead of specifying this operations in command line you can put-them in a journal file.-.IP-.nf-\f[C]-$\ rewrite\-rules.journal-\f[]-.fi-.PP-Make contents look like this:-.IP-.nf-\f[C]-=\ ^income-\ \ \ \ (liabilities:tax)\ \ *.33--=\ expenses:gifts-\ \ \ \ budget:gifts\ \ *\-1-\ \ \ \ assets:budget\ \ *1-\f[]-.fi-.PP-Note that \f[C]\[aq]=\[aq]\f[] (equality symbol) that is used instead of-date in transactions you usually write.-It indicates the query by which you want to match the posting to add new-ones.-.IP-.nf-\f[C]-$\ hledger\ rewrite\ \-\-\ \-f\ input.journal\ \-f\ rewrite\-rules.journal\ >\ rewritten\-tidy\-output.journal-\f[]-.fi-.PP-This is something similar to the commands pipeline:-.IP-.nf-\f[C]-$\ hledger\ rewrite\ \-\-\ \-f\ input.journal\ \[aq]^income\[aq]\ \-\-add\-posting\ \[aq](liabilities:tax)\ \ *.33\[aq]\ \\-\ \ |\ hledger\ rewrite\ \-\-\ \-f\ \-\ expenses:gifts\ \ \ \ \ \ \-\-add\-posting\ \[aq]budget:gifts\ \ *\-1\[aq]\ \ \ \ \ \ \ \\-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \-\-add\-posting\ \[aq]assets:budget\ \ *1\[aq]\ \ \ \ \ \ \ \\-\ \ >\ rewritten\-tidy\-output.journal-\f[]-.fi-.PP-It is important to understand that relative order of such entries in-journal is important.-You can re\-use result of previously added postings.-.SS Diff output format-.PP-To use this tool for batch modification of your journal files you may-find useful output in form of unified diff.-.IP-.nf-\f[C]-$\ hledger\ rewrite\ \-\-\ \-\-diff\ \-f\ examples/sample.journal\ \[aq]^income\[aq]\ \-\-add\-posting\ \[aq](liabilities:tax)\ \ *.33\[aq]-\f[]-.fi-.PP-Output might look like:-.IP-.nf-\f[C]-\-\-\-\ /tmp/examples/sample.journal-+++\ /tmp/examples/sample.journal-\@\@\ \-18,3\ +18,4\ \@\@-\ 2008/01/01\ income-\-\ \ \ \ assets:bank:checking\ \ $1-+\ \ \ \ assets:bank:checking\ \ \ \ \ \ \ \ \ \ \ \ $1-\ \ \ \ \ income:salary-+\ \ \ \ (liabilities:tax)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0-\@\@\ \-22,3\ +23,4\ \@\@-\ 2008/06/01\ gift-\-\ \ \ \ assets:bank:checking\ \ $1-+\ \ \ \ assets:bank:checking\ \ \ \ \ \ \ \ \ \ \ \ $1-\ \ \ \ \ income:gifts-+\ \ \ \ (liabilities:tax)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0-\f[]-.fi-.PP-If you\[aq]ll pass this through \f[C]patch\f[] tool you\[aq]ll get-transactions containing the posting that matches your query be updated.-Note that multiple files might be update according to list of input-files specified via \f[C]\-\-file\f[] options and \f[C]include\f[]-directives inside of these files.-.PP-Be careful.-Whole transaction being re\-formatted in a style of output from-\f[C]hledger\ print\f[].-.PP-See also:-.PP-https://github.com/simonmichael/hledger/issues/99-.SS rewrite vs. print \-\-auto-.PP-This command predates print \-\-auto, and currently does much the same-thing, but with these differences:-.IP \[bu] 2-with multiple files, rewrite lets rules in any file affect all other-files.-print \-\-auto uses standard directive scoping; rules affect only child-files.-.IP \[bu] 2-rewrite\[aq]s query limits which transactions can be rewritten; all are-printed.-print \-\-auto\[aq]s query limits which transactions are printed.-.IP \[bu] 2-rewrite applies rules specified on command line or in the journal.-print \-\-auto applies rules specified in the journal.-.SS roi-.PP-roi-.PD 0-.P-.PD-Shows the time\-weighted (TWR) and money\-weighted (IRR) rate of return-on your investments.-.PP-This command assumes that you have account(s) that hold nothing but your-investments and whenever you record current appraisal/valuation of these-investments you offset unrealized profit and loss into account(s) that,-again, hold nothing but unrealized profit and loss.-.PP-Any transactions affecting balance of investment account(s) and not-originating from unrealized profit and loss account(s) are assumed to be-your investments or withdrawals.-.PP-At a minimum, you need to supply a query (which could be just an account-name) to select your investments with \f[C]\-\-inv\f[], and another-query to identify your profit and loss transactions with-\f[C]\-\-pnl\f[].-.PP-It will compute and display the internalized rate of return (IRR) and-time\-weighted rate of return (TWR) for your investments for the time-period requested.-Both rates of return are annualized before display, regardless of the-length of reporting interval.-.SS stats-.PP-stats-.PD 0-.P-.PD-Show some journal statistics.-.PP-The stats command displays summary information for the whole journal, or-a matched part of it.-With a reporting interval, it shows a report for each report period.-.PP-Example:-.IP-.nf-\f[C]-$\ hledger\ stats-Main\ journal\ file\ \ \ \ \ \ \ \ :\ /src/hledger/examples/sample.journal-Included\ journal\ files\ \ \ :\ -Transactions\ span\ \ \ \ \ \ \ \ :\ 2008\-01\-01\ to\ 2009\-01\-01\ (366\ days)-Last\ transaction\ \ \ \ \ \ \ \ \ :\ 2008\-12\-31\ (2333\ days\ ago)-Transactions\ \ \ \ \ \ \ \ \ \ \ \ \ :\ 5\ (0.0\ per\ day)-Transactions\ last\ 30\ days:\ 0\ (0.0\ per\ day)-Transactions\ last\ 7\ days\ :\ 0\ (0.0\ per\ day)-Payees/descriptions\ \ \ \ \ \ :\ 5-Accounts\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ :\ 8\ (depth\ 3)-Commodities\ \ \ \ \ \ \ \ \ \ \ \ \ \ :\ 1\ ($)-\f[]-.fi-.PP-This command also supports output destination and output format-selection.-.SS tags-.PP-tags-.PD 0-.P-.PD-List all the tag names used in the journal.-With a TAGREGEX argument, only tag names matching the regular expression-(case insensitive) are shown.-With QUERY arguments, only transactions matching the query are-considered.-.SS test-.PP-test-.PD 0-.P-.PD-Run built\-in unit tests.-.PP-This command runs the unit tests built in to hledger\-lib and hledger,-printing test names and results on stdout.-If any test fails, the exit code will be non\-zero.-.PP-Test names include a group prefix.-If a (exact, case sensitive) group prefix, or a full test name is-provided as the first argument, only that group or test is run.-.PP-If a numeric second argument is provided, it will set the randomness-seed, for repeatable results from tests using randomness (currently none-of them).-.PP-This is mainly used by developers, but it\[aq]s nice to be able to-sanity\-check your installed hledger executable at any time.-All tests are expected to pass \- if you ever see otherwise, something-has gone wrong, please report a bug!-.SH ADD\-ON COMMANDS-.PP-hledger also searches for external add\-on commands, and will include-these in the commands list.-These are programs or scripts in your PATH whose name starts with-\f[C]hledger\-\f[] and ends with a recognised file extension (currently:-no extension, \f[C]bat\f[],\f[C]com\f[],\f[C]exe\f[],-\f[C]hs\f[],\f[C]lhs\f[],\f[C]pl\f[],\f[C]py\f[],\f[C]rb\f[],\f[C]rkt\f[],\f[C]sh\f[]).-.PP-Add\-ons can be invoked like any hledger command, but there are a few-things to be aware of.-Eg if the \f[C]hledger\-web\f[] add\-on is installed,-.IP \[bu] 2-\f[C]hledger\ \-h\ web\f[] shows hledger\[aq]s help, while-\f[C]hledger\ web\ \-h\f[] shows hledger\-web\[aq]s help.-.IP \[bu] 2-Flags specific to the add\-on must have a preceding \f[C]\-\-\f[] to-hide them from hledger.-So \f[C]hledger\ web\ \-\-serve\ \-\-port\ 9000\f[] will be rejected;-you must use \f[C]hledger\ web\ \-\-\ \-\-serve\ \-\-port\ 9000\f[].-.IP \[bu] 2-You can always run add\-ons directly if preferred:-\f[C]hledger\-web\ \-\-serve\ \-\-port\ 9000\f[].-.PP-Add\-ons are a relatively easy way to add local features or experiment-with new ideas.-They can be written in any language, but haskell scripts have a big-advantage: they can use the same hledger (and haskell) library functions-that built\-in commands do, for command\-line options, journal parsing,-reporting, etc.-.PP-Here are some hledger add\-ons available:-.SS Official add\-ons-.PP-These are maintained and released along with hledger.-.SS api-.PP-hledger\-api serves hledger data as a JSON web API.-.SS ui-.PP-hledger\-ui provides an efficient curses\-style interface.-.SS web-.PP-hledger\-web provides a simple web interface.-.SS Third party add\-ons-.PP-These are maintained separately, and usually updated shortly after a-hledger release.-.SS diff-.PP-hledger\-diff shows differences in an account\[aq]s transactions between-one journal file and another.-.SS iadd-.PP-hledger\-iadd is a curses\-style, more interactive replacement for the-add command.-.SS interest-.PP-hledger\-interest generates interest transactions for an account-according to various schemes.-.SS irr-.PP-hledger\-irr calculates the internal rate of return of an investment-account, but it\[aq]s superseded now by the built\-in roi command.-.SS Experimental add\-ons-.PP-These are available in source form in the hledger repo\[aq]s bin/-directory; installing them is pretty easy.-They may be less mature and documented than built\-in commands.-Reading and tweaking these is a good way to start making your own!-.SS autosync-.PP-hledger\-autosync is a symbolic link for easily running-ledger\-autosync, if installed.-ledger\-autosync does deduplicating conversion of OFX data and some CSV-formats, and can also download the data if your bank offers OFX Direct-Connect.-.SS chart-.PP-hledger\-chart.hs is an old pie chart generator, in need of some love.-.SS check-.PP-hledger\-check.hs checks more powerful account balance assertions.-.SH ENVIRONMENT-.PP-\f[B]COLUMNS\f[] The screen width used by the register command.-Default: the full terminal width.-.PP-\f[B]LEDGER_FILE\f[] The journal file path when not specified with-\f[C]\-f\f[].-Default: \f[C]~/.hledger.journal\f[] (on windows, perhaps-\f[C]C:/Users/USER/.hledger.journal\f[]).-.SH FILES-.PP-Reads data from one or more files in hledger journal, timeclock,-timedot, or CSV format specified with \f[C]\-f\f[], or-\f[C]$LEDGER_FILE\f[], or \f[C]$HOME/.hledger.journal\f[] (on windows,-perhaps \f[C]C:/Users/USER/.hledger.journal\f[]).-.SH BUGS-.PP-The need to precede addon command options with \f[C]\-\-\f[] when-invoked from hledger is awkward.-.PP-When input data contains non\-ascii characters, a suitable system locale-must be configured (or there will be an unhelpful error).-Eg on POSIX, set LANG to something other than C.-.PP-In a Microsoft Windows CMD window, non\-ascii characters and colours are-not supported.-.PP-In a Cygwin/MSYS/Mintty window, the tab key is not supported in hledger-add.-.PP-Not all of Ledger\[aq]s journal file syntax is supported.-See file format differences.-.PP-On large data files, hledger is slower and uses more memory than Ledger.-.SH TROUBLESHOOTING-.PP-Here are some issues you might encounter when you run hledger (and-remember you can also seek help from the IRC channel, mail list or bug-tracker):-.PP-\f[B]Successfully installed, but "No command \[aq]hledger\[aq]-found"\f[]-.PD 0-.P-.PD-stack and cabal install binaries into a special directory, which should-be added to your PATH environment variable.-Eg on unix\-like systems, that is ~/.local/bin and ~/.cabal/bin-respectively.-.PP-\f[B]I set a custom LEDGER_FILE, but hledger is still using the default-file\f[]-.PD 0-.P-.PD-\f[C]LEDGER_FILE\f[] should be a real environment variable, not just a-shell variable.-The command \f[C]env\ |\ grep\ LEDGER_FILE\f[] should show it.-You may need to use \f[C]export\f[].-Here\[aq]s an explanation.-.PP-\f[B]"Illegal byte sequence" or "Invalid or incomplete multibyte or wide-character" errors\f[]-.PD 0-.P-.PD-In order to handle non\-ascii letters and symbols (like £), hledger-needs an appropriate locale.-This is usually configured system\-wide; you can also configure it-temporarily.-The locale may need to be one that supports UTF\-8, if you built hledger-with GHC < 7.2 (or possibly always, I\[aq]m not sure yet).-.PP-Here\[aq]s an example of setting the locale temporarily, on ubuntu-gnu/linux:-.IP-.nf-\f[C]-$\ file\ my.journal-my.journal:\ UTF\-8\ Unicode\ text\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ <\-\ the\ file\ is\ UTF8\-encoded-$\ locale\ \-a-C-en_US.utf8\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ <\-\ a\ UTF8\-aware\ locale\ is\ available-POSIX-$\ LANG=en_US.utf8\ hledger\ \-f\ my.journal\ print\ \ \ #\ <\-\ use\ it\ for\ this\ command-\f[]-.fi-.PP-Here\[aq]s one way to set it permanently, there are probably better-ways:-.IP-.nf-\f[C]-$\ echo\ "export\ LANG=en_US.UTF\-8"\ >>~/.bash_profile-$\ bash\ \-\-login-\f[]-.fi-.PP-If we preferred to use eg \f[C]fr_FR.utf8\f[], we might have to install-that first:-.IP-.nf-\f[C]-$\ apt\-get\ install\ language\-pack\-fr-$\ locale\ \-a-C-en_US.utf8-fr_BE.utf8-fr_CA.utf8-fr_CH.utf8-fr_FR.utf8-fr_LU.utf8-POSIX-$\ LANG=fr_FR.utf8\ hledger\ \-f\ my.journal\ print-\f[]-.fi-.PP-Note some platforms allow variant locale spellings, but not all (ubuntu-accepts \f[C]fr_FR.UTF8\f[], mac osx requires exactly-\f[C]fr_FR.UTF\-8\f[]).+.TH "hledger" "1" "August 2019" "hledger 1.15" "hledger User Manuals"++++.SH NAME+.PP+hledger - a command-line accounting tool+.SH SYNOPSIS+.PP+\f[C]hledger [-f FILE] COMMAND [OPTIONS] [ARGS]\f[R]+.PD 0+.P+.PD+\f[C]hledger [-f FILE] ADDONCMD -- [OPTIONS] [ARGS]\f[R]+.PD 0+.P+.PD+\f[C]hledger\f[R]+.SH DESCRIPTION+.PP+hledger is a cross-platform program for tracking money, time, or any+other commodity, using double-entry accounting and a simple, editable+file format.+hledger is inspired by and largely compatible with ledger(1).+.PD 0+.P+.PD+Tested on unix, mac, windows, hledger aims to be a reliable, practical+tool for daily use.+.PP+This is hledger\[cq]s command-line interface (there are also curses and+web interfaces).+Its basic function is to read a plain text file describing financial+transactions (in accounting terms, a general journal) and print useful+reports on standard output, or export them as CSV.+hledger can also read some other file formats such as CSV files,+translating them to journal format.+Additionally, hledger lists other hledger-* executables found in the+user\[cq]s $PATH and can invoke them as subcommands.+.PP+hledger reads data from one or more files in hledger journal, timeclock,+timedot, or CSV format specified with \f[C]-f\f[R], or+\f[C]$LEDGER_FILE\f[R], or \f[C]$HOME/.hledger.journal\f[R] (on windows,+perhaps \f[C]C:/Users/USER/.hledger.journal\f[R]).+If using \f[C]$LEDGER_FILE\f[R], note this must be a real environment+variable, not a shell variable.+You can specify standard input with \f[C]-f-\f[R].+.PP+Transactions are dated movements of money between two (or more) named+accounts, and are recorded with journal entries like this:+.IP+.nf+\f[C]+2015/10/16 bought food+ expenses:food          $10+ assets:cash+\f[R]+.fi+.PP+For more about this format, see hledger_journal(5).+.PP+Most users use a text editor to edit the journal, usually with an editor+mode such as ledger-mode for added convenience.+hledger\[cq]s interactive add command is another way to record new+transactions.+hledger never changes existing transactions.+.PP+To get started, you can either save some entries like the above in+\f[C]\[ti]/.hledger.journal\f[R], or run \f[C]hledger add\f[R] and+follow the prompts.+Then try some commands like \f[C]hledger print\f[R] or+\f[C]hledger balance\f[R].+Run \f[C]hledger\f[R] with no arguments for a list of commands.+.SH EXAMPLES+.PP+Two simple transactions in hledger journal format:+.IP+.nf+\f[C]+2015/9/30 gift received+  assets:cash   $20+  income:gifts++2015/10/16 farmers market+  expenses:food    $10+  assets:cash+\f[R]+.fi+.PP+Some basic reports:+.IP+.nf+\f[C]+$ hledger print+2015/09/30 gift received+    assets:cash            $20+    income:gifts          $-20++2015/10/16 farmers market+    expenses:food           $10+    assets:cash            $-10+\f[R]+.fi+.IP+.nf+\f[C]+$ hledger accounts --tree+assets+  cash+expenses+  food+income+  gifts+\f[R]+.fi+.IP+.nf+\f[C]+$ hledger balance+                 $10  assets:cash+                 $10  expenses:food+                $-20  income:gifts+--------------------+                   0+\f[R]+.fi+.IP+.nf+\f[C]+$ hledger register cash+2015/09/30 gift received   assets:cash               $20           $20+2015/10/16 farmers market  assets:cash              $-10           $10+\f[R]+.fi+.PP+More commands:+.IP+.nf+\f[C]+$ hledger                                 # show available commands+$ hledger add                             # add more transactions to the journal file+$ hledger balance                         # all accounts with aggregated balances+$ hledger balance --help                  # show detailed help for balance command+$ hledger balance --depth 1               # only top-level accounts+$ hledger register                        # show account postings, with running total+$ hledger reg income                      # show postings to/from income accounts+$ hledger reg \[aq]assets:some bank:checking\[aq] # show postings to/from this checking account+$ hledger print desc:shop                 # show transactions with shop in the description+$ hledger activity -W                     # show transaction counts per week as a bar chart+\f[R]+.fi+.SH OPTIONS+.SS General options+.PP+To see general usage help, including general options which are supported+by most hledger commands, run \f[C]hledger -h\f[R].+.PP+General help options:+.TP+.B \f[C]-h --help\f[R]+show general usage (or after COMMAND, command usage)+.TP+.B \f[C]--version\f[R]+show version+.TP+.B \f[C]--debug[=N]\f[R]+show debug output (levels 1-9, default: 1)+.PP+General input options:+.TP+.B \f[C]-f FILE --file=FILE\f[R]+use a different input file.+For stdin, use - (default: \f[C]$LEDGER_FILE\f[R] or+\f[C]$HOME/.hledger.journal\f[R])+.TP+.B \f[C]--rules-file=RULESFILE\f[R]+Conversion rules file to use when reading CSV (default: FILE.rules)+.TP+.B \f[C]--separator=CHAR\f[R]+Field separator to expect when reading CSV (default: \[aq],\[aq])+.TP+.B \f[C]--alias=OLD=NEW\f[R]+rename accounts named OLD to NEW+.TP+.B \f[C]--anon\f[R]+anonymize accounts and payees+.TP+.B \f[C]--pivot FIELDNAME\f[R]+use some other field or tag for the account name+.TP+.B \f[C]-I --ignore-assertions\f[R]+ignore any failing balance assertions+.PP+General reporting options:+.TP+.B \f[C]-b --begin=DATE\f[R]+include postings/txns on or after this date+.TP+.B \f[C]-e --end=DATE\f[R]+include postings/txns before this date+.TP+.B \f[C]-D --daily\f[R]+multiperiod/multicolumn report by day+.TP+.B \f[C]-W --weekly\f[R]+multiperiod/multicolumn report by week+.TP+.B \f[C]-M --monthly\f[R]+multiperiod/multicolumn report by month+.TP+.B \f[C]-Q --quarterly\f[R]+multiperiod/multicolumn report by quarter+.TP+.B \f[C]-Y --yearly\f[R]+multiperiod/multicolumn report by year+.TP+.B \f[C]-p --period=PERIODEXP\f[R]+set start date, end date, and/or reporting interval all at once using+period expressions syntax+.TP+.B \f[C]--date2\f[R]+match the secondary date instead (see command help for other effects)+.TP+.B \f[C]-U --unmarked\f[R]+include only unmarked postings/txns (can combine with -P or -C)+.TP+.B \f[C]-P --pending\f[R]+include only pending postings/txns+.TP+.B \f[C]-C --cleared\f[R]+include only cleared postings/txns+.TP+.B \f[C]-R --real\f[R]+include only non-virtual postings+.TP+.B \f[C]-NUM --depth=NUM\f[R]+hide/aggregate accounts or postings more than NUM levels deep+.TP+.B \f[C]-E --empty\f[R]+show items with zero amount, normally hidden (and vice-versa in+hledger-ui/hledger-web)+.TP+.B \f[C]-B --cost\f[R]+convert amounts to their cost at transaction time (using the transaction+price, if any)+.TP+.B \f[C]-V --value\f[R]+convert amounts to their market value on the report end date (using the+most recent applicable market price, if any)+.TP+.B \f[C]--auto\f[R]+apply automated posting rules to modify transactions.+.TP+.B \f[C]--forecast\f[R]+apply periodic transaction rules to generate future transactions, to 6+months from now or report end date.+.PP+When a reporting option appears more than once in the command line, the+last one takes precedence.+.PP+Some reporting options can also be written as query arguments.+.SS Command options+.PP+To see options for a particular command, including command-specific+options, run: \f[C]hledger COMMAND -h\f[R].+.PP+Command-specific options must be written after the command name, eg:+\f[C]hledger print -x\f[R].+.PP+Additionally, if the command is an addon, you may need to put its+options after a double-hyphen, eg: \f[C]hledger ui -- --watch\f[R].+Or, you can run the addon executable directly:+\f[C]hledger-ui --watch\f[R].+.SS Command arguments+.PP+Most hledger commands accept arguments after the command name, which are+often a query, filtering the data in some way.+.SS Argument files+.PP+You can save a set of command line options/arguments in a file, one per+line, and then reuse them by writing \f[C]\[at]FILENAME\f[R] in a+command line.+To prevent this expansion of \f[C]\[at]\f[R]-arguments, precede them+with a \f[C]--\f[R] argument.+For more, see Save frequently used options.+.SS Special characters in arguments and queries+.PP+In shell command lines, option and argument values which contain+\[dq]problematic\[dq] characters, ie spaces, and also characters+significant to your shell such as \f[C]<\f[R], \f[C]>\f[R], \f[C](\f[R],+\f[C])\f[R], \f[C]|\f[R] and \f[C]$\f[R], should be escaped by enclosing+them in quotes or by writing backslashes before the characters.+Eg:+.PP+\f[C]hledger register -p \[aq]last year\[aq] \[dq]accounts receivable (receivable|payable)\[dq] amt:\[rs]>100\f[R].+.SS More escaping+.PP+Characters significant both to the shell and in regular expressions may+need one extra level of escaping.+These include parentheses, the pipe symbol and the dollar sign.+Eg, to match the dollar symbol, bash users should do:+.PP+\f[C]hledger balance cur:\[aq]\[rs]$\[aq]\f[R]+.PP+or:+.PP+\f[C]hledger balance cur:\[rs]\[rs]$\f[R]+.SS Even more escaping+.PP+When hledger runs an addon executable (eg you type \f[C]hledger ui\f[R],+hledger runs \f[C]hledger-ui\f[R]), it de-escapes command-line options+and arguments once, so you might need to \f[I]triple\f[R]-escape.+Eg in bash, running the ui command and matching the dollar sign,+it\[aq]s:+.PP+\f[C]hledger ui cur:\[aq]\[rs]\[rs]$\[aq]\f[R]+.PP+or:+.PP+\f[C]hledger ui cur:\[rs]\[rs]\[rs]\[rs]$\f[R]+.PP+If you asked why \f[I]four\f[R] slashes above, this may help:+.PP+.TS+tab(@);+l l.+T{+unescaped:+T}@T{+\f[C]$\f[R]+T}+T{+escaped:+T}@T{+\f[C]\[rs]$\f[R]+T}+T{+double-escaped:+T}@T{+\f[C]\[rs]\[rs]$\f[R]+T}+T{+triple-escaped:+T}@T{+\f[C]\[rs]\[rs]\[rs]\[rs]$\f[R]+T}+.TE+.PP+(The number of backslashes in fish shell is left as an exercise for the+reader.)+.PP+You can always avoid the extra escaping for addons by running the addon+directly:+.PP+\f[C]hledger-ui cur:\[rs]\[rs]$\f[R]+.SS Less escaping+.PP+Inside an argument file, or in the search field of hledger-ui or+hledger-web, or at a GHCI prompt, you need one less level of escaping+than at the command line.+And backslashes may work better than quotes.+Eg:+.PP+\f[C]ghci> :main balance cur:\[rs]$\f[R]+.SS Command line tips+.PP+If in doubt, keep things simple:+.IP \[bu] 2+write options after the command (\f[C]hledger CMD -OPTIONS ARGS\f[R])+.IP \[bu] 2+run add-on executables directly (\f[C]hledger-ui -OPTIONS ARGS\f[R])+.IP \[bu] 2+enclose problematic args in single quotes+.IP \[bu] 2+if needed, also add a backslash to escape regexp metacharacters+.PP+To find out exactly how a command line is being parsed, add+\f[C]--debug=2\f[R] to troubleshoot.+.SS Unicode characters+.PP+hledger is expected to handle non-ascii characters correctly:+.IP \[bu] 2+they should be parsed correctly in input files and on the command line,+by all hledger tools (add, iadd, hledger-web\[aq]s search/add/edit+forms, etc.)+.IP \[bu] 2+they should be displayed correctly by all hledger tools, and on-screen+alignment should be preserved.+.PP+This requires a well-configured environment.+Here are some tips:+.IP \[bu] 2+A system locale must be configured, and it must be one that can decode+the characters being used.+In bash, you can set a locale like this:+\f[C]export LANG=en_US.UTF-8\f[R].+There are some more details in Troubleshooting.+This step is essential - without it, hledger will quit on encountering a+non-ascii character (as with all GHC-compiled programs).+.IP \[bu] 2+your terminal software (eg Terminal.app, iTerm, CMD.exe, xterm..) must+support unicode+.IP \[bu] 2+the terminal must be using a font which includes the required unicode+glyphs+.IP \[bu] 2+the terminal should be configured to display wide characters as double+width (for report alignment)+.IP \[bu] 2+on Windows, for best results you should run hledger in the same kind of+environment in which it was built.+Eg hledger built in the standard CMD.EXE environment (like the binaries+on our download page) might show display problems when run in a cygwin+or msys terminal, and vice versa.+(See eg #961).+.SS Input files+.PP+hledger reads transactions from a data file (and the add command writes+to it).+By default this file is \f[C]$HOME/.hledger.journal\f[R] (or on Windows,+something like \f[C]C:/Users/USER/.hledger.journal\f[R]).+You can override this with the \f[C]$LEDGER_FILE\f[R] environment+variable:+.IP+.nf+\f[C]+$ setenv LEDGER_FILE \[ti]/finance/2016.journal+$ hledger stats+\f[R]+.fi+.PP+or with the \f[C]-f/--file\f[R] option:+.IP+.nf+\f[C]+$ hledger -f /some/file stats+\f[R]+.fi+.PP+The file name \f[C]-\f[R] (hyphen) means standard input:+.IP+.nf+\f[C]+$ cat some.journal | hledger -f-+\f[R]+.fi+.PP+Usually the data file is in hledger\[aq]s journal format, but it can+also be one of several other formats, listed below.+hledger detects the format automatically based on the file extension, or+if that is not recognised, by trying each built-in \[dq]reader\[dq] in+turn:+.PP+.TS+tab(@);+lw(7.6n) lw(31.2n) lw(31.2n).+T{+Reader:+T}@T{+Reads:+T}@T{+Used for file extensions:+T}+_+T{+\f[C]journal\f[R]+T}@T{+hledger\[aq]s journal format, also some Ledger journals+T}@T{+\f[C].journal\f[R] \f[C].j\f[R] \f[C].hledger\f[R] \f[C].ledger\f[R]+T}+T{+\f[C]timeclock\f[R]+T}@T{+timeclock files (precise time logging)+T}@T{+\f[C].timeclock\f[R]+T}+T{+\f[C]timedot\f[R]+T}@T{+timedot files (approximate time logging)+T}@T{+\f[C].timedot\f[R]+T}+T{+\f[C]csv\f[R]+T}@T{+comma-separated values (data interchange)+T}@T{+\f[C].csv\f[R]+T}+.TE+.PP+If needed (eg to ensure correct error messages when a file has the+\[dq]wrong\[dq] extension), you can force a specific reader/format by+prepending it to the file path with a colon.+Examples:+.IP+.nf+\f[C]+$ hledger -f csv:/some/csv-file.dat stats+$ echo \[aq]i 2009/13/1 08:00:00\[aq] | hledger print -ftimeclock:-+\f[R]+.fi+.PP+You can also specify multiple \f[C]-f\f[R] options, to read multiple+files as one big journal.+There are some limitations with this:+.IP \[bu] 2+directives in one file will not affect the other files+.IP \[bu] 2+balance assertions will not see any account balances from previous files+.PP+If you need those, either use the include directive, or concatenate the+files, eg: \f[C]cat a.journal b.journal | hledger -f- CMD\f[R].+.SS Smart dates+.PP+hledger\[aq]s user interfaces accept a flexible \[dq]smart date\[dq]+syntax (unlike dates in the journal file).+Smart dates allow some english words, can be relative to today\[aq]s+date, and can have less-significant date parts omitted (defaulting to+1).+.PP+Examples:+.PP+.TS+tab(@);+l l.+T{+\f[C]2004/10/1\f[R], \f[C]2004-01-01\f[R], \f[C]2004.9.1\f[R]+T}@T{+exact date, several separators allowed.+Year is 4+ digits, month is 1-12, day is 1-31+T}+T{+\f[C]2004\f[R]+T}@T{+start of year+T}+T{+\f[C]2004/10\f[R]+T}@T{+start of month+T}+T{+\f[C]10/1\f[R]+T}@T{+month and day in current year+T}+T{+\f[C]21\f[R]+T}@T{+day in current month+T}+T{+\f[C]october, oct\f[R]+T}@T{+start of month in current year+T}+T{+\f[C]yesterday, today, tomorrow\f[R]+T}@T{+-1, 0, 1 days from today+T}+T{+\f[C]last/this/next day/week/month/quarter/year\f[R]+T}@T{+-1, 0, 1 periods from the current period+T}+T{+\f[C]20181201\f[R]+T}@T{+8 digit YYYYMMDD with valid year month and day+T}+T{+\f[C]201812\f[R]+T}@T{+6 digit YYYYMM with valid year and month+T}+.TE+.PP+Counterexamples - malformed digit sequences might give surprising+results:+.PP+.TS+tab(@);+l l.+T{+\f[C]201813\f[R]+T}@T{+6 digits with an invalid month is parsed as start of 6-digit year+T}+T{+\f[C]20181301\f[R]+T}@T{+8 digits with an invalid month is parsed as start of 8-digit year+T}+T{+\f[C]20181232\f[R]+T}@T{+8 digits with an invalid day gives an error+T}+T{+\f[C]201801012\f[R]+T}@T{+9+ digits beginning with a valid YYYYMMDD gives an error+T}+.TE+.SS Report start & end date+.PP+Most hledger reports show the full span of time represented by the+journal data, by default.+So, the effective report start and end dates will be the earliest and+latest transaction or posting dates found in the journal.+.PP+Often you will want to see a shorter time span, such as the current+month.+You can specify a start and/or end date using \f[C]-b/--begin\f[R],+\f[C]-e/--end\f[R], \f[C]-p/--period\f[R] or a \f[C]date:\f[R] query+(described below).+All of these accept the smart date syntax.+.PP+Some notes:+.IP \[bu] 2+As in Ledger, end dates are exclusive, so you need to write the date+\f[I]after\f[R] the last day you want to include.+.IP \[bu] 2+As noted in reporting options: among start/end dates specified with+\f[I]options\f[R], the last (i.e.+right-most) option takes precedence.+.IP \[bu] 2+The effective report start and end dates are the intersection of the+start/end dates from options and that from \f[C]date:\f[R] queries.+That is, \f[C]date:2019-01 date:2019 -p\[aq]2000 to 2030\[aq]\f[R]+yields January 2019, the smallest common time span.+.PP+Examples:+.PP+.TS+tab(@);+l l.+T{+\f[C]-b 2016/3/17\f[R]+T}@T{+begin on St.+Patrick\[aq]s day 2016+T}+T{+\f[C]-e 12/1\f[R]+T}@T{+end at the start of december 1st of the current year (11/30 will be the+last date included)+T}+T{+\f[C]-b thismonth\f[R]+T}@T{+all transactions on or after the 1st of the current month+T}+T{+\f[C]-p thismonth\f[R]+T}@T{+all transactions in the current month+T}+T{+\f[C]date:2016/3/17-\f[R]+T}@T{+the above written as queries instead+T}+T{+\f[C]date:-12/1\f[R]+T}@T{+T}+T{+\f[C]date:thismonth-\f[R]+T}@T{+T}+T{+\f[C]date:thismonth\f[R]+T}@T{+T}+.TE+.SS Report intervals+.PP+A report interval can be specified so that commands like register,+balance and activity will divide their reports into multiple subperiods.+The basic intervals can be selected with one of \f[C]-D/--daily\f[R],+\f[C]-W/--weekly\f[R], \f[C]-M/--monthly\f[R], \f[C]-Q/--quarterly\f[R],+or \f[C]-Y/--yearly\f[R].+More complex intervals may be specified with a period expression.+Report intervals can not be specified with a query.+.SS Period expressions+.PP+The \f[C]-p/--period\f[R] option accepts period expressions, a shorthand+way of expressing a start date, end date, and/or report interval all at+once.+.PP+Here\[aq]s a basic period expression specifying the first quarter of+2009.+Note, hledger always treats start dates as inclusive and end dates as+exclusive:+.PP+\f[C]-p \[dq]from 2009/1/1 to 2009/4/1\[dq]\f[R]+.PP+Keywords like \[dq]from\[dq] and \[dq]to\[dq] are optional, and so are+the spaces, as long as you don\[aq]t run two dates together.+\[dq]to\[dq] can also be written as \[dq]-\[dq].+These are equivalent to the above:+.PP+.TS+tab(@);+l.+T{+\f[C]-p \[dq]2009/1/1 2009/4/1\[dq]\f[R]+T}+T{+\f[C]-p2009/1/1to2009/4/1\f[R]+T}+T{+\f[C]-p2009/1/1-2009/4/1\f[R]+T}+.TE+.PP+Dates are smart dates, so if the current year is 2009, the above can+also be written as:+.PP+.TS+tab(@);+l.+T{+\f[C]-p \[dq]1/1 4/1\[dq]\f[R]+T}+T{+\f[C]-p \[dq]january-apr\[dq]\f[R]+T}+T{+\f[C]-p \[dq]this year to 4/1\[dq]\f[R]+T}+.TE+.PP+If you specify only one date, the missing start or end date will be the+earliest or latest transaction in your journal:+.PP+.TS+tab(@);+l l.+T{+\f[C]-p \[dq]from 2009/1/1\[dq]\f[R]+T}@T{+everything after january 1, 2009+T}+T{+\f[C]-p \[dq]from 2009/1\[dq]\f[R]+T}@T{+the same+T}+T{+\f[C]-p \[dq]from 2009\[dq]\f[R]+T}@T{+the same+T}+T{+\f[C]-p \[dq]to 2009\[dq]\f[R]+T}@T{+everything before january 1, 2009+T}+.TE+.PP+A single date with no \[dq]from\[dq] or \[dq]to\[dq] defines both the+start and end date like so:+.PP+.TS+tab(@);+l l.+T{+\f[C]-p \[dq]2009\[dq]\f[R]+T}@T{+the year 2009; equivalent to \[dq]2009/1/1 to 2010/1/1\[dq]+T}+T{+\f[C]-p \[dq]2009/1\[dq]\f[R]+T}@T{+the month of jan; equivalent to \[dq]2009/1/1 to 2009/2/1\[dq]+T}+T{+\f[C]-p \[dq]2009/1/1\[dq]\f[R]+T}@T{+just that day; equivalent to \[dq]2009/1/1 to 2009/1/2\[dq]+T}+.TE+.PP+The argument of \f[C]-p\f[R] can also begin with, or be, a report+interval expression.+The basic report intervals are \f[C]daily\f[R], \f[C]weekly\f[R],+\f[C]monthly\f[R], \f[C]quarterly\f[R], or \f[C]yearly\f[R], which have+the same effect as the+\f[C]-D\f[R],\f[C]-W\f[R],\f[C]-M\f[R],\f[C]-Q\f[R], or \f[C]-Y\f[R]+flags.+Between report interval and start/end dates (if any), the word+\f[C]in\f[R] is optional.+Examples:+.PP+.TS+tab(@);+l.+T{+\f[C]-p \[dq]weekly from 2009/1/1 to 2009/4/1\[dq]\f[R]+T}+T{+\f[C]-p \[dq]monthly in 2008\[dq]\f[R]+T}+T{+\f[C]-p \[dq]quarterly\[dq]\f[R]+T}+.TE+.PP+Note that \f[C]weekly\f[R], \f[C]monthly\f[R], \f[C]quarterly\f[R] and+\f[C]yearly\f[R] intervals will always start on the first day on week,+month, quarter or year accordingly, and will end on the last day of same+period, even if associated period expression specifies different+explicit start and end date.+.PP+For example:+.PP+.TS+tab(@);+l.+T{+\f[C]-p \[dq]weekly from 2009/1/1 to 2009/4/1\[dq]\f[R] -- starts on+2008/12/29, closest preceeding Monday+T}+T{+\f[C]-p \[dq]monthly in 2008/11/25\[dq]\f[R] -- starts on 2018/11/01+T}+T{+\f[C]-p \[dq]quarterly from 2009-05-05 to 2009-06-01\[dq]\f[R] - starts+on 2009/04/01, ends on 2009/06/30, which are first and last days of Q2+2009+T}+T{+\f[C]-p \[dq]yearly from 2009-12-29\[dq]\f[R] - starts on 2009/01/01,+first day of 2009+T}+.TE+.PP+The following more complex report intervals are also supported:+\f[C]biweekly\f[R], \f[C]bimonthly\f[R],+\f[C]every day|week|month|quarter|year\f[R],+\f[C]every N days|weeks|months|quarters|years\f[R].+.PP+All of these will start on the first day of the requested period and end+on the last one, as described above.+.PP+Examples:+.PP+.TS+tab(@);+l.+T{+\f[C]-p \[dq]bimonthly from 2008\[dq]\f[R] -- periods will have+boundaries on 2008/01/01, 2008/03/01, ...+T}+T{+\f[C]-p \[dq]every 2 weeks\[dq]\f[R] -- starts on closest preceeding+Monday+T}+T{+\f[C]-p \[dq]every 5 month from 2009/03\[dq]\f[R] -- periods will have+boundaries on 2009/03/01, 2009/08/01, ...+T}+.TE+.PP+If you want intervals that start on arbitrary day of your choosing and+span a week, month or year, you need to use any of the following:+.PP+\f[C]every Nth day of week\f[R], \f[C]every <weekday>\f[R],+\f[C]every Nth day [of month]\f[R],+\f[C]every Nth weekday [of month]\f[R], \f[C]every MM/DD [of year]\f[R],+\f[C]every Nth MMM [of year]\f[R], \f[C]every MMM Nth [of year]\f[R].+.PP+Examples:+.PP+.TS+tab(@);+l.+T{+\f[C]-p \[dq]every 2nd day of week\[dq]\f[R] -- periods will go from Tue+to Tue+T}+T{+\f[C]-p \[dq]every Tue\[dq]\f[R] -- same+T}+T{+\f[C]-p \[dq]every 15th day\[dq]\f[R] -- period boundaries will be on+15th of each month+T}+T{+\f[C]-p \[dq]every 2nd Monday\[dq]\f[R] -- period boundaries will be on+second Monday of each month+T}+T{+\f[C]-p \[dq]every 11/05\[dq]\f[R] -- yearly periods with boundaries on+5th of Nov+T}+T{+\f[C]-p \[dq]every 5th Nov\[dq]\f[R] -- same+T}+T{+\f[C]-p \[dq]every Nov 5th\[dq]\f[R] -- same+T}+.TE+.PP+Show historical balances at end of 15th each month (N is exclusive end+date):+.PP+\f[C]hledger balance -H -p \[dq]every 16th day\[dq]\f[R]+.PP+Group postings from start of wednesday to end of next tuesday (N is+start date and exclusive end date):+.PP+\f[C]hledger register checking -p \[dq]every 3rd day of week\[dq]\f[R]+.SS Depth limiting+.PP+With the \f[C]--depth N\f[R] option (short form: \f[C]-N\f[R]), commands+like account, balance and register will show only the uppermost accounts+in the account tree, down to level N.+Use this when you want a summary with less detail.+This flag has the same effect as a \f[C]depth:\f[R] query argument (so+\f[C]-2\f[R], \f[C]--depth=2\f[R] or \f[C]depth:2\f[R] are basically+equivalent).+.SS Pivoting+.PP+Normally hledger sums amounts, and organizes them in a hierarchy, based+on account name.+The \f[C]--pivot FIELD\f[R] option causes it to sum and organize+hierarchy based on the value of some other field instead.+FIELD can be: \f[C]code\f[R], \f[C]description\f[R], \f[C]payee\f[R],+\f[C]note\f[R], or the full name (case insensitive) of any tag.+As with account names, values containing \f[C]colon:separated:parts\f[R]+will be displayed hierarchically in reports.+.PP+\f[C]--pivot\f[R] is a general option affecting all reports; you can+think of hledger transforming the journal before any other processing,+replacing every posting\[aq]s account name with the value of the+specified field on that posting, inheriting it from the transaction or+using a blank value if it\[aq]s not present.+.PP+An example:+.IP+.nf+\f[C]+2016/02/16 Member Fee Payment+    assets:bank account                    2 EUR+    income:member fees                    -2 EUR  ; member: John Doe+\f[R]+.fi+.PP+Normal balance report showing account names:+.IP+.nf+\f[C]+$ hledger balance+               2 EUR  assets:bank account+              -2 EUR  income:member fees+--------------------+                   0+\f[R]+.fi+.PP+Pivoted balance report, using member: tag values instead:+.IP+.nf+\f[C]+$ hledger balance --pivot member+               2 EUR+              -2 EUR  John Doe+--------------------+                   0+\f[R]+.fi+.PP+One way to show only amounts with a member: value (using a query,+described below):+.IP+.nf+\f[C]+$ hledger balance --pivot member tag:member=.+              -2 EUR  John Doe+--------------------+              -2 EUR+\f[R]+.fi+.PP+Another way (the acct: query matches against the pivoted \[dq]account+name\[dq]):+.IP+.nf+\f[C]+$ hledger balance --pivot member acct:.+              -2 EUR  John Doe+--------------------+              -2 EUR+\f[R]+.fi+.SS Valuation+.SS -B: Cost+.PP+The \f[C]-B/--cost\f[R] flag converts amounts to their cost (or selling+price) at transaction time, if they have a transaction price specified.+This flag is equivalent to \f[C]--value=cost\f[R], described below.+.SS -V: Market value+.PP+The \f[C]-V/--market\f[R] flag converts reported amounts to their market+value in a default valuation commodity, using the historical market+prices in effect on a default valuation date.+.PP+For single period reports, the valuation date is today.+For multiperiod reports, it is the last day of each subperiod.+.PP+The valuation commodity will be the one referenced in the latest+applicable market price dated on or before the valuation date.+If most of your P declarations lead to a single home currency, this will+usually be what you want.+.PP+Unlike the similar flag in Ledger, it does not infer market prices from+transaction prices.+In hledger, -B uses transaction prices, -V and -X use market prices.+.PP+It is equivalent to \f[C]--value=now\f[R] or \f[C]--value=end\f[R].+.PP+Here\[aq]s a quick example:+.IP+.nf+\f[C]+# one euro is worth this many dollars from nov 1+P 2016/11/01 \[Eu] $1.10++# purchase some euros on nov 3+2016/11/3+    assets:euros        \[Eu]100+    assets:checking++# the euro is worth fewer dollars by dec 21+P 2016/12/21 \[Eu] $1.03+\f[R]+.fi+.PP+How many euros do I have ?+.IP+.nf+\f[C]+$ hledger -f t.j bal -N euros+                \[Eu]100  assets:euros+\f[R]+.fi+.PP+What are they worth at end of nov 3 ?+.IP+.nf+\f[C]+$ hledger -f t.j bal -N euros -V -e 2016/11/4+             $110.00  assets:euros+\f[R]+.fi+.PP+What are they worth after 2016/12/21 ?+(no report end date specified, defaults to today)+.IP+.nf+\f[C]+$ hledger -f t.j bal -N euros -V+             $103.00  assets:euros+\f[R]+.fi+.SS -X: Market value in specified commodity+.PP+The \f[C]-X/--exchange\f[R] option is like \f[C]-V/--market\f[R] except+it takes a commodity symbol argument, so that you can select a different+target commodity.+It is similar to the same option in Ledger, with the same caveat+mentioned for \f[C]-V\f[R]/\f[C]--value\f[R] above.+It is equivalent to \f[C]--value=now,COMM\f[R] or+\f[C]--value=end,COMM\f[R]; for more details, read on.+.SS --value+.PP+\f[I](experimental, added 201905)\f[R]+.PP+\f[C]-B\f[R], \f[C]-V\f[R] and \f[C]-X\f[R] are special cases of the+more general \f[C]--value\f[R] option:+.IP+.nf+\f[C]+ --value=TYPE[,COMM]  TYPE is cost, end, now or YYYY-MM-DD.+                      COMM is an optional commodity symbol.+                      Shows amounts converted to:+                      - cost commodity using transaction prices (then optionally to COMM using market prices at period end(s))+                      - default valuation commodity (or COMM) using market prices at period end(s)+                      - default valuation commodity (or COMM) using current market prices+                      - default valuation commodity (or COMM) using market prices at some date+\f[R]+.fi+.SS Valuation type+.PP+TYPE is one of these keywords, or their first letter, or a date (which+must be 8 digits with \f[C]-\f[R] or \f[C]/\f[R] or \f[C].\f[R]+separators):+.TP+.B \f[C]--value=cost\f[R]+Convert amounts to cost, using the prices recorded in transactions.+\f[C]-B\f[R]/\f[C]--cost\f[R] is equivalent to this.+.TP+.B \f[C]--value=end\f[R]+Convert amounts to their value in default valuation commodity using+market prices on the last day of the report period (or of each subperiod+in a multiperiod report).+When no report period is specified, uses the journal\[aq]s last+transaction date.+.TP+.B \f[C]--value=now\f[R]+Convert amounts to their value in default valuation commodity using+current market prices (as of when report is generated).+\f[C]-V\f[R]/\f[C]--market\f[R] is equivalent to this.+.TP+.B \f[C]--value=YYYY-MM-DD\f[R]+Convert amounts to their value in default valuation commodity using+market prices on this date.+Eg \f[C]--value=2019-04-25\f[R].+.SS Valuation commodity+.PP+The default valuation commodity is the commodity mentioned in the most+recent applicable market price declaration.+When all your price declarations lead to a single home currency, this+will usually do what you want.+.PP+To select a different valuation commodity: write the commodity symbol+after the valuation type, separated by a comma (eg:+\f[B]\f[CB]--value=now,EUR\f[B]\f[R]).+This will use, in this preferred order:+.IP \[bu] 2+declared prices (from source commodity to valuation commodity)+.IP \[bu] 2+reverse prices (declared prices from valuation to source commodity,+inverted)+.IP \[bu] 2+indirect prices (prices calculated from the shortest chain of declared+or reverse prices from source to valuation commodity).+.SS --value examples+.PP+Here are the effects of \f[C]--value\f[R] as seen with \f[C]print\f[R]:+.IP+.nf+\f[C]+P 2000-01-01 A  1 B+P 2000-02-01 A  2 B+P 2000-03-01 A  3 B+P 2000-04-01 A  4 B++2000-01-01+  (a)      1 A \[at] 5 B++2000-02-01+  (a)      1 A \[at] 6 B++2000-03-01+  (a)      1 A \[at] 7 B+\f[R]+.fi+.PP+Show the cost of each posting:+.IP+.nf+\f[C]+$ hledger -f- print --value=cost+2000/01/01+    (a)             5 B++2000/02/01+    (a)             6 B++2000/03/01+    (a)             7 B+\f[R]+.fi+.PP+Show the value as of the last day of the report period (2000-02-29):+.IP+.nf+\f[C]+$ hledger -f- print --value=end date:2000/01-2000/03+2000-01-01+    (a)             2 B++2000-02-01+    (a)             2 B+\f[R]+.fi+.PP+With no report period specified, that shows the value as of the last day+of the journal (2000-03-01):+.IP+.nf+\f[C]+$ hledger -f- print --value=end+2000/01/01+    (a)             3 B++2000/02/01+    (a)             3 B++2000/03/01+    (a)             3 B+\f[R]+.fi+.PP+Show the current value (the 2000-04-01 price is still in effect today):+.IP+.nf+\f[C]+$ hledger -f- print --value=now+2000-01-01+    (a)             4 B++2000-02-01+    (a)             4 B++2000-03-01+    (a)             4 B+\f[R]+.fi+.PP+Show the value on 2000/01/15:+.IP+.nf+\f[C]+$ hledger -f- print --value=2000-01-15+2000/01/01+    (a)             1 B++2000/02/01+    (a)             1 B++2000/03/01+    (a)             1 B+\f[R]+.fi+.PP+You may need to explicitly set a commodity\[aq]s display style, when+reverse prices are used.+Eg this output might be surprising:+.IP+.nf+\f[C]+P 2000-01-01 A 2B++2000-01-01+  a  1B+  b+\f[R]+.fi+.IP+.nf+\f[C]+$ hledger print -x -X A+2000/01/01+    a               0+    b               0+\f[R]+.fi+.PP+Explanation: because there\[aq]s no amount or commodity directive+specifying a display style for A, 0.5A gets the default style, which+shows no decimal digits.+Because the displayed amount looks like zero, the commodity symbol and+minus sign are not displayed either.+Adding a commodity directive sets a more useful display style for A:+.IP+.nf+\f[C]+P 2000-01-01 A 2B+commodity 0.00A++2000-01-01+  a  1B+  b+\f[R]+.fi+.IP+.nf+\f[C]+$ hledger print -X A+2000/01/01+    a           0.50A+    b          -0.50A+\f[R]+.fi+.SS Effect of --value on reports+.PP+Below is how \f[C]--value\f[R] affects each of hledger\[aq]s reports,+currently.+You\[aq]re not expected to remember all this, but when troubleshooting a+report, look here.+If you find problems - useless reports, misbehaving reports, or error+messages being printed - please report them (with reproducible examples)+eg at #329.+.PP+.TS+tab(@);+lw(12.5n) lw(13.6n) lw(25.4n) lw(18.4n).+T{+Report type+T}@T{+\f[C]--value\f[R] \f[C]cost\f[R]\ +T}@T{+\f[C]--value\f[R] \f[C]end\f[R]\ +T}@T{+\f[C]--value\f[R] \f[C]DATE\f[R]/\f[C]now\f[R]\ +T}+_+T{+\f[B]print\f[R]+T}@T{+T}@T{+T}@T{+T}+T{+posting amounts+T}@T{+cost, as recorded in transaction+T}@T{+market value at report end+T}@T{+market value at DATE+T}+T{+balance assertions/assignments+T}@T{+show unvalued+T}@T{+show unvalued+T}@T{+show unvalued+T}+T{+\f[B]register\f[R]+T}@T{+T}@T{+T}@T{+T}+T{+starting balance with -H+T}@T{+cost of starting balance+T}@T{+market value at day before report start+T}@T{+market value at DATE+T}+T{+posting amounts+T}@T{+cost+T}@T{+market value at report end+T}@T{+market value at DATE+T}+T{+posting amounts, multiperiod+T}@T{+summarised cost+T}@T{+market value each summary posting at period end+T}@T{+market value each summary posting at DATE+T}+T{+running total/average+T}@T{+sum/average of the displayed values+T}@T{+sum/average of the displayed values+T}@T{+sum/average of the displayed values+T}+T{+\f[B]balance (bs, cf, is..)\f[R]+T}@T{+T}@T{+T}@T{+T}+T{+starting balances with -H+T}@T{+costs of starting balances+T}@T{+market value at day before report start of sum of previous postings+T}@T{+market value at DATE of sum of previous postings+T}+T{+balances, simple balance report+T}@T{+summed costs+T}@T{+market value at period end of sum of postings+T}@T{+market value at DATE of sum of postings+T}+T{+balances, multiperiod report+T}@T{+summed costs+T}@T{+market value at period end of sum of postings+T}@T{+market value at DATE of sum of postings+T}+T{+budget amounts with --budget+T}@T{+costs of budget amounts+T}@T{+budget-setting periodic txns are valued at period end+T}@T{+budget-setting periodic txns are valued at DATE+T}+T{+column/row/grand totals/averages+T}@T{+sum/average of the displayed values+T}@T{+market value at period end of sum/average of postings+T}@T{+market value at DATE of sum/average of postings+T}+.TE+.SS Combining -B, -V, -X, --value+.PP+The rightmost of these flags wins.+.SS Output destination+.PP+Some commands (print, register, stats, the balance commands) can write+their output to a destination other than the console.+This is controlled by the \f[C]-o/--output-file\f[R] option.+.IP+.nf+\f[C]+$ hledger balance -o -     # write to stdout (the default)+$ hledger balance -o FILE  # write to FILE+\f[R]+.fi+.SS Output format+.PP+Some commands can write their output in other formats.+Eg print and register can output CSV, and the balance commands can+output CSV or HTML.+This is controlled by the \f[C]-O/--output-format\f[R] option, or by+specifying a \f[C].csv\f[R] or \f[C].html\f[R] file extension with+\f[C]-o/--output-file\f[R].+.IP+.nf+\f[C]+$ hledger balance -O csv       # write CSV to stdout+$ hledger balance -o FILE.csv  # write CSV to FILE.csv+\f[R]+.fi+.SS Regular expressions+.PP+hledger uses regular expressions in a number of places:+.IP \[bu] 2+query terms, on the command line and in the hledger-web search form:+\f[C]REGEX\f[R], \f[C]desc:REGEX\f[R], \f[C]cur:REGEX\f[R],+\f[C]tag:...=REGEX\f[R]+.IP \[bu] 2+CSV rules conditional blocks: \f[C]if REGEX ...\f[R]+.IP \[bu] 2+account alias directives and options:+\f[C]alias /REGEX/ = REPLACEMENT\f[R],+\f[C]--alias /REGEX/=REPLACEMENT\f[R]+.PP+hledger\[aq]s regular expressions come from the regex-tdfa library.+In general they:+.IP \[bu] 2+are case insensitive+.IP \[bu] 2+are infix matching (do not need to match the entire thing being matched)+.IP \[bu] 2+are POSIX extended regular expressions+.IP \[bu] 2+also support GNU word boundaries (\[rs]<, \[rs]>, \[rs]b, \[rs]B)+.IP \[bu] 2+and parenthesised capturing groups and numeric backreferences in+replacement strings+.IP \[bu] 2+do not support mode modifiers like (?s)+.PP+Some things to note:+.IP \[bu] 2+In the \f[C]alias\f[R] directive and \f[C]--alias\f[R] option, regular+expressions must be enclosed in forward slashes (\f[C]/REGEX/\f[R]).+Elsewhere in hledger, these are not required.+.IP \[bu] 2+In queries, to match a regular expression metacharacter like \f[C]$\f[R]+as a literal character, prepend a backslash.+Eg to search for amounts with the dollar sign in hledger-web, write+\f[C]cur:\[rs]$\f[R].+.IP \[bu] 2+On the command line, some metacharacters like \f[C]$\f[R] have a special+meaning to the shell and so must be escaped at least once more.+See Special characters.+.SH QUERIES+.PP+One of hledger\[aq]s strengths is being able to quickly report on+precise subsets of your data.+Most commands accept an optional query expression, written as arguments+after the command name, to filter the data by date, account name or+other criteria.+The syntax is similar to a web search: one or more space-separated+search terms, quotes to enclose whitespace, prefixes to match specific+fields, a not: prefix to negate the match.+.PP+We do not yet support arbitrary boolean combinations of search terms;+instead most commands show transactions/postings/accounts which match+(or negatively match):+.IP \[bu] 2+any of the description terms AND+.IP \[bu] 2+any of the account terms AND+.IP \[bu] 2+any of the status terms AND+.IP \[bu] 2+all the other terms.+.PP+The print command instead shows transactions which:+.IP \[bu] 2+match any of the description terms AND+.IP \[bu] 2+have any postings matching any of the positive account terms AND+.IP \[bu] 2+have no postings matching any of the negative account terms AND+.IP \[bu] 2+match all the other terms.+.PP+The following kinds of search terms can be used.+Remember these can also be prefixed with \f[B]\f[CB]not:\f[B]\f[R], eg+to exclude a particular subaccount.+.TP+.B \f[B]\f[CB]REGEX\f[B], \f[CB]acct:REGEX\f[B]\f[R]+match account names by this regular expression.+(With no prefix, \f[C]acct:\f[R] is assumed.)+same as above+.TP+.B \f[B]\f[CB]amt:N, amt:<N, amt:<=N, amt:>N, amt:>=N\f[B]\f[R]+match postings with a single-commodity amount that is equal to, less+than, or greater than N.+(Multi-commodity amounts are not tested, and will always match.) The+comparison has two modes: if N is preceded by a + or - sign (or is 0),+the two signed numbers are compared.+Otherwise, the absolute magnitudes are compared, ignoring sign.+.TP+.B \f[B]\f[CB]code:REGEX\f[B]\f[R]+match by transaction code (eg check number)+.TP+.B \f[B]\f[CB]cur:REGEX\f[B]\f[R]+match postings or transactions including any amounts whose+currency/commodity symbol is fully matched by REGEX.+(For a partial match, use \f[C].*REGEX.*\f[R]).+Note, to match characters which are regex-significant, like the dollar+sign (\f[C]$\f[R]), you need to prepend \f[C]\[rs]\f[R].+And when using the command line you need to add one more level of+quoting to hide it from the shell, so eg do:+\f[C]hledger print cur:\[aq]\[rs]$\[aq]\f[R] or+\f[C]hledger print cur:\[rs]\[rs]$\f[R].+.TP+.B \f[B]\f[CB]desc:REGEX\f[B]\f[R]+match transaction descriptions.+.TP+.B \f[B]\f[CB]date:PERIODEXPR\f[B]\f[R]+match dates within the specified period.+PERIODEXPR is a period expression (with no report interval).+Examples: \f[C]date:2016\f[R], \f[C]date:thismonth\f[R],+\f[C]date:2000/2/1-2/15\f[R], \f[C]date:lastweek-\f[R].+If the \f[C]--date2\f[R] command line flag is present, this matches+secondary dates instead.+.TP+.B \f[B]\f[CB]date2:PERIODEXPR\f[B]\f[R]+match secondary dates within the specified period.+.TP+.B \f[B]\f[CB]depth:N\f[B]\f[R]+match (or display, depending on command) accounts at or above this depth+.TP+.B \f[B]\f[CB]note:REGEX\f[B]\f[R]+match transaction notes (part of description right of \f[C]|\f[R], or+whole description when there\[aq]s no \f[C]|\f[R])+.TP+.B \f[B]\f[CB]payee:REGEX\f[B]\f[R]+match transaction payee/payer names (part of description left of+\f[C]|\f[R], or whole description when there\[aq]s no \f[C]|\f[R])+.TP+.B \f[B]\f[CB]real:, real:0\f[B]\f[R]+match real or virtual postings respectively+.TP+.B \f[B]\f[CB]status:, status:!, status:*\f[B]\f[R]+match unmarked, pending, or cleared transactions respectively+.TP+.B \f[B]\f[CB]tag:REGEX[=REGEX]\f[B]\f[R]+match by tag name, and optionally also by tag value.+Note a tag: query is considered to match a transaction if it matches any+of the postings.+Also remember that postings inherit the tags of their parent+transaction.+.PP+The following special search term is used automatically in hledger-web,+only:+.TP+.B \f[B]\f[CB]inacct:ACCTNAME\f[B]\f[R]+tells hledger-web to show the transaction register for this account.+Can be filtered further with \f[C]acct\f[R] etc.+.PP+Some of these can also be expressed as command-line options (eg+\f[C]depth:2\f[R] is equivalent to \f[C]--depth 2\f[R]).+Generally you can mix options and query arguments, and the resulting+query will be their intersection (perhaps excluding the+\f[C]-p/--period\f[R] option).+.SH COMMANDS+.PP+hledger provides a number of subcommands; \f[C]hledger\f[R] with no+arguments shows a list.+.PP+If you install additional \f[C]hledger-*\f[R] packages, or if you put+programs or scripts named \f[C]hledger-NAME\f[R] in your PATH, these+will also be listed as subcommands.+.PP+Run a subcommand by writing its name as first argument (eg+\f[C]hledger incomestatement\f[R]).+You can also write one of the standard short aliases displayed in+parentheses in the command list (\f[C]hledger b\f[R]), or any any+unambiguous prefix of a command name (\f[C]hledger inc\f[R]).+.PP+Here are all the builtin commands in alphabetical order.+See also \f[C]hledger\f[R] for a more organised command list, and+\f[C]hledger CMD -h\f[R] for detailed command help.+.SS accounts+.PP+accounts, a+.PD 0+.P+.PD+Show account names.+.PP+This command lists account names, either declared with account+directives (--declared), posted to (--used), or both (the default).+With query arguments, only matched account names and account names+referenced by matched postings are shown.+It shows a flat list by default.+With \f[C]--tree\f[R], it uses indentation to show the account+hierarchy.+In flat mode you can add \f[C]--drop N\f[R] to omit the first few+account name components.+Account names can be depth-clipped with \f[C]depth:N\f[R] or+\f[C]--depth N\f[R] or \f[C]-N\f[R].+.PP+Examples:+.IP+.nf+\f[C]+$ hledger accounts+assets:bank:checking+assets:bank:saving+assets:cash+expenses:food+expenses:supplies+income:gifts+income:salary+liabilities:debts+\f[R]+.fi+.SS activity+.PP+activity+.PD 0+.P+.PD+Show an ascii barchart of posting counts per interval.+.PP+The activity command displays an ascii histogram showing transaction+counts by day, week, month or other reporting interval (by day is the+default).+With query arguments, it counts only matched transactions.+.PP+Examples:+.IP+.nf+\f[C]+$ hledger activity --quarterly+2008-01-01 **+2008-04-01 *******+2008-07-01 +2008-10-01 **+\f[R]+.fi+.SS add+.PP+add+.PD 0+.P+.PD+Prompt for transactions and add them to the journal.+.PP+Many hledger users edit their journals directly with a text editor, or+generate them from CSV.+For more interactive data entry, there is the \f[C]add\f[R] command,+which prompts interactively on the console for new transactions, and+appends them to the journal file (if there are multiple+\f[C]-f FILE\f[R] options, the first file is used.) Existing+transactions are not changed.+This is the only hledger command that writes to the journal file.+.PP+To use it, just run \f[C]hledger add\f[R] and follow the prompts.+You can add as many transactions as you like; when you are finished,+enter \f[C].\f[R] or press control-d or control-c to exit.+.PP+Features:+.IP \[bu] 2+add tries to provide useful defaults, using the most similar (by+description) recent transaction (filtered by the query, if any) as a+template.+.IP \[bu] 2+You can also set the initial defaults with command line arguments.+.IP \[bu] 2+Readline-style edit keys can be used during data entry.+.IP \[bu] 2+The tab key will auto-complete whenever possible - accounts,+descriptions, dates (\f[C]yesterday\f[R], \f[C]today\f[R],+\f[C]tomorrow\f[R]).+If the input area is empty, it will insert the default value.+.IP \[bu] 2+If the journal defines a default commodity, it will be added to any bare+numbers entered.+.IP \[bu] 2+A parenthesised transaction code may be entered following a date.+.IP \[bu] 2+Comments and tags may be entered following a description or amount.+.IP \[bu] 2+If you make a mistake, enter \f[C]<\f[R] at any prompt to restart the+transaction.+.IP \[bu] 2+Input prompts are displayed in a different colour when the terminal+supports it.+.PP+Example (see the tutorial for a detailed explanation):+.IP+.nf+\f[C]+$ hledger add+Adding transactions to journal file /src/hledger/examples/sample.journal+Any command line arguments will be used as defaults.+Use tab key to complete, readline keys to edit, enter to accept defaults.+An optional (CODE) may follow transaction dates.+An optional ; COMMENT may follow descriptions or amounts.+If you make a mistake, enter < at any prompt to restart the transaction.+To end a transaction, enter . when prompted.+To quit, enter . at a date prompt or press control-d or control-c.+Date [2015/05/22]: +Description: supermarket+Account 1: expenses:food+Amount  1: $10+Account 2: assets:checking+Amount  2 [$-10.0]: +Account 3 (or . or enter to finish this transaction): .+2015/05/22 supermarket+    expenses:food             $10+    assets:checking        $-10.0++Save this transaction to the journal ? [y]: +Saved.+Starting the next transaction (. or ctrl-D/ctrl-C to quit)+Date [2015/05/22]: <CTRL-D> $+\f[R]+.fi+.PP+On Microsoft Windows, the add command makes sure that no part of the+file path ends with a period, as it can cause data loss on that platform+(cf #1056).+.SS balance+.PP+balance, bal, b+.PD 0+.P+.PD+Show accounts and their balances.+.PP+The balance command is hledger\[aq]s most versatile command.+Note, despite the name, it is not always used for showing real-world+account balances; the more accounting-aware balancesheet and+incomestatement may be more convenient for that.+.PP+By default, it displays all accounts, and each account\[aq]s change in+balance during the entire period of the journal.+Balance changes are calculated by adding up the postings in each+account.+You can limit the postings matched, by a query, to see fewer accounts,+changes over a different time period, changes from only cleared+transactions, etc.+.PP+If you include an account\[aq]s complete history of postings in the+report, the balance change is equivalent to the account\[aq]s current+ending balance.+For a real-world account, typically you won\[aq]t have all transactions+in the journal; instead you\[aq]ll have all transactions after a certain+date, and an \[dq]opening balances\[dq] transaction setting the correct+starting balance on that date.+Then the balance command will show real-world account balances.+In some cases the -H/--historical flag is used to ensure this (more+below).+.PP+The balance command can produce several styles of report:+.SS Classic balance report+.PP+This is the original balance report, as found in Ledger.+It usually looks like this:+.IP+.nf+\f[C]+$ hledger balance+                 $-1  assets+                  $1    bank:saving+                 $-2    cash+                  $2  expenses+                  $1    food+                  $1    supplies+                 $-2  income+                 $-1    gifts+                 $-1    salary+                  $1  liabilities:debts+--------------------+                   0+\f[R]+.fi+.PP+By default, accounts are displayed hierarchically, with subaccounts+indented below their parent.+At each level of the tree, accounts are sorted by account code if any,+then by account name.+Or with \f[C]-S/--sort-amount\f[R], by their balance amount.+.PP+\[dq]Boring\[dq] accounts, which contain a single interesting subaccount+and no balance of their own, are elided into the following line for more+compact output.+(Eg above, the \[dq]liabilities\[dq] account.) Use \f[C]--no-elide\f[R]+to prevent this.+.PP+Account balances are \[dq]inclusive\[dq] - they include the balances of+any subaccounts.+.PP+Accounts which have zero balance (and no non-zero subaccounts) are+omitted.+Use \f[C]-E/--empty\f[R] to show them.+.PP+A final total is displayed by default; use \f[C]-N/--no-total\f[R] to+suppress it, eg:+.IP+.nf+\f[C]+$ hledger balance -p 2008/6 expenses --no-total+                  $2  expenses+                  $1    food+                  $1    supplies+\f[R]+.fi+.SS Customising the classic balance report+.PP+You can customise the layout of classic balance reports with+\f[C]--format FMT\f[R]:+.IP+.nf+\f[C]+$ hledger balance --format \[dq]%20(account) %12(total)\[dq]+              assets          $-1+         bank:saving           $1+                cash          $-2+            expenses           $2+                food           $1+            supplies           $1+              income          $-2+               gifts          $-1+              salary          $-1+   liabilities:debts           $1+---------------------------------+                                0+\f[R]+.fi+.PP+The FMT format string (plus a newline) specifies the formatting applied+to each account/balance pair.+It may contain any suitable text, with data fields interpolated like so:+.PP+\f[C]%[MIN][.MAX](FIELDNAME)\f[R]+.IP \[bu] 2+MIN pads with spaces to at least this width (optional)+.IP \[bu] 2+MAX truncates at this width (optional)+.IP \[bu] 2+FIELDNAME must be enclosed in parentheses, and can be one of:+.RS 2+.IP \[bu] 2+\f[C]depth_spacer\f[R] - a number of spaces equal to the account\[aq]s+depth, or if MIN is specified, MIN * depth spaces.+.IP \[bu] 2+\f[C]account\f[R] - the account\[aq]s name+.IP \[bu] 2+\f[C]total\f[R] - the account\[aq]s balance/posted total, right+justified+.RE+.PP+Also, FMT can begin with an optional prefix to control how+multi-commodity amounts are rendered:+.IP \[bu] 2+\f[C]%_\f[R] - render on multiple lines, bottom-aligned (the default)+.IP \[bu] 2+\f[C]%\[ha]\f[R] - render on multiple lines, top-aligned+.IP \[bu] 2+\f[C]%,\f[R] - render on one line, comma-separated+.PP+There are some quirks.+Eg in one-line mode, \f[C]%(depth_spacer)\f[R] has no effect, instead+\f[C]%(account)\f[R] has indentation built in.+Experimentation may be needed to get pleasing results.+.PP+Some example formats:+.IP \[bu] 2+\f[C]%(total)\f[R] - the account\[aq]s total+.IP \[bu] 2+\f[C]%-20.20(account)\f[R] - the account\[aq]s name, left justified,+padded to 20 characters and clipped at 20 characters+.IP \[bu] 2+\f[C]%,%-50(account)  %25(total)\f[R] - account name padded to 50+characters, total padded to 20 characters, with multiple commodities+rendered on one line+.IP \[bu] 2+\f[C]%20(total)  %2(depth_spacer)%-(account)\f[R] - the default format+for the single-column balance report+.SS Colour support+.PP+The balance command shows negative amounts in red, if:+.IP \[bu] 2+the \f[C]TERM\f[R] environment variable is not set to \f[C]dumb\f[R]+.IP \[bu] 2+the output is not being redirected or piped anywhere+.SS Flat mode+.PP+To see a flat list instead of the default hierarchical display, use+\f[C]--flat\f[R].+In this mode, accounts (unless depth-clipped) show their full names and+\[dq]exclusive\[dq] balance, excluding any subaccount balances.+In this mode, you can also use \f[C]--drop N\f[R] to omit the first few+account name components.+.IP+.nf+\f[C]+$ hledger balance -p 2008/6 expenses -N --flat --drop 1+                  $1  food+                  $1  supplies+\f[R]+.fi+.SS Depth limited balance reports+.PP+With \f[C]--depth N\f[R] or \f[C]depth:N\f[R] or just \f[C]-N\f[R],+balance reports show accounts only to the specified numeric depth.+This is very useful to summarise a complex set of accounts and get an+overview.+.IP+.nf+\f[C]+$ hledger balance -N -1+                 $-1  assets+                  $2  expenses+                 $-2  income+                  $1  liabilities+\f[R]+.fi+.PP+Flat-mode balance reports, which normally show exclusive balances, show+inclusive balances at the depth limit.+.SS Multicolumn balance report+.PP+Multicolumn or tabular balance reports are a very useful hledger+feature, and usually the preferred style.+They share many of the above features, but they show the report as a+table, with columns representing time periods.+This mode is activated by providing a reporting interval.+.PP+There are three types of multicolumn balance report, showing different+information:+.IP "1." 3+By default: each column shows the sum of postings in that period, ie the+account\[aq]s change of balance in that period.+This is useful eg for a monthly income statement:+.RS 4+.IP+.nf+\f[C]+$ hledger balance --quarterly income expenses -E+Balance changes in 2008:++                   ||  2008q1  2008q2  2008q3  2008q4 +===================++=================================+ expenses:food     ||       0      $1       0       0 + expenses:supplies ||       0      $1       0       0 + income:gifts      ||       0     $-1       0       0 + income:salary     ||     $-1       0       0       0 +-------------------++---------------------------------+                   ||     $-1      $1       0       0 +\f[R]+.fi+.RE+.IP "2." 3+With \f[C]--cumulative\f[R]: each column shows the ending balance for+that period, accumulating the changes across periods, starting from 0 at+the report start date:+.RS 4+.IP+.nf+\f[C]+$ hledger balance --quarterly income expenses -E --cumulative+Ending balances (cumulative) in 2008:++                   ||  2008/03/31  2008/06/30  2008/09/30  2008/12/31 +===================++=================================================+ expenses:food     ||           0          $1          $1          $1 + expenses:supplies ||           0          $1          $1          $1 + income:gifts      ||           0         $-1         $-1         $-1 + income:salary     ||         $-1         $-1         $-1         $-1 +-------------------++-------------------------------------------------+                   ||         $-1           0           0           0 +\f[R]+.fi+.RE+.IP "3." 3+With \f[C]--historical/-H\f[R]: each column shows the actual historical+ending balance for that period, accumulating the changes across periods,+starting from the actual balance at the report start date.+This is useful eg for a multi-period balance sheet, and when you are+showing only the data after a certain start date:+.RS 4+.IP+.nf+\f[C]+$ hledger balance \[ha]assets \[ha]liabilities --quarterly --historical --begin 2008/4/1+Ending balances (historical) in 2008/04/01-2008/12/31:++                      ||  2008/06/30  2008/09/30  2008/12/31 +======================++=====================================+ assets:bank:checking ||          $1          $1           0 + assets:bank:saving   ||          $1          $1          $1 + assets:cash          ||         $-2         $-2         $-2 + liabilities:debts    ||           0           0          $1 +----------------------++-------------------------------------+                      ||           0           0           0 +\f[R]+.fi+.RE+.PP+Note that \f[C]--cumulative\f[R] or \f[C]--historical/-H\f[R] disable+\f[C]--row-total/-T\f[R], since summing end balances generally does not+make sense.+.PP+Multicolumn balance reports display accounts in flat mode by default; to+see the hierarchy, use \f[C]--tree\f[R].+.PP+With a reporting interval (like \f[C]--quarterly\f[R] above), the report+start/end dates will be adjusted if necessary so that they encompass the+displayed report periods.+This is so that the first and last periods will be \[dq]full\[dq] and+comparable to the others.+.PP+The \f[C]-E/--empty\f[R] flag does two things in multicolumn balance+reports: first, the report will show all columns within the specified+report period (without -E, leading and trailing columns with all zeroes+are not shown).+Second, all accounts which existed at the report start date will be+considered, not just the ones with activity during the report period+(use -E to include low-activity accounts which would otherwise would be+omitted).+.PP+The \f[C]-T/--row-total\f[R] flag adds an additional column showing the+total for each row.+.PP+The \f[C]-A/--average\f[R] flag adds a column showing the average value+in each row.+.PP+Here\[aq]s an example of all three:+.IP+.nf+\f[C]+$ hledger balance -Q income expenses --tree -ETA+Balance changes in 2008:++            ||  2008q1  2008q2  2008q3  2008q4    Total  Average +============++===================================================+ expenses   ||       0      $2       0       0       $2       $1 +   food     ||       0      $1       0       0       $1        0 +   supplies ||       0      $1       0       0       $1        0 + income     ||     $-1     $-1       0       0      $-2      $-1 +   gifts    ||       0     $-1       0       0      $-1        0 +   salary   ||     $-1       0       0       0      $-1        0 +------------++---------------------------------------------------+            ||     $-1      $1       0       0        0        0 ++# Average is rounded to the dollar here since all journal amounts are+\f[R]+.fi+.PP+Limitations:+.PP+In multicolumn reports the \f[C]-V/--value\f[R] flag uses the market+price on the report end date, for all columns (not the price on each+column\[aq]s end date).+.PP+Eliding of boring parent accounts in tree mode, as in the classic+balance report, is not yet supported in multicolumn reports.+.SS Budget report+.PP+With \f[C]--budget\f[R], extra columns are displayed showing budget+goals for each account and period, if any.+Budget goals are defined by periodic transactions.+This is very useful for comparing planned and actual income, expenses,+time usage, etc.+--budget is most often combined with a report interval.+.PP+For example, you can take average monthly expenses in the common expense+categories to construct a minimal monthly budget:+.IP+.nf+\f[C]+;; Budget+\[ti] monthly+  income  $2000+  expenses:food    $400+  expenses:bus     $50+  expenses:movies  $30+  assets:bank:checking++;; Two months worth of expenses+2017-11-01+  income  $1950+  expenses:food    $396+  expenses:bus     $49+  expenses:movies  $30+  expenses:supplies  $20+  assets:bank:checking++2017-12-01+  income  $2100+  expenses:food    $412+  expenses:bus     $53+  expenses:gifts   $100+  assets:bank:checking+\f[R]+.fi+.PP+You can now see a monthly budget report:+.IP+.nf+\f[C]+$ hledger balance -M --budget+Budget performance in 2017/11/01-2017/12/31:++                      ||                      Nov                       Dec +======================++====================================================+ assets               || $-2445 [  99% of $-2480]  $-2665 [ 107% of $-2480] + assets:bank          || $-2445 [  99% of $-2480]  $-2665 [ 107% of $-2480] + assets:bank:checking || $-2445 [  99% of $-2480]  $-2665 [ 107% of $-2480] + expenses             ||   $495 [ 103% of   $480]    $565 [ 118% of   $480] + expenses:bus         ||    $49 [  98% of    $50]     $53 [ 106% of    $50] + expenses:food        ||   $396 [  99% of   $400]    $412 [ 103% of   $400] + expenses:movies      ||    $30 [ 100% of    $30]       0 [   0% of    $30] + income               ||  $1950 [  98% of  $2000]   $2100 [ 105% of  $2000] +----------------------++----------------------------------------------------+                      ||      0 [              0]       0 [              0] +\f[R]+.fi+.PP+Note this is different from a normal balance report in several ways:+.IP \[bu] 2+Only accounts with budget goals during the report period are shown, by+default.+.IP \[bu] 2+In each column, in square brackets after the actual amount, budgeted+amounts are shown, along with the percentage of budget used.+.IP \[bu] 2+All parent accounts are always shown, even in flat mode.+Eg assets, assets:bank, and expenses above.+.IP \[bu] 2+Amounts always include all subaccounts, budgeted or unbudgeted, even in+flat mode.+.PP+This means that the numbers displayed will not always add up! Eg above,+the \f[C]expenses\f[R] actual amount includes the gifts and supplies+transactions, but the \f[C]expenses:gifts\f[R] and+\f[C]expenses:supplies\f[R] accounts are not shown, as they have no+budget amounts declared.+.PP+This can be confusing.+When you need to make things clearer, use the \f[C]-E/--empty\f[R] flag,+which will reveal all accounts including unbudgeted ones, giving the+full picture.+Eg:+.IP+.nf+\f[C]+$ hledger balance -M --budget --empty+Budget performance in 2017/11/01-2017/12/31:++                      ||                      Nov                       Dec +======================++====================================================+ assets               || $-2445 [  99% of $-2480]  $-2665 [ 107% of $-2480] + assets:bank          || $-2445 [  99% of $-2480]  $-2665 [ 107% of $-2480] + assets:bank:checking || $-2445 [  99% of $-2480]  $-2665 [ 107% of $-2480] + expenses             ||   $495 [ 103% of   $480]    $565 [ 118% of   $480] + expenses:bus         ||    $49 [  98% of    $50]     $53 [ 106% of    $50] + expenses:food        ||   $396 [  99% of   $400]    $412 [ 103% of   $400] + expenses:gifts       ||      0                      $100                   + expenses:movies      ||    $30 [ 100% of    $30]       0 [   0% of    $30] + expenses:supplies    ||    $20                         0                   + income               ||  $1950 [  98% of  $2000]   $2100 [ 105% of  $2000] +----------------------++----------------------------------------------------+                      ||      0 [              0]       0 [              0] +\f[R]+.fi+.PP+You can roll over unspent budgets to next period with+\f[C]--cumulative\f[R]:+.IP+.nf+\f[C]+$ hledger balance -M --budget --cumulative+Budget performance in 2017/11/01-2017/12/31:++                      ||                      Nov                       Dec +======================++====================================================+ assets               || $-2445 [  99% of $-2480]  $-5110 [ 103% of $-4960] + assets:bank          || $-2445 [  99% of $-2480]  $-5110 [ 103% of $-4960] + assets:bank:checking || $-2445 [  99% of $-2480]  $-5110 [ 103% of $-4960] + expenses             ||   $495 [ 103% of   $480]   $1060 [ 110% of   $960] + expenses:bus         ||    $49 [  98% of    $50]    $102 [ 102% of   $100] + expenses:food        ||   $396 [  99% of   $400]    $808 [ 101% of   $800] + expenses:movies      ||    $30 [ 100% of    $30]     $30 [  50% of    $60] + income               ||  $1950 [  98% of  $2000]   $4050 [ 101% of  $4000] +----------------------++----------------------------------------------------+                      ||      0 [              0]       0 [              0] +\f[R]+.fi+.PP+For more examples, see Budgeting and Forecasting.+.SS Nested budgets+.PP+You can add budgets to any account in your account hierarchy.+If you have budgets on both parent account and some of its children,+then budget(s) of the child account(s) would be added to the budget of+their parent, much like account balances behave.+.PP+In the most simple case this means that once you add a budget to any+account, all its parents would have budget as well.+.PP+To illustrate this, consider the following budget:+.IP+.nf+\f[C]+\[ti] monthly from 2019/01+    expenses:personal             $1,000.00+    expenses:personal:electronics    $100.00+    liabilities+\f[R]+.fi+.PP+With this, monthly budget for electronics is defined to be $100 and+budget for personal expenses is an additional $1000, which implicity+means that budget for both \f[C]expenses:personal\f[R] and+\f[C]expenses\f[R] is $1100.+.PP+Transactions in \f[C]expenses:personal:electronics\f[R] will be counted+both towards its $100 budget and $1100 of \f[C]expenses:personal\f[R] ,+and transactions in any other subaccount of \f[C]expenses:personal\f[R]+would be counted towards only towards the budget of+\f[C]expenses:personal\f[R].+.PP+For example, let\[aq]s consider these transactions:+.IP+.nf+\f[C]+\[ti] monthly from 2019/01+    expenses:personal             $1,000.00+    expenses:personal:electronics    $100.00+    liabilities++2019/01/01 Google home hub+    expenses:personal:electronics          $90.00+    liabilities                           $-90.00++2019/01/02 Phone screen protector+    expenses:personal:electronics:upgrades          $10.00+    liabilities++2019/01/02 Weekly train ticket+    expenses:personal:train tickets       $153.00+    liabilities++2019/01/03 Flowers+    expenses:personal          $30.00+    liabilities+\f[R]+.fi+.PP+As you can see, we have transactions in+\f[C]expenses:personal:electronics:upgrades\f[R] and+\f[C]expenses:personal:train tickets\f[R], and since both of these+accounts are without explicitly defined budget, these transactions would+be counted towards budgets of \f[C]expenses:personal:electronics\f[R]+and \f[C]expenses:personal\f[R] accordingly:+.IP+.nf+\f[C]+$ hledger balance --budget -M+Budget performance in 2019/01:++                               ||                           Jan +===============================++===============================+ expenses                      ||  $283.00 [  26% of  $1100.00] + expenses:personal             ||  $283.00 [  26% of  $1100.00] + expenses:personal:electronics ||  $100.00 [ 100% of   $100.00] + liabilities                   || $-283.00 [  26% of $-1100.00] +-------------------------------++-------------------------------+                               ||        0 [                 0] +\f[R]+.fi+.PP+And with \f[C]--empty\f[R], we can get a better picture of budget+allocation and consumption:+.IP+.nf+\f[C]+$ hledger balance --budget -M --empty+Budget performance in 2019/01:++                                        ||                           Jan +========================================++===============================+ expenses                               ||  $283.00 [  26% of  $1100.00] + expenses:personal                      ||  $283.00 [  26% of  $1100.00] + expenses:personal:electronics          ||  $100.00 [ 100% of   $100.00] + expenses:personal:electronics:upgrades ||   $10.00                      + expenses:personal:train tickets        ||  $153.00                      + liabilities                            || $-283.00 [  26% of $-1100.00] +----------------------------------------++-------------------------------+                                        ||        0 [                 0] +\f[R]+.fi+.SS Output format+.PP+The balance command supports output destination and output format+selection.+.SS balancesheet+.PP+balancesheet, bs+.PD 0+.P+.PD+This command displays a simple balance sheet, showing historical ending+balances of asset and liability accounts (ignoring any report begin+date).+It assumes that these accounts are under a top-level \f[C]asset\f[R] or+\f[C]liability\f[R] account (case insensitive, plural forms also+allowed).+.PP+Note this report shows all account balances with normal positive sign+(like conventional financial statements, unlike balance/print/register)+(experimental).+.PP+Example:+.IP+.nf+\f[C]+$ hledger balancesheet+Balance Sheet++Assets:+                 $-1  assets+                  $1    bank:saving+                 $-2    cash+--------------------+                 $-1++Liabilities:+                  $1  liabilities:debts+--------------------+                  $1++Total:+--------------------+                   0+\f[R]+.fi+.PP+With a reporting interval, multiple columns will be shown, one for each+report period.+As with multicolumn balance reports, you can alter the report mode with+\f[C]--change\f[R]/\f[C]--cumulative\f[R]/\f[C]--historical\f[R].+Normally balancesheet shows historical ending balances, which is what+you need for a balance sheet; note this means it ignores report begin+dates (and \f[C]-T/--row-total\f[R], since summing end balances+generally does not make sense).+.PP+This command also supports output destination and output format+selection.+.SS balancesheetequity+.PP+balancesheetequity, bse+.PD 0+.P+.PD+Just like balancesheet, but also reports Equity (which it assumes is+under a top-level \f[C]equity\f[R] account).+.PP+Example:+.IP+.nf+\f[C]+$ hledger balancesheetequity+Balance Sheet With Equity++Assets:+                 $-2  assets+                  $1    bank:saving+                 $-3    cash+--------------------+                 $-2++Liabilities:+                  $1  liabilities:debts+--------------------+                  $1++Equity:+          $1  equity:owner+--------------------+          $1++Total:+--------------------+                   0+\f[R]+.fi+.SS cashflow+.PP+cashflow, cf+.PD 0+.P+.PD+This command displays a simple cashflow statement, showing changes in+\[dq]cash\[dq] accounts.+It assumes that these accounts are under a top-level \f[C]asset\f[R]+account (case insensitive, plural forms also allowed) and do not contain+\f[C]receivable\f[R] or \f[C]A/R\f[R] in their name.+Note this report shows all account balances with normal positive sign+(like conventional financial statements, unlike balance/print/register)+(experimental).+.PP+Example:+.IP+.nf+\f[C]+$ hledger cashflow+Cashflow Statement++Cash flows:+                 $-1  assets+                  $1    bank:saving+                 $-2    cash+--------------------+                 $-1++Total:+--------------------+                 $-1+\f[R]+.fi+.PP+With a reporting interval, multiple columns will be shown, one for each+report period.+Normally cashflow shows changes in assets per period, though as with+multicolumn balance reports you can alter the report mode with+\f[C]--change\f[R]/\f[C]--cumulative\f[R]/\f[C]--historical\f[R].+.PP+This command also supports output destination and output format+selection.+.SS check-dates+.PP+check-dates+.PD 0+.P+.PD+Check that transactions are sorted by increasing date.+With --date2, checks secondary dates instead.+With --strict, dates must also be unique.+With a query, only matched transactions\[aq] dates are checked.+Reads the default journal file, or another specified with -f.+.SS check-dupes+.PP+check-dupes+.PD 0+.P+.PD+Reports account names having the same leaf but different prefixes.+In other words, two or more leaves that are categorized differently.+Reads the default journal file, or another specified as an argument.+.PP+An example: http://stefanorodighiero.net/software/hledger-dupes.html+.SS close+.PP+close, equity+.PD 0+.P+.PD+Prints a \[dq]closing balances\[dq] transaction and an \[dq]opening+balances\[dq] transaction that bring account balances to and from zero,+respectively.+Useful for bringing asset/liability balances forward into a new journal+file, or for closing out revenues/expenses to retained earnings at the+end of a period.+.PP+The closing transaction transfers balances to \[dq]equity:closing+balances\[dq].+The opening transaction transfers balances from \[dq]equity:opening+balances\[dq].+You can choose to print just one of the transactions by using the+\f[C]--opening\f[R] or \f[C]--closing\f[R] flag.+.PP+If you split your journal files by time (eg yearly), you will typically+run this command at the end of the year, and save the closing+transaction as last entry of the old file, and the opening transaction+as the first entry of the new file.+This makes the files self contained, so that correct balances are+reported no matter which of them are loaded.+Ie, if you load just one file, the balances are initialised correctly;+or if you load several files, the redundant closing/opening transactions+cancel each other out.+(They will show up in print or register reports; you can exclude them+with a query like+\f[C]not:desc:\[aq](opening|closing) balances\[aq]\f[R].)+.PP+If you\[aq]re running a business, you might also use this command to+\[dq]close the books\[dq] at the end of an accounting period,+transferring income statement account balances to retained earnings.+(You may want to change the equity account name to something like+\[dq]equity:retained earnings\[dq].)+.PP+By default, the closing transaction is dated yesterday, the balances are+calculated as of end of yesterday, and the opening transaction is dated+today.+To close on some other date, use:+\f[C]hledger close -e OPENINGDATE\f[R].+Eg, to close/open on the 2018/2019 boundary, use \f[C]-e 2019\f[R].+You can also use -p or \f[C]date:PERIOD\f[R] (any starting date is+ignored).+.PP+Both transactions will include balance assertions for the+closed/reopened accounts.+You probably shouldn\[aq]t use status or realness filters (like -C or -R+or \f[C]status:\f[R]) with this command, or the generated balance+assertions will depend on these flags.+Likewise, if you run this command with --auto, the balance assertions+will probably always require --auto.+.PP+When account balances have cost information (transaction prices), the+closing/opening transactions will preserve it, so that eg balance -B+reports will not be affected.+.PP+Examples:+.PP+Carrying asset/liability balances into a new file for 2019, all from+command line:+.PP+\f[I]Warning: we use \f[CI]>>\f[I] here to append; be careful not to+type a single \f[CI]>\f[I] which would wipe your journal!\f[R]+.IP+.nf+\f[C]+$ hledger close -f 2018.journal -e 2019 assets liabilities --opening >>2019.journal+$ hledger close -f 2018.journal -e 2019 assets liabilities --closing >>2018.journal+\f[R]+.fi+.PP+Now:+.IP+.nf+\f[C]+$ hledger bs -f 2019.journal                   # one file - balances are correct+$ hledger bs -f 2018.journal -f 2019.journal   # two files - balances still correct+$ hledger bs -f 2018.journal not:desc:closing  # to see year-end balances, must exclude closing txn+\f[R]+.fi+.PP+Transactions spanning the closing date can complicate matters, breaking+balance assertions:+.IP+.nf+\f[C]+2018/12/30 a purchase made in 2018, clearing the following year+    expenses:food          5+    assets:bank:checking  -5  ; [2019/1/2]+\f[R]+.fi+.PP+Here\[aq]s one way to resolve that:+.IP+.nf+\f[C]+; in 2018.journal:+2018/12/30 a purchase made in 2018, clearing the following year+    expenses:food          5+    liabilities:pending++; in 2019.journal:+2019/1/2 clearance of last year\[aq]s pending transactions+    liabilities:pending    5 = 0+    assets:checking+\f[R]+.fi+.SS files+.PP+files+.PD 0+.P+.PD+List all files included in the journal.+With a REGEX argument, only file names matching the regular expression+(case sensitive) are shown.+.SS help+.PP+help+.PD 0+.P+.PD+Show any of the hledger manuals.+.PP+The \f[C]help\f[R] command displays any of the main hledger manuals, in+one of several ways.+Run it with no argument to list the manuals, or provide a full or+partial manual name to select one.+.PP+hledger manuals are available in several formats.+hledger help will use the first of these display methods that it finds:+info, man, $PAGER, less, stdout (or when non-interactive, just stdout).+You can force a particular viewer with the \f[C]--info\f[R],+\f[C]--man\f[R], \f[C]--pager\f[R], \f[C]--cat\f[R] flags.+.PP+Examples:+.IP+.nf+\f[C]+$ hledger help+Please choose a manual by typing \[dq]hledger help MANUAL\[dq] (a substring is ok).+Manuals: hledger hledger-ui hledger-web hledger-api journal csv timeclock timedot+\f[R]+.fi+.IP+.nf+\f[C]+$ hledger help h --man++hledger(1)                    hledger User Manuals                    hledger(1)++NAME+       hledger - a command-line accounting tool++SYNOPSIS+       hledger [-f FILE] COMMAND [OPTIONS] [ARGS]+       hledger [-f FILE] ADDONCMD -- [OPTIONS] [ARGS]+       hledger++DESCRIPTION+       hledger  is  a  cross-platform  program  for tracking money, time, or any+\&...+\f[R]+.fi+.SS import+.PP+import+.PD 0+.P+.PD+Read new transactions added to each FILE since last run, and add them to+the main journal file.+Or with --dry-run, just print the transactions that would be added.+.PP+The input files are specified as arguments - no need to write -f before+each one.+So eg to add new transactions from all CSV files to the main journal,+it\[aq]s just: \f[C]hledger import *.csv\f[R]+.PP+New transactions are detected in the same way as print --new: by+assuming transactions are always added to the input files in increasing+date order, and by saving \f[C].latest.FILE\f[R] state files.+.PP+The --dry-run output is in journal format, so you can filter it, eg to+see only uncategorised transactions:+.IP+.nf+\f[C]+$ hledger import --dry ... | hledger -f- print unknown --ignore-assertions+\f[R]+.fi+.SS Importing balance assignments+.PP+Entries added by import will have their posting amounts made explicit+(like \f[C]hledger print -x\f[R]).+This means that any balance assignments in imported files must be+evaluated; but, imported files don\[aq]t get to see the main file\[aq]s+account balances.+As a result, importing entries with balance assignments (eg from an+institution that provides only balances and not posting amounts) will+probably generate incorrect posting amounts.+To avoid this problem, use print instead of import:+.IP+.nf+\f[C]+$ hledger print IMPORTFILE [--new] >> $LEDGER_FILE+\f[R]+.fi+.PP+(If you think import should leave amounts implicit like print does,+please test it and send a pull request.)+.SS incomestatement+.PP+incomestatement, is+.PD 0+.P+.PD+This command displays a simple income statement, showing revenues and+expenses during a period.+It assumes that these accounts are under a top-level \f[C]revenue\f[R]+or \f[C]income\f[R] or \f[C]expense\f[R] account (case insensitive,+plural forms also allowed).+Note this report shows all account balances with normal positive sign+(like conventional financial statements, unlike balance/print/register)+(experimental).+.PP+This command displays a simple income statement.+It currently assumes that you have top-level accounts named+\f[C]income\f[R] (or \f[C]revenue\f[R]) and \f[C]expense\f[R] (plural+forms also allowed.)+.IP+.nf+\f[C]+$ hledger incomestatement+Income Statement++Revenues:+                 $-2  income+                 $-1    gifts+                 $-1    salary+--------------------+                 $-2++Expenses:+                  $2  expenses+                  $1    food+                  $1    supplies+--------------------+                  $2++Total:+--------------------+                   0+\f[R]+.fi+.PP+With a reporting interval, multiple columns will be shown, one for each+report period.+Normally incomestatement shows revenues/expenses per period, though as+with multicolumn balance reports you can alter the report mode with+\f[C]--change\f[R]/\f[C]--cumulative\f[R]/\f[C]--historical\f[R].+.PP+This command also supports output destination and output format+selection.+.SS prices+.PP+prices+.PD 0+.P+.PD+Print market price directives from the journal.+With --costs, also print synthetic market prices based on transaction+prices.+With --inverted-costs, also print inverse prices based on transaction+prices.+Prices (and postings providing prices) can be filtered by a query.+.SS print+.PP+print, txns, p+.PD 0+.P+.PD+Show transaction journal entries, sorted by date.+.PP+The print command displays full journal entries (transactions) from the+journal file in date order, tidily formatted.+With --date2, transactions are sorted by secondary date instead.+.PP+print\[aq]s output is always a valid hledger journal.+.PD 0+.P+.PD+It preserves all transaction information, but it does not preserve+directives or inter-transaction comments+.IP+.nf+\f[C]+$ hledger print+2008/01/01 income+    assets:bank:checking            $1+    income:salary                  $-1++2008/06/01 gift+    assets:bank:checking            $1+    income:gifts                   $-1++2008/06/02 save+    assets:bank:saving              $1+    assets:bank:checking           $-1++2008/06/03 * eat & shop+    expenses:food                $1+    expenses:supplies            $1+    assets:cash                 $-2++2008/12/31 * pay off+    liabilities:debts               $1+    assets:bank:checking           $-1+\f[R]+.fi+.PP+Normally, the journal entry\[aq]s explicit or implicit amount style is+preserved.+Ie when an amount is omitted in the journal, it will be omitted in the+output.+You can use the \f[C]-x\f[R]/\f[C]--explicit\f[R] flag to make all+amounts explicit, which can be useful for troubleshooting or for making+your journal more readable and robust against data entry errors.+Note, \f[C]-x\f[R] will cause postings with a multi-commodity amount+(these can arise when a multi-commodity transaction has an implicit+amount) will be split into multiple single-commodity postings, for valid+journal output.+.PP+With \f[C]-B\f[R]/\f[C]--cost\f[R], amounts with transaction prices are+converted to cost using that price.+This can be used for troubleshooting.+.PP+With \f[C]-m\f[R]/\f[C]--match\f[R] and a STR argument, print will show+at most one transaction: the one one whose description is most similar+to STR, and is most recent.+STR should contain at least two characters.+If there is no similar-enough match, no transaction will be shown.+.PP+With \f[C]--new\f[R], for each FILE being read, hledger reads (and+writes) a special state file (\f[C].latest.FILE\f[R] in the same+directory), containing the latest transaction date(s) that were seen+last time FILE was read.+When this file is found, only transactions with newer dates (and new+transactions on the latest date) are printed.+This is useful for ignoring already-seen entries in import data, such as+downloaded CSV files.+Eg:+.IP+.nf+\f[C]+$ hledger -f bank1.csv print --new+# shows transactions added since last print --new on this file+\f[R]+.fi+.PP+This assumes that transactions added to FILE always have same or+increasing dates, and that transactions on the same day do not get+reordered.+See also the import command.+.PP+This command also supports output destination and output format+selection.+Here\[aq]s an example of print\[aq]s CSV output:+.IP+.nf+\f[C]+$ hledger print -Ocsv+\[dq]txnidx\[dq],\[dq]date\[dq],\[dq]date2\[dq],\[dq]status\[dq],\[dq]code\[dq],\[dq]description\[dq],\[dq]comment\[dq],\[dq]account\[dq],\[dq]amount\[dq],\[dq]commodity\[dq],\[dq]credit\[dq],\[dq]debit\[dq],\[dq]posting-status\[dq],\[dq]posting-comment\[dq]+\[dq]1\[dq],\[dq]2008/01/01\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]income\[dq],\[dq]\[dq],\[dq]assets:bank:checking\[dq],\[dq]1\[dq],\[dq]$\[dq],\[dq]\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq]+\[dq]1\[dq],\[dq]2008/01/01\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]income\[dq],\[dq]\[dq],\[dq]income:salary\[dq],\[dq]-1\[dq],\[dq]$\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq]+\[dq]2\[dq],\[dq]2008/06/01\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]gift\[dq],\[dq]\[dq],\[dq]assets:bank:checking\[dq],\[dq]1\[dq],\[dq]$\[dq],\[dq]\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq]+\[dq]2\[dq],\[dq]2008/06/01\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]gift\[dq],\[dq]\[dq],\[dq]income:gifts\[dq],\[dq]-1\[dq],\[dq]$\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq]+\[dq]3\[dq],\[dq]2008/06/02\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]save\[dq],\[dq]\[dq],\[dq]assets:bank:saving\[dq],\[dq]1\[dq],\[dq]$\[dq],\[dq]\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq]+\[dq]3\[dq],\[dq]2008/06/02\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]save\[dq],\[dq]\[dq],\[dq]assets:bank:checking\[dq],\[dq]-1\[dq],\[dq]$\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq]+\[dq]4\[dq],\[dq]2008/06/03\[dq],\[dq]\[dq],\[dq]*\[dq],\[dq]\[dq],\[dq]eat & shop\[dq],\[dq]\[dq],\[dq]expenses:food\[dq],\[dq]1\[dq],\[dq]$\[dq],\[dq]\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq]+\[dq]4\[dq],\[dq]2008/06/03\[dq],\[dq]\[dq],\[dq]*\[dq],\[dq]\[dq],\[dq]eat & shop\[dq],\[dq]\[dq],\[dq]expenses:supplies\[dq],\[dq]1\[dq],\[dq]$\[dq],\[dq]\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq]+\[dq]4\[dq],\[dq]2008/06/03\[dq],\[dq]\[dq],\[dq]*\[dq],\[dq]\[dq],\[dq]eat & shop\[dq],\[dq]\[dq],\[dq]assets:cash\[dq],\[dq]-2\[dq],\[dq]$\[dq],\[dq]2\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq]+\[dq]5\[dq],\[dq]2008/12/31\[dq],\[dq]\[dq],\[dq]*\[dq],\[dq]\[dq],\[dq]pay off\[dq],\[dq]\[dq],\[dq]liabilities:debts\[dq],\[dq]1\[dq],\[dq]$\[dq],\[dq]\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq]+\[dq]5\[dq],\[dq]2008/12/31\[dq],\[dq]\[dq],\[dq]*\[dq],\[dq]\[dq],\[dq]pay off\[dq],\[dq]\[dq],\[dq]assets:bank:checking\[dq],\[dq]-1\[dq],\[dq]$\[dq],\[dq]1\[dq],\[dq]\[dq],\[dq]\[dq],\[dq]\[dq]+\f[R]+.fi+.IP \[bu] 2+There is one CSV record per posting, with the parent transaction\[aq]s+fields repeated.+.IP \[bu] 2+The \[dq]txnidx\[dq] (transaction index) field shows which postings+belong to the same transaction.+(This number might change if transactions are reordered within the file,+files are parsed/included in a different order, etc.)+.IP \[bu] 2+The amount is separated into \[dq]commodity\[dq] (the symbol) and+\[dq]amount\[dq] (numeric quantity) fields.+.IP \[bu] 2+The numeric amount is repeated in either the \[dq]credit\[dq] or+\[dq]debit\[dq] column, for convenience.+(Those names are not accurate in the accounting sense; it just puts+negative amounts under credit and zero or greater amounts under debit.)+.SS print-unique+.PP+print-unique+.PD 0+.P+.PD+Print transactions which do not reuse an already-seen description.+.PP+Example:+.IP+.nf+\f[C]+$ cat unique.journal+1/1 test+ (acct:one)  1+2/2 test+ (acct:two)  2+$ LEDGER_FILE=unique.journal hledger print-unique+(-f option not supported)+2015/01/01 test+    (acct:one)             1+\f[R]+.fi+.SS register+.PP+register, reg, r+.PD 0+.P+.PD+Show postings and their running total.+.PP+The register command displays postings in date order, one per line, and+their running total.+This is typically used with a query selecting a particular account, to+see that account\[aq]s activity:+.IP+.nf+\f[C]+$ hledger register checking+2008/01/01 income               assets:bank:checking            $1           $1+2008/06/01 gift                 assets:bank:checking            $1           $2+2008/06/02 save                 assets:bank:checking           $-1           $1+2008/12/31 pay off              assets:bank:checking           $-1            0+\f[R]+.fi+.PP+With --date2, it shows and sorts by secondary date instead.+.PP+The \f[C]--historical\f[R]/\f[C]-H\f[R] flag adds the balance from any+undisplayed prior postings to the running total.+This is useful when you want to see only recent activity, with a+historically accurate running balance:+.IP+.nf+\f[C]+$ hledger register checking -b 2008/6 --historical+2008/06/01 gift                 assets:bank:checking            $1           $2+2008/06/02 save                 assets:bank:checking           $-1           $1+2008/12/31 pay off              assets:bank:checking           $-1            0+\f[R]+.fi+.PP+The \f[C]--depth\f[R] option limits the amount of sub-account detail+displayed.+.PP+The \f[C]--average\f[R]/\f[C]-A\f[R] flag shows the running average+posting amount instead of the running total (so, the final number+displayed is the average for the whole report period).+This flag implies \f[C]--empty\f[R] (see below).+It is affected by \f[C]--historical\f[R].+It works best when showing just one account and one commodity.+.PP+The \f[C]--related\f[R]/\f[C]-r\f[R] flag shows the \f[I]other\f[R]+postings in the transactions of the postings which would normally be+shown.+.PP+The \f[C]--invert\f[R] flag negates all amounts.+For example, it can be used on an income account where amounts are+normally displayed as negative numbers.+It\[aq]s also useful to show postings on the checking account together+with the related account:+.IP+.nf+\f[C]+$ hledger register --related --invert assets:checking+\f[R]+.fi+.PP+With a reporting interval, register shows summary postings, one per+interval, aggregating the postings to each account:+.IP+.nf+\f[C]+$ hledger register --monthly income+2008/01                 income:salary                          $-1          $-1+2008/06                 income:gifts                           $-1          $-2+\f[R]+.fi+.PP+Periods with no activity, and summary postings with a zero amount, are+not shown by default; use the \f[C]--empty\f[R]/\f[C]-E\f[R] flag to see+them:+.IP+.nf+\f[C]+$ hledger register --monthly income -E+2008/01                 income:salary                          $-1          $-1+2008/02                                                          0          $-1+2008/03                                                          0          $-1+2008/04                                                          0          $-1+2008/05                                                          0          $-1+2008/06                 income:gifts                           $-1          $-2+2008/07                                                          0          $-2+2008/08                                                          0          $-2+2008/09                                                          0          $-2+2008/10                                                          0          $-2+2008/11                                                          0          $-2+2008/12                                                          0          $-2+\f[R]+.fi+.PP+Often, you\[aq]ll want to see just one line per interval.+The \f[C]--depth\f[R] option helps with this, causing subaccounts to be+aggregated:+.IP+.nf+\f[C]+$ hledger register --monthly assets --depth 1h+2008/01                 assets                                  $1           $1+2008/06                 assets                                 $-1            0+2008/12                 assets                                 $-1          $-1+\f[R]+.fi+.PP+Note when using report intervals, if you specify start/end dates these+will be adjusted outward if necessary to contain a whole number of+intervals.+This ensures that the first and last intervals are full length and+comparable to the others in the report.+.SS Custom register output+.PP+register uses the full terminal width by default, except on windows.+You can override this by setting the \f[C]COLUMNS\f[R] environment+variable (not a bash shell variable) or by using the+\f[C]--width\f[R]/\f[C]-w\f[R] option.+.PP+The description and account columns normally share the space equally+(about half of (width - 40) each).+You can adjust this by adding a description width as part of+--width\[aq]s argument, comma-separated: \f[C]--width W,D\f[R] .+Here\[aq]s a diagram (won\[aq]t display correctly in --help):+.IP+.nf+\f[C]+<--------------------------------- width (W) ---------------------------------->+date (10)  description (D)       account (W-41-D)     amount (12)   balance (12)+DDDDDDDDDD dddddddddddddddddddd  aaaaaaaaaaaaaaaaaaa  AAAAAAAAAAAA  AAAAAAAAAAAA+\f[R]+.fi+.PP+and some examples:+.IP+.nf+\f[C]+$ hledger reg                     # use terminal width (or 80 on windows)+$ hledger reg -w 100              # use width 100+$ COLUMNS=100 hledger reg         # set with one-time environment variable+$ export COLUMNS=100; hledger reg # set till session end (or window resize)+$ hledger reg -w 100,40           # set overall width 100, description width 40+$ hledger reg -w $COLUMNS,40      # use terminal width, & description width 40+\f[R]+.fi+.PP+This command also supports output destination and output format+selection.+.SS register-match+.PP+register-match+.PD 0+.P+.PD+Print the one posting whose transaction description is closest to DESC,+in the style of the register command.+If there are multiple equally good matches, it shows the most recent.+Query options (options, not arguments) can be used to restrict the+search space.+Helps ledger-autosync detect already-seen transactions when importing.+.SS rewrite+.PP+rewrite+.PD 0+.P+.PD+Print all transactions, rewriting the postings of matched transactions.+For now the only rewrite available is adding new postings, like print+--auto.+.PP+This is a start at a generic rewriter of transaction entries.+It reads the default journal and prints the transactions, like print,+but adds one or more specified postings to any transactions matching+QUERY.+The posting amounts can be fixed, or a multiplier of the existing+transaction\[aq]s first posting amount.+.PP+Examples:+.IP+.nf+\f[C]+$ hledger-rewrite.hs \[ha]income --add-posting \[aq](liabilities:tax)  *.33  ; income tax\[aq] --add-posting \[aq](reserve:gifts)  $100\[aq]+$ hledger-rewrite.hs expenses:gifts --add-posting \[aq](reserve:gifts)  *-1\[dq]\[aq]+$ hledger-rewrite.hs -f rewrites.hledger+\f[R]+.fi+.PP+rewrites.hledger may consist of entries like:+.IP+.nf+\f[C]+= \[ha]income amt:<0 date:2017+  (liabilities:tax)  *0.33  ; tax on income+  (reserve:grocery)  *0.25  ; reserve 25% for grocery+  (reserve:)  *0.25  ; reserve 25% for grocery+\f[R]+.fi+.PP+Note the single quotes to protect the dollar sign from bash, and the two+spaces between account and amount.+.PP+More:+.IP+.nf+\f[C]+$ hledger rewrite -- [QUERY]        --add-posting \[dq]ACCT  AMTEXPR\[dq] ...+$ hledger rewrite -- \[ha]income        --add-posting \[aq](liabilities:tax)  *.33\[aq]+$ hledger rewrite -- expenses:gifts --add-posting \[aq](budget:gifts)  *-1\[dq]\[aq]+$ hledger rewrite -- \[ha]income        --add-posting \[aq](budget:foreign currency)  *0.25 JPY; diversify\[aq]+\f[R]+.fi+.PP+Argument for \f[C]--add-posting\f[R] option is a usual posting of+transaction with an exception for amount specification.+More precisely, you can use \f[C]\[aq]*\[aq]\f[R] (star symbol) before+the amount to indicate that that this is a factor for an amount of+original matched posting.+If the amount includes a commodity name, the new posting amount will be+in the new commodity; otherwise, it will be in the matched posting+amount\[aq]s commodity.+.SS Re-write rules in a file+.PP+During the run this tool will execute so called \[dq]Automated+Transactions\[dq] found in any journal it process.+I.e instead of specifying this operations in command line you can put+them in a journal file.+.IP+.nf+\f[C]+$ rewrite-rules.journal+\f[R]+.fi+.PP+Make contents look like this:+.IP+.nf+\f[C]+= \[ha]income+    (liabilities:tax)  *.33++= expenses:gifts+    budget:gifts  *-1+    assets:budget  *1+\f[R]+.fi+.PP+Note that \f[C]\[aq]=\[aq]\f[R] (equality symbol) that is used instead+of date in transactions you usually write.+It indicates the query by which you want to match the posting to add new+ones.+.IP+.nf+\f[C]+$ hledger rewrite -- -f input.journal -f rewrite-rules.journal > rewritten-tidy-output.journal+\f[R]+.fi+.PP+This is something similar to the commands pipeline:+.IP+.nf+\f[C]+$ hledger rewrite -- -f input.journal \[aq]\[ha]income\[aq] --add-posting \[aq](liabilities:tax)  *.33\[aq] \[rs]+  | hledger rewrite -- -f - expenses:gifts      --add-posting \[aq]budget:gifts  *-1\[aq]       \[rs]+                                                --add-posting \[aq]assets:budget  *1\[aq]       \[rs]+  > rewritten-tidy-output.journal+\f[R]+.fi+.PP+It is important to understand that relative order of such entries in+journal is important.+You can re-use result of previously added postings.+.SS Diff output format+.PP+To use this tool for batch modification of your journal files you may+find useful output in form of unified diff.+.IP+.nf+\f[C]+$ hledger rewrite -- --diff -f examples/sample.journal \[aq]\[ha]income\[aq] --add-posting \[aq](liabilities:tax)  *.33\[aq]+\f[R]+.fi+.PP+Output might look like:+.IP+.nf+\f[C]+--- /tmp/examples/sample.journal++++ /tmp/examples/sample.journal+\[at]\[at] -18,3 +18,4 \[at]\[at]+ 2008/01/01 income+-    assets:bank:checking  $1++    assets:bank:checking            $1+     income:salary++    (liabilities:tax)                0+\[at]\[at] -22,3 +23,4 \[at]\[at]+ 2008/06/01 gift+-    assets:bank:checking  $1++    assets:bank:checking            $1+     income:gifts++    (liabilities:tax)                0+\f[R]+.fi+.PP+If you\[aq]ll pass this through \f[C]patch\f[R] tool you\[aq]ll get+transactions containing the posting that matches your query be updated.+Note that multiple files might be update according to list of input+files specified via \f[C]--file\f[R] options and \f[C]include\f[R]+directives inside of these files.+.PP+Be careful.+Whole transaction being re-formatted in a style of output from+\f[C]hledger print\f[R].+.PP+See also:+.PP+https://github.com/simonmichael/hledger/issues/99+.SS rewrite vs. print --auto+.PP+This command predates print --auto, and currently does much the same+thing, but with these differences:+.IP \[bu] 2+with multiple files, rewrite lets rules in any file affect all other+files.+print --auto uses standard directive scoping; rules affect only child+files.+.IP \[bu] 2+rewrite\[aq]s query limits which transactions can be rewritten; all are+printed.+print --auto\[aq]s query limits which transactions are printed.+.IP \[bu] 2+rewrite applies rules specified on command line or in the journal.+print --auto applies rules specified in the journal.+.SS roi+.PP+roi+.PD 0+.P+.PD+Shows the time-weighted (TWR) and money-weighted (IRR) rate of return on+your investments.+.PP+This command assumes that you have account(s) that hold nothing but your+investments and whenever you record current appraisal/valuation of these+investments you offset unrealized profit and loss into account(s) that,+again, hold nothing but unrealized profit and loss.+.PP+Any transactions affecting balance of investment account(s) and not+originating from unrealized profit and loss account(s) are assumed to be+your investments or withdrawals.+.PP+At a minimum, you need to supply a query (which could be just an account+name) to select your investments with \f[C]--inv\f[R], and another query+to identify your profit and loss transactions with \f[C]--pnl\f[R].+.PP+It will compute and display the internalized rate of return (IRR) and+time-weighted rate of return (TWR) for your investments for the time+period requested.+Both rates of return are annualized before display, regardless of the+length of reporting interval.+.SS stats+.PP+stats+.PD 0+.P+.PD+Show some journal statistics.+.PP+The stats command displays summary information for the whole journal, or+a matched part of it.+With a reporting interval, it shows a report for each report period.+.PP+Example:+.IP+.nf+\f[C]+$ hledger stats+Main journal file        : /src/hledger/examples/sample.journal+Included journal files   : +Transactions span        : 2008-01-01 to 2009-01-01 (366 days)+Last transaction         : 2008-12-31 (2333 days ago)+Transactions             : 5 (0.0 per day)+Transactions last 30 days: 0 (0.0 per day)+Transactions last 7 days : 0 (0.0 per day)+Payees/descriptions      : 5+Accounts                 : 8 (depth 3)+Commodities              : 1 ($)+Market prices            : 12 ($)+\f[R]+.fi+.PP+This command also supports output destination and output format+selection.+.SS tags+.PP+tags+.PD 0+.P+.PD+List all the tag names used in the journal.+With a TAGREGEX argument, only tag names matching the regular expression+(case insensitive) are shown.+With QUERY arguments, only transactions matching the query are+considered.+With --values flag, the tags\[aq] unique values are listed instead.+.SS test+.PP+test+.PD 0+.P+.PD+Run built-in unit tests.+.PP+This command runs the unit tests built in to hledger-lib and hledger,+printing test names and results on stdout.+If any test fails, the exit code will be non-zero.+.PP+Test names include a group prefix.+If a (exact, case sensitive) group prefix, or a full test name is+provided as the first argument, only that group or test is run.+.PP+If a numeric second argument is provided, it will set the randomness+seed, for repeatable results from tests using randomness (currently none+of them).+.PP+This is mainly used by developers, but it\[aq]s nice to be able to+sanity-check your installed hledger executable at any time.+All tests are expected to pass - if you ever see otherwise, something+has gone wrong, please report a bug!+.SH ADD-ON COMMANDS+.PP+hledger also searches for external add-on commands, and will include+these in the commands list.+These are programs or scripts in your PATH whose name starts with+\f[C]hledger-\f[R] and ends with a recognised file extension (currently:+no extension, \f[C]bat\f[R],\f[C]com\f[R],\f[C]exe\f[R],+\f[C]hs\f[R],\f[C]lhs\f[R],\f[C]pl\f[R],\f[C]py\f[R],\f[C]rb\f[R],\f[C]rkt\f[R],\f[C]sh\f[R]).+.PP+Add-ons can be invoked like any hledger command, but there are a few+things to be aware of.+Eg if the \f[C]hledger-web\f[R] add-on is installed,+.IP \[bu] 2+\f[C]hledger -h web\f[R] shows hledger\[aq]s help, while+\f[C]hledger web -h\f[R] shows hledger-web\[aq]s help.+.IP \[bu] 2+Flags specific to the add-on must have a preceding \f[C]--\f[R] to hide+them from hledger.+So \f[C]hledger web --serve --port 9000\f[R] will be rejected; you must+use \f[C]hledger web -- --serve --port 9000\f[R].+.IP \[bu] 2+You can always run add-ons directly if preferred:+\f[C]hledger-web --serve --port 9000\f[R].+.PP+Add-ons are a relatively easy way to add local features or experiment+with new ideas.+They can be written in any language, but haskell scripts have a big+advantage: they can use the same hledger (and haskell) library functions+that built-in commands do, for command-line options, journal parsing,+reporting, etc.+.PP+Here are some hledger add-ons available:+.SS Official add-ons+.PP+These are maintained and released along with hledger.+.SS api+.PP+hledger-api serves hledger data as a JSON web API.+.SS ui+.PP+hledger-ui provides an efficient curses-style interface.+.SS web+.PP+hledger-web provides a simple web interface.+.SS Third party add-ons+.PP+These are maintained separately, and usually updated shortly after a+hledger release.+.SS diff+.PP+hledger-diff shows differences in an account\[aq]s transactions between+one journal file and another.+.SS iadd+.PP+hledger-iadd is a curses-style, more interactive replacement for the add+command.+.SS interest+.PP+hledger-interest generates interest transactions for an account+according to various schemes.+.SS irr+.PP+hledger-irr calculates the internal rate of return of an investment+account, but it\[aq]s superseded now by the built-in roi command.+.SS Experimental add-ons+.PP+These are available in source form in the hledger repo\[aq]s bin/+directory; installing them is pretty easy.+They may be less mature and documented than built-in commands.+Reading and tweaking these is a good way to start making your own!+.SS autosync+.PP+hledger-autosync is a symbolic link for easily running ledger-autosync,+if installed.+ledger-autosync does deduplicating conversion of OFX data and some CSV+formats, and can also download the data if your bank offers OFX Direct+Connect.+.SS chart+.PP+hledger-chart.hs is an old pie chart generator, in need of some love.+.SS check+.PP+hledger-check.hs checks more powerful account balance assertions.+.SH ENVIRONMENT+.PP+\f[B]COLUMNS\f[R] The screen width used by the register command.+Default: the full terminal width.+.PP+\f[B]LEDGER_FILE\f[R] The journal file path when not specified with+\f[C]-f\f[R].+Default: \f[C]\[ti]/.hledger.journal\f[R] (on windows, perhaps+\f[C]C:/Users/USER/.hledger.journal\f[R]).+.SH FILES+.PP+Reads data from one or more files in hledger journal, timeclock,+timedot, or CSV format specified with \f[C]-f\f[R], or+\f[C]$LEDGER_FILE\f[R], or \f[C]$HOME/.hledger.journal\f[R] (on windows,+perhaps \f[C]C:/Users/USER/.hledger.journal\f[R]).+.SH LIMITATIONS+.PP+The need to precede addon command options with \f[C]--\f[R] when invoked+from hledger is awkward.+.PP+When input data contains non-ascii characters, a suitable system locale+must be configured (or there will be an unhelpful error).+Eg on POSIX, set LANG to something other than C.+.PP+In a Microsoft Windows CMD window, non-ascii characters and colours are+not supported.+.PP+On Windows, non-ascii characters may not display correctly when running+a hledger built in CMD in MSYS/CYGWIN, or vice-versa.+.PP+In a Cygwin/MSYS/Mintty window, the tab key is not supported in hledger+add.+.PP+Not all of Ledger\[aq]s journal file syntax is supported.+See file format differences.+.PP+On large data files, hledger is slower and uses more memory than Ledger.+.SH TROUBLESHOOTING+.PP+Here are some issues you might encounter when you run hledger (and+remember you can also seek help from the IRC channel, mail list or bug+tracker):+.PP+\f[B]Successfully installed, but \[dq]No command \[aq]hledger\[aq]+found\[dq]\f[R]+.PD 0+.P+.PD+stack and cabal install binaries into a special directory, which should+be added to your PATH environment variable.+Eg on unix-like systems, that is \[ti]/.local/bin and \[ti]/.cabal/bin+respectively.+.PP+\f[B]I set a custom LEDGER_FILE, but hledger is still using the default+file\f[R]+.PD 0+.P+.PD+\f[C]LEDGER_FILE\f[R] should be a real environment variable, not just a+shell variable.+The command \f[C]env | grep LEDGER_FILE\f[R] should show it.+You may need to use \f[C]export\f[R].+Here\[aq]s an explanation.+.PP+\f[B]\[dq]Illegal byte sequence\[dq] or \[dq]Invalid or incomplete+multibyte or wide character\[dq] errors\f[R]+.PD 0+.P+.PD+In order to handle non-ascii letters and symbols (like \[Po]), hledger+needs an appropriate locale.+This is usually configured system-wide; you can also configure it+temporarily.+The locale may need to be one that supports UTF-8, if you built hledger+with GHC < 7.2 (or possibly always, I\[aq]m not sure yet).+.PP+Here\[aq]s an example of setting the locale temporarily, on ubuntu+gnu/linux:+.IP+.nf+\f[C]+$ file my.journal+my.journal: UTF-8 Unicode text                 # <- the file is UTF8-encoded+$ locale -a+C+en_US.utf8                             # <- a UTF8-aware locale is available+POSIX+$ LANG=en_US.utf8 hledger -f my.journal print   # <- use it for this command+\f[R]+.fi+.PP+Here\[aq]s one way to set it permanently, there are probably better+ways:+.IP+.nf+\f[C]+$ echo \[dq]export LANG=en_US.UTF-8\[dq] >>\[ti]/.bash_profile+$ bash --login+\f[R]+.fi+.PP+If we preferred to use eg \f[C]fr_FR.utf8\f[R], we might have to install+that first:+.IP+.nf+\f[C]+$ apt-get install language-pack-fr+$ locale -a+C+en_US.utf8+fr_BE.utf8+fr_CA.utf8+fr_CH.utf8+fr_FR.utf8+fr_LU.utf8+POSIX+$ LANG=fr_FR.utf8 hledger -f my.journal print+\f[R]+.fi+.PP+Note some platforms allow variant locale spellings, but not all (ubuntu+accepts \f[C]fr_FR.UTF8\f[R], mac osx requires exactly+\f[C]fr_FR.UTF-8\f[R]).   .SH "REPORTING BUGS"
hledger.cabal view
@@ -1,13 +1,13 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.31.1.+-- This file has been generated from package.yaml by hpack version 0.31.2. -- -- see: https://github.com/sol/hpack ----- hash: 8134c3c5306064822b7909327946d48b3bcd3fec6dc432a27afb7665840d6201+-- hash: 9b996544825f06ba1fe409f012a89d17e383ca7d94353ac080c40937ba5ce3d5  name:           hledger-version:        1.14.2+version:        1.15 synopsis:       Command-line interface for the hledger accounting tool description:    This is hledger's command-line interface.                 Its basic function is to read a plain text file describing@@ -27,7 +27,7 @@ maintainer:     Simon Michael <simon@joyful.com> license:        GPL-3 license-file:   LICENSE-tested-with:    GHC==7.10.3, GHC==8.0.2, GHC==8.2.2, GHC==8.4.3, GHC==8.6.3+tested-with:    GHC==7.10.3, GHC==8.0.2, GHC==8.2.2, GHC==8.4.3, GHC==8.6.5 build-type:     Simple extra-source-files:     CHANGES.md@@ -72,10 +72,14 @@     Hledger/Cli/Commands/Checkdupes.txt     Hledger/Cli/Commands/Close.txt     Hledger/Cli/Commands/Commodities.txt+    Hledger/Cli/Commands/Descriptions.txt+    Hledger/Cli/Commands/Diff.txt     Hledger/Cli/Commands/Files.txt     Hledger/Cli/Commands/Help.txt     Hledger/Cli/Commands/Import.txt     Hledger/Cli/Commands/Incomestatement.txt+    Hledger/Cli/Commands/Notes.txt+    Hledger/Cli/Commands/Payees.txt     Hledger/Cli/Commands/Prices.txt     Hledger/Cli/Commands/Print.txt     Hledger/Cli/Commands/Printunique.txt@@ -121,10 +125,14 @@       Hledger.Cli.Commands.Checkdupes       Hledger.Cli.Commands.Close       Hledger.Cli.Commands.Commodities+      Hledger.Cli.Commands.Descriptions+      Hledger.Cli.Commands.Diff       Hledger.Cli.Commands.Help       Hledger.Cli.Commands.Files       Hledger.Cli.Commands.Import       Hledger.Cli.Commands.Incomestatement+      Hledger.Cli.Commands.Notes+      Hledger.Cli.Commands.Payees       Hledger.Cli.Commands.Prices       Hledger.Cli.Commands.Print       Hledger.Cli.Commands.Printunique@@ -138,7 +146,7 @@   other-modules:       Paths_hledger   ghc-options: -Wall -fno-warn-unused-do-bind -fno-warn-name-shadowing -fno-warn-missing-signatures -fno-warn-type-defaults -fno-warn-orphans -optP-Wno-nonportable-include-path-  cpp-options: -DVERSION="1.14.2"+  cpp-options: -DVERSION="1.15"   build-depends:       Decimal     , Diff@@ -151,10 +159,11 @@     , data-default >=0.5     , directory     , easytest >=0.2.1 && <0.3+    , extra >=1.6.3     , filepath     , hashable >=1.2.4     , haskeline >=0.6-    , hledger-lib >=1.14.1 && <1.15+    , hledger-lib >=1.15 && <1.16     , lucid     , math-functions >=0.2.0.0     , megaparsec >=7.0.0 && <8@@ -172,6 +181,7 @@     , temporary     , text >=0.11     , time >=1.5+    , timeit     , transformers     , unordered-containers     , utf8-string >=0.3.5@@ -189,7 +199,7 @@   hs-source-dirs:       app   ghc-options: -Wall -fno-warn-unused-do-bind -fno-warn-name-shadowing -fno-warn-missing-signatures -fno-warn-type-defaults -fno-warn-orphans -optP-Wno-nonportable-include-path-  cpp-options: -DVERSION="1.14.2"+  cpp-options: -DVERSION="1.15"   build-depends:       Decimal     , ansi-terminal >=0.6.2.3@@ -201,10 +211,11 @@     , data-default >=0.5     , directory     , easytest >=0.2.1 && <0.3+    , extra >=1.6.3     , filepath     , haskeline >=0.6     , hledger-    , hledger-lib >=1.14.1 && <1.15+    , hledger-lib >=1.15 && <1.16     , math-functions >=0.2.0.0     , megaparsec >=7.0.0 && <8     , mtl@@ -221,6 +232,7 @@     , temporary     , text >=0.11     , time >=1.5+    , timeit     , transformers     , unordered-containers     , utf8-string >=0.3.5@@ -241,7 +253,7 @@   hs-source-dirs:       test   ghc-options: -Wall -fno-warn-unused-do-bind -fno-warn-name-shadowing -fno-warn-missing-signatures -fno-warn-type-defaults -fno-warn-orphans -optP-Wno-nonportable-include-path-  cpp-options: -DVERSION="1.14.2"+  cpp-options: -DVERSION="1.15"   build-depends:       Decimal     , ansi-terminal >=0.6.2.3@@ -253,10 +265,11 @@     , data-default >=0.5     , directory     , easytest >=0.2.1 && <0.3+    , extra >=1.6.3     , filepath     , haskeline >=0.6     , hledger-    , hledger-lib >=1.14.1 && <1.15+    , hledger-lib >=1.15 && <1.16     , math-functions >=0.2.0.0     , megaparsec >=7.0.0 && <8     , mtl@@ -275,6 +288,7 @@     , test-framework-hunit     , text >=0.11     , time >=1.5+    , timeit     , transformers     , unordered-containers     , utf8-string >=0.3.5@@ -305,10 +319,11 @@     , data-default >=0.5     , directory     , easytest >=0.2.1 && <0.3+    , extra >=1.6.3     , filepath     , haskeline >=0.6     , hledger-    , hledger-lib >=1.14.1 && <1.15+    , hledger-lib >=1.15 && <1.16     , html     , math-functions >=0.2.0.0     , megaparsec >=7.0.0 && <8
hledger.info view
@@ -3,7 +3,7 @@  File: hledger.info,  Node: Top,  Next: EXAMPLES,  Up: (dir) -hledger(1) hledger 1.14+hledger(1) hledger 1.15 ***********************  This is hledger's command-line interface (there are also curses and web@@ -40,6 +40,7 @@ '~/.hledger.journal', or run 'hledger add' and follow the prompts.  Then try some commands like 'hledger print' or 'hledger balance'.  Run 'hledger' with no arguments for a list of commands.+ * Menu:  * EXAMPLES::@@ -129,9 +130,7 @@ * Period expressions:: * Depth limiting:: * Pivoting::-* Cost::-* Market value::-* Combining -B and -V::+* Valuation:: * Output destination:: * Output format:: * Regular expressions::@@ -208,7 +207,7 @@ '-p --period=PERIODEXP'       set start date, end date, and/or reporting interval all at once-     using period expressions syntax (overrides the flags above)+     using period expressions syntax '--date2'       match the secondary date instead (see command help for other@@ -303,6 +302,7 @@     'hledger register -p 'last year' "accounts receivable (receivable|payable)" amt:\>100'.+ * Menu:  * More escaping::@@ -393,25 +393,39 @@ 2.7 Unicode characters ====================== -hledger is expected to handle unicode (non-ascii) characters, but this-requires a well-configured environment.+hledger is expected to handle non-ascii characters correctly: -   To handle unicode characters in the command line or input data, a-system locale that can decode them must be configured (POSIX's default-'C' locale will not work).  Eg in bash, you could do:+   * they should be parsed correctly in input files and on the command+     line, by all hledger tools (add, iadd, hledger-web's+     search/add/edit forms, etc.) -export LANG=en_US.UTF-8+   * they should be displayed correctly by all hledger tools, and+     on-screen alignment should be preserved. -   See Troubleshooting for more about this.+   This requires a well-configured environment.  Here are some tips: -   Unicode characters should appear correctly in hledger's output.  For-the hledger and hledger-ui tools, this requires that+   * A system locale must be configured, and it must be one that can+     decode the characters being used.  In bash, you can set a locale+     like this: 'export LANG=en_US.UTF-8'.  There are some more details+     in Troubleshooting.  This step is essential - without it, hledger+     will quit on encountering a non-ascii character (as with all+     GHC-compiled programs). -   * your terminal supports unicode-   * the terminal's font includes the required unicode glyphs-   * the terminal is configured to display "wide" characters as double-     width (otherwise report alignment will be off)+   * your terminal software (eg Terminal.app, iTerm, CMD.exe, xterm..)+     must support unicode +   * the terminal must be using a font which includes the required+     unicode glyphs++   * the terminal should be configured to display wide characters as+     double width (for report alignment)++   * on Windows, for best results you should run hledger in the same+     kind of environment in which it was built.  Eg hledger built in the+     standard CMD.EXE environment (like the binaries on our download+     page) might show display problems when run in a cygwin or msys+     terminal, and vice versa.  (See eg #961).+  File: hledger.info,  Node: Input files,  Next: Smart dates,  Prev: Unicode characters,  Up: OPTIONS @@ -439,16 +453,16 @@ format automatically based on the file extension, or if that is not recognised, by trying each built-in "reader" in turn: -Reader:     Reads:                              Used for file extensions:------------------------------------------------------------------------------'journal'   hledger's journal format, also      '.journal' '.j'-            some Ledger journals                '.hledger' '.ledger'-'timeclock' timeclock files (precise time       '.timeclock'-            logging)-'timedot'   timedot files (approximate time     '.timedot'-            logging)-'csv'       comma-separated values (data        '.csv'-            interchange)+Reader:  Reads:                           Used for file extensions:+---------------------------------------------------------------------------+'journal'hledger's journal format, also   '.journal' '.j' '.hledger'+         some Ledger journals             '.ledger'+'timeclock'timeclock files (precise time  '.timeclock'+         logging)+'timedot'timedot files (approximate       '.timedot'+         time logging)+'csv'    comma-separated values (data     '.csv'+         interchange)     If needed (eg to ensure correct error messages when a file has the "wrong" extension), you can force a specific reader/format by prepending@@ -514,10 +528,19 @@    Often you will want to see a shorter time span, such as the current month.  You can specify a start and/or end date using '-b/--begin', '-e/--end', '-p/--period' or a 'date:' query (described below).  All of-these accept the smart date syntax.  One important thing to be aware of-when specifying end dates: as in Ledger, end dates are exclusive, so you-need to write the date _after_ the last day you want to include.+these accept the smart date syntax. +   Some notes:++   * As in Ledger, end dates are exclusive, so you need to write the+     date _after_ the last day you want to include.+   * As noted in reporting options: among start/end dates specified with+     _options_, the last (i.e.  right-most) option takes precedence.+   * The effective report start and end dates are the intersection of+     the start/end dates from options and that from 'date:' queries.+     That is, 'date:2019-01 date:2019 -p'2000 to 2030'' yields January+     2019, the smallest common time span.+    Examples:  '-b 2016/3/17'      begin on St.  Patrick's day 2016@@ -540,7 +563,7 @@ The basic intervals can be selected with one of '-D/--daily', '-W/--weekly', '-M/--monthly', '-Q/--quarterly', or '-Y/--yearly'.  More complex intervals may be specified with a period expression.  Report-intervals can not be specified with a query, currently.+intervals can not be specified with a query.   File: hledger.info,  Node: Period expressions,  Next: Depth limiting,  Prev: Report intervals,  Up: OPTIONS@@ -663,7 +686,7 @@ (so '-2', '--depth=2' or 'depth:2' are basically equivalent).  -File: hledger.info,  Node: Pivoting,  Next: Cost,  Prev: Depth limiting,  Up: OPTIONS+File: hledger.info,  Node: Pivoting,  Next: Valuation,  Prev: Depth limiting,  Up: OPTIONS  2.14 Pivoting =============@@ -720,32 +743,55 @@               -2 EUR  -File: hledger.info,  Node: Cost,  Next: Market value,  Prev: Pivoting,  Up: OPTIONS+File: hledger.info,  Node: Valuation,  Next: Output destination,  Prev: Pivoting,  Up: OPTIONS -2.15 Cost-=========+2.15 Valuation+============== -The '-B/--cost' flag converts amounts to their cost at transaction time,-if they have a transaction price specified.+* Menu: +* -B Cost::+* -V Market value::+* -X Market value in specified commodity::+* --value::+* Combining -B -V -X --value::+ -File: hledger.info,  Node: Market value,  Next: Combining -B and -V,  Prev: Cost,  Up: OPTIONS+File: hledger.info,  Node: -B Cost,  Next: -V Market value,  Up: Valuation -2.16 Market value-=================+2.15.1 -B: Cost+--------------- -The '-V/--value' flag converts reported amounts to their current market-value.-Specifically, when there is a market price (P directive) for the-amount's commodity, dated on or before today's date (or the report end-date if specified), the amount will be converted to the price's-commodity.+The '-B/--cost' flag converts amounts to their cost (or selling price)+at transaction time, if they have a transaction price specified.  This+flag is equivalent to '--value=cost', described below. -   When there are multiple applicable P directives, -V chooses the most-recent one, or in case of equal dates, the last-parsed one.++File: hledger.info,  Node: -V Market value,  Next: -X Market value in specified commodity,  Prev: -B Cost,  Up: Valuation -   For example:+2.15.2 -V: Market value+----------------------- +The '-V/--market' flag converts reported amounts to their market value+in a default valuation commodity, using the historical market prices in+effect on a default valuation date.++   For single period reports, the valuation date is today.  For+multiperiod reports, it is the last day of each subperiod.++   The valuation commodity will be the one referenced in the latest+applicable market price dated on or before the valuation date.  If most+of your P declarations lead to a single home currency, this will usually+be what you want.++   Unlike the similar flag in Ledger, it does not infer market prices+from transaction prices.  In hledger, -B uses transaction prices, -V and+-X use market prices.++   It is equivalent to '--value=now' or '--value=end'.++   Here's a quick example:+ # one euro is worth this many dollars from nov 1 P 2016/11/01 € $1.10 @@ -773,27 +819,275 @@ $ hledger -f t.j bal -N euros -V              $103.00  assets:euros -   Currently, hledger's -V only uses market prices recorded with P-directives, not transaction prices (unlike Ledger).++File: hledger.info,  Node: -X Market value in specified commodity,  Next: --value,  Prev: -V Market value,  Up: Valuation -   Currently, -V has a limitation in multicolumn balance reports: it-uses the market prices on the report end date for all columns.  (Instead-of the prices on each column's end date.)+2.15.3 -X: Market value in specified commodity+---------------------------------------------- +The '-X/--exchange' option is like '-V/--market' except it takes a+commodity symbol argument, so that you can select a different target+commodity.  It is similar to the same option in Ledger, with the same+caveat mentioned for '-V'/'--value' above.  It is equivalent to+'--value=now,COMM' or '--value=end,COMM'; for more details, read on.+ -File: hledger.info,  Node: Combining -B and -V,  Next: Output destination,  Prev: Market value,  Up: OPTIONS+File: hledger.info,  Node: --value,  Next: Combining -B -V -X --value,  Prev: -X Market value in specified commodity,  Up: Valuation -2.17 Combining -B and -V-========================+2.15.4 -value+------------- -Using -B/-cost and -V/-value together is currently allowed, but the-results are probably not meaningful.  Let us know if you find a use for-this.+_(experimental, added 201905)_ +   '-B', '-V' and '-X' are special cases of the more general '--value'+option:++ --value=TYPE[,COMM]  TYPE is cost, end, now or YYYY-MM-DD.+                      COMM is an optional commodity symbol.+                      Shows amounts converted to:+                      - cost commodity using transaction prices (then optionally to COMM using market prices at period end(s))+                      - default valuation commodity (or COMM) using market prices at period end(s)+                      - default valuation commodity (or COMM) using current market prices+                      - default valuation commodity (or COMM) using market prices at some date++* Menu:++* Valuation type::+* Valuation commodity::+* --value examples::+* Effect of --value on reports::+ -File: hledger.info,  Node: Output destination,  Next: Output format,  Prev: Combining -B and -V,  Up: OPTIONS+File: hledger.info,  Node: Valuation type,  Next: Valuation commodity,  Up: --value -2.18 Output destination+2.15.4.1 Valuation type+.......................++TYPE is one of these keywords, or their first letter, or a date (which+must be 8 digits with '-' or '/' or '.' separators):++'--value=cost'++     Convert amounts to cost, using the prices recorded in transactions.+     '-B'/'--cost' is equivalent to this.+'--value=end'++     Convert amounts to their value in default valuation commodity using+     market prices on the last day of the report period (or of each+     subperiod in a multiperiod report).  When no report period is+     specified, uses the journal's last transaction date.+'--value=now'++     Convert amounts to their value in default valuation commodity using+     current market prices (as of when report is generated).+     '-V'/'--market' is equivalent to this.+'--value=YYYY-MM-DD'++     Convert amounts to their value in default valuation commodity using+     market prices on this date.  Eg '--value=2019-04-25'.+++File: hledger.info,  Node: Valuation commodity,  Next: --value examples,  Prev: Valuation type,  Up: --value++2.15.4.2 Valuation commodity+............................++The default valuation commodity is the commodity mentioned in the most+recent applicable market price declaration.  When all your price+declarations lead to a single home currency, this will usually do what+you want.++   To select a different valuation commodity: write the commodity symbol+after the valuation type, separated by a comma (eg:+*'--value=now,EUR'*).  This will use, in this preferred order:++   * declared prices (from source commodity to valuation commodity)+   * reverse prices (declared prices from valuation to source commodity,+     inverted)+   * indirect prices (prices calculated from the shortest chain of+     declared or reverse prices from source to valuation commodity).+++File: hledger.info,  Node: --value examples,  Next: Effect of --value on reports,  Prev: Valuation commodity,  Up: --value++2.15.4.3 -value examples+........................++Here are the effects of '--value' as seen with 'print':++P 2000-01-01 A  1 B+P 2000-02-01 A  2 B+P 2000-03-01 A  3 B+P 2000-04-01 A  4 B++2000-01-01+  (a)      1 A @ 5 B++2000-02-01+  (a)      1 A @ 6 B++2000-03-01+  (a)      1 A @ 7 B++   Show the cost of each posting:++$ hledger -f- print --value=cost+2000/01/01+    (a)             5 B++2000/02/01+    (a)             6 B++2000/03/01+    (a)             7 B++   Show the value as of the last day of the report period (2000-02-29):++$ hledger -f- print --value=end date:2000/01-2000/03+2000-01-01+    (a)             2 B++2000-02-01+    (a)             2 B++   With no report period specified, that shows the value as of the last+day of the journal (2000-03-01):++$ hledger -f- print --value=end+2000/01/01+    (a)             3 B++2000/02/01+    (a)             3 B++2000/03/01+    (a)             3 B++   Show the current value (the 2000-04-01 price is still in effect+today):++$ hledger -f- print --value=now+2000-01-01+    (a)             4 B++2000-02-01+    (a)             4 B++2000-03-01+    (a)             4 B++   Show the value on 2000/01/15:++$ hledger -f- print --value=2000-01-15+2000/01/01+    (a)             1 B++2000/02/01+    (a)             1 B++2000/03/01+    (a)             1 B++   You may need to explicitly set a commodity's display style, when+reverse prices are used.  Eg this output might be surprising:++P 2000-01-01 A 2B++2000-01-01+  a  1B+  b++$ hledger print -x -X A+2000/01/01+    a               0+    b               0++   Explanation: because there's no amount or commodity directive+specifying a display style for A, 0.5A gets the default style, which+shows no decimal digits.  Because the displayed amount looks like zero,+the commodity symbol and minus sign are not displayed either.  Adding a+commodity directive sets a more useful display style for A:++P 2000-01-01 A 2B+commodity 0.00A++2000-01-01+  a  1B+  b++$ hledger print -X A+2000/01/01+    a           0.50A+    b          -0.50A+++File: hledger.info,  Node: Effect of --value on reports,  Prev: --value examples,  Up: --value++2.15.4.4 Effect of -value on reports+....................................++Below is how '--value' affects each of hledger's reports, currently.+You're not expected to remember all this, but when troubleshooting a+report, look here.  If you find problems - useless reports, misbehaving+reports, or error messages being printed - please report them (with+reproducible examples) eg at #329.++Report type   '--value'      '--value' 'end'            '--value'+              'cost'                                    'DATE'/'now' +----------------------------------------------------------------------------+*print*+posting       cost, as       market value at report     market value at+amounts       recorded in    end                        DATE+              transaction+balance       show           show unvalued              show unvalued+assertions/assignmentsunvalued+*register*+starting      cost of        market value at day        market value at+balance       starting       before report start        DATE+with -H       balance+posting       cost           market value at report     market value at+amounts                      end                        DATE+posting       summarised     market value each          market value each+amounts,      cost           summary posting at         summary posting+multiperiod                  period end                 at DATE+running       sum/average    sum/average of the         sum/average of+total/average of the         displayed values           the displayed+              displayed                                 values+              values+*balance+(bs, cf,+is..)*+starting      costs of       market value at day        market value at+balances      starting       before report start of     DATE of sum of+with -H       balances       sum of previous postings   previous postings+balances,     summed costs   market value at period     market value at+simple                       end of sum of postings     DATE of sum of+balance                                                 postings+report+balances,     summed costs   market value at period     market value at+multiperiod                  end of sum of postings     DATE of sum of+report                                                  postings+budget        costs of       budget-setting periodic    budget-setting+amounts       budget         txns are valued at         periodic txns are+with          amounts        period end                 valued at DATE+-budget+column/row/grandsum/average  market value at period     market value at+totals/averagesof the        end of sum/average of      DATE of+              displayed      postings                   sum/average of+              values                                    postings+++File: hledger.info,  Node: Combining -B -V -X --value,  Prev: --value,  Up: Valuation++2.15.5 Combining -B, -V, -X, -value+-----------------------------------++The rightmost of these flags wins.+++File: hledger.info,  Node: Output destination,  Next: Output format,  Prev: Valuation,  Up: OPTIONS++2.16 Output destination =======================  Some commands (print, register, stats, the balance commands) can write@@ -806,7 +1100,7 @@  File: hledger.info,  Node: Output format,  Next: Regular expressions,  Prev: Output destination,  Up: OPTIONS -2.19 Output format+2.17 Output format ==================  Some commands can write their output in other formats.  Eg print and@@ -820,7 +1114,7 @@  File: hledger.info,  Node: Regular expressions,  Prev: Output format,  Up: OPTIONS -2.20 Regular expressions+2.18 Regular expressions ========================  hledger uses regular expressions in a number of places:@@ -987,6 +1281,7 @@    Here are all the builtin commands in alphabetical order.  See also 'hledger' for a more organised command list, and 'hledger CMD -h' for detailed command help.+ * Menu:  * accounts::@@ -1132,6 +1427,10 @@ Starting the next transaction (. or ctrl-D/ctrl-C to quit) Date [2015/05/22]: <CTRL-D> $ +   On Microsoft Windows, the add command makes sure that no part of the+file path ends with a period, as it can cause data loss on that platform+(cf #1056).+  File: hledger.info,  Node: balance,  Next: balancesheet,  Prev: add,  Up: COMMANDS @@ -1162,6 +1461,7 @@ is used to ensure this (more below).     The balance command can produce several styles of report:+ * Menu:  * Classic balance report::@@ -1250,7 +1550,9 @@    '%[MIN][.MAX](FIELDNAME)'     * MIN pads with spaces to at least this width (optional)+    * MAX truncates at this width (optional)+    * FIELDNAME must be enclosed in parentheses, and can be one of:          * 'depth_spacer' - a number of spaces equal to the account's@@ -1390,6 +1692,10 @@      ----------------------++-------------------------------------                            ||           0           0           0  +   Note that '--cumulative' or '--historical/-H' disable+'--row-total/-T', since summing end balances generally does not make+sense.+    Multicolumn balance reports display accounts in flat mode by default; to see the hierarchy, use '--tree'. @@ -1557,6 +1863,7 @@                       ||      0 [              0]       0 [              0]      For more examples, see Budgeting and Forecasting.+ * Menu:  * Nested budgets::@@ -1696,7 +2003,9 @@ each report period.  As with multicolumn balance reports, you can alter the report mode with '--change'/'--cumulative'/'--historical'.  Normally balancesheet shows historical ending balances, which is what you need-for a balance sheet; note this means it ignores report begin dates.+for a balance sheet; note this means it ignores report begin dates (and+'-T/--row-total', since summing end balances generally does not make+sense).     This command also supports output destination and output format selection.@@ -1815,7 +2124,7 @@     The closing transaction transfers balances to "equity:closing balances".  The opening transaction transfers balances from-"equity:opening balances".  You can chose to print just one of the+"equity:opening balances".  You can choose to print just one of the transactions by using the '--opening' or '--closing' flag.     If you split your journal files by time (eg yearly), you will@@ -1849,6 +2158,10 @@ this command with -auto, the balance assertions will probably always require -auto. +   When account balances have cost information (transaction prices), the+closing/opening transactions will preserve it, so that eg balance -B+reports will not be affected.+    Examples:     Carrying asset/liability balances into a new file for 2019, all from@@ -1959,7 +2272,30 @@  $ hledger import --dry ... | hledger -f- print unknown --ignore-assertions +* Menu:++* Importing balance assignments::+ +File: hledger.info,  Node: Importing balance assignments,  Up: import++4.13.1 Importing balance assignments+------------------------------------++Entries added by import will have their posting amounts made explicit+(like 'hledger print -x').  This means that any balance assignments in+imported files must be evaluated; but, imported files don't get to see+the main file's account balances.  As a result, importing entries with+balance assignments (eg from an institution that provides only balances+and not posting amounts) will probably generate incorrect posting+amounts.  To avoid this problem, use print instead of import:++$ hledger print IMPORTFILE [--new] >> $LEDGER_FILE++   (If you think import should leave amounts implicit like print does,+please test it and send a pull request.)++ File: hledger.info,  Node: incomestatement,  Next: prices,  Prev: import,  Up: COMMANDS  4.14 incomestatement@@ -2225,6 +2561,7 @@ these will be adjusted outward if necessary to contain a whole number of intervals.  This ensures that the first and last intervals are full length and comparable to the others in the report.+ * Menu:  * Custom register output::@@ -2292,9 +2629,9 @@     Examples: -hledger-rewrite.hs ^income --add-posting '(liabilities:tax)  *.33  ; income tax' --add-posting '(reserve:gifts)  $100'-hledger-rewrite.hs expenses:gifts --add-posting '(reserve:gifts)  *-1"'-hledger-rewrite.hs -f rewrites.hledger+$ hledger-rewrite.hs ^income --add-posting '(liabilities:tax)  *.33  ; income tax' --add-posting '(reserve:gifts)  $100'+$ hledger-rewrite.hs expenses:gifts --add-posting '(reserve:gifts)  *-1"'+$ hledger-rewrite.hs -f rewrites.hledger     rewrites.hledger may consist of entries like: @@ -2483,6 +2820,7 @@ Payees/descriptions      : 5 Accounts                 : 8 (depth 3) Commodities              : 1 ($)+Market prices            : 12 ($)     This command also supports output destination and output format selection.@@ -2497,7 +2835,8 @@ List all the tag names used in the journal.  With a TAGREGEX argument, only tag names matching the regular expression (case insensitive) are shown.  With QUERY arguments, only transactions matching the query are-considered.+considered.  With -values flag, the tags' unique values are listed+instead.   File: hledger.info,  Node: test,  Prev: tags,  Up: COMMANDS@@ -2557,6 +2896,7 @@ options, journal parsing, reporting, etc.     Here are some hledger add-ons available:+ * Menu:  * Official add-ons::@@ -2570,6 +2910,7 @@ ====================  These are maintained and released along with hledger.+ * Menu:  * api::@@ -2608,6 +2949,7 @@  These are maintained separately, and usually updated shortly after a hledger release.+ * Menu:  * diff::@@ -2661,6 +3003,7 @@ installing them is pretty easy.  They may be less mature and documented than built-in commands.  Reading and tweaking these is a good way to start making your own!+ * Menu:  * autosync::@@ -2697,160 +3040,176 @@  Tag Table: Node: Top68-Node: EXAMPLES1884-Ref: #examples1984-Node: OPTIONS3630-Ref: #options3732-Node: General options4167-Ref: #general-options4292-Node: Command options6974-Ref: #command-options7125-Node: Command arguments7523-Ref: #command-arguments7677-Node: Argument files7798-Ref: #argument-files7974-Node: Special characters in arguments and queries8240-Ref: #special-characters-in-arguments-and-queries8474-Node: More escaping8924-Ref: #more-escaping9086-Node: Even more escaping9382-Ref: #even-more-escaping9576-Node: Less escaping10247-Ref: #less-escaping10409-Node: Command line tips10654-Ref: #command-line-tips10840-Node: Unicode characters11217-Ref: #unicode-characters11373-Node: Input files12098-Ref: #input-files12234-Node: Smart dates14204-Ref: #smart-dates14345-Node: Report start & end date15751-Ref: #report-start-end-date15923-Node: Report intervals16989-Ref: #report-intervals17154-Node: Period expressions17555-Ref: #period-expressions17715-Node: Depth limiting21672-Ref: #depth-limiting21816-Node: Pivoting22158-Ref: #pivoting22276-Node: Cost23952-Ref: #cost24060-Node: Market value24178-Ref: #market-value24313-Node: Combining -B and -V25679-Ref: #combining--b-and--v25842-Node: Output destination25989-Ref: #output-destination26151-Node: Output format26434-Ref: #output-format26586-Node: Regular expressions26971-Ref: #regular-expressions27108-Node: QUERIES28469-Ref: #queries28571-Node: COMMANDS32533-Ref: #commands32645-Node: accounts33645-Ref: #accounts33743-Node: activity34442-Ref: #activity34552-Node: add34935-Ref: #add35034-Node: balance37621-Ref: #balance37732-Node: Classic balance report39173-Ref: #classic-balance-report39346-Node: Customising the classic balance report40715-Ref: #customising-the-classic-balance-report40943-Node: Colour support43017-Ref: #colour-support43184-Node: Flat mode43357-Ref: #flat-mode43505-Node: Depth limited balance reports43918-Ref: #depth-limited-balance-reports44118-Node: Multicolumn balance report44574-Ref: #multicolumn-balance-report44772-Node: Budget report49952-Ref: #budget-report50095-Node: Nested budgets55296-Ref: #nested-budgets55408-Ref: #output-format-158888-Node: balancesheet58966-Ref: #balancesheet59102-Node: balancesheetequity60336-Ref: #balancesheetequity60485-Node: cashflow61046-Ref: #cashflow61174-Node: check-dates62202-Ref: #check-dates62329-Node: check-dupes62608-Ref: #check-dupes62732-Node: close63025-Ref: #close63133-Node: files66546-Ref: #files66647-Node: help66794-Ref: #help66894-Node: import67987-Ref: #import68101-Node: incomestatement68845-Ref: #incomestatement68979-Node: prices70315-Ref: #prices70430-Node: print70709-Ref: #print70819-Node: print-unique75312-Ref: #print-unique75438-Node: register75723-Ref: #register75850-Node: Custom register output80021-Ref: #custom-register-output80150-Node: register-match81412-Ref: #register-match81546-Node: rewrite81897-Ref: #rewrite82012-Node: Re-write rules in a file83861-Ref: #re-write-rules-in-a-file83995-Node: Diff output format85205-Ref: #diff-output-format85374-Node: rewrite vs print --auto86466-Ref: #rewrite-vs.-print---auto86645-Node: roi87201-Ref: #roi87299-Node: stats88311-Ref: #stats88410-Node: tags89164-Ref: #tags89262-Node: test89492-Ref: #test89576-Node: ADD-ON COMMANDS90337-Ref: #add-on-commands90447-Node: Official add-ons91734-Ref: #official-add-ons91874-Node: api91961-Ref: #api92050-Node: ui92102-Ref: #ui92201-Node: web92259-Ref: #web92348-Node: Third party add-ons92394-Ref: #third-party-add-ons92569-Node: diff92704-Ref: #diff92801-Node: iadd92900-Ref: #iadd93014-Node: interest93097-Ref: #interest93218-Node: irr93313-Ref: #irr93411-Node: Experimental add-ons93542-Ref: #experimental-add-ons93694-Node: autosync93974-Ref: #autosync94085-Node: chart94324-Ref: #chart94443-Node: check94514-Ref: #check94616+Node: EXAMPLES1885+Ref: #examples1985+Node: OPTIONS3631+Ref: #options3733+Node: General options4132+Ref: #general-options4257+Node: Command options6911+Ref: #command-options7062+Node: Command arguments7460+Ref: #command-arguments7614+Node: Argument files7735+Ref: #argument-files7911+Node: Special characters in arguments and queries8177+Ref: #special-characters-in-arguments-and-queries8411+Node: More escaping8862+Ref: #more-escaping9024+Node: Even more escaping9320+Ref: #even-more-escaping9514+Node: Less escaping10185+Ref: #less-escaping10347+Node: Command line tips10592+Ref: #command-line-tips10778+Node: Unicode characters11155+Ref: #unicode-characters11311+Node: Input files12723+Ref: #input-files12859+Node: Smart dates14788+Ref: #smart-dates14929+Node: Report start & end date16335+Ref: #report-start-end-date16507+Node: Report intervals17931+Ref: #report-intervals18096+Node: Period expressions18486+Ref: #period-expressions18646+Node: Depth limiting22603+Ref: #depth-limiting22747+Node: Pivoting23089+Ref: #pivoting23212+Node: Valuation24888+Ref: #valuation25017+Node: -B Cost25145+Ref: #b-cost25256+Node: -V Market value25454+Ref: #v-market-value25628+Node: -X Market value in specified commodity27034+Ref: #x-market-value-in-specified-commodity27254+Node: --value27594+Ref: #value27759+Node: Valuation type28560+Ref: #valuation-type28696+Node: Valuation commodity29581+Ref: #valuation-commodity29752+Node: --value examples30452+Ref: #value-examples30629+Node: Effect of --value on reports32612+Ref: #effect-of---value-on-reports32785+Node: Combining -B -V -X --value35476+Ref: #combining--b--v--x---value35638+Node: Output destination35674+Ref: #output-destination35826+Node: Output format36109+Ref: #output-format36261+Node: Regular expressions36646+Ref: #regular-expressions36783+Node: QUERIES38144+Ref: #queries38246+Node: COMMANDS42208+Ref: #commands42320+Node: accounts43321+Ref: #accounts43419+Node: activity44118+Ref: #activity44228+Node: add44611+Ref: #add44710+Node: balance47455+Ref: #balance47566+Node: Classic balance report49008+Ref: #classic-balance-report49181+Node: Customising the classic balance report50550+Ref: #customising-the-classic-balance-report50778+Node: Colour support52854+Ref: #colour-support53021+Node: Flat mode53194+Ref: #flat-mode53342+Node: Depth limited balance reports53755+Ref: #depth-limited-balance-reports53955+Node: Multicolumn balance report54411+Ref: #multicolumn-balance-report54609+Node: Budget report59923+Ref: #budget-report60066+Node: Nested budgets65268+Ref: #nested-budgets65380+Ref: #output-format-168860+Node: balancesheet68938+Ref: #balancesheet69074+Node: balancesheetequity70389+Ref: #balancesheetequity70538+Node: cashflow71099+Ref: #cashflow71227+Node: check-dates72255+Ref: #check-dates72382+Node: check-dupes72661+Ref: #check-dupes72785+Node: close73078+Ref: #close73186+Node: files76773+Ref: #files76874+Node: help77021+Ref: #help77121+Node: import78214+Ref: #import78328+Node: Importing balance assignments79116+Ref: #importing-balance-assignments79264+Node: incomestatement79913+Ref: #incomestatement80047+Node: prices81383+Ref: #prices81498+Node: print81777+Ref: #print81887+Node: print-unique86380+Ref: #print-unique86506+Node: register86791+Ref: #register86918+Node: Custom register output91090+Ref: #custom-register-output91219+Node: register-match92481+Ref: #register-match92615+Node: rewrite92966+Ref: #rewrite93081+Node: Re-write rules in a file94936+Ref: #re-write-rules-in-a-file95070+Node: Diff output format96280+Ref: #diff-output-format96449+Node: rewrite vs print --auto97541+Ref: #rewrite-vs.-print---auto97720+Node: roi98276+Ref: #roi98374+Node: stats99386+Ref: #stats99485+Node: tags100273+Ref: #tags100371+Node: test100665+Ref: #test100749+Node: ADD-ON COMMANDS101510+Ref: #add-on-commands101620+Node: Official add-ons102908+Ref: #official-add-ons103048+Node: api103136+Ref: #api103225+Node: ui103277+Ref: #ui103376+Node: web103434+Ref: #web103523+Node: Third party add-ons103569+Ref: #third-party-add-ons103744+Node: diff103880+Ref: #diff103977+Node: iadd104076+Ref: #iadd104190+Node: interest104273+Ref: #interest104394+Node: irr104489+Ref: #irr104587+Node: Experimental add-ons104718+Ref: #experimental-add-ons104870+Node: autosync105151+Ref: #autosync105262+Node: chart105501+Ref: #chart105620+Node: check105691+Ref: #check105793  End Tag Table
hledger.txt view
@@ -173,7 +173,7 @@         -p --period=PERIODEXP               set  start date, end date, and/or reporting interval all at once-              using period expressions syntax (overrides the flags above)+              using period expressions syntax         --date2               match the secondary date instead (see  command  help  for  other@@ -244,7 +244,7 @@        shell such as <, >, (, ), | and $, should be escaped by enclosing  them        in quotes or by writing backslashes before the characters.  Eg: -       hledger register -p 'last year' "accounts receivable (receiv-+       hledger   register   -p   'last  year'  "accounts  receivable  (receiv-        able|payable)" amt:\>100.     More escaping@@ -310,27 +310,39 @@        to troubleshoot.     Unicode characters-       hledger is expected to handle unicode (non-ascii) characters, but  this-       requires a well-configured environment.+       hledger is expected to handle non-ascii characters correctly: -       To  handle unicode characters in the command line or input data, a sys--       tem locale that can decode them must be configured (POSIX's  default  C-       locale will not work).  Eg in bash, you could do:+       o they should be parsed correctly in input files  and  on  the  command+         line,  by all hledger tools (add, iadd, hledger-web's search/add/edit+         forms, etc.) -              export LANG=en_US.UTF-8+       o they should be displayed correctly by  all  hledger  tools,  and  on-+         screen alignment should be preserved. -       See Troubleshooting for more about this.+       This requires a well-configured environment.  Here are some tips: -       Unicode  characters  should  appear correctly in hledger's output.  For-       the hledger and hledger-ui tools, this requires that+       o A  system  locale  must  be  configured,  and it must be one that can+         decode the characters being used.  In bash, you can set a locale like+         this:  export LANG=en_US.UTF-8.  There are some more details in Trou-+         bleshooting.  This step is essential - without it, hledger will  quit+         on  encountering a non-ascii character (as with all GHC-compiled pro-+         grams). -       o your terminal supports unicode+       o your terminal software (eg  Terminal.app,  iTerm,  CMD.exe,  xterm..)+         must support unicode -       o the terminal's font includes the required unicode glyphs+       o the terminal must be using a font which includes the required unicode+         glyphs -       o the terminal is configured to display  "wide"  characters  as  double-         width (otherwise report alignment will be off)+       o the terminal should be configured to display wide characters as  dou-+         ble width (for report alignment) +       o on  Windows, for best results you should run hledger in the same kind+         of environment in which it was built.  Eg hledger built in the  stan-+         dard  CMD.EXE  environment  (like  the binaries on our download page)+         might show display problems when run in a cygwin  or  msys  terminal,+         and vice versa.  (See eg #961).+    Input files        hledger reads transactions from a data file (and the add command writes        to it).  By default this file is $HOME/.hledger.journal (or on Windows,@@ -354,16 +366,16 @@        recognised, by trying each built-in "reader" in turn:  -       Reader:      Reads:                               Used for file extensions:+       Reader:    Reads:                            Used for file extensions:        ------------------------------------------------------------------------------       journal      hledger's  journal  format,  also    .journal    .j    .hledger-                    some Ledger journals                 .ledger-       timeclock    timeclock   files  (precise  time    .timeclock-                    logging)-       timedot      timedot files  (approximate  time    .timedot-                    logging)-       csv          comma-separated    values   (data    .csv-                    interchange)+       journal    hledger's  journal format, also   .journal .j .hledger .ledger+                  some Ledger journals+       time-      timeclock  files  (precise time   .timeclock+       clock      logging)+       timedot    timedot files (approximate time   .timedot+                  logging)+       csv        comma-separated   values  (data   .csv+                  interchange)         If needed (eg to ensure correct error messages  when  a  file  has  the        "wrong"  extension), you can force a specific reader/format by prepend-@@ -392,55 +404,66 @@        Examples:  -       2004/10/1,     2004-01-01,            exact  date, several sepa--       2004.9.1                              rators allowed.   Year  is-                                             4+  digits, month is 1-12,-                                             day is 1-31-       2004                                  start of year--       2004/10                               start of month-       10/1                                  month and day  in  current-                                             year-       21                                    day in current month-       october, oct                          start  of month in current-                                             year-       yesterday, today, tomorrow            -1, 0, 1 days from today-       last/this/next day/week/month/quar-   -1, 0, 1 periods from  the-       ter/year                              current period-       20181201                              8   digit   YYYYMMDD  with-                                             valid year month and day-       201812                                6 digit YYYYMM with  valid-                                             year and month+       2004/10/1,     2004-01-01,   exact  date, several sepa-+       2004.9.1                     rators allowed.   Year  is+                                    4+  digits, month is 1-12,+                                    day is 1-31+       2004                         start of year+       2004/10                      start of month+       10/1                         month and day  in  current+                                    year+       21                           day in current month+       october, oct                 start  of month in current+                                    year+       yesterday, today, tomorrow   -1, 0, 1 days from today+       last/this/next               -1,  0, 1 periods from the+       day/week/month/quar-         current period+       ter/year+       20181201                     8  digit   YYYYMMDD   with+                                    valid year month and day+       201812                       6  digit YYYYMM with valid+                                    year and month -       Counterexamples  -  malformed  digit  sequences  might  give surprising+       Counterexamples -  malformed  digit  sequences  might  give  surprising        results:  -       201813      6 digits with  an  invalid-                   month  is  parsed as start+       201813      6  digits  with an invalid+                   month is parsed  as  start                    of 6-digit year-       20181301    8 digits with  an  invalid-                   month  is  parsed as start+       20181301    8  digits  with an invalid+                   month is parsed  as  start                    of 8-digit year-       20181232    8 digits with  an  invalid+       20181232    8  digits  with an invalid                    day gives an error        201801012   9+ digits beginning with a                    valid  YYYYMMDD  gives  an                    error     Report start & end date-       Most  hledger  reports  show  the  full span of time represented by the+       Most hledger reports show the full span  of  time  represented  by  the        journal data, by default.  So, the effective report start and end dates-       will  be  the earliest and latest transaction or posting dates found in+       will be the earliest and latest transaction or posting dates  found  in        the journal. -       Often you will want to see a shorter time span,  such  as  the  current-       month.   You  can  specify  a  start  and/or end date using -b/--begin,+       Often  you  will  want  to see a shorter time span, such as the current+       month.  You can specify a  start  and/or  end  date  using  -b/--begin,        -e/--end, -p/--period or a date: query (described below).  All of these-       accept  the smart date syntax.  One important thing to be aware of when-       specifying end dates: as in Ledger, end dates  are  exclusive,  so  you-       need to write the date after the last day you want to include.+       accept the smart date syntax. +       Some notes:++       o As in Ledger, end dates are exclusive, so you need to write the  date+         after the last day you want to include.++       o As  noted  in reporting options: among start/end dates specified with+         options, the last (i.e.  right-most) option takes precedence.++       o The effective report start and end dates are the intersection of  the+         start/end  dates  from options and that from date: queries.  That is,+         date:2019-01 date:2019 -p'2000 to  2030'  yields  January  2019,  the+         smallest common time span.+        Examples:  @@ -467,7 +490,7 @@        The   basic   intervals   can  be  selected  with  one  of  -D/--daily,        -W/--weekly, -M/--monthly, -Q/--quarterly, or -Y/--yearly.   More  com-        plex  intervals  may  be  specified  with  a period expression.  Report-       intervals can not be specified with a query, currently.+       intervals can not be specified with a query.     Period expressions        The -p/--period option accepts period expressions, a shorthand  way  of@@ -538,44 +561,43 @@        For example:  -       -p "weekly from 2009/1/1 to 2009/4/1"+       -p "weekly from 2009/1/1  to  2009/4/1"        --  starts  on 2008/12/29, closest pre-        ceeding Monday        -p "monthly in 2008/11/25" -- starts on        2018/11/01-       -p "quar--       terly from 2009-05-05 to 2009-06-01"  --       starts    on    2009/04/01,   ends   on-       2009/06/30, which are  first  and  last-       days of Q2 2009+       -p   "quarterly   from   2009-05-05  to+       2009-06-01"  -  starts  on  2009/04/01,+       ends on 2009/06/30, which are first and+       last days of Q2 2009        -p "yearly from 2009-12-29" - starts on        2009/01/01, first day of 2009         The  following  more  complex  report  intervals  are  also  supported:-       biweekly,         bimonthly,         every day|week|month|quarter|year,-       every N days|weeks|months|quarters|years.+       biweekly,  bimonthly,  every   day|week|month|quarter|year,   every   N+       days|weeks|months|quarters|years. -       All of these will start on the first day of the  requested  period  and+       All  of  these  will start on the first day of the requested period and        end on the last one, as described above.         Examples:  -       -p "bimonthly from 2008"   --   periods+       -p "bimonthly  from  2008"  --  periods        will  have  boundaries  on  2008/01/01,        2008/03/01, ...        -p "every 2 weeks" -- starts on closest        preceeding Monday-       -p "every 5 month from 2009/03"      --+       -p  "every  5  month  from  2009/03" --        periods   will   have   boundaries   on        2009/03/01, 2009/08/01, ... -       If you want intervals that start on arbitrary day of your choosing  and+       If  you want intervals that start on arbitrary day of your choosing and        span a week, month or year, you need to use any of the following: -       every Nth day of week,    every <weekday>,    every Nth day [of month],-       every Nth weekday [of month],                    every MM/DD [of year],-       every Nth MMM [of year], every MMM Nth [of year].+       every Nth day of week, every <weekday>, every Nth day [of month], every+       Nth weekday [of month], every MM/DD [of year], every Nth MMM [of year],+       every MMM Nth [of year].         Examples: @@ -583,44 +605,44 @@        -p "every 2nd day of week"  --  periods        will go from Tue to Tue        -p "every Tue" -- same-       -p "every 15th day"  --  period  bound-+       -p  "every  15th  day" -- period bound-        aries will be on 15th of each month-       -p "every 2nd Monday"  -- period bound--       aries will be on second Monday of  each+       -p "every 2nd Monday" -- period  bound-+       aries  will be on second Monday of each        month        -p "every 11/05" -- yearly periods with        boundaries on 5th of Nov        -p "every 5th Nov" -- same        -p "every Nov 5th" -- same -       Show historical balances at end of 15th each month (N is exclusive  end+       Show  historical balances at end of 15th each month (N is exclusive end        date):         hledger balance -H -p "every 16th day" -       Group  postings  from  start  of wednesday to end of next tuesday (N is+       Group postings from start of wednesday to end of  next  tuesday  (N  is        start date and exclusive end date):         hledger register checking -p "every 3rd day of week"     Depth limiting        With the --depth N option (short form: -N), commands like account, bal--       ance  and register will show only the uppermost accounts in the account-       tree, down to level N.  Use this when you  want  a  summary  with  less-       detail.   This  flag has the same effect as a depth: query argument (so+       ance and register will show only the uppermost accounts in the  account+       tree,  down  to  level  N.   Use this when you want a summary with less+       detail.  This flag has the same effect as a depth: query  argument  (so        -2, --depth=2 or depth:2 are basically equivalent).     Pivoting        Normally hledger sums amounts, and organizes them in a hierarchy, based-       on  account  name.  The --pivot FIELD option causes it to sum and orga--       nize hierarchy based on the value of some other field  instead.   FIELD+       on account name.  The --pivot FIELD option causes it to sum  and  orga-+       nize  hierarchy  based on the value of some other field instead.  FIELD        can be: code, description, payee, note, or the full name (case insensi-        tive) of any tag.  As with account names, values containing colon:sepa-        rated:parts will be displayed hierarchically in reports. -       --pivot  is  a  general  option affecting all reports; you can think of+       --pivot is a general option affecting all reports;  you  can  think  of        hledger transforming the journal before any other processing, replacing-       every  posting's  account name with the value of the specified field on+       every posting's account name with the value of the specified  field  on        that posting, inheriting it from the transaction or using a blank value        if it's not present. @@ -646,7 +668,7 @@               --------------------                                  0 -       One  way  to  show  only  amounts  with a member: value (using a query,+       One way to show only amounts with  a  member:  value  (using  a  query,        described below):                $ hledger balance --pivot member tag:member=.@@ -654,7 +676,7 @@               --------------------                             -2 EUR -       Another way (the acct:  query  matches  against  the  pivoted  "account+       Another  way  (the  acct:  query  matches  against the pivoted "account        name"):                $ hledger balance --pivot member acct:.@@ -662,62 +684,282 @@               --------------------                             -2 EUR -   Cost-       The  -B/--cost flag converts amounts to their cost at transaction time,-       if they have a transaction price specified.+   Valuation+   -B: Cost+       The -B/--cost flag converts amounts to their cost (or selling price) at+       transaction  time,  if  they  have a transaction price specified.  This+       flag is equivalent to --value=cost, described below. -   Market value-       The -V/--value flag converts reported amounts to their  current  market-       value.-       Specifically,  when  there  is  a  market  price  (P directive) for the-       amount's commodity, dated on or before today's date (or the report  end-       date if specified), the amount will be converted to the price's commod--       ity.+   -V: Market value+       The -V/--market flag converts reported amounts to their market value in+       a  default  valuation  commodity, using the historical market prices in+       effect on a default valuation date. -       When there are multiple applicable P directives, -V  chooses  the  most-       recent one, or in case of equal dates, the last-parsed one.+       For single period reports, the valuation date  is  today.   For  multi-+       period reports, it is the last day of each subperiod. -       For example:+       The valuation commodity will be the one referenced in the latest appli-+       cable market price dated on or before the valuation date.  If  most  of+       your  P  declarations lead to a single home currency, this will usually+       be what you want. +       Unlike the similar flag in Ledger, it does not infer market prices from+       transaction  prices.  In hledger, -B uses transaction prices, -V and -X+       use market prices.++       It is equivalent to --value=now or --value=end.++       Here's a quick example:+               # one euro is worth this many dollars from nov 1-              P 2016/11/01  $1.10+              P 2016/11/01 EUR $1.10                # purchase some euros on nov 3               2016/11/3-                  assets:euros        100+                  assets:euros        EUR100                   assets:checking                # the euro is worth fewer dollars by dec 21-              P 2016/12/21  $1.03+              P 2016/12/21 EUR $1.03         How many euros do I have ?                $ hledger -f t.j bal -N euros-                              100  assets:euros+                              EUR100  assets:euros         What are they worth at end of nov 3 ?                $ hledger -f t.j bal -N euros -V -e 2016/11/4                            $110.00  assets:euros -       What  are they worth after 2016/12/21 ?  (no report end date specified,+       What are they worth after 2016/12/21 ?  (no report end date  specified,        defaults to today)                $ hledger -f t.j bal -N euros -V                            $103.00  assets:euros -       Currently, hledger's -V only uses market prices recorded with P  direc--       tives, not transaction prices (unlike Ledger).+   -X: Market value in specified commodity+       The  -X/--exchange option is like -V/--market except it takes a commod-+       ity symbol argument, so that you can select a different target  commod-+       ity.   It is similar to the same option in Ledger, with the same caveat+       mentioned for -V/--value above.  It is equivalent  to  --value=now,COMM+       or --value=end,COMM; for more details, read on. -       Currently,  -V has a limitation in multicolumn balance reports: it uses-       the market prices on the report end date for all columns.  (Instead  of-       the prices on each column's end date.)+   --value+       (experimental, added 201905) -   Combining -B and -V-       Using  -B/--cost  and -V/--value together is currently allowed, but the-       results are probably not meaningful.  Let us know if you find a use for-       this.+       -B, -V and -X are special cases of the more general --value option: +               --value=TYPE[,COMM]  TYPE is cost, end, now or YYYY-MM-DD.+                                    COMM is an optional commodity symbol.+                                    Shows amounts converted to:+                                    - cost commodity using transaction prices (then optionally to COMM using market prices at period end(s))+                                    - default valuation commodity (or COMM) using market prices at period end(s)+                                    - default valuation commodity (or COMM) using current market prices+                                    - default valuation commodity (or COMM) using market prices at some date++   Valuation type+       TYPE  is one of these keywords, or their first letter, or a date (which+       must be 8 digits with - or / or .  separators):++       --value=cost+              Convert amounts to cost, using the prices recorded  in  transac-+              tions.  -B/--cost is equivalent to this.++       --value=end+              Convert  amounts  to  their value in default valuation commodity+              using market prices on the last day of the report period (or  of+              each  subperiod in a multiperiod report).  When no report period+              is specified, uses the journal's last transaction date.++       --value=now+              Convert amounts to their value in  default  valuation  commodity+              using  current  market  prices (as of when report is generated).+              -V/--market is equivalent to this.++       --value=YYYY-MM-DD+              Convert amounts to their value in  default  valuation  commodity+              using market prices on this date.  Eg --value=2019-04-25.++   Valuation commodity+       The  default valuation commodity is the commodity mentioned in the most+       recent applicable market price declaration.  When all your price decla-+       rations  lead  to a single home currency, this will usually do what you+       want.++       To select a different valuation commodity: write the  commodity  symbol+       after  the  valuation type, separated by a comma (eg: --value=now,EUR).+       This will use, in this preferred order:++       o declared prices (from source commodity to valuation commodity)++       o reverse prices (declared prices from valuation to  source  commodity,+         inverted)++       o indirect  prices  (prices  calculated  from  the  shortest  chain  of+         declared or reverse prices from source to valuation commodity).++   --value examples+       Here are the effects of --value as seen with print:++              P 2000-01-01 A  1 B+              P 2000-02-01 A  2 B+              P 2000-03-01 A  3 B+              P 2000-04-01 A  4 B++              2000-01-01+                (a)      1 A @ 5 B++              2000-02-01+                (a)      1 A @ 6 B++              2000-03-01+                (a)      1 A @ 7 B++       Show the cost of each posting:++              $ hledger -f- print --value=cost+              2000/01/01+                  (a)             5 B++              2000/02/01+                  (a)             6 B++              2000/03/01+                  (a)             7 B++       Show the value as of the last day of the report period (2000-02-29):++              $ hledger -f- print --value=end date:2000/01-2000/03+              2000-01-01+                  (a)             2 B++              2000-02-01+                  (a)             2 B++       With no report period specified, that shows the value as  of  the  last+       day of the journal (2000-03-01):++              $ hledger -f- print --value=end+              2000/01/01+                  (a)             3 B++              2000/02/01+                  (a)             3 B++              2000/03/01+                  (a)             3 B++       Show the current value (the 2000-04-01 price is still in effect today):++              $ hledger -f- print --value=now+              2000-01-01+                  (a)             4 B++              2000-02-01+                  (a)             4 B++              2000-03-01+                  (a)             4 B++       Show the value on 2000/01/15:++              $ hledger -f- print --value=2000-01-15+              2000/01/01+                  (a)             1 B++              2000/02/01+                  (a)             1 B++              2000/03/01+                  (a)             1 B++       You may need to  explicitly  set  a  commodity's  display  style,  when+       reverse prices are used.  Eg this output might be surprising:++              P 2000-01-01 A 2B++              2000-01-01+                a  1B+                b++              $ hledger print -x -X A+              2000/01/01+                  a               0+                  b               0++       Explanation:  because there's no amount or commodity directive specify-+       ing a display style for A, 0.5A gets the default style, which shows  no+       decimal digits.  Because the displayed amount looks like zero, the com-+       modity symbol and minus sign are not displayed either.  Adding  a  com-+       modity directive sets a more useful display style for A:++              P 2000-01-01 A 2B+              commodity 0.00A++              2000-01-01+                a  1B+                b++              $ hledger print -X A+              2000/01/01+                  a           0.50A+                  b          -0.50A++   Effect of --value on reports+       Below  is  how  --value  affects  each of hledger's reports, currently.+       You're not expected to remember all this, but  when  troubleshooting  a+       report, look here.  If you find problems - useless reports, misbehaving+       reports, or error messages being printed -  please  report  them  (with+       reproducible examples) eg at #329.+++       Report type     --value cost     --value end                 --value DATE/now+       ---------------------------------------------------------------------------------+       print+       posting         cost,       as   market  value  at  report   market   value  at+       amounts         recorded    in   end                         DATE+                       transaction+       balance         show unvalued    show unvalued               show unvalued+       asser-+       tions/assign-+       ments+       register+       starting bal-   cost of start-   market   value   at   day   market  value   at+       ance with -H    ing balance      before report start         DATE+       posting         cost             market  value  at  report   market   value  at+       amounts                          end                         DATE+       posting         summarised       market value each summary   market value  each+       amounts, mul-   cost             posting at period end       summary posting at+       tiperiod                                                     DATE+       running         sum/average of   sum/average of  the  dis-   sum/average of the+       total/average   the  displayed   played values               displayed values+                       values+       balance  (bs,+       cf, is..)++++       starting bal-   costs       of   market   value   at   day   market   value  at+       ances with -H   starting  bal-   before  report  start  of   DATE  of  sum   of+                       ances            sum of previous postings    previous postings+       balances,       summed costs     market  value  at  period   market  value   at+       simple   bal-                    end of sum of postings      DATE   of  sum  of+       ance report                                                  postings+       balances,       summed costs     market  value  at  period   market   value  at+       multiperiod                      end of sum of postings      DATE  of  sum   of+       report                                                       postings+       budget          costs  of bud-   budget-setting   periodic   budget-setting+       amounts  with   get amounts      txns are valued at period   periodic  txns are+       --budget                         end                         valued at DATE+       col-            sum/average of   market  value  at  period   market   value  at+       umn/row/grand   the  displayed   end  of  sum/average   of   DATE of  sum/aver-+       totals/aver-    values           postings                    age of postings+       ages++   Combining -B, -V, -X, --value+       The rightmost of these flags wins.+    Output destination        Some  commands (print, register, stats, the balance commands) can write        their output to a destination other than the  console.   This  is  con-@@ -813,8 +1055,7 @@         REGEX, acct:REGEX               match account names by this regular expression.  (With  no  pre--              fix, acct: is assumed.)-       same as above+              fix, acct: is assumed.)  same as above         amt:N, amt:<N, amt:<=N, amt:>N, amt:>=N               match  postings with a single-commodity amount that is equal to,@@ -833,8 +1074,8 @@               tial match, use .*REGEX.*).  Note, to match characters which are               regex-significant, like the dollar sign ($), you need to prepend               \.  And when using the command line you need  to  add  one  more-              level  of  quoting  to  hide  it  from  the  shell,  so  eg  do:-              hledger print cur:'\$' or hledger print cur:\\$.+              level  of  quoting  to hide it from the shell, so eg do: hledger+              print cur:'\$' or hledger print cur:\\$.         desc:REGEX               match transaction descriptions.@@ -893,13 +1134,13 @@        scripts  named  hledger-NAME in your PATH, these will also be listed as        subcommands. -       Run  a  subcommand  by  writing  its  name  as   first   argument   (eg-       hledger incomestatement).  You can also write one of the standard short-       aliases displayed in parentheses in the command  list  (hledger b),  or-       any any unambiguous prefix of a command name (hledger inc).+       Run a subcommand by writing its name  as  first  argument  (eg  hledger+       incomestatement).  You can also write one of the standard short aliases+       displayed in parentheses in the command list (hledger b),  or  any  any+       unambiguous prefix of a command name (hledger inc).         Here  are  all  the  builtin  commands in alphabetical order.  See also-       hledger for a more  organised  command  list,  and  hledger CMD -h  for+       hledger for a more organised command  list,  and  hledger  CMD  -h  for        detailed command help.     accounts@@ -950,8 +1191,8 @@        Many hledger users edit their journals directly with a text editor,  or        generate  them from CSV.  For more interactive data entry, there is the        add command, which prompts interactively on the console for new  trans--       actions,  and  appends  them to the journal file (if there are multiple-       -f FILE options, the first file is used.) Existing transactions are not+       actions, and appends them to the journal file (if there are multiple -f+       FILE options, the first file is used.) Existing  transactions  are  not        changed.   This  is the only hledger command that writes to the journal        file. @@ -1013,6 +1254,10 @@               Starting the next transaction (. or ctrl-D/ctrl-C to quit)               Date [2015/05/22]: <CTRL-D> $ +       On  Microsoft  Windows,  the add command makes sure that no part of the+       file path ends with a period, as it can cause data loss on  that  plat-+       form (cf #1056).+    balance        balance, bal, b        Show accounts and their balances.@@ -1082,8 +1327,8 @@                                 $1    supplies     Customising the classic balance report-       You  can  customise  the  layout of classic balance reports with --for--       mat FMT:+       You  can  customise the layout of classic balance reports with --format+       FMT:                $ hledger balance --format "%20(account) %12(total)"                             assets          $-1@@ -1128,21 +1373,21 @@        o %, - render on one line, comma-separated         There are some quirks.  Eg in one-line  mode,  %(depth_spacer)  has  no-       effect, instead %(account) has indentation built in.-        Experimentation may be needed to get pleasing results.+       effect,  instead  %(account) has indentation built in.  Experimentation+       may be needed to get pleasing results.         Some example formats:         o %(total) - the account's total -       o %-20.20(account)  -  the account's name, left justified, padded to 20+       o %-20.20(account) - the account's name, left justified, padded  to  20          characters and clipped at 20 characters -       o %,%-50(account)  %25(total) - account name padded to  50  characters,-         total  padded to 20 characters, with multiple commodities rendered on+       o %,%-50(account)   %25(total)  - account name padded to 50 characters,+         total padded to 20 characters, with multiple commodities rendered  on          one line -       o %20(total)  %2(depth_spacer)%-(account) - the default format for  the+       o %20(total)   %2(depth_spacer)%-(account) - the default format for the          single-column balance report     Colour support@@ -1153,9 +1398,9 @@        o the output is not being redirected or piped anywhere     Flat mode-       To  see  a  flat  list instead of the default hierarchical display, use-       --flat.  In this mode, accounts (unless depth-clipped) show their  full-       names  and  "exclusive" balance, excluding any subaccount balances.  In+       To see a flat list instead of the  default  hierarchical  display,  use+       --flat.   In this mode, accounts (unless depth-clipped) show their full+       names and "exclusive" balance, excluding any subaccount  balances.   In        this mode, you can also use --drop N to omit the first few account name        components. @@ -1164,8 +1409,8 @@                                 $1  supplies     Depth limited balance reports-       With  --depth N  or  depth:N  or just -N, balance reports show accounts-       only to the specified numeric depth.  This is very useful to  summarise+       With --depth N or depth:N or just -N,  balance  reports  show  accounts+       only  to the specified numeric depth.  This is very useful to summarise        a complex set of accounts and get an overview.                $ hledger balance -N -1@@ -1178,17 +1423,17 @@        inclusive balances at the depth limit.     Multicolumn balance report-       Multicolumn or tabular balance reports are a very useful  hledger  fea--       ture,  and  usually  the preferred style.  They share many of the above-       features, but they show the report as a table, with columns  represent--       ing  time  periods.   This  mode  is activated by providing a reporting+       Multicolumn  or  tabular balance reports are a very useful hledger fea-+       ture, and usually the preferred style.  They share many  of  the  above+       features,  but they show the report as a table, with columns represent-+       ing time periods.  This mode is  activated  by  providing  a  reporting        interval. -       There are three types of multicolumn balance report, showing  different+       There  are three types of multicolumn balance report, showing different        information:         1. By default: each column shows the sum of postings in that period, ie-          the account's change of balance in that period.  This is  useful  eg+          the  account's  change of balance in that period.  This is useful eg           for a monthly income statement:                    $ hledger balance --quarterly income expenses -E@@ -1203,8 +1448,8 @@                   -------------------++---------------------------------                                      ||     $-1      $1       0       0 -       2. With  --cumulative:  each  column  shows the ending balance for that-          period, accumulating the changes across periods, starting from 0  at+       2. With --cumulative: each column shows the  ending  balance  for  that+          period,  accumulating the changes across periods, starting from 0 at           the report start date:                    $ hledger balance --quarterly income expenses -E --cumulative@@ -1220,8 +1465,8 @@                                      ||         $-1           0           0           0         3. With --historical/-H: each column shows the actual historical ending-          balance for that period, accumulating the  changes  across  periods,-          starting  from the actual balance at the report start date.  This is+          balance  for  that  period, accumulating the changes across periods,+          starting from the actual balance at the report start date.  This  is           useful eg for a multi-period balance sheet, and when you are showing           only the data after a certain start date: @@ -1237,6 +1482,9 @@                   ----------------------++-------------------------------------                                         ||           0           0           0 +       Note that --cumulative or --historical/-H disable --row-total/-T, since+       summing end balances generally does not make sense.+        Multicolumn  balance  reports display accounts in flat mode by default;        to see the hierarchy, use --tree. @@ -1522,7 +1770,9 @@        report  period.  As with multicolumn balance reports, you can alter the        report mode  with  --change/--cumulative/--historical.   Normally  bal-        ancesheet  shows historical ending balances, which is what you need for-       a balance sheet; note this means it ignores report begin dates.+       a balance sheet; note this means it ignores  report  begin  dates  (and+       -T/--row-total,  since  summing  end  balances  generally does not make+       sense).         This command also supports output destination and output format  selec-        tion.@@ -1616,7 +1866,7 @@         The closing transaction  transfers  balances  to  "equity:closing  bal-        ances".   The opening transaction transfers balances from "equity:open--       ing balances".  You can chose to print just one of the transactions  by+       ing balances".  You can choose to print just one of the transactions by        using the --opening or --closing flag.         If you split your journal files by time (eg yearly), you will typically@@ -1638,7 +1888,7 @@         By default, the closing transaction is dated  yesterday,  the  balances        are  calculated  as of end of yesterday, and the opening transaction is-       dated today.  To close on some other date, use:  hledger close -e OPEN-+       dated today.  To close on some other date, use: hledger close -e  OPEN-        INGDATE.   Eg,  to  close/open  on the 2018/2019 boundary, use -e 2019.        You can also use -p or date:PERIOD (any starting date is ignored). @@ -1649,6 +1899,10 @@        run this command with --auto,  the  balance  assertions  will  probably        always require --auto. +       When  account  balances have cost information (transaction prices), the+       closing/opening transactions will preserve it, so that  eg  balance  -B+       reports will not be affected.+        Examples:         Carrying  asset/liability  balances  into a new file for 2019, all from@@ -1744,17 +1998,31 @@                $ hledger import --dry ... | hledger -f- print unknown --ignore-assertions +   Importing balance assignments+       Entries  added  by import will have their posting amounts made explicit+       (like hledger print -x).  This means that any  balance  assignments  in+       imported  files must be evaluated; but, imported files don't get to see+       the main file's account balances.  As a result, importing entries  with+       balance assignments (eg from an institution that provides only balances+       and not posting  amounts)  will  probably  generate  incorrect  posting+       amounts.  To avoid this problem, use print instead of import:++              $ hledger print IMPORTFILE [--new] >> $LEDGER_FILE++       (If  you  think  import  should leave amounts implicit like print does,+       please test it and send a pull request.)+    incomestatement        incomestatement, is-       This  command  displays a simple income statement, showing revenues and-       expenses during a period.  It assumes that these accounts are  under  a-       top-level  revenue or income or expense account (case insensitive, plu--       ral forms also allowed).  Note this report shows all  account  balances-       with  normal  positive  sign  (like  conventional financial statements,+       This command displays a simple income statement, showing  revenues  and+       expenses  during  a period.  It assumes that these accounts are under a+       top-level revenue or income or expense account (case insensitive,  plu-+       ral  forms  also allowed).  Note this report shows all account balances+       with normal positive  sign  (like  conventional  financial  statements,        unlike balance/print/register) (experimental). -       This command displays a simple income statement.  It currently  assumes-       that  you have top-level accounts named income (or revenue) and expense+       This  command displays a simple income statement.  It currently assumes+       that you have top-level accounts named income (or revenue) and  expense        (plural forms also allowed.)                $ hledger incomestatement@@ -1779,19 +2047,19 @@                                  0         With a reporting interval, multiple columns will be shown, one for each-       report  period.   Normally  incomestatement shows revenues/expenses per-       period, though as with multicolumn balance reports you  can  alter  the+       report period.  Normally incomestatement  shows  revenues/expenses  per+       period,  though  as  with multicolumn balance reports you can alter the        report mode with --change/--cumulative/--historical. -       This  command also supports output destination and output format selec-+       This command also supports output destination and output format  selec-        tion.     prices        prices-       Print market price directives from the  journal.   With  --costs,  also-       print  synthetic  market  prices  based  on  transaction  prices.  With+       Print  market  price  directives  from the journal.  With --costs, also+       print synthetic  market  prices  based  on  transaction  prices.   With        --inverted-costs,  also  print  inverse  prices  based  on  transaction-       prices.   Prices  (and  postings providing prices) can be filtered by a+       prices.  Prices (and postings providing prices) can be  filtered  by  a        query.     print@@ -1799,11 +2067,11 @@        Show transaction journal entries, sorted by date.         The print command displays full journal entries (transactions) from the-       journal  file  in date order, tidily formatted.  With --date2, transac-+       journal file in date order, tidily formatted.  With  --date2,  transac-        tions are sorted by secondary date instead.         print's output is always a valid hledger journal.-       It preserves all transaction information,  but  it  does  not  preserve+       It  preserves  all  transaction  information,  but it does not preserve        directives or inter-transaction comments                $ hledger print@@ -1829,39 +2097,39 @@                   assets:bank:checking           $-1         Normally, the journal entry's explicit or implicit amount style is pre--       served.  Ie when an amount is omitted in the journal, it will be  omit--       ted  in  the  output.   You  can use the -x/--explicit flag to make all+       served.   Ie when an amount is omitted in the journal, it will be omit-+       ted in the output.  You can use the  -x/--explicit  flag  to  make  all        amounts explicit, which can be useful for troubleshooting or for making        your journal more readable and robust against data entry errors.  Note,-       -x will cause postings with a multi-commodity amount (these  can  arise-       when  a  multi-commodity  transaction  has  an implicit amount) will be-       split into multiple single-commodity postings, for valid  journal  out-+       -x  will  cause postings with a multi-commodity amount (these can arise+       when a multi-commodity transaction has  an  implicit  amount)  will  be+       split  into  multiple single-commodity postings, for valid journal out-        put. -       With  -B/--cost,  amounts with transaction prices are converted to cost+       With -B/--cost, amounts with transaction prices are converted  to  cost        using that price.  This can be used for troubleshooting. -       With -m/--match and a STR argument, print will show at most one  trans--       action:  the  one  one whose description is most similar to STR, and is-       most recent.  STR should contain at least two characters.  If there  is+       With  -m/--match and a STR argument, print will show at most one trans-+       action: the one one whose description is most similar to  STR,  and  is+       most  recent.  STR should contain at least two characters.  If there is        no similar-enough match, no transaction will be shown.         With --new, for each FILE being read, hledger reads (and writes) a spe--       cial state file (.latest.FILE in the same  directory),  containing  the-       latest  transaction  date(s)  that  were  seen last time FILE was read.-       When this file is found, only transactions with newer  dates  (and  new-       transactions  on  the  latest  date)  are  printed.  This is useful for-       ignoring already-seen entries in import data, such  as  downloaded  CSV+       cial  state  file  (.latest.FILE in the same directory), containing the+       latest transaction date(s) that were seen  last  time  FILE  was  read.+       When  this  file  is found, only transactions with newer dates (and new+       transactions on the latest date)  are  printed.   This  is  useful  for+       ignoring  already-seen  entries  in import data, such as downloaded CSV        files.  Eg:                $ hledger -f bank1.csv print --new               # shows transactions added since last print --new on this file -       This  assumes  that  transactions  added  to  FILE  always have same or-       increasing dates, and that transactions on the  same  day  do  not  get+       This assumes that transactions  added  to  FILE  always  have  same  or+       increasing  dates,  and  that  transactions  on the same day do not get        reordered.  See also the import command. -       This  command also supports output destination and output format selec-+       This command also supports output destination and output format  selec-        tion.  Here's an example of print's CSV output:                $ hledger print -Ocsv@@ -1878,20 +2146,20 @@               "5","2008/12/31","","*","","pay off","","liabilities:debts","1","$","","1","",""               "5","2008/12/31","","*","","pay off","","assets:bank:checking","-1","$","1","","","" -       o There is one CSV record per posting, with  the  parent  transaction's+       o There  is  one  CSV record per posting, with the parent transaction's          fields repeated.         o The "txnidx" (transaction index) field shows which postings belong to-         the same transaction.  (This number might change if transactions  are-         reordered  within  the file, files are parsed/included in a different+         the  same transaction.  (This number might change if transactions are+         reordered within the file, files are parsed/included in  a  different          order, etc.) -       o The amount is separated into "commodity" (the  symbol)  and  "amount"+       o The  amount  is  separated into "commodity" (the symbol) and "amount"          (numeric quantity) fields.         o The numeric amount is repeated in either the "credit" or "debit" col--         umn, for convenience.  (Those names are not accurate in the  account--         ing  sense;  it  just  puts negative amounts under credit and zero or+         umn,  for convenience.  (Those names are not accurate in the account-+         ing sense; it just puts negative amounts under  credit  and  zero  or          greater amounts under debit.)     print-unique@@ -1915,7 +2183,7 @@        Show postings and their running total.         The register command displays postings in date order, one per line, and-       their  running  total.  This is typically used with a query selecting a+       their running total.  This is typically used with a query  selecting  a        particular account, to see that account's activity:                $ hledger register checking@@ -1926,8 +2194,8 @@         With --date2, it shows and sorts by secondary date instead. -       The --historical/-H flag adds the balance from  any  undisplayed  prior-       postings  to  the  running  total.  This is useful when you want to see+       The  --historical/-H  flag  adds the balance from any undisplayed prior+       postings to the running total.  This is useful when  you  want  to  see        only recent activity, with a historically accurate running balance:                $ hledger register checking -b 2008/6 --historical@@ -1937,30 +2205,30 @@         The --depth option limits the amount of sub-account detail displayed. -       The --average/-A flag shows the running average posting amount  instead+       The  --average/-A flag shows the running average posting amount instead        of the running total (so, the final number displayed is the average for-       the whole report period).  This flag implies --empty (see  below).   It-       is  affected  by  --historical.   It  works  best when showing just one+       the  whole  report period).  This flag implies --empty (see below).  It+       is affected by --historical.  It  works  best  when  showing  just  one        account and one commodity. -       The --related/-r flag shows the other postings in the  transactions  of+       The  --related/-r  flag shows the other postings in the transactions of        the postings which would normally be shown. -       The  --invert flag negates all amounts.  For example, it can be used on+       The --invert flag negates all amounts.  For example, it can be used  on        an income account where amounts are normally displayed as negative num--       bers.   It's  also  useful  to  show  postings  on the checking account+       bers.  It's also useful  to  show  postings  on  the  checking  account        together with the related account:                $ hledger register --related --invert assets:checking -       With a reporting interval, register shows  summary  postings,  one  per+       With  a  reporting  interval,  register shows summary postings, one per        interval, aggregating the postings to each account:                $ hledger register --monthly income               2008/01                 income:salary                          $-1          $-1               2008/06                 income:gifts                           $-1          $-2 -       Periods  with no activity, and summary postings with a zero amount, are+       Periods with no activity, and summary postings with a zero amount,  are        not shown by default; use the --empty/-E flag to see them:                $ hledger register --monthly income -E@@ -1977,7 +2245,7 @@               2008/11                                                          0          $-2               2008/12                                                          0          $-2 -       Often, you'll want to see just one  line  per  interval.   The  --depth+       Often,  you'll  want  to  see  just one line per interval.  The --depth        option helps with this, causing subaccounts to be aggregated:                $ hledger register --monthly assets --depth 1h@@ -1985,19 +2253,19 @@               2008/06                 assets                                 $-1            0               2008/12                 assets                                 $-1          $-1 -       Note  when using report intervals, if you specify start/end dates these-       will be adjusted outward if necessary to  contain  a  whole  number  of-       intervals.   This  ensures  that  the first and last intervals are full+       Note when using report intervals, if you specify start/end dates  these+       will  be  adjusted  outward  if  necessary to contain a whole number of+       intervals.  This ensures that the first and  last  intervals  are  full        length and comparable to the others in the report.     Custom register output-       register uses the full terminal width by default,  except  on  windows.-       You  can override this by setting the COLUMNS environment variable (not+       register  uses  the  full terminal width by default, except on windows.+       You can override this by setting the COLUMNS environment variable  (not        a bash shell variable) or by using the --width/-w option. -       The description and account columns normally share  the  space  equally-       (about  half  of  (width  - 40) each).  You can adjust this by adding a-       description width  as  part  of  --width's  argument,  comma-separated:+       The  description  and  account columns normally share the space equally+       (about half of (width - 40) each).  You can adjust  this  by  adding  a+       description  width  as  part  of  --width's  argument, comma-separated:        --width W,D .  Here's a diagram (won't display correctly in --help):                <--------------------------------- width (W) ---------------------------------->@@ -2013,34 +2281,34 @@               $ hledger reg -w 100,40           # set overall width 100, description width 40               $ hledger reg -w $COLUMNS,40      # use terminal width, & description width 40 -       This  command also supports output destination and output format selec-+       This command also supports output destination and output format  selec-        tion.     register-match        register-match        Print the one posting whose transaction description is closest to DESC,-       in  the  style  of the register command.  If there are multiple equally-       good matches, it shows the most recent.  Query  options  (options,  not-       arguments)   can   be   used  to  restrict  the  search  space.   Helps-       ledger-autosync detect already-seen transactions when importing.+       in the style of the register command.  If there  are  multiple  equally+       good  matches,  it  shows the most recent.  Query options (options, not+       arguments) can be used to restrict the  search  space.   Helps  ledger-+       autosync detect already-seen transactions when importing.     rewrite        rewrite        Print all transactions, rewriting the postings of matched transactions.-       For  now  the only rewrite available is adding new postings, like print+       For now the only rewrite available is adding new postings,  like  print        --auto.         This is a start at a generic rewriter of transaction entries.  It reads-       the  default  journal and prints the transactions, like print, but adds+       the default journal and prints the transactions, like print,  but  adds        one or more specified postings to any transactions matching QUERY.  The-       posting  amounts can be fixed, or a multiplier of the existing transac-+       posting amounts can be fixed, or a multiplier of the existing  transac-        tion's first posting amount.         Examples: -              hledger-rewrite.hs ^income --add-posting '(liabilities:tax)  *.33  ; income tax' --add-posting '(reserve:gifts)  $100'-              hledger-rewrite.hs expenses:gifts --add-posting '(reserve:gifts)  *-1"'-              hledger-rewrite.hs -f rewrites.hledger+              $ hledger-rewrite.hs ^income --add-posting '(liabilities:tax)  *.33  ; income tax' --add-posting '(reserve:gifts)  $100'+              $ hledger-rewrite.hs expenses:gifts --add-posting '(reserve:gifts)  *-1"'+              $ hledger-rewrite.hs -f rewrites.hledger         rewrites.hledger may consist of entries like: @@ -2049,7 +2317,7 @@                 (reserve:grocery)  *0.25  ; reserve 25% for grocery                 (reserve:)  *0.25  ; reserve 25% for grocery -       Note the single quotes to protect the dollar sign from  bash,  and  the+       Note  the  single  quotes to protect the dollar sign from bash, and the        two spaces between account and amount.         More:@@ -2059,16 +2327,16 @@               $ hledger rewrite -- expenses:gifts --add-posting '(budget:gifts)  *-1"'               $ hledger rewrite -- ^income        --add-posting '(budget:foreign currency)  *0.25 JPY; diversify' -       Argument  for  --add-posting  option  is a usual posting of transaction-       with an exception for amount specification.  More  precisely,  you  can+       Argument for --add-posting option is a  usual  posting  of  transaction+       with  an  exception  for amount specification.  More precisely, you can        use '*' (star symbol) before the amount to indicate that that this is a-       factor for an amount  of  original  matched  posting.   If  the  amount-       includes  a  commodity  name, the new posting amount will be in the new-       commodity; otherwise, it will be in the matched posting  amount's  com-+       factor  for  an  amount  of  original  matched  posting.  If the amount+       includes a commodity name, the new posting amount will be  in  the  new+       commodity;  otherwise,  it will be in the matched posting amount's com-        modity.     Re-write rules in a file-       During  the  run  this  tool will execute so called "Automated Transac-+       During the run this tool will execute  so  called  "Automated  Transac-        tions" found in any journal it process.  I.e instead of specifying this        operations in command line you can put them in a journal file. @@ -2083,7 +2351,7 @@                   budget:gifts  *-1                   assets:budget  *1 -       Note  that '=' (equality symbol) that is used instead of date in trans-+       Note that '=' (equality symbol) that is used instead of date in  trans-        actions you usually write.  It indicates the query by which you want to        match the posting to add new ones. @@ -2096,12 +2364,12 @@                                                               --add-posting 'assets:budget  *1'       \                 > rewritten-tidy-output.journal -       It  is  important  to understand that relative order of such entries in-       journal is important.  You can re-use result of previously added  post-+       It is important to understand that relative order of  such  entries  in+       journal  is important.  You can re-use result of previously added post-        ings.     Diff output format-       To  use  this tool for batch modification of your journal files you may+       To use this tool for batch modification of your journal files  you  may        find useful output in form of unified diff.                $ hledger rewrite -- --diff -f examples/sample.journal '^income' --add-posting '(liabilities:tax)  *.33'@@ -2125,10 +2393,10 @@         If you'll pass this through patch tool you'll get transactions contain-        ing the posting that matches your query be updated.  Note that multiple-       files might be update according to list of input  files  specified  via+       files  might  be  update according to list of input files specified via        --file options and include directives inside of these files. -       Be  careful.  Whole transaction being re-formatted in a style of output+       Be careful.  Whole transaction being re-formatted in a style of  output        from hledger print.         See also:@@ -2136,48 +2404,48 @@        https://github.com/simonmichael/hledger/issues/99     rewrite vs. print --auto-       This command predates print --auto, and currently does  much  the  same+       This  command  predates  print --auto, and currently does much the same        thing, but with these differences: -       o with  multiple files, rewrite lets rules in any file affect all other-         files.  print --auto uses standard directive  scoping;  rules  affect+       o with multiple files, rewrite lets rules in any file affect all  other+         files.   print  --auto  uses standard directive scoping; rules affect          only child files. -       o rewrite's  query  limits which transactions can be rewritten; all are+       o rewrite's query limits which transactions can be rewritten;  all  are          printed.  print --auto's query limits which transactions are printed. -       o rewrite  applies  rules  specified on command line or in the journal.+       o rewrite applies rules specified on command line or  in  the  journal.          print --auto applies rules specified in the journal.     roi        roi-       Shows the time-weighted (TWR) and money-weighted (IRR) rate  of  return+       Shows  the  time-weighted (TWR) and money-weighted (IRR) rate of return        on your investments. -       This  command  assumes  that  you have account(s) that hold nothing but+       This command assumes that you have account(s)  that  hold  nothing  but        your investments and whenever you record current appraisal/valuation of        these investments you offset unrealized profit and loss into account(s)        that, again, hold nothing but unrealized profit and loss. -       Any transactions affecting balance of  investment  account(s)  and  not-       originating  from  unrealized profit and loss account(s) are assumed to+       Any  transactions  affecting  balance  of investment account(s) and not+       originating from unrealized profit and loss account(s) are  assumed  to        be your investments or withdrawals. -       At a minimum, you need to supply  a  query  (which  could  be  just  an-       account  name) to select your investments with --inv, and another query+       At  a  minimum,  you  need  to  supply  a query (which could be just an+       account name) to select your investments with --inv, and another  query        to identify your profit and loss transactions with --pnl. -       It will compute and display the internalized rate of return  (IRR)  and-       time-weighted  rate  of  return (TWR) for your investments for the time-       period requested.  Both rates of return are annualized before  display,+       It  will  compute and display the internalized rate of return (IRR) and+       time-weighted rate of return (TWR) for your investments  for  the  time+       period  requested.  Both rates of return are annualized before display,        regardless of the length of reporting interval.     stats        stats        Show some journal statistics. -       The  stats  command displays summary information for the whole journal,-       or a matched part of it.  With a reporting interval, it shows a  report+       The stats command displays summary information for the  whole  journal,+       or  a matched part of it.  With a reporting interval, it shows a report        for each report period.         Example:@@ -2193,16 +2461,18 @@               Payees/descriptions      : 5               Accounts                 : 8 (depth 3)               Commodities              : 1 ($)+              Market prices            : 12 ($) -       This  command also supports output destination and output format selec-+       This command also supports output destination and output format  selec-        tion.     tags        tags-       List all the tag names used in the journal.  With a TAGREGEX  argument,-       only  tag  names matching the regular expression (case insensitive) are-       shown.  With QUERY arguments, only transactions matching the query  are-       considered.+       List  all the tag names used in the journal.  With a TAGREGEX argument,+       only tag names matching the regular expression (case  insensitive)  are+       shown.   With QUERY arguments, only transactions matching the query are+       considered.  With --values flag, the tags'  unique  values  are  listed+       instead.     test        test@@ -2220,8 +2490,8 @@        seed, for repeatable results from  tests  using  randomness  (currently        none of them). -       This  is  mainly  used  by developers, but it's nice to be able to san--       ity-check your installed hledger executable at any time.  All tests are+       This  is mainly used by developers, but it's nice to be able to sanity-+       check your installed hledger executable at any  time.   All  tests  are        expected to pass - if you ever see otherwise, something has gone wrong,        please report a bug! @@ -2234,15 +2504,15 @@        Add-ons  can  be  invoked like any hledger command, but there are a few        things to be aware of.  Eg if the hledger-web add-on is installed, -       o hledger -h web  shows  hledger's  help,  while  hledger web -h  shows+       o hledger -h web shows hledger's  help,  while  hledger  web  -h  shows          hledger-web's help.         o Flags  specific  to  the add-on must have a preceding -- to hide them          from hledger.  So hledger web --serve --port 9000 will  be  rejected;          you must use hledger web -- --serve --port 9000. -       o You    can    always    run    add-ons    directly    if   preferred:-         hledger-web --serve --port 9000.+       o You can always run add-ons directly if preferred: hledger-web --serve+         --port 9000.         Add-ons are a relatively easy way to add local features  or  experiment        with  new  ideas.   They  can  be  written in any language, but haskell@@ -2316,7 +2586,7 @@        $HOME/.hledger.journal          (on          windows,           perhaps        C:/Users/USER/.hledger.journal). -BUGS+LIMITATIONS        The  need  to  precede  addon command options with -- when invoked from        hledger is awkward. @@ -2327,36 +2597,39 @@        In a Microsoft Windows CMD window, non-ascii characters and colours are        not supported. +       On Windows, non-ascii characters may not display correctly when running+       a hledger built in CMD in MSYS/CYGWIN, or vice-versa.+        In a Cygwin/MSYS/Mintty window, the tab key is not supported in hledger        add. -       Not all of Ledger's journal file syntax is supported.  See file  format+       Not  all of Ledger's journal file syntax is supported.  See file format        differences. -       On  large  data  files,  hledger  is  slower  and uses more memory than+       On large data files, hledger  is  slower  and  uses  more  memory  than        Ledger.  TROUBLESHOOTING-       Here are some issues you might encounter  when  you  run  hledger  (and-       remember  you can also seek help from the IRC channel, mail list or bug+       Here  are  some  issues  you  might encounter when you run hledger (and+       remember you can also seek help from the IRC channel, mail list or  bug        tracker):         Successfully installed, but "No command 'hledger' found"        stack and cabal install binaries into a special directory, which should-       be  added  to your PATH environment variable.  Eg on unix-like systems,+       be added to your PATH environment variable.  Eg on  unix-like  systems,        that is ~/.local/bin and ~/.cabal/bin respectively.         I set a custom LEDGER_FILE, but hledger is still using the default file-       LEDGER_FILE  should  be  a  real environment variable, not just a shell-       variable.  The command env | grep LEDGER_FILE should show it.  You  may+       LEDGER_FILE should be a real environment variable,  not  just  a  shell+       variable.   The command env | grep LEDGER_FILE should show it.  You may        need to use export.  Here's an explanation. -       "Illegal  byte  sequence"  or  "Invalid or incomplete multibyte or wide+       "Illegal byte sequence" or "Invalid or  incomplete  multibyte  or  wide        character" errors        In order to handle non-ascii letters and symbols (like ), hledger needs        an appropriate locale.  This is usually configured system-wide; you can        also configure it temporarily.  The locale may need to be one that sup--       ports  UTF-8,  if you built hledger with GHC < 7.2 (or possibly always,+       ports UTF-8, if you built hledger with GHC < 7.2 (or  possibly  always,        I'm not sure yet).         Here's  an  example  of  setting  the  locale  temporarily,  on  ubuntu@@ -2375,7 +2648,7 @@               $ echo "export LANG=en_US.UTF-8" >>~/.bash_profile               $ bash --login -       If  we  preferred  to  use eg fr_FR.utf8, we might have to install that+       If we preferred to use eg fr_FR.utf8, we might  have  to  install  that        first:                $ apt-get install language-pack-fr@@ -2396,7 +2669,7 @@   REPORTING BUGS-       Report  bugs at http://bugs.hledger.org (or on the #hledger IRC channel+       Report bugs at http://bugs.hledger.org (or on the #hledger IRC  channel        or hledger mail list)  @@ -2410,7 +2683,7 @@   SEE ALSO-       hledger(1),     hledger-ui(1),     hledger-web(1),      hledger-api(1),+       hledger(1),      hledger-ui(1),     hledger-web(1),     hledger-api(1),        hledger_csv(5), hledger_journal(5), hledger_timeclock(5), hledger_time-        dot(5), ledger(1) @@ -2418,4 +2691,4 @@   -hledger 1.14                      March 2019                        hledger(1)+hledger 1.15                      August 2019                       hledger(1)