balance

144 views
Skip to first unread message

francois PEGORY

unread,
May 16, 2016, 12:26:29 PM5/16/16
to bean...@googlegroups.com
hello,
i look for having the latest balance fro each account in my file:
do you know how to have it ?

regards


Martin Blais

unread,
May 17, 2016, 12:42:28 AM5/17/16
to Beancount
bean-report <filename> balances
bean-query <filename> "select account, sum(position) group by account" 


--
You received this message because you are subscribed to the Google Groups "Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beancount+...@googlegroups.com.
To post to this group, send email to bean...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/CALUWbLeHGUJE6XY74MB3dH-Q7wzfcqyWzw3SLySJ5y7r_5LEUA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Martin Blais

unread,
May 18, 2016, 10:33:08 AM5/18/16
to francois PEGORY, Martin Blais, Beancount
Do you want "data from the last Balance directive" or "the balances as of the date of the last Balance directive in each account"?
Please be specific.


On Wed, May 18, 2016 at 5:46 AM, francois PEGORY <pfranc...@gmail.com> wrote:

Thanks but i wanted to have the latest Balance directive not the effective Balance.

Regards

 

 

 

De : Martin Blais
Envoyé le :mardi 17 mai 2016 06:42
À : Beancount
Objet :Re: balance

francois PEGORY

unread,
May 20, 2016, 10:37:49 AM5/20/16
to Martin Blais, Beancount

Thanks but i wanted to have the latest Balance directive not the effective Balance.

Regards

 

 

 

De : Martin Blais
Envoyé le :mardi 17 mai 2016 06:42
À : Beancount
Objet :Re: balance

 

bean-report <filename> balances

francois PEGORY

unread,
May 22, 2016, 12:25:34 PM5/22/16
to Martin Blais, Beancount
exactly i want the date from the last Balance directive. 
regards

Martin Blais

unread,
May 22, 2016, 2:21:51 PM5/22/16
to francois PEGORY, Martin Blais, Beancount
There's no possible date common over all accounts which makes this possible.
For example, two different accounts may have different dates for their last balance directives.

In order to carry this out using bean-query, you'd have to somehow tell it to stop accumulating the positions after the last balance, conditional on this per-account value. Not sure how to do that, there's no conditional on aggregation functions in bean-query.

However, an easy way to do this would be to write a plugin that discards all transactions after the last Balance directive in each account. Note that this is not well-defined because a single transaction posts to multiple accounts... if one of the postings is before that account's last Balance directive and the other isn't, should one ignore the transaction or not? I don't know. You might have your own opinion on that.

If you don't care to maintain the accounting equation, you could write a custom report that sums up the positions in each account, disregarding the transactions themselves. But then running a balance sheet or trial balance on those won't sum up to zero.

Or ... yet another idea: you could write a plugin that inserts metadata on postings which occur after the last Balance directive (e.g. "unverified: TRUE") and use bean-query's WHERE clause to filter those out. That would work. In fact, you could always leave that plugin on... if you don't use the field, it wouldn't hurt anything else. That's the best implementation IMO.

Choose your evil.

Martin Blais

unread,
May 22, 2016, 3:21:08 PM5/22/16
to Beancount, francois PEGORY

francois PEGORY

unread,
May 22, 2016, 3:32:40 PM5/22/16
to Martin Blais, Beancount
thanks it will be usefull

francois PEGORY

unread,
May 22, 2016, 3:56:25 PM5/22/16
to Martin Blais, Beancount
yes but in fact, it is not the thing.
to have for a account a balance at a date, it is easy to have it with bql :
select date, flag, payee, account, position, balance from close on 2016-01-01 where account = "Assets:Banque:bank"
if i want to have balance for this account at this date but i can't query the balance directive in BQL. 
in the perfect world, someting like that:
select date, flag, payee, account, position, balance from close on Max(date_of_balance_directive) where account = "Assets:Banque:bank"
like this, no need to have a plugin.

regards

Martin Blais

unread,
May 22, 2016, 6:15:59 PM5/22/16
to francois PEGORY, Martin Blais, Beancount
On Sun, May 22, 2016 at 3:56 PM, francois PEGORY <pfranc...@gmail.com> wrote:
yes but in fact, it is not the thing.
to have for a account a balance at a date, it is easy to have it with bql :
select date, flag, payee, account, position, balance from close on 2016-01-01 where account = "Assets:Banque:bank"
if i want to have balance for this account at this date but i can't query the balance directive in BQL. 
in the perfect world, someting like that:
select date, flag, payee, account, position, balance from close on Max(date_of_balance_directive) where account = "Assets:Banque:bank"
like this, no need to have a plugin.

If you did that (that is, simply compute the balances on a fixed closing date) it may include some postings from accounts other than the one with the latest balance directive.
I'm not sure that this is what you want.

In any case, you can always write a script to produce anything you need.
Cheers,
Reply all
Reply to author
Forward
0 new messages