Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

SPEC: print command

Notes on some of print’s behaviour.

Effects of certain output flags

No output flags (default output)

By default, print tries to show each entry as it is written in the journal file, except for alignment. And it shows entries in date-then-parse order. Two additions for lot entries: the gain posting inferred for a disposal is shown, and lot postings are shown with the cost basis annotation inferred by lot processing when the user wrote none (eg 10 AAPL {$50} @ $50, -5 AAPL {2026-01-15, $50} @ $70, or {} for a disposal from several lots). So lot entries are self-describing: the output can be re-read without the commodity’s lots: declaration, under the default cost basis method. (With --lots, the lot subaccount name carries the basis instead; and --export does not add them, since it reproduces the directives and aims to keep entries as written.) Comment lines immediately preceding an entry (with no blank line between) are part of it (tprecedingcomment) and are shown before it, verbatim.

--export

Reproduces the journal file(s) rather than a date-sorted list of entries. The journal reader records every top-level item verbatim and in order in jitems (see JournalItem in Types.hs); export walks those items, emitting directives, comment lines and comment blocks as written, and replacing each transaction placeholder with print’s normal rendering of that transaction (looked up in jtxns by source position, so filtering and processing of jtxns are respected). Blank lines are normalised, as in ordinary print output: transactions, and groups of adjacent directive/comment lines (as delimited by blank lines in the source), are output as blocks separated by exactly one blank line, and a final transaction is followed by a blank line. Each run of blank lines is recorded as a single JIBlank separator, so the author’s grouping is preserved. Details:

  • include lines are dropped; the included file’s items follow inline, starting a new block (so adjacent included files’ entries are separated by a blank line). (A future --export=file mode could keep the include line and omit them.)
  • apply account/alias and their end forms are dropped: their effect is baked into the stored account names. Hence an account declaration inside an apply account block is reproduced without its prefix.
  • !/@ prefixes and the Ledger-only directives hledger ignores are dropped.
  • By default, periodic ~ rules and auto posting = rules are exported as directives. With --forecast and/or --auto, the generated transactions and postings are exported instead (and the rules are not). In other words these flags materialise the rules. Postings generated by --infer-equity are exported too. (Beancount output never includes the rules, since Beancount doesn’t support them; the output just includes whatever generated transactions/postings have been enabled by options.)
  • Transactions with no placeholder (from non-journal files, eg an included CSV) are appended at the end.
  • A decimal-mark, D or Y directive inside an included file, once inlined, also affects later entries of the parent file. Known limitation.
  • Output formats: txt (the default), ledger and beancount. With -O ledger, ledgerItemRenderer (Write/Ledger.hs) renders transactions with Ledger lot syntax and comments out directives it can detect as Ledger-incompatible (decimal-mark; one-line commodity with an amount; ~ rule with a description; = rule with *N multipliers), preceded by ; not supported as-is:. Comments pass through (;, #, * and comment blocks are all Ledger syntax). Other incompatibilities (hledger query syntax in = rules, ==/=* assertions, trailing decimal marks, date: tags) are not detected.
  • With -O beancount, beancountDirectives (Write/Beancount.hs) synthesises a header from the Journal: tolerance option, operating_currency options (cost currencies), commodity directives (declared commodities, tags as metadata), open directives (declared and used accounts, each on its earliest posting date or else the earliest transaction date; account tags as metadata, lots: as booking method), and price directives sorted by date. Then beancountItemRenderer renders the items: directive items are dropped (no in-place translation, since Beancount directives are dated and order-independent), #/* comment lines and comment blocks become ; comments, transactions use showTransactionBeancount (which also renders preceding comments). Plain print -O beancount outputs only transactions (the header moved to –export).

--round

Controls rounding/padding of displayed amounts:

  • none — show original decimal digits, as in the journal (default)
  • soft — add or remove trailing decimal zeros to match commodity precision
  • hard — round posting amounts to commodity precision (can unbalance transactions)
  • all — also round cost amounts to commodity precision (can unbalance transactions)

--verbose-tags

Makes certain normally-hidden tags visible (in comments):

  • ptype: acquire/dispose/transfer-from/transfer-to — lot posting classification
  • cost-tagged: — marks postings that have or were given a transaction cost
  • conversion-tagged: — marks equity conversion postings
  • generated-posting: — marks auto-generated postings (from transaction modifiers or –infer-equity)
  • modified-transaction: — marks transactions modified by auto posting rules
  • generated-transaction: <period> — marks forecast transactions from periodic rules

Without this flag, these tags still exist internally (queryable) but don’t appear in print output.

-x / --explicit

Shows all inferred balancing amounts and balancing costs:

  • Inferred amounts are shown
  • Inferred costs are shown
  • Balance assignment amounts are shown explicitly

--lots

Triggers lot calculation, which restructures postings:

  • Cost basis fields are made explicit, with missing parts filled in
  • Lots acquired on the same day get uniquifying labels added if needed
  • All lot postings get specific lot subaccounts added (e.g. assets:stocks → assets:stocks:{2026-01-15, $50})
  • Transfer postings and dispose postings affecting multiple lots are split into one per lot