packages feed

hledger-web-2.0: hledger-web.info

This is hledger-web.info, produced by makeinfo version 7.3 from stdin.

INFO-DIR-SECTION User Applications
START-INFO-DIR-ENTRY
* hledger-web: (hledger-web).  Web UI/API for the hledger accounting tool.
END-INFO-DIR-ENTRY


File: hledger-web.info,  Node: Top,  Next: OPTIONS,  Up: (dir)

hledger-web(1)
**************

hledger-web - web interface and API for 'hledger', a robust, friendly
plain text accounting app.

   'hledger-web [OPTS] [QUERY]'
or
'hledger web [OPTS] [QUERY]'

   This manual is for hledger's web interface, version 2.0.  See also
the hledger manual for common concepts and file formats.

   hledger is a robust, user-friendly, cross-platform set of programs
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), and largely interconvertible with
beancount(1).

   hledger-web is hledger's web interface.  In a web browser, it shows
the journal, account registers, and the main financial reports with
their charts, and lets you search them, add transactions, and (if
allowed) edit the journal files.  It shows more at once than the hledger
CLI or hledger-ui (eg the accounts beside a register, or a report's
chart above its table), and every view has its own url, so it can be
bookmarked or shared.

   hledger-web also lets you share a journal with multiple users, or
even the public web.  There is no user authentication, so if you need
that you should put it behind a suitable web proxy (see Permissions).

   Like hledger, it reads from (and appends to) a journal file specified
by the 'LEDGER_FILE' environment variable (defaulting to
'$HOME/.hledger.journal'); or you can specify files with '-f' options.
It can also read timeclock files, timedot files, or any CSV/SSV/TSV file
with a date field.  (See hledger(1) -> Input for details.)

   hledger-web can be run in three modes:

   * '--serve-browse' mode (the default): the app serves the web UI and
     JSON API, and opens your default web browser to show the app if
     possible, and exits automatically once no browser window has shown
     it for fifteen minutes.

   * '--serve': the app just serves the web UI and JSON API.

   * '--serve-api': the app just serves the JSON API.

   In all cases hledger-web runs as a foreground process, logging
requests to stdout.

* Menu:

* OPTIONS::
* WEB UI::
* PERMISSIONS::
* EDITING UPLOADING DOWNLOADING::
* REPORTS::
* URL PARAMETERS::
* RELOADING::
* JSON API::
* DEBUG OUTPUT::
* LANGUAGE::
* ENVIRONMENT::
* BUGS::


File: hledger-web.info,  Node: OPTIONS,  Next: WEB UI,  Prev: Top,  Up: Top

1 OPTIONS
*********

hledger-web provides the following command line options:

Flags:
     --serve-browse            server mode: serve the web UI and JSON API,
                               and open a browser, and exit if inactive for 15m
                               (default)
     --serve                   server mode: just serve the web UI and JSON
                               API
     --serve-api               server mode: just serve the JSON API
     --allow=view|add|edit     set the user's access level for changing data
                               (default: `add` on a local-only address, `view`
                               otherwise). It also accepts `sandstorm` for that
                               platform (reading from the
                               `X-Sandstorm-Permissions` request header).
     --cors=ORIGIN             allow cross-origin requests from the specified
                               origin; setting ORIGIN to "*" allows requests
                               from any origin
     --host=IPADDR             listen on this IP address (default: 127.0.0.1)
     --port=PORT               listen on this TCP port (default: 5000); 0
                               means a free port chosen by the OS
     --socket=SOCKET           listen on the given unix socket instead of an
                               IP address and port (only on unix)
     --base-url=BASEURL        set the base url (default: http://IPADDR:PORT)
     --chart[=KIND,net,SCALE]  set the charts' defaults, as the commands'
                               --chart does. KIND: lay out the statements'
                               charts with each period's sections in one bar,
                               above and below zero (diverging, the default),
                               or side by side (grouped). net: show the net
                               total lines by default (the N key toggles them,
                               and the browser remembers that). SCALE: the
                               amount that fills the charts (eg 1000 or 1000
                               USD; one per commodity), for comparable charts.
     --lang=LANG               show the web UI in this language (en, de, es,
                               ru, zh); or with auto, use each viewer's browser
                               language if available, otherwise the server's.
                               (Default: the browser's language if available,
                               otherwise en.)

   By default hledger-web listens only on IP address '127.0.0.1', which
can be accessed only from the local machine.

   To allow access from elsewhere, use '--host' to specify an externally
accessible address configured on this machine.  The special address
'0.0.0.0' causes it to listen on all of this machine's addresses.

   Similarly, you can use '--port' to listen on a TCP port other than
5000.  This is useful if you want to run multiple hledger-web instances
on a machine.  '--port 0' makes the operating system choose a free port,
which is reported in the startup message and in the default base url,
and is where the browser is opened in '--serve-browse' mode.  This can
be useful eg when scripting.

   When '--socket' is used, hledger-web creates and communicates via a
socket file instead of a TCP port.  This can be more secure, respects
unix file permissions, and makes certain use cases easier, such as
running per-user instances behind an nginx reverse proxy.  (Eg:
'proxy_pass http://unix:/tmp/hledger/${remote_user}.socket;'.)

   You can use '--base-url' to change the protocol, hostname, port and
path that appear in hledger-web's hyperlinks.  This is useful eg when
integrating hledger-web within 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).  Note this affects url generation
but not route parsing.

   hledger-web also supports many of hledger's general options:

General input flags:
  -f --file=[FMT:]FILE      Use this as the journal file (- means stdin). If
                            not specified, $LEDGER_FILE or ~/.hledger.journal
                            will be used. If specified more than once, the
                            files will be read in order. Each file's format
                            (journal, csv, timeclock, timedot, rules..) is
                            inferred from the file extension or a FMT: prefix.
                            Some commands (add, import) write to the (first)
                            file, and expect it to be in journal format.
     --rules=RULESFILE      Use rules defined in this rules file for
                            converting subsequent CSV/SSV/TSV files. If not
                            specified, uses FILE.csv.rules for each FILE.csv.
     --alias=A=B|/RGX/=RPL  transform account names from A to B, or by
                            replacing regular expression matches
     --auto                 generate extra postings by applying auto posting
                            rules ("=") to all transactions
     --forecast[=PERIOD]    Generate extra transactions from periodic rules
                            ("~"), from after the latest ordinary transaction
                            until 6 months from now. Or, during the specified
                            PERIOD (the equals is required). Auto posting rules
                            will also be applied to these transactions. In
                            hledger-ui, also make future-dated transactions
                            visible at startup.
     --ignore-assertions    don't check balance assertions by default
     --ignore-lots          don't track lots: skip lot checks, inferred cost
                            bases and gain postings
  -I                        shortcut for --ignore-assertions --ignore-lots
     --txn-tolerance=...    how much imbalance to allow in transactions:
                            'entry':   - the entry's precision (default)
                            'display': - display precision (legacy)
     --infer-costs          infer costs from conversion equity postings
     --infer-equity         infer conversion equity postings from costs
     --infer-imbalance      add postings showing tolerated imbalances
     --infer-market-prices  infer market prices from costs
     --pivot=TAGNAME        use a different field or tag as account names
  -s --strict               do extra error checks (and override -I)

General output flags (affecting some commands):
  -b --begin=DATE           include postings/transactions on/after this date
  -e --end=DATE             include postings/transactions before this date
                            (with a report interval, will be adjusted to
                            following subperiod end)
  -D --daily                set report interval: 1 day
  -W --weekly               set report interval: 1 week
  -M --monthly              set report interval: 1 month
  -Q --quarterly            set report interval: 1 quarter
  -Y --yearly               set report interval: 1 year
  -p --period=PERIODEXP     set begin date, end date, and/or report interval,
                            with more flexibility
     --today=DATE           override today's date (affects relative dates)
     --date2                match/use secondary dates instead (deprecated)
  -U --unmarked             include only unmarked postings/transactions
  -P --pending              include only pending postings/transactions
  -C --cleared              include only cleared postings/transactions
                            (-U/-P/-C can be combined)
  -R --real                 include only non-virtual postings
  -E --empty                Show zero items, which are normally hidden.
                            In hledger-ui & hledger-web, do the opposite.
     --depth=DEPTHEXP       if a number (or -NUM): show only top NUM levels
                            of accounts. If REGEXP=NUM, only apply limiting to
                            accounts matching the regular expression.
  -B --cost                 convert amounts to their cost basis ({}), or else
                            their cost/sale amount (@/@@)
  -V --market               valuation mode: show amounts converted to market
                            value at period end(s) in their default valuation
                            commodity. Short for --value=end.
  -X --exchange=COMM        valuation mode: show amounts converted to market
                            value at period end(s) in the specified commodity.
                            Short for --value=end,COMM.
     --value=WHEN[,COMM]    valuation mode: show amounts converted to market
                            value on the specified date(s) in their default
                            valuation commodity or a specified commodity. WHEN
                            can be:
                            'then':     value on transaction dates
                            'end':      value at period end(s)
                            'now':      value today
                            YYYY-MM-DD: value on given date
                            'cost':     cost basis, or else transacted cost
                            (same as -B)
                            'transacted': transacted cost/sale amount (@/@@)
                            only
                            COMM may be written in double quotes; '""' or an
                            empty COMM means the no-symbol commodity.
     --lots                 show lot subaccounts and other lot details
  -c --commodity-style=S    Override a commodity's display style.
                            Eg: -c '.' or -c '1.000,00 EUR'
     --pretty[=YN]          Use box-drawing characters in text output? The
                            optional 'y'/'yes' or 'n'/'no' arg requires =.
     --title=T              set or customise a report title
     --subreport-titles=TS  customise subreport headings in compound reports
                            (|-separated)
     --period-titles=OPT    customise headings in periodic reports:
                            'compact': readable period names when possible
                            'dates':   exact dates/date ranges always

General help flags:
  -?                        show the hledger quick reference
  -h --help                 show this command's usage help
     --info                 show this command's manual with info
     --man                  show this command's manual with man
     --webman               show this command's manual on the web
     --examples             show examples for this command
     --version              show version information
     --test[=PATTERN]       run built-in tests (those matching PATTERN) and
                            exit
     --write-lang=LANG      write LANG's PO file to the config directory, for
                            editing translations, and exit
     --debug=[1-9]          show this much debug output (default: 1)
     --pager=YN             use a pager when needed ? y/yes (default) or n/no
     --color=YNA --colour   use ANSI color ? y/yes, n/no, or auto (default)

   Some of these can be adjusted while hledger-web is running, in the
web UI's Options panel.

   hledger-web shows accounts with zero balances by default (like
'hledger-ui', and unlike 'hledger'); '-E/--empty' starts it with them
hidden instead.  In the web UI, the Zero balances option or the 'z' key
shows or hides them.  (The holdings page differs: its closed positions
are hidden by default, as in the 'holdings' command; '-E' starts it with
them shown, and 'z' there shows or hides them.)

   Report options and a query given at startup set the view hledger-web
opens with, by putting them in its url (see URL parameters).  Eg
'hledger-web -V -M' opens '/balancesheet?interval=monthly&value=end',
and 'hledger-web --cleared -3 assets' opens '/balancesheet?q=assets
status:*&depth=3'.  They are only a starting point: they can be changed
in the web UI, and they don't affect other urls or the JSON API. Report
options that hledger-web has no equivalent for are ignored.

   Note, a startup query doesn't restrict what hledger-web serves; to do
that, give it a file holding only the entries to serve (eg one written
by 'hledger print QUERY').

   If you use the bash shell, you can auto-complete flags by pressing
TAB in the command line.  If this is not working see Install > Shell
completions.


File: hledger-web.info,  Node: WEB UI,  Next: PERMISSIONS,  Prev: OPTIONS,  Up: Top

2 WEB UI
********

hledger-web's main views are:

   * the *journal view*, showing journal entries, newest first, with
     their postings
   * the *report views*, described below: the balance sheet, income
     statement, cashflow statement (and holdings, for journals using
     lots), and All accounts report
   * a *register view* for each account, reached by clicking an account
     name, showing the transactions affecting that account (and its
     subaccounts), with a running balance and a balance chart.

   Every page has, from the top: links to the journal and the reports,
the search form, the options, and then the view itself.  The options are
hidden until you open them (click Options, or press 'o'); while hidden,
they list the ones in effect, eg "Monthly · Depth 2 · Tree".

   The journal and register show the newest 1000 matching transactions,
with links to older and newer pages.  When the transactions span more
than one year, the options include a row of years, to narrow the view to
one year; shift-click a second year to select a range of years.

   The register's chart shows the running balance over the page's
transactions.  With several commodities, use the legend, or the '[' and
']' keys, to choose the one charted.  Click a point to go to its
transaction, or drag across the chart to see the transactions of those
dates.  The register's Costs option shows the costs recorded with its
amounts.

   The *sidebar* lists every account, and optionally their balances
(parent balances include subaccounts).  The search doesn't change it,
except that its dates set the balances' date.  The balances are hidden
at first, since on a large journal they take much of each page's time;
click the "Balances" heading above the accounts to show them, or to hide
them again.  These are historical balances, as of the end of the report
period set by date:, otherwise the latest (the heading shows the date).
While the balances are hidden, all accounts are listed, even with Zero
balances: Hidden.  It is always a tree, with carets that fold and open
each group, whether the Accounts option is List or Tree.  The − and +
above it fold or open a level of the whole tree, without changing the
page; its depth is its own, apart from the page's depth limit.  The
browser remembers the sidebar's depth and the groups you open or close
(until the next − or +).  The button at the top left (or the 's' key)
shows or hides the sidebar, and it stays the way you left it from page
to page.  On a narrow screen, it slides the sidebar in or out.

   Click an account name to see its register, with the search, or an
amount to see the transactions it is made of.  In the journal and
register, click a date to see that day's journal entries.

   The *search form* filters every view with hledger's query syntax, eg
