Equity:Earnings:Current/Previous and "Closing the year"

2,117 views
Skip to first unread message

Jacques Gagnon

unread,
Feb 17, 2016, 2:06:24 PM2/17/16
to Beancount
Hi,

I'm a bit confuse on how this is suppose to work. From what I've read from the docs/mailling list I have the feeling this is populate somewhat automatically???

In ledger people seems to create manually a posting at the end of the year to move Income/Expense into Equity ie: "Closing the year"

How do we do that in beancount and how I query for it in bean-query? I dont see those automatic Equity account there.

Thanks!
Jacques

Martin Blais

unread,
Feb 17, 2016, 4:21:19 PM2/17/16
to Beancount
On Wed, Feb 17, 2016 at 9:06 AM, Jacques Gagnon <darth...@gmail.com> wrote:
Hi,

I'm a bit confuse on how this is suppose to work. From what I've read from the docs/mailling list I have the feeling this is populate somewhat automatically???

Yes.
While you can create and post to Equity accounts, you really shouldn't need to.


In ledger people seems to create manually a posting at the end of the year to move Income/Expense into Equity ie: "Closing the year"

These guys are very confused about this particular topic.

We have built this software that allows us to easily create a linear history of all postings to all accounts. Why would one need to carry out operations on this manually? The software (e.g., Beancount) should be able to "close a period" at any point in time by itself. I see no reason to zero out income/expenses accounts manually at the end of any arbitrary period -- Beancount does this for you on demand, at any date you desire, for any subset of transactions. This is a simple process that is automated by the reporting jobs. You should never need to close the year manually if you use Beancount. and I've solved this by defining a few simple operations.

I think some Ledger users do this manually in order to minimize the size of their Ledger files, for performance (files that contain one particular year). It's somewhat ironic that a Ledger user should have to do this annoying manual task because Ledger is supposed to be fast in the first place -- that's the motivation for them not sorting transactions in the first place, to be able to run in a single pass, but this which makes their balance assertions ill-defined and impossible to work with; this is a major design flaw of Ledger IMHO and reason enough I could not use it myself. Reordering transactions in the input file should never break assertions. Isn't it nice you don't have to worry about the ordering of your input? Anyhow, just ranting a bit, I've brought this up a long long time ago and I'd imagined they would all begin sorting their transactions like Beancount does, what they do seems like an intolerable compromise to me. Given the small size of these input files I see no reason to require a single processing pass.

But about your question... let's define some concepts. It's not a short answer, but it's actually not that complicated to understand if we define a few ideas well.


Closing the Year (the idea)
Here's what "closing the year" means to them: at a particular point in time, move the balance of all income and expenses account to an equity account. The resulting balance of income and expenses accounts should be zero. "Closing the year" applies at a date. Nota bene: I call this "CLEARING" in the query documentation. Read on.


