Balance Assertions on Income and Expense a/c

191 views
Skip to first unread message

Alok Parlikar

unread,
Aug 26, 2016, 11:04:52 PM8/26/16
to Beancount
Hi Martin,

I understand that generally balance assertions are relevant only for balance sheet accounts. However, I have a use case to use them on Income and Expense accounts, and I wonder what your advice would be on going about writing these assertions.

I'd like to assert that, say, between 1 Jan and 31 Dec 2015, the "balance" in Income:Interest is XX. I have declared this amount in my tax return and would therefore like an assertion to prevent this amount changing "accidentally" in the future. The other purpose of doing this is to help with reconciliation at the end of the year. Example: a broker sends me what it's record of Income:ShortTermGains is, and I'd like to make sure my entries of the gains add up to the same value.

I see a couple of ways of doing it:

1. Writing assertions of actual balances rather than the "this years balance". Easiest to do, but makes the entries hard to read.

2. Writing a plugin that adds entries for each year and matches against given targets.

Is there a simpler way? Or an alternative approach to handle the use case?

Thanks
Alok

Martin Blais

unread,
Aug 27, 2016, 12:44:38 AM8/27/16
to Beancount
On Fri, Aug 26, 2016 at 11:04 PM, Alok Parlikar <happ...@gmail.com> wrote:
Hi Martin,

I understand that generally balance assertions are relevant only for balance sheet accounts. However, I have a use case to use them on Income and Expense accounts, and I wonder what your advice would be on going about writing these assertions.

I'd like to assert that, say, between 1 Jan and 31 Dec 2015, the "balance" in Income:Interest is XX. I have declared this amount in my tax return and would therefore like an assertion to prevent this amount changing "accidentally" in the future. The other purpose of doing this is to help with reconciliation at the end of the year. Example: a broker sends me what it's record of Income:ShortTermGains is, and I'd like to make sure my entries of the gains add up to the same value.

This is a valid use case and shares some aspects with budgeting constraints.
If you think about it, budgets are about avoiding too much of a delta over a time period on an asset account.

This is very congruent with the general properties of accounts:
- Assets/Liabilities: Are snapshots, and we generally care only about the particular value of them at a single point in time.
- Income/Expenses: Are changes, and we generally care only about the changes over some interval over time.

A balance sheet is a snapshot of assets/liabilities accounts at a single point in time (incl. net income).
An income statement is a report of differences of income/expense accounts over a particular interval.

We have an assertion type for assets/liabilites accounts ("balance" directive).
It only begs that we ought to also have an assertion for changes to income/expenses accounts. 
(And budgets are an application of the latter to the accounts of the former.)


I see a couple of ways of doing it:

1. Writing assertions of actual balances rather than the "this years balance". Easiest to do, but makes the entries hard to read.

2. Writing a plugin that adds entries for each year and matches against given targets.

Is there a simpler way? Or an alternative approach to handle the use case?

The Right Thing (TM) to do IMO is to design a new directive and implement that in the core.

In the meantime, you could use the Custom directive type to prototype it in a plugin, have your plugin run some code to check the difference.

One interesting question is how to carry this out efficiently (think: if there are many many such constraints to be applied). Not sure it's so important for a proof-of-concept though.




Thanks
Alok

--
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+unsubscribe@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/010bc7ff-fa41-4720-8524-f40badd2f791%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alok Parlikar

unread,
Sep 29, 2018, 3:03:28 AM9/29/18
to Beancount
Just wondering.. Has there been some support added for these income/expense balance assertions :-)

Alok

Martin Blais

unread,
Sep 29, 2018, 7:40:20 AM9/29/18
to Beancount
Not yet

On Sat, Sep 29, 2018, 03:03 Alok Parlikar <happ...@gmail.com> wrote:
Just wondering.. Has there been some support added for these income/expense balance assertions :-)

Alok

--
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.

Alok Parlikar

unread,
Jan 4, 2021, 4:41:59 AM1/4/21
to Beancount
Sorry to bring up this old thread; but since v3 is actively underway, ... Is this likely to be part of v3 :-) ?

Writing balance assertions for BS and P&L after doing taxes for that year feel like "test cases" in case I need to modify any plugins I'm using.

Alok

Martin Blais

unread,
Jan 4, 2021, 9:21:26 AM1/4/21
to Beancount
This is a nice idea but ther'es a lot of more pedestrian stuff to come before.
I think you can easily write a script to do this right now.

Just create an instance of Inventory, iterate through the subset of transactions relevant for you, accumulate all their postings in there and check that balance in your script.
You could create a script that accepts input from a config file, or use Custom directives and pull them from the Beancount stream of directives.




Reply all
Reply to author
Forward
0 new messages