bean-query get last balance assertion

127 views
Skip to first unread message

Tim Legg

unread,
Aug 24, 2023, 1:25:54 PM8/24/23
to Beancount
Is there a bean-query or another way to list the last balance assertion for all or a given account?

I tend to let my accounts get stale and like a way to ask.. when was the last time I verified this account or all account balances.

Red S

unread,
Aug 24, 2023, 5:57:56 PM8/24/23
to Beancount
I don't know if there's a way to get it through bean-query. If you use Fava, it does precisely this in the feature below.

Up-to-date indicators

Fava offers colored indicators that can help you keep your accounts up-to-date. They are shown next to accounts that have the metadata fava-uptodate-indication: TRUE set on their Open directive. The colors have the following meaning:

  • green: The last entry for this account is a balance check that passed.
  • red: The last entry is a balance check that failed.
  • yellow: The last entry is not a balance check.

In addition, a grey dot will be shown if the account has not been updated in a while, as configured by the uptodate-indicator-grey-lookback-days option.


Red S

unread,
Aug 24, 2023, 5:59:33 PM8/24/23
to Beancount
There is also a "copy balance directives" button in Fava's statistics page that I believe does exactly what you want.

It used to work, but I just checked, and it doesn't work on my current version. Perhaps it's been fixed, or needs someone to file a bug.

Tim Legg

unread,
Aug 26, 2023, 8:59:05 PM8/26/23
to Beancount
Ah, I was hoping to find a way to do it through bean-query when I'm on my hp stream which struggles with fava sometimes. But this works, thanks!

Red S

unread,
Aug 26, 2023, 10:05:46 PM8/26/23
to Beancount
If you're handy with some scripting, it's fairly trivial to do that. You can adapt Fava's code that's here to run on the shell.

Red S

unread,
Aug 28, 2023, 9:17:44 PM8/28/23
to Beancount

Actually, I’d been wanting this for a long time, so I just wrote it up. It’s here. Install via pip: pip3 install beancount-reds-importers, and then run bean-download needs-update --help

You can also simply download this single file and run it, though I’m not sure if I’ll support that in the future.

I'll write more about it in a separate post soon.

Tim Legg

unread,
Aug 29, 2023, 1:52:10 PM8/29/23
to Beancount
Wow, thanks, that's exactly what I was looking for. Also thanks for the link to your blog, I'm sure you've mentioned it before but it's new to me. Good stuff there!

Red S

unread,
Aug 31, 2023, 9:18:50 PM8/31/23
to Beancount
Great! And glad to hear the articles on my site are helpful as well :).

Daniele Nicolodi

unread,
Sep 1, 2023, 8:17:29 AM9/1/23
to bean...@googlegroups.com
On 24/08/23 19:25, Tim Legg wrote:
> Is there a bean-query or another way to list the last balance assertion
> for all or a given account?

I've just added a few more table definitions to beanquery. Adding them
was planned since a while, but not having a concrete use case for them,
it was not implemented.

With these, it is possible to write a query like this:

SELECT
account,
max(date)
FROM
#balances
GROUP BY
account


Cheers,
Dan

Reply all
Reply to author
Forward
0 new messages