Goal: export an hledger file into Beancount format so I can use Fava
Issues: Searching the documentation isn't helping!
The hledger Print command is supposed to do this, but I can't find anything that explains how to use it. This page is both helpful and frustrating: hledger and Beancount - hledger
I'd love some step by step help if anyone has the patience to fill in my knowledge gaps. I know how to use hledger in the command line, but I'm not up on how to search for what I don't know.
Second tier docs like the cookbook (everything other than manuals and primary landing pages) are updated on a best effort basis, and anyone is welcome to help.
In this case, the last paragraph is up to date:
Since hledger 1.32, and especially in hledger 1.40.99+, the best option for exporting from hledger to beancount is hledger's print command, which supports beancount output.
and the specific Beancount output doc, which is a new section supposed to explain Beancount export issues in detail.
Though we should note the links I just pasted above are to the latest and greatest "dev" version of the docs, which is my habit. Normally it's best to look at the doc version corresponding to the hledger version you are using (if reading it on hledger.org, select the version at the top of any manual page).
So did you find those particular docs ? What went wrong ?
make sure you're running the latest hledger release (to benefit from the recent updates noted here)
hledger print -o main.beancount
if hledger says alias options are needed, add those to the command and run again: --alias revenues=income --alias 'other assets'=assets ...
Then beancount and fava should work:
$ bean-check main.beancount
$ bean-query main.beancount "SELECT account, units(sum(position)), cost(sum(position)) WHERE account ~ 'Aaa' GROUP BY 1 ORDER BY account;"
$ fava main.beancount
Thank you, all! Sounds like I've been giving up too easily, not searching through the documentation.
My problem at the moment is with the aliases I'm using in hledger; Beancount doesn't seem to like them as it's calling them out as not being an Asset, Liability, Expense, Equity, or Income. At the top of my hledger file I have a whole heap of entries like:
alias pay = Assets:Bank:Paycheck
alias x gifts = Expenses:Gifts
alias i interest = Income:Interest
When I go to export the file to Beancount it's rejecting the aliases. Any way around this?
@Ellane: you only need to ensure the top-most account names are the five expected by Beancount. You seem to be using those already, so there's some information we are missing; the place to look more closely is probably the original error message. Was it from hledger or from beancount ? What did it say ? Also check what top-level account names are reported by hledger accounts -1
And a tip in case you need it: if sharing terminal output on this forum, you can begin and end with a line of three backticks to preserve the text and layout as seen on the terminal.
Oh! It worked!! The error message I received wasn't what I thought. It was pointing out that I hadn't declared one of the aliases I was using. This is exciting! Thanks for all your help