packages feed

hledger-web-1.52: 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 1.52.  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 a simple web application for browsing and adding
transactions.  It provides a more user-friendly UI than the hledger CLI
or hledger-ui TUI, showing more at once (accounts, the current account
register, balance charts) and allowing history-aware data entry,
interactive searching, and bookmarking.

   hledger-web also lets you share a journal with multiple users, or
even the public web.  There is no access control, so if you need that
you should put it behind a suitable web proxy.  As a small protection
against data loss when running an unprotected instance, it writes a
numbered backup of the main journal file (only) on every edit.

   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 after two minutes of inactivity
     (with no requests received and no open browser windows viewing it).

   * '--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::
* PERMISSIONS::
* EDITING UPLOADING DOWNLOADING::
* RELOADING::
* JSON API::
* DEBUG OUTPUT::
* ENVIRONMENT::
* BUGS::


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

1 OPTIONS
*********

hledger-web provides the following options:

Flags:
     --serve --server       serve and log requests, don't browse or auto-exit
     --serve-api            like --serve, but serve only the JSON web API,
                            not the web UI
     --allow=view|add|edit  set the user's access level for changing data
                            (default: `add`). It also accepts `sandstorm` for
                            use on that platform (reads permissions 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)
     --socket=SOCKET        listen on the given unix socket instead of an IP
                            address and port (unix only; implies --serve)
     --base-url=BASEURL     set the base url (default: http://IPADDR:PORT)
     --test                 run hledger-web's tests and exit. hspec test
                            runner args may follow a --, eg: hledger-web --test
                            --help

   By default hledger-web listens only on IP address '127.0.0.1', which
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.

   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/data transformation flags:
  -f --file=[FMT:]FILE      Read data from FILE, or from stdin if FILE is -,
                            inferring format from extension or a FMT: prefix.
                            Can be specified more than once. If not specified,
                            reads from $LEDGER_FILE or $HOME/.hledger.journal.
     --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.
  -I --ignore-assertions    don't check balance assertions by default
     --txn-balancing=...    how to check that transactions are balanced:
                            'old':   use global display precision
                            'exact': use transaction precision (default)
     --infer-costs          infer conversion equity postings from costs
     --infer-equity         infer costs from conversion equity postings
     --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)
     --verbose-tags         add tags indicating generated/modified data

General output/reporting flags (supported by 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                multiperiod report with 1 day interval
  -W --weekly               multiperiod report with 1 week interval
  -M --monthly              multiperiod report with 1 month interval
  -Q --quarterly            multiperiod report with 1 quarter interval
  -Y --yearly               multiperiod report with 1 year interval
  -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                 show amounts converted to their cost/sale amount
  -V --market               Show amounts converted to their value at period
                            end(s) in their default valuation commodity.
                            Equivalent to --value=end.
  -X --exchange=COMM        Show amounts converted to their value at period
                            end(s) in the specified commodity.
                            Equivalent to --value=end,COMM.
     --value=WHEN[,COMM]    show amounts converted to their 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
  -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? Can be
                            'y'/'yes' or 'n'/'no'.
                            If YN is specified, the equals is required.

General help flags:
  -h --help                 show command line help
     --tldr                 show command examples with tldr
     --info                 show the manual with info
     --man                  show the manual with man
     --version              show version information
     --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)

   hledger-web shows accounts with zero balances by default (like
'hledger-ui', and unlike 'hledger').  Using the '-E/--empty' flag will
reverse this behaviour.  If you see accounts which appear to have a zero
balance, but cannot be hidden with '-E', it's because they have a
mixed-cost balance, which looks like zero when costs are hidden.
(hledger-web does not show costs.)

   Reporting options and/or query arguments can be used to set an
initial query, which although not shown in the UI, will restrict the
data shown (in addition to any search query entered in the UI).

   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: PERMISSIONS,  Next: EDITING UPLOADING DOWNLOADING,  Prev: OPTIONS,  Up: Top

2 PERMISSIONS
*************

By default, hledger-web allows anyone who can reach it to view the
journal and to add new transactions, but not to change existing data.

   You can restrict who can reach it, by

   * 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.
   * putting it behind an authenticating proxy, such as caddy or apache
   * 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'.


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

3 EDITING, UPLOADING, DOWNLOADING
*********************************

If you enable the 'manage' capability mentioned above, you'll see a new
"spanner" button to the right of the search form.  Clicking this will
let you edit, upload, or download the journal file or any files it
includes.

   Note, unlike any other hledger command, in this mode you (or any
visitor) can alter or wipe the data files.

   Normally whenever a file is changed in this way, hledger-web saves a
numbered backup (assuming file permissions allow it, the disk is not
full, etc.)  hledger-web is not aware of version control systems,
currently; if you use one, you'll have to arrange to commit the changes
yourself (eg with a cron job or a file watcher like entr).

   Changes which would leave the journal file(s) unparseable or
