ledger.1 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456
  1. .Dd March 23, 2012
  2. .Dt LEDGER 1
  3. .Os
  4. .Sh NAME
  5. .Nm ledger
  6. .Nd Command-line, double-entry account reporting tool
  7. .Sh SYNOPSIS
  8. .Nm
  9. .Op Ar command
  10. .Op Ar options
  11. .Op Ar arguments
  12. .Sh DESCRIPTION
  13. .Nm
  14. is a command-line accounting tool based on the power and completeness
  15. of double-entry accounting. It is only a reporting tool, which means it never
  16. modifies your data files, but it does offer a large selection of reports, and
  17. different ways to customize them to your needs.
  18. .Sh COMMANDS
  19. .Nm
  20. accepts several top-level commands, each of which generates a different
  21. kind of basic report. Most of them accept a
  22. .Ar report-query
  23. argument, in order to determine what should be reported. To understand the
  24. syntax of a
  25. .Ar report-query ,
  26. see the section on
  27. .Sx QUERIES .
  28. In its most basic form, simply specifying one or more strings produces a
  29. report for all accounts containing those strings.
  30. .Pp
  31. If no command is given,
  32. .Nm
  33. enters a
  34. .Tn REPL ,
  35. or command loop, allowing several commands to be executed on the same
  36. dataset without reparsing.
  37. .Pp
  38. The following is a complete list of accepted reporting commands:
  39. .Bl -tag -width accounts
  40. .It Ic accounts Oo Ar report-query Oc
  41. List all accounts for postings that match the
  42. .Ar report-query .
  43. .El
  44. .Bl -tag -width balance
  45. .It Ic balance Oo Ar report-query Oc
  46. Print a balance report showing totals for postings that match
  47. .Ar report-query ,
  48. and aggregate totals for parents of those accounts. Options most commonly used
  49. with this command are:
  50. .Bl -tag -compact -width "--collapse (-n)"
  51. .It Fl \-basis Pq Fl B
  52. Report in terms of cost basis, not amount or value. This is the only form of
  53. report which is guaranteed to always balance to zero, when no
  54. .Ar report-query
  55. is specified.
  56. Only show totals for the top-most accounts.
  57. .It Fl \-empty Pq Fl E
  58. Show accounts whose total is zero.
  59. .It Fl \-flat
  60. Rather than display a hierarchical tree, flatten the report to show subtotals
  61. for only accounts matching
  62. .Ar report-query .
  63. .It Fl \-no-total
  64. Suppress the summary total shown at the bottom of the report.
  65. .El
  66. .Pp
  67. The synonyms
  68. .Ic bal
  69. and
  70. .Ic b
  71. are also accepted.
  72. .It Ic budget Oo Ar report-query Oc
  73. A special balance report which includes three extra columns: the amount
  74. budgeted during the reporting period, how spending differed from the budget,
  75. and the percentage of budget spent (exceeds 100% if you go over budget).
  76. Note that budgeting requires one or more
  77. .Do
  78. periodic transactions
  79. .Dc
  80. to be defined in your data file(s). See the manual for more information.
  81. .It Ic cleared Oo Ar report-query Oc
  82. A special balance report which adds two extra columns: the cleared balance for
  83. each account, and the date of the most recent cleared posting in that account.
  84. For this accounting to be meaningful, the cleared flag must be set on at least
  85. one posting. See the manual for more information.
  86. .It Ic commodities Oo Ar report-query Oc
  87. List all commodities for postings matching the
  88. .Ar report-query .
  89. .It Ic convert
  90. Reads data from a CSV (comma-separated values) file and generates
  91. .Nm
  92. transactions.
  93. .It Ic csv Oo Ar report-query Oc
  94. Report of postings matching the
  95. .Ar report-query
  96. in CSV format (comma-separated values). Useful for exporting data to a
  97. spreadsheet for further analysis or charting.
  98. .It Ic entry Oo Ar entry-template Oc
  99. Generate and display a new, properly formatted
  100. .Nm
  101. transaction by comparing
  102. the
  103. .Ar entry-template
  104. to the transactions in your data file(s). For more information on draft
  105. templates and using this command to quickly create new transactions, see the
  106. section
  107. .Sx ENTRIES .
  108. .Pp
  109. The synonym
  110. .Ic xact
  111. is also accepted.
  112. .It Ic emacs Oo Ar query Oc
  113. Output posting and transaction data in a format readily consumed by the Emacs
  114. editor, in a series of Lisp forms. This is used by the
  115. .Pa ledger.el
  116. Emacs mode to process reporting data from
  117. .Nm .
  118. .It Ic equity Oo Ar report-query Oc
  119. Print a transaction with a series of postings that balance current totals for
  120. accounts matching the
  121. .Ar report-query
  122. in a special account called
  123. .Li Equity:Opening Balances .
  124. The purpose of this report is to close the books for a prior year, while using
  125. these equity postings to carry forward those balances.
  126. .It Ic org
  127. Produce a journal file suitable for use in the Emacs org mode.
  128. .It Ic payees Oo Ar report-query Oc
  129. List all payees for postings matching the
  130. .Ar report-query .
  131. .It Ic pricemap
  132. Produce a file which can be used to generate a graph with graphviz showing
  133. the relationship of commodities in the
  134. .Nm
  135. file.
  136. .It Ic prices Oo Ar report-query Oc
  137. Report prices for all commodities in postings matching the
  138. .Ar report-query .
  139. The prices are reported with the granularity of a single day.
  140. .It Ic pricedb Oo Ar report-query Oc
  141. Report prices for all commodities in postings matching the
  142. .Ar report-query .
  143. Prices are reported down to the second, using the same format as the
  144. .Pa ~/.pricedb
  145. file.
  146. .It Ic print Oo Ar report-query Oc
  147. Print out the full transactions of any matching postings using the same
  148. format as they would appear in a data file. This can be used to extract
  149. subsets from a
  150. .Nm
  151. file to transfer to other files.
  152. .It Ic push Oo Ar options Oc
  153. In the
  154. .Tn REPL ,
  155. push a set of command-line
  156. .Ar options ,
  157. so that they will apply to all subsequent reports.
  158. .It Ic pop
  159. In the
  160. .Tn REPL ,
  161. pop any option settings that have been
  162. .Sm off
  163. .Ic push
  164. ed.
  165. .Sm on
  166. .It Ic register Oo Ar report-query Oc
  167. List all postings matching the
  168. .Ar report-query .
  169. This is one of the most common commands, and can be used to provide a variety
  170. of useful reports. Options most commonly used
  171. with this command are:
  172. .Pp
  173. .Bl -tag -compact -width "--collapse (-n)"
  174. .It Fl \-average Pq Fl A
  175. Show the running average, rather than a running total.
  176. .It Fl \-current Pq Fl c
  177. Don't show postings beyond the present day.
  178. .It Fl \-exchange Ar commodity Pq Fl X
  179. Render all values in the given
  180. .Ar commodity ,
  181. if a price conversion rate can be determined. Rates are always displayed
  182. relative to the date of the posting they are calculated for. This means a
  183. .Ic register
  184. report is a historical value report. For current values, it may be preferable
  185. to use the
  186. .Ic balance
  187. report.
  188. .It Fl \-gain Pq Fl G
  189. Show any gains (or losses) in commodity values over time.
  190. .It Fl \-head Ar number
  191. Only show the top
  192. .Ar number
  193. postings.
  194. .It Fl \-historical Pq Fl H
  195. Value commodities at the time of their acquisition.
  196. .It Fl \-invert
  197. Invert the value of amounts shown.
  198. .It Fl \-market Pq Fl V
  199. Show current market values for all amounts. This is determined in a somewhat
  200. magical fashion. It is probably more straightforward to use
  201. .Fl \-exchange
  202. option.
  203. .It Fl \-period Ar time-period Pq Fl p
  204. Show postings only for the given
  205. .Ar time-period .
  206. .It Fl \-related Pq Fl r
  207. Show postings that are related to those that would have been shown. It has
  208. the effect of displaying the
  209. .Qq other side
  210. of the postings.
  211. .It Fl \-sort Ar value-expression Pq Fl S
  212. Sort postings by evaluating the given
  213. .Ar value-expression .
  214. Note that a comma-separated list of expressions is allowed, in which case each
  215. sorting term is used in order to determine the final ordering. For example,
  216. to search by date and then amount, one would use:
  217. .Dl ledger reg --sort 'date, amount'
  218. .It Fl \-tail Ar number
  219. Only show the last
  220. .Ar number
  221. postings.
  222. .It Fl \-uncleared Pq Fl U
  223. Only show uncleared (i.e., recent) postings.
  224. .El
  225. .Pp
  226. There are also several grouping options that can be useful:
  227. .Pp
  228. .Bl -tag -compact -width "--collapse (-n)"
  229. .It Fl \-by-payee Pq Fl P
  230. Group postings by common payee names.
  231. .It Fl \-daily Pq Fl D
  232. Group postings by day.
  233. .It Fl \-weekly Pq Fl W
  234. Group postings by week (starting on Sundays).
  235. .It Fl \-start-of-week Ar day
  236. Set the start of each report grouped by week to the given
  237. .Ar day .
  238. .It Fl \-monthly Pq Fl M
  239. Group postings by month.
  240. .It Fl \-quarterly
  241. Group postings by fiscal quarter.
  242. .It Fl \-yearly Pq Fl Y
  243. Group postings by year.
  244. .It Fl \-days-of-week
  245. Group postings by the day of the week on which they took place.
  246. .It Fl \-subtotal Pq Fl s
  247. Group all postings together. This is very similar to the totals shown by the
  248. .Ic balance
  249. report.
  250. .El
  251. .Pp
  252. The synonyms
  253. .Ic reg
  254. and
  255. .Ic r
  256. are also accepted.
  257. .It Ic server
  258. This command requires that Python support be active. If so, it starts up an
  259. .Tn HTTP
  260. server listening for requests on port 9000. This provides an alternate
  261. interface to creating and viewing reports. Note that this is very much a
  262. work-in-progress, and will not be fully functional until a later version.
  263. .It Ic select Oo Ar sql-query Oc
  264. List all postings matching the
  265. .Ar sql-query .
  266. This command allows to generate SQL-like queries, e.g.:
  267. .Dl Li ledger select date,amount from posts where account=~/Income/
  268. .It Ic source
  269. Parse a journal file and checks it for errors.
  270. .Nm
  271. will return success
  272. if no errors are found.
  273. .It Ic stats Oo Ar report-query Oc
  274. Provide summary information about all the postings matching
  275. .Ar report-query .
  276. It provides information such as:
  277. .Bl -bullet -offset indent -compact
  278. .It
  279. Time range of all matching postings
  280. .It
  281. Unique payees
  282. .It
  283. Unique accounts
  284. .It
  285. Postings total
  286. .It
  287. Uncleared postings
  288. .It
  289. Days since last posting
  290. .It
  291. Posts in the last 7 days
  292. .It
  293. Posts in the last 30 days
  294. .It
  295. Posts this month
  296. .El
  297. .It Ic xml Oo Ar report-query Oc
  298. Output data relating to the current report in
  299. .Tn XML
  300. format. It includes all
  301. accounts and commodities involved in the report, plus the postings and the
  302. transactions they are contained in. See the manual for more information.
  303. .El
  304. .Sh OPTIONS
  305. .Bl -tag -width -indent
  306. .It Fl \-abbrev-len Ar INT
  307. Set the minimum length an account can be abbreviated to if it doesn't
  308. fit inside the
  309. .Sy account-width .
  310. If
  311. .Ar INT
  312. is zero, then the
  313. account name will be truncated on the right. If
  314. .Ar INT
  315. is greater
  316. than
  317. .Sy account-width
  318. then the account will be truncated on the
  319. left, with no shortening of the account names in order to fit into the
  320. desired width.
  321. .It Fl \-account Ar EXPR
  322. Prepend
  323. .Ar EXPR
  324. to all accounts reported. That is, the option
  325. .Fl \-account Ar \*q'Personal'\*q
  326. would tack
  327. .Ar Personal:
  328. and
  329. .Fl \-account Ar \*qtag('VAT')\*q
  330. would tack the value of the VAT tag to the beginning of every account
  331. reported in a
  332. .Ic balance
  333. or
  334. .Ic register
  335. report.
  336. .It Fl \-account-width Ar INT
  337. Set the width of the account column in the
  338. .Ic register
  339. report
  340. to
  341. .Ar INT
  342. characters.
  343. .It Fl \-actual Pq Fl L
  344. Report only real transactions, with no automated or virtual
  345. transactions used.
  346. .It Fl \-add-budget
  347. Show only un-budgeted postings.
  348. .It Fl \-amount Ar EXPR Pq Fl t
  349. Apply the given value expression to the posting amount. Using
  350. .Fl \-amount Ar EXPR
  351. you can apply an
  352. arbitrary transformation to the postings.
  353. .It Fl \-amount-data Pq Fl j
  354. On a register report print only the dates and amount of postings.
  355. Useful for graphing and spreadsheet applications.
  356. .It Fl \-amount-width Ar INT
  357. Set the width in characters of the amount column in the
  358. .Ic register
  359. report.
  360. .It Fl \-anon
  361. Anonymize registry output, mostly for sending in bug reports.
  362. .It Fl \-ansi
  363. Use color if the terminal supports it.
  364. Alias for
  365. .Fl \-color
  366. .It Fl \-args-only
  367. Ignore init files and environment variables for the
  368. .Nm
  369. run.
  370. .It Fl \-auto-match
  371. When generating a ledger transaction from a CSV file using the
  372. .Ic convert
  373. command, automatically match an account from the Ledger journal.
  374. .It Fl \-aux-date
  375. Show auxiliary dates for all calculations.
  376. Alias for
  377. .Fl \-effective
  378. .It Fl \-average Pq Fl A
  379. Print average values over the number of transactions instead of
  380. running totals.
  381. .It Fl \-balance-format Ar FMT
  382. Specify the format to use for the
  383. .Ic balance
  384. report.
  385. .It Fl \-base
  386. Reduce convertible commodities down the bottom of the conversion, e.g.
  387. display time in seconds.
  388. .It Fl \-basis Pq Fl B
  389. Report the cost basis on all posting.
  390. Alias for
  391. .Fl \-cost
  392. .It Fl \-begin Ar DATE Pq Fl b
  393. Specify the start
  394. .Ar DATE
  395. of all calculations. Transactions before
  396. that date will be ignored.
  397. .It Fl \-bold-if Ar EXPR
  398. Print the entire line in bold if the given value expression is true.
  399. .It Fl \-budget
  400. Only display budgeted items. In a
  401. .Ic register
  402. report this displays transaction in the budget, in a balance report this
  403. displays accounts in the budget.
  404. .It Fl \-budget-format Ar FMT
  405. Specify the format to use for the
  406. .Ic budget
  407. report.
  408. .It Fl \-by-payee Pq Fl P
  409. Group postings in the register report by common payee names.
  410. .It Fl \-check-payees
  411. Enable strict and pedantic checking for payees as well as accounts,
  412. commodities and tags.
  413. .It Fl \-cleared Pq Fl C
  414. Display only cleared postings.
  415. .It Fl \-cleared-format Ar FMT
  416. Specify the format to use for the
  417. .Ic cleared
  418. report
  419. .It Fl \-collapse Pq Fl n
  420. Print only the top level accounts.
  421. .It Fl \-collapse-if-zero
  422. Collapse the account display only if it has a zero balance.
  423. .It Fl \-color
  424. Use color if the terminal supports it.
  425. Alias for
  426. .Fl \-ansi
  427. .It Fl \-columns Ar INT
  428. Make the
  429. .Ic register
  430. report
  431. .Ar INT
  432. characters wide. By default
  433. .Nm
  434. will use all available columns in your terminal.
  435. .It Fl \-cost
  436. Report the cost basis on all posting.
  437. Alias for
  438. .Fl \-basis .
  439. .It Fl \-count
  440. Direct
  441. .Nm
  442. to report the number of items when appended to the
  443. .Ic commodities ,
  444. .Ic accounts
  445. or
  446. .Ic payees
  447. commands.
  448. .It Fl \-csv-format Ar FMT
  449. Format
  450. .Ic csv
  451. report
  452. according to
  453. .Ar FMT .
  454. .It Fl \-current Pq Fl c
  455. Shorthand for
  456. .Fl \-limit Ar "'date <= today'" .
  457. .It Fl \-daily Pq Fl D
  458. Shorthand for
  459. .Fl \-period Ar daily .
  460. .It Fl \-date Ar EXPR
  461. Transform the date of the transaction using
  462. .Ar EXPR .
  463. .It Fl \-date-format Ar DATEFMT Pq Fl y
  464. Print dates using
  465. .Ar DATEFMT .
  466. Refer to
  467. .Xr strftime 3
  468. for details on the format string syntax.
  469. .It Fl \-datetime-format Ar DATETIMEFMT
  470. Print datetimes using
  471. .Ar DATETIMEFMT .
  472. Refer to
  473. .Xr strftime 3
  474. for details on the format string syntax.
  475. .It Fl \-date-width Ar INT
  476. Specify the width, in characters, of the date column in the
  477. .Ic register
  478. report.
  479. .It Fl \-day-break
  480. Break up
  481. .Ic register
  482. report of timelog entries that span multiple days by day.
  483. .It Fl \-days-of-week
  484. Group transactions by the days of the week.
  485. Alias for
  486. .Fl \-dow .
  487. .It Fl \-dc
  488. Display register or balance in debit/credit format If you use
  489. .Fl \-dc
  490. with either the
  491. .Ic register
  492. or
  493. .Ic balance
  494. commands, you will now get separate columns for debits and credits.
  495. .It Fl \-debug Ar STR
  496. If
  497. .Nm
  498. has been built with debug options this will provide extra
  499. data during the run.
  500. .It Fl \-decimal-comma
  501. Direct
  502. .Nm
  503. to parse journals using the European standard comma as
  504. decimal separator, vice a period.
  505. .It Fl \-depth Ar INT
  506. Limit the depth of the account tree. In a balance report, for example,
  507. .Fl \-depth Ar 2
  508. will print balances only for accounts with two levels, i.e.
  509. .Sy Expenses:Entertainment
  510. but not
  511. .Sy Expenses:Entertainment:Dining .
  512. This is a display predicate, which means it only affects display,
  513. not the total calculations.
  514. .It Fl \-detail
  515. Related to
  516. .Ic convert
  517. command. Synonym to
  518. .Fl \-rich-data
  519. option.
  520. .It Fl \-deviation
  521. Report each posting's deviation from the average. It is only meaningful
  522. in the
  523. .Ic register No and Ic prices
  524. reports.
  525. .It Fl \-display Ar EXPR Pq Fl d
  526. Display lines that satisfy the expression
  527. .Ar EXPR .
  528. .It Fl \-display-amount Ar EXPR
  529. Apply a transformation to the
  530. .Em displayed
  531. amount. This occurs after
  532. calculations occur.
  533. .It Fl \-display-total Ar EXPR
  534. Apply a transformation to the
  535. .Em displayed
  536. total. This occurs after
  537. calculations occur.
  538. .It Fl \-dow
  539. Group transactions by the days of the week.
  540. Alias for
  541. .Fl \-days-of-week .
  542. .It Fl \-download
  543. Cause quotes to be automagically downloaded, as needed, by running
  544. a script named
  545. .Em getquote
  546. and expecting that script to return
  547. a value understood by
  548. .Nm .
  549. A sample implementation of a
  550. .Em getquote
  551. script, implemented in Perl, is provided in the
  552. distribution. Downloaded quote price are then appended to the price
  553. database, usually specified using the environment variable
  554. .Ev LEDGER_PRICE_DB .
  555. .It Fl \-effective
  556. Show auxiliary dates for all calculations. Alias for
  557. .Fl \-aux-date .
  558. .It Fl \-empty Pq Fl E
  559. Include empty accounts in report.
  560. .It Fl \-end Ar DATE Pq Fl e
  561. Constrain the report so that transactions on or after
  562. .Ar DATE
  563. are not considered.
  564. .It Fl \-equity
  565. Related to the
  566. .Ic equity
  567. command. Gives current account balances in the form of a register
  568. report.
  569. .It Fl \-exact
  570. Report beginning and ending of periods by the date of the first and last
  571. posting occurring in that period.
  572. .It Fl \-exchange Ar COMMODITY Oo , Ar COMMODITY, ... Oc Pq Fl X
  573. Display values in terms of the given
  574. .Ar COMMODITY .
  575. The latest available price is used.
  576. .It Fl \-explicit
  577. Direct
  578. .Nm
  579. to require pre-declarations for entities (such as accounts,
  580. commodities and tags) rather than taking entities from cleared
  581. transactions as defined.
  582. .It Fl \-file Ar FILE
  583. Read journal data from
  584. .Ar FILE .
  585. .It Fl \-first Ar INT
  586. Print the first
  587. .Ar INT
  588. entries. Opposite of
  589. .Fl \-last Ar INT .
  590. Alias for
  591. .Fl \-head .
  592. .It Fl \-flat
  593. Force the full names of accounts to be used in the balance report. The
  594. balance report will not use an indented tree.
  595. .It Fl \-force-color
  596. Output TTY color codes even if the TTY doesn't support them. Useful
  597. for TTYs that don't advertise their capabilities correctly.
  598. .It Fl \-force-pager
  599. Force
  600. .Nm
  601. to paginate its output.
  602. .It Fl \-forecast-while Ar EXPR
  603. Continue forecasting while
  604. .Ar VEXPR
  605. is true.
  606. Alias for
  607. .Fl \-forecast .
  608. .It Fl \-forecast-years Ar INT
  609. Forecast at most
  610. .Ar INT
  611. years into the future.
  612. .It Fl \-format Ar FMT Pq Fl F
  613. Use the given format string
  614. .Ar FMT
  615. to print output.
  616. .It Fl \-gain Pq Fl G
  617. Report net gain or loss for commodities that have a price history.
  618. .It Fl \-generated
  619. Include auto-generated postings (such as those from automated
  620. transactions) in the report, in cases where you normally wouldn't want
  621. them.
  622. .It Fl \-group-by Ar EXPR
  623. Group transaction together in the
  624. .Ic register
  625. report.
  626. .Ar EXPR
  627. can be anything, although most common would be
  628. .Ar payee
  629. or
  630. .Ar commodity .
  631. The
  632. .Fn tag
  633. function is also useful here.
  634. .It Fl \-group-title-format Ar FMT
  635. Set the format for the headers that separate reports section of
  636. a grouped report. Only has effect with a
  637. .Fl \-group-by Ar EXPR
  638. register report.
  639. .It Fl \-head Ar INT
  640. Print the first
  641. .Ar INT
  642. entries. Opposite of
  643. .Fl \-tail Ar INT .
  644. Alias for
  645. .Fl \-first
  646. .It Fl \-help
  647. Print this man page.
  648. .It Fl \-immediate
  649. Evaluate calculations immediately rather than lazily.
  650. .It Fl \-import Ar FILE
  651. Import
  652. .Ar FILE
  653. as Python module.
  654. .It Fl \-init-file Ar FILE Pq Fl i
  655. Read
  656. .Ar FILE
  657. before any other
  658. .Nm
  659. file.
  660. This file may not contain any postings, but it may contain option
  661. settings. To specify options in the init file, use the same syntax as
  662. the command-line, but put each option on its own line.
  663. .It Fl \-inject Ar STR
  664. Use
  665. .Ar STR
  666. amounts in calculations. In case you know
  667. what amount a transaction should be, but the actual transaction has the
  668. wrong value you can use metadata
  669. .Ar STR
  670. to specify the expected amount.
  671. .It Fl \-input-date-format Ar DATEFMT
  672. Specify the input date format for journal entries.
  673. .It Fl \-invert
  674. Change the sign of all reported values.
  675. .It Fl \-last Ar INT .
  676. Report only the last
  677. .Ar INT
  678. entries. Opposite of
  679. .Fl \-first Ar INT .
  680. Only useful on a register report. Alias for
  681. .Fl \-tail .
  682. .It Fl \-leeway Ar INT Pq Fl Z
  683. Alias for
  684. .Fl \-price-expr .
  685. .It Fl \-limit Ar EXPR Pq Fl l
  686. Limit postings in calculations.
  687. .It Fl \-lot-dates
  688. Report the date on which each commodity in a balance report was
  689. purchased.
  690. .It Fl \-lot-notes
  691. Report the tag attached to each commodity in a balance report.
  692. .It Fl \-lot-prices
  693. Report the price at which each commodity in a balance report was
  694. purchased.
  695. .It Fl \-lots
  696. Report the date and price at which each commodity was purchased in
  697. a balance report.
  698. .It Fl \-lots-actual
  699. Preserve the uniqueness of commodities so they aren't merged during
  700. reporting without printing the lot annotations.
  701. .It Fl \-market Pq Fl V
  702. Use the latest market value for all commodities.
  703. .It Fl \-master-account Ar STR
  704. Prepend all account names with
  705. .Ar STR
  706. .It Fl \-meta Ar STR
  707. In the register report, prepend the transaction with the value of the given
  708. tag
  709. .Ar STR .
  710. .It Fl \-meta-width Ar INT
  711. Specify the width of the Meta column used for the
  712. .Fl \-meta Ar TAG
  713. options.
  714. .It Fl \-monthly Pq Fl M
  715. Shorthand for
  716. .Fl \-period Ar monthly .
  717. .It Fl \-no-aliases
  718. Aliases are completely ignored.
  719. .It Fl \-no-color
  720. Suppress any color TTY output.
  721. .It Fl \-no-pager
  722. Disables the pager on TTY output.
  723. .It Fl \-no-revalued
  724. Stop
  725. .Nm
  726. from showing
  727. <Revalued>
  728. postings.
  729. .It Fl \-no-rounding
  730. Don't output
  731. .Qq Li <Adjustment>
  732. postings. Note that this will cause the
  733. running total to often not add up! Its main use is for
  734. .Fl \-amount-data Pq Fl j
  735. and
  736. .Fl \-total-data Pq Fl J
  737. reports.
  738. .It Fl \-no-titles
  739. Suppress the output of group titles.
  740. .It Fl \-no-total
  741. Suppress printing the final total line in a balance report.
  742. .It Fl \-now Ar DATE
  743. Use
  744. .Ar DATE
  745. as the current date. This affects the output when using
  746. .Fl \-period ,
  747. .Fl \-begin ,
  748. .Fl \-end ,
  749. or
  750. .Fl \-current
  751. to decide which dates lie in the past or future.
  752. .It Fl \-only Ar EXPR
  753. This is a postings predicate that applies after certain transforms have
  754. been executed, such as periodic gathering.
  755. .It Fl \-options
  756. Display the options in effect for this
  757. .Nm
  758. invocation, along with
  759. their values and the source of those values.
  760. .It Fl \-output Ar FILE Pq Fl o
  761. Redirect the output of
  762. .Nm
  763. to
  764. .Ar FILE .
  765. .It Fl \-pager Ar STR
  766. Use
  767. .Ar STR
  768. as the pager program.
  769. .It Fl \-payee
  770. Sets a value expression for formatting the payee. In the
  771. .Ic register
  772. report this prevents the second entry from having
  773. a date and payee for each transaction.
  774. .It Fl \-payee-width Ar INT
  775. Set the number of columns dedicated to the payee in the register
  776. report to
  777. .Ar INT .
  778. .It Fl \-pedantic
  779. Accounts, tags or commodities not previously declared will cause errors.
  780. .It Fl \-pending
  781. Use only postings that are marked pending.
  782. .It Fl \-percent Pq Fl %
  783. Calculate the percentage value of each account in a balance reports.
  784. Only works for account that have a single commodity.
  785. .It Fl \-period Ar PERIOD Pq Fl p
  786. Define a period expression that sets the time period during which
  787. transactions are to be accounted. For a
  788. .Ic register
  789. report only
  790. the transactions that satisfy the period expression with be displayed.
  791. For a balance report only those transactions will be accounted in the
  792. final balances.
  793. .It Fl \-period-sort
  794. Sort the posting within transactions using the given value expression.
  795. .It Fl \-permissive
  796. Quiet balance assertions.
  797. .It Fl \-pivot Ar TAG
  798. Produce a balance pivot report
  799. .Qq around
  800. the given
  801. .Ar TAG .
  802. .It Fl \-plot-amount-format Ar FMT
  803. Define the output format for an amount data plot.
  804. .It Fl \-plot-total-format Ar FMT
  805. Define the output format for a total data plot.
  806. .It Fl \-prepend-format Ar FMT
  807. Prepend
  808. .Ar FMT
  809. to every line of the output.
  810. .It Fl \-prepend-width Ar INT
  811. Reserve
  812. .Ar INT
  813. spaces at the beginning of each line of the output.
  814. .It Fl \-price Pq Fl I
  815. Use the price of the commodity purchase for performing calculations.
  816. .It Fl \-price-db Ar FILE
  817. .It Fl \-price-exp Ar STR Pq Fl Z
  818. Set the expected freshness of price quotes, in
  819. .Ar INT
  820. minutes. That
  821. is, if the last known quote for any commodity is older than this value,
  822. and if
  823. .Fl \-download
  824. is being used, then the Internet will be
  825. consulted again for a newer price. Otherwise, the old price is still
  826. considered to be fresh enough.
  827. Alias for
  828. .Fl \-leeway .
  829. .It Fl \-prices-format Ar FMT
  830. Set the format for the
  831. .Ic prices
  832. report.
  833. .It Fl \-pricedb-format Ar FMT
  834. Set the format expected for the historical price file.
  835. .It Fl \-primary-date
  836. Show primary dates for all calculations. Alias for
  837. .Fl \-actual-dates
  838. .It Fl \-quantity Pq Fl O
  839. Report commodity totals (this is the default).
  840. .It Fl \-quarterly
  841. Shorthand for
  842. .Fl \-period Ar quarterly .
  843. .It Fl \-raw
  844. In the
  845. .Ic print
  846. report, show transactions using the exact same syntax as
  847. specified by the user in their data file. Don't do any massaging or
  848. interpreting. Can be useful for minor cleanups, like just aligning
  849. amounts.
  850. .It Fl \-real Pq Fl R
  851. Account using only real transactions ignoring virtual and automatic
  852. transactions.
  853. .It Fl \-recursive-aliases
  854. Causes
  855. .Nm
  856. to try to expand aliases recursively, i.e. try to expand
  857. the result of an earlier expansion again, until no more expansions apply.
  858. .It Fl \-register-format Ar FMT
  859. Define the output format for the
  860. .Ic register
  861. report.
  862. .It Fl \-related Pq Fl r
  863. In a register report show the related account. This is the other
  864. .Em side
  865. of the transaction.
  866. .It Fl \-related-all
  867. Show all postings in a transaction, similar to
  868. .Fl \-related
  869. but show both sides of each transaction.
  870. .It Fl \-revalued
  871. Report discrepancy in values for manual reports by inserting
  872. <Revalued>
  873. postings.
  874. This is implied when using
  875. the
  876. .Fl \-exchange Pq Fl X
  877. or
  878. .Fl \-market Pq Fl V
  879. option.
  880. .It Fl \-revalued-only
  881. Show only
  882. <Revalued>
  883. postings.
  884. .It Fl \-revalued-total
  885. Display the sum of the revalued postings as the running total, which serves
  886. to show unrealized capital in a gain/losses report.
  887. .It Fl \-rich-data
  888. When generating a ledger transaction from a CSV file using the
  889. .Ic convert
  890. command, add CSV, Imported, and UUID meta-data.
  891. .It Fl \-seed Ar INT
  892. Set the random seed to
  893. .Ar INT
  894. for the
  895. .Ic generate
  896. command. Used as part of development testing.
  897. .It Fl \-script Ar FILE
  898. Execute a
  899. .Nm
  900. script.
  901. .It Fl \-sort Ar EXPR Pq Fl S
  902. Sort the register report based on the value expression
  903. .Ar EXPR .
  904. .\".It Fl \-sort-all Ar EXPR
  905. .It Fl \-sort-xacts
  906. Sort the posting within transactions using the given value expression.
  907. .It Fl \-start-of-week Ar STR
  908. Use
  909. .Ar STR
  910. as the particular day of the week to start when using the
  911. .Fl \-weekly
  912. option.
  913. .Ar STR
  914. can be day names, their abbreviations like
  915. .Qq Mon ,
  916. or the weekday number
  917. starting at 0 for Sunday.
  918. .It Fl \-strict
  919. Accounts, tags or commodities not previously declared will cause warnings.
  920. .It Fl \-subtotal Pq Fl s
  921. Report register as a single subtotal.
  922. .It Fl \-tail Ar INT
  923. Report only the last
  924. .Ar INT
  925. entries. Only useful on a register report. Alias for
  926. .Fl \-last Ar INT
  927. .It Fl \-time-colon
  928. Display the value for commodities based on seconds as hours and minutes.
  929. Thus 8100s will be displayed as 2:15h instead of 2.25h.
  930. .It Fl \-time-report
  931. Add two columns to the
  932. .Ic balance
  933. report to show the earliest checkin and checkout times for timelog entries.
  934. .It Fl \-total Ar EXPR Pq Fl T
  935. Define a value expression used to calculate the total in reports.
  936. .It Fl \-total-data Pq Fl J
  937. Show only dates and totals to format the output for plots.
  938. .It Fl \-total-width Ar INT
  939. Set the width of the total field in the register report.
  940. .It Fl \-trace Ar INT
  941. Enable tracing. The
  942. .Ar INT
  943. specifies the level of trace desired.
  944. .It Fl \-truncate Ar STR
  945. Indicates how truncation should happen when the contents of columns
  946. exceed their width. Valid arguments for
  947. .Ar STR
  948. are
  949. .Ar leading ,
  950. .Ar middle ,
  951. and
  952. .Ar trailing .
  953. The default is smarter than any of these three,
  954. as it considers sub-names within the account name (that style is
  955. called
  956. .Qq abbreviate ) .
  957. .It Fl \-unbudgeted
  958. Show only un-budgeted postings.
  959. .It Fl \-uncleared Pq Fl U
  960. Use only uncleared transactions in calculations and reports.
  961. .It Fl \-unrealized
  962. Show generated unrealized gain and loss accounts in the balance
  963. report.
  964. .It Fl \-unrealized-gains
  965. Allow the user to specify what account name should be used for
  966. unrealized gains. Defaults to
  967. .Sy "Equity:Unrealized Gains" .
  968. Often set in one's
  969. .Pa ~/.ledgerrc
  970. file to change the default.
  971. .It Fl \-unrealized-losses
  972. Allow the user to specify what account name should be used for
  973. unrealized losses. Defaults to
  974. .Sy "Equity:Unrealized Losses" .
  975. Often set in one's
  976. .Pa ~/.ledgerrc
  977. file to change the default.
  978. .It Fl \-unround
  979. Perform all calculations without rounding and display results to full
  980. precision.
  981. .It Fl \-values
  982. Show the values used by each tag when used in combination with the
  983. .Ic tags
  984. command.
  985. .It Fl \-value-expr Ar EXPR
  986. Set a global value expression annotation.
  987. .It Fl \-verbose
  988. Print detailed information on the execution of
  989. .Nm .
  990. .It Fl \-verify
  991. Enable additional assertions during run-time. This causes a significant
  992. slowdown. When combined with
  993. .Fl \-debug Ar CODE
  994. .Nm
  995. will produce memory trace information.
  996. .It Fl \-verify-memory
  997. Verify that every constructed object is properly destructed. This is for
  998. debugging purposes only.
  999. .It Fl \-version
  1000. Print version information and exit.
  1001. .It Fl \-weekly Pq Fl W
  1002. Shorthand for
  1003. .Fl \-period Ar weekly .
  1004. .It Fl \-wide Pq Fl w
  1005. Assume 132 columns instead of the TTY width.
  1006. .It Fl \-yearly Pq Fl Y
  1007. Shorthand for
  1008. .Fl \-period Ar yearly .
  1009. .El
  1010. .Sh PRE-COMMANDS
  1011. Pre-commands are useful when you aren't sure how a command or option
  1012. will work. The difference between a pre-command and a regular command
  1013. is that pre-commands ignore the journal data file completely, nor is
  1014. the user's init file read.
  1015. .Bl -tag -width -indent
  1016. .It Ic args No / Ic query
  1017. Evaluate the given arguments and report how
  1018. .Nm
  1019. interprets it against the following model transaction:
  1020. .Bd -literal -offset indent
  1021. 2004/05/27 Book Store
  1022. ; This note applies to all postings. :SecondTag:
  1023. Expenses:Books 20 BOOK @ $10
  1024. ; Metadata: Some Value
  1025. ; Typed:: $100 + $200
  1026. ; :ExampleTag:
  1027. ; Here follows a note describing the posting.
  1028. Liabilities:MasterCard $-200.00
  1029. .Ed
  1030. .It Ic eval
  1031. Evaluate the given value expression against the model transaction.
  1032. .It Ic format
  1033. Print details of how
  1034. .Nm
  1035. uses the given formatting description and
  1036. apply it against a model transaction.
  1037. .It Ic parse No / Ic expr
  1038. Print details of how
  1039. .Nm
  1040. uses the given value expression description
  1041. and apply it against a model transaction.
  1042. .It Ic generate
  1043. Randomly generates syntactically valid
  1044. .Nm
  1045. data from a seed. Used
  1046. by the GenerateTests harness for development testing.
  1047. .It Ic period
  1048. Evaluate the given period and report how
  1049. .Nm
  1050. interprets it.
  1051. .\".It Ic script
  1052. .It Ic template
  1053. Shows the insertion template that the
  1054. .Ic xact
  1055. command generates. This is a debugging command.
  1056. .El
  1057. .Sh QUERIES
  1058. The syntax for reporting queries can get somewhat complex. It is a series of
  1059. query terms with an implicit OR operator between them. The following terms
  1060. are accepted:
  1061. .Bl -tag -width "term and term"
  1062. .It Ar regex
  1063. A bare string is taken as a regular expression matching the full account name.
  1064. Thus, to report the current balance for all assets and liabilities, you would
  1065. use:
  1066. .Pp
  1067. .Dl ledger bal asset liab
  1068. .It Ic payee Ar regex Pq Ic \&@ Ns Ar regex
  1069. Query on the payee, rather than the account.
  1070. .It Ic tag Ar regex Pq Ic \&% Ns Ar regex
  1071. .It Ic note Ar regex Pq Ic \&= Ns Ar regex
  1072. Query on anything found in an item's note.
  1073. .It Ic code Ar regex Pq Ic \&# Ns Ar regex
  1074. Query on the xact's optional code (which can be any string the user wishes).
  1075. .It Ar term Cm and Ar term
  1076. Query terms are joined by an implicit OR operator. You can change this to AND
  1077. by using the
  1078. .Cm and
  1079. keyword. For example, to show food expenditures occurring at
  1080. Shakee's Pizza, you could say:
  1081. .Pp
  1082. .Dl Li ledger reg food and @Shakee
  1083. .It Ar term Cm or Ar term
  1084. When you wish to be more explicit, use the OR operator.
  1085. .It Ic show
  1086. .It Cm not Ar term
  1087. Reverse the logical meaning of the following term. This can be used with
  1088. parentheses to great effect:
  1089. .Pp
  1090. .Dl Li ledger reg food and @Shakee and not dining
  1091. .It \&( Ar term No \&)
  1092. If you wish to mix OR and AND operators, it is often helpful to surround
  1093. logical units with parentheses. \fBNOTE\fR: Because of the way some shells
  1094. interpret parentheses, you should always escape them:
  1095. .Pp
  1096. .Dl Li ledger bal \e( assets or liab \e) and not food
  1097. .El
  1098. .Sh EXPRESSIONS
  1099. .Bl -tag -width "partial_account"
  1100. .It Fn abs value
  1101. Return the absolute value of the given
  1102. .Ar value .
  1103. .It Sy account
  1104. Return the posting's account.
  1105. .It Sy account_base
  1106. Return the base account, i.e. everything after the last account delimiter ':'.
  1107. .\".It Sy account_amount
  1108. .It Sy actual
  1109. .\" Is there a difference between real and actual?
  1110. Return true if the transaction is real, i.e not a automated or virtual
  1111. transaction, false otherwise.
  1112. .It Sy amount
  1113. Return the amount of the posting.
  1114. .It Sy amount_expr
  1115. Return the calculated amount of the posting according to the
  1116. .Fl \-amount
  1117. option.
  1118. .It Fn ansify_if value color bool
  1119. Render the given
  1120. .Ar value
  1121. as a string, applying the proper ANSI escape codes to display it in the given
  1122. .Ar color
  1123. if
  1124. .Ar bool
  1125. is true. It typically checks the value of the option
  1126. .Fl \-color ,
  1127. for example:
  1128. .Dl Li ansify_if(amount, "blue", options.color)
  1129. .It Sy beg_line
  1130. Line number where entry for posting begins.
  1131. .It Sy beg_pos
  1132. Character position where entry for posting begins.
  1133. .\".It Sy calculated
  1134. .It Fn ceiling value
  1135. Return the next integer of
  1136. .Ar value
  1137. toward +infinity.
  1138. .It Sy cleared
  1139. Return true if the posting was cleared, false otherwise.
  1140. .It Sy code
  1141. Return the transaction code, the string between the parenthesis after the date.
  1142. .\".It Sy comment
  1143. .It Fn commodity value
  1144. Return the commodity of
  1145. .Ar value
  1146. or the posting amount when
  1147. .Ar value
  1148. was not specified.
  1149. .\".It Sy cost
  1150. .\".It Sy count
  1151. .It Sy date
  1152. Return the date of the posting.
  1153. .\".It Sy depth
  1154. .\".It Sy depth_spacer
  1155. .\".It Sy display_amount
  1156. .\".It Sy display_total
  1157. .It Sy end_line
  1158. Line number where entry for posting ends.
  1159. .It Sy end_pos
  1160. Character position where entry for posting ends.
  1161. .It Fn floor value
  1162. Return the next integer of
  1163. .Ar value
  1164. toward -infinity.
  1165. .It Sy filename
  1166. The name of the
  1167. .Nm
  1168. data file from whence the posting came.
  1169. .It Fn format string
  1170. Evaluate
  1171. .Ar string
  1172. as format just like the
  1173. .Fl \-format
  1174. option.
  1175. .It Fn format_date date format
  1176. Return the
  1177. .Ar date
  1178. as a string using
  1179. .Ar format .
  1180. Refer to
  1181. .Xr strftime 3
  1182. for format string details.
  1183. .It Fn format_datetime datetime format
  1184. Return the
  1185. .Ar datetime
  1186. as a string using
  1187. .Ar format .
  1188. Refer to
  1189. .Xr strftime 3
  1190. for format string details.
  1191. .It Fn get_at seq index
  1192. Return value at
  1193. .Ar index
  1194. from
  1195. .Ar seq .
  1196. Used internally to construct different reports.
  1197. .It Fn has_meta
  1198. Return true if the posting has metadata named
  1199. .Ar tag ,
  1200. false otherwise.
  1201. .It Fn has_tag tag
  1202. Return true if the posting has metadata named
  1203. .Ar tag ,
  1204. false otherwise.
  1205. .It Fn is_seq value
  1206. Return true if
  1207. .Ar value
  1208. is a sequence. Used internally.
  1209. .It Fn join value
  1210. Replace all newlines in
  1211. .Ar value
  1212. with
  1213. .Li \en .
  1214. .It Fn justify value first_width latter_width right_justify colorize
  1215. Right or left justify the string representing
  1216. .Ar value .
  1217. The width of the field in the first line is given by
  1218. .Ar first_width .
  1219. For subsequent lines the width is given by
  1220. .Ar latter_width .
  1221. If
  1222. .Ar latter_width
  1223. is -1,
  1224. .Ar first_width
  1225. is used for all lines.
  1226. If
  1227. .Ar right_justify
  1228. is true then the field is right justified within the width of the field. If it
  1229. is false, then the field is left justified and padded to the full width of the
  1230. field. If
  1231. .Ar colorize
  1232. is true, then ledger will honor color settings.
  1233. .It Fn market value datetime
  1234. Return the price of
  1235. .Ar value
  1236. at
  1237. .Ar datetime .
  1238. Note that
  1239. .Ar datetime
  1240. must be surrounded by brackets in order to be parsed correctly, e.g.
  1241. .Bq 2012/03/23 .
  1242. .It Fn meta
  1243. Return the value of metadata named
  1244. .Ar name .
  1245. .It Sy note
  1246. Return the note for the posting.
  1247. .It Sy now
  1248. Return the current datetime.
  1249. .\".It Sy null
  1250. .It Sy options
  1251. A variable that allows access to the values of the given command-line options
  1252. using the long option names, e.g. to see whether
  1253. .Fl \-daily Pq Fl D
  1254. was given use
  1255. .Sy option.daily .
  1256. .\" .It Sy partial_account
  1257. .It Sy payee
  1258. Return the payee of the posting.
  1259. .It Fn percent value_a value_b
  1260. Return the percentage of
  1261. .Ar value_a
  1262. in relation to
  1263. .Ar value_b
  1264. (used as 100%).
  1265. .It Sy pending
  1266. Return true if the posting is marked as pending, false otherwise.
  1267. .It Fn percent value_a value_b
  1268. Return the percentage of
  1269. .Ar value_a
  1270. in relation to
  1271. .Ar value_b .
  1272. .\".It Sy post
  1273. .\" A variable scope
  1274. .It Fn print value
  1275. Print
  1276. .Ar value
  1277. to stdout.
  1278. Used internally for debugging.
  1279. .It Fn quantity value
  1280. Return the quantity of
  1281. .Ar value
  1282. for values that have a per-unit cost.
  1283. .It Fn quoted expression
  1284. Surround
  1285. .Ar expression
  1286. with double-quotes.
  1287. .It Sy real
  1288. .\" Is there a difference between real and actual?
  1289. Return true if the transaction is real, i.e not a automated or virtual
  1290. transaction, false otherwise.
  1291. .\".It Sy rounded
  1292. .It Fn roundto value n
  1293. Return
  1294. .Ar value
  1295. rounded to
  1296. .Ar n
  1297. digits. Does not affect formatting.
  1298. .It Sy should_bold
  1299. Return true if expression given to
  1300. .Fl \-bold-if
  1301. evaluates to true. Internal use only!
  1302. .It Fn scrub value
  1303. Clean
  1304. .Ar value
  1305. using various transformations such as round,
  1306. stripping value annotations, and more.
  1307. .\".It Sy status
  1308. .It Fn strip value
  1309. Strip value annotation from
  1310. .Ar value .
  1311. .\".It Sy subcount
  1312. .It Fn tag name
  1313. Return the value of tag named
  1314. .Ar name .
  1315. .It Fn to_amount value
  1316. Convert
  1317. .Ar value
  1318. to an amount. Internal use only!
  1319. .It Fn to_balance value
  1320. Convert
  1321. .Ar value
  1322. to a balance. Internal use only!
  1323. .It Fn to_boolean value
  1324. Convert
  1325. .Ar value
  1326. to a boolean. Internal use only!
  1327. .It Fn to_date value
  1328. Convert
  1329. .Ar value
  1330. to a date. Internal use only!
  1331. .It Fn to_datetime value
  1332. Convert
  1333. .Ar value
  1334. to a datetime. Internal use only!
  1335. .It Fn to_int value
  1336. Return the integer value for
  1337. .Ar value .
  1338. .It Fn to_mask value
  1339. Convert
  1340. .Ar value
  1341. to a mask. Internal use only!
  1342. .It Fn to_sequence value
  1343. Convert
  1344. .Ar value
  1345. to a sequence. Internal use only!
  1346. .It Fn to_string value
  1347. Convert
  1348. .Ar value
  1349. to a character string.
  1350. .It Sy today
  1351. Return today's date.
  1352. .It Sy total
  1353. Return the total of the posting.
  1354. .It Sy total_expr
  1355. Return the calculated total of the posting according to the
  1356. .Fl \-total
  1357. option.
  1358. .It Fn trim value
  1359. Trim leading and trailing whitespace from
  1360. .Ar value .
  1361. .It Fn truncated string total_len account_len
  1362. Truncate
  1363. .Ar string
  1364. to
  1365. .Ar total_len
  1366. ensuring that each account is at least
  1367. .Ar account_len
  1368. long.
  1369. .\".It Sy uncleared
  1370. .It Sy virtual
  1371. Return true if the transaction is virtual, e.g automated, false otherwise.
  1372. .\".It Sy xact
  1373. .\" A variable scope
  1374. .El
  1375. .\".Sh ENTRIES
  1376. .\".Sh FORMATS
  1377. .Sh DEBUG COMMANDS
  1378. In addition to the regular reporting commands,
  1379. .Nm
  1380. also accepts several
  1381. debug commands:
  1382. .Bl -tag -width balance
  1383. .It Ic args Oo Ar report-query Oc
  1384. Display complete analysis of how
  1385. .Nm
  1386. interpreted the given
  1387. .Ar report-query .
  1388. Useful if you want to understand how report queries are translated into value
  1389. expressions.
  1390. .It Ic eval Oo Ar value-expression Oc
  1391. Evaluate the given
  1392. .Ar value-expression
  1393. and prints the result. For more on value expressions, see the section
  1394. .Sx EXPRESSIONS .
  1395. .It Ic format Oo Ar format-string Oc
  1396. Display an analysis of how
  1397. .Ar format-string
  1398. was parsed, and what it would look like applied to a sample transaction. For
  1399. more on format strings, see the section
  1400. .Sx FORMATS .
  1401. .It Ic generate
  1402. Generate 50 randomly composed yet valid
  1403. .Nm
  1404. transactions.
  1405. .It Ic parse Oo Ar value-expression Oc
  1406. Parse the given
  1407. .Ar value-expression
  1408. and display an analysis of the expression tree and its evaluated value. For
  1409. more on value expressions, see the section
  1410. .Sx EXPRESSIONS .
  1411. .It Ic python Oo Ar file Oc
  1412. Invoke a Python interpreter to read the given
  1413. .Ar file .
  1414. What is special about this is that the
  1415. .Nm
  1416. module is builtin, not read from
  1417. disk, so it doesn't require
  1418. .Nm
  1419. to be installed anywhere, or the shared
  1420. library variants to be built.
  1421. .It Ic reload
  1422. Reload all data files for the current session immediately.
  1423. Can only be used in the
  1424. .Tn REPL .
  1425. .It Ic template Oo Ar draft-template Oc
  1426. Display information about how
  1427. .Ar draft-template
  1428. was parsed. See the section on
  1429. .Sx DRAFTS .
  1430. .El
  1431. .Sh ENVIRONMENT
  1432. Every option to
  1433. .Nm
  1434. may be set using an environment variable if the option has a long name.
  1435. For example setting the environment variable
  1436. .Ev LEDGER_DATE_FORMAT="%d.%m.%Y'
  1437. will have the same effect as specifying
  1438. .Fl \-date-format Ar '%d.%m.%Y'
  1439. on the command-line. Options on the command-line always take precedence over
  1440. environment variable settings, however.
  1441. .Sh FILES
  1442. .Bl -tag -width -indent
  1443. .It Pa ~/.ledgerrc
  1444. Your personal
  1445. .Nm
  1446. initializations.
  1447. .El
  1448. .Sh SEE ALSO
  1449. .Xr beancount 1 ,
  1450. .Xr hledger 1
  1451. .Sh AUTHORS
  1452. .An "John Wiegley"
  1453. .Aq johnw@newartisans.com
  1454. .\" .Sh BUGS \" Document known, unremedied bugs
  1455. .\" .Sh HISTORY \" Document history if command behaves in a unique manner