Dear John

Sorry for re-drawing initial condition: I simplified data file for sake 
of brevity (content of new file appended below). Thierry helped me with the 
issue. Among other, he provided me with the links:

https://groups.google.com/d/topic/ledger-cli/_ukyL9WlzM0/discussion
https://groups.google.com/d/topic/ledger-cli/_EqH8mJOc5w/discussion

It looks like there is no other way to fix the exch/rate for a given 
transaction rather than to append {=1.00CAD} option to it. 

By 'fixing exch/rate' I mean this:
   - fixing exch/rate of given commodity for a TRANSCTION DATE -, 
not
   - fixing exch/rate of given commodity for ALL TRANSACTIONS TO DATE -

In other words, I want to link the exch/rate of a given transaction to the 
rate, fixed in relevant "P .... " record. As far as I can see, this 
functionality only comes together with re-valuation of closing balance, 
which serves as prohibitive complement for me.

The method suggtested by Theirry has some drawbacks, however:
- certain flexibility of 'ledger cli' is lost: 
   no way to change the reporting currency (by -X EUR) other, than the 
currency hard-coded in {}
   no way to change the rate for given date for given currency via amending 
appropriate "P ...." record
- stipulating exch/rate within transactions does not wave necessity to 
indicate the rate in "P..." record, for 'balance' report with '-X EUR' 
remain meaningful. This both complicates maintenance of data file and 
weakens data integrity.

The good thing is that if income/cost account is appended to each posting, 
as Theirry suggested, then 'balance' report places forex losses/income 
 into this account and zeroes total trial balance, if '-X USD' (in my case) 
option is applied.

    ======= VALUE:: =======
As I've mentioned in my previous correspondence, I was unable to aplpy 
'Value::' metadata modification operator to get sensible output. So If the 
following instruction is inserted into the data file, disclosed in the end:


= /^pl:/
 ; Value:: market(amount, post.date, exchange)

then, I have the following output:

> ledger -f dummy.ledger reg pl -X USD
12-Nov-01 inv 201-243           pl:sales                  USD250000   
 USD250000
12-Dec-05 inv 201-524           pl:sales                  USD750000   
USD1000000

which is beyond my comprehension. As far as I understand market() function, 
given post.date as the second parameter, shall return valuation of 
commodity on the date of transaction. In fact, output of USD250,000 is 
probably 500^2, which is obviously not one would expect.
    ======= VALUE:: (end) =======

Regards,
Dmitri


=========== test reports =======
> ledger -f dummy.ledger --exchange=USD bal
             USD2000  a:debtors:one
             USD-500  c:exch
            USD-1500  pl:sales

# comment: almost perfect!

> ledger -f dummy.ledger --exchange=USD reg pl:sales
12-Nov-01 inv 201-243           pl:sales                    USD-500     
 USD-500
12-Dec-05 inv 201-524           pl:sales                   USD-1000     
USD-1500

# comment: good to - no creeping revaluation!
========== test reports (end) =======
=========== data file ==========

P 2012/11/01  EUR                  1.00 USD
P 2012/12/01  EUR                  2.00 USD

2012/11/01 (243) inv 201-243
   a:debtors:one                    EUR500
   pl:sales                        EUR-500 {=1.00 USD}

2012/12/05 (241) inv 201-524
   a:debtors:one                    EUR500
   pl:sales                        EUR-500 {=2.00 USD}

=========== data file (end) =========


On Monday, February 18, 2013 3:16:04 PM UTC+2, John Wiegley wrote:
>
> >>>>> Dmitri Kourbatsky <[email protected] <javascript:>> writes: 
>
> > Both solutions apply fixed rate, common for all transactions. I which to 
> find 
> > the way to valuate commodity for each transaction at rate, applicable 
> for the 
> > transaction's date. 
>
> That isn't the behavior you get from just -X USD?  What do you see? 
>
> John 
>

-- 

--- 
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to