Conversions
The other concept is that of inserting "conversion" transactions: this is simply used to make sure that the sum total of all the balances is an empty inventory, precisely. For example, when you convert from one currency to another, if you sum up _all_ of the postings, you end up with an inventory with multiple currencies in it. The sum total of these should approximate zero (it's the sum total of all currency conversions, and the conversion factor between them should be close to a weighted average of the exchange rates over these conversions). I want to have them be EXACTLY zero, so I automatically insert a special conversion transaction that zeroes out this full balance:

What this special transaction should contain is a function of the subset of transactions for which one wants to produce a balance sheet or income statement (what's filtered, which currency conversions remain in that subset). This is admittedly not the very best way to do this. I want to eventually do this using the currency trading accounts, essentially undoing the conversions purely in Equity accounts by auto-inserting postings on each transaction itself when there is a price conversion (search for "trading accounts" on the mailing list, this topic has come up multiple times, e.g., https://groups.google.com/d/msg/beancount/2Y7EWFUA3OA/e7N4cwbCIxcJ). I think that's a better method. Easy to do, just haven't had time yet.


Now, in the concepts and query language, let's look at the terminology of operations. I define three operations: "Open", "Close" and "Clear". These are applies on a list of directives before producing the reports (functions which accept a list of directives and return a new, modified list of directives). These operations are defined at particular dates and typically "open" happens before "close" and "clear". Call that start and end dates and the period it defines the "exercise period", e.g. one year, one quarter, whatever.

Open
The operation I call "open" at a particular date is defined as 
1. Inserting a conversions entry at that date
2. "clearing" the income / expenses accounts to zero by inserting transactions to fill up the Equity:Earnings:Previous account, and
3. Summarizing the past by replacing all the past history of each account with a single transaction to "opening balances"

From the resulting entries, you can draw a balance sheet at the opening date:

Close
The operation I call "close" at a particular date is
1. Removing all the entries past that date (i.e., deleting the future)
2. Inserting a conversions entry at that date, to account for currency conversions which occurred since the open date, during the period of exercise.

From that, you can draw an income statement of the balances of income and expenses accounts, and render registers for the period of exercise (the entries before the "open" date have been summarized by "open" so I don't have to do anything special to just render for that period). The code is here:

Clear
Finally, to render a balance sheet at the closing date:
1. Clear the income / expenses statements to the Equity:Earnings:Current account, which represents the net income for the current exercise period, by inserting suitable transactions in each account with a non-zero balance.

This zeroes out the income/expenses account and now we can produce a balance sheet for which the totals add up to zero. The source is here:

There's also some explanation similar to this in the query language doc:


So much for all the internals, but now it should be clear what these accounts are for:

Equity:Earnings:Previous : Contains net income accumulated from the beginning of time until the open date.
Equity:Earnings:Current : Contains net income accumulated between the open and close dates.

I hope this helps.

I have been meaning to explain this for a long while, I think I'll just cut-n-paste this in the intro doc for now.

And like I said, eventually I'll insert "undoing" postings automatically on transactions which involve currency conversions, so the insertion of special "conversion" entries will simply go away. In lieu of the Equity:Conversions:* accounts, there will be new equity accounts for each currency, similar to that in the currency trading accounts document by Peter (?) found somewhere else online (but it'll be all automatic, the user won't have to do anything manually or even think about it).



How do we do that in beancount and how I query for it in bean-query? I dont see those automatic Equity account there.

You can query them just like any other account.
Of course, if you didn't "OPEN" or "CLOSE" they'll be absent because there won't be any transactions posting anything to them.

More here:


I hope this helps. Please ask more questions if the above isn't clear enough. This is not an easy topic, but I have an idea for discussing it visually at some point I'll make a set of slides and perhaps even a video.


 

Thanks!
Jacques

--
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/15927c5f-66a5-4669-b755-5c1f71f03202%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jacques Gagnon

unread,
Feb 17, 2016, 5:25:08 PM2/17/16
to Beancount
Oh it's much more clear to me now. Thanks!

I had the bad mindset of thinking I had to record this somehow in my data file.
It's kind of dynamic virtual account used for reporting.

Plus I somehow didn't realize OPEN/CLOSE/CLEAR existed for this very use case.

I'll give it a try tonight and let you know if I got more question!

Nathan Grigg

unread,
Feb 17, 2016, 6:16:41 PM2/17/16
to bean...@googlegroups.com
This is tangentially related, but I've been thinking it would be useful to have something similar to "clear" that converts non-currency inventory to its market value on the closing date. Postings to Equity:Earnings:Future would balance these transactions.

The purpose would be to have a balance sheet that shows market value instead of book value.

Nathan

Jason Chu

unread,
Feb 17, 2016, 6:30:03 PM2/17/16
to Beancount
Since we're taking this conversation off-topic, I would like to point out the unrealized plugin as described in Trading with Beancount (https://docs.google.com/document/d/1WjARst_cSxNE-Lq6JnJ5CC41T3WndEsiMw4d46r2694/edit#heading=h.pm582rhzr9ws):


It works by applying a single transaction per account at the end of your balance sheet to record unrealized PnL.

My proposal (which I haven't finished thinking through) is to add an option to generate these transactions monthly, constantly keeping the account up to date with market value.

Martin Blais

unread,
Feb 18, 2016, 5:34:07 AM2/18/16
to Beancount
On Wed, Feb 17, 2016 at 12:25 PM, Jacques Gagnon <darth...@gmail.com> wrote:
Oh it's much more clear to me now. Thanks!

I had the bad mindset of thinking I had to record this somehow in my data file.
It's kind of dynamic virtual account used for reporting.

That's right. Kind of like that. I'd say, it's an "account used to transfer to and hold accumulated net income on the balance sheet." And Beancount does that transfer itself.

 
Plus I somehow didn't realize OPEN/CLOSE/CLEAR existed for this very use case.

Yep. It's a very useful thing to have. Ledger and HLedger don't adopt the idea because they don't want to enforce from the user that all accounts must be in one of the five categories, and that prevents them from automating this. They view this as freedom; I view these categories as a useful frame and a reasonable demand on the user. I think they mostly work with simple trial balance reports; I like to also have the classic Balance Sheet and Income Statement views, I think they're relevant reports, and coercing the user to work within the framework of these five accounts (well, in practice, four, really, you rarely ever end up make an explicit posting to an Equity account) allows us to get a little bit further towards fulfilling accounting tasks.

 
I'll give it a try tonight and let you know if I got more question!

On Wednesday, February 17, 2016 at 9:06:24 AM UTC-5, Jacques Gagnon wrote:
Hi,

I'm a bit confuse on how this is suppose to work. From what I've read from the docs/mailling list I have the feeling this is populate somewhat automatically???

In ledger people seems to create manually a posting at the end of the year to move Income/Expense into Equity ie: "Closing the year"

How do we do that in beancount and how I query for it in bean-query? I dont see those automatic Equity account there.

Thanks!
Jacques

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

Martin Blais

unread,
Feb 18, 2016, 5:48:22 AM2/18/16
to Beancount
On Wed, Feb 17, 2016 at 1:30 PM, Jason Chu <xen...@gmail.com> wrote:
Since we're taking this conversation off-topic, I would like to point out the unrealized plugin as described in Trading with Beancount (https://docs.google.com/document/d/1WjARst_cSxNE-Lq6JnJ5CC41T3WndEsiMw4d46r2694/edit#heading=h.pm582rhzr9ws):

I was just going to say. It kind-of does that indeed, except not against Equity:Earnings:Future, but rather against an income account, which is sensible.




It works by applying a single transaction per account at the end of your balance sheet to record unrealized PnL.

My proposal (which I haven't finished thinking through) is to add an option to generate these transactions monthly, constantly keeping the account up to date with market value.

Note that you'd might also want to adjust the cost basis every time you do this.. An alternative view is that it's essentially transferring unrealized profit out to cash and cost basis in, though that's problematic for other reasons (the original cost bases will be lost).

Just some context: The unrealized_gains plugin was a bit of an experiment to see if I could fold the market value reporting feature entirely using some of these profit realizing transactions. Currently that's the way to view market value in bean-web (I think fava could easily improve on this). As it turns out it's a bit limited, I don't like how the values render out very much, and it's currently not making that transfer at the opening of the exercise period, so the profit reported is a bit misleading, it's the total profit over the entire lifetime of the assets. I now feel that reporting at market value would be best done in the reporting itself rather than changing the flow of transactions.

(Of course, the "advanced" version of that is the accurate reporting of market returns, but that's still a work in progress.)

So much to do...




On Wednesday, February 17, 2016 at 10:16:41 AM UTC-8, Nathan Grigg wrote:
This is tangentially related, but I've been thinking it would be useful to have something similar to "clear" that converts non-currency inventory to its market value on the closing date. Postings to Equity:Earnings:Future would balance these transactions.

The purpose would be to have a balance sheet that shows market value instead of book value.

Nathan

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

Jacques Gagnon

unread,
Feb 18, 2016, 12:35:15 PM2/18/16
to bean...@googlegroups.com
Other subject but still related to Equity,

I think I need to add my house as an Asset so that my opening balance represent my real starting Equity.

How people usually estimate house value over the year? I was thinking of just following the municipal evaluation. Since it's hard to tell the market price unless you actually sell it.

How about home renovation, it's an expenses but shall add to the Equity.

Also do people usually track asset like a car and devaluate it over the time? Or its just track as a huge expenses?

Thanks

Jacques

Daniël Bos

unread,
Feb 18, 2016, 12:46:33 PM2/18/16
to bean...@googlegroups.com

Estimated house value for me is very easy. Where I live (in Beijing) houses are built in massive developments. In my area there are probably in the order of 10,000 apartments all built to the same spec at the same time. The average sales price per square meter is pretty much what you'll get when you put your property up for sale.

I suppose for most people this isn't an option though...

As for a car, in my opinion it depends on how large a part of your world it is. If the value of a car is small compared to your yearly income and net worth, then just book it as an expense. Otherwise you could get make it an asset, get the blue-book (or comparable) value each year and depreciate it. This goes for anything with a potential resale value.


Jacques Gagnon

unread,
Feb 18, 2016, 1:01:22 PM2/18/16
to Beancount
How do you track the house value over time exactly?

I was thinking to do:
Assets:House     1 HOUSE {XXX CAD}

And add price directive over time
price HOUSE  XXX CAD

Daniël Bos

unread,
Feb 18, 2016, 1:11:38 PM2/18/16
to bean...@googlegroups.com
That's one way to do it. Personally I book it against income:unrealized-gains.

I'm curious though if there are other (better) approaches.
> https://groups.google.com/d/msgid/beancount/61e32274-16a2-4368-9c25-5a236e4c7bfd%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



--
Best regards,
Daniël Bos


Your government is reading your email. Slow them down with encryption.

My public key: http://goo.gl/gms497 (4096 bit RSA, id EF2D5D91)
Fingerprint : D8D0 9FBE F075 F709 7B52 2F73 326C 2123 EF2D 5D91

Martin Blais

unread,
Feb 18, 2016, 2:21:33 PM2/18/16
to Beancount
On Thu, Feb 18, 2016 at 8:01 AM, Jacques Gagnon <darth...@gmail.com> wrote:
How do you track the house value over time exactly?

I was thinking to do:
Assets:House     1 HOUSE {XXX CAD}

And add price directive over time
price HOUSE  XXX CAD

Yes. That's exactly how I used to do it (when I had a home). Instead of "HOUSE" I used a currency name a bit more representative of the property, e.g. with the house number in it (LOFT4530), but otherwise that's essentially it.

Initially the cost was set to the price I paid for it, but over time I would "reevaluate" by inserting Price entries just as you suggest, with one Price source maybe once per year, or whenever I heard some relevant data points from neighbors. Price sources for reevaluation are somewhat relative, but a good benchmark would be to call a real estate agent and ask them to run a query for comparable properties in your area once per year. They'll probably do that for free (you may have to fake potential interest in selling), the large brokers all have systems to do this, and IMO taking the average recent sales prices of those properties is a realistic estimate of your property value. Don't use the municipal evaluation, that's always way off.

About the cost basis: Note that the true profit you'll make in the end does not include some of the costs of purchase and sale. Depends on the law where you are. I left that to be calculated at the end and did not adjust my cost basis.

Another tip for real estate tracking is to use a common name or root account for _all_ expenses related to the property, so that at the end you're able to segment those out easily derive all the cash flows that relate to it and compute its true investment value. This should help soften the notion that real estate is never a losing proposition; anyhow, I have a doc I've been meaning to write about this for the cookbook, a project to calculate the returns on a property as an investment using my own experience, which includes all the myriad costs associated with it, using Beancount. Haven't gotten to it yet.



On Thursday, February 18, 2016 at 7:46:33 AM UTC-5, Daniel Bos wrote:

Estimated house value for me is very easy. Where I live (in Beijing) houses are built in massive developments. In my area there are probably in the order of 10,000 apartments all built to the same spec at the same time. The average sales price per square meter is pretty much what you'll get when you put your property up for sale.

I suppose for most people this isn't an option though...

As for a car, in my opinion it depends on how large a part of your world it is. If the value of a car is small compared to your yearly income and net worth, then just book it as an expense. Otherwise you could get make it an asset, get the blue-book (or comparable) value each year and depreciate it. This goes for anything with a potential resale value.


On Thu, Feb 18, 2016, 20:35 Jacques Gagnon <darth...@gmail.com> wrote:
Other subject but still related to Equity,

I think I need to add my house as an Asset so that my opening balance represent my real starting Equity.

Yes.  ... so that your balance sheet reflects your total net worth, your house being (probably) a large portion of it.



Jason Chu

unread,
Feb 18, 2016, 4:56:13 PM2/18/16
to bean...@googlegroups.com
Note that you'd might also want to adjust the cost basis every time you do this.. An alternative view is that it's essentially transferring unrealized profit out to cash and cost basis in, though that's problematic for other reasons (the original cost bases will be lost).

All these advanced accounting terms... I'm not sure I understand what you mean by adjusting the cost basis.  You're talking about modifying the lots and prices themselves periodically?
 
Just some context: The unrealized_gains plugin was a bit of an experiment to see if I could fold the market value reporting feature entirely using some of these profit realizing transactions. Currently that's the way to view market value in bean-web (I think fava could easily improve on this). As it turns out it's a bit limited, I don't like how the values render out very much, and it's currently not making that transfer at the opening of the exercise period, so the profit reported is a bit misleading, it's the total profit over the entire lifetime of the assets. I now feel that reporting at market value would be best done in the reporting itself rather than changing the flow of transactions.

So what you're saying is closer to my original proposal in https://github.com/aumayr/fava/issues/129, right?  Instead of having synthetic transactions that represent the change in value over time, just report the market value when calculating monthly/yearly balances?

For me, I use it to look at a particular investment over time.  When I look at the Monthly Balances tab for a particular parent account, I get to see the increases (and decreases) in the book value over time and then I see a final market value in the last period.  The size of the Unrealized transaction makes me feel good or bad about my decisions in life.

You're probably looking at this an entirely different way.
 
(Of course, the "advanced" version of that is the accurate reporting of market returns, but that's still a work in progress.)

Is there a proposal in progress around this?  Should I just wait till it's implemented?  I think that what I have is good enough for the time being, but I'm not as dialed in with all of this as you are.

Gary Peck

unread,
Feb 19, 2016, 2:38:22 AM2/19/16
to Beancount
A cooperative I'm involved with is using beancount for our bookkeeping. I ended up writing a python script that takes data from `beancount.query` and generates the common financial reports (balance sheet, income statement, and cash flows) in markdown format (which then gets post-processed into a PDF annual report). The script assumes some things specific to how our coop operates (e.g. it assumes all transactions are in a single currency), but it might be a useful starting point for others. If there's interest I can get it published on github.

I've attached examples of the reports it produces. The balance sheet and income statement generation is basically a thin wrapper around the results of these queries:

- Opening balances:
SELECT account, SUM(position)
FROM CLOSE ON ${opening_date} CLEAR
GROUP BY account

- Closing balances:
SELECT account, SUM(position)
FROM OPEN ON ${opening_date} CLOSE ON ${closing_date + 1}
GROUP BY account

- Current earnings balance:
SELECT account, SUM(position)
FROM OPEN ON ${opening_date} CLOSE ON ${closing_date + 1} CLEAR
WHERE account = 'Equity:Earnings:Current'
GROUP BY account

The cash flow statement generation is a bit more involved since it actually has to know about the categories of various asset and liability accounts.

Gary

balance-sheet.md
cash-flows.md
income-statement.md

Martin Blais

unread,
Feb 19, 2016, 5:57:05 AM2/19/16
to Beancount
Thanks for sharing this Gary. I often feel like I develop Beancount in my own little lonely void. It's really fun to see people using the software and taking advantage of some features I feel may be a bit obscure.

I think you probably want to CLEAR on the Closing balance statement, because it will give you an income statement + a non-balancing balance sheet (equity accounts will be missing the net income from the non-zero income/expenses accounts). I'd call that a "trial balance" rather than a "balance sheet." (Then again, maybe that's what you want.)



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

Martin Blais

unread,
Feb 19, 2016, 6:26:52 AM2/19/16
to Beancount
On Thu, Feb 18, 2016 at 11:56 AM, Jason Chu <xen...@gmail.com> wrote:
Note that you'd might also want to adjust the cost basis every time you do this.. An alternative view is that it's essentially transferring unrealized profit out to cash and cost basis in, though that's problematic for other reasons (the original cost bases will be lost).

All these advanced accounting terms... I'm not sure I understand what you mean by adjusting the cost basis.  You're talking about modifying the lots and prices themselves periodically?

Yes.

It's a lot simpler than it sounds, and I must apologize for my use of so much jargon.
Each lot has a number of units of the commodity, and some number of units of the cost currency (that's the cost basis); these are joined together in each lot.
In a non-taxable account, all the lots can be considered in their totality, as well as the sum total of all the cost basis. We can do this because there is no tax consequence to realizing profit, so it doesn't matter which lot gets sold.

"Unrealized profit" is the difference between the current price of the commodity and the cost of each unit of the commodity, times the number of units.
You can convert unrealized profit to realized profit (i.e., you "realize" the profit) when you either (a) sell some units of the commodity, or (b) change (I usually say "adjust") the cost basis from those lots at some point in time (and move the corresponding amount to an income account).

Here's a real life example of making such a cost basis adjustment (b).

2013-08-24 * "Wash Sales cost basis adjustment for 50 shares from 100 shares sale"
  Assets:US:ETrade:Main:NYF                                          -50.00 NYF {101.98 USD}
  Assets:US:ETrade:Main:NYF                                           50.00 NYF {104.4614 USD}
  Income:US:ETrade:Main:PnL                                         -124.07 USD

What I was suggesting is that your periodic realizations, to be sensible, could adjust the cost basis of the lots they modify. In other words, after the adjustments, the new cost basis should be equal to the market value at that date. The difference is realized profit (like in the income account in the example above).

Problem is: the resulting lots, after these adjustments, wouldn't match any of the real lots you have. I don't like that.


 
Just some context: The unrealized_gains plugin was a bit of an experiment to see if I could fold the market value reporting feature entirely using some of these profit realizing transactions. Currently that's the way to view market value in bean-web (I think fava could easily improve on this). As it turns out it's a bit limited, I don't like how the values render out very much, and it's currently not making that transfer at the opening of the exercise period, so the profit reported is a bit misleading, it's the total profit over the entire lifetime of the assets. I now feel that reporting at market value would be best done in the reporting itself rather than changing the flow of transactions.

So what you're saying is closer to my original proposal in https://github.com/aumayr/fava/issues/129, right?  Instead of having synthetic transactions that represent the change in value over time, just report the market value when calculating monthly/yearly balances?

Yes, I think that probably makes more sense, to leave the unrealized profit as such and have explicit treatment and reporting of market value in the report. IMO it's less confusing, and you maintain the original list of lots.


For me, I use it to look at a particular investment over time.  When I look at the Monthly Balances tab for a particular parent account, I get to see the increases (and decreases) in the book value over time

"book value" === "cost basis"
If you don't invest new money, the book value does not change.
I'll take it you meant the "market value" here.

 
and then I see a final market value in the last period.  The size of the Unrealized transaction makes me feel good or bad about my decisions in life.

A better picture is to consider the returns over various trailing periods of time in addition to absolute amounts.
e.g. "returns over the last month"
"returns over the last three months"
"returns over the last year"
and then different aggregations of assets.
If you have all the data to compute the returns for one asset, you can combine them in different ways to look at the returns of these groups.
The correlations offer yet another view of your investment strategy.
Which helps answer the question: Have these been good decisions? Should I continue following this investment / strategy?


You're probably looking at this an entirely different way.
 
(Of course, the "advanced" version of that is the accurate reporting of market returns, but that's still a work in progress.)

Is there a proposal in progress around this?  Should I just wait till it's implemented?  I think that what I have is good enough for the time being, but I'm not as dialed in with all of this as you are.

I'm really eager to finish this but it's taking time and I'm prioritizing the ledgerhub conversion and the almost-finished booking branch. The way I've been going about this is I'm adding my own investments one-by-one (and relying on the fact I'll be able to combine them for reporting the returns of aggregates later on) but I'm still finding weird kinks in my trading history that trip up the returns code, some debugging to do. I've got some rewritten code in a branch that needs more work (branch: "returns2"). Part of that branch will include some better debugging output, to diagnose calculations that look wrong. I'd suggest waiting, or hacking your own. It might be instructive to read what I've got though, I think the way I ended up characterizing each of the flows into three categories (value, internal, external) is correct and I'm going to keep this framework.

Read more here:

There's a vastly incomplete doc here that I started with my friend Filippo which was unfortunately never completed (this is not really in a state to share but whatever, I'm running out of bandwidth at this point so why not):



Dominik Aumayr

unread,
Feb 19, 2016, 12:12:31 PM2/19/16
to Beancount
Gary,

I would like to incorporate these reports in fava (https://github.com/aumayr/fava/issues/145), as a HTML-table and Excel- and PDF-file.

Could you share the code to generate the balance sheet and income statement, as well as the cash flow statement?

Thanks,
Dominik
> To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/CAK21%2BhPw0YV_DKnRURj%2Bx159t5_byELL4eGyzSsHYpaUwr2oKA%40mail.gmail.com.

Dominik Aumayr

unread,
Feb 19, 2016, 12:12:59 PM2/19/16
to ga...@realify.com, Beancount
Gary,

I would like to incorporate these reports in fava (https://github.com/aumayr/fava/issues/145), as a HTML-table and Excel- and PDF-file.

Could you share the code to generate the balance sheet and income statement, as well as the cash flow statement?

Thanks,
Dominik


> Am 19.02.2016 um 06:56 schrieb Martin Blais <bl...@furius.ca>:
>
> To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/CAK21%2BhPw0YV_DKnRURj%2Bx159t5_byELL4eGyzSsHYpaUwr2oKA%40mail.gmail.com.

Jacques Gagnon

unread,
Feb 19, 2016, 12:14:20 PM2/19/16
to bean...@googlegroups.com
I think its worth sharing even if it's a bit specific, can be use as example.
Maybe along a dummy bean data file that has the proper account structure to be able try the script as is.

I planning to do something similar with my own reports once I'm done converting then to python (rather than awk)

Jacques Gagnon
GTalk/E-Mail: darth...@gmail.com
WLM (MSN): clou...@msn.com

On Thu, Feb 18, 2016 at 9:38 PM, Gary Peck <ga...@realify.com> wrote:

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

Martin Blais

unread,
Feb 20, 2016, 10:17:38 PM2/20/16
to Beancount
BTW, there is a new directive called "Query" which could be used to house those queries within the Beancount file itself.
It's currently unused, but the idea is that eventually bean-report would just render those queries by default if no specific ones are asked for on the command-line.

FYI.

Gary Peck

unread,
Mar 6, 2016, 7:15:54 PM3/6/16
to bean...@googlegroups.com
I've published the script at
https://gist.github.com/garyp/3ee36e8df5ce48611d66. As mentioned before,
it hard-codes some things that are specific to how our coop operates.
But hopefully it's a useful starting point for others. Happy to answer
questions anyone might have about what it's doing.

Gary

Dominik Aumayr

unread,
Mar 6, 2016, 7:18:29 PM3/6/16
to Beancount
Thank you very much, Gary!

I'll try to incorporate it into fava, and will get back to you once I'm done or if I have questions.

Thanks again,
Dominik
> --
> 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/20160306191553.GB4793%40marvin.realify.com.

Gary Peck

unread,
Mar 6, 2016, 7:26:06 PM3/6/16
to bean...@googlegroups.com
That's a great idea. I'm not sure about attaching the query to a
specific date (I was imagining more of a query template where the date,
and other placeholders, are filled in based on arguments provided by the
user), but I'll play around with this and see how I end up using it.

Thanks,
Gary

Gary Peck

unread,
Mar 6, 2016, 7:59:01 PM3/6/16
to bean...@googlegroups.com
You're right, I'm using the closing balance report more as a "trial
balance" than a proper "balance sheet". Mainly this was so I could have
both the income statement and balance sheet amounts in one query result,
which simplified my script a bit. I then derive the proper balance sheet
from this trial balance by ignoring the `Income` and `Expense` account
hierarchies and adding in the result of my "Current earnings balance"
query. Admittedly, this is a slightly roundabout way of doing this :)

Gary

Simon Michael

unread,
Mar 11, 2016, 9:49:34 PM3/11/16
to bean...@googlegroups.com
(Catching up on some old threads)

On 2/17/16 9:33 PM, Martin Blais wrote:
>> Plus I somehow didn't realize OPEN/CLOSE/CLEAR existed for this very use
>> case.
>
> Yep. It's a very useful thing to have. Ledger and HLedger don't adopt the
> idea because they don't want to enforce from the user that all accounts
> must be in one of the five categories, and that prevents them from
> automating this. They view this as freedom; I view these categories as a
> useful frame and a reasonable demand on the user. I think they mostly work
> with simple trial balance reports; I like to also have the classic Balance
> Sheet and Income Statement views, I think they're relevant reports, and
> coercing the user to work within the framework of these five accounts
> (well, in practice, four, really, you rarely ever end up make an explicit
> posting to an Equity account) allows us to get a little bit further towards
> fulfilling accounting tasks.

For the record, not at all; I'm very keen to have more of this kind of
thing available in hledger. Ie:

- awareness of the standard account types. Currently hledger has very
basic balancesheet/incomestatement/cashflow reports which use hard-coded
regexps to determine account types from the name.

- modelling account opening/closing, so that you can eg check for
mis-dated postings (And I'll have to learn what CLEAR does).

Martin Blais

unread,
Mar 12, 2016, 10:27:02 PM3/12/16
to Beancount

Simon Michael

unread,
May 11, 2016, 4:45:51 PM5/11/16
to bean...@googlegroups.com
On 3/12/16 2:26 PM, Martin Blais wrote:
> Clear is simple: for each balance of the income and expenses accounts,
> insert a transaction that returns this balance to zero.
>
> https://bitbucket.org/blais/beancount/src/adb5510d49c21a13d34082d40d9bfa6b5f39e55b/src/python/beancount/ops/summarize.py?at=default&fileviewer=file-view-default#summarize.py-145
>
> https://bitbucket.org/blais/beancount/src/adb5510d49c21a13d34082d40d9bfa6b5f39e55b/src/python/beancount/ops/summarize.py?at=default&fileviewer=file-view-default#summarize.py-347
>
> Best way to witness this in action is to create a minimal test input file
> and to use the print report to observe the resulting stream of
> transactions. Or inspect the unit tests here:
> https://bitbucket.org/blais/beancount/src/adb5510d49c21a13d34082d40d9bfa6b5f39e55b/src/python/beancount/ops/summarize_test.py?at=default&fileviewer=file-view-default#summarize_test.py-212

Thanks, that's interesting. (I do it manually to balance sheet accounts
at file boundaries to allow journal file concatenation. clear is a good
name.)


Reply all
Reply to author
Forward
0 new messages