├── .aspell.en.prepl ├── .aspell.en.pws ├── .editorconfig ├── .github ├── FUNDING.yaml └── workflows │ └── ci.yaml ├── .gitignore ├── .pyspelling.yaml ├── .yamllint ├── AUTHORS ├── Dockerfile ├── LICENSE ├── Makefile ├── README.md ├── bin ├── ledger2beancount └── ledger2beancount-ledger-config ├── cpanfile ├── devel ├── release-process.md └── spell-check ├── docs ├── authors.md ├── changelog.md ├── compatibility.md ├── configuration.md ├── contributing.md ├── features.md ├── guide.md ├── index.md ├── installation.md ├── ledger2beancount.1.scd ├── ledger2beancount.5.scd ├── license.md ├── limitations.md ├── tips.md └── usage.md ├── examples ├── illustrated.ledger ├── illustrated.yaml └── simple.ledger ├── ledger2beancount.yaml ├── misc └── initial-git-import.sh ├── mkdocs.yml ├── requirements.txt ├── tests ├── README.md ├── accounts.beancount ├── accounts.header ├── accounts.ledger ├── accounts.yaml ├── amounts-decimal-comma.beancount ├── amounts-decimal-comma.ledger ├── amounts-decimal-comma.yaml ├── amounts-plus-sign-decimal-comma.beancount ├── amounts-plus-sign-decimal-comma.hledger ├── amounts-plus-sign-decimal-comma.yaml ├── amounts-plus-sign.beancount ├── amounts-plus-sign.hledger ├── amounts.beancount ├── amounts.ledger ├── aux-date.beancount ├── aux-date.ledger ├── balance-assertion.beancount ├── balance-assertion.ledger ├── bug214.beancount ├── bug214.ledger ├── bug237.beancount ├── bug237.ledger ├── bug237.yaml ├── bug245.beancount ├── bug245.hledger ├── bug245.yaml ├── code.beancount ├── code.ledger ├── comments.beancount ├── comments.ledger ├── commodities.beancount ├── commodities.ledger ├── dates-month.beancount ├── dates-month.ledger ├── dates-month.yaml ├── dates.beancount ├── dates.ledger ├── dates.yaml ├── directives.beancount ├── directives.ledger ├── fixated.beancount ├── fixated.ledger ├── flags.beancount ├── flags.ledger ├── hledger.beancount ├── hledger.hledger ├── hledger.yaml ├── ignore.beancount ├── ignore.ledger ├── ignore.yaml ├── include1.beancount ├── include1.ledger ├── include2.beancount ├── include2.ledger ├── include3.beancount ├── include3.ledger ├── ledger2beancount.yaml ├── lots.beancount ├── lots.header ├── lots.ledger ├── lots.yaml ├── metadata.beancount ├── metadata.ledger ├── narration.beancount ├── narration.ledger ├── no-config.beancount ├── no-config.ledger ├── no-config.yaml ├── non-standard-account-root.beancount ├── non-standard-account-root.ledger ├── option-move_posting_tags.beancount ├── option-move_posting_tags.ledger ├── option-move_posting_tags.yaml ├── payee.beancount ├── payee.ledger ├── prices.beancount ├── prices.ledger ├── runtests ├── spacing.beancount ├── spacing.ledger ├── tags.beancount ├── tags.ledger ├── transactions.beancount ├── transactions.ledger ├── virtual-postings.beancount ├── virtual-postings.ledger └── virtual-postings.yaml └── themes └── versions.html /.aspell.en.prepl: -------------------------------------------------------------------------------- 1 | personal_repl-1.1 en 0 utf-8 2 | -------------------------------------------------------------------------------- /.aspell.en.pws: -------------------------------------------------------------------------------- 1 | personal_ws-1.1 en 80 utf-8 2 | AUR 3 | Alen 4 | Baier 5 | Blais 6 | CSV 7 | Creasy 8 | Daniele 9 | FileCopyrightText 10 | GBP 11 | GPL 12 | Goncharov 13 | Homebrew 14 | JPY 15 | Jelmer 16 | Kaleem 17 | Kirill 18 | Kurup 19 | MERCHANTABILITY 20 | Michlmayr 21 | Mohsin 22 | NetBSD 23 | Nicolodi 24 | PWD 25 | Pre 26 | Raufeisen 27 | Remco 28 | Rijnders 29 | SPDX 30 | Siljak 31 | Stefano 32 | Thierry 33 | Timeclock 34 | UI 35 | USD 36 | UTF 37 | Vernooij 38 | Vinod 39 | Wiegley 40 | XDG 41 | YAML 42 | Yaml 43 | Zacchiroli 44 | Zhuoyun 45 | auxdate 46 | backports 47 | beancount 48 | beancount's 49 | bratekarate 50 | config 51 | coreutils 52 | cpanminus 53 | documentclass 54 | faaafo 55 | fava 56 | hledger 57 | hledger's 58 | ledgerrc 59 | libstring 60 | macOS 61 | mefromthepast 62 | misparse 63 | modeline 64 | perl 65 | pkgsrc 66 | poptag 67 | pre 68 | pricedb 69 | pushtag 70 | scrartcl 71 | stdin 72 | stdout 73 | str 74 | toc 75 | txn 76 | uncomment 77 | undef 78 | urlcolor 79 | whitespace 80 | yaml 81 | yml 82 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig: http://EditorConfig.org 2 | 3 | # SPDX-FileCopyrightText: © 2018 Martin Michlmayr 4 | # 5 | # SPDX-License-Identifier: GPL-3.0-or-later 6 | 7 | # top-most EditorConfig file 8 | root = true 9 | 10 | [*] 11 | charset = utf-8 12 | end_of_line = lf 13 | insert_final_newline = true 14 | trim_trailing_whitespace = true 15 | 16 | [Makefile] 17 | indent_style = tab 18 | 19 | [*.bat] 20 | indent_size = 4 21 | indent_style = space 22 | 23 | [*.ledger] 24 | indent_size = 4 25 | indent_style = space 26 | 27 | [*.beancount] 28 | indent_size = 2 29 | indent_style = space 30 | 31 | [*.md] 32 | indent_size = 4 33 | indent_style = space 34 | 35 | [*.yaml] 36 | indent_style = space 37 | indent_size = 2 38 | max_line_length = off 39 | 40 | [tests/accounts.ledger] 41 | trim_trailing_whitespace = false 42 | 43 | [tests/aux-date.ledger] 44 | trim_trailing_whitespace = false 45 | 46 | [tests/comments.beancount] 47 | trim_trailing_whitespace = false 48 | 49 | [tests/comments.ledger] 50 | trim_trailing_whitespace = false 51 | 52 | [tests/metadata.ledger] 53 | trim_trailing_whitespace = false 54 | 55 | [tests/spacing.ledger] 56 | trim_trailing_whitespace = false 57 | 58 | -------------------------------------------------------------------------------- /.github/FUNDING.yaml: -------------------------------------------------------------------------------- 1 | github: tbm 2 | custom: ["https://paypal.me/MartinMichlmayr"] 3 | -------------------------------------------------------------------------------- /.github/workflows/ci.yaml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: © 2018 Stefano Zacchiroli 2 | # SPDX-FileCopyrightText: © 2018 Martin Michlmayr 3 | # 4 | # SPDX-License-Identifier: GPL-3.0-or-later 5 | on: 6 | - push 7 | - pull_request 8 | jobs: 9 | test: 10 | name: Unit Tests 11 | strategy: 12 | fail-fast: false 13 | matrix: 14 | os: 15 | - macos-latest 16 | - ubuntu-latest 17 | - windows-latest 18 | beancount: 19 | - "beancount>=2.3.3" 20 | - "git+https://github.com/beancount/beancount/@v2" 21 | runs-on: ${{ matrix.os }} 22 | steps: 23 | - uses: actions/checkout@v3 24 | - uses: actions/setup-python@v4 25 | with: 26 | python-version: "3.10" 27 | - if: matrix.os == 'ubuntu-latest' 28 | run: sudo apt install hledger ledger 29 | - if: matrix.os == 'macos-latest' 30 | run: brew install coreutils hledger ledger 31 | - if: matrix.os == 'windows-latest' 32 | run: choco install strawberryperl 33 | - uses: perl-actions/install-with-cpanm@v1.1 34 | with: 35 | cpanfile: "cpanfile" 36 | - run: pip install ${{ matrix.beancount }} 37 | - if: matrix.os != 'windows-latest' 38 | run: make test 39 | - if: matrix.os == 'windows-latest' 40 | run: make test 41 | env: 42 | PERL5BIN: C:\\strawberry\\perl\\bin\\perl 43 | docs: 44 | name: Documentation 45 | runs-on: ubuntu-latest 46 | steps: 47 | - uses: actions/checkout@v3 48 | - uses: actions/setup-python@v4 49 | - run: pip install -r requirements.txt 50 | - run: mkdocs build 51 | - run: find -name "*.yml" -exec yamllint -s {} \; 52 | - run: find -name "*.yaml" -exec yamllint -s {} \; 53 | - run: sudo apt-get install aspell aspell-en 54 | - run: pip install "pyspelling>=2.7" 55 | - run: pyspelling 56 | - run: pip install codespell 57 | - run: find \( -name "*.md" -or -name "*.scd" \) -exec codespell {} \; 58 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *-stamp 2 | docs/ledger2beancount.1 3 | docs/ledger2beancount.5 4 | docs/manual.pdf 5 | site 6 | -------------------------------------------------------------------------------- /.pyspelling.yaml: -------------------------------------------------------------------------------- 1 | spellchecker: aspell 2 | 3 | matrix: 4 | - name: markdown 5 | default_encoding: utf-8 6 | sources: 7 | - "**/*.md" 8 | pipeline: 9 | - pyspelling.filters.markdown: 10 | markdown_extensions: 11 | - markdown.extensions.extra: 12 | - pyspelling.filters.html: 13 | comments: true 14 | ignores: 15 | - code 16 | - pre 17 | - pyspelling.filters.url: 18 | aspell: 19 | lang: en 20 | d: en_GB 21 | dictionary: 22 | encoding: utf-8 23 | wordlists: 24 | - .aspell.en.pws 25 | -------------------------------------------------------------------------------- /.yamllint: -------------------------------------------------------------------------------- 1 | extends: default 2 | 3 | rules: 4 | document-start: disable 5 | line-length: disable 6 | truthy: disable 7 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Stefano Zacchiroli 2 | Martin Michlmayr 3 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | #------------------------ 2 | # From Linux base image 3 | # Update system 4 | # Install git 5 | FROM ubuntu:18.04 as step1 6 | RUN apt-get update -y \ 7 | && apt-get install --yes git 8 | 9 | #-------------------------- 10 | # Install compiler and Perl 11 | # Clean up temp files 12 | FROM step1 as step2-a 13 | RUN apt-get install --yes \ 14 | build-essential \ 15 | gcc-multilib \ 16 | apt-utils \ 17 | perl \ 18 | expat \ 19 | libexpat-dev \ 20 | locales \ 21 | cpanminus \ 22 | && apt-get clean && rm -rf /tmp/* /var/tmp/* 23 | 24 | #-------------------------------------------- 25 | # Get files directly from GitHub repository 26 | # so as to prevent LF errors due to Windows 27 | # For Linux: COPY . /usr/ledger2beancount 28 | FROM step1 as step2-b 29 | RUN git clone https://github.com/beancount/ledger2beancount.git /usr/ledger2beancount 30 | 31 | #-------------------------- 32 | # Merge step2-a and step2-b 33 | FROM step2-a as final 34 | COPY --from=step2-b /usr/ledger2beancount /usr/ledger2beancount 35 | 36 | #------------------------- 37 | # Install app dependencies 38 | WORKDIR /usr/ledger2beancount 39 | RUN cpanm --installdeps . 40 | 41 | #-------------------------- 42 | # Set environment variables 43 | # Fix Perl warnings 44 | ENV PATH="/usr/bin/perl:$PATH" 45 | RUN locale-gen "en_US.UTF-8" 46 | RUN update-locale "LANG=en_US.UTF-8" 47 | # RUN locale-gen --purge "en_US.UTF-8" 48 | # RUN dpkg-reconfigure --frontend noninteractive locales 49 | 50 | #------------------------------------- 51 | # Set default script and arguments 52 | # This can be overridden at runtime 53 | ENTRYPOINT [ "bin/ledger2beancount" ] 54 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: © 2016 Stefano Zacchiroli 2 | # SPDX-FileCopyrightText: © 2018 Martin Michlmayr 3 | # 4 | # SPDX-License-Identifier: GPL-3.0-or-later 5 | 6 | all: test docs 7 | 8 | L2C = bin/ledger2beancount 9 | TEST_DEPS = $(wildcard tests/*) $(L2C) 10 | 11 | test: test-stamp 12 | test-stamp: $(TEST_DEPS) 13 | cd tests && ./runtests 14 | touch $@ 15 | 16 | check: test 17 | 18 | docs/ledger2beancount.1: docs/ledger2beancount.1.scd 19 | scdoc < $< > $@ 20 | 21 | docs/ledger2beancount.5: docs/ledger2beancount.5.scd 22 | scdoc < $< > $@ 23 | 24 | docs/manual.pdf: docs/index.md docs/features.md docs/compatibility.md docs/installation.md docs/usage.md docs/configuration.md docs/guide.md docs/limitations.md docs/tips.md docs/changelog.md docs/contributing.md docs/authors.md docs/license.md 25 | pandoc -f markdown+definition_lists+backtick_code_blocks $^ -o $@ 26 | 27 | pdf: docs/manual.pdf 28 | 29 | man: docs/ledger2beancount.1 docs/ledger2beancount.5 30 | 31 | docs: pdf man 32 | 33 | clean: 34 | rm -f test-stamp docs/ledger2beancount.1 docs/ledger2beancount.5 docs/manual.pdf 35 | 36 | .PHONY: all check clean test pdf man docs 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/beancount/ledger2beancount.svg?branch=master)](https://travis-ci.org/beancount/ledger2beancount) 2 | 3 | 4 | # ledger2beancount 5 | 6 | A script to automatically convert [Ledger](https://www.ledger-cli.org/)-based 7 | textual ledgers to [Beancount](http://furius.ca/beancount/) ones. 8 | 9 | Conversion is based on (concrete) syntax, so that information that is not 10 | meaningful for accounting reasons but still valuable (e.g., comments, 11 | formatting, etc.) can be preserved. 12 | 13 | ledger2beancount supports the file formats from: 14 | 15 | * [ledger](https://ledger-cli.org/) 16 | * [hledger](https://hledger.org/) 17 | 18 | ## Usage 19 | 20 | ledger2beancount accepts input from `stdin` or from a file and will write 21 | the converted data to `stdout`. You can run ledger2beancount like this: 22 | 23 | ledger2beancount test.ledger > test.beancount 24 | 25 | 26 | ## Installation 27 | 28 | Please see [the installation information](docs/installation.md) for 29 | dependencies and installation instructions. 30 | 31 | ## Documentation 32 | 33 | ledger2beancount comes with extensive documentation. You can also [read 34 | the documentation online](https://ledger2beancount.readthedocs.io/) 35 | thanks to Read the Docs. 36 | 37 | ## Features 38 | 39 | The majority of features from ledger are supported by ledger2beancount. Here 40 | is an overview of fully supported, partly supported and unsupported features. 41 | Please refer to [the user guide](docs/guide.md) for more details on how to 42 | use ledger2beancount and to configure it to your needs. 43 | 44 | ### Fully supported 45 | 46 | * Accounts 47 | * Account declarations (`account ...`) 48 | * Conversion of invalid account names 49 | * Mapping of account names 50 | * Directive `apply account` 51 | * Account aliases (the `alias` directive and the `alias` sub-directive of `account` declarations) 52 | * Balance assignments 53 | * Balance assertions 54 | * Comments 55 | * Comments in and outside of transactions 56 | * Directives `comment` and `test` 57 | * Commodities 58 | * Commodity declarations (`commodity ...`) 59 | * Commodity symbols like `$`, `£` and `€` 60 | * Commodities placed in front and after the amount 61 | * Conversion of invalid commodities 62 | * Mapping of commodities 63 | * Directives 64 | * `bucket` / `A` 65 | * `include` 66 | * `Year` / `Y`, `apply year` 67 | * Flags 68 | * State flags (posting flags) 69 | * Transaction state (transaction flags) 70 | * Inline maths 71 | * Lots 72 | * Lot dates 73 | * Lot notes 74 | * Per unit and total costs and prices 75 | * Conversion of ledger price to beancount cost 76 | * Metadata 77 | * Payees 78 | * Obtain payee from metadata 79 | * Split payee into payee and narration 80 | * Assign payee based on narration 81 | * Tags 82 | * Directive `apply tag` 83 | * Mapping `#tags` to `^links` 84 | 85 | ### Partly supported 86 | 87 | * Amounts 88 | * Amounts without commodities (not supported in beancount) 89 | * Decimal comma (not supported in beancount) 90 | * Dates 91 | * Dates on posting-level (no equivalence in beancount) 92 | * Auxiliary dates (no equivalence in beancount) 93 | * Effective dates (no equivalence in beancount) 94 | * Deferred postings (no equivalence in beancount) 95 | * Directives 96 | * `D` (not supported in beancount) 97 | * `define` and `def` (no functions) 98 | * `eval`: skipped (not supported in beancount) 99 | * `import`: skipped (not supported in beancount) 100 | * `payee`: skipped (not needed in beancount) 101 | * `python`: skipped (not supported in beancount) 102 | * `tag`: skipped (not needed in beancount) 103 | * `value`: skipped (not supported in beancount) 104 | * Fixated prices (`=$10` and the `fixed` directive) 105 | * Lot value expressions (no equivalence in beancount) 106 | * Tags and links on posting-level (not supported by beancount) 107 | * Transaction codes: stored as metadata (no equivalence in beancount) 108 | * Virtual postings: can be skipped or converted to real postings 109 | * Virtual posting costs: recognised but skipped (no equivalence in beancount) 110 | 111 | ### Not supported 112 | 113 | * Automated transactions 114 | * Directives 115 | * `assert` 116 | * `C` (commodity equivalences) 117 | * `check` 118 | * `expr` 119 | * `N` 120 | * Timeclock (`I`, `i`, `O`, `o`, `b`, `h`) 121 | * Periodic transactions 122 | 123 | ### Supported features from hledger 124 | 125 | * Account aliases can be regular expressions 126 | * Amounts 127 | * All digit group marks (space, comma, and period) are supported 128 | * Number format can be specified via `commodity` and `D` directives 129 | * Narration: support for `payee | note` format 130 | * Posting dates: `date` and `date2` 131 | * Tags: `tag1:, tag2:, tag2: info` 132 | * Balance assertions 133 | * Sub-account balance assertions 134 | * Total balance assertions: recognised but no equivalent in beancount 135 | * Directives 136 | * `D` (set default commodity) 137 | * `end aliases` 138 | 139 | ## Authors 140 | 141 | * Stefano Zacchiroli `` 142 | * Martin Michlmayr `` 143 | 144 | 145 | ## License 146 | 147 | This program is free software: you can redistribute it and/or modify 148 | it under the terms of the GNU General Public License as published by 149 | the Free Software Foundation, either version 3 of the License, or 150 | (at your option) any later version. 151 | 152 | This program is distributed in the hope that it will be useful, 153 | but WITHOUT ANY WARRANTY; without even the implied warranty of 154 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 155 | GNU General Public License for more details. 156 | 157 | You should have received a copy of the GNU General Public License 158 | along with this program. If not, see . 159 | 160 | SPDX-License-Identifier: GPL-3.0-or-later 161 | -------------------------------------------------------------------------------- /bin/ledger2beancount-ledger-config: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | # SPDX-FileCopyrightText: © 2018 Martin Michlmayr 4 | 5 | # SPDX-License-Identifier: GPL-3.0-or-later 6 | 7 | # obtain configuration data from ~/.ledgerrc for ledger2beancount 8 | 9 | use strict; 10 | use warnings; 11 | 12 | unshift(@ARGV, "$ENV{HOME}/.ledgerrc") unless @ARGV; 13 | open my $input, $ARGV[0] or die "Can't read $ARGV[0]"; 14 | 15 | my $format; 16 | while (<$input>) { 17 | if (/^--input-date-format\s+"?(.*)"?/) { 18 | $format = $1; 19 | } elsif (!$format && /^--date-format\s+"?(.*)"?/) { 20 | $format = $1; 21 | } elsif (/^--decimal-comma/) { 22 | print "decimal_comma: true\n"; 23 | } 24 | } 25 | close $input; 26 | 27 | print "date_format: \"$format\"\n" if $format; 28 | 29 | -------------------------------------------------------------------------------- /cpanfile: -------------------------------------------------------------------------------- 1 | 2 | requires 'Date::Calc'; 3 | requires 'DateTime::Format::Strptime', '>= 1.58'; 4 | requires 'enum'; 5 | requires 'experimental'; 6 | requires 'File::BaseDir'; 7 | requires 'Getopt::Long::Descriptive'; 8 | requires 'List::MoreUtils'; 9 | requires 'POSIX'; 10 | requires 'Regexp::Common'; 11 | requires 'String::Interpolate'; 12 | requires 'Unicode::Normalize'; 13 | requires 'YAML::XS'; 14 | 15 | -------------------------------------------------------------------------------- /devel/release-process.md: -------------------------------------------------------------------------------- 1 | # Release process 2 | 3 | * Update `$VERSION` in `bin/ledger2beancount` 4 | * Update `docs/changelog.md` 5 | * Update date in `docs/index.md` 6 | * Write changes to git: 7 | 8 | ```shell 9 | git commit -S -m "changelog: timestamp 2.X release" 10 | ``` 11 | 12 | * Tag release: 13 | 14 | ```shell 15 | git tag 2.X -s 16 | ``` 17 | 18 | Use the following format for the commit message: 19 | 20 | ``` 21 | Release ledger2beancount 2.X 22 | 23 | 24 | ``` 25 | 26 | * Push new tags to GitHub: 27 | 28 | ```shell 29 | git push github master --tags 30 | ``` 31 | 32 | * Go to the [GitHub release page](https://github.com/beancount/ledger2beancount/releases/new) to create a new release: 33 | 34 | * Select the tag 35 | * Use 2.X as the release title 36 | * Copy release notes from `docs/changelog.md` 37 | 38 | * Email packagers: 39 | 40 | ``` 41 | Jelmer Vernooij 42 | Kirill Goncharov 43 | Taylor R Campbell 44 | ``` 45 | 46 | -------------------------------------------------------------------------------- /devel/spell-check: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # SPDX-FileCopyrightText: © 2020 Martin Michlmayr 4 | 5 | # SPDX-License-Identifier: GPL-3.0-or-later 6 | 7 | find -name "*.md" -exec aspell -d en_GB --home-dir=. -x --mode markdown check {} \; 8 | find -name "*.scd" -exec aspell -d en_GB --home-dir=. -x check {} \; 9 | 10 | find \( -name "*.md" -or -name "*.scd" \) -exec anorack {} \; 11 | 12 | find \( -name "*.md" -or -name "*.scd" \) -exec spellintian {} \; 13 | 14 | find \( -name "*.md" -or -name "*.scd" \) -exec codespell {} \; 15 | 16 | -------------------------------------------------------------------------------- /docs/authors.md: -------------------------------------------------------------------------------- 1 | # Authors 2 | 3 | The authors of ledger2beancount are: 4 | 5 | * Stefano Zacchiroli <> 6 | * Martin Michlmayr <> 7 | 8 | Stefano started the project, created the design and initial implementation. Martin joined later and added more functionality, documentation and test cases. 9 | 10 | We have also had contributions and input from: 11 | 12 | * Alen Siljak (bug reports) 13 | * Alexander Baier (bug reports) 14 | * Ben Creasy (fixes) 15 | * Colin Dean (bug reports) 16 | * Daniele Nicolodi (feedback) 17 | * Dennis Lee (Docker image) 18 | * GitHub user bratekarate (bug reports) 19 | * GitHub user faaafo (bug reports) 20 | * GitHub user mefromthepast (bug reports) 21 | * Jelmer Vernooij (package for Debian) 22 | * Johannes Raufeisen (bug reports) 23 | * John Wiegley (help with compatibility with ledger) 24 | * Kirill Goncharov (bug reports; package for Arch Linux) 25 | * Marin Bernard (bug reports) 26 | * Martin Blais (help with compatibility with beancount) 27 | * Mohsin Kaleem (bug reports) 28 | * Remco Rijnders (feedback) 29 | * Simon Michael (bug reports; fixes; help with compatibility with hledger) 30 | * Taylor R. Campbell (package for pkgsrc) 31 | * Thierry (bug reports; documentation) 32 | * Vinod Kurup (fixes) 33 | * Yuri Khan (feedback) 34 | * Zhuoyun Wei (package for Arch Linux) 35 | 36 | Some work done by Martin Michlmayr was sponsored by [Software Freedom Conservancy](https://sfconservancy.org/) and [Software in the Public Interest, Inc.](https://spi-inc.org/) You can also [sponsor Martin's work](https://github.com/sponsors/tbm) on ledger2beancount, ledger, and beancount. 37 | 38 | Thank you to all contributors and users! 39 | 40 | If you'd like to contribute to ledger2beancount, please see the [contributions information](contributing.md). 41 | 42 | -------------------------------------------------------------------------------- /docs/compatibility.md: -------------------------------------------------------------------------------- 1 | # Beancount compatibility 2 | 3 | The syntax of beancount is quite stable but it's expected to become 4 | slightly less restrictive as some missing features are implemented (such 5 | as posting-level tags). 6 | 7 | ledger2beancount aims to be compatible with the latest official release 8 | of beancount, but some functionality may require an unreleased version of 9 | beancount. You can install the latest development version of beancount 10 | directly from the beancount repository: 11 | 12 | ```shell 13 | pip3 install git+https://github.com/beancount/beancount/ 14 | ``` 15 | 16 | Currently, there are no features that require an unreleased version of 17 | beancount. 18 | 19 | ledger2beancount is largely compatible with Beancount 2.0. If you 20 | use the following features, you need Beancount 2.1: 21 | 22 | * UTF-8 letters and digits in account names 23 | * Full-line comments in transactions 24 | * Transaction tags on multiple lines 25 | 26 | # Ledger compatibility 27 | 28 | ledger2beancount is compatible with the latest release of ledger and 29 | supports the majority of features, as documented in the previous 30 | section. 31 | 32 | There is one limitation, though. While ledger doesn't care about the 33 | encoding of files (as long as your operating system processes them 34 | correctly), ledger2beancount expects input to be UTF-8. This is 35 | because beancount files have to be UTF-8, so users are expected to 36 | have an environment that is compatible with UTF-8 anyway. 37 | 38 | Modern operating systems use UTF-8 by default. On Windows, UTF-8 39 | may need to be set explicitly for the console. If you run into 40 | encoding issues, you should run the following command before you 41 | use ledger2beancount: 42 | 43 | ```shell 44 | chcp 65001 45 | ``` 46 | 47 | This sets the code page 65001, which is [UTF-8 on Windows 48 | systems](https://docs.microsoft.com/en-us/windows/win32/intl/code-page-identifiers). 49 | 50 | -------------------------------------------------------------------------------- /docs/configuration.md: -------------------------------------------------------------------------------- 1 | # Configuration 2 | 3 | ledger2beancount can use a configuration file. It will search for 4 | the config file in the following locations (taking the first file 5 | that is found): 6 | 7 | * `.ledger2beancount.yaml` in the current working directory 8 | * `ledger2beancount.yaml` in the current working directory 9 | * `$XDG_CONFIG_HOME/ledger2beancount/config.yaml` (which is 10 | typically `$HOME/.config/ledger2beancount/config.yaml`) 11 | 12 | You can also pass an alternative config file via `--config/-c`. The 13 | file must end in `.yml` or `.yaml`. 14 | 15 | While the configuration file is optional, you may have to define a 16 | number of variables for ledger2beancount to work correctly with your 17 | ledger files: 18 | 19 | * `ledger_indent` sets the indentation level used in your ledger file 20 | (by default `4`). 21 | * `date_format` has to be configured if you don't use the date format 22 | `YYYY-MM-DD`. 23 | * `decimal_comma` has to be set to `true` if you use commas as the 24 | decimal separator (for example, `10,12 EUR` meaning 10 Euro and 25 | 12 cents). 26 | * `commodity_map` defines mappings from ledger to beancount commodities. 27 | You have to set this if you use commodity codes like `€` or `£` (to 28 | map them to `EUR` and `GBP`, respectively). 29 | 30 | Additionally, these options are useful to configure beancount: 31 | 32 | * `operating_currencies`: a list of the currencies you frequently use. 33 | * `beancount_header`: a file which is embedded at the beginning of 34 | the converted beancount file which can include beancount `option` 35 | statements, `plugin` directives, `query` information and more. 36 | 37 | Other variables can be set to use various functionality offered by 38 | ledger2beancount. All variables are described below. Please read 39 | the [user guide](guide.md) to learn how to use these variables to 40 | configure ledger2beancount for your needs. 41 | 42 | ## Input options 43 | 44 | The following options may be needed for ledger2beancount to interpret 45 | your ledger files correctly. 46 | 47 | date_format 48 | 49 | : The date format used in your ledger file (default: `%Y-%m-%d`). 50 | 51 | date_format_no_year 52 | 53 | : The date format for dates without the year when ledger's `Y`/`year` 54 | directive is used (default: `%m-%d`). 55 | 56 | ledger_indent 57 | 58 | : Sets the indentation level used in your ledger file (default: `4`). 59 | 60 | decimal_comma 61 | 62 | : Parses amounts with the decimal comma (e.g. `10,00 EUR`). Set this 63 | option to `true` if you use option `--decimal-comma` in ledger. 64 | 65 | hledger 66 | 67 | : Tells ledger2beancount whether to attempt to parse hledger-specific 68 | features. 69 | 70 | ## Other options 71 | 72 | beancount_indent 73 | 74 | : Sets the indentation level for the generated beancount file (default: `2`). 75 | 76 | operating_currencies 77 | 78 | : A list of frequently used currencies. This is used by fava, the web 79 | UI for beancount. 80 | 81 | automatic_declarations 82 | 83 | : Emit account and commodity declarations. (Default: `true`) 84 | 85 | Note: the declarations done in ledger via `account` and 86 | `commodity` declarations are always converted. If this option 87 | is `true`, declarations are created for those which have not 88 | been explicitly declared in ledger but used. 89 | 90 | account_open_date 91 | 92 | : The date used to open accounts (default: `1970-01-01`). 93 | 94 | commodities_date 95 | 96 | : The date used to create commodities (default: `1970-01-01`). 97 | 98 | beancount_header 99 | 100 | : Specifies a file which serves as a beancount "header", i.e. it's put 101 | at the beginning of the converted beancount file. You can use such 102 | a header to specify options for beancount, such as `option "title"`, 103 | define `plugin` directives or beancount `query` information. 104 | 105 | ignore_marker 106 | 107 | : Specifies a marker that tells ledger2beancount to ignore a line if the 108 | marker is found. 109 | 110 | keep_marker 111 | 112 | : Specifies a marker that tells ledger2beancount to take a line from the 113 | input that is commented out, uncomment it and display it in the output. 114 | 115 | convert_virtual 116 | 117 | : Specifies whether virtual postings should be converted. If set to 118 | `true`, virtual postings in brackets will be made into real accounts. 119 | (Virtual postings in parentheses are always ignored, regardless of this 120 | option.) 121 | 122 | account_map 123 | 124 | : Specifies a hash of account names to be mapped to other account names. 125 | 126 | account_regex 127 | 128 | : Specifies a hash of regular expressions to replace account names. 129 | 130 | commodity_map 131 | 132 | : Specifies a mapping of ledger commodities to beancount commodities. 133 | 134 | tag_map 135 | 136 | : Specifies a mapping of ledger tags to corresponding beancount tags. 137 | 138 | metadata_map 139 | 140 | : Specifies a mapping of ledger metadata keys to corresponding beancount keys. 141 | 142 | payee_tag 143 | 144 | : Specify a metadata tag (after the mapping done by `metadata_map`) used to set the payee. 145 | 146 | payer_tag 147 | 148 | : Specify a metadata tag (after the mapping done by `metadata_map`) used to set the payee. 149 | 150 | narration_tag 151 | 152 | : Specify a metadata tag (after the mapping done by `metadata_map`) used to set the narration. 153 | 154 | payee_split 155 | 156 | : Specifies a list of regular expressions to split ledger's payee field 157 | into payee and narration. You have to use the named capture groups 158 | `payee` and `narration`. 159 | 160 | payee_match 161 | 162 | : Specifies a list of regular expressions and corresponding payees. The 163 | whole ledger payee becomes the narration and the matched payee from the 164 | regular expression becomes the payee. 165 | 166 | postdate_tag 167 | 168 | : Specifies the metadata tag to be used to store posting dates. (Use the 169 | empty string if you don't want the metadata to be added to beancount.) 170 | 171 | auxdate_tag 172 | 173 | : Specifies the metadata tag to be used to store auxiliary dates (also 174 | known as effective dates; or `date2` in hledger). (Use the empty 175 | string if you don't want the metadata to be added to beancount.) 176 | 177 | code_tag 178 | 179 | : Specifies the metadata tag to be used to store transaction codes. 180 | (Use the empty string if you don't want the metadata to be added to 181 | beancount.) 182 | 183 | link_match 184 | 185 | : Specifies a list of regular expressions that will cause a tag to be 186 | rendered as a link. 187 | 188 | link_tags 189 | 190 | : Specifies a list of metadata tags whose values should be converted to 191 | beancount links instead of metadata. Tags are case insensitive and 192 | values must not contain whitespace. 193 | 194 | currency_is_commodity 195 | 196 | : Specifies a list of commodities that should be treated as commodities 197 | rather than currencies even though they consist of 3 characters (which 198 | is usually a characteristic of a currency). Expects beancount 199 | commodities (i.e. after transformation and mapping). 200 | 201 | commodity_is_currency 202 | 203 | : Specifies a list of commodities that should be treated as currencies 204 | (in the sense that cost is not retained). Expects beancount 205 | commodities (i.e. after transformation and mapping). 206 | 207 | default_commodity 208 | 209 | : Specifies the commodity to be used if an amount without commodity is 210 | found. 211 | 212 | move_posting_tags 213 | 214 | : Tells ledger2beancount to move posting-level tags to the transaction 215 | itself to work around the lack of posting-level tags in beancount. 216 | 217 | -------------------------------------------------------------------------------- /docs/contributing.md: -------------------------------------------------------------------------------- 1 | # Bugs and contributions 2 | 3 | If you find any bugs in ledger2beancount or believe the conversion from 4 | ledger to beancount could be improved, please [open an 5 | issue](https://github.com/beancount/ledger2beancount/issues). Please 6 | include a small test case so we can reproduce the problem. 7 | 8 | If you'd like to contribute code to ledger2beancount, please submit a 9 | [pull request on GitHub](https://github.com/beancount/ledger2beancount/pulls) 10 | or send a `git format-patch` patch (series) to [the authors via 11 | email](authors.md). 12 | 13 | Please make sure you add a test case under `tests` and update the 14 | documentation (`docs/`, and possibly `README.md` and 15 | `examples/illustrated.md`). 16 | 17 | You can run the test suite with `make test`. 18 | 19 | -------------------------------------------------------------------------------- /docs/features.md: -------------------------------------------------------------------------------- 1 | # Features 2 | 3 | The majority of features from [ledger](https://ledger-cli.org/) and [hledger](https://hledger.org/) are supported by ledger2beancount. 4 | 5 | ## Fully supported 6 | 7 | * Accounts 8 | * Account declarations (`account ...`) 9 | * Conversion of invalid account names 10 | * Mapping of account names 11 | * Directive `apply account` 12 | * Account aliases (the `alias` directive and the `alias` sub-directive of `account` declarations) 13 | * Balance assignments 14 | * Balance assertions 15 | * Comments 16 | * Comments in and outside of transactions 17 | * Directives `comment` and `test` 18 | * Commodities 19 | * Commodity declarations (`commodity ...`) 20 | * Commodity symbols like `$`, `£` and `€` 21 | * Commodities placed in front and after the amount 22 | * Conversion of invalid commodities 23 | * Mapping of commodities 24 | * Directives 25 | * `bucket` / `A` 26 | * `include` 27 | * `Year` / `Y`, `apply year` 28 | * Flags 29 | * Transaction state (transaction flags) 30 | * Inline maths 31 | * Lots 32 | * Lot dates 33 | * Lot notes 34 | * Per unit and total costs and prices 35 | * Conversion of ledger price to beancount cost 36 | * Metadata 37 | * Payees 38 | * Obtain payee from metadata 39 | * Split payee into payee and narration 40 | * Assign payee based on narration 41 | * Tags 42 | * Directive `apply tag` 43 | * Mapping `#tags` to `^links` 44 | 45 | ## Partly supported 46 | 47 | * Amounts 48 | * Amounts without commodities (not supported in beancount) 49 | * Decimal comma (not supported in beancount) 50 | * Dates 51 | * Dates on posting-level (no equivalence in beancount) 52 | * Auxiliary dates (no equivalence in beancount) 53 | * Effective dates (no equivalence in beancount) 54 | * Deferred postings (no equivalence in beancount) 55 | * Directives 56 | * `define` and `def` (no functions) 57 | * `eval`: skipped (not supported in beancount) 58 | * `import`: skipped (not supported in beancount) 59 | * `payee`: skipped (not needed in beancount) 60 | * `python`: skipped (not supported in beancount) 61 | * `tag`: skipped (not needed in beancount) 62 | * `value`: skipped (not supported in beancount) 63 | * Fixated prices (`=$10` and the `fixed` directive) 64 | * Lot value expressions (no equivalence in beancount) 65 | * Tags and links on posting-level (not supported by beancount) 66 | * Transaction codes: stored as metadata (no equivalence in beancount) 67 | * Virtual postings: can be skipped or converted to real postings 68 | * Virtual posting costs: recognised but skipped (no equivalence in beancount) 69 | 70 | ## Unsupported in beancount 71 | 72 | The following features are not supported in beancount and therefore 73 | commented out during the conversion from ledger to beancount: 74 | 75 | * Automated transactions 76 | * Checks and assertions (`check` and `assert`) 77 | * Commodity conversion (`C AMOUNT1 = AMOUNT2`) 78 | * Commodity format (`D AMOUNT`) 79 | * Commodity pricing: ignore pricing (`N SYMBOL`) 80 | * Timeclock support (`I`, `i`, `O`, `o`, `b`, `h`) 81 | * Periodic transactions 82 | 83 | ## Supported features from hledger 84 | 85 | The following syntax from [hledger](https://hledger.org/) is supported if the `hledger` configuration variable is set: 86 | 87 | * Account aliases can be regular expressions 88 | * Amounts 89 | * All digit group marks (space, comma, and period) are supported 90 | * Number format can be specified via `commodity` and `D` directives 91 | * Narration: support for `payee | note` format 92 | * Posting dates: `date` and `date2` 93 | * Tags: `tag1:, tag2:, tag2: info` 94 | * Balance assertions 95 | * Sub-account balance assertions 96 | * Total balance assertions: recognised but no equivalent in beancount 97 | * Directives 98 | * `D` (set default commodity) 99 | * `end aliases` 100 | 101 | -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | # SPDX-FileCopyrightText: © 2018 Martin Michlmayr 3 | # 4 | # SPDX-License-Identifier: GPL-3.0-or-later 5 | title: ledger2beancount 6 | subtitle: Ledger to Beancount converter 7 | author: 8 | - Stefano Zacchiroli 9 | - Martin Michlmayr 10 | keywords: ledger, beancount, converter, conversion, accounting, bookkeeping, finance 11 | date: December 2022 12 | documentclass: scrartcl 13 | urlcolor: blue 14 | toc: true 15 | --- 16 | 17 | # ledger2beancount 18 | 19 | [ledger2beancount](https://github.com/beancount/ledger2beancount/) is a 20 | script to automatically convert [Ledger](https://www.ledger-cli.org/)-based 21 | textual ledgers to [Beancount](http://furius.ca/beancount/) ones. 22 | 23 | Conversion is based on (concrete) syntax, so that information that is not 24 | meaningful for accounting reasons but still valuable (e.g., comments, 25 | formatting, etc.) can be preserved. 26 | 27 | As input, ledger2beancount supports the file formats from: 28 | 29 | * [ledger](https://ledger-cli.org/) 30 | * [hledger](https://hledger.org/) 31 | 32 | ledger2beancount aims to be compatible with the latest official release of 33 | beancount. 34 | 35 | -------------------------------------------------------------------------------- /docs/installation.md: -------------------------------------------------------------------------------- 1 | # Installation 2 | 3 | ledger2beancount is a Perl script and relies on the following modules: 4 | 5 | * `Date::Calc` 6 | * `DateTime::Format::Strptime` 7 | * `enum` 8 | * `File::BaseDir` 9 | * `Getopt::Long::Descriptive` 10 | * `List::MoreUtils` 11 | * `Regexp::Common` 12 | * `String::Interpolate` 13 | * `YAML::XS` 14 | 15 | You can install the required Perl modules with 16 | [cpanminus](https://metacpan.org/pod/distribution/App-cpanminus/bin/cpanm): 17 | 18 | ```shell 19 | cpanm --installdeps . 20 | ``` 21 | 22 | If you use Debian, you can install the dependencies with this command: 23 | 24 | ```shell 25 | sudo apt install libdate-calc-perl libdatetime-format-strptime-perl \ 26 | libenum-perl libfile-basedir-perl libgetopt-long-descriptive-perl \ 27 | liblist-moreutils-perl libregexp-common-perl \ 28 | libstring-interpolate-perl libyaml-libyaml-perl 29 | ``` 30 | 31 | ledger2beancount itself consists of one script. You can clone the 32 | repository and run the script directly or copy it to `$HOME/bin` or 33 | a similar location: 34 | 35 | ```shell 36 | git clone https://github.com/beancount/ledger2beancount/ 37 | cd ledger2beancount 38 | ./bin/ledger2beancount examples/simple.ledger 39 | ``` 40 | 41 | ## Arch Linux 42 | 43 | ledger2beancount is available on [AUR](https://aur.archlinux.org/packages/ledger2beancount/). 44 | 45 | ## Debian 46 | 47 | ledger2beancount is [available in Debian](https://packages.debian.org/ledger2beancount). 48 | 49 | ## Docker 50 | 51 | You can create a Docker image for ledger2beancount using the `Dockerfile` 52 | that's part of ledger2beancount's Git repository: 53 | 54 | ```shell 55 | git clone https://github.com/beancount/ledger2beancount/ 56 | cd ledger2beancount 57 | DOCKER_BUILDKIT=1 docker image build -t . 58 | ``` 59 | 60 | Now you can run ledger2beancount like this: 61 | 62 | ```shell 63 | docker run --rm -v :/usr/ledger2beancount/docker:rw docker/ 64 | ``` 65 | 66 | ## macOS 67 | 68 | You can install Perl and `cpanm` from Homebrew: 69 | 70 | ```shell 71 | brew install perl 72 | brew install cpanminus 73 | ``` 74 | 75 | ## Microsoft Windows 76 | 77 | You can install [Strawberry Perl](http://strawberryperl.com/) on Windows 78 | and use `cpanm` as described above to install the required Perl modules. 79 | ledger2beancount is not packaged for Windows but you can clone this Git 80 | repository and run the script. 81 | 82 | ## pkgsrc 83 | 84 | ledger2beancount is [available for pkgsrc](https://pkgsrc.se/finance/ledger2beancount) 85 | which is used on NetBSD and other operating systems. 86 | 87 | ## Ubuntu 88 | 89 | ledger2beancount is [available in Ubuntu](https://packages.ubuntu.com/ledger2beancount). 90 | 91 | -------------------------------------------------------------------------------- /docs/ledger2beancount.1.scd: -------------------------------------------------------------------------------- 1 | ledger2beancount(1) 2 | 3 | ; SPDX-FileCopyrightText: © 2019 Martin Michlmayr 4 | 5 | ; SPDX-License-Identifier: GPL-3.0-or-later 6 | 7 | # NAME 8 | 9 | ledger2beancount - ledger to beancount converter 10 | 11 | # SYNOPSIS 12 | 13 | *ledger2beancount* [options] _input.ledger_ > _output.beancount_ 14 | 15 | *cat* _input.ledger_ | *ledger2beancount* [options] > _output.beancount_ 16 | 17 | # DESCRIPTION 18 | 19 | *ledger2beancount* is a script to automatically convert 20 | *ledger*(1)-based textual ledgers to *beancount* files. 21 | 22 | Conversion is based on (concrete) syntax, so that information that is 23 | not meaningful for accounting reasons but still valuable (e.g., 24 | comments, formatting, etc.) can be preserved. 25 | 26 | # OPTIONS 27 | 28 | *-c, --config* 29 | Specify a configuration file. The options of the configuration 30 | file are described in *ledger2beancount*(5) and the 31 | *ledger2beancount* manual. 32 | 33 | *-h, --help* 34 | Show help message and quit. 35 | 36 | *-V, --version* 37 | Show version and quit. 38 | 39 | # USAGE 40 | 41 | *ledger2beancount* accepts input from _stdin_ or from a file and will 42 | write the converted data to _stdout_. You can run *ledger2beancount* 43 | like this on the example provided: 44 | 45 | *ledger2beancount* _examples/simple.ledger_ > _simple.beancount_ 46 | 47 | After you convert your *ledger*(1) file, you should validate the 48 | generated beancount file with *bean-check*(1) and fix all errors: 49 | 50 | *bean-check* _simple.beancount_ 51 | 52 | You should also inspect the generated *beancount* file to see if it 53 | looks correct to you. Please note that *ledger2beancount* puts notes at 54 | the beginning of the generated *beancount* file if it encounters 55 | problems with the conversion. 56 | 57 | # FILES 58 | 59 | _$PWD/.ledger2beancount.yaml_ or _$PWD/ledger2beancount.yaml_ 60 | The configuration file for the current directory. 61 | 62 | _$XDG_CONFIG_HOME/ledger2beancount/config.yaml_ (usually _$HOME/.config/ledger2beancount/config.yaml_) 63 | The default configuration file. 64 | 65 | # BUGS 66 | 67 | If you find any bugs in *ledger2beancount* or believe the conversion 68 | from *ledger* to *beancount* could be improved, please open an issue on 69 | GitHub: 70 | https://github.com/beancount/ledger2beancount/issues 71 | 72 | Please include a small test case so we can reproduce the problem. 73 | 74 | # AUTHORS 75 | 76 | Stefano Zacchiroli and Martin Michlmayr 77 | 78 | # SEE ALSO 79 | 80 | *ledger2beancount*(5), *ledger*(1), *bean-check*(1) 81 | 82 | The full documentation for *ledger2beancount* can be found in its manual. 83 | 84 | -------------------------------------------------------------------------------- /docs/ledger2beancount.5.scd: -------------------------------------------------------------------------------- 1 | ledger2beancount(5) 2 | 3 | ; SPDX-FileCopyrightText: © 2019 Martin Michlmayr 4 | 5 | ; SPDX-License-Identifier: GPL-3.0-or-later 6 | 7 | # NAME 8 | 9 | ledger2beancount - configuration file for *ledger2beancount*(1) 10 | 11 | # INPUT OPTIONS 12 | 13 | The following options may be needed for *ledger2beancount* to interpret 14 | your *ledger* files correctly. 15 | 16 | *date_format* 17 | The date format used in your *ledger* file (default: *%Y-%m-%d*). 18 | 19 | *date_format_no_year* 20 | The date format for dates without the year when *ledger*'s 21 | *Y*/*year* directive is used (default: *%m-%d*). 22 | 23 | *ledger_indent* 24 | Sets the indentation level used in your ledger file (default: *4*). 25 | 26 | *decimal_comma* true|false 27 | Parses amounts with the decimal comma (e.g. *10,00 EUR*). Set 28 | this option to *true* if you use option *--decimal-comma* in 29 | *ledger*. 30 | 31 | *hledger* true|false 32 | Tells *ledger2beancount* whether to attempt to parse 33 | *hledger*(1)-specific features. 34 | 35 | # OTHER OPTIONS 36 | 37 | *beancount_indent* 38 | Sets the indentation level for the generated beancount file 39 | (default: *2*). 40 | 41 | *operating_currencies* 42 | A list of frequently used currencies. This is used by 43 | *fava*, the web UI for beancount. 44 | 45 | *automatic_declarations* true|false 46 | Emit account and commodity declarations. (Default: *true*) 47 | 48 | Note: the declarations done in ledger via *account* and 49 | *commodity* declarations are always converted. If this option 50 | is *true*, declarations are created for those which have not 51 | been explicitly declared in *ledger* but used. 52 | 53 | *account_open_date* 54 | The date used to open accounts (default: *1970-01-01*). 55 | 56 | *commodities_date* 57 | The date used to create commodities (default: *1970-01-01*). 58 | 59 | *beancount_header* 60 | Specifies a file which serves as a beancount "header", i.e. it's 61 | put at the beginning of the converted beancount file. You can 62 | use such a header to specify options for beancount, such as 63 | *option "title"*, define *plugin* directives or beancount *query* 64 | information. 65 | 66 | *ignore_marker* 67 | Specifies a marker that tells *ledger2beancount*(1) to ignore 68 | a line if the marker is found. 69 | 70 | *keep_marker* 71 | Specifies a marker that tells *ledger2beancount*(1) to take 72 | a line from the input that is commented out, uncomment it and 73 | display it in the output. 74 | 75 | *convert_virtual* true|false 76 | Specifies whether virtual postings should be converted. If set 77 | to *true*, virtual postings in brackets will be made into real 78 | accounts. (Virtual postings in parentheses are always ignored, 79 | regardless of this option.) 80 | 81 | *account_map* 82 | Specifies a hash of account names to be mapped to other account 83 | names. 84 | 85 | *account_regex* 86 | Specifies a hash of regular expressions to replace account 87 | names. 88 | 89 | *commodity_map* 90 | Specifies a mapping of *ledger* commodities to beancount 91 | commodities. 92 | 93 | *tag_map* 94 | 95 | Specifies a mapping of *ledger* tags to corresponding *beancount* 96 | tags. 97 | 98 | *metadata_map* 99 | Specifies a mapping of *ledger* metadata keys to corresponding 100 | *beancount* keys. 101 | 102 | *payee_tag* and *payer_tag* 103 | Specify a metadata tag (after the mapping done by *metadata_map*) 104 | used to set the payee. 105 | 106 | *narration_tag* 107 | Specify a metadata tag (after the mapping done by *metadata_map*) 108 | used to set the narration. 109 | 110 | *payee_split* 111 | Specifies a list of regular expressions to split *ledger*'s payee 112 | field into payee and narration. You have to use the named capture 113 | groups *payee* and *narration*. 114 | 115 | *payee_match* 116 | Specifies a list of regular expressions and corresponding payees. 117 | The whole *ledger* payee becomes the narration and the matched 118 | payee from the regular expression becomes the payee. 119 | 120 | *postdate_tag* 121 | Specifies the metadata tag to be used to store posting 122 | dates. (Use the empty string if you don't want the metadata 123 | to be added to beancount.) 124 | 125 | *auxdate_tag* 126 | Specifies the metadata tag to be used to store auxiliary dates 127 | (also known as effective dates; or *date2* in *hledger*). 128 | (Use the empty string if you don't want the metadata 129 | to be added to beancount.) 130 | 131 | *code_tag* 132 | Specifies the metadata tag to be used to store transaction 133 | codes. (Use the empty string if you don't want the metadata 134 | to be added to beancount.) 135 | 136 | *link_match* 137 | Specifies a list of regular expressions that will cause a tag 138 | to be rendered as a link. 139 | 140 | *link_tags* 141 | Specifies a list of metadata tags whose values should be 142 | converted to *beancount* links instead of metadata. 143 | Tags are case insensitive and values must not contain whitespace. 144 | 145 | *currency_is_commodity* 146 | Specifies a list of commodities that should be treated as 147 | commodities rather than currencies even though they consist 148 | of 3 characters (which is usually a characteristic of a 149 | currency). Expects beancount commodities (i.e. after 150 | transformation and mapping). 151 | 152 | *commodity_is_currency* 153 | Specifies a list of commodities that should be treated as 154 | currencies (in the sense that cost is not retained). 155 | Expects beancount commodities (i.e. after transformation 156 | and mapping). 157 | 158 | *move_posting_tags* 159 | Move posting-level tags to the transaction itself to work around 160 | the lack of posting-level tags in beancount. 161 | 162 | # AUTHORS 163 | 164 | Stefano Zacchiroli and Martin Michlmayr 165 | 166 | # SEE ALSO 167 | 168 | *ledger2beancount*(1), *ledger*(1), *hledger*(1) 169 | 170 | The full documentation for *ledger2beancount* can be found in its manual. 171 | 172 | -------------------------------------------------------------------------------- /docs/license.md: -------------------------------------------------------------------------------- 1 | # License 2 | 3 | ledger2beancount is distributed under the [GNU General Public License](https://www.gnu.org/licenses/gpl-3.0.en.html) version 3.0 or later. 4 | 5 | The [SPDX license identifier](https://spdx.org/licenses/) is [GPL-3.0-or-later](https://spdx.org/licenses/GPL-3.0-or-later.html): 6 | 7 | ```text 8 | SPDX-License-Identifier: GPL-3.0-or-later 9 | ``` 10 | 11 | ## Copyright 12 | 13 | ```text 14 | © 2016 Stefano Zacchiroli 15 | © 2018 Martin Michlmayr 16 | © 2020 Software in the Public Interest, Inc. 17 | ``` 18 | 19 | The years indicated are the *first* year of contribution (see [Why not bump the year on change?](https://matija.suklje.name/how-and-why-to-properly-write-copyright-statements-in-your-code#why-not-bump-the-year-on-change)). 20 | 21 | -------------------------------------------------------------------------------- /docs/limitations.md: -------------------------------------------------------------------------------- 1 | # Limitations 2 | 3 | ## Include files and apply directives 4 | 5 | Ledger offers the `include` directive to include transactions from other files. It also has the `apply` directives to apply certain transformations to transactions, such as adding a string to the account name. When you include other files within the scope of an `apply` directive, the transformation is applied to the included transactions. 6 | 7 | Since there is no equivalent directive in beancount for most of ledger's `apply` directives, ledger2beancount manually applies the transformation manually during conversion, i.e. the generated beancount file will have the transformation applied. However, as ledger2beancount operates on individual files, such transformations are not applied to the file that is included in another file because there's no `apply` directive in the file. 8 | 9 | One exception is the `apply tag` directive since that's converted to `pushtag` in beancount instead of manually applying the transformation by ledger2beancount. 10 | -------------------------------------------------------------------------------- /docs/tips.md: -------------------------------------------------------------------------------- 1 | 2 | # Tips and tricks 3 | 4 | ## Pre- and post-processing 5 | 6 | While ledger2beancount is fairly powerful and configurable, it won't 7 | meet all needs. In some cases, it makes more sense to pre-process the 8 | input file or post-process the output file rather than to add more 9 | features to ledger2beancount. 10 | 11 | An example where pre-processing is useful are ledger transactions that 12 | were created with [ledger's convert](https://www.ledger-cli.org/3.0/doc/ledger3.html#The-convert-command) 13 | command, which allows the generation of transactions from CSV. 14 | 15 | Since ledger doesn't distinguish between payee and narration, narration 16 | information can be stored in a transaction note. The problem with 17 | processing such transactions is that ledger puts the note either on the 18 | same line as the payee or the next line depending on the length of the 19 | payee and narration information. Furthermore, ledger2beancount doesn't 20 | support taking narration information from transaction notes, so we have 21 | to transform the transaction and store the information as metadata. 22 | 23 | Let's take this CSV file as an example: 24 | 25 | ```csv 26 | date,note,payee,amount 27 | 2021-04-21,A very long note that will be printed on the next line,Short Payee,-7.99 EUR 28 | 2021-04-21,Short note,Short Payee,-7.99 EUR 29 | 2021-04-21,Short note,A Long Payee Name that leaves no more room for the note,-7.99 EUR 30 | ``` 31 | 32 | The command `ledger convert --account Assets:Bank` produces this 33 | output: 34 | 35 | ```ledger 36 | 2021-04-21 * Short Payee 37 | ;A very long note that will be printed on the next line 38 | Expenses:Unknown -7.99 EUR 39 | Assets:Bank 40 | 41 | 2021-04-21 * Short Payee ;Short note 42 | Expenses:Unknown -7.99 EUR 43 | Assets:Bank 44 | 45 | 2021-04-21 * A Long Payee Name that leaves no more room for the note 46 | ;Short note 47 | Expenses:Unknown -7.99 EUR 48 | Assets:Bank 49 | ``` 50 | 51 | The following script takes the transaction notes (either the transaction 52 | note on the same line as the payee or the first comment of a transaction) 53 | and stores them as metadata with the key `narration`: 54 | 55 | ```perl 56 | #!/usr/bin/perl 57 | 58 | use warnings; 59 | use strict; 60 | 61 | my $before_posting = 1; 62 | my $seen_note = 0; 63 | while (<>) { 64 | if (/^\d/) { # Transaction header 65 | $before_posting = 1; 66 | if (/ ;/) { 67 | my ($header, $note) = split / ;/; 68 | print "$header\n"; 69 | print " ; narration: $note"; 70 | $seen_note = 1; 71 | } else { 72 | print; 73 | $seen_note = 0; 74 | } 75 | } elsif (/^\s+[^;\s]/) { # Posting 76 | $before_posting = 0; 77 | print; 78 | } elsif (/^\s+;(.*)/) { # Comment 79 | my $note = $1; 80 | if ($before_posting && !$seen_note) { 81 | print " ; narration: $note\n"; 82 | $seen_note = 1; 83 | } else { 84 | print; 85 | } 86 | } else { 87 | print; 88 | } 89 | } 90 | ``` 91 | 92 | This changes the input file to: 93 | 94 | ```ledger 95 | 2021-04-21 * Short Payee 96 | ; narration: A very long note that will be printed on the next line 97 | Expenses:Unknown -7.99 EUR 98 | Assets:Bank 99 | 100 | 2021-04-21 * Short Payee 101 | ; narration: Short note 102 | Expenses:Unknown -7.99 EUR 103 | Assets:Bank 104 | 105 | 2021-04-21 * A Long Payee Name that leaves no more room for the note 106 | ; narration: Short note 107 | Expenses:Unknown -7.99 EUR 108 | Assets:Bank 109 | ``` 110 | 111 | Now the comment is metadata and we can use the following configuration: 112 | 113 | ```yaml 114 | payee_split: 115 | - (?.*) 116 | 117 | narration_tag: narration 118 | ``` 119 | 120 | to get the expected output: 121 | 122 | ```beancount 123 | 2021-04-21 * "Short Payee" "A very long note that will be printed on the next line" 124 | Expenses:Unknown -7.99 EUR 125 | Assets:Bank 126 | 127 | 2021-04-21 * "Short Payee" "Short note" 128 | Expenses:Unknown -7.99 EUR 129 | Assets:Bank 130 | 131 | 2021-04-21 * "A Long Payee Name that leaves no more room for the note" "Short note" 132 | Expenses:Unknown -7.99 EUR 133 | Assets:Bank 134 | ... 135 | ``` 136 | 137 | An example of post-processing is to change the variable type of ledger 138 | codes from string to integer. Using `code_tag`, the ledger code from 139 | transactions is stored as metadata. Since ledger codes can be 140 | anything, they are stored as strings by default: 141 | 142 | ```beancount 143 | 2021-04-14 * "Code" 144 | code: "1201" 145 | ... 146 | ``` 147 | 148 | If you know that all your codes are integer, you can remove the 149 | quotation marks to turn them from strings into integers: 150 | 151 | ```shell 152 | perl -pi -e 's/^(\s+code: )"(\d+)"$/$1$2/' *.beancount 153 | ``` 154 | 155 | The `code` metadata is now an integer: 156 | 157 | ```beancount 158 | 2021-04-14 * "Code" 159 | code: 1201 160 | ... 161 | ``` 162 | 163 | -------------------------------------------------------------------------------- /docs/usage.md: -------------------------------------------------------------------------------- 1 | # Usage 2 | 3 | ledger2beancount accepts input from `stdin` or from a file and will write 4 | the converted data to `stdout`. You can run ledger2beancount like this 5 | on the example provided: 6 | 7 | ```shell 8 | ledger2beancount examples/simple.ledger > simple.beancount 9 | ``` 10 | 11 | After you convert your ledger file, you should validate the generated 12 | beancount file with `bean-check` and fix all errors: 13 | 14 | ```shell 15 | bean-check simple.beancount 16 | ``` 17 | 18 | You should also inspect the generated beancount file to see if it 19 | looks correct to you. Please note that ledger2beancount puts notes 20 | at the beginning of the generated beancount file if it encounters 21 | problems with the conversion. 22 | 23 | If you believe that ledger2beancount could have produced a better 24 | conversion or if you get an error message from ledger2beancount, please 25 | [file a bug](https://github.com/beancount/ledger2beancount/issues) along 26 | with a simple test case. 27 | 28 | You can pipe the output of ledger2beancount to beancount's bean-format 29 | if you want to use the conversion as an opportunity to reformat your 30 | file. 31 | 32 | -------------------------------------------------------------------------------- /examples/illustrated.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | date_format: "%Y-%m-%d" 3 | # Date without year (if ledger's Y/year directive is used) 4 | date_format_no_year: "%m/%d" 5 | 6 | # Date used to open accounts 7 | account_open_date: "2010-03-01" # Unix epoch, just because 8 | 9 | # Date used to create commodities 10 | commodities_date: "2010-03-01" # Unix epoch, just because 11 | 12 | beancount_indent: 2 13 | ledger_indent: 4 14 | 15 | # list of frequently used currencies (not *all* used currencies) 16 | operating_currencies: 17 | - EUR 18 | 19 | # Set to `true` if you use option --decimal-comma in ledger 20 | decimal_comma: false 21 | 22 | # mapping of ledger metadata key to corresponding beancount key 23 | metadata_map: 24 | x-payee: payee 25 | x-payer: payer 26 | foo: bar 27 | 28 | # metadata tags (*after* above mapping) used for specific purposes 29 | payee_tag: payee 30 | payer_tag: payer 31 | 32 | # payee_split: a list of regular expressions which allows you 33 | # to split ledger's payee field into payee and narration. 34 | # Use named capture groups "payee" and "narration". 35 | payee_split: 36 | - (?.*?)\s+\((?.*)\) 37 | 38 | # payee_match: a list of regular expressions and corresponding 39 | # payees. The whole ledger payee becomes the narration and 40 | # the matched payee from the regular expression becomes the 41 | # payee. 42 | payee_match: 43 | - ^Oyster top-up: TfL 44 | 45 | account_map: 46 | "Equity:Opening-balance": Equity:Opening-Balance 47 | Assets:MyLedger: Assets:MyBeancount 48 | 49 | # mapping of ledger commodities to valid beancount commodities 50 | commodity_map: 51 | "$": USD 52 | "£": GBP 53 | "€": EUR 54 | "¥": JPY 55 | M&M: MILESMORE 56 | 57 | # You can set the following metadata tags to an empty string if you 58 | # don't want the metadata to be added to beancount. 59 | auxdate_tag: aux-date 60 | code_tag: code 61 | 62 | # A list of regular expressions that will cause a tag to be 63 | # rendered as a link. 64 | link_match: 65 | - ^\d\d\d\d-\d\d-\d\d- 66 | 67 | # A list of metadata tags whose values should be converted to 68 | # beancount links instead of metadata. 69 | # Tags are case insensitive. Values must not contain whitespace. 70 | link_tags: [] 71 | 72 | # A list of commodities that should be treated as commodities 73 | # rather than currencies even though they consist of 3 characters 74 | # (which is usually a characteristic of a currency). Expects 75 | # beancount commodities (i.e. after transformation and mapping). 76 | currency_is_commodity: 77 | - BTC 78 | - ETH 79 | - IBM 80 | 81 | # A list of commodities that should be treated as currencies 82 | # (in the sense that cost is not retained). Expects beancount 83 | # commodities (i.e. after transformation and mapping). 84 | commodity_is_currency: 85 | - MILESMORE 86 | -------------------------------------------------------------------------------- /examples/simple.ledger: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | 2018-03-28 Simple transaction 6 | Expenses:Purchase 10.00 EUR 7 | Assets:Wallet 8 | 9 | 2018-03-28 Currency code, posting flag 10 | Expenses:Purchase $20.00 11 | * Assets:Wallet 12 | 13 | 2018-03-28=2018-03-27 * (100) Transaction flag, aux date, code, conversion 14 | Expenses:Purchase 10.00 EUR @ 0.86 GBP 15 | Assets:Wallet -8.60 GBP 16 | 17 | 2018-03-28 * Meta data 18 | ; :tag: 19 | ; Key: value 20 | ; Typed:: [2018-03-20] 21 | Expenses:Purchase 10.00 EUR 22 | Assets:Wallet 23 | 24 | -------------------------------------------------------------------------------- /ledger2beancount.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | date_format: "%Y-%m-%d" 3 | # Date without year (if ledger's Y/year directive is used) 4 | date_format_no_year: "%m-%d" 5 | 6 | # Date used to open accounts 7 | account_open_date: "1970-01-01" # Unix epoch, just because 8 | 9 | # Date used to create commodities 10 | commodities_date: "1970-01-01" # Unix epoch, just because 11 | 12 | beancount_indent: 2 13 | ledger_indent: 4 14 | 15 | # list of frequently used currencies (not *all* used currencies) 16 | operating_currencies: 17 | - EUR 18 | 19 | # Attempt to parse hledger specific features 20 | hledger: false 21 | 22 | # You can specify a file which serves as a beancount "header", i.e. 23 | # it's put at the beginning of the converted beancount file. You can 24 | # specify options for beancount, such as `option "title"`, define 25 | # `plugin` directives or beancount `query` information. 26 | # beancount_header: 27 | 28 | # emit account and commodity declares 29 | # (Note: the declarations done in ledger via `account` and 30 | # `commodity` are always converted. If this option is true, 31 | # declarations are created for those which have not been 32 | # explicitly declared in ledger but used.) 33 | automatic_declarations: true 34 | 35 | # Set to `true` if you use option --decimal-comma in ledger 36 | decimal_comma: false 37 | 38 | # Should virtual postings be converted. If set to true, virtual 39 | # postings in brackets will be made into real accounts. (Virtual 40 | # postings in parentheses are always ignored, regardless of this option) 41 | convert_virtual: false 42 | 43 | # mapping of ledger tags to corresponding beancount tag 44 | tag_map: 45 | WTF???: WTF 46 | 47 | # mapping of ledger metadata key to corresponding beancount key 48 | metadata_map: 49 | x-payee: payee 50 | x-payer: payer 51 | 52 | # metadata tags (*after* above mapping) used to set payee 53 | payee_tag: payee 54 | payer_tag: payer 55 | 56 | # payee_split: a list of regular expressions which allows you 57 | # to split ledger's payee field into payee and narration. 58 | # Use named capture groups "payee" and "narration". 59 | payee_split: 60 | - (?.*?)\s+\((?Tesco)\) 61 | 62 | # payee_match: a list of regular expressions and corresponding 63 | # payees. The whole ledger payee becomes the narration and 64 | # the matched payee from the regular expression becomes the 65 | # payee. 66 | payee_match: 67 | - (?i)^Oyster card top-up: TfL 68 | 69 | # A hash of account names to be mapped to other account 70 | # names. 71 | account_map: 72 | "Equity:Opening-balance": Equity:Opening-Balance 73 | 74 | # A hash of regular expressions to replace account names. 75 | account_regex: 76 | ^Accrued:Accounts Payable:(.*): Liabilities:Accounts-Payable:$1 77 | ^Accrued:Accounts Receivable:(.*): Assets:Accounts-Receivable:$1 78 | 79 | # mapping of ledger commodities to valid beancount commodities 80 | commodity_map: 81 | "$": USD 82 | "£": GBP 83 | "€": EUR 84 | "¥": JPY 85 | 86 | # You can set the following metadata tags to an empty string if you 87 | # don't want the metadata to be added to beancount. 88 | postdate_tag: date 89 | auxdate_tag: aux-date 90 | code_tag: code 91 | 92 | # A list of regular expressions that will cause a tag to be 93 | # rendered as a link. 94 | link_match: 95 | - ^\d\d\d\d-\d\d-\d\d- 96 | 97 | # A list of metadata tags whose values should be converted to 98 | # beancount links instead of metadata. 99 | # Tags are case insensitive. Values must not contain whitespace. 100 | link_tags: [] 101 | 102 | # A list of commodities that should be treated as commodities 103 | # rather than currencies even though they consist of 3 characters 104 | # (which is usually a characteristic of a currency). Expects 105 | # beancount commodities (i.e. after transformation and mapping). 106 | currency_is_commodity: 107 | - BTC 108 | - ETH 109 | - IBM 110 | 111 | # A list of commodities that should be treated as currencies 112 | # (in the sense that cost is not retained). Expects beancount 113 | # commodities (i.e. after transformation and mapping). 114 | commodity_is_currency: 115 | - MARRIOTT 116 | - MILESMORE 117 | - NECTAR 118 | 119 | # A marker that tells ledger2beancount to ignore a line if the 120 | # marker is found. 121 | # ignore_marker: NoL2B 122 | # 123 | # A marker that tells ledger2beancount to take a line from 124 | # the input that is commented out, uncomment it and display 125 | # it in the output. 126 | keep_marker: L2Bonly 127 | -------------------------------------------------------------------------------- /misc/initial-git-import.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # SPDX-FileCopyrightText: © 2018 Stefano Zacchiroli 4 | 5 | # SPDX-License-Identifier: GPL-3.0-or-later 6 | 7 | # ledger2beancount started as an ad hoc personal script. As such it was 8 | # maintained in zack's private Ledger Git repository. It was later spun off 9 | # as an independent project, when tbm started to heavily contribute to it. The 10 | # script below was used to migrate the git history of ledger2beancount from 11 | # zack's private repo to a new, independent one. It is ad hoc, uninteresting, 12 | # and archived here just for historical reasons. 13 | 14 | flags="--force --prune-empty" 15 | revs="-- --all" 16 | git_url="git@*censored*:ledger" 17 | 18 | git clone "$git_url" ledger2beancount 19 | cd ledger2beancount 20 | 21 | git filter-branch $flags --subdirectory-filter bin $revs 22 | git filter-branch $flags --tree-filter "ls | grep -v beancount | xargs rm" $revs 23 | git filter-branch $flags --env-filter ' 24 | export GIT_AUTHOR_NAME="Martin Michlmayr" 25 | export GIT_AUTHOR_EMAIL="tbm@cyrius.com" 26 | export GIT_COMMITTER_NAME="Stefano Zacchiroli" 27 | export GIT_COMMITTER_EMAIL="zack@upsilon.cc" 28 | ' -- $(git rev-list HEAD --since=2018-03-10 | tail -n 1)^..HEAD 29 | -------------------------------------------------------------------------------- /mkdocs.yml: -------------------------------------------------------------------------------- 1 | --- 2 | site_name: ledger2beancount 3 | site_description: Ledger to Beancount converter 4 | site_url: https://ledger2beancount.readthedocs.io/ 5 | repo_url: https://github.com/beancount/ledger2beancount 6 | site_author: Stefano Zacchiroli, Martin Michlmayr 7 | use_directory_urls: true 8 | 9 | theme: 10 | name: readthedocs 11 | custom_dir: themes 12 | highlightjs: true 13 | hljs_languages: 14 | - shell 15 | - text 16 | - yaml 17 | 18 | nav: 19 | - Introduction: index.md 20 | - Getting started: 21 | - Features: features.md 22 | - Compatibility: compatibility.md 23 | - Installation: installation.md 24 | - Usage: usage.md 25 | - Configuration: configuration.md 26 | - Guides: 27 | - User guide: guide.md 28 | - Limitations: limitations.md 29 | - Tips and tricks: tips.md 30 | - About: 31 | - Release notes: changelog.md 32 | - Bugs and contributions: contributing.md 33 | - Authors and contributors: authors.md 34 | - License and copyright: license.md 35 | 36 | markdown_extensions: 37 | - toc: 38 | permalink:  39 | baselevel: 2 40 | - def_list 41 | 42 | plugins: 43 | - search 44 | - exclude: 45 | glob: 46 | - "*.1" 47 | - "*.5" 48 | - "*.scd" 49 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | mkdocs>=1.1 2 | mkdocs-exclude>=1.0.2 3 | -------------------------------------------------------------------------------- /tests/README.md: -------------------------------------------------------------------------------- 1 | 2 | While ledger2beancount is pretty portable, the test suite makes use of some functionality which might not be available on all platforms out of the box. 3 | 4 | ## Required 5 | 6 | * The test suite assumes a UTF-8 environment. 7 | * The test suite uses the `-V` (`--version-sort`) option of `sort` in order to compare versions. This option is not available in all implementations of sort. Therefore, sort from [GNU coreutils](https://www.gnu.org/software/coreutils/) is required. This is provided as `gsort` on some platforms. You can set the `SORT` environment variable to specify the binary for sort. 8 | * The tool `mktemp` is called to create temporary files. If this is not provided by the platform, GNU coreutils can be installed. 9 | 10 | ## Optional 11 | 12 | * If `ledger`, `hledger`, and/or `beancount` are installed, these tools will be used to validate input (ledger and hledger) and output files (beancount). 13 | 14 | -------------------------------------------------------------------------------- /tests/accounts.header: -------------------------------------------------------------------------------- 1 | 2 | option "title" "Test account names" 3 | 4 | -------------------------------------------------------------------------------- /tests/accounts.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | beancount_header: accounts.header 3 | 4 | convert_virtual: true 5 | 6 | account_map: 7 | Assets:♚♛♕♔: Assets:Crowns 8 | Assets:Test:I love ♚♛♕♔: Assets:Test:I-Love-Crowns 9 | Assets:Coll1: Assets:Collision 10 | Assets:Coll2: Assets:Collision 11 | Equity:Opening-balance: Equity:Opening-Balance 12 | Assets:Shorter: Assets:Short 13 | Assets:Longer: Assets:MuchLonger 14 | Assets:Cash: Assets:Bash 15 | Assets:Bank (Debian): Assets:Bank:Debian 16 | Assets:Bank Debian]bar: Assets:Bank:Debian:Bar 17 | Income:Interest: Revenue:Interest 18 | Expenses:Foo:Travel: Expenses:Travel 19 | Expenses:Bar:Travel: Expenses:Travel 20 | Trading:Currency: Equity:Trading:Currency 21 | A: Assets:Aaa 22 | B: Assets:Bbb 23 | 24 | account_regex: 25 | ^Accrued:Accounts Payable:(.*): Liabilities:Accounts Payable:$1 26 | ^Accrued:Accounts Receivable:(.*): Assets:Accounts-Receivable:$1 27 | -------------------------------------------------------------------------------- /tests/amounts-decimal-comma.beancount: -------------------------------------------------------------------------------- 1 | ;---------------------------------------------------------------------- 2 | ; ledger2beancount conversion notes: 3 | ; 4 | ; - Directive `define` not supported by beancount: replacing thousand with 1.000,00 EUR 5 | ; - Amount without commodity found; set default_commodity in config 6 | ; - Commodity Avios renamed to AVIOS 7 | ; - Collision for commodity EUR: EUR, € 8 | ; - Collision for commodity GBP: GBP, £ 9 | ; - Collision for commodity USD: $, USD 10 | ;---------------------------------------------------------------------- 11 | 12 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 13 | ; 14 | ; SPDX-License-Identifier: GPL-3.0-or-later 15 | 16 | 17 | 1970-01-01 open Assets:99Test:Test99 18 | 1970-01-01 open Assets:Test1 19 | 1970-01-01 open Assets:Test2 20 | 1970-01-01 open Equity:Opening-Balance 21 | 22 | 1970-01-01 commodity EUR 23 | 1970-01-01 commodity GBP 24 | 1970-01-01 commodity USD 25 | 26 | 1970-01-01 open Assets:Bank 27 | 1970-01-01 open Assets:Current 28 | 1970-01-01 open Assets:Investments 29 | 1970-01-01 open Assets:Receivable 30 | 1970-01-01 open Assets:Rewards 31 | 1970-01-01 open Assets:Test 32 | 1970-01-01 open Expenses:Housing:Rent 33 | 1970-01-01 open Expenses:Travel:Airfare 34 | 1970-01-01 open Income:401k:Match 35 | 1970-01-01 open Income:Salary 36 | 1970-01-01 open Liabilities:BA 37 | 38 | 1970-01-01 commodity AVIOS 39 | 1970-01-01 commodity FRF 40 | 1970-01-01 commodity XXX 41 | 42 | 2002-01-01 price EUR 6.55957 FRF 43 | 44 | 2018-03-26 * "Decimal comma" 45 | Assets:99Test:Test99 10.12 EUR 46 | Equity:Opening-Balance 47 | 48 | 2018-03-26 * "Decimal comma, with thousand separator" 49 | Assets:99Test:Test99 1000.00 EUR 50 | Equity:Opening-Balance 51 | 52 | 2018-03-26 * "Decimal comma, with thousand separator" 53 | Assets:99Test:Test99 1000.00 EUR 54 | Equity:Opening-Balance 55 | 56 | 2018-03-26 * "Commodity after amount" 57 | Assets:99Test:Test99 1 EUR 58 | Equity:Opening-Balance 59 | 60 | 2018-03-26 * "Commodity after amount, no space" 61 | Assets:99Test:Test99 1 EUR 62 | Equity:Opening-Balance 63 | 64 | 2018-03-26 * "Commodity before amount" 65 | Assets:99Test:Test99 1 EUR 66 | Equity:Opening-Balance 67 | 68 | 2018-03-26 * "Commodity before amount, no space" 69 | Assets:99Test:Test99 1000.00 EUR 70 | Equity:Opening-Balance 71 | 72 | 2018-03-26 * "Commodity after amount, negative" 73 | Assets:99Test:Test99 -1 EUR 74 | Equity:Opening-Balance 75 | 76 | 2018-03-26 * "Commodity after amount, negative, no space" 77 | Assets:99Test:Test99 -1 EUR 78 | Equity:Opening-Balance 79 | 80 | 2018-03-26 * "Commodity before amount, negative" 81 | Assets:99Test:Test99 -3 EUR 82 | Equity:Opening-Balance 83 | 84 | 2018-03-26 * "Commodity before amount, negative" 85 | Assets:99Test:Test99 -2 EUR 86 | Equity:Opening-Balance 87 | 88 | 2018-03-26 * "Commodity symbol after amount" 89 | Assets:99Test:Test99 100 USD 90 | Equity:Opening-Balance 91 | 92 | 2018-03-26 * "Commodity symbol after amount, negative" 93 | Assets:99Test:Test99 -1 USD 94 | Equity:Opening-Balance 95 | 96 | 2018-03-26 * "Commodity symbol before amount" 97 | Assets:99Test:Test99 1 USD 98 | Equity:Opening-Balance 99 | 100 | 2018-03-26 * "Commodity symbol before amount, negative" 101 | Assets:99Test:Test99 -1 USD 102 | Equity:Opening-Balance 103 | 104 | 2018-03-26 * "Commodity symbol after amount, with space" 105 | Assets:99Test:Test99 1 USD 106 | Equity:Opening-Balance 107 | 108 | 2018-03-26 * "Commodity symbol before amount, with space" 109 | Assets:99Test:Test99 1 USD 110 | Equity:Opening-Balance 111 | 112 | 2018-03-26 * "Commodity symbol after amount, negative, with space" 113 | Assets:99Test:Test99 -1 USD 114 | Equity:Opening-Balance 115 | 116 | 2018-03-26 * "Commodity symbol before amount, negative" 117 | Assets:99Test:Test99 -1 USD 118 | Equity:Opening-Balance 119 | 120 | 2018-03-26 * "Commodity after amount, thousand" 121 | Assets:99Test:Test99 1000 EUR 122 | Equity:Opening-Balance 123 | 124 | 2018-03-26 * "Commodity before amount, thousands" 125 | Assets:99Test:Test99 1000.00 EUR 126 | Equity:Opening-Balance 127 | 128 | 2018-03-26 * "Commodity before amount, thousands, no space" 129 | Assets:99Test:Test99 1000.00 EUR 130 | Equity:Opening-Balance 131 | 132 | 2018-03-26 * "Commodity before amount, one million" 133 | Assets:99Test:Test99 1000000.00 EUR 134 | Equity:Opening-Balance 135 | 136 | 2018-03-26 * "Simple inline math" 137 | Assets:Test1 1*3 GBP 138 | Assets:Test2 -3 GBP 139 | 140 | 2018-03-26 * "Simple inline math" 141 | Assets:Test1 1 GBP @ 1/1.14 EUR 142 | Assets:Test2 -0.88 EUR 143 | 144 | 2018-03-26 * "Simple inline math" 145 | Assets:Test1 44.06 USD @ 1/1.362 GBP 146 | Assets:Test2 -32.35 GBP 147 | 148 | 2018-03-26 * "Simple inline math" 149 | Assets:Test1 1 * 3 GBP 150 | Assets:Test2 -3 GBP 151 | 152 | 2018-03-26 * "Simple inline math" 153 | Assets:Test1 1 GBP @ 1 / 1.14 EUR 154 | Assets:Test2 -0.88 EUR 155 | 156 | 2018-03-26 * "Simple inline math" 157 | Assets:Test1 44.06 USD @ 1 / 1.362 GBP 158 | Assets:Test2 -32.35 GBP 159 | 160 | 2018-04-10 * "Inline math: negative amounts" 161 | Expenses:Travel:Airfare 2 * 15.00 GBP 162 | Expenses:Travel:Airfare 2*4500 AVIOS 163 | Assets:Rewards 2*-4500 AVIOS 164 | Liabilities:BA 2 * -15.00 GBP 165 | 166 | 2018-04-10 * "Inline math" 167 | Expenses:Housing:Rent 550.00/2 GBP 168 | Assets:Receivable 550.00/2 GBP 169 | Assets:Current -550.00 GBP 170 | 171 | 2018-09-27 * "Test amounts without digits before comma separator" 172 | Assets:Test 0.10 EUR 173 | Assets:Test -0.10 EUR 174 | Assets:Test 0.10 GBP 175 | Assets:Test -0.10 GBP 176 | Assets:Test 0.10 USD 177 | Assets:Test -0.10 USD 178 | 179 | 2020-06-22 txn "Paycheck" 180 | Income:Salary -4000.00 USD 181 | Assets:Bank 4000.00 USD 182 | Income:401k:Match -4000.00 * 0.05 USD 183 | Assets:Investments 4000.00 * 0.05 USD 184 | 185 | 2020-06-22 txn "Paycheck" 186 | Income:Salary -4000.00 USD 187 | Assets:Bank 4000.00 USD 188 | Income:401k:Match -4000.00* 0.05 USD 189 | Assets:Investments 4000.00* 0.05 USD 190 | 191 | 2020-06-22 txn "Inline math" 192 | Assets:Test1 (4.00 *100.00) USD 193 | Assets:Test2 194 | 195 | 2020-06-22 txn "Inline math" 196 | Assets:Test1 (4.00) *100.00 USD 197 | Assets:Test2 198 | 199 | 2020-06-22 txn "Inline math" 200 | Assets:Test1 (4.00*2.00) *100.00 USD 201 | Assets:Test2 202 | 203 | 2020-06-22 txn "Inline math" 204 | Assets:Test1 (4.00*2.00) * 100.00 USD 205 | Assets:Test2 206 | 207 | 2020-06-22 txn "Inline math" 208 | Assets:Test1 2.00* -4.00 USD 209 | Assets:Test2 210 | 211 | 2020-06-27 txn "Define" 212 | Assets:Test1 2.00+ 1000.00 EUR 213 | Assets:Test2 214 | 215 | 2020-08-01 * "Amount without commodity" 216 | Assets:Test 10 XXX 217 | Assets:Test -10 XXX 218 | 219 | 2020-08-01 * "Amount without commodity" 220 | Assets:Test 10.00 XXX 221 | Assets:Test -10.00 XXX 222 | 223 | 2020-08-01 * "Amount without commodity" 224 | Assets:Test 0.50 XXX 225 | Assets:Test -0.50 XXX 226 | 227 | 2020-08-01 * "Amount without commodity" 228 | Assets:Test 0.50 XXX 229 | Assets:Test -0.50 XXX 230 | 231 | 2020-08-01 * "Amount without commodity" 232 | Assets:Test 0.5 XXX 233 | Assets:Test -0.5 XXX 234 | 235 | 2020-08-01 * "Amount without commodity: space between minus and number" 236 | Assets:Test 0.5 XXX 237 | Assets:Test -0.5 XXX 238 | 239 | -------------------------------------------------------------------------------- /tests/amounts-decimal-comma.ledger: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | --decimal-comma 6 | 7 | account Assets:99Test:Test99 8 | account Assets:Test1 9 | account Assets:Test2 10 | account Equity:Opening-Balance 11 | 12 | commodity EUR 13 | commodity GBP 14 | commodity $ 15 | 16 | P 2002-01-01 € 6,55957 FRF 17 | 18 | 2018-03-26 * Decimal comma 19 | Assets:99Test:Test99 10,12 EUR 20 | Equity:Opening-Balance 21 | 22 | 2018-03-26 * Decimal comma, with thousand separator 23 | Assets:99Test:Test99 EUR 1.000,00 24 | Equity:Opening-Balance 25 | 26 | 2018-03-26 * Decimal comma, with thousand separator 27 | Assets:99Test:Test99 EUR 1.000,00 28 | Equity:Opening-Balance 29 | 30 | 2018-03-26 * Commodity after amount 31 | Assets:99Test:Test99 1 EUR 32 | Equity:Opening-Balance 33 | 34 | 2018-03-26 * Commodity after amount, no space 35 | Assets:99Test:Test99 1EUR 36 | Equity:Opening-Balance 37 | 38 | 2018-03-26 * Commodity before amount 39 | Assets:99Test:Test99 EUR 1 40 | Equity:Opening-Balance 41 | 42 | 2018-03-26 * Commodity before amount, no space 43 | Assets:99Test:Test99 EUR1000,00 44 | Equity:Opening-Balance 45 | 46 | 2018-03-26 * Commodity after amount, negative 47 | Assets:99Test:Test99 -1 EUR 48 | Equity:Opening-Balance 49 | 50 | 2018-03-26 * Commodity after amount, negative, no space 51 | Assets:99Test:Test99 -1EUR 52 | Equity:Opening-Balance 53 | 54 | 2018-03-26 * Commodity before amount, negative 55 | Assets:99Test:Test99 EUR -3 56 | Equity:Opening-Balance 57 | 58 | 2018-03-26 * Commodity before amount, negative 59 | Assets:99Test:Test99 -EUR 2 60 | Equity:Opening-Balance 61 | 62 | 2018-03-26 * Commodity symbol after amount 63 | Assets:99Test:Test99 100$ 64 | Equity:Opening-Balance 65 | 66 | 2018-03-26 * Commodity symbol after amount, negative 67 | Assets:99Test:Test99 -1$ 68 | Equity:Opening-Balance 69 | 70 | 2018-03-26 * Commodity symbol before amount 71 | Assets:99Test:Test99 $1 72 | Equity:Opening-Balance 73 | 74 | 2018-03-26 * Commodity symbol before amount, negative 75 | Assets:99Test:Test99 -$1 76 | Equity:Opening-Balance 77 | 78 | 2018-03-26 * Commodity symbol after amount, with space 79 | Assets:99Test:Test99 1 $ 80 | Equity:Opening-Balance 81 | 82 | 2018-03-26 * Commodity symbol before amount, with space 83 | Assets:99Test:Test99 $ 1 84 | Equity:Opening-Balance 85 | 86 | 2018-03-26 * Commodity symbol after amount, negative, with space 87 | Assets:99Test:Test99 -1 $ 88 | Equity:Opening-Balance 89 | 90 | 2018-03-26 * Commodity symbol before amount, negative 91 | Assets:99Test:Test99 -$ 1 92 | Equity:Opening-Balance 93 | 94 | 2018-03-26 * Commodity after amount, thousand 95 | Assets:99Test:Test99 1.000 EUR 96 | Equity:Opening-Balance 97 | 98 | 2018-03-26 * Commodity before amount, thousands 99 | Assets:99Test:Test99 EUR 1.000,00 100 | Equity:Opening-Balance 101 | 102 | 2018-03-26 * Commodity before amount, thousands, no space 103 | Assets:99Test:Test99 EUR1.000,00 104 | Equity:Opening-Balance 105 | 106 | 2018-03-26 * Commodity before amount, one million 107 | Assets:99Test:Test99 EUR 1.000.000,00 108 | Equity:Opening-Balance 109 | 110 | 2018-03-26 * Simple inline math 111 | Assets:Test1 (1*3 GBP) 112 | Assets:Test2 -3 GBP 113 | 114 | 2018-03-26 * Simple inline math 115 | Assets:Test1 1 GBP @ (1/1,14 EUR) 116 | Assets:Test2 -0,88 EUR 117 | 118 | 2018-03-26 * Simple inline math 119 | Assets:Test1 44,06 USD @ (1/1,362 GBP) 120 | Assets:Test2 -32,35 GBP 121 | 122 | 2018-03-26 * Simple inline math 123 | Assets:Test1 (1 * 3 GBP) 124 | Assets:Test2 -3 GBP 125 | 126 | 2018-03-26 * Simple inline math 127 | Assets:Test1 1 GBP @ (1 / 1,14 EUR) 128 | Assets:Test2 -0,88 EUR 129 | 130 | 2018-03-26 * Simple inline math 131 | Assets:Test1 44,06 USD @ (1 / 1,362 GBP) 132 | Assets:Test2 -32,35 GBP 133 | 134 | 2018-04-10 * Inline math: negative amounts 135 | Expenses:Travel:Airfare (2 * 15,00 GBP) 136 | Expenses:Travel:Airfare (2*4500 Avios) 137 | Assets:Rewards (2*-4500 Avios) 138 | Liabilities:BA (2 * -15,00 GBP) 139 | 140 | 2018-04-10 * Inline math 141 | Expenses:Housing:Rent (550,00/2 GBP) 142 | Assets:Receivable (550,00/2 GBP) 143 | Assets:Current -550,00 GBP 144 | 145 | 2018-09-27 * Test amounts without digits before comma separator 146 | Assets:Test €,10 147 | Assets:Test €-,10 148 | Assets:Test £,10 149 | Assets:Test £-,10 150 | Assets:Test $,10 151 | Assets:Test $-0,10 152 | 153 | 2020-06-22 Paycheck 154 | Income:Salary -4000,00 USD 155 | Assets:Bank 4000,00 USD 156 | Income:401k:Match ($-4.000,00 * 0,05) 157 | Assets:Investments ($4.000,00 * 0,05) 158 | 159 | 2020-06-22 Paycheck 160 | Income:Salary -4000,00 USD 161 | Assets:Bank 4000,00 USD 162 | Income:401k:Match (-4000,00 USD * 0,05) 163 | Assets:Investments (4000,00 USD * 0,05) 164 | 165 | 2020-06-22 Inline math 166 | Assets:Test1 ((4,00 * $100,00)) 167 | Assets:Test2 168 | 169 | 2020-06-22 Inline math 170 | Assets:Test1 ((4,00) * $100,00) 171 | Assets:Test2 172 | 173 | 2020-06-22 Inline math 174 | Assets:Test1 ((4,00*2,00) * $100,00) 175 | Assets:Test2 176 | 177 | 2020-06-22 Inline math 178 | Assets:Test1 ((4,00 USD*2,00) * 100,00 USD) 179 | Assets:Test2 180 | 181 | 2020-06-22 Inline math 182 | Assets:Test1 (2,00 USD * -4,00) 183 | Assets:Test2 184 | 185 | define thousand=1.000,00 EUR 186 | 2020-06-27 Define 187 | Assets:Test1 (2,00 EUR + thousand) 188 | Assets:Test2 189 | 190 | 2020-08-01 * Amount without commodity 191 | Assets:Test 10 192 | Assets:Test -10 193 | 194 | 2020-08-01 * Amount without commodity 195 | Assets:Test 10,00 196 | Assets:Test -10,00 197 | 198 | 2020-08-01 * Amount without commodity 199 | Assets:Test 0,50 200 | Assets:Test -0,50 201 | 202 | 2020-08-01 * Amount without commodity 203 | Assets:Test ,50 204 | Assets:Test -,50 205 | 206 | 2020-08-01 * Amount without commodity 207 | Assets:Test ,5 208 | Assets:Test -,5 209 | 210 | 2020-08-01 * Amount without commodity: space between minus and number 211 | Assets:Test ,5 212 | Assets:Test - ,5 213 | 214 | -------------------------------------------------------------------------------- /tests/amounts-decimal-comma.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | decimal_comma: true 3 | -------------------------------------------------------------------------------- /tests/amounts-plus-sign-decimal-comma.beancount: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2021 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | ; This is an .hledger file because the +amount syntax is currently 6 | ; not supported by ledger (https://github.com/ledger/ledger/issues/1990) 7 | 8 | 1970-01-01 open Assets:Test 9 | 10 | 1970-01-01 commodity AUD 11 | 1970-01-01 commodity USD 12 | 13 | 2021-08-29 * "Amount with plus sign" 14 | Assets:Test +10.00 USD 15 | Assets:Test -10.00 USD 16 | 17 | 2021-08-29 * "Amount with plus sign" 18 | Assets:Test +10.00 USD 19 | Assets:Test -10.00 USD 20 | 21 | 2021-08-29 * "Amount with plus sign" 22 | Assets:Test +10.00 AUD 23 | Assets:Test -10.00 AUD 24 | 25 | 2021-08-29 * "Amount with plus sign" 26 | Assets:Test +10.00 USD 27 | Assets:Test -10.00 USD 28 | 29 | 2021-08-29 * "Amount with plus sign" 30 | Assets:Test +10.00 USD 31 | Assets:Test -10.00 USD 32 | 33 | 2021-08-29 * "Amount with plus sign" 34 | Assets:Test +10.00 USD 35 | Assets:Test -10.00 USD 36 | 37 | 2021-08-29 * "Amount with plus sign" 38 | Assets:Test +10.00 USD 39 | Assets:Test -10.00 USD 40 | 41 | 2021-08-29 * "Amount with plus sign" 42 | Assets:Test +10.00 AUD 43 | Assets:Test -10.00 AUD 44 | 45 | 2021-08-29 * "Amount with plus sign" 46 | Assets:Test +1.00 USD 47 | Assets:Test -1.00 USD 48 | 49 | 2021-08-29 * "Amount with plus sign" 50 | Assets:Test +1.00 USD 51 | Assets:Test -1.00 USD 52 | 53 | 2021-08-29 * "Amount with plus sign" 54 | Assets:Test +1.00 AUD 55 | Assets:Test -1.00 AUD 56 | 57 | 2021-08-29 * "Amount with plus sign" 58 | Assets:Test +0.10 USD 59 | Assets:Test -0.10 USD 60 | 61 | 2021-08-29 * "Amount with plus sign" 62 | Assets:Test +0.10 USD 63 | Assets:Test -0.10 USD 64 | 65 | -------------------------------------------------------------------------------- /tests/amounts-plus-sign-decimal-comma.hledger: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2021 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | ; This is an .hledger file because the +amount syntax is currently 6 | ; not supported by ledger (https://github.com/ledger/ledger/issues/1990) 7 | 8 | 2021-08-29 * Amount with plus sign 9 | Assets:Test $+10,00 10 | Assets:Test $-10,00 11 | 12 | 2021-08-29 * Amount with plus sign 13 | Assets:Test +$10,00 14 | Assets:Test -$10,00 15 | 16 | 2021-08-29 * Amount with plus sign 17 | Assets:Test +10,00 AUD 18 | Assets:Test -10,00 AUD 19 | 20 | 2021-08-29 * Amount with plus sign 21 | Assets:Test $ + 10,00 22 | Assets:Test $ - 10,00 23 | 24 | 2021-08-29 * Amount with plus sign 25 | Assets:Test $+ 10,00 26 | Assets:Test $- 10,00 27 | 28 | 2021-08-29 * Amount with plus sign 29 | Assets:Test + $10,00 30 | Assets:Test -$10,00 31 | 32 | 2021-08-29 * Amount with plus sign 33 | Assets:Test + $ 10,00 34 | Assets:Test - $ 10,00 35 | 36 | 2021-08-29 * Amount with plus sign 37 | Assets:Test + 10,00 AUD 38 | Assets:Test - 10,00 AUD 39 | 40 | 2021-08-29 * Amount with plus sign 41 | Assets:Test $+1,00 42 | Assets:Test $-1,00 43 | 44 | 2021-08-29 * Amount with plus sign 45 | Assets:Test +$1,00 46 | Assets:Test -$1,00 47 | 48 | 2021-08-29 * Amount with plus sign 49 | Assets:Test + 1,00 AUD 50 | Assets:Test - 1,00 AUD 51 | 52 | 2021-08-29 * Amount with plus sign 53 | Assets:Test $+,10 54 | Assets:Test $-,10 55 | 56 | 2021-08-29 * Amount with plus sign 57 | Assets:Test +$,10 58 | Assets:Test -$,10 59 | 60 | -------------------------------------------------------------------------------- /tests/amounts-plus-sign-decimal-comma.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | decimal_comma: true 3 | -------------------------------------------------------------------------------- /tests/amounts-plus-sign.beancount: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2021 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | ; This is an .hledger file because the +amount syntax is currently 6 | ; not supported by ledger (https://github.com/ledger/ledger/issues/1990) 7 | 8 | 1970-01-01 open Assets:Test 9 | 10 | 1970-01-01 commodity AUD 11 | 1970-01-01 commodity USD 12 | 13 | 2021-08-29 * "Amount with plus sign" 14 | Assets:Test +10.00 USD 15 | Assets:Test -10.00 USD 16 | 17 | 2021-08-29 * "Amount with plus sign" 18 | Assets:Test +10.00 USD 19 | Assets:Test -10.00 USD 20 | 21 | 2021-08-29 * "Amount with plus sign" 22 | Assets:Test +10.00 AUD 23 | Assets:Test -10.00 AUD 24 | 25 | 2021-08-29 * "Amount with plus sign" 26 | Assets:Test +10.00 USD 27 | Assets:Test -10.00 USD 28 | 29 | 2021-08-29 * "Amount with plus sign" 30 | Assets:Test +10.00 USD 31 | Assets:Test -10.00 USD 32 | 33 | 2021-08-29 * "Amount with plus sign" 34 | Assets:Test +10.00 USD 35 | Assets:Test -10.00 USD 36 | 37 | 2021-08-29 * "Amount with plus sign" 38 | Assets:Test +10.00 USD 39 | Assets:Test -10.00 USD 40 | 41 | 2021-08-29 * "Amount with plus sign" 42 | Assets:Test +10.00 AUD 43 | Assets:Test -10.00 AUD 44 | 45 | 2021-08-29 * "Amount with plus sign" 46 | Assets:Test +1.00 USD 47 | Assets:Test -1.00 USD 48 | 49 | 2021-08-29 * "Amount with plus sign" 50 | Assets:Test +1.00 USD 51 | Assets:Test -1.00 USD 52 | 53 | 2021-08-29 * "Amount with plus sign" 54 | Assets:Test +1.00 AUD 55 | Assets:Test -1.00 AUD 56 | 57 | 2021-08-29 * "Amount with plus sign" 58 | Assets:Test +0.10 USD 59 | Assets:Test -0.10 USD 60 | 61 | 2021-08-29 * "Amount with plus sign" 62 | Assets:Test +0.10 USD 63 | Assets:Test -0.10 USD 64 | 65 | 2021-08-29 * "Amount with plus sign" 66 | Assets:Test +0.10 AUD 67 | Assets:Test -0.10 AUD 68 | 69 | -------------------------------------------------------------------------------- /tests/amounts-plus-sign.hledger: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2021 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | ; This is an .hledger file because the +amount syntax is currently 6 | ; not supported by ledger (https://github.com/ledger/ledger/issues/1990) 7 | 8 | 2021-08-29 * Amount with plus sign 9 | Assets:Test $+10.00 10 | Assets:Test $-10.00 11 | 12 | 2021-08-29 * Amount with plus sign 13 | Assets:Test +$10.00 14 | Assets:Test -$10.00 15 | 16 | 2021-08-29 * Amount with plus sign 17 | Assets:Test +10.00 AUD 18 | Assets:Test -10.00 AUD 19 | 20 | 2021-08-29 * Amount with plus sign 21 | Assets:Test $ + 10.00 22 | Assets:Test $ - 10.00 23 | 24 | 2021-08-29 * Amount with plus sign 25 | Assets:Test $+ 10.00 26 | Assets:Test $- 10.00 27 | 28 | 2021-08-29 * Amount with plus sign 29 | Assets:Test + $10.00 30 | Assets:Test -$10.00 31 | 32 | 2021-08-29 * Amount with plus sign 33 | Assets:Test + $ 10.00 34 | Assets:Test - $ 10.00 35 | 36 | 2021-08-29 * Amount with plus sign 37 | Assets:Test + 10.00 AUD 38 | Assets:Test - 10.00 AUD 39 | 40 | 2021-08-29 * Amount with plus sign 41 | Assets:Test $+1.00 42 | Assets:Test $-1.00 43 | 44 | 2021-08-29 * Amount with plus sign 45 | Assets:Test +$1.00 46 | Assets:Test -$1.00 47 | 48 | 2021-08-29 * Amount with plus sign 49 | Assets:Test + 1.00 AUD 50 | Assets:Test - 1.00 AUD 51 | 52 | 2021-08-29 * Amount with plus sign 53 | Assets:Test $+.10 54 | Assets:Test $-.10 55 | 56 | 2021-08-29 * Amount with plus sign 57 | Assets:Test +$.10 58 | Assets:Test -$.10 59 | 60 | 2021-08-29 * Amount with plus sign 61 | Assets:Test + .10 AUD 62 | Assets:Test - .10 AUD 63 | 64 | -------------------------------------------------------------------------------- /tests/aux-date.beancount: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | 1970-01-01 open Assets:Commodity-Test123 6 | 1970-01-01 open Assets:Test 7 | 1970-01-01 open Equity:Opening-Balance 8 | 9 | 1970-01-01 commodity EUR 10 | 11 | 2018-03-17 * "Test with transaction aux date" 12 | aux-date: 2018-03-16 13 | Assets:Test 10.00 EUR 14 | Equity:Opening-Balance -10.00 EUR 15 | 16 | 2018-03-18 * "Test with posting aux date" 17 | Assets:Test 10.00 EUR 18 | aux-date: 2018-03-13 19 | Equity:Opening-Balance 20 | 21 | 2018-03-18 * "Test with transaction and posting aux date" 22 | aux-date: 2018-03-17 23 | Assets:Test 10.00 EUR 24 | aux-date: 2018-03-13 25 | Equity:Opening-Balance 26 | 27 | 2018-03-18 * "Test with posting aux date plus comment" 28 | Assets:Test 10.00 EUR ; foo 29 | aux-date: 2018-03-13 30 | Equity:Opening-Balance 31 | 32 | 2018-03-18 * "Test with posting aux date after no amount" 33 | Assets:Test 10.00 EUR 34 | Equity:Opening-Balance 35 | aux-date: 2018-03-13 36 | 37 | 2018-03-27 * "Account name could be mistaken for commodity" 38 | Assets:Test 10.00 EUR 39 | Assets:Commodity-Test123 40 | aux-date: 2018-03-13 41 | 42 | 2019-01-16 * "Posting date using comment" 43 | Assets:Test 10.00 EUR 44 | date: 2017-03-04 45 | Equity:Opening-Balance -10.00 EUR 46 | date: 2017-07-08 47 | 48 | 2019-01-16 * "Posting date and aux date using comment" 49 | Assets:Test 10.00 EUR 50 | date: 2017-03-04 51 | aux-date: 2017-03-05 52 | Equity:Opening-Balance -10.00 EUR 53 | date: 2017-07-08 54 | aux-date: 2017-07-09 55 | 56 | 2020-03-09 * "Test with posting date and comment" 57 | Assets:Test 10.00 EUR ; Foo Bar 58 | date: 2018-03-13 59 | Equity:Opening-Balance 60 | 61 | 2020-03-09 * "Test with posting date and comment, but no amount" 62 | Assets:Test ; Foo Bar 63 | date: 2018-03-13 64 | Equity:Opening-Balance -10.00 EUR 65 | 66 | 2020-03-09 * "Test with posting aux date and comment" 67 | Assets:Test 10.00 EUR ; Foo Bar 68 | aux-date: 2018-03-13 69 | Equity:Opening-Balance 70 | 71 | 2020-03-09 * "Test with posting aux date and comment, but no amount" 72 | Assets:Test ; Foo Bar 73 | aux-date: 2018-03-13 74 | Equity:Opening-Balance -10.00 EUR 75 | 76 | 2020-10-01 * "Trailing whitespace" 77 | Assets:Test 10.00 EUR 78 | date: 2020-09-30 79 | Assets:Test -10.00 EUR 80 | 81 | 2020-10-23 * "Posting date and tag" 82 | Assets:Test 10.00 EUR 83 | date: 2020-09-30 84 | tags: "foo" 85 | Assets:Test -10.00 EUR 86 | 87 | 2020-10-23 * "Posting date and metadata" 88 | Assets:Test 10.00 EUR 89 | date: 2020-09-30 90 | foo: "bar" 91 | Assets:Test -10.00 EUR 92 | 93 | 2020-10-23 * "Aux date and tag" 94 | Assets:Test 10.00 EUR 95 | aux-date: 2020-09-30 96 | tags: "foo" 97 | Assets:Test -10.00 EUR 98 | 99 | 2020-10-23 * "Aux date and metadata" 100 | Assets:Test 10.00 EUR 101 | aux-date: 2020-09-30 102 | foo: "bar" 103 | Assets:Test -10.00 EUR 104 | 105 | 2020-10-23 * "Posting date, aux date and tag" 106 | Assets:Test 10.00 EUR 107 | date: 2020-10-20 108 | aux-date: 2020-09-30 109 | tags: "foo" 110 | Assets:Test -10.00 EUR 111 | 112 | 2020-10-23 * "Posting date, aux date and metadata" 113 | Assets:Test 10.00 EUR 114 | date: 2020-10-20 115 | aux-date: 2020-09-30 116 | foo: "bar" 117 | Assets:Test -10.00 EUR 118 | 119 | 2020-10-23 * "Comment spacing for comment after date" 120 | Assets:Test 10.00 EUR ; foo 121 | date: 2020-09-30 122 | Equity:Opening-Balance -10.00 EUR 123 | 124 | 2020-10-23 * "Comment spacing for comment after date" 125 | Assets:Test 10.00 EUR ;foo 126 | date: 2020-09-30 127 | Equity:Opening-Balance -10.00 EUR 128 | 129 | -------------------------------------------------------------------------------- /tests/aux-date.ledger: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | account Assets:Commodity-Test123 6 | account Assets:Test 7 | account Equity:Opening-Balance 8 | 9 | commodity EUR 10 | 11 | 2018-03-17=2018-03-16 * Test with transaction aux date 12 | Assets:Test 10.00 EUR 13 | Equity:Opening-Balance -10.00 EUR 14 | 15 | 2018-03-18 * Test with posting aux date 16 | Assets:Test 10.00 EUR ; [=2018-03-13] 17 | Equity:Opening-Balance 18 | 19 | 2018-03-18=2018-03-17 * Test with transaction and posting aux date 20 | Assets:Test 10.00 EUR ; [=2018-03-13] 21 | Equity:Opening-Balance 22 | 23 | 2018-03-18 * Test with posting aux date plus comment 24 | Assets:Test 10.00 EUR ; [=2018-03-13] foo 25 | Equity:Opening-Balance 26 | 27 | 2018-03-18 * Test with posting aux date after no amount 28 | Assets:Test 10.00 EUR 29 | Equity:Opening-Balance ; [=2018-03-13] 30 | 31 | 2018-03-27 * Account name could be mistaken for commodity 32 | Assets:Test 10.00 EUR 33 | Assets:Commodity-Test123 ; [=2018-03-13] 34 | 35 | 2019-01-16 * Posting date using comment 36 | Assets:Test 10.00 EUR ; [2017-03-04] 37 | Equity:Opening-Balance -10.00 EUR ; [2017-07-08] 38 | 39 | 2019-01-16 * Posting date and aux date using comment 40 | Assets:Test 10.00 EUR ; [2017-03-04=2017-03-05] 41 | Equity:Opening-Balance -10.00 EUR ; [2017-07-08=2017-07-09] 42 | 43 | 2020-03-09 * Test with posting date and comment 44 | Assets:Test 10.00 EUR ; [2018-03-13] Foo Bar 45 | Equity:Opening-Balance 46 | 47 | 2020-03-09 * Test with posting date and comment, but no amount 48 | Assets:Test ; [2018-03-13] Foo Bar 49 | Equity:Opening-Balance -10.00 EUR 50 | 51 | 2020-03-09 * Test with posting aux date and comment 52 | Assets:Test 10.00 EUR ; [=2018-03-13] Foo Bar 53 | Equity:Opening-Balance 54 | 55 | 2020-03-09 * Test with posting aux date and comment, but no amount 56 | Assets:Test ; [=2018-03-13] Foo Bar 57 | Equity:Opening-Balance -10.00 EUR 58 | 59 | 2020-10-01 * Trailing whitespace 60 | Assets:Test 10.00 EUR ; [2020-09-30] 61 | Assets:Test -10.00 EUR 62 | 63 | 2020-10-23 * Posting date and tag 64 | Assets:Test 10.00 EUR ; [2020-09-30] :foo: 65 | Assets:Test -10.00 EUR 66 | 67 | 2020-10-23 * Posting date and metadata 68 | Assets:Test 10.00 EUR ; [2020-09-30] foo: bar 69 | Assets:Test -10.00 EUR 70 | 71 | 2020-10-23 * Aux date and tag 72 | Assets:Test 10.00 EUR ; [=2020-09-30] :foo: 73 | Assets:Test -10.00 EUR 74 | 75 | 2020-10-23 * Aux date and metadata 76 | Assets:Test 10.00 EUR ; [=2020-09-30] foo: bar 77 | Assets:Test -10.00 EUR 78 | 79 | 2020-10-23 * Posting date, aux date and tag 80 | Assets:Test 10.00 EUR ; [2020-10-20=2020-09-30] :foo: 81 | Assets:Test -10.00 EUR 82 | 83 | 2020-10-23 * Posting date, aux date and metadata 84 | Assets:Test 10.00 EUR ; [2020-10-20=2020-09-30] foo: bar 85 | Assets:Test -10.00 EUR 86 | 87 | 2020-10-23 * Comment spacing for comment after date 88 | Assets:Test 10.00 EUR ; [2020-09-30] foo 89 | Equity:Opening-Balance -10.00 EUR 90 | 91 | 2020-10-23 * Comment spacing for comment after date 92 | Assets:Test 10.00 EUR ;[2020-09-30] foo 93 | Equity:Opening-Balance -10.00 EUR 94 | 95 | -------------------------------------------------------------------------------- /tests/balance-assertion.beancount: -------------------------------------------------------------------------------- 1 | ;---------------------------------------------------------------------- 2 | ; ledger2beancount conversion notes: 3 | ; 4 | ; - Account Assets:wallet cash renamed to Assets:Wallet-cash 5 | ; - Account Expenses:Food and drink renamed to Expenses:Food-and-drink 6 | ;---------------------------------------------------------------------- 7 | 8 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 9 | ; 10 | ; SPDX-License-Identifier: GPL-3.0-or-later 11 | 12 | 1970-01-01 open Assets:Test 13 | 1970-01-01 open Assets:Test2 14 | 1970-01-01 open Assets:Test3 15 | 1970-01-01 open Assets:Test4 16 | 1970-01-01 open Assets:Test5 17 | 1970-01-01 open Assets:Test6 18 | 1970-01-01 open Assets:Test7 19 | 1970-01-01 open Assets:Test8 20 | 1970-01-01 open Assets:Test9 21 | 1970-01-01 open Income:Test 22 | 1970-01-01 open Equity:Opening-Balance 23 | 24 | 1970-01-01 commodity EUR 25 | 1970-01-01 commodity USD 26 | 27 | 1970-01-01 open Assets:Cash 28 | 1970-01-01 open Assets:Test10 29 | 1970-01-01 open Assets:Test11 30 | 1970-01-01 open Assets:Wallet 31 | 1970-01-01 open Assets:Wallet-cash 32 | 1970-01-01 open Equity:Adjustments 33 | 1970-01-01 open Expenses:Drinks 34 | 1970-01-01 open Expenses:Food 35 | 1970-01-01 open Expenses:Food-and-drink 36 | 1970-01-01 open Expenses:Tips 37 | 38 | 1970-01-01 commodity GBP 39 | 1970-01-01 commodity THB 40 | 41 | 2018-03-23 * "Test 1" 42 | Assets:Test 10.00 EUR 43 | Equity:Opening-Balance -10.00 EUR 44 | 45 | 2018-03-24 balance Assets:Test 10.00 EUR 46 | 47 | 2018-03-24 * "Test 2" 48 | Assets:Test 10.00 EUR 49 | Equity:Opening-Balance -10.00 EUR 50 | 51 | 2018-03-25 balance Assets:Test 20.00 EUR 52 | 2018-03-25 balance Equity:Opening-Balance -20.00 EUR 53 | 54 | 2019-01-18 * "Assertion with commodity mapping" 55 | Assets:Test2 10.00 USD 56 | Equity:Opening-Balance -10.00 USD 57 | 58 | 2019-01-19 balance Assets:Test2 10.00 USD 59 | 60 | 2019-01-18 txn "KFC" 61 | Expenses:Food 20.00 USD 62 | Assets:Cash -20.00 USD 63 | 64 | 2019-01-19 balance Assets:Cash -20.00 USD 65 | 66 | 2019-01-19 txn "KFC" 67 | Expenses:Food 20.00 USD 68 | Expenses:Drinks 3.00 USD 69 | Assets:Cash 70 | 71 | 2019-01-20 balance Assets:Cash -43.00 USD 72 | 73 | ; account name needs mapping 74 | 2019-01-20 txn "KFC" 75 | Expenses:Food-and-drink 20.00 USD 76 | Expenses:Tips 3.00 USD 77 | Assets:Wallet-cash 78 | 79 | 2019-01-21 balance Assets:Wallet-cash -23.00 USD 80 | 81 | 2019-01-21 pad Assets:Cash Equity:Adjustments 82 | 2019-01-22 balance Assets:Cash 500.00 USD 83 | 84 | 2019-01-25 * "Balance assertion with comment" 85 | Assets:Test3 10.00 EUR ; comment 86 | Equity:Opening-Balance -10.00 EUR 87 | 88 | 2019-01-26 balance Assets:Test3 10.00 EUR 89 | 90 | 2019-01-25 * "Balance assertion with tag" 91 | Assets:Test4 10.00 EUR 92 | tags: "foo" 93 | Equity:Opening-Balance -10.00 EUR 94 | 95 | 2019-01-26 balance Assets:Test4 10.00 EUR 96 | 97 | 2019-01-29 * "Balance assertion with metadata" 98 | Assets:Test5 10.00 EUR 99 | foo: "bar" 100 | Equity:Opening-Balance -10.00 EUR 101 | 102 | 2019-01-30 balance Assets:Test5 10.00 EUR 103 | 104 | 2019-01-29 pad Assets:Test6 Equity:Adjustments 105 | 2019-01-30 balance Assets:Test6 500.00 USD 106 | 107 | 2019-04-20 txn "Wallet" 108 | Assets:Wallet 500.00 THB 109 | Equity:Opening-Balance 110 | 111 | 2019-04-28 txn "Food" 112 | Expenses:Food 10.00 THB 113 | Assets:Wallet 114 | 115 | 2019-04-29 balance Assets:Wallet 490.00 THB 116 | 117 | 2020-02-15 txn "Specify amount" 118 | Assets:Test7 20.00 EUR 119 | Equity:Opening-Balance -20.00 EUR 120 | 121 | 2020-02-15 note Assets:Test7 "Balance assertion with 0 value" 122 | 123 | 2020-02-16 balance Assets:Test7 20.00 EUR 124 | 125 | 2020-02-15 txn "Specify amount" 126 | Assets:Test8 30.00 EUR 127 | Equity:Opening-Balance -30.00 EUR 128 | 129 | 2020-02-15 note Assets:Test8 "Balance assignment with a single posting" 130 | 131 | 2020-02-16 balance Assets:Test8 30.00 EUR 132 | 133 | 2020-02-15 note Assets:Test8 "Balance assignment with a single posting" 134 | 135 | 2020-02-16 balance Assets:Test8 30.00 EUR 136 | 137 | 2020-02-15 note Assets:Test8 "Balance assignment with a single posting" 138 | 139 | 2020-02-16 balance Assets:Test8 30.00 EUR 140 | 141 | 2020-02-15 note Assets:Test8 "Balance assignment with a single posting" 142 | 143 | 2020-02-16 balance Assets:Test8 30.00 EUR 144 | 145 | 2020-02-15 note Assets:Test8 "Balance assignment with a single posting" 146 | 147 | 2020-02-16 balance Assets:Test8 30.00 EUR 148 | 149 | 2020-02-15 txn "Specify amount" 150 | Assets:Test9 40.00 EUR 151 | Equity:Opening-Balance -40.00 EUR 152 | 153 | 154 | 2020-02-15 * "Balance assertion with a single posting - use bucket to balance" 155 | Assets:Test9 5.00 EUR 156 | Income:Test 157 | 158 | 2020-02-16 balance Assets:Test9 45.00 EUR 159 | 160 | 2020-06-22 * "Balance assignment with inline math" 161 | Assets:Test10 1 GBP 162 | Assets:Test11 163 | 164 | 2020-06-23 balance Assets:Test10 0.25+ 0.75 GBP 165 | 166 | 2022-12-18 balance Assets:Test7 20.00 EUR 167 | 168 | -------------------------------------------------------------------------------- /tests/balance-assertion.ledger: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | account Assets:Test 6 | account Assets:Test2 7 | account Assets:Test3 8 | account Assets:Test4 9 | account Assets:Test5 10 | account Assets:Test6 11 | account Assets:Test7 12 | account Assets:Test8 13 | account Assets:Test9 14 | account Income:Test 15 | account Equity:Opening-Balance 16 | 17 | commodity EUR 18 | commodity $ 19 | 20 | 2018-03-23 * Test 1 21 | Assets:Test 10.00 EUR = 10.00 EUR 22 | Equity:Opening-Balance -10.00 EUR 23 | 24 | 2018-03-24 * Test 2 25 | Assets:Test 10.00 EUR = 20.00 EUR 26 | Equity:Opening-Balance -10.00 EUR = -20.00 EUR 27 | 28 | 2019-01-18 * Assertion with commodity mapping 29 | Assets:Test2 $10.00 = $10.00 30 | Equity:Opening-Balance -$10.00 31 | 32 | 2019-01-18 KFC 33 | Expenses:Food $20.00 34 | Assets:Cash $-20.00 = $-20.00 35 | 36 | 2019-01-19 KFC 37 | Expenses:Food $20.00 38 | Expenses:Drinks $3.00 39 | Assets:Cash = $-43.00 40 | 41 | ; account name needs mapping 42 | 2019-01-20 KFC 43 | Expenses:Food and drink $20.00 44 | Expenses:Tips $3.00 45 | Assets:wallet cash = $-23.00 46 | 47 | 2019-01-21 Adjustment 48 | Assets:Cash = $500.00 49 | Equity:Adjustments 50 | 51 | 2019-01-25 * Balance assertion with comment 52 | Assets:Test3 10.00 EUR = 10.00 EUR ; comment 53 | Equity:Opening-Balance -10.00 EUR 54 | 55 | 2019-01-25 * Balance assertion with tag 56 | Assets:Test4 10.00 EUR = 10.00 EUR ; :foo: 57 | Equity:Opening-Balance -10.00 EUR 58 | 59 | 2019-01-29 * Balance assertion with metadata 60 | Assets:Test5 10.00 EUR = 10.00 EUR ; foo: bar 61 | Equity:Opening-Balance -10.00 EUR 62 | 63 | 2019-01-29 Adjustment 64 | ; :foo: 65 | Assets:Test6 = $500.00 66 | Equity:Adjustments 67 | 68 | 2019-04-20 Wallet 69 | Assets:Wallet 500.00 THB 70 | Equity:Opening-Balance 71 | 72 | 2019-04-28 Food 73 | Expenses:Food 10.00 THB 74 | Assets:Wallet = 490.00 THB 75 | 76 | 2020-02-15 Specify amount 77 | Assets:Test7 20.00 EUR 78 | Equity:Opening-Balance -20.00 EUR 79 | 80 | 2020-02-15 * Balance assertion with 0 value 81 | Assets:Test7 0.00 EUR = 20.00 EUR 82 | 83 | 2020-02-15 Specify amount 84 | Assets:Test8 30.00 EUR 85 | Equity:Opening-Balance -30.00 EUR 86 | 87 | 2020-02-15 * Balance assignment with a single posting 88 | Assets:Test8 = 30.00 EUR 89 | 90 | 2020-02-15 * Balance assignment with a single posting 91 | Assets:Test8 = 30.00 EUR 92 | 93 | 2020-02-15 * Balance assignment with a single posting 94 | Assets:Test8 0 = 30.00 EUR 95 | 96 | 2020-02-15 * Balance assignment with a single posting 97 | Assets:Test8 0.00 = 30.00 EUR 98 | 99 | 2020-02-15 * Balance assignment with a single posting 100 | Assets:Test8 0.00 EUR = 30.00 EUR 101 | 102 | 2020-02-15 Specify amount 103 | Assets:Test9 40.00 EUR 104 | Equity:Opening-Balance -40.00 EUR 105 | 106 | bucket Income:Test 107 | 108 | 2020-02-15 * Balance assertion with a single posting - use bucket to balance 109 | Assets:Test9 5.00 EUR = 45.00 EUR 110 | 111 | 2020-06-22 * Balance assignment with inline math 112 | Assets:Test10 1 GBP = (0.25 GBP + 0.75 GBP) 113 | Assets:Test11 114 | 115 | 2022-12-17 116 | Assets:Test7 0.00 EUR = 20.00 EUR 117 | 118 | -------------------------------------------------------------------------------- /tests/bug214.beancount: -------------------------------------------------------------------------------- 1 | ; Ensure there are no "uninitialized value" warnings from reading 2 | ; the stanza when a commodity directive is at the end of a file. 3 | 1970-01-01 commodity EUR 4 | -------------------------------------------------------------------------------- /tests/bug214.ledger: -------------------------------------------------------------------------------- 1 | ; Ensure there are no "uninitialized value" warnings from reading 2 | ; the stanza when a commodity directive is at the end of a file. 3 | commodity EUR 4 | -------------------------------------------------------------------------------- /tests/bug237.beancount: -------------------------------------------------------------------------------- 1 | 2 | 1970-01-01 open Expenses:Transport:Zug 3 | 1970-01-01 open Assets:Giro 4 | 5 | 1970-01-01 commodity EUR 6 | 7 | 2020-03-06 * "Deutsche Bahn" "7B6E33" 8 | Expenses:Transport:Zug 3.85 EUR 9 | Assets:Giro 10 | 11 | -------------------------------------------------------------------------------- /tests/bug237.ledger: -------------------------------------------------------------------------------- 1 | 2 | account Expenses:Transport:Zug 3 | account Assets:Giro 4 | 5 | 2020/03/06 * Deutsche Bahn 6 | ; thing: 7B6E33 7 | Expenses:Transport:Zug €3.85 8 | Assets:Giro 9 | 10 | -------------------------------------------------------------------------------- /tests/bug237.yaml: -------------------------------------------------------------------------------- 1 | payee_split: 2 | - (?.*) 3 | 4 | narration_tag: thing 5 | -------------------------------------------------------------------------------- /tests/bug245.beancount: -------------------------------------------------------------------------------- 1 | ;---------------------------------------------------------------------- 2 | ; ledger2beancount conversion notes: 3 | ; 4 | ; - Amount without commodity found; set default_commodity in config 5 | ;---------------------------------------------------------------------- 6 | 7 | 8 | 1970-01-01 open Assets:A 9 | 1970-01-01 open Assets:B 10 | 11 | 1970-01-01 commodity XXX 12 | 13 | 2021-02-17 * "Test" 14 | Assets:A 15.00 XXX 15 | Assets:B 16 | 17 | -------------------------------------------------------------------------------- /tests/bug245.hledger: -------------------------------------------------------------------------------- 1 | 2 | 2021-02-17 * Test 3 | Assets:A 15.00 4 | Assets:B 5 | 6 | -------------------------------------------------------------------------------- /tests/bug245.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | hledger: true 4 | -------------------------------------------------------------------------------- /tests/code.beancount: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | 1970-01-01 open Assets:Test 6 | 1970-01-01 open Equity:Opening-Balance 7 | 8 | 1970-01-01 commodity EUR 9 | 10 | ; Integer 11 | 2018-03-17 * "Test" 12 | code: "1201" 13 | Assets:Test 10.00 EUR 14 | Equity:Opening-Balance -10.00 EUR 15 | 16 | ; String 17 | 2018-03-17 * "Test" 18 | code: "AT20" 19 | Assets:Test 10.00 EUR 20 | Equity:Opening-Balance -10.00 EUR 21 | 22 | ; Code but no flag 23 | 2018-03-17 txn "Test" 24 | code: "AT20" 25 | Assets:Test 10.00 EUR 26 | Equity:Opening-Balance -10.00 EUR 27 | 28 | 2018-05-16 * "Code without space" 29 | code: "1201" 30 | Assets:Test 10.00 EUR 31 | Equity:Opening-Balance -10.00 EUR 32 | 33 | 2018-05-16 * "Code without space" 34 | code: "AT20" 35 | Assets:Test 10.00 EUR 36 | Equity:Opening-Balance -10.00 EUR 37 | 38 | 2018-05-16 txn "Code without space, no flag" 39 | code: "1201" 40 | Assets:Test 10.00 EUR 41 | Equity:Opening-Balance -10.00 EUR 42 | 43 | 2018-05-16 txn "Code without space, no flag" 44 | code: "AT20" 45 | Assets:Test 10.00 EUR 46 | Equity:Opening-Balance -10.00 EUR 47 | 48 | -------------------------------------------------------------------------------- /tests/code.ledger: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | account Assets:Test 6 | account Equity:Opening-Balance 7 | 8 | commodity EUR 9 | 10 | ; Integer 11 | 2018-03-17 * (1201) Test 12 | Assets:Test 10.00 EUR 13 | Equity:Opening-Balance -10.00 EUR 14 | 15 | ; String 16 | 2018-03-17 * (AT20) Test 17 | Assets:Test 10.00 EUR 18 | Equity:Opening-Balance -10.00 EUR 19 | 20 | ; Code but no flag 21 | 2018-03-17 (AT20) Test 22 | Assets:Test 10.00 EUR 23 | Equity:Opening-Balance -10.00 EUR 24 | 25 | 2018-05-16 *(1201)Code without space 26 | Assets:Test 10.00 EUR 27 | Equity:Opening-Balance -10.00 EUR 28 | 29 | 2018-05-16 *(AT20)Code without space 30 | Assets:Test 10.00 EUR 31 | Equity:Opening-Balance -10.00 EUR 32 | 33 | 2018-05-16 (1201)Code without space, no flag 34 | Assets:Test 10.00 EUR 35 | Equity:Opening-Balance -10.00 EUR 36 | 37 | 2018-05-16 (AT20)Code without space, no flag 38 | Assets:Test 10.00 EUR 39 | Equity:Opening-Balance -10.00 EUR 40 | 41 | -------------------------------------------------------------------------------- /tests/comments.beancount: -------------------------------------------------------------------------------- 1 | ; Beancount: 2.1.0 2 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 3 | ; 4 | ; SPDX-License-Identifier: GPL-3.0-or-later 5 | 6 | ; -*- mode: beancount -*- 7 | ;; -*- mode: beancount -*- 8 | 9 | * -*- mode: beancount -*- 10 | 11 | 1970-01-01 open Assets:Test 12 | 1970-01-01 open Equity:Opening-Balance 13 | 1970-01-01 open Assets:Commodity-Test123 14 | 15 | 1970-01-01 commodity EUR 16 | 17 | ; This is a block comment 18 | ; Second line 19 | 20 | ; Comment without indentation 21 | ; Second line 22 | 23 | ; Another comment 24 | 25 | ; test can be ended with end comment 26 | 27 | ; comment can be ended with end test 28 | 29 | ; This is another block comment 30 | 31 | ; No indentation, followed by 32 | ; indentation. 33 | 34 | ; Indentation, followed by 35 | ; no indentation. 36 | 37 | ; This is a single line comment, 38 | # and this, 39 | % and this, 40 | ; and this, 41 | * and this. 42 | 43 | ; This is a comment 44 | ; Test: not a tag 45 | ; :not:a:tag: 46 | ; Another comment 47 | 48 | 2018-03-17 * "Test" 49 | ; Another comment 50 | Assets:Test 10.00 EUR ; What an "interesting" account name 51 | ; full line posting comment 52 | Equity:Opening-Balance -10.00 EUR ; Opening balance? 53 | ; posting-level comment 54 | 55 | 2018-03-17 * "Tag and comment on same line" 56 | #tag 57 | ; comment 58 | Assets:Test 10.00 EUR 59 | Equity:Opening-Balance -10.00 EUR 60 | 61 | 2018-03-17 * "Multi-line comment" 62 | ; comment1 63 | ; comment2 64 | Assets:Test 10.00 EUR 65 | Equity:Opening-Balance -10.00 EUR 66 | 67 | 2018-03-27 * "Account name could be mistaken for commodity" 68 | Assets:Test 10.00 EUR 69 | Assets:Commodity-Test123 ; comment 70 | 71 | 2018-03-27 * "Account name could be mistaken for commodity" 72 | Assets:Test 10.00 EUR 73 | Assets:Commodity-Test123 ; comment 74 | 75 | 2019-01-25 * "A payee can contain ; without problems" 76 | Assets:Test 10.00 EUR 77 | Equity:Opening-Balance -10.00 EUR 78 | 79 | 2019-01-25 * "You can put a comment on the same line as the payee" ; comment 80 | Assets:Test 10.00 EUR 81 | Equity:Opening-Balance -10.00 EUR 82 | 83 | 2019-01-25 * "You can put a comment on the same line as the payee" ; this is a comment 84 | Assets:Test 10.00 EUR 85 | Equity:Opening-Balance -10.00 EUR 86 | 87 | ;No space 88 | 2020-10-01 * "Comment spacing" 89 | ;No space 90 | Assets:Test 10.00 EUR;No space 91 | Equity:Opening-Balance -10.00 EUR 92 | 93 | ; Two space 94 | 2020-10-01 * "Comment spacing" 95 | ; Two space 96 | Assets:Test 10.00 EUR; Two space 97 | Equity:Opening-Balance -10.00 EUR 98 | 99 | 2020-10-01 * "Empty comment, with trailing whitespace" 100 | Assets:Test 10.00 EUR ; 101 | Assets:Test -10.00 EUR 102 | 103 | 2020-10-23 * "Payee" ; comment which starts with two spaces 104 | Assets:Test 10.00 EUR 105 | Assets:Test -10.00 EUR 106 | 107 | 2020-10-23 * "Payee" ; comment which starts with tab 108 | Assets:Test 10.00 EUR 109 | Assets:Test -10.00 EUR 110 | 111 | 2020-10-23 * "Empty comment" 112 | Assets:Test 10.00 EUR ; 113 | Assets:Test -10.00 EUR 114 | 115 | 2020-10-23 * "Comment spacing" 116 | ; Tab 117 | Assets:Test 10.00 EUR ; Tab 118 | Equity:Opening-Balance -10.00 EUR 119 | 120 | 2020-10-23 * "Empty comments" 121 | Assets:Test 10.00 EUR ; 122 | Assets:Test 10.00 EUR ; 123 | Assets:Test 10.00 EUR ; 124 | Assets:Test 10.00 EUR ; 125 | ; 126 | ; 127 | ; 128 | ; 129 | ; 130 | Equity:Opening-Balance 131 | 132 | -------------------------------------------------------------------------------- /tests/comments.ledger: -------------------------------------------------------------------------------- 1 | ; Beancount: 2.1.0 2 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 3 | ; 4 | ; SPDX-License-Identifier: GPL-3.0-or-later 5 | 6 | ; -*- ledger -*- 7 | ;; -*- ledger -*- 8 | 9 | * -*- ledger -*- 10 | 11 | account Assets:Test 12 | account Equity:Opening-Balance 13 | account Assets:Commodity-Test123 14 | 15 | commodity EUR 16 | 17 | comment 18 | This is a block comment 19 | Second line 20 | end comment 21 | 22 | comment 23 | Comment without indentation 24 | Second line 25 | end comment 26 | 27 | test 28 | Another comment 29 | end test 30 | 31 | test 32 | test can be ended with end comment 33 | end comment 34 | 35 | comment 36 | comment can be ended with end test 37 | end test 38 | 39 | !comment 40 | This is another block comment 41 | end comment 42 | 43 | @comment 44 | No indentation, followed by 45 | indentation. 46 | end comment 47 | 48 | @comment 49 | Indentation, followed by 50 | no indentation. 51 | end comment 52 | 53 | ; This is a single line comment, 54 | # and this, 55 | % and this, 56 | | and this, 57 | * and this. 58 | 59 | ; This is a comment 60 | ; Test: not a tag 61 | ; :not:a:tag: 62 | ; Another comment 63 | 64 | 2018-03-17 * Test 65 | ; Another comment 66 | Assets:Test 10.00 EUR ; What an "interesting" account name 67 | ; full line posting comment 68 | Equity:Opening-Balance -10.00 EUR ; Opening balance? 69 | ; posting-level comment 70 | 71 | 2018-03-17 * Tag and comment on same line 72 | ; :tag: comment 73 | Assets:Test 10.00 EUR 74 | Equity:Opening-Balance -10.00 EUR 75 | 76 | 2018-03-17 * Multi-line comment 77 | ; comment1 78 | ; comment2 79 | Assets:Test 10.00 EUR 80 | Equity:Opening-Balance -10.00 EUR 81 | 82 | 2018-03-27 * Account name could be mistaken for commodity 83 | Assets:Test 10.00 EUR 84 | Assets:Commodity-Test123 ; comment 85 | 86 | 2018-03-27 * Account name could be mistaken for commodity 87 | Assets:Test 10.00 EUR 88 | Assets:Commodity-Test123 ; comment 89 | 90 | 2019-01-25 * A payee can contain ; without problems 91 | Assets:Test 10.00 EUR 92 | Equity:Opening-Balance -10.00 EUR 93 | 94 | 2019-01-25 * You can put a comment on the same line as the payee ; comment 95 | Assets:Test 10.00 EUR 96 | Equity:Opening-Balance -10.00 EUR 97 | 98 | 2019-01-25 * You can put a comment on the same line as the payee ; this is a comment 99 | Assets:Test 10.00 EUR 100 | Equity:Opening-Balance -10.00 EUR 101 | 102 | ;No space 103 | 2020-10-01 * Comment spacing 104 | ;No space 105 | Assets:Test 10.00 EUR;No space 106 | Equity:Opening-Balance -10.00 EUR 107 | 108 | ; Two space 109 | 2020-10-01 * Comment spacing 110 | ; Two space 111 | Assets:Test 10.00 EUR; Two space 112 | Equity:Opening-Balance -10.00 EUR 113 | 114 | 2020-10-01 * Empty comment, with trailing whitespace 115 | Assets:Test 10.00 EUR ; 116 | Assets:Test -10.00 EUR 117 | 118 | 2020-10-23 * Payee ; comment which starts with two spaces 119 | Assets:Test 10.00 EUR 120 | Assets:Test -10.00 EUR 121 | 122 | 2020-10-23 * Payee ; comment which starts with tab 123 | Assets:Test 10.00 EUR 124 | Assets:Test -10.00 EUR 125 | 126 | 2020-10-23 * Empty comment 127 | Assets:Test 10.00 EUR ; 128 | Assets:Test -10.00 EUR 129 | 130 | 2020-10-23 * Comment spacing 131 | ; Tab 132 | Assets:Test 10.00 EUR ; Tab 133 | Equity:Opening-Balance -10.00 EUR 134 | 135 | 2020-10-23 * Empty comments 136 | Assets:Test 10.00 EUR ; 137 | Assets:Test 10.00 EUR ; 138 | Assets:Test 10.00 EUR ; 139 | Assets:Test 10.00 EUR ; 140 | ; 141 | ; 142 | ; 143 | ; 144 | ; 145 | Equity:Opening-Balance 146 | 147 | -------------------------------------------------------------------------------- /tests/commodities.beancount: -------------------------------------------------------------------------------- 1 | ;---------------------------------------------------------------------- 2 | ; ledger2beancount conversion notes: 3 | ; 4 | ; - Skipped second commodity declaration for USD (old USD) 5 | ; - Commodity "A commodity" renamed to A-COMMODITY 6 | ; - Commodity "M&M3" renamed to M-M3 7 | ; - Commodity 'TEST' renamed to XTESTX 8 | ; - Commodity AnotherAnotherAnotherAnother renamed to ANOTHERANOTHERANOTHERANO 9 | ; - Commodity Aud renamed to AUD 10 | ; - Commodity Bär renamed to BAR 11 | ; - Commodity C renamed to CX 12 | ; - Commodity Crown♛ renamed to CROWNX 13 | ; - Commodity Föö renamed to FOO 14 | ; - Commodity Gandi renamed to GANDI 15 | ; - Commodity KrisFlyer renamed to KRISFLYER 16 | ; - Commodity T'EST renamed to T-EST 17 | ; - Commodity TE"ST renamed to TE-ST 18 | ; - Commodity TEST" renamed to TESTX 19 | ; - Commodity krw renamed to KRW 20 | ; - Collision for commodity COLLISION: COLLA, COLLB 21 | ; - Collision for commodity USD: $, USD 22 | ;---------------------------------------------------------------------- 23 | 24 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 25 | ; 26 | ; SPDX-License-Identifier: GPL-3.0-or-later 27 | 28 | 1970-01-01 open Assets:Test 29 | 1970-01-01 open Assets:Test123 30 | 1970-01-01 open Expenses:Gandi ; test comment 31 | 1970-01-01 open Equity:Opening-Balance 32 | 33 | 1970-01-01 commodity A-COMMODITY 34 | 1970-01-01 commodity ANOTHER ; just a comment 35 | 1970-01-01 commodity ANOTHERANOTHERANOTHERANO 36 | 1970-01-01 commodity UR 37 | 1970-01-01 commodity DE0002635307 38 | 39 | 1970-01-01 commodity USD 40 | ; value 0.90 EUR 41 | 42 | 43 | 1970-01-01 commodity EUR 44 | name: "Euro" 45 | ; nomarket 46 | ; default 47 | 48 | 1970-01-01 commodity GANDI 49 | name: "Gandi points" 50 | 1970-01-01 commodity KRISFLYER 51 | 1970-01-01 commodity MILESMORE 52 | 1970-01-01 commodity MILESMORE2 53 | 1970-01-01 commodity M-M3 54 | 1970-01-01 commodity MILESMORE4 55 | 1970-01-01 commodity MR 56 | name: "AMEX Membership Rewards" 57 | 58 | 1970-01-01 commodity KRW 59 | 1970-01-01 commodity AUD 60 | 1970-01-01 commodity CROWNX 61 | 1970-01-01 commodity BAR 62 | 1970-01-01 commodity FOO 63 | 64 | 1970-01-01 commodity MOETZ 65 | 1970-01-01 commodity MOO 66 | 67 | 1970-01-01 commodity TEST123 ; comment with "quote" 68 | 69 | 1970-01-01 commodity AA 70 | 1970-01-01 commodity COLLISION 71 | 1970-01-01 commodity CX 72 | 1970-01-01 commodity T-EST 73 | 1970-01-01 commodity TE-ST 74 | 1970-01-01 commodity TESTX 75 | 1970-01-01 commodity XTESTX 76 | 77 | 2018-03-17 * "Test quoted commodity" 78 | Assets:Test 1 DE0002635307 79 | Equity:Opening-Balance -1 DE0002635307 80 | 81 | 2018-03-17 * "Test commodity mapping" 82 | Assets:Test 1 UR 83 | Equity:Opening-Balance -1 UR 84 | 85 | 2018-03-18 * "Test quoted commodity with defined mapping" 86 | Assets:Test 1 MILESMORE 87 | Equity:Opening-Balance -1 MILESMORE 88 | 89 | 2018-03-18 * "Test quoted commodity with defined mapping missing quotes" 90 | Assets:Test 1 MILESMORE2 91 | Equity:Opening-Balance -1 MILESMORE2 92 | 93 | 2018-03-18 * "Test upper case" 94 | Assets:Test 1 GANDI 95 | Equity:Opening-Balance -1 GANDI 96 | 97 | 2017-03-31 * "Test with account name containing same string as commodity" 98 | Expenses:Gandi 140616 GANDI 99 | Assets:Test -140616 GANDI 100 | 101 | 2018-03-20 * "Account name ending in digits - digits not part of amount" 102 | Assets:Test123 10.00 EUR 103 | Equity:Opening-Balance 104 | 105 | 2018-03-21 * "Test upper caser for lot price" 106 | Assets:Test 1 MR @ 1 KRISFLYER 107 | Equity:Opening-Balance 108 | 109 | 2018-03-21 * "Invalid character for beancount commodity names" 110 | Assets:Test 1 M-M3 111 | Equity:Opening-Balance 112 | 113 | 2018-03-21 * "Invalid character for beancount commodity names, with mapping" 114 | Assets:Test 1 MILESMORE4 115 | Equity:Opening-Balance 116 | 117 | 2018-03-21 * "Commodity with space" 118 | Assets:Test 1 A-COMMODITY 119 | Equity:Opening-Balance 120 | 121 | 2018-03-21 * "Commodity with space, with mapping" 122 | Assets:Test 1 ANOTHER 123 | Equity:Opening-Balance 124 | 125 | 2018-03-21 * "Commodity is too long for beancount" 126 | Assets:Test 1 ANOTHERANOTHERANOTHERANO 127 | Equity:Opening-Balance 128 | 129 | 2018-03-26 * "Lower case" 130 | Assets:Test 1 KRW 131 | Equity:Opening-Balance 132 | 133 | 2018-03-26 * "Lower case at end" 134 | Assets:Test 1 AUD 135 | Equity:Opening-Balance 136 | 137 | 2018-03-26 * "Non-letter at end" 138 | Assets:Test 1 CROWNX 139 | Equity:Opening-Balance 140 | 141 | 2018-03-26 * "Umlaut in middle" 142 | Assets:Test 1 BAR 143 | Equity:Opening-Balance 144 | 145 | 2018-03-26 * "Umlaut at end" 146 | Assets:Test 1 FOO 147 | Equity:Opening-Balance 148 | 149 | 2018-03-26 * "Mapped before transformation" 150 | Assets:Test 1 MOETZ 151 | Equity:Opening-Balance 152 | 153 | 2018-03-26 * "Mapped after transformation" 154 | Assets:Test 1 MOO 155 | Equity:Opening-Balance 156 | 157 | 2018-03-29 * "Mapping creating collision" 158 | Assets:Test 1 COLLISION 159 | Equity:Opening-Balance 160 | 161 | 2018-03-29 * "Mapping creating collision" 162 | Assets:Test 1 COLLISION 163 | Equity:Opening-Balance 164 | 165 | 2018-04-28 * "Commodity with only 1 letter" 166 | Assets:Test 1 CX 167 | Equity:Opening-Balance 168 | 169 | 2018-04-28 * "Commodity with only 1 letter" 170 | Assets:Test 1 AA 171 | Equity:Opening-Balance 172 | 173 | 2020-07-27 * "Unquoted commodities may contain single quote" 174 | Assets:Test 1 XTESTX 175 | Assets:Test 176 | 177 | 2020-07-27 * "Unquoted commodities may contain single quote" 178 | Assets:Test 1 T-EST 179 | Assets:Test 180 | 181 | 2020-07-27 * "Unquoted commodities may contain double quote" 182 | Assets:Test 1 TE-ST 183 | Assets:Test 184 | 185 | 2020-07-27 * "Unquoted commodities may contain double quote" 186 | Assets:Test 1 TESTX 187 | Assets:Test 188 | 189 | -------------------------------------------------------------------------------- /tests/commodities.ledger: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | account Assets:Test 6 | account Assets:Test123 7 | account Expenses:Gandi ; test comment 8 | account Equity:Opening-Balance 9 | 10 | commodity "A commodity" 11 | commodity "Another commodity" ; just a comment 12 | commodity AnotherAnotherAnotherAnother 13 | @commodity Chase 14 | !commodity "DE0002635307" 15 | 16 | commodity $ 17 | value 0.90 EUR 18 | 19 | commodity USD 20 | alias FOO 21 | 22 | commodity EUR 23 | note Euro 24 | format 1000.00EUR 25 | nomarket 26 | default 27 | 28 | commodity Gandi 29 | note Gandi points 30 | commodity KrisFlyer 31 | commodity "M&M" 32 | commodity "M&M2" 33 | commodity "M&M3" 34 | commodity "M&M4" 35 | commodity MR 36 | note AMEX Membership Rewards 37 | 38 | commodity krw 39 | commodity Aud 40 | commodity Crown♛ 41 | commodity Bär 42 | commodity Föö 43 | 44 | commodity Mötz 45 | commodity M♛O 46 | 47 | commodity "TEST123" ; comment with "quote" 48 | 49 | 2018-03-17 * Test quoted commodity 50 | Assets:Test 1 "DE0002635307" 51 | Equity:Opening-Balance -1 "DE0002635307" 52 | 53 | 2018-03-17 * Test commodity mapping 54 | Assets:Test 1 Chase 55 | Equity:Opening-Balance -1 Chase 56 | 57 | 2018-03-18 * Test quoted commodity with defined mapping 58 | Assets:Test 1 "M&M" 59 | Equity:Opening-Balance -1 "M&M" 60 | 61 | 2018-03-18 * Test quoted commodity with defined mapping missing quotes 62 | Assets:Test 1 "M&M2" 63 | Equity:Opening-Balance -1 "M&M2" 64 | 65 | 2018-03-18 * Test upper case 66 | Assets:Test 1 Gandi 67 | Equity:Opening-Balance -1 Gandi 68 | 69 | 2017-03-31 * Test with account name containing same string as commodity 70 | Expenses:Gandi 140616 Gandi 71 | Assets:Test -140616 Gandi 72 | 73 | 2018-03-20 * Account name ending in digits - digits not part of amount 74 | Assets:Test123 10.00 EUR 75 | Equity:Opening-Balance 76 | 77 | 2018-03-21 * Test upper caser for lot price 78 | Assets:Test 1 MR @ 1 KrisFlyer 79 | Equity:Opening-Balance 80 | 81 | 2018-03-21 * Invalid character for beancount commodity names 82 | Assets:Test 1 "M&M3" 83 | Equity:Opening-Balance 84 | 85 | 2018-03-21 * Invalid character for beancount commodity names, with mapping 86 | Assets:Test 1 "M&M4" 87 | Equity:Opening-Balance 88 | 89 | 2018-03-21 * Commodity with space 90 | Assets:Test 1 "A commodity" 91 | Equity:Opening-Balance 92 | 93 | 2018-03-21 * Commodity with space, with mapping 94 | Assets:Test 1 "Another commodity" 95 | Equity:Opening-Balance 96 | 97 | 2018-03-21 * Commodity is too long for beancount 98 | Assets:Test 1 AnotherAnotherAnotherAnother 99 | Equity:Opening-Balance 100 | 101 | 2018-03-26 * Lower case 102 | Assets:Test 1 krw 103 | Equity:Opening-Balance 104 | 105 | 2018-03-26 * Lower case at end 106 | Assets:Test 1 Aud 107 | Equity:Opening-Balance 108 | 109 | 2018-03-26 * Non-letter at end 110 | Assets:Test 1 Crown♛ 111 | Equity:Opening-Balance 112 | 113 | 2018-03-26 * Umlaut in middle 114 | Assets:Test 1 Bär 115 | Equity:Opening-Balance 116 | 117 | 2018-03-26 * Umlaut at end 118 | Assets:Test 1 Föö 119 | Equity:Opening-Balance 120 | 121 | 2018-03-26 * Mapped before transformation 122 | Assets:Test 1 Mötz 123 | Equity:Opening-Balance 124 | 125 | 2018-03-26 * Mapped after transformation 126 | Assets:Test 1 M♛O 127 | Equity:Opening-Balance 128 | 129 | 2018-03-29 * Mapping creating collision 130 | Assets:Test 1 COLLA 131 | Equity:Opening-Balance 132 | 133 | 2018-03-29 * Mapping creating collision 134 | Assets:Test 1 COLLB 135 | Equity:Opening-Balance 136 | 137 | 2018-04-28 * Commodity with only 1 letter 138 | Assets:Test 1 C 139 | Equity:Opening-Balance 140 | 141 | 2018-04-28 * Commodity with only 1 letter 142 | Assets:Test 1 ♛ 143 | Equity:Opening-Balance 144 | 145 | 2020-07-27 * Unquoted commodities may contain single quote 146 | Assets:Test 1 'TEST' 147 | Assets:Test 148 | 149 | 2020-07-27 * Unquoted commodities may contain single quote 150 | Assets:Test 1 T'EST 151 | Assets:Test 152 | 153 | 2020-07-27 * Unquoted commodities may contain double quote 154 | Assets:Test 1 TE"ST 155 | Assets:Test 156 | 157 | 2020-07-27 * Unquoted commodities may contain double quote 158 | Assets:Test 1 TEST" 159 | Assets:Test 160 | 161 | -------------------------------------------------------------------------------- /tests/dates-month.beancount: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | 6 | 1970-01-01 open Assets:Test 7 | 1970-01-01 open Equity:Opening-Balance 8 | 9 | 1970-01-01 commodity EUR 10 | 1970-01-01 commodity USD 11 | 12 | 2018-03-29 * "Non-ISO 8601 date" 13 | Assets:Test 10.00 EUR 14 | Equity:Opening-Balance -10.00 EUR 15 | 16 | 2020-06-02 * "Date %Y/%m/%d" 17 | Assets:Test 10.00 EUR 18 | Assets:Test 19 | 20 | 2020-06-23 * "Date %Y/%m/%d" 21 | Assets:Test 10.00 EUR 22 | Assets:Test 23 | 24 | 2020-06-02 * "Date %Y-%m-%d" 25 | Assets:Test 10.00 EUR 26 | Assets:Test 27 | 28 | 2020-06-23 * "Date %Y-%m-%d" 29 | Assets:Test 10.00 EUR 30 | Assets:Test 31 | 32 | 33 | 2020-06-02 txn "Date %m/%d" 34 | Assets:Test 10.00 EUR 35 | Assets:Test 36 | 37 | 2020-06-23 txn "Date %m/%d" 38 | Assets:Test 10.00 EUR 39 | Assets:Test 40 | 41 | -------------------------------------------------------------------------------- /tests/dates-month.ledger: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | --input-date-format %Y-%b-%d 6 | 7 | account Assets:Test 8 | account Equity:Opening-Balance 9 | 10 | commodity EUR 11 | commodity USD 12 | 13 | 2018-Mar-29 * Non-ISO 8601 date 14 | Assets:Test 10.00 EUR 15 | Equity:Opening-Balance -10.00 EUR 16 | 17 | 2020/6/2 * Date %Y/%m/%d 18 | Assets:Test 10.00 EUR 19 | Assets:Test 20 | 21 | 2020/06/23 * Date %Y/%m/%d 22 | Assets:Test 10.00 EUR 23 | Assets:Test 24 | 25 | 2020/6/2 * Date %Y-%m-%d 26 | Assets:Test 10.00 EUR 27 | Assets:Test 28 | 29 | 2020/06/23 * Date %Y-%m-%d 30 | Assets:Test 10.00 EUR 31 | Assets:Test 32 | 33 | year 2020 34 | 35 | 6/2 Date %m/%d 36 | Assets:Test 10.00 EUR 37 | Assets:Test 38 | 39 | 06/23 Date %m/%d 40 | Assets:Test 10.00 EUR 41 | Assets:Test 42 | 43 | -------------------------------------------------------------------------------- /tests/dates-month.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | date_format: "%Y-%b-%d" 3 | -------------------------------------------------------------------------------- /tests/dates.beancount: -------------------------------------------------------------------------------- 1 | ;---------------------------------------------------------------------- 2 | ; ledger2beancount conversion notes: 3 | ; 4 | ; - Metadata key Date renamed to date 5 | ;---------------------------------------------------------------------- 6 | 7 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 8 | ; 9 | ; SPDX-License-Identifier: GPL-3.0-or-later 10 | 11 | 1970-01-01 open Assets:Test 12 | 1970-01-01 open Equity:Opening-Balance 13 | 14 | 1970-01-01 commodity EUR 15 | 1970-01-01 commodity USD 16 | 17 | 2018-03-19 * "Non-ISO 8601 date" 18 | Assets:Test 10.00 EUR 19 | Equity:Opening-Balance -10.00 EUR 20 | 21 | 2018-03-20 * "Typed meta data with non-ISO 8601 date" 22 | date: 2017-12-31 23 | Assets:Test 10.00 EUR 24 | Equity:Opening-Balance -10.00 EUR 25 | 26 | 2018-03-20 * "Lot date with non-ISO 8601 date" 27 | Assets:Test 10.00 EUR {1.23 USD, 2018-03-16} 28 | Equity:Opening-Balance -12.30 USD 29 | 30 | 2020-06-02 * "Date %Y/%m/%d" 31 | Assets:Test 10.00 EUR 32 | Assets:Test 33 | 34 | 2020-06-23 * "Date %Y/%m/%d" 35 | Assets:Test 10.00 EUR 36 | Assets:Test 37 | 38 | 2020-06-02 * "Date %Y-%m-%d" 39 | Assets:Test 10.00 EUR 40 | Assets:Test 41 | 42 | 2020-06-23 * "Date %Y-%m-%d" 43 | Assets:Test 10.00 EUR 44 | Assets:Test 45 | 46 | 47 | 2020-06-02 txn "Date %m/%d" 48 | Assets:Test 10.00 EUR 49 | Assets:Test 50 | 51 | 2020-06-23 txn "Date %m/%d" 52 | Assets:Test 10.00 EUR 53 | Assets:Test 54 | 55 | -------------------------------------------------------------------------------- /tests/dates.ledger: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | account Assets:Test 6 | account Equity:Opening-Balance 7 | 8 | commodity EUR 9 | commodity USD 10 | 11 | 2018/03/19 * Non-ISO 8601 date 12 | Assets:Test 10.00 EUR 13 | Equity:Opening-Balance -10.00 EUR 14 | 15 | 2018/03/20 * Typed meta data with non-ISO 8601 date 16 | ; Date:: [2017/12/31] 17 | Assets:Test 10.00 EUR 18 | Equity:Opening-Balance -10.00 EUR 19 | 20 | 2018/03/20 * Lot date with non-ISO 8601 date 21 | Assets:Test 10.00 EUR {1.23 USD} [2018/03/16] @ 1.23 USD 22 | Equity:Opening-Balance -12.30 USD 23 | 24 | 2020/6/2 * Date %Y/%m/%d 25 | Assets:Test 10.00 EUR 26 | Assets:Test 27 | 28 | 2020/06/23 * Date %Y/%m/%d 29 | Assets:Test 10.00 EUR 30 | Assets:Test 31 | 32 | 2020/6/2 * Date %Y-%m-%d 33 | Assets:Test 10.00 EUR 34 | Assets:Test 35 | 36 | 2020/06/23 * Date %Y-%m-%d 37 | Assets:Test 10.00 EUR 38 | Assets:Test 39 | 40 | year 2020 41 | 42 | 6/2 Date %m/%d 43 | Assets:Test 10.00 EUR 44 | Assets:Test 45 | 46 | 06/23 Date %m/%d 47 | Assets:Test 10.00 EUR 48 | Assets:Test 49 | 50 | -------------------------------------------------------------------------------- /tests/dates.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | date_format: "%Y/%m/%d" 3 | -------------------------------------------------------------------------------- /tests/directives.ledger: -------------------------------------------------------------------------------- 1 | ; Beancount: 2.1.0 2 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 3 | ; 4 | ; SPDX-License-Identifier: GPL-3.0-or-later 5 | 6 | --input-date-format %Y-%m-%d 7 | --input-date-format %m-%d 8 | 9 | = expr true 10 | Assets:Foo 50.00 USD 11 | Assets:Bar -50.00 USD 12 | 13 | = /^(?:Income:|Expenses:(?:Business|Rent$|Furnishings|Taxes|Insurance))/ 14 | (Liabilities:Huququ'llah) 0.19 15 | 16 | ~ Yearly 17 | Expenses:Auto:Repair $500.00 18 | Assets 19 | 20 | payee KFC 21 | alias KENTUCKY FRIED CHICKEN 22 | uuid 2a2e21d434356f886c84371eebac6e44f1337fda 23 | 24 | !payee McD 25 | 26 | @payee Burger King 27 | 28 | ; setting year 2014 29 | ; (no space) 30 | Y2014 31 | 32 | 10-02 * Transaction without year 33 | Assets:Test 10.00 EUR 34 | Equity:Opening-Balance -10.00 EUR 35 | 36 | 10-02=10-01 * Transaction without year, with aux date 37 | Assets:Test 10.00 EUR 38 | Equity:Opening-Balance -10.00 EUR 39 | 40 | ; setting year 2015 41 | Y 2015 42 | 43 | 10-02 * Transaction without year 44 | Assets:Test 10.00 EUR 45 | Equity:Opening-Balance -10.00 EUR 46 | 47 | 10-02=10-01 * Transaction without year, with aux date 48 | Assets:Test 10.00 EUR 49 | Equity:Opening-Balance -10.00 EUR 50 | 51 | ; setting year 2016 52 | year 2016 53 | 54 | 10-02 * Transaction without year 55 | Assets:Test 10.00 EUR 56 | Equity:Opening-Balance -10.00 EUR 57 | 58 | 10-02=10-01 * Transaction without year, with aux date 59 | Assets:Test 10.00 EUR 60 | Equity:Opening-Balance -10.00 EUR 61 | 62 | 2018-03-25 * Transaction with year 63 | Assets:Test 10.00 EUR 64 | Equity:Opening-Balance -10.00 EUR 65 | 66 | ; setting year 2018 67 | 68 | apply year 2018 69 | 70 | 10-02 * Transaction without year 71 | Assets:Test 10.00 EUR 72 | Equity:Opening-Balance -10.00 EUR 73 | 74 | 10-02=10-01 * Transaction without year, with aux date 75 | Assets:Test 10.00 EUR 76 | Equity:Opening-Balance -10.00 EUR 77 | 78 | 2015-03-25 * Transaction with year 79 | Assets:Test 10.00 EUR 80 | Equity:Opening-Balance -10.00 EUR 81 | 82 | end apply 83 | 84 | ; apply year can be nested 85 | 86 | apply year 2013 87 | 88 | 04-13 Test apply year - 2013 89 | Assets:Test 10.00 EUR 90 | Equity:Opening-Balance -10.00 EUR 91 | 92 | apply year 2014 93 | 94 | apply year 2015 95 | 96 | 04-13 Test apply year - 2015 97 | Assets:Test 10.00 EUR 98 | Equity:Opening-Balance -10.00 EUR 99 | 100 | end apply 101 | 102 | 04-13 Test apply year - 2014 103 | Assets:Test 10.00 EUR 104 | Equity:Opening-Balance -10.00 EUR 105 | 106 | end apply 107 | 108 | 04-13 Test apply year - 2013 109 | Assets:Test 10.00 EUR 110 | Equity:Opening-Balance -10.00 EUR 111 | 112 | end apply 113 | 114 | 04-13 Test year after apply year - should be back to last year directive: 2016 115 | Assets:Test 10.00 EUR 116 | Equity:Opening-Balance -10.00 EUR 117 | 118 | !include include1.ledger 119 | @include include2.ledger 120 | include include3.ledger 121 | 122 | ; Test apply account and apply tag 123 | 124 | !apply account Assets: 125 | apply tag foo 126 | apply tag bar 127 | apply tag 2018-02-02-brussels-fosdem 128 | apply tag test: martin 129 | @apply account Test1::::::::::: 130 | @apply account Test2 131 | 132 | 2018-03-29 * Test apply 133 | AA 10.00 EUR 134 | BB 135 | 136 | 2018-03-29 * Test apply 137 | CC:DD 10.00 EUR 138 | EE:FF 139 | 140 | end apply 141 | end apply 142 | end apply 143 | end apply 144 | end apply 145 | end apply 146 | end apply 147 | 148 | ; Test apply account and alias 149 | 150 | alias BB=Assets:What:A:Long:Name 151 | !apply account Assets: 152 | @apply account Test1::::::::::: 153 | @apply account Test2 154 | 155 | 2018-03-29 * Test apply 156 | AA 10.00 EUR 157 | BB 158 | 159 | alias BB=Another:Alias 160 | apply account XXX 161 | 162 | 2018-03-29 * Test apply 163 | AA 10.00 EUR 164 | BB 165 | 166 | end apply 167 | end apply 168 | end apply 169 | end apply 170 | 171 | 2018-03-29 * Test apply 172 | Assets:GG 10.00 EUR 173 | BB 174 | 175 | alias BB=Assets:Another:Alias 176 | 177 | 2018-03-29 * Test apply 178 | Assets:GG 10.00 EUR 179 | BB 180 | 181 | bucket Assets:Checking 182 | 183 | 2018-03-29 * Bucket 184 | Assets:Test 10.00 EUR 185 | 186 | A Assets:Savings 187 | 188 | 2018-03-29 * Bucket 189 | Assets:Test 10.00 EUR 190 | 191 | !tag foo 192 | @tag bar 193 | tag baz 194 | 195 | tag Project 196 | check value =~ /^(0ad|ankur|aptosid|archlinux|chakra|debian)$/ 197 | 198 | ; timeclock 199 | i 2018-03-29 14:10:20 B 200 | o 2018-03-29 14:50:00 201 | I 2018-03-29 14:55:40 B 202 | O 2018-03-29 15:10:10 203 | b 2018-03-29 14:10:20 204 | h 2018-03-29 14:10:20 205 | ; commodity conversion 206 | C 1.00 Mb = 1024 Kb 207 | ; Default Commodity 208 | D 1000.00 EUR 209 | ; Ignore pricing information 210 | N EUR 211 | 212 | import os 213 | 214 | python 215 | def print_type(val): 216 | print(type(val), val) 217 | 218 | eval print_type(true) 219 | 220 | python 221 | def option_pyfirst(context): 222 | print("In --pyfirst (from %s)" % context) 223 | 224 | def option_pysecond(context, val): 225 | print("In --pysecond=%s (from %s)" % (val, context)) 226 | 2019-04-28 * Transactions can follow python without empty line 227 | Assets:Test 10.00 EUR 228 | Equity:Opening-Balance -10.00 EUR 229 | 230 | define myfunc_seven(s, d, t) = 7 EUR 231 | 232 | ;; The 'value' directive sets the valuation used for all commodities used in 233 | ;; the rest of the daat stream. This is the fallback, if nothing more 234 | ;; specific is found. 235 | 236 | value myfunc_seven 237 | 238 | def foo=200 USD 239 | define hundred=$100 240 | !define twenty = $20 241 | @define my_var = $5 242 | def thousand=$1000 243 | 244 | 2020-06-27 Using define 245 | Assets:Test (foo) 246 | Equity:Opening-Balance 247 | 248 | 2020-06-27 Using define 249 | Assets:Test (my_var*4) 250 | Equity:Opening-Balance 251 | 252 | 2020-06-27 Using define 253 | Assets:Test (hundred*4) 254 | Equity:Opening-Balance 255 | 256 | 2020-06-27 Using multiple define 257 | Assets:Test (hundred*4 + twenty) 258 | Equity:Opening-Balance 259 | 260 | 2020-06-27 Using multiple define 261 | Assets:Test (thousand + hundred*4 + twenty) 262 | Equity:Opening-Balance 263 | 264 | apply tag foo!bar 265 | 266 | 2022-12-16 * Tag not valid in beancount 267 | Assets:Test 10.00 EUR 268 | Assets:Test 269 | 270 | end apply 271 | 272 | apply tag WTF??? 273 | 274 | 2022-12-16 * Tag in tag_map 275 | Assets:Test 10.00 EUR 276 | Assets:Test 277 | 278 | end apply 279 | 280 | apply tag 10!20 281 | 282 | 2022-12-16 * Link and link_match 283 | Assets:Test 10.00 EUR 284 | Assets:Test 285 | 286 | end apply 287 | 288 | -------------------------------------------------------------------------------- /tests/fixated.beancount: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2019 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | 1970-01-01 open Assets:Brokerage 6 | 1970-01-01 open Assets:Brokerage:Cash 7 | 1970-01-01 open Assets:Test 8 | 1970-01-01 open Assets:Wallet 9 | 1970-01-01 open Expenses:Food 10 | 11 | 1970-01-01 commodity AA 12 | 1970-01-01 commodity AAPL 13 | 1970-01-01 commodity CAD 14 | 1970-01-01 commodity EUR 15 | 1970-01-01 commodity PHP 16 | 1970-01-01 commodity USD 17 | 18 | 2012-04-10 txn "My Broker" 19 | Assets:Brokerage 10 AAPL {50.00 USD} 20 | Assets:Brokerage:Cash -500.00 USD 21 | 22 | 2012-04-11 txn "My Broker" 23 | Assets:Brokerage 10 AAPL {50.00 USD} 24 | Assets:Brokerage:Cash -500.00 USD 25 | 26 | ; Only apply fixated to CAD, not to EUR 27 | 28 | 29 | 2012-04-10 txn "Lunch in Canada" 30 | Assets:Wallet -15.50 CAD {0.20 USD} 31 | Expenses:Food 15.50 CAD {0.20 USD} 32 | 33 | 2012-04-10 txn "Lunch in Canada" 34 | Assets:Wallet -15.50 CAD {0.90 USD} 35 | Expenses:Food 15.50 CAD {0.90 USD} 36 | 37 | 2012-04-11 txn "Second day Dinner in Canada" 38 | Assets:Wallet -25.75 CAD {0.90 USD} 39 | Expenses:Food 25.75 CAD {0.90 USD} 40 | 41 | 2012-04-11 txn "Paid in EUR" 42 | Assets:Wallet -25.75 EUR 43 | Expenses:Food 25.75 EUR 44 | 45 | 2012-04-11 txn "Paid in EUR" 46 | Assets:Wallet -25.75 EUR 47 | Expenses:Food 48 | 49 | 50 | ; Apply fixated to CAD and EUR 51 | 52 | 53 | 2012-04-10 txn "Lunch in Canada" 54 | Assets:Wallet -15.50 CAD {0.20 USD} 55 | Expenses:Food 15.50 CAD {0.20 USD} 56 | 57 | 2012-04-10 txn "Lunch in Canada" 58 | Assets:Wallet -15.50 CAD {0.90 USD} 59 | Expenses:Food 15.50 CAD {0.90 USD} 60 | 61 | 2012-04-11 txn "Second day Dinner in Canada" 62 | Assets:Wallet -25.75 CAD {0.90 USD} 63 | Expenses:Food 25.75 CAD {0.90 USD} 64 | 65 | 2012-04-11 txn "Second day Dinner in Canada" 66 | Assets:Wallet -25.75 CAD {0.90 USD} 67 | Expenses:Food 68 | 69 | 2012-04-11 txn "Paid in EUR" 70 | Assets:Wallet -25.75 EUR {0.40 CAD} 71 | Expenses:Food 25.75 EUR {0.40 CAD} 72 | 73 | 2012-04-11 txn "Paid in EUR" 74 | Assets:Wallet -25.75 EUR {0.40 CAD} 75 | Expenses:Food 76 | 77 | 78 | 79 | 2012-04-10 txn "Lunch in Canada" 80 | Assets:Wallet -15.50 CAD {0.20 USD} 81 | Expenses:Food 15.50 CAD {0.20 USD} 82 | 83 | 2012-04-10 txn "Lunch in Canada" 84 | Assets:Wallet -15.50 CAD {0.85 USD} 85 | Expenses:Food 15.50 CAD {0.85 USD} 86 | 87 | 88 | 2020-10-02 * "Fixated price should become a cost in beancount" 89 | Expenses:Food 100.00 PHP {1.76 EUR} 90 | Assets:Wallet 91 | 92 | 2020-10-02 * "Fixated price should become a cost in beancount (despite commodity_is_currency)" 93 | Assets:Test 1000 AA {5.00 EUR} 94 | Assets:Test 95 | 96 | -------------------------------------------------------------------------------- /tests/fixated.ledger: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2019 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | 2012-04-10 My Broker 6 | Assets:Brokerage 10 AAPL @ =$50.00 7 | Assets:Brokerage:Cash $-500.00 8 | 9 | 2012-04-11 My Broker 10 | Assets:Brokerage 10 AAPL {=$50.00} 11 | Assets:Brokerage:Cash $-500.00 12 | 13 | ; Only apply fixated to CAD, not to EUR 14 | 15 | apply fixed CAD $0.90 16 | 17 | 2012-04-10 Lunch in Canada 18 | Assets:Wallet -15.50 CAD {$0.20} 19 | Expenses:Food 15.50 CAD {$0.20} 20 | 21 | 2012-04-10 Lunch in Canada 22 | Assets:Wallet -15.50 CAD 23 | Expenses:Food 15.50 CAD 24 | 25 | 2012-04-11 Second day Dinner in Canada 26 | Assets:Wallet -25.75 CAD 27 | Expenses:Food 25.75 CAD 28 | 29 | 2012-04-11 Paid in EUR 30 | Assets:Wallet -25.75 EUR 31 | Expenses:Food 25.75 EUR 32 | 33 | 2012-04-11 Paid in EUR 34 | Assets:Wallet -25.75 EUR 35 | Expenses:Food 36 | 37 | end apply fixed 38 | 39 | ; Apply fixated to CAD and EUR 40 | 41 | apply fixed CAD $0.90 42 | apply fixed EUR 0.40 CAD 43 | 44 | 2012-04-10 Lunch in Canada 45 | Assets:Wallet -15.50 CAD {$0.20} 46 | Expenses:Food 15.50 CAD {$0.20} 47 | 48 | 2012-04-10 Lunch in Canada 49 | Assets:Wallet -15.50 CAD 50 | Expenses:Food 15.50 CAD 51 | 52 | 2012-04-11 Second day Dinner in Canada 53 | Assets:Wallet -25.75 CAD 54 | Expenses:Food 25.75 CAD 55 | 56 | 2012-04-11 Second day Dinner in Canada 57 | Assets:Wallet -25.75 CAD 58 | Expenses:Food 59 | 60 | 2012-04-11 Paid in EUR 61 | Assets:Wallet -25.75 EUR 62 | Expenses:Food 25.75 EUR 63 | 64 | 2012-04-11 Paid in EUR 65 | Assets:Wallet -25.75 EUR 66 | Expenses:Food 67 | 68 | end apply fixed 69 | end apply fixed 70 | 71 | apply rate CAD $0.85 72 | 73 | 2012-04-10 Lunch in Canada 74 | Assets:Wallet -15.50 CAD {$0.20} 75 | Expenses:Food 15.50 CAD {$0.20} 76 | 77 | 2012-04-10 Lunch in Canada 78 | Assets:Wallet -15.50 CAD 79 | Expenses:Food 15.50 CAD 80 | 81 | end apply fixed 82 | 83 | 2020-10-02 * Fixated price should become a cost in beancount 84 | Expenses:Food 100.00 PHP @ =1.76 EUR 85 | Assets:Wallet 86 | 87 | 2020-10-02 * Fixated price should become a cost in beancount (despite commodity_is_currency) 88 | Assets:Test 1000 AA @ =5.00 EUR 89 | Assets:Test 90 | 91 | -------------------------------------------------------------------------------- /tests/flags.beancount: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | 1970-01-01 open Assets:Test 6 | 1970-01-01 open Equity:Opening-Balance 7 | 8 | 1970-01-01 commodity EUR 9 | 10 | 2018-03-17 txn "Test" 11 | Assets:Test 10.00 EUR 12 | Equity:Opening-Balance -10.00 EUR 13 | 14 | 2018-03-17 * "Test" 15 | Assets:Test 10.00 EUR 16 | Equity:Opening-Balance -10.00 EUR 17 | 18 | 2018-03-17 ! "Test" 19 | Assets:Test 10.00 EUR 20 | Equity:Opening-Balance -10.00 EUR 21 | 22 | -------------------------------------------------------------------------------- /tests/flags.ledger: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | account Assets:Test 6 | account Equity:Opening-Balance 7 | 8 | commodity EUR 9 | 10 | 2018-03-17 Test 11 | Assets:Test 10.00 EUR 12 | Equity:Opening-Balance -10.00 EUR 13 | 14 | 2018-03-17 * Test 15 | Assets:Test 10.00 EUR 16 | Equity:Opening-Balance -10.00 EUR 17 | 18 | 2018-03-17 ! Test 19 | Assets:Test 10.00 EUR 20 | Equity:Opening-Balance -10.00 EUR 21 | 22 | -------------------------------------------------------------------------------- /tests/hledger.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | date_format: "%Y/%m/%d" 3 | date_format_no_year: "%m/%d" 4 | 5 | hledger: true 6 | 7 | postdate_tag: date 8 | auxdate_tag: aux-date 9 | 10 | commodity_map: 11 | ₪: ILS 12 | ¥: JPY 13 | Ft: HUF 14 | Kč: CZK 15 | kr: NOK 16 | R$: BRL 17 | zł: PLN 18 | 19 | # mapping of ledger tags to corresponding beancount tag 20 | tag_map: 21 | WTF???: WTF 22 | 23 | link_match: 24 | - ^\d\d!\d\d 25 | -------------------------------------------------------------------------------- /tests/ignore.beancount: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | 6 | 1970-01-01 open Assets:Test1 7 | description: "Test account" 8 | ; default 9 | 10 | 1970-01-01 open Liabilities:CreditCard 11 | 12 | 13 | 14 | 1970-01-01 open Assets:Test3 15 | 1970-01-01 open Equity:Opening-Balance 16 | 17 | 1970-01-01 commodity EUR 18 | 19 | 2018-03-17 * "Test 1" 20 | Assets:Test1 10.00 EUR 21 | Equity:Opening-Balance -10.00 EUR 22 | 23 | 2018-03-17 * "Test 3" 24 | Assets:Test3 10.00 EUR 25 | Equity:Opening-Balance 26 | 27 | 2014-07-09 event "location" "Paris, France" 28 | 2018-09-01 event "location" "Bologna, Italy" 29 | 30 | 2013-11-03 note Liabilities:CreditCard "Called about fraud" 31 | 2013-11-03 note Liabilities:CreditCard "Called about fraud" 32 | 2013-11-03 note Liabilities:CreditCard "Called about fraud" 33 | 34 | -------------------------------------------------------------------------------- /tests/ignore.ledger: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | ; NoL2B begin 6 | ~ Yearly 7 | Expenses:Auto:Repair $500.00 8 | Assets 9 | ; NoL2B end 10 | 11 | account Assets:Test1 12 | note Test account 13 | alias food 14 | default 15 | 16 | account Liabilities:CreditCard 17 | 18 | C 1.00 Mb = 1024 Kb ; NoL2B 19 | 20 | ; NoL2B begin 21 | account Assets:Test2 22 | note Test account 23 | alias food 24 | default 25 | ; NoL2B end 26 | 27 | 2018-03-17 * Test 1 28 | Assets:Test1 10.00 EUR 29 | Equity:Opening-Balance -10.00 EUR 30 | 31 | ; NoL2B begin 32 | 2018-03-17 * Test 2 33 | Assets:Test2 34 | Equity:Opening-Balance -10.00 EUR 35 | 36 | ; NoL2B end 37 | 2018-03-17 * Test 3 38 | Assets:Test3 10.00 EUR 39 | Equity:Opening-Balance 40 | 41 | ; L2Bonly begin 42 | ;2014-07-09 event "location" "Paris, France" 43 | ; 2018-09-01 event "location" "Bologna, Italy" 44 | ; L2Bonly end 45 | 46 | ; 2013-11-03 note Liabilities:CreditCard "Called about fraud" ; L2Bonly 47 | # 2013-11-03 note Liabilities:CreditCard "Called about fraud" ; L2Bonly 48 | *2013-11-03 note Liabilities:CreditCard "Called about fraud" ; L2Bonly 49 | 50 | -------------------------------------------------------------------------------- /tests/ignore.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | # A marker that tells ledger2beancount to ignore a line if the 3 | # marker is found. 4 | ignore_marker: NoL2B 5 | # A marker that tells ledger2beancount to take a line from 6 | # the input that is commented out, uncomment it and display 7 | # it in the output. 8 | keep_marker: L2Bonly 9 | -------------------------------------------------------------------------------- /tests/include1.beancount: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | 1970-01-01 open Assets:Include1a 6 | 1970-01-01 open Assets:Include1b 7 | 8 | 1970-01-01 commodity INC1 9 | 10 | 2018-03-28 * "Include1" 11 | Assets:Include1a 10.00 INC1 12 | Assets:Include1b 13 | 14 | -------------------------------------------------------------------------------- /tests/include1.ledger: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | 2018-03-28 * Include1 6 | Assets:Include1a 10.00 "INC1" 7 | Assets:Include1b 8 | 9 | -------------------------------------------------------------------------------- /tests/include2.beancount: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | 1970-01-01 open Assets:Include2a 6 | 1970-01-01 open Assets:Include2b 7 | 8 | 1970-01-01 commodity INC2 9 | 10 | 2018-03-28 * "Include2" 11 | Assets:Include2a 10.00 INC2 12 | Assets:Include2b 13 | 14 | -------------------------------------------------------------------------------- /tests/include2.ledger: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | 2018-03-28 * Include2 6 | Assets:Include2a 10.00 "INC2" 7 | Assets:Include2b 8 | 9 | -------------------------------------------------------------------------------- /tests/include3.beancount: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | 1970-01-01 open Assets:Include3a 6 | 1970-01-01 open Assets:Include3b 7 | 8 | 1970-01-01 commodity INC3 9 | 10 | 2018-03-28 * "Include3" 11 | Assets:Include3a 10.00 INC3 12 | Assets:Include3b 13 | 14 | -------------------------------------------------------------------------------- /tests/include3.ledger: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | 2018-03-28 * Include3 6 | Assets:Include3a 10.00 "INC3" 7 | Assets:Include3b 8 | 9 | -------------------------------------------------------------------------------- /tests/ledger2beancount.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | date_format: "%Y-%m-%d" 3 | # Date without year (if ledger's Y/year directive is used) 4 | date_format_no_year: "%m-%d" 5 | 6 | # mapping of ledger tags to corresponding beancount tag 7 | tag_map: 8 | WTF???: WTF 9 | aa!bb!cc: aa_bb_cc 10 | 11 | # mapping of ledger metadata key to corresponding beancount key 12 | metadata_map: 13 | label: bank-label 14 | x-payee: payee 15 | x-payer: payer 16 | 17 | # metadata tags (*after* above mapping) used for specific purposes 18 | payee_tag: payee 19 | payer_tag: payer 20 | narration_tag: thing 21 | 22 | payee_split: 23 | - (?.*?)\s+\((?Tesco)\) 24 | 25 | payee_match: 26 | - (?i)^Oyster card top-up: TfL 27 | - ^Marriott reward1.*\(£\d+\.\d+\): Creation 28 | - ^Marriott reward2.*\(.\d+\.\d+\): Creation 29 | - test: test 30 | 31 | account_map: 32 | "Equity:Opening-balance": Equity:Opening-Balance 33 | 34 | # mapping of ledger commodities to valid beancount commodities 35 | commodity_map: 36 | Chase: UR 37 | '"M&M"': MILESMORE 38 | M&M2: MILESMORE2 39 | M-M4: MILESMORE4 40 | Another commodity: ANOTHER 41 | Mötz: MOETZ 42 | M-O: MOO 43 | XX: AA 44 | COLLA: COLLISION 45 | COLLB: COLLISION 46 | 47 | # You can set the following metadata tags to an empty string if you 48 | # don't want the metadata to be added to beancount. 49 | postdate_tag: date 50 | auxdate_tag: aux-date 51 | code_tag: code 52 | 53 | link_match: 54 | - ^\d\d\d\d-\d\d-\d\d- 55 | - ^\d\d!\d\d 56 | 57 | link_tags: 58 | - Trip 59 | - Invoice 60 | 61 | # A list of commodities that should be treated as commodities 62 | # rather than currencies even though they consist of 3 characters 63 | # (which is usually a characteristic of a currency) 64 | currency_is_commodity: 65 | - ETH 66 | 67 | commodity_is_currency: 68 | - MR 69 | 70 | default_commodity: FOO 71 | -------------------------------------------------------------------------------- /tests/lots.header: -------------------------------------------------------------------------------- 1 | option "inferred_tolerance_default" "GBP:0.004" 2 | 3 | -------------------------------------------------------------------------------- /tests/lots.yaml: -------------------------------------------------------------------------------- 1 | beancount_header: lots.header 2 | 3 | commodity_map: 4 | XX: AA 5 | 6 | currency_is_commodity: 7 | - ETH 8 | 9 | commodity_is_currency: 10 | - AA 11 | - MR 12 | - XXXX 13 | -------------------------------------------------------------------------------- /tests/narration.beancount: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | 1970-01-01 open Assets:Test 6 | 1970-01-01 open Equity:Opening-Balance 7 | 8 | 1970-01-01 commodity EUR 9 | 10 | 2018-03-17 * "Test \"quote me\" please" 11 | Assets:Test 10.00 EUR 12 | Equity:Opening-Balance -10.00 EUR 13 | 14 | ; empty narration 15 | 2018-05-16 txn "" 16 | Assets:Test 10.00 EUR 17 | Equity:Opening-Balance -10.00 EUR 18 | 19 | ; empty narration with flag 20 | 2018-05-16 * "" 21 | Assets:Test 10.00 EUR 22 | Equity:Opening-Balance -10.00 EUR 23 | 24 | 2018-05-16 * "No space between flag and narration" 25 | Assets:Test 10.00 EUR 26 | Equity:Opening-Balance -10.00 EUR 27 | 28 | 2019-03-05 txn "Foo\\" 29 | Assets:Test 10.00 EUR 30 | Equity:Opening-Balance -10.00 EUR 31 | 32 | 2019-03-05 txn "Foo\\ bar" 33 | Assets:Test 10.00 EUR 34 | Equity:Opening-Balance -10.00 EUR 35 | 36 | 2019-03-05 txn "Foo\\ \"" 37 | Assets:Test 10.00 EUR 38 | Equity:Opening-Balance -10.00 EUR 39 | 40 | -------------------------------------------------------------------------------- /tests/narration.ledger: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | account Assets:Test 6 | account Equity:Opening-Balance 7 | 8 | commodity EUR 9 | 10 | 2018-03-17 * Test "quote me" please 11 | Assets:Test 10.00 EUR 12 | Equity:Opening-Balance -10.00 EUR 13 | 14 | ; empty narration 15 | 2018-05-16 16 | Assets:Test 10.00 EUR 17 | Equity:Opening-Balance -10.00 EUR 18 | 19 | ; empty narration with flag 20 | 2018-05-16 * 21 | Assets:Test 10.00 EUR 22 | Equity:Opening-Balance -10.00 EUR 23 | 24 | 2018-05-16 *No space between flag and narration 25 | Assets:Test 10.00 EUR 26 | Equity:Opening-Balance -10.00 EUR 27 | 28 | 2019-03-05 Foo\ 29 | Assets:Test 10.00 EUR 30 | Equity:Opening-Balance -10.00 EUR 31 | 32 | 2019-03-05 Foo\ bar 33 | Assets:Test 10.00 EUR 34 | Equity:Opening-Balance -10.00 EUR 35 | 36 | 2019-03-05 Foo\ " 37 | Assets:Test 10.00 EUR 38 | Equity:Opening-Balance -10.00 EUR 39 | 40 | -------------------------------------------------------------------------------- /tests/no-config.beancount: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | 1970-01-01 open Assets:Test 6 | 7 | 1970-01-01 commodity EUR 8 | 1970-01-01 commodity GBP 9 | 1970-01-01 commodity USD 10 | 11 | 2018-09-27 * "Test conversion of built-in commodity codes" 12 | Assets:Test 10.00 EUR 13 | Assets:Test -10.00 EUR 14 | Assets:Test 10.00 GBP 15 | Assets:Test -10.00 GBP 16 | Assets:Test 10.00 USD 17 | Assets:Test -10.00 USD 18 | 19 | -------------------------------------------------------------------------------- /tests/no-config.ledger: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | 2018-09-27 * Test conversion of built-in commodity codes 6 | Assets:Test €10.00 7 | Assets:Test €-10.00 8 | Assets:Test £10.00 9 | Assets:Test £-10.00 10 | Assets:Test $10.00 11 | Assets:Test $-10.00 12 | 13 | -------------------------------------------------------------------------------- /tests/no-config.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | # empty config file 3 | -------------------------------------------------------------------------------- /tests/non-standard-account-root.beancount: -------------------------------------------------------------------------------- 1 | ;---------------------------------------------------------------------- 2 | ; ledger2beancount conversion notes: 3 | ; 4 | ; - Non-standard root name Aktiva used; setting beancount option name_assets 5 | ; - Non-standard root name Eigenkapital used; setting beancount option name_equity 6 | ; - Non-standard root name Ausgaben used; setting beancount option name_expenses 7 | ; - Non-standard root name Ertrag used; setting beancount option name_income 8 | ; - Non-standard root name Passiva used; setting beancount option name_liabilities 9 | ;---------------------------------------------------------------------- 10 | 11 | 12 | option "name_assets" "Aktiva" 13 | option "name_expenses" "Ausgaben" 14 | option "name_equity" "Eigenkapital" 15 | option "name_income" "Ertrag" 16 | option "name_liabilities" "Passiva" 17 | 18 | ; Test the automatic creation of config options for non-standard 19 | ; account roots 20 | 21 | 1970-01-01 open Aktiva:Bank 22 | 1970-01-01 open Ausgaben:Essen 23 | 1970-01-01 open Eigenkapital:Anfangsbestand 24 | 1970-01-01 open Ertrag:Lohn 25 | 1970-01-01 open Passiva:Darlehen 26 | 27 | 1970-01-01 commodity EUR 28 | 29 | 2020-01-01 * "Opening balance" 30 | Aktiva:Bank 1000.00 EUR 31 | Eigenkapital:Anfangsbestand 32 | 33 | 2020-09-28 * "Expenses" 34 | Ausgaben:Essen 20.00 EUR 35 | Aktiva:Bank 36 | 37 | 2020-09-28 * "Income" 38 | Aktiva:Bank 1000.00 EUR 39 | Ertrag:Lohn 40 | 41 | 2020-09-28 * "Liabilities" 42 | Aktiva:Bank 50000.00 EUR 43 | Passiva:Darlehen 44 | 45 | -------------------------------------------------------------------------------- /tests/non-standard-account-root.ledger: -------------------------------------------------------------------------------- 1 | ; Test the automatic creation of config options for non-standard 2 | ; account roots 3 | 4 | 2020-01-01 * Opening balance 5 | Aktiva:Bank 1000.00 EUR 6 | Eigenkapital:Anfangsbestand 7 | 8 | 2020-09-28 * Expenses 9 | Ausgaben:Essen 20.00 EUR 10 | Aktiva:Bank 11 | 12 | 2020-09-28 * Income 13 | Aktiva:Bank 1000.00 EUR 14 | Ertrag:Lohn 15 | 16 | 2020-09-28 * Liabilities 17 | Aktiva:Bank 50000.00 EUR 18 | Passiva:Darlehen 19 | 20 | -------------------------------------------------------------------------------- /tests/option-move_posting_tags.beancount: -------------------------------------------------------------------------------- 1 | 2 | 1970-01-01 open Assets:Test 3 | 1970-01-01 open Equity:Opening-Balance 4 | 5 | 1970-01-01 commodity EUR 6 | 7 | 2020-12-30 * "Posting-level tags" 8 | #foo 9 | #bar 10 | #baz 11 | Assets:Test 10.00 EUR 12 | Equity:Opening-Balance -10.00 EUR 13 | 14 | 2020-12-30 * "Posting-level tags" 15 | #foo 16 | #bar 17 | #baz 18 | Assets:Test 10.00 EUR 19 | Equity:Opening-Balance -10.00 EUR 20 | 21 | 2020-12-30 * "Posting-level tags" 22 | #foo 23 | #bar 24 | #foobar 25 | #baz 26 | #foobaz 27 | Assets:Test 10.00 EUR 28 | Equity:Opening-Balance -10.00 EUR 29 | 30 | 2020-12-30 * "Posting-level link" 31 | ^2020-12-30-test 32 | Assets:Test 10.00 EUR 33 | Equity:Opening-Balance -10.00 EUR 34 | 35 | 2020-12-30 * "Posting-level link" 36 | ^2020-12-30-test 37 | Assets:Test 10.00 EUR 38 | Equity:Opening-Balance -10.00 EUR 39 | 40 | -------------------------------------------------------------------------------- /tests/option-move_posting_tags.ledger: -------------------------------------------------------------------------------- 1 | 2 | 2020-12-30 * Posting-level tags 3 | ; :foo: 4 | Assets:Test 10.00 EUR 5 | ; :bar: 6 | Equity:Opening-Balance -10.00 EUR 7 | ; :baz: 8 | 9 | 2020-12-30 * Posting-level tags 10 | ; :foo: 11 | Assets:Test 10.00 EUR ; :bar: 12 | Equity:Opening-Balance -10.00 EUR ; :baz: 13 | 14 | 2020-12-30 * Posting-level tags 15 | ; :foo: 16 | Assets:Test 10.00 EUR ; :bar: 17 | ; :foobar: 18 | Equity:Opening-Balance -10.00 EUR ; :baz: 19 | ; :foobaz: 20 | 21 | 2020-12-30 * Posting-level link 22 | Assets:Test 10.00 EUR 23 | ; :2020-12-30-test: 24 | Equity:Opening-Balance -10.00 EUR 25 | 26 | 2020-12-30 * Posting-level link 27 | Assets:Test 10.00 EUR ; :2020-12-30-test: 28 | Equity:Opening-Balance -10.00 EUR 29 | 30 | -------------------------------------------------------------------------------- /tests/option-move_posting_tags.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | link_match: 4 | - ^\d\d\d\d-\d\d-\d\d- 5 | 6 | move_posting_tags: true 7 | -------------------------------------------------------------------------------- /tests/payee.beancount: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | 1970-01-01 open Assets:Test 6 | 1970-01-01 open Equity:Opening-Balance 7 | 8 | 1970-01-01 commodity EUR 9 | 1970-01-01 commodity GBP 10 | 11 | 2018-03-18 * "Foo" "Payee Foo" 12 | Assets:Test 10.00 EUR 13 | Equity:Opening-Balance -10.00 EUR 14 | 15 | 2018-03-18 * "Bar" "Payer Bar" 16 | Assets:Test 10.00 EUR 17 | Equity:Opening-Balance -10.00 EUR 18 | 19 | 2018-03-18 * "TfL" "Oyster card top-up" 20 | Assets:Test 10.00 EUR 21 | Equity:Opening-Balance -10.00 EUR 22 | 23 | ; case insensitive match 24 | 2018-03-18 * "TfL" "oyster card top-up" 25 | Assets:Test 10.00 EUR 26 | Equity:Opening-Balance -10.00 EUR 27 | 28 | 2018-03-18 * "Tesco" "Supermarket" 29 | Assets:Test 10.00 EUR 30 | Equity:Opening-Balance -10.00 EUR 31 | 32 | 2018-03-22 * "Creation" "Marriott reward1: test (£10.00)" 33 | Assets:Test 10.00 GBP 34 | Equity:Opening-Balance -10.00 GBP 35 | 36 | 2018-03-22 * "Creation" "Marriott reward2: test (£10.00)" 37 | Assets:Test 10.00 GBP 38 | Equity:Opening-Balance -10.00 GBP 39 | 40 | 2018-03-26 * "MK2" "Payee from metadata" 41 | Assets:Test 10.00 GBP 42 | Equity:Opening-Balance -10.00 GBP 43 | 44 | 2018-03-26 * "Martin" "Payer from metadata" 45 | Assets:Test 10.00 GBP 46 | Equity:Opening-Balance -10.00 GBP 47 | 48 | ; Interaction of payee_split and payee_tag 49 | 2018-03-31 * "MyEmployer" "Supermarket" 50 | Assets:Test 10.00 EUR 51 | Equity:Opening-Balance -10.00 EUR 52 | 53 | ; Interaction of payee_match and payee_tag 54 | 2018-03-31 * "MyEmployer" "Oyster card top-up" 55 | Assets:Test 10.00 EUR 56 | Equity:Opening-Balance -10.00 EUR 57 | 58 | 2020-10-09 * "Foo" "Payee Foo" 59 | Assets:Test 10.00 EUR 60 | Equity:Opening-Balance -10.00 EUR 61 | 62 | 63 | 2020-10-09 * "Bar" "Payee Bar" 64 | Assets:Test 10.00 EUR 65 | Equity:Opening-Balance -10.00 EUR 66 | 67 | 68 | 2020-10-15 * "No payee" 69 | Assets:Test 10.00 EUR 70 | payee: "Foo" 71 | Equity:Opening-Balance -10.00 EUR 72 | 73 | 2020-11-18 * "My narration" 74 | Assets:Test 10.00 EUR 75 | Equity:Opening-Balance -10.00 EUR 76 | 77 | 2020-11-18 * "My payee" "My narration" 78 | Assets:Test 10.00 EUR 79 | Equity:Opening-Balance -10.00 EUR 80 | 81 | 2020-11-18 * "My payee" "My narration" 82 | Assets:Test 10.00 EUR 83 | Equity:Opening-Balance -10.00 EUR 84 | 85 | 2020-12-30 * "My payee" "Payee and payer" 86 | payer: "My payer" 87 | Assets:Test 10.00 EUR 88 | Equity:Opening-Balance -10.00 EUR 89 | 90 | 2020-12-30 * "My payer" "Payee and payer" 91 | payee: "My payee" 92 | Assets:Test 10.00 EUR 93 | Equity:Opening-Balance -10.00 EUR 94 | 95 | 2020-12-30 * "My payee" "My narration" 96 | payer: "My payer" 97 | Assets:Test 10.00 EUR 98 | Equity:Opening-Balance -10.00 EUR 99 | 100 | 2020-12-30 * "My payer" "My narration" 101 | payee: "My payee" 102 | Assets:Test 10.00 EUR 103 | Equity:Opening-Balance -10.00 EUR 104 | 105 | -------------------------------------------------------------------------------- /tests/payee.ledger: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | account Assets:Test 6 | account Equity:Opening-Balance 7 | 8 | commodity EUR 9 | commodity GBP 10 | 11 | 2018-03-18 * Payee Foo 12 | ; payee: Foo 13 | Assets:Test 10.00 EUR 14 | Equity:Opening-Balance -10.00 EUR 15 | 16 | 2018-03-18 * Payer Bar 17 | ; payer: Bar 18 | Assets:Test 10.00 EUR 19 | Equity:Opening-Balance -10.00 EUR 20 | 21 | 2018-03-18 * Oyster card top-up 22 | Assets:Test 10.00 EUR 23 | Equity:Opening-Balance -10.00 EUR 24 | 25 | ; case insensitive match 26 | 2018-03-18 * oyster card top-up 27 | Assets:Test 10.00 EUR 28 | Equity:Opening-Balance -10.00 EUR 29 | 30 | 2018-03-18 * Supermarket (Tesco) 31 | Assets:Test 10.00 EUR 32 | Equity:Opening-Balance -10.00 EUR 33 | 34 | 2018-03-22 * Marriott reward1: test (£10.00) 35 | Assets:Test 10.00 GBP 36 | Equity:Opening-Balance -10.00 GBP 37 | 38 | 2018-03-22 * Marriott reward2: test (£10.00) 39 | Assets:Test 10.00 GBP 40 | Equity:Opening-Balance -10.00 GBP 41 | 42 | 2018-03-26 * Payee from metadata 43 | ; X-Payee: MK2 44 | Assets:Test 10.00 GBP 45 | Equity:Opening-Balance -10.00 GBP 46 | 47 | 2018-03-26 * Payer from metadata 48 | ; X-Payer: Martin 49 | Assets:Test 10.00 GBP 50 | Equity:Opening-Balance -10.00 GBP 51 | 52 | ; Interaction of payee_split and payee_tag 53 | 2018-03-31 * Supermarket (Tesco) 54 | ; X-Payee: MyEmployer 55 | Assets:Test 10.00 EUR 56 | Equity:Opening-Balance -10.00 EUR 57 | 58 | ; Interaction of payee_match and payee_tag 59 | 2018-03-31 * Oyster card top-up 60 | ; X-Payee: MyEmployer 61 | Assets:Test 10.00 EUR 62 | Equity:Opening-Balance -10.00 EUR 63 | 64 | 2020-10-09 * Payee Foo ; payee: Foo 65 | Assets:Test 10.00 EUR 66 | Equity:Opening-Balance -10.00 EUR 67 | 68 | apply tag payee: Bar 69 | 70 | 2020-10-09 * Payee Bar 71 | Assets:Test 10.00 EUR 72 | Equity:Opening-Balance -10.00 EUR 73 | 74 | end apply tag 75 | 76 | 2020-10-15 * No payee 77 | Assets:Test 10.00 EUR 78 | ; payee: Foo 79 | Equity:Opening-Balance -10.00 EUR 80 | 81 | 2020-11-18 * Payee 82 | ; thing: My narration 83 | Assets:Test 10.00 EUR 84 | Equity:Opening-Balance -10.00 EUR 85 | 86 | 2020-11-18 * Payee 87 | ; payee: My payee 88 | ; thing: My narration 89 | Assets:Test 10.00 EUR 90 | Equity:Opening-Balance -10.00 EUR 91 | 92 | 2020-11-18 * Payee 93 | ; thing: My narration 94 | ; payee: My payee 95 | Assets:Test 10.00 EUR 96 | Equity:Opening-Balance -10.00 EUR 97 | 98 | 2020-12-30 * Payee and payer 99 | ; payee: My payee 100 | ; payer: My payer 101 | Assets:Test 10.00 EUR 102 | Equity:Opening-Balance -10.00 EUR 103 | 104 | 2020-12-30 * Payee and payer 105 | ; payer: My payer 106 | ; payee: My payee 107 | Assets:Test 10.00 EUR 108 | Equity:Opening-Balance -10.00 EUR 109 | 110 | 2020-12-30 * Payee, payer and narration 111 | ; payee: My payee 112 | ; payer: My payer 113 | ; thing: My narration 114 | Assets:Test 10.00 EUR 115 | Equity:Opening-Balance -10.00 EUR 116 | 117 | 2020-12-30 * Payee, payer and narration 118 | ; thing: My narration 119 | ; payer: My payer 120 | ; payee: My payee 121 | Assets:Test 10.00 EUR 122 | Equity:Opening-Balance -10.00 EUR 123 | 124 | -------------------------------------------------------------------------------- /tests/prices.beancount: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | 1970-01-01 open Assets:Bank 6 | 1970-01-01 open Assets:Cash 7 | 1970-01-01 open Assets:Test 8 | 1970-01-01 open Assets:Voucher 9 | 1970-01-01 open Equity:Opening-Balance 10 | 11 | 1970-01-01 commodity ETH 12 | 1970-01-01 commodity EUR 13 | 1970-01-01 commodity GBP 14 | 15 | 1970-01-01 commodity JPY 16 | 1970-01-01 commodity MILESMORE4 17 | 1970-01-01 commodity UR 18 | 1970-01-01 commodity USD 19 | 20 | 2018-03-21 price EUR 0.87 GBP 21 | 2018-03-21 price UR 0.015 USD 22 | 2018-03-21 price MILESMORE4 0.01 USD 23 | 2019-04-28 price EUR 124.56 JPY 24 | 2020-06-26 price GBP 1.11 EUR ;comment 25 | 2020-06-26 price GBP 1.11 EUR ;comment 26 | 27 | 2018-03-21 * "Virtual cost (@)" 28 | Assets:Test 10.00 EUR @ 0.90 GBP 29 | Equity:Opening-Balance -9.00 GBP 30 | 31 | 2018-03-21 * "Virtual cost (@@)" 32 | Assets:Test 10.00 EUR @@ 9.00 GBP 33 | Equity:Opening-Balance -9.00 GBP 34 | 35 | 2018-03-21 * "Virtual cost (@) becoming a cost" 36 | Assets:Test 1.00 ETH {6500.00 EUR} 37 | Equity:Opening-Balance -6500.00 EUR 38 | 39 | 2018-03-21 * "Virtual cost (@) becoming a cost" 40 | Assets:Test 1.00 ETH {{6500.00 EUR}} 41 | Equity:Opening-Balance -6500.00 EUR 42 | 43 | 2020-06-22 * "Lot and virtual price" 44 | Assets:Test 10.00 EUR {1.23 USD} @ 1.30 USD 45 | Equity:Opening-Balance 46 | 47 | 2020-06-22 * "Lot date and virtual price" 48 | Assets:Test 10.00 EUR {1.23 USD, 2020-06-21} @ 1.30 USD 49 | Equity:Opening-Balance 50 | 51 | 2020-06-22 * "Lot and virtual price" 52 | Assets:Test 10.00 EUR {1.23 USD} @@ 1.30 USD 53 | Equity:Opening-Balance 54 | 55 | 2020-06-22 * "Lot date and virtual price" 56 | Assets:Test 10.00 EUR {1.23 USD, 2020-06-21} @@ 1.30 USD 57 | Equity:Opening-Balance 58 | 59 | 2020-06-22 * "Lot note followed by virtual price" 60 | Assets:Test 10.00 EUR {1.23 USD, "this is a note"} @ 1.30 USD 61 | Assets:Bank 62 | 63 | 2020-06-22 * "Lot note followed by virtual price" 64 | Assets:Test 10.00 EUR {1.23 USD, "this is a note"} @@ 1.30 USD 65 | Assets:Bank 66 | 67 | 2020-06-23 * "Price with cost" 68 | Assets:Voucher 10.00 EUR @@ 10.00 EUR 69 | Assets:Cash 70 | 71 | 2020-06-23 * "Price with cost and date" 72 | Assets:Voucher 10.00 EUR @@ 10.00 EUR 73 | Assets:Cash 74 | 75 | 2020-06-23 * "Price with cost, date and note" 76 | Assets:Voucher 10.00 EUR @@ 10.00 EUR 77 | Assets:Cash 78 | 79 | 2020-06-23 * "Price with cost, date, note and value expression" 80 | Assets:Voucher 10.00 EUR @@ 10.00 EUR 81 | Assets:Cash 82 | 83 | 2020-06-23 * "Price with cost, date and value expression" 84 | Assets:Voucher 10.00 EUR @@ 10.00 EUR 85 | Assets:Cash 86 | 87 | 2020-06-23 * "Price with cost and note" 88 | Assets:Voucher 10.00 EUR @@ 10.00 EUR 89 | Assets:Cash 90 | 91 | 2020-06-23 * "Price with cost, note and value expression" 92 | Assets:Voucher 10.00 EUR @@ 10.00 EUR 93 | Assets:Cash 94 | 95 | 2020-06-23 * "Price with cost and value expression" 96 | Assets:Voucher 10.00 EUR @@ 10.00 EUR 97 | Assets:Cash 98 | 99 | 2020-06-23 * "Price with date" 100 | Assets:Voucher 10.00 EUR @@ 10.00 EUR 101 | Assets:Cash 102 | 103 | 2020-06-23 * "Price with date and note" 104 | Assets:Voucher 10.00 EUR @@ 10.00 EUR 105 | Assets:Cash 106 | 107 | 2020-06-23 * "Price with date, note and value expression" 108 | Assets:Voucher 10.00 EUR @@ 10.00 EUR 109 | Assets:Cash 110 | 111 | 2020-06-23 * "Price with date and value expression" 112 | Assets:Voucher 10.00 EUR @@ 10.00 EUR 113 | Assets:Cash 114 | 115 | 2020-06-23 * "Price with note" 116 | Assets:Voucher 10.00 EUR @@ 10.00 EUR 117 | Assets:Cash 118 | 119 | 2020-06-23 * "Price with note and value expression" 120 | Assets:Voucher 10.00 EUR @@ 10.00 EUR 121 | Assets:Cash 122 | 123 | 2020-06-23 * "Price with value expression" 124 | Assets:Voucher 10.00 EUR @@ 10.00 EUR 125 | Assets:Cash 126 | 127 | -------------------------------------------------------------------------------- /tests/prices.ledger: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | account Assets:Bank 6 | account Assets:Cash 7 | account Assets:Test 8 | account Assets:Voucher 9 | account Equity:Opening-Balance 10 | 11 | commodity ETH 12 | commodity EUR 13 | commodity GBP 14 | 15 | P 2018-03-21 EUR 0.87 GBP 16 | P 2018-03-21 Chase 0.015 USD 17 | P 2018-03-21 "M&M4" 0.01 USD 18 | P 2019-04-28 17:12:15 EUR ¥124.56 19 | P 2020-06-26 GBP 1.11 EUR;comment 20 | P 2020-06-26 GBP 1.11 EUR ;comment 21 | 22 | 2018-03-21 * Virtual cost (@) 23 | Assets:Test 10.00 EUR (@) 0.90 GBP 24 | Equity:Opening-Balance -9.00 GBP 25 | 26 | 2018-03-21 * Virtual cost (@@) 27 | Assets:Test 10.00 EUR (@@) 9.00 GBP 28 | Equity:Opening-Balance -9.00 GBP 29 | 30 | 2018-03-21 * Virtual cost (@) becoming a cost 31 | Assets:Test 1.00 ETH (@) 6500.00 EUR 32 | Equity:Opening-Balance -6500.00 EUR 33 | 34 | 2018-03-21 * Virtual cost (@) becoming a cost 35 | Assets:Test 1.00 ETH (@@) 6500.00 EUR 36 | Equity:Opening-Balance -6500.00 EUR 37 | 38 | 2020-06-22 * Lot and virtual price 39 | Assets:Test 10.00 EUR {1.23 USD} (@) 1.30 USD 40 | Equity:Opening-Balance 41 | 42 | 2020-06-22 * Lot date and virtual price 43 | Assets:Test 10.00 EUR {1.23 USD} [2020-06-21] (@) 1.30 USD 44 | Equity:Opening-Balance 45 | 46 | 2020-06-22 * Lot and virtual price 47 | Assets:Test 10.00 EUR {1.23 USD} (@@) 1.30 USD 48 | Equity:Opening-Balance 49 | 50 | 2020-06-22 * Lot date and virtual price 51 | Assets:Test 10.00 EUR {1.23 USD} [2020-06-21] (@@) 1.30 USD 52 | Equity:Opening-Balance 53 | 54 | 2020-06-22 * Lot note followed by virtual price 55 | Assets:Test 10.00 EUR {1.23 USD} (this is a note) (@) 1.30 USD 56 | Assets:Bank 57 | 58 | 2020-06-22 * Lot note followed by virtual price 59 | Assets:Test 10.00 EUR {1.23 USD} (this is a note) (@@) 1.30 USD 60 | Assets:Bank 61 | 62 | 2020-06-23 * Price with cost 63 | Assets:Voucher 10.00 EUR @@ 10.00 EUR {2.00 GBP} 64 | Assets:Cash 65 | 66 | 2020-06-23 * Price with cost and date 67 | Assets:Voucher 10.00 EUR @@ 10.00 EUR {2.00 GBP} [2020-06-23] 68 | Assets:Cash 69 | 70 | 2020-06-23 * Price with cost, date and note 71 | Assets:Voucher 10.00 EUR @@ 10.00 EUR {2.00 GBP} [2020-06-23] (foo) 72 | Assets:Cash 73 | 74 | 2020-06-23 * Price with cost, date, note and value expression 75 | Assets:Voucher 10.00 EUR @@ 10.00 EUR {2.00 GBP} [2020-06-23] (foo) ((market)) 76 | Assets:Cash 77 | 78 | 2020-06-23 * Price with cost, date and value expression 79 | Assets:Voucher 10.00 EUR @@ 10.00 EUR {2.00 GBP} [2020-06-23] ((market)) 80 | Assets:Cash 81 | 82 | 2020-06-23 * Price with cost and note 83 | Assets:Voucher 10.00 EUR @@ 10.00 EUR {2.00 GBP} (foo) 84 | Assets:Cash 85 | 86 | 2020-06-23 * Price with cost, note and value expression 87 | Assets:Voucher 10.00 EUR @@ 10.00 EUR {2.00 GBP} (foo) ((market)) 88 | Assets:Cash 89 | 90 | 2020-06-23 * Price with cost and value expression 91 | Assets:Voucher 10.00 EUR @@ 10.00 EUR {2.00 GBP} ((market)) 92 | Assets:Cash 93 | 94 | 2020-06-23 * Price with date 95 | Assets:Voucher 10.00 EUR @@ 10.00 EUR [2020-06-23] 96 | Assets:Cash 97 | 98 | 2020-06-23 * Price with date and note 99 | Assets:Voucher 10.00 EUR @@ 10.00 EUR [2020-06-23] (foo) 100 | Assets:Cash 101 | 102 | 2020-06-23 * Price with date, note and value expression 103 | Assets:Voucher 10.00 EUR @@ 10.00 EUR [2020-06-23] (foo) ((market)) 104 | Assets:Cash 105 | 106 | 2020-06-23 * Price with date and value expression 107 | Assets:Voucher 10.00 EUR @@ 10.00 EUR [2020-06-23] ((market)) 108 | Assets:Cash 109 | 110 | 2020-06-23 * Price with note 111 | Assets:Voucher 10.00 EUR @@ 10.00 EUR (foo) 112 | Assets:Cash 113 | 114 | 2020-06-23 * Price with note and value expression 115 | Assets:Voucher 10.00 EUR @@ 10.00 EUR (foo) ((market)) 116 | Assets:Cash 117 | 118 | 2020-06-23 * Price with value expression 119 | Assets:Voucher 10.00 EUR @@ 10.00 EUR ((market)) 120 | Assets:Cash 121 | 122 | -------------------------------------------------------------------------------- /tests/runtests: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # SPDX-FileCopyrightText: © 2018 Martin Michlmayr 4 | 5 | # SPDX-License-Identifier: GPL-3.0-or-later 6 | 7 | status=0 8 | 9 | if [ -z "${SORT-}" ]; then 10 | # We need sort from coreutils for -V 11 | case `uname -s` in 12 | Linux*) SORT=sort ;; 13 | Darwin*) SORT=gsort ;; 14 | NetBSD*) SORT=gsort ;; 15 | *) SORT=sort ;; 16 | esac 17 | fi 18 | 19 | meets_version() { 20 | has=$1 21 | needed=$2 22 | latest=$(printf "$needed\n$has" | $SORT -V | tail -n 1) 23 | if [ "$has" != "$latest" ]; then 24 | return 1 25 | else 26 | return 0 27 | fi 28 | } 29 | 30 | test_conversion () { 31 | test=$1 32 | expected=$(echo $test | sed -e 's/\.h*ledger$/.beancount/') 33 | actual=$(mktemp) 34 | 35 | printf "Converting $test... " 36 | 37 | config=ledger2beancount.yaml 38 | t=$(echo $test | sed 's/.\h*ledger$//') 39 | if [ -e $t.yaml ]; then 40 | config=$t.yaml 41 | fi 42 | 43 | if [ -n "$PERL5BIN" ]; then 44 | $PERL5BIN ../bin/ledger2beancount --config $config $test > $actual 45 | else 46 | ../bin/ledger2beancount --config $config $test > $actual 47 | fi 48 | 49 | if $(cmp -s $expected $actual); then 50 | echo "ok" 51 | else 52 | status=1 53 | echo "FAIL" 54 | diff -urN $expected $actual | tail -n +3 55 | fi 56 | 57 | rm -f $actual 58 | } 59 | 60 | test_validity_hledger () { 61 | test=$1 62 | printf "Validating $test... " 63 | tmp=$(mktemp) 64 | if $(hledger -f $test bal > $tmp 2>&1); then 65 | echo "ok" 66 | else 67 | echo "FAIL" 68 | cat $tmp 69 | status=1 70 | fi 71 | rm -f $tmp 72 | } 73 | 74 | test_validity_ledger () { 75 | test=$1 76 | printf "Validating $test... " 77 | tmp=$(mktemp) 78 | ledger --init-file /dev/null -f $test bal > $tmp 2>&1 79 | # Ignore errors due to missing Python support 80 | errors=$(grep "^Error:" $tmp | grep -v "^Error: 'python' directive seen" | \ 81 | grep -v "^Error: 'import' directive seen" | \ 82 | grep -v "^Error: Unknown identifier 'print_type'$") 83 | if [ -z "$errors" ]; then 84 | echo "ok" 85 | else 86 | echo "FAIL" 87 | cat $tmp 88 | status=1 89 | fi 90 | rm -f $tmp 91 | } 92 | 93 | test_validity_beancount () { 94 | test=$1 95 | printf "Validating $test... " 96 | 97 | # Ensure beancount is new enough 98 | needed=$(grep "^; Beancount:" $test | head -n 1 | sed 's/^; Beancount:[[:space:]]*//') 99 | if [ -n "$needed" ]; then 100 | if ! $(meets_version $beancount_version $needed); then 101 | echo "skipping since beancount is too old" 102 | return 103 | fi 104 | fi 105 | 106 | if bean-check $test; then 107 | echo "ok" 108 | else 109 | echo "FAIL" 110 | status=1 111 | fi 112 | } 113 | 114 | # Warn if the locale is not UTF-8 115 | case "$LANG" in 116 | *UTF-8* | *utf8*) 117 | # good 118 | ;; 119 | "") 120 | echo "Can't determine locale. Please ensure UTF-8" 121 | ;; 122 | *) 123 | echo "Locale is not UTF-8. Tests might fail" 124 | ;; 125 | esac 126 | 127 | # Validate ledger files 128 | ledger_date=$(ledger --version 2>/dev/null | grep "^Ledger [0-9]" | cut -d " " -f 2 | cut -d - -f 2 | sed 's/,//') 129 | if [ -z $ledger_date ]; then 130 | echo "Skipping ledger validation checks since ledger is not installed" 131 | elif [ $ledger_date -lt 20190205 ]; then 132 | echo "Skipping ledger validation checks since ledger from $ledger_date is too old" 133 | else 134 | for test in *.ledger; do 135 | test_validity_ledger "$test" 136 | done 137 | fi 138 | 139 | # Validate hledger file 140 | hledger_version=$(hledger --version 2>/dev/null | cut -d" " -f2) 141 | if [ -z $hledger_version ]; then 142 | echo "Skipping hledger validation checks since hledger is not installed" 143 | elif ! $(meets_version $hledger_version 1.14.2); then 144 | echo "Skipping hledger validation checks since hledger $hledger_version is too old" 145 | else 146 | for test in *.hledger; do 147 | test_validity_hledger "$test" 148 | done 149 | fi 150 | 151 | # Convert files 152 | for test in *.ledger *.hledger; do 153 | test_conversion "$test" 154 | done 155 | 156 | # Validate beancount files 157 | beancount_version=$(bean-check --version 2>/dev/null | cut -d' ' -f2) 158 | if [ -z $beancount_version ]; then 159 | echo "Skipping beancount validation checks since beancount is not installed" 160 | else 161 | for test in *.beancount; do 162 | test_validity_beancount "$test" 163 | done 164 | fi 165 | 166 | exit $status 167 | 168 | -------------------------------------------------------------------------------- /tests/spacing.beancount: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | 1970-01-01 open Assets:Test 6 | 1970-01-01 open Equity:Opening-Balance 7 | 1970-01-01 commodity EUR 8 | 2018-03-24 * "Test 1" 9 | Assets:Test 10.00 EUR 10 | Equity:Opening-Balance -10.00 EUR 11 | ; comment 12 | 2018-03-24 * "Test 2" 13 | Assets:Test 14 | Equity:Opening-Balance -10.00 EUR 15 | 2018-03-24 * "Indented whitespace" 16 | Assets:Test 10.00 EUR 17 | Equity:Opening-Balance 18 | 19 | 2018-03-24 * "No empty line after the transaction" 20 | Assets:Test 10.00 EUR 21 | Equity:Opening-Balance 22 | -------------------------------------------------------------------------------- /tests/spacing.ledger: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | account Assets:Test 6 | account Equity:Opening-Balance 7 | commodity EUR 8 | 2018-03-24 * Test 1 9 | Assets:Test 10.00 EUR 10 | Equity:Opening-Balance -10.00 EUR 11 | ; comment 12 | 2018-03-24 * Test 2 13 | Assets:Test 14 | Equity:Opening-Balance -10.00 EUR 15 | 2018-03-24 * Indented whitespace 16 | Assets:Test 10.00 EUR 17 | Equity:Opening-Balance 18 | 19 | 2018-03-24 * No empty line after the transaction 20 | Assets:Test 10.00 EUR 21 | Equity:Opening-Balance 22 | -------------------------------------------------------------------------------- /tests/tags.beancount: -------------------------------------------------------------------------------- 1 | ;---------------------------------------------------------------------- 2 | ; ledger2beancount conversion notes: 3 | ; 4 | ; - Tag 10!20 renamed to 10-20 5 | ; - Tag test! renamed to test- 6 | ; - Tag test+ renamed to test- 7 | ; - Tag ♚ renamed to - 8 | ; - Collision for tag test-: test!, test+ 9 | ;---------------------------------------------------------------------- 10 | 11 | ; Beancount: 2.1.0 12 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 13 | ; 14 | ; SPDX-License-Identifier: GPL-3.0-or-later 15 | 16 | 1970-01-01 open Assets:Test 17 | 1970-01-01 open Equity:Opening-Balance 18 | 19 | 1970-01-01 commodity EUR 20 | 21 | 2018-03-17 * "Tag on transaction" 22 | #foo #bar #baz 23 | Assets:Test 10.00 EUR 24 | Equity:Opening-Balance -10.00 EUR 25 | 26 | 2018-03-17 * "Tag on transaction, split over two lines" 27 | #foo #bar #baz 28 | #second 29 | Assets:Test 10.00 EUR 30 | Equity:Opening-Balance -10.00 EUR 31 | 32 | 2018-03-17 * "Tag on transaction, one converted to a link" 33 | #foo #bar ^2018-02-02-brussels-fosdem #baz 34 | Assets:Test 10.00 EUR 35 | Equity:Opening-Balance -10.00 EUR 36 | 37 | 2018-03-17 * "Tag on transaction, one link on posting level" 38 | #foo #bar ^2018-02-02-brussels-fosdem #baz 39 | Assets:Test 10.00 EUR 40 | tags: "qux, quux, quuz" 41 | links: "2018-03-08-london" 42 | Equity:Opening-Balance -10.00 EUR 43 | 44 | 2018-03-17 * "Tag on postings" 45 | #foo #bar #baz 46 | Assets:Test 10.00 EUR 47 | tags: "foo" 48 | Equity:Opening-Balance -10.00 EUR 49 | tags: "bar" 50 | 51 | 2018-03-31 * "Tag on postings, without indentation" 52 | #foo #bar #baz 53 | Assets:Test 10.00 EUR 54 | tags: "qux" 55 | links: "2018-03-08-london" 56 | Equity:Opening-Balance -10.00 EUR 57 | tags: "quux, quuz" 58 | 59 | 2018-05-23 * "Tag on postings, same line" 60 | #foo #bar #baz 61 | Assets:Test 10.00 EUR 62 | tags: "qux" 63 | links: "2018-03-08-london" 64 | Equity:Opening-Balance -10.00 EUR 65 | tags: "quux, quuz" 66 | 67 | 2018-05-23 * "Tag on postings, same and next line" 68 | #foo #bar #baz 69 | Assets:Test 10.00 EUR 70 | tags: "qux, foo" 71 | links: "2018-03-08-london" 72 | Equity:Opening-Balance -10.00 EUR 73 | tags: "quux, quuz" 74 | 75 | ; This is not a tag; you need two spaces before the comment 76 | 2019-01-25 * "Just a payee description ; :foo:" 77 | #bar #baz 78 | Assets:Test 10.00 EUR 79 | Equity:Opening-Balance -10.00 EUR 80 | 81 | 2019-01-25 * "Tag on same line as payee" #foo 82 | #bar #baz 83 | Assets:Test 10.00 EUR 84 | Equity:Opening-Balance -10.00 EUR 85 | 86 | 2019-01-25 * "Tag on same line as payee" #foo 87 | #bar #baz 88 | Assets:Test 10.00 EUR 89 | Equity:Opening-Balance -10.00 EUR 90 | 91 | 2019-01-25 * "Comment and tag on same line as payee" #foo ; comment 92 | #bar #baz 93 | Assets:Test 10.00 EUR 94 | Equity:Opening-Balance -10.00 EUR 95 | 96 | 2020-08-06 * "Tag on same line as payee" #foo 97 | Assets:Test 10.00 EUR 98 | Assets:Test -10.00 EUR 99 | 100 | 2020-08-06 * "Tag on same line as payee" #foo 101 | Assets:Test 10.00 EUR 102 | Assets:Test -10.00 EUR 103 | 104 | 2020-08-06 * "Tag on same line as payee" #foo 105 | Assets:Test 10.00 EUR 106 | Assets:Test -10.00 EUR 107 | 108 | 2020-10-01 * "No space before tag" 109 | Assets:Test 10.00 EUR 110 | tags: "foo" 111 | Assets:Test -10.00 EUR 112 | 113 | 2020-10-01 * "Many spaces before tag" 114 | Assets:Test 10.00 EUR 115 | tags: "foo" 116 | Assets:Test -10.00 EUR 117 | 118 | 2020-10-01 * "Tab separated" 119 | ; Comment 120 | Assets:Test 10.00 EUR 121 | tags: "foo" 122 | Assets:Test -10.00 EUR 123 | 124 | 2020-10-01 * "Tab separated" #foo 125 | Assets:Test 10.00 EUR 126 | tags: "foo" 127 | Assets:Test -10.00 EUR 128 | 129 | 2020-10-02 * "Inconsistent spacing: 4 for postings, 2 for tags" 130 | #foo 131 | Assets:Test 10.00 EUR 132 | tags: "bar" 133 | Assets:Test -10.00 EUR 134 | 135 | 2020-10-13 * "Tag on same line as payee, with auxdate" #foo 136 | aux-date: 2020-10-11 137 | Assets:Test 10.00 EUR 138 | Assets:Test -10.00 EUR 139 | 140 | 2020-10-23 * "Comment spacing for comment after tag" 141 | Assets:Test 10.00 EUR ; test 142 | tags: "bar" 143 | Equity:Opening-Balance -10.00 EUR ;test 144 | tags: "bar" 145 | 146 | 2020-10-23 * "Comment spacing for comment after tag" 147 | Assets:Test 10.00 EUR 148 | ; test 149 | tags: "bar" 150 | Equity:Opening-Balance -10.00 EUR 151 | ;test 152 | tags: "bar" 153 | 154 | 2022-12-16 * "test" "Tag test" 155 | #foo/bar 156 | Assets:Test 10.00 EUR 157 | Assets:Test 158 | 159 | 2022-12-16 * "test" "Tag test" 160 | #test- 161 | Assets:Test 10.00 EUR 162 | Assets:Test 163 | 164 | 2022-12-16 * "test" "Tag test" 165 | #- 166 | Assets:Test 10.00 EUR 167 | Assets:Test 168 | 169 | 2022-12-16 * "test" "Tag test" 170 | #foo_bar 171 | Assets:Test 10.00 EUR 172 | Assets:Test 173 | 174 | 2022-12-16 * "test" "Tag test" 175 | #foo-bar 176 | Assets:Test 10.00 EUR 177 | Assets:Test 178 | 179 | 2022-12-16 * "test" "Tag test" 180 | #1234 181 | Assets:Test 10.00 EUR 182 | Assets:Test 183 | 184 | 2022-12-16 * "test" "Tag test" 185 | #abcd1234 186 | Assets:Test 10.00 EUR 187 | Assets:Test 188 | 189 | 2022-12-16 * "test" "Tag test" 190 | #foo/bar #- #foo_bar #foo-bar #1234 #abcd1234 191 | Assets:Test 10.00 EUR 192 | Assets:Test 193 | 194 | 2022-12-16 * "test" "Tag test" 195 | Assets:Test 10.00 EUR 196 | tags: "foo/bar" 197 | Assets:Test 198 | 199 | 2022-12-16 * "test" "Tag test" 200 | Assets:Test 10.00 EUR 201 | tags: "test-" 202 | Assets:Test 203 | 204 | 2022-12-16 * "test" "Tag test" 205 | Assets:Test 10.00 EUR 206 | tags: "test-" 207 | Assets:Test 208 | 209 | 2022-12-16 * "test" "Tag test" 210 | Assets:Test 10.00 EUR 211 | tags: "-" 212 | Assets:Test 213 | 214 | 2022-12-16 * "test" "Tag test" 215 | Assets:Test 10.00 EUR 216 | tags: "foo_bar" 217 | Assets:Test 218 | 219 | 2022-12-16 * "test" "Tag test" 220 | Assets:Test 10.00 EUR 221 | tags: "foo-bar" 222 | Assets:Test 223 | 224 | 2022-12-16 * "test" "Tag test" 225 | Assets:Test 10.00 EUR 226 | tags: "1234" 227 | Assets:Test 228 | 229 | 2022-12-16 * "test" "Tag test" 230 | Assets:Test 10.00 EUR 231 | tags: "abcd1234" 232 | Assets:Test 233 | 234 | 2022-12-16 * "test" "Tag test in tag_map" 235 | #WTF 236 | Assets:Test 10.00 EUR 237 | tags: "WTF" 238 | Assets:Test 239 | 240 | 2022-12-16 * "Link and link_match" 241 | ^10-20 242 | Assets:Test 10.00 EUR 243 | Assets:Test 244 | 245 | -------------------------------------------------------------------------------- /tests/tags.ledger: -------------------------------------------------------------------------------- 1 | ; Beancount: 2.1.0 2 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 3 | ; 4 | ; SPDX-License-Identifier: GPL-3.0-or-later 5 | 6 | account Assets:Test 7 | account Equity:Opening-Balance 8 | 9 | commodity EUR 10 | 11 | 2018-03-17 * Tag on transaction 12 | ; :foo:bar:baz: 13 | Assets:Test 10.00 EUR 14 | Equity:Opening-Balance -10.00 EUR 15 | 16 | 2018-03-17 * Tag on transaction, split over two lines 17 | ; :foo:bar:baz: 18 | ; :second: 19 | Assets:Test 10.00 EUR 20 | Equity:Opening-Balance -10.00 EUR 21 | 22 | 2018-03-17 * Tag on transaction, one converted to a link 23 | ; :foo:bar:2018-02-02-brussels-fosdem:baz: 24 | Assets:Test 10.00 EUR 25 | Equity:Opening-Balance -10.00 EUR 26 | 27 | 2018-03-17 * Tag on transaction, one link on posting level 28 | ; :foo:bar:2018-02-02-brussels-fosdem:baz: 29 | Assets:Test 10.00 EUR 30 | ; :qux:quux:2018-03-08-london:quuz: 31 | Equity:Opening-Balance -10.00 EUR 32 | 33 | 2018-03-17 * Tag on postings 34 | ; :foo:bar:baz: 35 | Assets:Test 10.00 EUR 36 | ; :foo: 37 | Equity:Opening-Balance -10.00 EUR 38 | ; :bar: 39 | 40 | 2018-03-31 * Tag on postings, without indentation 41 | ; :foo:bar:baz: 42 | Assets:Test 10.00 EUR 43 | ; :qux:2018-03-08-london: 44 | Equity:Opening-Balance -10.00 EUR 45 | ; :quux:quuz: 46 | 47 | 2018-05-23 * Tag on postings, same line 48 | ; :foo:bar:baz: 49 | Assets:Test 10.00 EUR ; :qux:2018-03-08-london: 50 | Equity:Opening-Balance -10.00 EUR ; :quux:quuz: 51 | 52 | 2018-05-23 * Tag on postings, same and next line 53 | ; :foo:bar:baz: 54 | Assets:Test 10.00 EUR ; :qux:2018-03-08-london: 55 | ; :foo: 56 | Equity:Opening-Balance -10.00 EUR ; :quux:quuz: 57 | 58 | ; This is not a tag; you need two spaces before the comment 59 | 2019-01-25 * Just a payee description ; :foo: 60 | ; :bar:baz: 61 | Assets:Test 10.00 EUR 62 | Equity:Opening-Balance -10.00 EUR 63 | 64 | 2019-01-25 * Tag on same line as payee ; :foo: 65 | ; :bar:baz: 66 | Assets:Test 10.00 EUR 67 | Equity:Opening-Balance -10.00 EUR 68 | 69 | 2019-01-25 * Tag on same line as payee ; :foo: 70 | ; :bar:baz: 71 | Assets:Test 10.00 EUR 72 | Equity:Opening-Balance -10.00 EUR 73 | 74 | 2019-01-25 * Comment and tag on same line as payee ; comment :foo: 75 | ; :bar:baz: 76 | Assets:Test 10.00 EUR 77 | Equity:Opening-Balance -10.00 EUR 78 | 79 | 2020-08-06 * Tag on same line as payee ; :foo: 80 | Assets:Test 10.00 EUR 81 | Assets:Test -10.00 EUR 82 | 83 | 2020-08-06 * Tag on same line as payee ; :foo: 84 | Assets:Test 10.00 EUR 85 | Assets:Test -10.00 EUR 86 | 87 | 2020-08-06 * Tag on same line as payee ; :foo: 88 | Assets:Test 10.00 EUR 89 | Assets:Test -10.00 EUR 90 | 91 | 2020-10-01 * No space before tag 92 | Assets:Test 10.00 EUR;:foo: 93 | Assets:Test -10.00 EUR 94 | 95 | 2020-10-01 * Many spaces before tag 96 | Assets:Test 10.00 EUR ; :foo: 97 | Assets:Test -10.00 EUR 98 | 99 | 2020-10-01 * Tab separated 100 | ; Comment 101 | Assets:Test 10.00 EUR; :foo: 102 | Assets:Test -10.00 EUR 103 | 104 | 2020-10-01 * Tab separated ; :foo: 105 | Assets:Test 10.00 EUR ; :foo: 106 | Assets:Test -10.00 EUR 107 | 108 | 2020-10-02 * Inconsistent spacing: 4 for postings, 2 for tags 109 | ; :foo: 110 | Assets:Test 10.00 EUR 111 | ; :bar: 112 | Assets:Test -10.00 EUR 113 | 114 | 2020-10-13=2020-10-11 * Tag on same line as payee, with auxdate ; :foo: 115 | Assets:Test 10.00 EUR 116 | Assets:Test -10.00 EUR 117 | 118 | 2020-10-23 * Comment spacing for comment after tag 119 | Assets:Test 10.00 EUR ; :bar: test 120 | Equity:Opening-Balance -10.00 EUR ;:bar: test 121 | 122 | 2020-10-23 * Comment spacing for comment after tag 123 | Assets:Test 10.00 EUR 124 | ; :bar: test 125 | Equity:Opening-Balance -10.00 EUR 126 | ;:bar: test 127 | 128 | 2022-12-16 * Tag test 129 | ; :foo/bar: 130 | Assets:Test 10.00 EUR 131 | Assets:Test 132 | 133 | 2022-12-16 * Tag test 134 | ; :test+: 135 | Assets:Test 10.00 EUR 136 | Assets:Test 137 | 138 | 2022-12-16 * Tag test 139 | ; :♚: 140 | Assets:Test 10.00 EUR 141 | Assets:Test 142 | 143 | 2022-12-16 * Tag test 144 | ; :foo_bar: 145 | Assets:Test 10.00 EUR 146 | Assets:Test 147 | 148 | 2022-12-16 * Tag test 149 | ; :foo-bar: 150 | Assets:Test 10.00 EUR 151 | Assets:Test 152 | 153 | 2022-12-16 * Tag test 154 | ; :1234: 155 | Assets:Test 10.00 EUR 156 | Assets:Test 157 | 158 | 2022-12-16 * Tag test 159 | ; :abcd1234: 160 | Assets:Test 10.00 EUR 161 | Assets:Test 162 | 163 | 2022-12-16 * Tag test 164 | ; :foo/bar:♚:foo_bar:foo-bar:1234:abcd1234: 165 | Assets:Test 10.00 EUR 166 | Assets:Test 167 | 168 | 2022-12-16 * Tag test 169 | Assets:Test 10.00 EUR 170 | ; :foo/bar: 171 | Assets:Test 172 | 173 | 2022-12-16 * Tag test 174 | Assets:Test 10.00 EUR 175 | ; :test+: 176 | Assets:Test 177 | 178 | 2022-12-16 * Tag test 179 | Assets:Test 10.00 EUR 180 | ; :test!: 181 | Assets:Test 182 | 183 | 2022-12-16 * Tag test 184 | Assets:Test 10.00 EUR 185 | ; :♚: 186 | Assets:Test 187 | 188 | 2022-12-16 * Tag test 189 | Assets:Test 10.00 EUR 190 | ; :foo_bar: 191 | Assets:Test 192 | 193 | 2022-12-16 * Tag test 194 | Assets:Test 10.00 EUR 195 | ; :foo-bar: 196 | Assets:Test 197 | 198 | 2022-12-16 * Tag test 199 | Assets:Test 10.00 EUR 200 | ; :1234: 201 | Assets:Test 202 | 203 | 2022-12-16 * Tag test 204 | Assets:Test 10.00 EUR 205 | ; :abcd1234: 206 | Assets:Test 207 | 208 | 2022-12-16 * Tag test in tag_map 209 | ; :WTF???: 210 | Assets:Test 10.00 EUR 211 | ; :WTF???: 212 | Assets:Test 213 | 214 | 2022-12-16 * Link and link_match 215 | ; :10!20: 216 | Assets:Test 10.00 EUR 217 | Assets:Test 218 | 219 | -------------------------------------------------------------------------------- /tests/transactions.beancount: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2020 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | 1970-01-01 open Assets:Test 6 | 7 | 1970-01-01 commodity EUR 8 | 9 | 2019-02-15 note Assets:Test "A transaction with a single posting - only allowed when amount == 0" 10 | 11 | 12 | 2019-02-15 note Assets:Test "A transaction with a single posting - only allowed when amount == 0" 13 | 14 | 15 | ; Skipping transaction without header. 16 | 17 | ; Skipping transaction without header. 18 | 19 | 2020-09-29 note Assets:Test "A transaction with a single posting - no amount" 20 | 21 | 22 | -------------------------------------------------------------------------------- /tests/transactions.ledger: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2020 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | 2019-02-15 * A transaction with a single posting - only allowed when amount == 0 6 | Assets:Test 0.00 EUR 7 | 8 | 2019-02-15 * A transaction with a single posting - only allowed when amount == 0 9 | Assets:Test -0.00 EUR 10 | 11 | 2020-07-26 * No posting 12 | 13 | 2020-07-26 * No posting 14 | ; comment 15 | ; foo: 16 | 17 | 2020-09-29 * A transaction with a single posting - no amount 18 | Assets:Test 19 | 20 | -------------------------------------------------------------------------------- /tests/virtual-postings.beancount: -------------------------------------------------------------------------------- 1 | ;---------------------------------------------------------------------- 2 | ; ledger2beancount conversion notes: 3 | ; 4 | ; - Virtual posting in parentheses ignored 5 | ;---------------------------------------------------------------------- 6 | 7 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 8 | ; 9 | ; SPDX-License-Identifier: GPL-3.0-or-later 10 | 11 | 1970-01-01 open Assets:Cash 12 | 1970-01-01 open Assets:Test 13 | 1970-01-01 open Assets:Wallet 14 | 1970-01-01 open Equity:Opening-Balance 15 | 1970-01-01 open Expenses:Food 16 | 1970-01-01 open Expenses:Virtual 17 | 18 | 1970-01-01 commodity EUR 19 | 20 | 2018-03-17 * "Virtual posting with parentheses" 21 | Assets:Test 10.00 EUR 22 | Equity:Opening-Balance -10.00 EUR 23 | 24 | 2018-03-17 * "Virtual posting with brackets" 25 | Assets:Test 10.00 EUR 26 | Equity:Opening-Balance -10.00 EUR 27 | Assets:Wallet 7.00 EUR 28 | Equity:Opening-Balance -7.00 EUR 29 | 30 | 2020-05-29 * "Metadata on virtual posting" 31 | Assets:Cash -10.00 EUR 32 | Expenses:Food 33 | foo: "bar" 34 | Expenses:Virtual 2.00 EUR 35 | foo: "baz" 36 | 37 | 2020-05-29 * "Metadata on virtual posting" 38 | Assets:Cash -10.00 EUR 39 | Expenses:Food 40 | foo: "bar" 41 | Expenses:Virtual 2.00 EUR 42 | ; Some comment 43 | foo: "baz" 44 | 45 | 2020-05-29 * "Metadata on virtual posting" 46 | Assets:Cash -10.00 EUR 47 | Expenses:Food 48 | foo: "bar" 49 | Expenses:Virtual 2.00 EUR 50 | foo: "baz" 51 | ; Some comment 52 | 53 | 2020-05-30 * "Metadata on virtual posting" 54 | Expenses:Virtual 2.00 EUR 55 | foo: "baz" 56 | Expenses:Food 57 | foo: "bar" 58 | Assets:Cash -10.00 EUR 59 | xyz: "abc" 60 | 61 | 2020-05-30 * "Metadata on virtual posting" 62 | Expenses:Virtual 2.00 EUR 63 | ; Some comment 64 | foo: "baz" 65 | Expenses:Food 66 | foo: "bar" 67 | Assets:Cash -10.00 EUR 68 | xyz: "abc" 69 | 70 | 2020-05-30 * "Metadata on virtual posting" 71 | Expenses:Virtual 2.00 EUR 72 | foo: "baz" 73 | ; Some comment 74 | Expenses:Food 75 | foo: "bar" 76 | Assets:Cash -10.00 EUR 77 | xyz: "abc" 78 | 79 | -------------------------------------------------------------------------------- /tests/virtual-postings.ledger: -------------------------------------------------------------------------------- 1 | ; SPDX-FileCopyrightText: © 2018 Martin Michlmayr 2 | ; 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | 2018-03-17 * Virtual posting with parentheses 6 | Assets:Test 10.00 EUR 7 | Equity:Opening-Balance -10.00 EUR 8 | (Budget:Test) -10.00 EUR 9 | 10 | 2018-03-17 * Virtual posting with brackets 11 | Assets:Test 10.00 EUR 12 | Equity:Opening-Balance -10.00 EUR 13 | [Assets:Wallet] 7.00 EUR 14 | [Equity:Opening-Balance] -7.00 EUR 15 | 16 | 2020-05-29 * Metadata on virtual posting 17 | Assets:Cash -10.00 EUR 18 | Expenses:Food 19 | ; foo: bar 20 | [Expenses:Virtual] 2.00 EUR 21 | ; foo: baz 22 | 23 | 2020-05-29 * Metadata on virtual posting 24 | Assets:Cash -10.00 EUR 25 | Expenses:Food 26 | ; foo: bar 27 | [Expenses:Virtual] 2.00 EUR 28 | ; Some comment 29 | ; foo: baz 30 | 31 | 2020-05-29 * Metadata on virtual posting 32 | Assets:Cash -10.00 EUR 33 | Expenses:Food 34 | ; foo: bar 35 | [Expenses:Virtual] 2.00 EUR 36 | ; foo: baz 37 | ; Some comment 38 | 39 | 2020-05-30 * Metadata on virtual posting 40 | [Expenses:Virtual] 2.00 EUR 41 | ; foo: baz 42 | Expenses:Food 43 | ; foo: bar 44 | Assets:Cash -10.00 EUR 45 | ; xyz: abc 46 | 47 | 2020-05-30 * Metadata on virtual posting 48 | [Expenses:Virtual] 2.00 EUR 49 | ; Some comment 50 | ; foo: baz 51 | Expenses:Food 52 | ; foo: bar 53 | Assets:Cash -10.00 EUR 54 | ; xyz: abc 55 | 56 | 2020-05-30 * Metadata on virtual posting 57 | [Expenses:Virtual] 2.00 EUR 58 | ; foo: baz 59 | ; Some comment 60 | Expenses:Food 61 | ; foo: bar 62 | Assets:Cash -10.00 EUR 63 | ; xyz: abc 64 | 65 | -------------------------------------------------------------------------------- /tests/virtual-postings.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | convert_virtual: true 3 | -------------------------------------------------------------------------------- /themes/versions.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | {% if config.repo_name == 'GitHub' %} 4 | GitHub 5 | {% elif config.repo_name == 'Bitbucket' %} 6 | BitBucket 7 | {% elif config.repo_name == 'GitLab' %} 8 | GitLab 9 | {% endif %} 10 | {% if page.previous_page %} 11 | « Previous 12 | {% endif %} 13 | {% if page.next_page %} 14 | Next » 15 | {% endif %} 16 | 17 |
18 | 19 | 20 | --------------------------------------------------------------------------------