'expenses date:thismonth'; the help dialog summarises the query types.
The search and the options are part of the page's url (see URL
parameters).

   The *add form* (press 'a', or click "Add a transaction" in the
journal view) adds a transaction to the main journal file, if the access
level allows it, and if the journal would still be readable with it
added (see Editing, uploading, downloading).  It autocompletes account
names and descriptions from your existing entries.

   The *help dialog* (press '?', or click the question mark button)
lists these keyboard shortcuts, which work when you are not typing in a
field:

   * 'h' or '?' - show or hide the help dialog
   * 'g' - go to another page: shows a menu of the pages, each with its
     key; then 'j' journal, 'b' balance sheet, 'i' income statement, 'c'
     cashflow statement, 'h' holdings (for journals using lots), 'a' all
     accounts (escape to cancel)
   * 'n' / 'p' - go to the next / previous page, in the 'g' menu's
     order, wrapping round
   * 'a' - add a transaction (escape to cancel)
   * 's' - show or hide the sidebar
   * shift with '1'-'9' - fold or open the sidebar's accounts to that
     depth, as its − and + do (by the digit keys' place, whatever the
     layout; except where shift with one types a character that is a
     shortcut itself, eg a digit on AZERTY keyboards, or '/' on German
     ones)
   * 'b' - show or hide the sidebar's balances, as its Balances heading
     does (while the sidebar shows)
   * 'o' - show or hide the report options
   * 'c' - show or hide the report's chart (on pages with one)
   * '[' / ']' - chart the previous / next commodity (on pages whose
     chart has several, wrapping round)
   * 'N' - show or hide the chart's net total line (on pages whose chart
     has one)
   * 'd' - show or hide the report's data, its table (on pages with a
     chart)
   * 'f' - full window: show only the report's heading and data, or
     everything ('s', 'o' and '/' leave it, showing what they ask for)
   * 'z' - show or hide accounts with zero balances (on the holdings
     page: closed positions)
   * 't' - show accounts as a tree, or a list
   * 'H' - show ending balances, or balance changes
   * 'L' - show or hide lot detail
   * 'V' - show amounts at market value, or as recorded
   * 'B' - show amounts at cost, or as recorded
   * 'R' - show only real postings, or all
   * 'U', 'P', 'C' - show only unmarked, pending, or cleared
     transactions, or all
   * 'S' - sort by amount, or by account
   * 'T', 'A' - add or remove the row total and average columns
     (multi-period reports)
   * 'D', 'W', 'M', 'Q', 'Y' - set the report interval (daily, weekly,
     monthly, quarterly, yearly); pressed again, remove it
   * '0'-'9', '-', '+' - set or adjust the account depth limit ('-' and
     '+' step between 0 and the deepest)
   * '/' - focus the search form, ready to add a term (escape to leave
     it)
   * 'Delete' or 'Backspace' - clear the search, as its clear button
     does

   The pages are light or dark, following your OS or browser's color
scheme setting, and switch when it changes.

   Editing, uploading and downloading journal files is described below.


File: hledger-web.info,  Node: PERMISSIONS,  Next: EDITING UPLOADING DOWNLOADING,  Prev: WEB UI,  Up: Top

3 PERMISSIONS
*************

You can restrict who can access hledger-web by

   * setting the IP address it listens on (see '--host' above).  By
     default it listens on 127.0.0.1, accessible to users on the local
     machine only.
   * or by putting it behind an authenticating proxy, such as caddy or
     apache
   * or by putting it behind a firewall.

   And you can restrict what the users reaching it can do, by specifying
the '--allow=ACCESSLEVEL' option at startup.  ACCESSLEVEL is one of:

   * 'view' - allows viewing the journal file(s)
   * 'add' - also allows adding new transactions to the main journal
     file
   * 'edit' - also allows editing, uploading or downloading the journal
     file(s)
   * 'sandstorm' - (for the hledger-web Sandstorm app:) allows whichever
     of 'view', 'add', or 'edit' are specified in the
     'X-Sandstorm-Permissions' HTTP header

   The default access level is 'add' when listening on a local-only
address ('127.0.0.1', '::1', 'localhost', or a unix socket), and 'view'
otherwise.  To allow more than the default access, start it with an
explicit '--allow=add' or '--allow=edit' option.


File: hledger-web.info,  Node: EDITING UPLOADING DOWNLOADING,  Next: REPORTS,  Prev: PERMISSIONS,  Up: Top

4 EDITING, UPLOADING, DOWNLOADING
*********************************

If you start hledger-web with '--allow=edit', 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
visitor) can alter or wipe the data files.  Before saving an edited or
uploaded file, hledger-web saves a numbered backup of it (eg
'main.journal.1', then 'main.journal.2'); if the backup can't be
written, the file is not changed.  (Adding a transaction appends it to
the main journal file without making a backup.)  hledger-web is not
aware of version control systems, currently; if you use one, you'll have
to arrange to commit the changes yourself.

   Changes which would leave the journal unreadable are refused, and the
