MoneyWorks Manual
Edit
!--sphider_noindex-->
SetExchangeRate (currency, date, period, newRate)
Definition: Sets the currency rate and creates the associated journal entry.
Example:
on GetRates
let url = "http://download.finance.yahoo.com/d/quotes.csv?s="
let currencyCount = 0
foreach cur in offledger CreateSelection("offledger", "kind=`CUR`")
let url = url + BaseCurrency + cur.Name + "=X+"
let currencyCount = currencyCount + 1
endfor
if currencyCount = 0
return
endif
let url = url + "&f=sl1d1t1ba&e=.csv"
let rates = ""
foreach row in textfile url
let rates = rates + Right(Left(Slice(row, 1, ","), 7), 3) + "\t" + Slice(row, 2, ",") + "\n"
endfor
foreach rate in text rates
let cur = Slice(rate, 1, "\t")
let xr = TextToNum(Slice(rate, 2, "\t"))
syslog("setting " + cur + " to " + xr)
SetExchangeRate(cur, Today(), CurrentPeriod(), xr)
endfor
end
Availability: within an MWScript handler
See Also:
CurrencyConvert: Convert amount between currencies
CurrencyName: Full name or denomination of a currency