### Check hledger Installation Status with hledger setup Source: https://github.com/simonmichael/hledger/blob/main/hledger/embeddedfiles/hledger.txt Run `setup` to verify your hledger installation. It checks various aspects of your setup, including version, path, configuration, and journal file integrity, providing helpful hints for any issues. ```bash $ hledger setup ``` -------------------------------- ### Valuation Print Examples Setup Source: https://github.com/simonmichael/hledger/blob/main/hledger/hledger.m4.md Journal data used to demonstrate the effect of --value options. ```journal P 2000-01-01 A 1 B P 2000-02-01 A 2 B P 2000-03-01 A 3 B P 2000-04-01 A 4 B 2000-01-01 (a) 1 A @ 5 B 2000-02-01 (a) 1 A @ 6 B 2000-03-01 (a) 1 A @ 7 B ``` -------------------------------- ### Create and compile a new hledger script Source: https://github.com/simonmichael/hledger/blob/main/bin/README.md Steps to copy the example script, install dependencies, and compile the new command. ```cli $ cd bin $ cp hledger-script-example.hs hledger-cmd.hs # replace cmd with your command name # edit hledger-cmd.hs, updating at least the command name and help $ stack install safe text # ensure the script's dependencies are installed $ hledger-cmd.hs --help cmd [OPTIONS] My new cmd command. ... $ stack ghc hledger-cmd.hs # optionally compile for faster startup/durability $ hledger cmd --help cmd [OPTIONS] My new cmd command. ... ``` -------------------------------- ### Install hledger from source with hledger-install Source: https://github.com/simonmichael/hledger/blob/main/hledger/embeddedfiles/DEMOS.md Downloads and executes the hledger-install script. Ensure the PATH is configured correctly after installation to allow the script to locate the installed stack. ```bash curl -O https://raw.githubusercontent.com/simonmichael/hledger/main/hledger-install/hledger-install.sh ls -l hledger-install.sh less hledger-install.sh bash hledger-install.sh ``` -------------------------------- ### Hledger-install script setup message clarification Source: https://github.com/simonmichael/hledger/blob/main/doc/CHANGES.md Clarifies some stack/cabal setup messages within the hledger-install script. ```bash hledger-install: clarify some stack/cabal setup messages ``` -------------------------------- ### Start hledger-web Service Source: https://github.com/simonmichael/hledger/blob/main/examples/systemd/readme.md Use this command to start the hledger-web service. Ensure the service file is correctly configured and placed. ```bash systemctl --user start hledger-web.service ``` -------------------------------- ### Get GHCI Prompt for hledger-ui Source: https://github.com/simonmichael/hledger/blob/main/doc/DEVWORKFLOWS.md Starts a GHCI session for the hledger-ui package. ```bash cd hledger-ui; stack ghci hledger-ui ``` -------------------------------- ### Simplified Rewrite Command Examples Source: https://github.com/simonmichael/hledger/blob/main/hledger/hledger.txt Concise examples of using hledger rewrite with specific queries and --add-posting arguments. ```bash $ hledger rewrite ^income --add-posting '(liabilities:tax) *.33' ``` ```bash $ hledger rewrite expenses:gifts --add-posting '(budget:gifts) *-1"' ``` ```bash $ hledger rewrite ^income --add-posting '(budget:foreign currency) *0.25 JPY; diversify' ``` -------------------------------- ### Run hledger-web from GHCI (Just) Source: https://github.com/simonmichael/hledger/blob/main/doc/CODE.md Starts the hledger-web server in developer mode from GHCI using 'just ghci-web'. This setup also interprets hledger-lib and hledger packages for quicker development cycles. ```cli $ just ghci-web ghci> :main --serve ``` -------------------------------- ### Configure PATH for Windows hledger Installation Source: https://github.com/simonmichael/hledger/blob/main/doc/ghtestbinnotes.md Set up a directory for installed binaries and add it to the user's PATH environment variable. This is a one-time setup for Windows. ```powershell mkdir -force $HOME\bin >$null $ENV:PATH += ";"+$HOME+"\bin" [Environment]::SetEnvironmentVariable("Path", [Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::User)+";"+$HOME+"\bin", [EnvironmentVariableTarget]::User) ``` -------------------------------- ### Get GHCI Prompt for hledger-web Source: https://github.com/simonmichael/hledger/blob/main/doc/DEVWORKFLOWS.md Starts a GHCI session for the hledger-web package. Ensure the current directory is correctly set for accessing static assets. ```bash cd hledger-web; stack ghci hledger-web ``` -------------------------------- ### Register command width examples Source: https://github.com/simonmichael/hledger/blob/main/doc/relnotes.md Examples of using the --width option to control column sizing in register reports. ```bash $ hledger reg # use terminal width on posix $ hledger reg -w 100 # width 100, equal description/account widths $ hledger reg -w 100,40 # width 100, wider description $ hledger reg -w $COLUMNS,100 # terminal width and set description width ``` -------------------------------- ### Get GHCI Prompt for hledger-lib Source: https://github.com/simonmichael/hledger/blob/main/doc/DEVWORKFLOWS.md Starts a GHCI session for the hledger-lib package. Changing into the package directory enables a custom .ghci script for a shorter prompt. ```bash cd hledger-lib; stack ghci hledger-lib ``` -------------------------------- ### Complete Multi-Lot Example Source: https://github.com/simonmichael/hledger/blob/main/examples/lots/export-lots-workflow/ledger-gains-howto.md A full example demonstrating opening balances, multiple lot purchases, and specific lot sales. ```ledger ; Account setup 2020-01-01 * Opening balances Assets:Brokerage:Cash $10000.00 Equity:OpeningBalances ; Buy lots 2023-01-15 * Buy AAPL lot 1 Assets:Brokerage:Stock 10 AAPL {$150.00} Assets:Brokerage:Cash 2023-06-01 * Buy AAPL lot 2 Assets:Brokerage:Stock 5 AAPL {$160.00} Assets:Brokerage:Cash ; Sell specific lot 2024-03-01 * Sell AAPL (short-term gain) ; Holding period: < 1 year Assets:Brokerage:Stock -10 AAPL {$150.00} @ $170.00 Assets:Brokerage:Cash $1700.00 Income:CapitalGains:ShortTerm ; Check remaining position ; Should show: 5 AAPL {$160.00} ``` -------------------------------- ### Hledger Configuration File Example Source: https://github.com/simonmichael/hledger/blob/main/doc/MOCKUPS.md Example of a hledger.conf file demonstrating default command-line arguments and custom command aliases. Supports TOML/INI-like syntax. ```toml # hledger.conf [defaults] # Set options/arguments to be always used with hledger commands. # Each line is: HLEDGERCMD ARGS, or: hledger ARGS hledger -f hledger.journal bal -M --flat -b lastmonth ui --watch web -V help --html [commands] # Define aliases for custom hledger commands. # Each line is: CMDALIAS = HLEDGERCMD ARGS assets = bal -M ^assets\b liab = bal -M ^liabilities\b # Or use colon, like make ? bs2: bs --no-total date:thisyear # Or just whitespace, like hledger csv rules ? smui ui ^sm\b # Allow arbitrary shell commands ? 2019: hledger -f 2019.journal jstatus: git status -sb -- *.journal # Allow multi-command shell scripts, with optional help string ? bsis: "Show monthly balance sheet and income statement" hledger bs -M echo hledger is -M echo ``` -------------------------------- ### Install hledger Executables with Cabal Source: https://github.com/simonmichael/hledger/blob/main/doc/DEVFAQ.md Install all hledger executables to ~/.cabal/bin using cabal. The 'all:exes' argument is required. ```cli $ cabal install all:exes ``` -------------------------------- ### Tag Matching Examples Source: https://github.com/simonmichael/hledger/blob/main/hledger/hledger.txt Examples of using tag queries with regular expressions for names and values. ```text tag:'^fullname$', tag:'^fullname$=^fullvalue$' ``` -------------------------------- ### Install hledger Executables with Stack Source: https://github.com/simonmichael/hledger/blob/main/doc/DEVFAQ.md Install the hledger executables to ~/.local/bin using stack. Ensure this directory is in your system's PATH. ```cli $ stack install ``` -------------------------------- ### hledger Register Command Examples Source: https://github.com/simonmichael/hledger/blob/main/hledger/embeddedfiles/hledger.txt Basic examples of using the hledger register command with different width settings. ```bash $ hledger reg ``` ```bash $ hledger reg -w 100 ``` ```bash $ hledger reg -w 100,40 ``` -------------------------------- ### Start hledger-web Source: https://github.com/simonmichael/hledger/blob/main/doc/tldr/hledger-web.md Launches the web application for local viewing and adding. ```bash hledger-web ``` -------------------------------- ### Configure Periodic Report Start Dates Source: https://github.com/simonmichael/hledger/blob/main/hledger/CHANGES.md Examples of adjusting start dates for periodic reports to maintain desired period boundaries. ```bash hledger reg -M -b 1/15 ``` ```bash ~ monthly from 2023-01-15 ``` ```bash -p 'weekly from 202304' ``` ```bash -p 'weekly from 20230403' ``` ```bash -M -b 2023/1/15 ``` ```bash -M -b 2023/1 ``` -------------------------------- ### GHC Debug Output Example Source: https://github.com/simonmichael/hledger/blob/main/doc/DEVFAQ.md Example output indicating that ghc-debug has started and is listening on a specific socket. This is shown when running hledger with the appropriate debug flag. ```cli Starting ghc-debug on socket: ... ``` -------------------------------- ### Display help Source: https://github.com/simonmichael/hledger/blob/main/doc/tldr/hledger-web.md Shows the command line help documentation. ```bash hledger-web --help ``` -------------------------------- ### Valuation CLI Examples Source: https://github.com/simonmichael/hledger/blob/main/hledger/hledger.m4.md CLI commands demonstrating balance reporting with valuation options. ```cli $ hledger -f t.j bal -N euros €100 assets:euros ``` ```cli $ hledger -f t.j bal -N euros -V -e 2016/11/4 $110.00 assets:euros ``` ```cli $ hledger -f t.j bal -N euros -V $103.00 assets:euros ``` -------------------------------- ### Get GHCI Prompt for hledger Source: https://github.com/simonmichael/hledger/blob/main/doc/DEVWORKFLOWS.md Starts a GHCI session for the hledger package. ```bash cd hledger; stack ghci hledger ``` -------------------------------- ### Month and Quarter smart dates Source: https://github.com/simonmichael/hledger/blob/main/hledger/hledger.txt Examples of smart date syntax for specifying the start of a month or quarter. ```text 2004-10 2004q3 q3 2004 ``` -------------------------------- ### Run Add-on Commands Source: https://github.com/simonmichael/hledger/blob/main/hledger/hledger.m4.md Examples of executing add-on commands directly or via the hledger wrapper. ```shell hledger-ui --watch ``` ```shell hledger ui --watch ``` -------------------------------- ### Example hledger Addon Script Source: https://github.com/simonmichael/hledger/blob/main/hledger/CHANGES.md A template script `hledger-addon-example.hs` provided as a starting point for developing hledger addons. ```haskell hledger-addon-example.hs ``` -------------------------------- ### Initialize and Configure Hledger Journal File Source: https://github.com/simonmichael/hledger/blob/main/hledger/embeddedfiles/hledger.txt Demonstrates the process of setting up a new journal file, initializing a Git repository for version control, and configuring the environment to use the new file. ```bash mkdir ~/finance cd ~/finance git init touch 2023.journal echo "export LEDGER_FILE=$HOME/finance/2023.journal" >> ~/.profile source ~/.profile hledger stats ``` -------------------------------- ### CSV Rule Regex for Date/Amount Matching Source: https://github.com/simonmichael/hledger/blob/main/hledger/hledger.txt Example of CSV rules matching specific amounts around the end or start of a month using regex. ```regex if %amount \b3\.99 ``` ```regex & %date (29|30|31|01|02|03)$ ``` -------------------------------- ### Install hledger and bin scripts Source: https://github.com/simonmichael/hledger/blob/main/bin/README.md Procedure for downloading the hledger repository, symlinking the bin directory, and updating the system PATH. ```cli # Go to wherever you keep financial files: $ cd ~/finance # Get the hledger repo # the fast way, without version control: $ curl -LOJ https://github.com/simonmichael/hledger/archive/refs/heads/main.zip && unzip hledger-main.zip && mv hledger-main hledger # or the slow way, with version control for easy diffing/updating/contributing # git clone https://github.com/simonmichael/hledger # Make a more convenient symlink to the bin directory: $ ln -s hledger/bin # Add the bin directory to your PATH. Eg as a bash user: $ echo "export PATH=$PATH:$PWD/bin" >>~/.bash_profile" $ export PATH=$PATH:$PWD/bin # Optionally, compile all haskell scripts for faster startup: $ cd hledger; bin/compile.sh # Optionally, install the python scripts: $ pip install -U hledger-utils $ pip install -U hledger-lots # Check that hledger's command list now includes the bin scripts. # Eg "check-fancyassertions" and "swap-dates" should be listed: $ hledger ``` -------------------------------- ### Start hledger-web server with host and port Source: https://github.com/simonmichael/hledger/blob/main/doc/tldr/hledger-web.md Configures the server to listen on a specific host and port. ```bash hledger-web --serve --host {{my.host.name}} --port 8000 ``` -------------------------------- ### Example Argument File for hledger Source: https://github.com/simonmichael/hledger/blob/main/hledger/embeddedfiles/hledger.txt Save command line options and arguments in a file for reuse. Each line represents an argument or option. Blank lines and lines starting with '#' are ignored. Options and values are joined by '='. Values can contain spaces without quotes. Use one less level of quoting than at the command line. ```shell # cash.args assets:cash assets:charles schwab:sweep cur:$ -c=$1. ``` -------------------------------- ### Valuation Print CLI Examples Source: https://github.com/simonmichael/hledger/blob/main/hledger/hledger.m4.md CLI commands demonstrating how --value and --cost affect printed output. ```cli $ hledger -f- print --cost 2000-01-01 (a) 5 B 2000-02-01 (a) 6 B 2000-03-01 (a) 7 B ``` ```cli $ hledger -f- print --value=end date:2000/01-2000/03 2000-01-01 (a) 2 B 2000-02-01 (a) 2 B ``` ```cli $ hledger -f- print --value=end 2000-01-01 (a) 3 B 2000-02-01 (a) 3 B 2000-03-01 (a) 3 B ``` ```cli $ hledger -f- print --value=now 2000-01-01 (a) 4 B 2000-02-01 (a) 4 B 2000-03-01 (a) 4 B ``` ```cli $ hledger -f- print --value=2000-01-15 2000-01-01 (a) 1 B 2000-02-01 (a) 1 B 2000-03-01 (a) 1 B ``` -------------------------------- ### Install Rustledger using Cargo Source: https://github.com/simonmichael/hledger/blob/main/examples/lots/export-lots-workflow/rustledger-gains-howto.md Install Rustledger using the Cargo package manager. Ensure you have Rust and Cargo installed. ```bash cargo install rustledger ``` -------------------------------- ### Install ghcup for hledger Source: https://github.com/simonmichael/hledger/blob/main/hledger/embeddedfiles/DEMOS.md Downloads and runs the ghcup installer. Note that this may install older versions of GHC and requires manual PATH configuration to locate cabal. ```bash curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org ``` -------------------------------- ### Access hledger help and documentation Source: https://github.com/simonmichael/hledger/blob/main/hledger/hledger.m4.md Use these commands to list available commands, view options, and access the manual. ```cli $ hledger # show available commands $ hledger --help # show common options $ hledger CMD --help # show CMD's options, common options and CMD's documentation ``` ```cli $ hledger help # show the hledger manual with info, man or $PAGER (best available) $ hledger help journal # show the journal topic in the hledger manual $ hledger help --help # find out more about the help command ``` -------------------------------- ### Example of an if table Source: https://github.com/simonmichael/hledger/blob/main/hledger/hledger.m4.md A practical example of an if table using a comma as a separator. ```rules if,account2,comment atm transaction fee,expenses:business:banking,deductible? check it %description groceries,expenses:groceries, ;; Comment line that desribes why this particular date is special 2023/01/12.*Plumbing LLC,expenses:house:upkeep,emergency plumbing call-out ``` -------------------------------- ### Install hledger with eget Source: https://github.com/simonmichael/hledger/blob/main/doc/ghtestbinnotes.md Use `eget` to conveniently download the correct hledger binaries for your machine. This is a recommended method if `eget` is available. ```bash eget simonmichael/hledger --pre-release --all ``` -------------------------------- ### Filtering Output Example Source: https://github.com/simonmichael/hledger/wiki/hledger-tags-tutorial Example output generated by filtering transactions. ```text 2016/10/31 Smiths Income:Treat -1 candy -1 candy 2016/10/31 Ms. Miller Income:Treat -1 candy -2 candy 2016/10/31 Mr. Freeman Income:Treat -3 candy -5 candy ``` ```text 2016/10/31 Reids Income:Treat -1 candy -1 candy ``` -------------------------------- ### Initialize and track changes with Git Source: https://github.com/simonmichael/hledger/wiki/Track-changes-with-version-control Initializes a repository and commits the initial journal file. ```bash git init && git add 2017.journal && git commit 2017.journal -m "first commit" ``` -------------------------------- ### Beancount Installation and Reporting Source: https://github.com/simonmichael/hledger/blob/main/examples/lots/export-lots-workflow/README.md Commands to install Beancount and generate holdings reports. ```bash pip install beancount==2.3.6 ``` ```bash bean-report vceb.beancount balances ``` ```bash bean-report vceb.beancount holdings ``` ```bash bean-report vceb-lotless.beancount holdings ``` -------------------------------- ### Negative Query Examples Source: https://github.com/simonmichael/hledger/blob/main/hledger/hledger.txt Examples of negating query terms using the not: prefix. ```text not:equity, not:desc:apple ``` -------------------------------- ### Hledger Sample Queries Source: https://github.com/simonmichael/hledger/blob/main/hledger/hledger.m4.md Example hledger commands to query timeclock data. These demonstrate how to check current balances, view sessions within a specific period, and summarize time by week. ```cli $ hledger -f sample.timeclock balance # current time balances ``` ```cli $ hledger -f sample.timeclock register -p 2009/3 # sessions in march 2009 ``` ```cli $ hledger -f sample.timeclock register -p weekly --depth 1 --empty # time summary by week ``` -------------------------------- ### Basic Amount Example in hledger Source: https://github.com/simonmichael/hledger/blob/main/hledger/embeddedfiles/hledger.txt A simple example of a numeric amount in hledger. ```plaintext 1 ``` -------------------------------- ### View manual Source: https://github.com/simonmichael/hledger/blob/main/doc/tldr/hledger-web.md Displays the manual in Info format. ```bash hledger-web --info ``` -------------------------------- ### Show Menu Screen by Default Source: https://github.com/simonmichael/hledger/blob/main/hledger-ui/test/uitest.md Launches hledger-ui with a sample journal file, displaying the main menu screen. The 'Cash accounts' option is pre-selected. ```bash $ hledger-ui -f sample.journal ──────────────────────────────── sample.journal ──────────────────────────────── Cash accounts # <- selected Balance sheet accounts Income statement accounts All accounts ``` -------------------------------- ### Mixed @ and @@ Journal Example Source: https://github.com/simonmichael/hledger/blob/main/doc/NOTE-amount-keys.md Example of mixed transaction notation in a journal file. ```journal assets:cash $100 @ €0.9 assets:cash $50 @@ €44 ``` -------------------------------- ### Display simplebench help Source: https://github.com/simonmichael/hledger/blob/main/doc/BENCHMARKS.md Display the help message for the simplebench tool to understand its options and usage. ```cli $ tools/simplebench -h tools/simplebench -h simplebench: at least one executable needed bench [-f testsfile] [-n iterations] [-p precision] executable1 [executable2 ...] Run some functional tests with each of the specified executables, where a test is "zero or more arguments supported by all executables", and report the best execution times. -f testsfile --testsfile=testsfile file containing tests, one per line, default: bench.tests -n iterations --iterations=iterations number of test iterations to run, default: 2 -p precision --precision=precision show times with this precision, default: 2 -v --verbose show intermediate results -h --help show this help Tips: - executables may have arguments if enclosed in quotes - tests can be commented out with # - results are saved in benchresults.{html,txt} ``` -------------------------------- ### Date Query Examples Source: https://github.com/simonmichael/hledger/blob/main/hledger/hledger.txt Examples of period expressions used with the date: query type. ```text date:2016, date:thismonth, date:2/1-2/15, date:2021-07-27..nextquarter. ``` -------------------------------- ### Complete Example with Multiple Lots and FIFO Booking Source: https://github.com/simonmichael/hledger/blob/main/examples/lots/export-lots-workflow/beancount-gains-howto.md A comprehensive example demonstrating the purchase of multiple stock lots and their subsequent sale using the FIFO (First-In, First-Out) booking method, automatically calculating short-term gains. ```beancount option "operating_currency" "USD" option "booking_method" "FIFO" 2020-01-01 open Assets:Brokerage:Cash USD 2020-01-01 open Assets:Brokerage:Stock AAPL 2020-01-01 open Income:CapitalGains:LongTerm USD 2020-01-01 open Income:CapitalGains:ShortTerm USD ; Buy lots 2023-01-15 * "Buy AAPL lot 1" Assets:Brokerage:Stock 10 AAPL {150.00 USD} Assets:Brokerage:Cash -1500.00 USD 2023-06-01 * "Buy AAPL lot 2" Assets:Brokerage:Stock 5 AAPL {160.00 USD} Assets:Brokerage:Cash -800.00 USD ; Sell - FIFO means lot 1 is sold first 2024-03-01 * "Sell AAPL (short-term gain)" Assets:Brokerage:Stock -10 AAPL {150.00 USD} @ 170.00 USD Assets:Brokerage:Cash 1700.00 USD Income:CapitalGains:ShortTerm -200.00 USD ; Check remaining position 2024-03-01 balance Assets:Brokerage:Stock 5 AAPL ``` -------------------------------- ### Timedot file structure examples Source: https://github.com/simonmichael/hledger/blob/main/hledger/hledger.m4.md Examples of how to structure data within a .timedot file. ```timedot * 2023 Work Diary ** Q1 *** 2023-02-29 **** DONE 0700 yoga **** UNPLANNED **** BEGUN hom:chores cleaning ... water plants outdoor - one full watering can indoor - light watering **** TODO adm:planning: trip *** LATER ``` ```timedot 2016/2/4 fos.hledger.timedot 4h fos.ledger .. ``` -------------------------------- ### Enable hledger-web on Boot Source: https://github.com/simonmichael/hledger/blob/main/examples/systemd/readme.md Enable the hledger-web service to automatically start on system boot. This requires the service file to be correctly set up in the systemd user directory. ```bash systemctl --user enable hledger-web.service ``` -------------------------------- ### Timedot format example Source: https://github.com/simonmichael/hledger/wiki/Use-another-account-separator-character An example of the timedot format using dot-separated account names. ```timedot 2016/2/4 fos.hledger.timedot 2 fos.ledger 1 ``` -------------------------------- ### Compare argument file usage with direct command line Source: https://github.com/simonmichael/hledger/wiki/Save-frequently-used-options Demonstrates how argument file contents are expanded into individual command-line arguments. ```shell $ hledger bal @simple.args ``` ```shell $ hledger bal "--alias=/:(business|personal):/=:" "--alias=/:(bank|cash|online):/=:" "--alias=/:bofi:/=:b" "--alias=/:unify:/=:u" "--alias=/:wf:/=:w" "-2" "cur:." ``` -------------------------------- ### Start hledger-web JSON API Source: https://github.com/simonmichael/hledger/blob/main/doc/tldr/hledger-web.md Starts the API in read-only mode on a specified host. ```bash hledger-web --serve-api --host {{my.host.name}} --allow view ``` -------------------------------- ### hledger demo command usage examples Source: https://github.com/simonmichael/hledger/blob/main/hledger/Hledger/Cli/Commands/Demo.txt Commands for listing available demos and playing specific demos with custom playback speeds. ```bash $ hledger demo # list available demos ``` ```bash $ hledger demo 1 # play the first demo at default speed (2x) ``` ```bash $ hledger demo install -s4 # play the "install" demo at 4x speed ``` -------------------------------- ### Install Rustledger using Homebrew Source: https://github.com/simonmichael/hledger/blob/main/examples/lots/export-lots-workflow/rustledger-gains-howto.md Install Rustledger on macOS using the Homebrew package manager. ```bash brew install rustledger ``` -------------------------------- ### Start hledger-web with JSON API enabled Source: https://github.com/simonmichael/hledger/blob/main/hledger-web/hledger-web.m4.md Use the `--serve-api` flag to enable the JSON API when starting hledger-web. This is useful if you only need API access and not the web UI. ```cli $ hledger-web -f examples/sample.journal --serve-api ... ``` -------------------------------- ### rustledger Installation and Reporting Source: https://github.com/simonmichael/hledger/blob/main/examples/lots/export-lots-workflow/README.md Commands to install rustledger and generate reports using its compatible tools. ```bash eget --all rustledger/rustledger --to /usr/local/bin ``` ```bash rbean-report vceb.beancount balances ``` ```bash rbean-report vceb.beancount holdings ``` ```bash rbean-report vceb-lotless.beancount holdings ``` -------------------------------- ### Complete Beancount File Example Source: https://github.com/simonmichael/hledger/blob/main/examples/lots/export-lots-workflow/rustledger-gains-howto.md This Beancount file demonstrates opening accounts, recording stock purchases with cost basis, selling stocks realizing short-term gains, and includes a balance assertion. It also shows how to enable plugins for tracking capital gains. ```beancount option "operating_currency" "USD" option "booking_method" "FIFO" plugin "beancount.plugins.sellgains" plugin "beancount.plugins.unrealized" "Unrealized" 2020-01-01 open Assets:Brokerage:Cash USD 2020-01-01 open Assets:Brokerage:Stock AAPL 2020-01-01 open Income:CapitalGains:LongTerm USD 2020-01-01 open Income:CapitalGains:ShortTerm USD ; Purchase lots 2023-01-15 * "Buy AAPL lot 1" Assets:Brokerage:Stock 10 AAPL {150.00 USD} Assets:Brokerage:Cash -1500.00 USD 2023-06-01 * "Buy AAPL lot 2" Assets:Brokerage:Stock 5 AAPL {160.00 USD} Assets:Brokerage:Cash -800.00 USD ; Sell - FIFO means lot 1 is sold first 2024-03-01 * "Sell AAPL (short-term gain)" Assets:Brokerage:Stock -10 AAPL {150.00 USD} @ 170.00 USD Assets:Brokerage:Cash 1700.00 USD Income:CapitalGains:ShortTerm -200.00 USD ; Balance assertion to verify 2024-03-01 balance Assets:Brokerage:Stock 5 AAPL ``` -------------------------------- ### Boolean Query Examples Source: https://github.com/simonmichael/hledger/blob/main/hledger/hledger.txt Examples of using boolean expressions with the expr: prefix to combine subqueries. ```text hledger print expr:'cash AND expenses' ``` ```text hledger print expr:'cash expenses' hledger print cash expenses ``` ```text expr:'date:lastmonth AND NOT (food OR rent)' ``` ```text hledger print expr:'cash and amt:>0' ``` -------------------------------- ### Query as command-line option Source: https://github.com/simonmichael/hledger/blob/main/hledger/hledger.m4.md Demonstrates using query terms as command-line options, such as depth:2 for --depth 2 and date:2023 for -p 2023. ```cli depth:2 ``` ```cli date:2023 ``` -------------------------------- ### Auto Posting Rule Examples Source: https://github.com/simonmichael/hledger/blob/main/hledger/hledger.txt Examples of rules for scheduling donations and managing budget subaccounts. ```hledger ; every time I buy food, schedule a dollar donation = expenses:food (liabilities:charity) $-1 ; when I buy a gift, also deduct that amount from a budget envelope subaccount = expenses:gifts assets:checking:gifts *-1 assets:checking *1 ``` -------------------------------- ### CSV Record Example Source: https://github.com/simonmichael/hledger/blob/main/hledger/CHANGES.md Example of a CSV record format used in hledger error reporting. ```text 2000-01-01,a,"1" ``` ```text the CSV record is: "2000-01-01", "a", "1" ``` -------------------------------- ### Initialize a new journal file Source: https://github.com/simonmichael/hledger/blob/main/hledger/hledger.txt Commands to create a new finance directory, initialize a git repository, and set the default journal file. ```bash $ hledger stats ``` ```bash $ mkdir ~/finance $ cd ~/finance $ git init Initialized empty Git repository in /Users/simon/finance/.git/ $ touch 2023.journal $ echo "export LEDGER_FILE=$HOME/finance/2023.journal" >> ~/.profile $ source ~/.profile $ hledger stats ```