file is not changed.  This applies to edits, uploads and added
transactions.  Each change is checked as the next read of the journal
will check it, in the context of all the journal's files and with the
options hledger-web was started with: so transactions must balance,
balance assertions must pass (unless started with '-I'), lots must be
valid, and with '--strict', the strict checks must pass too.


File: hledger-web.info,  Node: REPORTS,  Next: URL PARAMETERS,  Prev: EDITING UPLOADING DOWNLOADING,  Up: Top

5 REPORTS
*********

Besides the journal and the account registers, hledger-web shows these
reports.  The sidebar and the links at the top of every page lead to
each of them, and so does the 'g' key followed by the first letter of
the report's name:

   * *Balance sheet* ('b', '/balancesheet'): assets, liabilities and net
     worth, like the balancesheet command.  Its Equity option adds an
     equity section, like balancesheetequity.
   * *Income statement* ('i', '/incomestatement'): revenues, expenses
     and net income, like incomestatement.
   * *Cashflow* ('c', '/cashflow'): changes in cash accounts, like
     cashflow.
   * *Holdings* ('h', '/holdings'): investments and their performance,
     like holdings.  Shown only for journals that use lots; see below.
   * *All accounts* ('a', '/balance'): all accounts, or those you search
     for, like balance.

   Each report shows a chart and then a table (by default; both can be
toggled).  Click any amount to see the transactions it is made of.

* Menu:

* Options::
* Charts::
* From a report to its transactions::
* Holdings::


File: hledger-web.info,  Node: Options,  Next: Charts,  Up: REPORTS

5.1 Options
===========

