Opening and closing balances
Opening Balances
Section titled “Opening Balances”hledger-flow looks for a file named YEAR-opening.journal in each
account directory, where YEAR corresponds to an actual year directory,
eg. 1983 (if you have electronic statements
dating back to 1983). Example:
import/john/mybank/savings/1983-opening.journal
If it exists the file will automatically be included at the beginning of the generated journal include file for that year.
You need to edit this file for each account to specify the opening balance at the date of the first available transaction.
An opening balance may look something like this:
2018-06-01 Savings Account Opening Balance assets:mybank:savings $102.01 equity:opening/closing balancesA Note of Caution Regarding Closing Balances
Section titled “A Note of Caution Regarding Closing Balances”When closing your balances it may result in some hledger queries showing zero-values, or there could be issues with balance assertions.
Please have a look at the upstream hledger documentation on closing balances, e.g here:
https://hledger.org/hledger.html#close-usage
Some of the gotchas you may run into are also described in this hledger-flow issue.
Closing Balances
Section titled “Closing Balances”Similar to opening balances, hledger-flow looks for an optional file
named YEAR-closing.journal in each account directory. Example:
import/john/mybank/savings/1983-closing.journal
If it exists the file will automatically be included at the end of the generated journal include file for that year.
A closing balance may look something like this:
2018-06-01 Savings Account Closing Balance assets:mybank:savings $-234.56 = $0.00 equity:opening/closing balancesExample Opening and Closing Journal Files
Section titled “Example Opening and Closing Journal Files”As an example, assuming that the relevant year is 2019 and
hledger-flow is about to generate
import/john/mybank/savings/2019-include.journal, then one or both of
the following files will be added to the include file if they exist:
import/john/mybank/savings/2019-opening.journalimport/john/mybank/savings/2019-closing.journal
The opening.journal will be included just before the other included
entries, while the closing.journal will be included just after the
other entries in that include file.
An include file may look like this:
cat import/john/mybank/savings/2019-include.journal### Generated by hledger-flow - DO NOT EDIT ###
include 2019-opening.journalinclude 3-journal/2019/123456789_2019-01-30include 2019-closing.journalStability
Section titled “Stability”Closing balances sometimes result in unexpected query results. In future we may change how/where the generated files include the closing journal.
We may also need to suggest some naming conventions for opening and closing balances so that reports can exclude some of these transactions.
It is also possible that we might want to change the name/location of the closing journal, but we’ll try to avoid this if possible, because that would require users to rename their existing files.