A workaround for which part? I don't understand your question.
On Fri, Jul 7, 2017 at 8:02 AM, <[email protected]> wrote: > Oh! Nevermind. It appears this is invalid beancount syntax. I thought if > the line did not begin with a date it was ignored, but that doesn't appear > to be the case. > Oh well. It would be nice to be able to embed Org Tables and such into > beancount files. > > According to the manual, "Any line that does not begin as a valid > Beancount syntax directive (e.g. with a date) is silently ignored.". > > Is there something I'm missing or a work-around for this? > > -k. > > > On Friday, July 7, 2017 at 7:54:12 AM UTC-4, [email protected] wrote: >> >> I've searched this list and it appears some people use Org Mode for >> outline hierarchy, I don't see much mention of using the other Org >> capabilities with beancount. >> >> I've just set up some Org Babel and tables to simplify the process of >> entering and updating currency positions. >> >> First, a babel bash shell block that converts from one currency to >> another. The default here is 1 USD to USD, but you can change the "curfrom" >> and "curto" and "amt" if you want. >> >> #+NAME: cconv >> #+BEGIN_SRC sh :results output :eval no-export :var amt="1", >> curfrom="USD", curto="USD" >> val=$(wget -qO- "http://www.google.com/finance/converter?a=${amt}&from=${ >> curfrom}&to=${curto}" | gsed '/res/!d;s/<[^>]*>//g' | cut -d" " -f4) >> echo $val >> #+END_SRC >> #+RESULTS: cconv >> : 1 >> >> Then, an inline babel call to test that the function works when passed >> other arguments >> >> #+CALL: cconv(amt="1", curfrom="USD", curto="CHF") >> #+RESULTS: >> : 0.9622 >> >> Then, an Org Table of all of my currencies I would like to track: >> >> #+NAME: currency_table >> | Input | Output | Value | >> |-------+--------+--------| >> | USD | DKK | 6.5135 | >> | USD | CHF | 0.9622 | >> | DKK | CAD | 0.1992 | >> #+TBLFM: $3='(org-sbe cconv (amt 1) (curfrom '$1) (curto '$2)) >> >> Pressing "C-c C-c" on the #+TBLFM line should update the 3rd column with >> the current conversion rate of each currency. >> >> Finally, another Babel bash shell block that takes the current conversion >> rate and prints the appropriate beancount lines. >> Note that because we are using NAMED blocks, all of this code can be >> located anywhere in your document, and the #+RESULTS: prices line located >> in a separate location, and it will still be updated. Also, "prepend" can >> be removed if you want to sort by date decreasing. >> >> #+NAME: prices >> #+BEGIN_SRC sh :results output raw prepend :eval no-export :var >> c=currency_table >> cc=( $c ) >> len=$(echo ${#cc[@]}) >> for (( i=0; i<$len; i+=3 )); do >> line=$(echo $c | cut -d" " -f1-3) # first three >> c=$(echo $c | cut -d" " -f4-) # rest of line >> curin=$(echo $line | cut -d" " -f1) # break out first three >> curout=$(echo $line | cut -d" " -f2) >> val=$(echo $line | cut -d" " -f3) >> echo $(date "+%Y-%m-%d") price $curin \\t\\t\\t $val $curout >> done >> #+END_SRC >> #+RESULTS: prices >> 2017-07-07 price USD 6.5135 DKK >> 2017-07-07 price USD 0.9622 CHF >> 2017-07-07 price DKK 0.1992 CAD >> >> >> Currently this requires evaluating (C-c C-c) the TBLFM and then >> evaluating the #+NAME:prices code block. I think there is a way to force >> the code block to update the table when it is evaluated, saving a bit of >> time, but I am not yet sure how to do that. >> >> I hope this is helpful to someone else, >> >> -k. >> >> >> -- > You received this message because you are subscribed to the Google Groups > "Beancount" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/beancount/b6bd803c-d3b0-46a3-8e76-068899359386%40googlegroups.com > <https://groups.google.com/d/msgid/beancount/b6bd803c-d3b0-46a3-8e76-068899359386%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Beancount" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/CAK21%2BhOdZcKqQv7mkDjatkn04t239vDtczKHfhjjp8AzENoJ5Q%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