A report's options (click Options, or press 'o') change what it shows.
These are similar to hledger's command-line options and hledger-ui's
keys.  The main ones, with their keyboard shortcuts:

   * *Interval* ('D', 'W', 'M', 'Q', 'Y'): one column for the whole
     period, or one per day, week, month, quarter or year (see Report
     intervals).  Until you choose one, the reports pick an interval to
     suit the period shown (except holdings, whose interval is its own;
     see Holdings): monthly for up to two years, quarterly for up to
     six, yearly beyond.  Click a column's heading to see the report for
     just its dates.
   * *Show* ('H'): balance changes in each period, or ending balances
     (which include everything before the period).  The balance sheet
     shows ending balances by default and the other reports show
     changes, as their commands do; the report's heading says which it
     is showing.
   * *Depth* ('0'-'9', '-', '+'): how many levels of accounts to show
     (see Depth).  Depth 0 shows only the totals.  Until you choose one,
     the depth is 1, the top-level accounts.  The − and + beside the
     table's Account heading step it too.  In tree mode they fold or
     open a level of the whole tree.  (The sidebar has a depth of its
     own; see above.)
   * *Accounts* ('t'): a list, or a tree with subtotals; the List and
     Tree links beside the table's Account heading switch too.  In a
     tree, the accounts below the depth limit are folded, and their
     carets open them in place (at depth 0, all of them, under each
     section's total).
   * *Amounts* ('B', 'V'): as recorded, at cost, or at market value at
     the end of each period (see Cost reporting and Value reporting).
   * *Zero balances* ('z'): hide or show accounts whose balance is zero.
     (On the holdings page, 'z' toggles Closed positions instead; use
     this option's links there.)
   * *Equity* (balance sheet only): hide or show the equity section.
     The browser remembers this choice for each hledger-web server.
   * *Status* ('U', 'P', 'C'), *Postings* ('R'), account types, and
     commodities: show only transactions with that status, only real
     postings, or only some account types or commodities.  These rows
     edit the search, adding a term like 'status:*' or 'type:A'.
     Shift-click selects several types or commodities.

   The options you choose stay in effect as you move to other pages,
except Show, which each report sets to its own default.  On the journal
and register, the report options are shown muted, but are kept.

   The search form filters reports as it does the other pages, and its
'date:' terms set the report's dates.  An interval or depth typed in the
search, like 'date:monthly' or 'depth:2', moves into the options when
the page reloads.  A depth limit for some accounts only, like
'depth:assets=3', stays in the search.

   The options are also URL parameters, so you can bookmark a report
with them.

   (For more detail, see the hledger manual, eg CONCEPTS.)


File: hledger-web.info,  Node: Charts,  Next: From a report to its transactions,  Prev: Options,  Up: REPORTS

5.2 Charts
==========

A report's chart is the one its command draws with '--chart': eg a bar
per account, or with an interval, each account over time, and for the
statements, each section and the net total.  In tree mode it shows the
accounts down to the depth limit.  With several commodities, use the
legend, or the '[' and ']' keys, to choose the one charted.  The Balance
page's and statements' charts stack each period's accounts (or sections)
in one bar, above and below zero; the Chart row in Options (or
'--chart=grouped' at startup) shows a bar per account type (or section),
side by side, instead (on the Balance page with no interval, for the
whole period, as 'balance --chart=grouped' does).  '--chart' at startup
takes the same value as the commands' '--chart'; its SCALE amounts fix
the scales of the report and register charts, so that they can be
compared.  Hover over a bar or a line (or on a touch screen, tap it) to
see its period (or date, or account), its series and its amount.  Charts
are drawn as wide as the page shows them, and redrawn when that changes,
eg when you hide or show the sidebar or resize the window.

   The 'c' key hides or shows the chart, and 'd' the table (the report's
data).  You can also click the Chart and Data buttons at their top right
corners, whose carets show whether they are shown.  The 'N' key shows or
hides the net total line (or marks), eg a statement's net, or holdings'
value or net gain; this is hidden at first, leaving the bars it totals
(or with '--chart=net' at startup, shown at first).  The browser
remembers this for each hledger-web server, and once you have chosen
with 'N', your choice wins over '--chart=net'.


File: hledger-web.info,  Node: From a report to its transactions,  Next: Holdings,  Prev: Charts,  Up: REPORTS

5.3 From a report to its transactions
=====================================

Click an amount to see its account's register for that period: the
transactions the amount is made of.  An ending balance's register starts
with the balance brought forward, so its final running balance is that
amount.  A section's total shows the register of all the section's
accounts.  An amount shown at cost or market value leads to a register
showing its amounts the same way.

   Some things can make the register look different from the report:

   * The statements show liabilities, equity and revenues as positive
     amounts, as their commands do, so their registers show the same
     amounts negated.  The amount's tooltip says so.
   * When a posting has a date of its own, the report counts it on that
     date, but the register lists its whole transaction, on the
     transaction's date.


File: hledger-web.info,  Node: Holdings,  Prev: From a report to its transactions,  Up: REPORTS

5.4 Holdings
============

The holdings report shows one row for each commodity held in each
account, with its cost basis, value and gains.  Its chart has a bar for
each one, showing its cost basis and unrealised gain or loss.  Its own
options can show:

   * each lot separately (*Lots*, 'L'),
   * fully disposed positions and their realised gains (*Closed
     positions*, 'z'),
   * all values in the market valuation commodity (*Values*).

   Closed positions are hidden by default, as in the 'holdings' command,
but the totals' RGain and XIRR always include them; a note below the
table says how many are hidden, with a link to show them.

   Its depth limit doesn't fold accounts: as on the command line, it
merges the deeper accounts' positions, by commodity, into the accounts
at the limit.

   With an *Interval* chosen (it picks none by itself), it shows how
your holdings changed, like holdings with a report interval: a row for
each period's end, with the totals of all the holdings then, and a bar
for each in the chart.  Each row's date links to the holdings on that
date.  This page's interval is its own, since it makes a different
report here: choosing one doesn't change the other reports' interval,
nor theirs this page's, and an interval given at startup (eg '-M') is
theirs.  Its *Gains* option chooses what the gain columns cover: each
period, the time since the report's start date, or the time since
acquisition (the default).  With the first two, the chart shows those
gains: realised, and unrealised (hatched).  'H' toggles between gains
since acquisition and gains in each period.

   On journals that use lots, every page also has a Lots option, showing
lot subaccounts and per-lot postings.


File: hledger-web.info,  Node: URL PARAMETERS,  Next: RELOADING,  Prev: REPORTS,  Up: Top

6 URL PARAMETERS
****************

A page's url includes its search and options, so a bookmark or a shared
link shows the same view.  You can also write these urls yourself, eg
'/balancesheet?interval=monthly&depth=2' or
'/register?account=assets:bank'.  These are the parameters, most
corresponding to hledger options:

   * 'q' - the search
   * 'account' - the account whose register to show (with its
     subaccounts, unless 'subs=0')
   * 'page' - which page of transactions to show, in the journal and
     register (1 is the newest)
   * 'interval' - 'daily', 'weekly', 'monthly', 'quarterly' or 'yearly'
     (like '-D', '-W', '-M', '-Q', '-Y'), or 'none' for one column;
     without it the reports pick one
   * 'hinterval' - the holdings page's own interval, in the same words;
     without it, none
   * 'depth' - a number (like '--depth'), or 'all' for no limit; without
     it, 1
   * 'accum' - 'change', 'historical' or 'cumulative' (like '--change',
     '-H', '--cumulative'); on the holdings page, with an interval, what
     the gains cover
   * 'value' - 'none', 'cost', or 'then', 'end', 'now' or a date,
     optionally followed by ',COMMODITY' (like '--value')
   * 'infer' - '1' to infer market prices from transaction costs too
     (like '--infer-market-prices')
   * 'empty' - '1' to show zero balances, '0' to hide them (like '-E')
   * 'list' - 'tree' or 'flat' (like '--tree', '--flat')
   * 'sort' - 'amount' (like '-S')
   * 'total', 'avg', 'pct' - '1' to add totals, averages, or show
     percentages (like '-T', '-A', '-%')
   * 'calc' - 'valuechange', 'gain' or 'count' (like '--valuechange',
     '--gain', '--count')
   * 'date2' - '1' to use secondary dates (like '--date2')
   * 'costs' - '1' to show costs, in the register
   * 'equity' - '1' or '0', on the balance sheet (the old
     '/balancesheetequity' address leads to 'equity=1')
   * 'lots' - '1' to show lots (like '--lots')
   * 'closed' - '1', on the holdings page, to show closed positions, '0'
     to hide them
   * 'chart' - 'grouped', on the Balance and statement pages, to chart
     each period's account types (or sections) side by side (like
     '--chart=grouped')


File: hledger-web.info,  Node: RELOADING,  Next: JSON API,  Prev: URL PARAMETERS,  Up: Top

7 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 until the
file has been fixed.

   (If you are viewing files mounted from another machine, make sure
that both machines have roughly the same idea of what time it is.)


File: hledger-web.info,  Node: JSON API,  Next: DEBUG OUTPUT,  Prev: RELOADING,  Up: Top

8 JSON API
**********

In addition to the web UI, hledger-web also serves a JSON API that can
be used to get data or add new transactions.  If you want the JSON API
only, you can use the '--serve-api' flag.  Eg:

$ hledger-web -f examples/sample.journal --serve-api
...

   You can get JSON data from these routes:

/version
/accountnames
/transactions
/prices
/commodities
/accounts
/accounttransactions/ACCOUNTNAME
/openapi.json

   Eg, all account names in the journal (similar to the accounts
command).  (hledger-web's JSON does not include newlines, here we use
python to prettify it):

$ curl -s http://127.0.0.1:5000/accountnames | python3 -m json.tool
[
    "assets",
    "assets:bank",
    "assets:bank:checking",
    "assets:bank:saving",
    "assets:cash",
    "expenses",
    "expenses:food",
    "expenses:supplies",
    "income",
    "income:gifts",
    "income:salary",
    "liabilities",
    "liabilities:debts"
]

   Or all transactions:

$ curl -s http://127.0.0.1:5000/transactions | python3 -m json.tool
[
    {
        "tcode": "",
        "tcomment": "",
        "tdate": "2008-01-01",
        "tdate2": null,
        "tdescription": "income",
        "tindex": 1,
        "tpostings": [
            {
                "paccount": "assets:bank:checking",
                "pamount": [
                    {
                        "acommodity": "$",
                        "acost": null,
                        "acostbasis": null,
...

   Most of the JSON corresponds to hledger's data types; for details of
what the fields mean, see the Hledger.Data.Json haddock docs and click
on the various data types, eg Transaction.  And for a higher level
understanding, see the journal docs.  There is also a basic OpenAPI
specification, also served at '/openapi.json'.

   Some routes return a report type wrapping the data; eg
'/accounttransactions' returns an AccountTransactionsReport, a report
title and a list of items.  The handlers in Hledger.Web.Handler.MiscR
show what each route returns.

   You can add a new transaction to the journal with a PUT request to
'/add', if hledger-web was started with '--allow=add' (the default when
listening on a local-only address).  The payload must be the full, exact
JSON representation of a hledger transaction (partial data won't do).
The journal must still be readable with the transaction added, with
hledger-web's startup options (see Editing, uploading, downloading); if
not, the response has status 400 and the error message, and the journal
is not changed.  You can get sample JSON from hledger-web's
'/transactions' or '/accounttransactions', or from hledger's print
command.  Eg, this saves the first transaction of the sample journal to
'txn.json':

$ hledger -f examples/sample.journal print -O json | python3 -c 'import json,sys; json.dump(json.load(sys.stdin)[0], sys.stdout, indent=4)' > txn.json

   Here's how it looks (remember, this JSON corresponds to hledger's
Transaction and related data types):

{
    "tcode": "",
    "tcomment": "",
    "tdate": "2008-01-01",
    "tdate2": null,
    "tdescription": "income",
    "tindex": 1,
    "tpostings": [
        {
            "paccount": "assets:bank:checking",
            "pamount": [
                {
                    "acommodity": "$",
                    "acost": null,
                    "acostbasis": null,
                    "aquantity": {
                        "decimalMantissa": 1,
                        "decimalPlaces": 0,
                        "floatingPoint": 1
                    },
                    "astyle": {
                        "ascommodityside": "L",
                        "ascommodityspaced": false,
                        "asdecimalmark": ".",
                        "asdigitgroups": null,
                        "asprecision": 0,
                        "asrounding": "NoRounding"
                    }
                }
            ],
            "pbalanceassertion": null,
            "pcomment": "",
            "pdate": null,
            "pdate2": null,
            "poriginal": null,
            "preal": "RealPosting",
            "pstatus": "Unmarked",
            "ptags": [],
            "ptransaction_": "1"
        },
        {
            "paccount": "income:salary",
            "pamount": [
                {
                    "acommodity": "$",
                    "acost": null,
                    "acostbasis": null,
                    "aquantity": {
                        "decimalMantissa": -1,
                        "decimalPlaces": 0,
                        "floatingPoint": -1
                    },
                    "astyle": {
                        "ascommodityside": "L",
                        "ascommodityspaced": false,
                        "asdecimalmark": ".",
                        "asdigitgroups": null,
                        "asprecision": 0,
                        "asrounding": "NoRounding"
                    }
                }
            ],
            "pbalanceassertion": null,
            "pcomment": "",
            "pdate": null,
            "pdate2": null,
            "poriginal": null,
            "preal": "RealPosting",
            "pstatus": "Unmarked",
            "ptags": [],
            "ptransaction_": "1"
        }
    ],
    "tprecedingcomment": "",
    "tsourcepos": [
        {
            "sourceColumn": 1,
            "sourceLine": 31,
            "sourceName": "/home/user/hledger/examples/sample.journal"
        },
        {
            "sourceColumn": 1,
            "sourceLine": 34,
            "sourceName": "/home/user/hledger/examples/sample.journal"
        }
    ],
    "tstatus": "Unmarked",
    "ttags": []
}

   And here's how to add it with curl.  This should append a new entry
to your journal file:

$ curl http://127.0.0.1:5000/add -X PUT -H 'Content-Type: application/json' --data-binary @txn.json


File: hledger-web.info,  Node: DEBUG OUTPUT,  Next: LANGUAGE,  Prev: JSON API,  Up: Top

9 DEBUG OUTPUT
**************

You can add '--debug[=N]' to the command line to log debug output.  N
ranges from 1 (least output, the default) to 9 (maximum output).
Typically you would start with 1 and increase until you are seeing
enough.  Debug output goes to stderr, interleaved with the requests
logged on stdout.  To capture debug output in a log file instead, you
can usually redirect stderr, eg:
'hledger-web --debug=3 2>hledger-web.log'.


File: hledger-web.info,  Node: LANGUAGE,  Next: ENVIRONMENT,  Prev: DEBUG OUTPUT,  Up: Top

10 LANGUAGE
***********

hledger-web's pages can be shown in another language when a translation
catalog is available (see Languages in the hledger manual).

   When hledger-web is started with '--lang LANG', eg '--lang de', every
page is in that language, whatever the browser asks for.  So you can use
hledger-web in a language other than your browser's, or give every user
of a shared server the same language.

   Otherwise the language is chosen per request, and the first of these
naming an available translation wins:

  1. a '_LANG' query parameter, eg '?_LANG=de'.  This choice is
     remembered in a '_LANG' cookie.
  2. the '_LANG' cookie
  3. the browser's 'Accept-Language' header, ie the browser's or
     system's language settings

   If none does, pages are in English, or with '--lang auto', in the
language of hledger-web's environment.  So viewers usually get their
browser's language automatically, if hledger-web has it.  Catalogs,
including any in the config directory, are loaded when hledger-web
starts.


File: hledger-web.info,  Node: ENVIRONMENT,  Next: BUGS,  Prev: LANGUAGE,  Up: Top

11 ENVIRONMENT
**************

*LEDGER_FILE* The main journal file to use when not specified with
'-f/--file'.  Default: '$HOME/.hledger.journal'.


File: hledger-web.info,  Node: BUGS,  Prev: ENVIRONMENT,  Up: Top

12 BUGS
*******

We welcome bug reports in the hledger issue tracker
(https://bugs.hledger.org), or on the hledger chat or mail list
(https://hledger.org/support).

   Some known issues:

   Without JavaScript (eg in text-mode browsers), pages can be viewed
and their links followed, but the add form, help dialog, keyboard
shortcuts, sidebar toggle and folding don't work.


Tag Table:
Node: Top223
Node: OPTIONS2577
Node: WEB UI15201
Node: PERMISSIONS21325
Node: EDITING UPLOADING DOWNLOADING22579
Node: REPORTS23966
Node: Options25177
Node: Charts28323
Node: From a report to its transactions30122
Node: Holdings31121
Node: URL PARAMETERS32942
Node: RELOADING35215
Node: JSON API35781
Node: DEBUG OUTPUT41753
Node: LANGUAGE42292
Node: ENVIRONMENT43417
Node: BUGS43651

End Tag Table


Local Variables:
coding: utf-8
End: