





## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ##
##                                                    ##
##             UPDATE 2015-02-15                      ##
##                                                    ##

          This file is no longer useful. 
          Instead use  get_DT.exchangerates()
##                                                    ##
##                                                    ##
##                                                    ##
## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ##




## Note to self:  The purpose of the "01 ingest..."  file is to convert Michael B's sheet 
##     to a tsv that can then be sent ot amazon S3 for Paulo to work with. 


setScience("Currency_Exchange_Rates", load=FALSE, create=FALSE, subl=FALSE)
DT.currency_exchange <- fread("~/git/orch/out/Currency_Exchange_Rates/exchange_rates_upto_2014_AUG.tsv")
DT.currency_exchange[, month := as.Date(sprintf("%s-%02i-01", year, match(MONTH_ABB, toupper(month.abb)))), by=accountingperiodid]

if ("USD" %ni% DT.currency_exchange[["currency_code"]]) {
  tmp_DT.USD <- unique(DT.currency_exchange[!is.na(currency_rate)], by="accountingperiodid")
  tmp_DT.USD[, `:=`(currency_code="USD", currency_rate=1)]
  DT.currency_exchange <- rbind(DT.currency_exchange, tmp_DT.USD)
  rm(tmp_DT.USD)
}

setkeyIfNot(DT.currency_exchange, "month", organize=TRUE, warnForColNameInEnv=FALSE, verbose=FALSE)
jesusForData(DT.currency_exchange, dir=data.p(proj="Currency_Exchange_Rates"))
