1;; A valuation function receives three arguments: 2;; 3;; 'source' A string identifying the commodity whose price 4;; is being asked for (example: "EUR") 5;; 6;; 'date' The reference date the price should be relative. 7;; 8;; 'target' A string identifying the "target" commodity, or 9;; the commodity the returned price should be in. 10;; This argument is null if -V was used instead of -X. 11;; 12;; The valuation function should return an amount. If you've written your 13;; function in Python, you can return something like Amount("$100"). If the 14;; function returns an explicit value, that value is always used, regardless 15;; of the commodity, the date, or the desired target commodity. 16 17define myfunc_seven(s, d, t) = 7 EUR 18 19;; In order to specific a fixed price, but still valuate that price into the 20;; target commodity, use something like this: 21 22define myfunc_five(s, d, t) = market(5 EUR, d, t) 23 24;; The 'value' directive sets the valuation used for all commodities used in 25;; the rest of the daat stream. This is the fallback, if nothing more 26;; specific is found. 27 28value myfunc_seven 29 30;; You can set a specific valuation function on a per-commodity basis. 31;; Instead of defining a function, you can also pass a lambda. 32 33commodity $ 34 value s, d, t -> 6 EUR 35 36;; Each account can also provide a default valuation function for any 37;; commodities transferred to that account. 38 39account Expenses:Food5 40 value myfunc_five 41 42;; The metadata field "Value", if found, overrides the valuation function on a 43;; transaction-wide or per-posting basis. 44 45= @XACT and Food 46 ; Value:: 8 EUR 47 (Equity) $1 48 49= @POST and Dining 50 (Expenses:Food9) $1 51 ; Value:: 9 EUR 52 53;; Lastly, you can specify the valuation function/value for any specific 54;; amount using the (( )) commodity annotation. 55 562012-03-02 KFC 57 Expenses:Food2 $1 ((2 EUR)) 58 Assets:Cash2 59 602012-03-03 KFC 61 Expenses:Food3 $1 62 ; Value:: 3 EUR 63 Assets:Cash3 64 652012-03-04 KFC 66 ; Value:: 4 EUR 67 Expenses:Food4 $1 68 Assets:Cash4 69 702012-03-05 KFC 71 Expenses:Food5 $1 72 Assets:Cash5 73 742012-03-06 KFC 75 Expenses:Food6 $1 76 Assets:Cash6 77 782012-03-07 KFC 79 Expenses:Food7 1 CAD 80 Assets:Cash7 81 822012-03-08 XACT 83 Expenses:Food8 $1 84 Assets:Cash8 85 862012-03-09 POST 87 Expenses:Dining9 $1 88 Assets:Cash9 89 90test reg -V food 9112-Mar-02 KFC Expenses:Food2 2 EUR 2 EUR 9212-Mar-03 KFC Expenses:Food3 3 EUR 5 EUR 9312-Mar-04 KFC Expenses:Food4 4 EUR 9 EUR 9412-Mar-05 KFC Expenses:Food5 5 EUR 14 EUR 9512-Mar-06 KFC Expenses:Food6 6 EUR 20 EUR 9612-Mar-07 KFC Expenses:Food7 7 EUR 27 EUR 9712-Mar-08 XACT Expenses:Food8 8 EUR 35 EUR 9812-Mar-09 POST (Expenses:Food9) 9 EUR 44 EUR 99end test 100