#' Create and upload a new fac
#'
#' @param facture_n generated by new_fac_num()
#' @param client client
#' @param contact contact chez le client
#' @param adresse adresse
#' @param objet objet
#' @param quantite quantite
#' @param prix prix
#' @param quoi quoi
#' @param date date
#' @param fait_a fait_a
#' @param money money
#' @param type type
#' @param dir dir
#' @param comment comment
#'
#' @importFrom cli cat_rule
#' @importFrom rmarkdown render
#' @importFrom pagedown chrome_print
#' @importFrom fs file_delete dir_delete
#' @importFrom googlesheets4 sheets_append
#' @export
create_fac <- function(
facture_n = "DATENUM",
client = "CLIENT",
contact = "PERSONNE EN CHARGE",
adresse = "LA BAS",
objet = "Sponsoring",
quantite = 1,
prix = 1000,
quoi = "SPONSORING DE",
date = as.character(Sys.Date()),
fait_a = "Paris",
money = "€",
comment = "",
type = "sponsoring",
dir = "."
) {
html_nm <- sprintf(
"molieR_fac_%s_%s.html",
thinkr::clean_vec(quoi),
client
)
pdf_nm <- sprintf(
"molieR_fac_%s_%s.pdf",
thinkr::clean_vec(quoi),
client
)
withr::with_dir(
new = dir, {
cat_rule("rendering the html")
render(quiet = TRUE,
system.file(
"facture.Rmd",
package = "compta"
),
output_dir = ".",
output_file = html_nm,
params = list(
facture_n = facture_n,
client = client,
contact = contact,
adresse = adresse,
objet = objet,
quantite = quantite,
prix = prix,
quoi = quoi,
date = date,
fait_a = fait_a,
money = money
)
)
cat_rule("Shoting to pdf")
chrome_print(
html_nm,
pdf_nm
)
file_delete(
html_nm
)
dir_delete(
paste0(
tools::file_path_sans_ext(html_nm),
"_files"
)
)
}
)
cat_rule("Appending the google sheet")
sheets_append(
data.frame(
stringsAsFactors = FALSE,
facture_n = facture_n,
date = date,
client = client,
contact = contact,
adresse = adresse,
objet = objet,
quantite = quantite,
prix = prix,
quoi = quoi,
comment = comment
),
url
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.