Is it possible to show number of transactions in register report

91 views
Skip to first unread message

Ivanov Dmitry

unread,
Jan 3, 2015, 6:51:02 AM1/3/15
to ledge...@googlegroups.com
Suppose, I am attending piano lessons, and have the following ledger file:

---------------------------------------------
2014/01/02 * Piano lesson
  Expenses:Piano             $30
  Assets:Cash

2014/02/02 * Piano lesson
  Expenses:Piano             $30
  Assets:Cash

2014/03/02 * Piano lesson
  Expenses:Piano             $30
  Assets:Cash

2014/04/02 * Piano lesson
  Expenses:Piano             $30
  Assets:Cash

2014/04/12 * Piano lesson
  Expenses:Piano             $30
  Assets:Cash
---------------------------------------------

Then I run a register report to see monthly statistics:  ledger --date-format %m -f test.txt --monthly register Expenses:Piano

I get this:

01 - 01                  Expenses:Piano                    $30          $30
02 - 02                  Expenses:Piano                    $30          $60
03 - 03                  Expenses:Piano                    $30          $90
04 - 04                  Expenses:Piano                    $60         $150

Is it possible to show 2 new columns:
1. number of transactions
2. growing number of transactions?

So, I could know, how many lessons I attended each month. Like this:


01 - 01                  Expenses:Piano                    $30          $30     1      1
02 - 02                  Expenses:Piano                    $30          $60     1      2
03 - 03                  Expenses:Piano                    $30          $90     1      3
04 - 04                  Expenses:Piano                    $60         $150    2      5

Craig Earls

unread,
Jan 4, 2015, 2:09:45 PM1/4/15
to ledge...@googlegroups.com
I don't know of any way to do this. 

--

---
You received this message because you are subscribed to the Google Groups "Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ledger-cli+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Craig, Corona De Tucson, AZ
enderw88.wordpress.com

Martin Blais

unread,
Jan 4, 2015, 2:50:53 PM1/4/15
to ledger-cli
As an FYI, in the Beancount query language, you express this using COUNT():

beancount> select year(date), month(date), account, count(position) where  account ~ 'Expenses:Piano' group by 1, 2, 3 order by 1, 2, 3;

I haven't merged it into the default branch yet, but I'm working on documenting it right now in order to merge it and make it available.



Ivanov Dmitry

unread,
Jan 6, 2015, 5:21:22 AM1/6/15
to ledge...@googlegroups.com
Martin Blais:
As an FYI, in the Beancount query language, you express this using COUNT():

beancount> select year(date), month(date), account, count(position) where  account ~ 'Expenses:Piano' group by 1, 2, 3 order by 1, 2, 3;

I haven't merged it into the default branch yet, but I'm working on documenting it right now in order to merge it and make it available.

It would be fantastic to combine the power of SQL and flexibility of ledger files.

Martin Blais

unread,
Jan 6, 2015, 9:33:37 AM1/6/15
to ledger-cli
I've merged the SQL client two days ago on the 'default' branch of Beancount.
Doc is here:

An approach I would recommend is to convert your input file to Beancount, which provides the benefit of inventory booking checks (it's more strict) and dated balance assertions (you don't have to worry about file ordering). From there, you can then automatically convert that file into Ledger format equivalent and use the reports you've become accustomed to. This way you get both set of tools and a much tighter input file with less errors. I'm seeing a few users take this road now.

Or... you could port my SQL client to use Ledger's Python interface. I don't think it would be very difficult. It might even be possible to support both backends without forking it.

Cheers,

Ivanov Dmitry

unread,
Feb 18, 2015, 11:28:00 AM2/18/15
to ledge...@googlegroups.com
I tried to install beancount on Linux Slackware. But got an error:

/beancount/bin$ ./bean-example
Traceback (most recent call last):
  File "./bean-example", line 2, in <module>
    from beancount.scripts.example import main; main()
  File "/usr/lib/python3.3/site-packages/beancount/scripts/example.py", line 26, in <module>
    from dateutil import rrule
ImportError: No module named 'dateutil'

Where to get this module? I installed one, but it seems to be for Python 2.

Martin Blais

unread,
Feb 18, 2015, 11:26:58 PM2/18/15
to ledger-cli, bean...@googlegroups.com
Hi Ivanov,
You need to install dateutil for Python3.
It's here:

See this document for more instructions: 

I don't know what you have available in terms of package management (under Ubuntu there's a python3-dateutil package available).
In any case you should be able to install it using pip3; you could also build it from source.
Cheers,






--
Reply all
Reply to author
Forward
0 new messages