Dear Ed,
Thank you very much for your email, it was really useful for me :)
It would be really nice to have a "plugin library" for common "problems" like exports, imports. Probably imports are more important than exports (depends on users).
Finally I figured out how to get a fresh currency from our government site (www.mnb.hu), which we have to use officially. We cannot use other source. Rules....
The trick is:
---------------------
TODDAY=`date +%Y.%m.%d.`
THISY=`date +%Y`
USD=`lynx -dump "http://mnb.hu/arfolyam-tablazat?query=$TODDAY,$TODDAY,1,USD" | grep $THISY | awk '{print $4}'`
EUR=`lynx -dump "http://mnb.hu/arfolyam-tablazat?query=$TODDAY,$TODDAY,1,EUR" | grep $THISY | awk '{print $4}'`
---------------------
Cheers,
István
Üdvözlettel / Kind regards
Pongrácz István
ügyvezető / CEO
StartIT Kft.
+36 20 4489 581
StartIT Kft. | Fit-PC2 oldal | Csoportmunka | Webáruház | Javasolt Google motoros kereső | Keress a Facebook-on
----------------eredeti üzenet-----------------
Feladó: "Ed W" <..hidden..>
Címzett: "Development discussion for LedgerSMB" <..hidden..>
Dátum: Wed, 04 Aug 2010 08:29:17 +0100
----------------------------------------------------------
Hi
* Automaticly refresh currency exchange rate from official web services (configurable somehow: when, from, which with multiple currencies). Example: In Hungary we must use www.mnb.hu, others should use anything else. Exchange rate should be like this: HUF/USD: 216,99 (Configurable)
This seems like a solution which could be contributed as a "plugin" of sorts? Anyone want to step up?
I should think the solution will be found (or end up) on CPAN. Quick search there shows a few:
Finance::Currency::Convert::XE
Finance::Currency::Convert::WebserviceX
Finance::Quote
Finance::Currency::Convert::Yahoo
Actually this raises the good point about checking T&Cs on any data source used. XE has some specific T&Cs if you haven't paid for the data
Those not using XE for commercial purposes and hence not violating their T&Cs might consider something like the following script as a quick fix (run it via cron at a specific time of the day)
---------------------------------
#!/bin/bash
if [ $1 ]; then
TODAY=$1
else
TODAY=`date --rfc-3339='date'`
fi
# get exchangerate from XE
USD=`lynx -dump "http://www.xe.com/ucc/convert.cgi?Amount=1&From=USD&To=GBP" | grep "1 USD =" | awk '{print $4}'`
EUR=`lynx -dump "http://www.xe.com/ucc/convert.cgi?Amount=1&From=EUR&To=GBP" | grep "1 EUR =" | awk '{print $4}'`
if [ -n $EUR ] ; then
EXIST=`psql -U sql-ledger -t -c "SELECT * FROM exchangerate WHERE curr = 'EUR' AND transdate = '$TODAY';" nippynetworks`
if [ -n "$EXIST" ] ; then
psql -U sql-ledger -q -c "DELETE FROM exchangerate WHERE curr='EUR' AND transdate='$TODAY';" nippynetworks
fi
# echo "EUR: $EUR"
psql -U sql-ledger -q -c "INSERT INTO exchangerate (curr,transdate,buy,sell) VALUES('EUR','$TODAY',$EUR + 0.01,$EUR);" nippynetworks
else
echo "Failed to retrieve EUR rates"
fi
if [ -n $USD ] ; then
EXIST=`psql -U sql-ledger -t -c "SELECT * FROM exchangerate WHERE curr = 'USD' AND transdate = '$TODAY';" nippynetworks`
if [ -n "$EXIST" ] ; then
psql -U sql-ledger -q -c "DELETE FROM exchangerate WHERE curr='USD' AND transdate='$TODAY';" nippynetworks
fi
# echo "USD: $USD"
psql -U sql-ledger -q -c "INSERT INTO exchangerate (curr,transdate,buy,sell) VALUES('USD','$TODAY',$USD + 0.01,$USD);" nippynetworks
else
echo "Failed to retrieve USD rates"
fi
-----------------------------------
------------------------------------------------------------------------------ The Palm PDK Hot Apps Program offers developers who use the Plug-In Development Kit to bring their C/C++ apps to Palm for a share of $1 Million in cash or HP Products. Visit us here for more details: http://p.sf.net/sfu/dev2dev-palm
_______________________________________________ Ledger-smb-devel mailing list ..hidden.. https://lists.sourceforge.net/lists/listinfo/ledger-smb-devel