#' Write input files for KPI report
#'
#' Presupposes relevant network connections
#'
#' @param month character variable
#' @param path character variable
#'
#' @return files
#'
#' @examples
#' ## fis_write_kpi(month = "201908", path = "c:/temp")
#'
#' @importFrom rlang .data
#' @export
fis_write_kpi <- function(month = "202102", path = "s:/productie/product/fiscript/1-inputpharmo") {
art_file <- paste0(path, "/kpiartikelen", month, ".txt")
sal_file <- paste0(path, "/kpiomzet", month, ".txt")
arts <- read_from_productie(schema = "fiscript", view = "vwKpiPharmoArtikel")
sales <- read_from_fiaprod(view = "Report_PharmoKpiOmzet")
arts %>%
readr::write_csv2(art_file, col_names=F, eol = "\r\n")
sales %>%
dplyr::mutate(knmp = as.numeric(.data$knmp)) %>%
dplyr::inner_join(arts, by = c("knmp" = "atkode")) %>%
dplyr::group_by(.data$maand, .data$ephmra, .data$merk) %>%
dplyr::summarise(aip = sum(.data$aip),
.groups = "drop") %>%
dplyr::mutate_if(is.numeric, round, digits = 2) %>%
tibble::add_column(empty1 ="",
empty2 = "") %>%
readr::write_csv(sal_file, col_names=F, eol = "\r\n")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.