I'd like to propose a feature (for post 3.0) that would make ledger
even more powerful and useful.  It would make it easier to keep
separate books (e.g. cash vs accrual) and to get useful information
out of ledger.

My idea is inspired by SQL views.  In SQL, you can can define a
view which is essential a query that makes data available in a
virtual table that can be queried normally. (This idea is unrelated
to ledger's recently SQL support, though, afaict.)

Essentially what I'd like to do is to specify a config file in
ledger that would tell ledger how to re-write certain transactions
before showing them to me.

Let's consider some examples of how this would be useful.

Example 1) Cash vs accruals basis

I have Google ads on my web site and get a small income from this.
In ledger, I account for this income as it accrues (on a monthly
basis): every month, I login and check how much I've earned this
month and then I add this ledger.  But I only get paid from Google
when I reach 70 EUR or so (in the example I use 0.02 EUR).

So in ledger I have transactions like this:

2012-01-31 * AdSense earnings (1 Jan - 31 Jan)
    Assets:Receivable:AdSense                            0.01 EUR
    Income:AdSense

2012-02-29 * AdSense earnings (1 Feb - 29 Feb)
    Assets:Receivable:AdSense                            0.02 EUR
    Income:AdSense

2012-03-01 * AdSense payment
    Assets:Bank                                           0.02 EUR
    Assets:Receivable:AdSense                            -0.02 EUR

So far so good.  The problem is that when I do my tax return, I don't
have to specify income I've accrued but only money that has been paid
to me.  So I have to ignore the Assets:Receivable:AdSense entries and
only look for actual payments to my bank account.  Essentially, I have
to convert my accruals based accounting system to cash based accounting.

It would be great if I could tell ledger in a config file:
 - ignore all transactions that involve Assets:Receivable:AdSense
   _and_ Income:AdSense
 - and re-write all transactions that involve Assets:Receivable:AdSense
   _and_ Assets:Bank and re-write Assets:Receivable:AdSense to
   Income:AdSense in this case.

In the example above, this would delete the first two transactions
and leave me with the following transaction:

2012-03-01 * AdSense payment
    Assets:Bank                                           0.02 EUR
    Income:AdSense                                       -0.02 EUR

(Bonus points if I can also re-write the description from "AdSense
payment" to "AdSense earnings".)

Example 2) Combining accounts into one - salary, taxes, etc

A lot of us are tracking our personal finance.  We sometimes get
the question as to how to track salary best: should we track all
gross income and then track deductions, such as tax.  Or should we
simply enter our net pay since this is the figure we typically care
about.

This question was recently asked on this list and I argued in
http://www.mail-archive.com/[email protected]/msg02552.html
that the correct way is to account for the gross income plus all
deductions.  However, this makes it hard to see the net pay since
you have to specify all deductions, e.g.:
  bal income:employment:salary expenses:tax:income expenses:tax:ni

This is another example that could be simplified if ledger would
allow to specify a config file to re-write transactions.  I could
then track all information (gross income, tax paid, social security,
etc), but I could also specify a config file that would simply it
for me.

Let's take a simpler example: let's say you receive money from PayPal.
PayPal takes a fee so what you receive is actually less.  So you have
something like this:

2012-02-07 * PayPal payment
    Income                                               -5.00 EUR
    Expenses:Fees:PayPal                                  0.57 EUR
    Assets:PayPal                                         4.43 EUR

In this case, if I want to know the net income, I have to run:

$ ledger -f c.ledger bal incom expenses:
            0.57 EUR  Expenses:Fees:PayPal
           -5.00 EUR  Income
--------------------
           -4.43 EUR

What I'd like to do is specify a file containing re-write rules so
that this transaction would become:

2012-02-07 * PayPal payment
    Income                                               -4.43 EUR
    Assets:PayPal                                         4.43 EUR

Then I could run ledger reg on my ledger file and get:

2012-02-07 PayPal payment  Income               -5.00 EUR -5.00 EUR
                           Expenses:Fees:PayPal  0.57 EUR -4.43 EUR
                           Assets:PayPal         4.43 EUR         0

But if I'd specify ledger reg --re-write test, I'd get:

2012-02-07 PayPal payment  Income           -4.43 EUR    -4.43 EUR
                           Assets:PayPal     4.43 EUR            0

I think such a feature would be very powerful and I can think of many
use cases for such a feature.  John, how difficult would this be to
implement and does this fit into your plans for ledger?

-- 
Martin Michlmayr
http://www.cyrius.com/

Reply via email to