historical prices with and without revaluation

189 views
Skip to first unread message

Qwertyu

unread,
Dec 2, 2011, 1:01:59 PM12/2/11
to Ledger
Hi there,

if I try to keep track of gasoline usage I could do this:

P 2011/11/01 00:00:00 LiterGas 1.00 $
2011/11/01 Get Gas
Expenses:Car:Gas 10 LiterGas
Assets:Cash

P 2011/11/02 00:00:00 LiterGas 10.00 $
2011/11/02 Get Gas
Expenses:Car:Gas 10 LiterGas
Assets:Cash

P 2011/11/03 00:00:00 LiterGas 100.00 $
2011/11/03 Get Gas
Expenses:Car:Gas 10 LiterGas
Assets:Cash

To see how much gas was used works OK:

> ledger reg Car:Gas
11-Nov-01 Get Gas Expenses:Car:Gas 10 LiterGas 10
LiterGas
11-Nov-02 Get Gas Expenses:Car:Gas 10 LiterGas 20
LiterGas
11-Nov-03 Get Gas Expenses:Car:Gas 10 LiterGas 30
LiterGas

And now, how much was spent on gas:

> ledger -X $ reg Car:Gas
11-Nov-01 Get Gas Expenses:Car:Gas
$10 $10
11-Nov-02 Commodities revalued <Revalued>
$90 $100
11-Nov-02 Get Gas Expenses:Car:Gas
$100 $200
11-Nov-03 Commodities revalued <Revalued>
$1800 $2000
11-Nov-03 Get Gas Expenses:Car:Gas
$1000 $3000

This wrong, since I have spent only $1110 on gas. What is the proper
way to do this? Somehow the revaluation should be disabled. On the
other hand, if I kept, say one liter bought on 11/11/01 and sold it
again on 11/11/03, then this should be revalued. Say, we change the
ledger file to:

P 2011/11/01 00:00:00 LiterGas 1.00 $
2011/11/01 Get Gas
Expenses:Car:Gas 10 LiterGas
Assets:Gas 1 LiterGas
Assets:Cash

P 2011/11/02 00:00:00 LiterGas 10.00 $
2011/11/02 Get Gas
Expenses:Car:Gas 10 LiterGas
Assets:Gas 1 LiterGas
Assets:Cash

P 2011/11/03 00:00:00 LiterGas 100.00 $
2011/11/03 Get Gas
Expenses:Car:Gas 10 LiterGas
Assets:Gas 1 LiterGas
Assets:Cash

Now

> ledger -X $ reg Assets:Gas
11-Nov-01 Get Gas Assets:Gas
$1 $1
11-Nov-02 Commodities revalued <Revalued>
$9 $10
11-Nov-02 Get Gas Assets:Gas
$10 $20
11-Nov-03 Commodities revalued <Revalued>
$180 $200
11-Nov-03 Get Gas Assets:Gas
$100 $300

is actually correct but

> ledger -X $ reg Assets:Cash
11-Nov-01 Get Gas Assets:Cash
$-11 $-11
11-Nov-02 Commodities revalued <Revalued>
$-99 $-110
11-Nov-02 Get Gas Assets:Cash
$-110 $-220
11-Nov-03 Commodities revalued <Revalued>
$-1980 $-2200
11-Nov-03 Get Gas Assets:Cash
$-1100 $-3300

is wrong.

Somehow one should be able to specify

Assets:Gas -- use historical prices AND revaluate
Assets:Cash -- use historical prices without revaluation
(but if you have 10 GPB in there it should be revalued, but not
the -10 LiterGas)
Expenses:Car:Gas -- use historical prices without revaluation

There is a similar situation with currencies. If you spend, say 10
GBP, worth 15$ then this should not be revalued later on. However, if
you have 10 GPB in your wallet, I guess it should be revalued
according to the current rate.

Any good ideas how to handle this with ledger?

There were some similar discussion already:
http://groups.google.com/group/ledger-cli/browse_thread/thread/8b3b29d3e167e6ab/5b0721d1dff72135
http://groups.google.com/group/ledger-cli/browse_thread/thread/6cbcaa9aa20bab6d/21424ed3eae62d58

Cheers, Heiko

thierry

unread,
Dec 3, 2011, 9:22:21 AM12/3/11
to Ledger

One syntax can be (using fixated commodity price)

P 2011/11/01 00:00:00 LiterGas 1.00 $
2011/11/01 Get Gas

Expenses:Car:Gas 10 LiterGas {=1$}
Assets:Cash

P 2011/11/02 00:00:00 LiterGas 10.00 $
2011/11/02 Get Gas

Expenses:Car:Gas 10 LiterGas {=10$}
Assets:Cash

P 2011/11/03 00:00:00 LiterGas 100.00 $
2011/11/03 Get Gas

Expenses:Car:Gas 10 LiterGas {=100$}
Assets:Cash

and then

$ ledger --exchange=$ reg Car:Gas


11-Nov-01 Get Gas Expenses:Car:Gas $10 $10

11-Nov-02 Get Gas Expenses:Car:Gas $100 $110
11-Nov-03 Get Gas Expenses:Car:Gas $1000 $1110

you have to read about multiple currency accounting, reference is
http://www.mscs.dal.ca/~selinger/accounting/tutorial.html, and read
about commodities fixated prices, which is one of the way of ledger to
implement it.

> On the
> other hand, if I kept, say one liter bought on 11/11/01 and sold it
> again on 11/11/03, then this should be revalued. Say, we change the
> ledger file to:

