Commit a5777d28 authored by Dorchies David's avatar Dorchies David
Browse files

feat: detection of time differences in a month and automatic edition of lacking time

Closes #2
parent 924bc517
No related merge requests found
Showing with 160 additions and 8 deletions
+160 -8
# Generated by roxygen2: do not edit by hand
export(fdt_add_event)
export(fdt_get_differentiel)
export(fdt_get_lack_days)
export(fdt_isValidable)
export(fdt_valid)
export(get_user_id)
......
......@@ -26,7 +26,7 @@ fdt_add_event <- function(
cfg = config::get(file = system.file("config.yml", package = "hatata"))
) {
if(!inherits(session, "hatata_pointage")) {
session <- jump_to_pointage(session)
session <- jump_to_pointage(session, cfg = cfg)
}
cookies <- session$response$cookies$value
......
fdt_add_events <- function(session,
durees,
dates = names(durees),
type_regulation = "22",
commentaire = "",
cfg = config::get(file = system.file("config.yml", package = "hatata"))) {
if (!inherits(session, "hatata_pointage")) {
session <- jump_to_pointage(session, cfg = cfg)
}
invisible(
lapply(seq_along(durees),
function(i)
fdt_add_event(session,
dates[i],
durees[i],
type_regulation, commentaire, cfg))
)
}
#' Get column "Différentiel" content of a "pointage" page
#'
#' @param session a [rvest::session] provided by [login] or [jump_to_mon_calendrier] functions
#' @param date a [character] representing the current date in format "%Y-%m-%d"
#'
#' @return A named [vector] of [character] : the name is the date in "%d/%m/%Y" format and the content is the difference between theoretical and actually worked hours in format "(-)00h00".
#' @export
#'
#' @examples
#' \dontrun{
#' library(hatata)
#' session <- login("pnom", "password")
#' fdt_get_differentiel(session)
#' }
fdt_get_differentiel <- function(session,
date = format(Sys.Date() - months(1), "%Y-%m-%d")) {
date <- as.Date(date)
firstMonth <- lubridate::floor_date(date, "month")
lastMonth <- lubridate::ceiling_date(date, "month") - 1
dates <- seq(firstMonth, lastMonth, by = "1 day")
session <- jump_to_pointage(session, date = date)
df <- session %>%
rvest::html_node(xpath = "//*[@id=\"fiche_pointage\"]") %>%
rvest::html_table()
differentiel <- unlist(df[-nrow(df),ncol(df)])
names(differentiel) <- format(dates, "%d/%m/%Y")
return(differentiel)
}
#' Extract days where work hours in less than theoretical hours
#'
#' @param session a [rvest::session] provided by [login] or [jump_to_mon_calendrier] functions
#' @param date a [character] representing the current date in format "%Y-%m-%d"
#'
#' @return A named [vector] of [character] : the name is the date in "%d/%m/%Y" format and the content is the necessary time to add for reaching theoretical time for the day in format "+00h00".
#' @export
#'
#' @examples
#' \dontrun{
#' library(hatata)
#' session <- login("pnom", "password")
#' fdt_get_differentiel(session)
#' }
fdt_get_lack_days <- function(session,
date = format(Sys.Date() - months(1), "%Y-%m-%d")) {
d <- fdt_get_differentiel(session, date)
d <- d[substr(d, 1, 1) == "-"]
names_d <- names(d)
substr(d, 1, 1) <- "+"
names(d) <- names_d
return(d)
}
......@@ -29,24 +29,41 @@ Pour saisir des temps dans [l'outil #temps](https://temps-activites.inra.fr/temp
session <- login("mon_idenfiant_INRAE_pnom", "mon_mot_de_passe_INRAE")
```
Choisissez ensuite des dates sur lesquelles vous avez des régularisations à faire, exemple pour le 15 avril 2021 avec une journée de 7h44 en "heures normales"&nbsp;:
Pour obtenir les dates du mois précédent pour lesquelles vous avez un nombre d'heures inférieur aux horaires théoriques et le nombre d'heures par jour à compléter:
``` r
fdt_add_event(session, "15/04/2021")
> fdt_get_lack_days(session)
08/06/2021 10/06/2021 14/06/2021 15/06/2021 17/06/2021 21/06/2021 22/06/2021 24/06/2021 28/06/2021 29/06/2021
"+07h44" "+07h44" "+07h44" "+07h44" "+07h44" "+07h44" "+07h44" "+07h44" "+07h44" "+07h44"
```
Pour valider la feuille de temps mensuelle du mois d'avril 2021&nbsp;
Pour saisir automatiquement ces temps dans la feuille de pointage :
``` r
fdt_valid(session, "01/04/2021")
fdt_add_events(session, fdt_get_lack_days(session))
```
Pour valider la feuille de temps mensuelle du mois de juin 2021&nbsp;:
``` r
fdt_valid(session, "01/06/2021")
```
# Roadmap
Pour rendre cette application plus fonctionnelle, il manque les fonctionnalités suivante:
Pour rendre cette application fonctionnelle pour le commun des mortels, il faut une interface graphique&nbsp;:
- Développement d'une interface Shiny pour les fonctionnalités développées
Saisie des congés :
- Automatiser l'annulation des jours de télétravail ou autre lorsque l'on veut poser des congés
Saisie des activités&nbsp;:
- Détection automatique des jours en défaut avant la date courante pour une présélection de dates à remplir automatiquement ([#2](https://gitlab.irstea.fr/david.dorchies/hatata/-/issues/2))
- Développement d'une interface Shiny pour les utilisateurs Lambda (Fonctionnalités à définir)
- Lire les temps d'activité à partir de l'agenda de l'agent ou d'un fichier Excel
- Affecter les temps en fonction de mots clés prédéfinis pour chaque affectation
- Saisir automatiquement ces informations dans l'interface
# Contribution
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/fdt_get_differentiel.R
\name{fdt_get_differentiel}
\alias{fdt_get_differentiel}
\title{Get column "Différentiel" content of a "pointage" page}
\usage{
fdt_get_differentiel(
session,
date = format(Sys.Date() - months(1), "\%Y-\%m-\%d")
)
}
\arguments{
\item{session}{a \link[rvest:session]{rvest::session} provided by \link{login} or \link{jump_to_mon_calendrier} functions}
\item{date}{a \link{character} representing the current date in format "\%Y-\%m-\%d"}
}
\value{
A named \link{vector} of \link{character} : the name is the date in "\%d/\%m/\%Y" format and the content is the difference between theoretical and actually worked hours in format "(-)00h00".
}
\description{
Get column "Différentiel" content of a "pointage" page
}
\examples{
\dontrun{
library(hatata)
session <- login("pnom", "password")
fdt_get_differentiel(session)
}
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/fdt_get_lack_days.R
\name{fdt_get_lack_days}
\alias{fdt_get_lack_days}
\title{Extract days where work hours in less than theoretical hours}
\usage{
fdt_get_lack_days(
session,
date = format(Sys.Date() - months(1), "\%Y-\%m-\%d")
)
}
\arguments{
\item{session}{a \link[rvest:session]{rvest::session} provided by \link{login} or \link{jump_to_mon_calendrier} functions}
\item{date}{a \link{character} representing the current date in format "\%Y-\%m-\%d"}
}
\value{
A named \link{vector} of \link{character} : the name is the date in "\%d/\%m/\%Y" format and the content is the necessary time to add for reaching theoretical time for the day in format "+00h00".
}
\description{
Extract days where work hours in less than theoretical hours
}
\examples{
\dontrun{
library(hatata)
session <- login("pnom", "password")
fdt_get_differentiel(session)
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment