diff --git a/examples/multi-year/2021.journal b/examples/multi-year/2021.journal new file mode 100644 index 000000000..64e5940c5 --- /dev/null +++ b/examples/multi-year/2021.journal @@ -0,0 +1,14 @@ +; 2021.journal + +2021-06-01 opening balances ; start:2021 + assets 20 = 20 + equity:start + +2021-07-01 income + income + assets 1 + +2021-12-31 closing balances ; start:2022 + assets -21 = 0 + equity:start + diff --git a/examples/multi-year/2022.journal b/examples/multi-year/2022.journal new file mode 100644 index 000000000..6b0c467ee --- /dev/null +++ b/examples/multi-year/2022.journal @@ -0,0 +1,14 @@ +; 2022.journal + +2022-01-01 opening balances ; start:2022 + assets 21 = 21 + equity:start + +2022-07-01 income + income + assets 1 + +2022-12-31 closing balances ; start:2023 + assets -22 = 0 + equity:start + diff --git a/examples/multi-year/2023.journal b/examples/multi-year/2023.journal new file mode 100644 index 000000000..37c2520ac --- /dev/null +++ b/examples/multi-year/2023.journal @@ -0,0 +1,10 @@ +; 2023.journal + +2023-01-01 opening balances ; start:2023 + assets 22 = 22 + equity:start + +2023-07-01 income + income + assets 1 + diff --git a/examples/multi-year/README.md b/examples/multi-year/README.md new file mode 100644 index 000000000..49f46a2cc --- /dev/null +++ b/examples/multi-year/README.md @@ -0,0 +1,4 @@ +Multiple yearly journal files, demonstrating the tags and commands +suggested in the [close command's doc](https://hledger.org/dev/hledger.html#example-exclude-openingclosing-transactions>) +for flexible multi-year reporting. +See `reports`. diff --git a/examples/multi-year/reports b/examples/multi-year/reports new file mode 100755 index 000000000..ee090de5c --- /dev/null +++ b/examples/multi-year/reports @@ -0,0 +1,14 @@ +#!/usr/bin/env sh + +# Suppressing redundant starting/ending balances transactions as suggested in +# https://hledger.org/dev/hledger.html#example-exclude-openingclosing-transactions . +# All of these will show the year-end balances correctly. +# In each case, we exclude all transactions tagged with start: except the earliest. + +hledger bs -Y -f 2021.journal -f 2022.journal -f 2023.journal expr:'tag:start=2021 or not tag:start' +hledger bs -Y -f 2021.journal -f 2022.journal expr:'tag:start=2021 or not tag:start' +hledger bs -Y -f 2022.journal -f 2023.journal expr:'tag:start=2022 or not tag:start' +hledger bs -Y -f 2021.journal expr:'tag:start=2021 or not tag:start' +hledger bs -Y -f 2022.journal expr:'tag:start=2022 or not tag:start' +hledger bs -Y -f 2023.journal # unclosed file, no query needed + diff --git a/hledger/Hledger/Cli/Commands/Close.md b/hledger/Hledger/Cli/Commands/Close.md index 4be0c4e11..86f514d80 100644 --- a/hledger/Hledger/Cli/Commands/Close.md +++ b/hledger/Hledger/Cli/Commands/Close.md @@ -188,7 +188,7 @@ $ hledger -f 2022.journal bs not:desc:'closing balances' When combining files for multi-year reports, for some reports (eg a yearly balance sheet) you may need to suppress all opening/closing transactions except the first. This is a bit awkward if you also want to be able to choose any range of year files, -but here is a way, using tags: +but here is a way, using tags (full example [here](https://github.com/simonmichael/hledger/tree/master/examples/multi-year/)): ```journal ; 2021.journal