Re: [fava] Generate reports in other formats (PDF, Excel and ODF Spreadsheet) (#145)

201 views
Skip to first unread message

Martin Blais

unread,
Feb 20, 2016, 5:29:16 PM2/20/16
to aumayr/fava, Beancount, aumayr/fava, Martin Blais
On Fri, Feb 19, 2016 at 7:42 AM, aumayr <notifi...@github.com> wrote:

My goal with fava is to present the data Beancount generates in ways that fit my needs.

HTML was the first and most important one (as I wanted more than bean-web could deliver). PDF, XLSX and ODS (ODF Spreadsheet) are the other three formats that beancount does not deliver (and IMHO should not).

So there are three options:

  1. Build a separate tool to do this (a new project).
  2. Build it into fava and also provide a new CLI command (eg. fava-report)
  3. Build into Beancount. I don't think that Martin intends that, and it seems very complicated. (@blais Have you thought about that? Would you want this to be in Beancount?)
I favor (3).
bean-report was designed to include extensible reports that would render in a variety of formats.

 
yuzu [hg|default]:~/p/repos/beancount1$ bean-report --list-formats
Name             text  html  htmldiv  csv  beancount  hledger  ledger  ofx
---------------  ----  ----  -------  ---  ---------  -------  ------  ---
balances         X     X     X                                            
balsheet               X     X                                            
income                 X     X                                            
journal          X     X     X        X                                   
conversions            X     X                                            
documents              X     X                                            
holdings         X     X     X        X    X                              
cash             X     X     X        X                                   
networth         X     X     X        X                                   
export_holdings  X     X     X        X                                X  
commodities      X     X     X        X                                   
lifetimes        X     X     X        X                                   
prices           X     X     X        X                                   
all_prices                                 X                              
pricedb                                    X                              
tickers          X     X     X        X                                   
check            X                                                        
errors           X     X     X                                            
print                                      X                              
accounts                                   X                              
current_events   X     X     X        X                                   
events           X     X     X        X                                   
activity         X     X     X                                            
stats-types      X     X     X        X                                   
stats-postings   X     X     X        X                                   
ledger                                                         X          
hledger                                               X                   
---------------  ----  ----  -------  ---  ---------  -------  ------  ---


I think those formats should include CSV, ODF, XLS, etc. from Beancount itself.
I don't think the dependencies to make those happen are unreasonable, and if they are fat dependencies, we can make those optional. IMO it is within the scope of Beancount to provide this.

What would make sense to me is to reuse and/or add to the reporting code that's in Beancount and you could instantiate and render the reports from fava. This is exactly what I do in bean-web, e.g.:

All that reporting code used to be embedded in beancount/web/web.py itself, and I factored it out to beancount/reports/* in order to reuse the same code to render to any output format, the idea being that the reports are defined conceptually, include all the same data regardless of output formats, and the web app just becomes a thin container that calls into these.

This historical note should explain why the matrix above isn't entirely filled. I just haven't had time to build exporters for all the formats.

In particular, bean-query is screaming for an output to CSV. (Note: in the meantime, I've had a grand idea about bean-query and I'm coding it in a different repository, so that feature will probably appear there within the context of a much renewed and general tool that will also support Beancount).

I could extend the registration mechanism for reports (https://bitbucket.org/blais/beancount/src/54157625f090c97e70356ecf71607cf3784eadf3/src/python/beancount/reports/balance_reports.py?at=default&fileviewer=file-view-default#balance_reports.py-140) to include outside modules, so you could create your own reports outside so Beancount's development doesn't slow you down, yet still work within its framework, if this makes sense.


For me, option 1 is viable, but you would have to duplicate a lot of what our API does.

Option 2 is quick and easy. It also allows to factor this out into it's own project if in the future we feel that it does not belong to fava, as fava should stay true to it's HTML origin.

And both options 1 and 2 allow for the code to be integrated into beancount if Martin wants that.

But for now, I think option 2 and developing this alongside fava is the best option, until option 1 or 3 kick in and we factor it out.

(CSV should stay in bean-report IMHO)

@yagebu What do you think?


Reply to this email directly or view it on GitHub.


Reply all
Reply to author
Forward
0 new messages