I am not able to make the link between the sentence just above, and
the ledger file just below.

> P 2011/11/01 00:00:00 LiterGas 1.00 $
> 2011/11/01 Get Gas
> Expenses:Car:Gas 10 LiterGas
> Assets:Gas 1 LiterGas
> Assets:Cash
>
> P 2011/11/02 00:00:00 LiterGas 10.00 $
> 2011/11/02 Get Gas
> Expenses:Car:Gas 10 LiterGas
> Assets:Gas 1 LiterGas
> Assets:Cash
>
> P 2011/11/03 00:00:00 LiterGas 100.00 $
> 2011/11/03 Get Gas
> Expenses:Car:Gas 10 LiterGas
> Assets:Gas 1 LiterGas
> Assets:Cash
>

Here is my understanding of your sentence:
- keep the exemple at the beginning of the email
01-Nov Buy 10 liter gas, 1$ per liter
02-Nov Buy 10 liter gas, 10$ per liter
03-Nov Buy 10 liter gas, 100$ per liter
- on 01-Nov keep one liter aside
- on 03-Nov sell that liter with price revalued

Here is how I would write it in ledger syntax

P 2011/11/01 LiterGas 1.00 $
2011/11/01 Get Gas
Assets:Cash -10 $
Assets:Gas 10 LiterGas
Assets:Gas -9 LiterGas
Expenses:Car:Gas 9 $

P 2011/11/02 LiterGas 10.00 $
2011/11/02 Get Gas
Assets:Cash -100 $
Assets:Gas 10 LiterGas
Assets:Gas -10 LiterGas
Expenses:Car:Gas 100 $

P 2011/11/03 LiterGas 100.00 $
2011/11/03 Get Gas
Assets:Cash -1000 $
Assets:Gas 10 LiterGas
Assets:Gas -10 LiterGas
Expenses:Car:Gas 1000 $

2011/11/03 Sell 1 LiterGas
Assets:Gas -1 LiterGas @@ 100 $
Assets:Cash 100 $
Incomes:Gas -1 LiterGas @ 1 $
Incomes:Gas 1 LiterGas @ 100 $
Incomes:Gas


Two "tricks"
- in my mind, the account Expenses:Car:Gas is of currency dollar, not
LiterGas
- the 3 last lines enables me to not compute the gain

> Now
>
> > ledger -X $ reg Assets:Gas
>
> 11-Nov-01 Get Gas Assets:Gas
> $1 $1
> 11-Nov-02 Commodities revalued <Revalued>
> $9 $10
> 11-Nov-02 Get Gas Assets:Gas
> $10 $20
> 11-Nov-03 Commodities revalued <Revalued>
> $180 $200
> 11-Nov-03 Get Gas Assets:Gas
> $100 $300
>
> is actually correct but

$ ledger register Assets:Gas
11-Nov-01 Get Gas Assets:Gas 10 LiterGas 10 LiterGas
Assets:Gas -9 LiterGas 1 LiterGas
11-Nov-02 Get Gas Assets:Gas 10 LiterGas 11 LiterGas
Assets:Gas -10 LiterGas 1
LiterGas
11-Nov-03 Get Gas Assets:Gas 10 LiterGas 11 LiterGas
Assets:Gas -10 LiterGas 1
LiterGas
11-Nov-03 Get Gas Assets:Gas -1 LiterGas 0

is different, because I separate the "buy" from the "consumption". You
can not accumulate indefinitely LiterGas, you have to consume them.
I treat the "LiterGas" as it was a stock share.

>
> > ledger -X $ reg Assets:Cash
>
> 11-Nov-01 Get Gas Assets:Cash
> $-11 $-11
> 11-Nov-02 Commodities revalued <Revalued>
> $-99 $-110
> 11-Nov-02 Get Gas Assets:Cash
> $-110 $-220
> 11-Nov-03 Commodities revalued <Revalued>
> $-1980 $-2200
> 11-Nov-03 Get Gas Assets:Cash
> $-1100 $-3300
>
> is wrong.

$ ledger register Assets:Cash
11-Nov-01 Get Gas Assets:Cash -10 $ -10 $
11-Nov-02 Get Gas Assets:Cash -100 $ -110 $
11-Nov-03 Get Gas Assets:Cash -1000 $ -1110 $
11-Nov-03 Get Gas Assets:Cash 100 $ -1010 $

>
> Somehow one should be able to specify
>
> Assets:Gas -- use historical prices AND revaluate
> Assets:Cash -- use historical prices without revaluation
> (but if you have 10 GPB in there it should be revalued, but not
> the -10 LiterGas)
> Expenses:Car:Gas -- use historical prices without revaluation
>
> There is a similar situation with currencies. If you spend, say 10
> GBP, worth 15$ then this should not be revalued later on.

This is what ledger calls "fixated commodity price"

> However, if
> you have 10 GPB in your wallet, I guess it should be revalued
> according to the current rate.

Can be realued if not fixated.

> Any good ideas how to handle this with ledger?
>
> There were some similar discussion already:
> http://groups.google.com/group/ledger-cli/browse_thread/thread/8b3b29d3e167e6ab/5b0721d1dff72135

In second post of this thread, as advised by John, "You will need to
periodically reduce the GallonsGas balance to zero"

> http://groups.google.com/group/ledger-cli/browse_thread/thread/6cbcaa...
>
> Cheers, Heiko

Reply all
Reply to author
Forward
0 new messages