non-valid (eg with failing balance assertions) are prevented.
(Probably.  This needs re-testing.)


File: hledger-web.info,  Node: RELOADING,  Next: JSON API,  Prev: EDITING UPLOADING DOWNLOADING,  Up: Top

4 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.

   (Note: if you are viewing files mounted from another machine, make
sure that both machine clocks are roughly in step.)


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

5 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

   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 | python -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 | python -m json.tool
[
    {
        "tcode": "",
        "tcomment": "",
        "tdate": "2008-01-01",
        "tdate2": null,
        "tdescription": "income",
        "tindex": 1,
        "tpostings": [
            {
                "paccount": "assets:bank:checking",
                "pamount": [
                    {
                        "acommodity": "$",
                        "aismultiplier": false,
                        "aprice": 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.

   In some cases there is outer JSON corresponding to a "Report" type.
To understand that, go to the Hledger.Web.Handler.MiscR haddock and look
at the source for the appropriate handler to see what it returns.  Eg
for '/accounttransactions' it's getAccounttransactionsR, returning a
"'accountTransactionsReport ...'".  Looking up the haddock for that we
can see that /accounttransactions returns an AccountTransactionsReport,
which consists of a report title and a list of
AccountTransactionsReportItem (etc).

   You can add a new transaction to the journal with a PUT request to
'/add', if hledger-web was started with the 'add' capability (enabled by
default).  The payload must be the full, exact JSON representation of a
hledger transaction (partial data won't do).  You can get sample JSON
from hledger-web's '/transactions' or '/accounttransactions', or you can
export it with hledger-lib, eg like so:

.../hledger$ stack ghci hledger-lib
>>> writeJsonFile "txn.json" (head $ jtxns samplejournal)
>>> :q

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

{
    "tcomment": "",
    "tpostings": [
        {
            "pbalanceassertion": null,
            "pstatus": "Unmarked",
            "pamount": [
                {
                    "aprice": null,
                    "acommodity": "$",
                    "aquantity": {
                        "floatingPoint": 1,
                        "decimalPlaces": 10,
                        "decimalMantissa": 10000000000
                    },
                    "aismultiplier": false,
                    "astyle": {
                        "ascommodityside": "L",
                        "asdigitgroups": null,
                        "ascommodityspaced": false,
                        "asprecision": 2,
                        "asdecimalpoint": "."
                    }
                }
            ],
            "ptransaction_": "1",
            "paccount": "assets:bank:checking",
            "pdate": null,
            "ptype": "RegularPosting",
            "pcomment": "",
            "pdate2": null,
            "ptags": [],
            "poriginal": null
        },
        {
            "pbalanceassertion": null,
            "pstatus": "Unmarked",
            "pamount": [
                {
                    "aprice": null,
                    "acommodity": "$",
                    "aquantity": {
                        "floatingPoint": -1,
                        "decimalPlaces": 10,
                        "decimalMantissa": -10000000000
                    },
                    "aismultiplier": false,
                    "astyle": {
                        "ascommodityside": "L",
                        "asdigitgroups": null,
                        "ascommodityspaced": false,
                        "asprecision": 2,
                        "asdecimalpoint": "."
                    }
                }
            ],
            "ptransaction_": "1",
            "paccount": "income:salary",
            "pdate": null,
            "ptype": "RegularPosting",
            "pcomment": "",
            "pdate2": null,
            "ptags": [],
            "poriginal": null
        }
    ],
    "ttags": [],
    "tsourcepos": {
        "tag": "JournalSourcePos",
        "contents": [
            "",
            [
                1,
                1
            ]
        ]
    },
    "tdate": "2008-01-01",
    "tcode": "",
    "tindex": 1,
    "tprecedingcomment": "",
    "tdate2": null,
    "tdescription": "income",
    "tstatus": "Unmarked"
}

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

$ 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: ENVIRONMENT,  Prev: JSON API,  Up: Top

6 DEBUG OUTPUT
**************

* Menu:

* Debug output::


File: hledger-web.info,  Node: Debug output,  Up: DEBUG OUTPUT

6.1 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: ENVIRONMENT,  Next: BUGS,  Prev: DEBUG OUTPUT,  Up: Top

7 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

8 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:

   Does not work well on small screens, or in text-mode browsers.


Tag Table:
Node: Top223
Node: OPTIONS2575
Node: PERMISSIONS11473
Node: EDITING UPLOADING DOWNLOADING12623
Node: RELOADING13638
Node: JSON API14205
Node: DEBUG OUTPUT19854
Node: Debug output20006
Node: ENVIRONMENT20524
Node: BUGS20760

End Tag Table


Local Variables:
coding: utf-8
End: