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
Ledger-smb-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ledger-smb-devel

Reply via email to