Specify Date Range

351 views
Skip to first unread message

ELI

unread,
Dec 2, 2014, 11:54:56 PM12/2/14
to bean...@googlegroups.com
Does Beancount have a command-line option for specifying a date range to limit queries to?

- Harpreet "Eli" Sangha

Martin Blais

unread,
Dec 3, 2014, 9:22:05 AM12/3/14
to ELI, bean...@googlegroups.com
Hi Eli,
From which tool?
- bean-web, you simply click on the year
- bean-reports: does not have it yet, probably should be added to "balances" report
- bean-query:  in SELECT or BALANCES,  "FROM  year = 2014", but better is "FROM OPEN on 2014-01-01 CLOSE on 2015-01-01"  and add CLEAR if you're interested in just the balance sheet accounts. I have to merge this branch and write docs to explain why this matters, this isn't released yet.







On Tue, Dec 2, 2014 at 11:54 PM, ELI <eli...@gmail.com> wrote:
Does Beancount have a command-line option for specifying a date range to limit queries to?

- Harpreet "Eli" Sangha

--
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/CAKU2X8aZi6%2B%2BYY36V3%2Bg33%2BXJmq1D6noFWA%3DE69beFJCsBT9UQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

ELI

unread,
Dec 3, 2014, 11:29:40 AM12/3/14
to Martin Blais, bean...@googlegroups.com

bean-report is what I had in mind. With ledger-cli I found it useful to view the register outputs for statement periods for comparison. With beancount I was hoping to leverage such an option in forecasting plugins to control how far out to forecast.

I haven't looked at bean-sql yet. I'll check it out.

Thanks,
- Harpreet "Eli" Sangha

Martin Blais

unread,
Dec 3, 2014, 10:08:21 PM12/3/14
to ELI, Martin Blais, bean...@googlegroups.com
Are you interested in registers or balances?

In the shell branch, using the bean-query tool, journals are

  SELECT date, flag, payee, narration, account, change  
  FROM OPEN ON 2014-01-01 CLOSE ON 2015-01-01 CLEAR

a shorthand is

  JOURNAL FROM OPEN ON ...

(Try with and without clear)

Registers are 

  SELECT acocunt, sum(cost(balance)) 
  FROM ....
  GROUP BY 1

or as shorthand

  BALANCE FROM ...

(Warning: This is still being worked on, subject to simplifications... the next thing I'll do is create use cases with unit tests for each and then merge this into default, might take a few weeks, certainly some version of it will be merged during Christmas time.)

ELI

unread,
Dec 3, 2014, 10:25:30 PM12/3/14
to Martin Blais, bean...@googlegroups.com
My immediate interest is in registers to see the result of my plugin that adds forecasting entries.  I'll experiment with bean-query when I get home, but with it will the date ranges be visible to plugins?

- Harpreet "Eli" Sangha

Martin Blais

unread,
Dec 3, 2014, 10:28:29 PM12/3/14
to ELI, Martin Blais, bean...@googlegroups.com
No, the SQL queries are independent, they work on the result of the processing pipeline after all the plugins have run.

In order to configure a plugin, you can use the second (optional) argument to the plugins directive; you can put any Python data structure in there, it will get passed as an argument to your plugin.

Tell me from a high-level what you'd like to do, a bit more precisely?

ELI

unread,
Dec 3, 2014, 11:42:12 PM12/3/14
to Martin Blais, bean...@googlegroups.com
I want to have a plugin that generates forecasted transactions, but rather than forecasting for an arbitrary date range or specific number or transaction I want to only generate transactions within the scope of the query.  For example, if I'm looking at the registers or balances for 2014, from your example, then forecasted transactions should be generated up to 2015-01-01.  If I'm just looking at current balances (no date is specified) then no forecasted transactions need to be generated.  Similarly, no generated transactions would be needed when viewing 2013 data, but a whole years worth would be necessary for viewing 2015 projections.

- Harpreet "Eli" Sangha
Reply all
Reply to author
Forward
0 new messages