addCurrencyNeutralCols_ <- function(DT, colsToRevAdjust=extract("_usd$", DT), newCols, joinCols.rec=c("quarter_and_year", "currency"), DT.Currency_Neutral_Factors = getDT.Currency_Neutral_Factors(refresh=refresh_cnf), refresh_cnf=FALSE) {
  if (missing(newCols))
    newCols <- colsToRevAdjust %>%
                colNamesFromVector %>%
                removeText(pat="_usd$", x=., ignore.case=TRUE) %>%
                paste0("_cneutral")


  ### Issue with truelength;  using this for now
  if (!truelength(DT.Currency_Neutral_Factors))
    DT.Currency_Neutral_Factors <- copy(alloc.col(DT.Currency_Neutral_Factors))

  ## add in fx_neutralizing_factor;
  ## In previous versions, it was called fx_factor instead of fx_neutralizing_factor
  colsToBring <- c("fx_neutralizing_factor" = ifelse("fx_factor" %in% names(DT.Currency_Neutral_Factors), "fx_factor", "fx_neutralizing_factor"))
  addColsFrom_(DT, DT.Currency_Neutral_Factors, joinCols.rec=joinCols.rec, joinCols.giv=c("quarter", "currency_code"), colsToBring=colsToBring, showWarnings=FALSE)

  if ("fx_neutralizing_factor" %ni% names(DT)) {
    warning("The fx_neutralizing_factor was not naturally brought over to the DT.\nThis is most likely due to a lack of overlap between the values in the keyCols for the DT and DT.Currency_Neutral_Factors.\n\nHINT: Do you have the most recent currency conversion rates")
    DT[, fx_neutralizing_factor := NA_real_]
  }

  ## all NAs should be 1
  DT[is.na(fx_neutralizing_factor), fx_neutralizing_factor := 1]

  ## Create the columns
  DT[, (newCols) := {lapply(colsToRevAdjust, function(col) get(col) * fx_neutralizing_factor)}]

  return(invisible(DT))
}

getDT.Currency_Neutral_Factors <- function(refresh=(.Pfm != "Darwin"), .Pfm=getPfm(), wh=getSnowflakeWH(), verbose=TRUE) {
  if (refresh) {
    verboseMsg(verbose, "Querying for DT.Currency_Neutral_Factors")
    DT.Currency_Neutral_Factors <- makeQry(tbl="Currency_Neutral_Factors", schema="bi", colsToPull="*", expand=FALSE, aggFunc=NULL) %>% sfQry(verbose=FALSE, wh=getSnowflakeWH())
  } else if (exists("DT.Currency_Neutral_Factors") && is.data.table(get("DT.Currency_Neutral_Factors"))) {
    DT.Currency_Neutral_Factors <- get("DT.Currency_Neutral_Factors")
  } else {
    envir <- environment()
    DT.Currency_Neutral_Factors <- loadFromJesus("DT.Currency_Neutral_Factors", envir=envir)
    ## if for some reason, the saved value is not a DT, refresh
    if (!is.data.table(DT.Currency_Neutral_Factors)) {
      warning("The DT.Currency_Neutral_Factors pulled from disk is NOT a data.table -- will refresh")
      DT.Currency_Neutral_Factors <- getDT.Currency_Neutral_Factors(refresh=TRUE, wh=wh, verbose=verbose)
    }
  }

  return(DT.Currency_Neutral_Factors)
}
