File size: 4,579 Bytes
2145052
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import pandas as pd
import numpy as np
from utils.times import date_to_week_day

def generate_society_fit(form: dict):
    society_form = {
        "year": form["year"],
        "month": form["month"],
        "week": form["week"],
        "date": form["date"],
        "prestataire": form["prestataire"],
        "client": form["client"],
        "affaire": form["affaire"],
        "intervenant": form["intervenant"],
        "vehicule": form["vehicule"],
        "location": form["location"],
        "activities": form["activities"],
        "worked_hours": form["worked_hours"],
        "night_hours": form["night_hours"],
        "drive_hours": form["drive_hours"],
    }
    return society_form
    
def generate_intervenant_monthly_payroll(form: pd.DataFrame):
    historic_df = form
    column_sums = {}
    for column in historic_df.columns:
        if historic_df[column].dtype in [int, float] \
            and not np.isnan(historic_df[column]).all() \
            and column not in ['year', 'month', 'week', 'date', 'public_holyday']:
            column_sums[column] = historic_df[column].sum()
    
    payroll = {
        "Nom": historic_df["nom"].values[0],
        "Prénom": historic_df["prenom"].values[0],
        "Semaine": f'{historic_df["year"].values[0]}-s{historic_df["week"].values[0]}',
        "H Réal.": column_sums['worked_hours'],
        "H Récup.": 0.,
        "H Sup. Contrat": 0.,
        "H Nuit": column_sums['night_hours'],
        "H route": column_sums['drive_hours'],
        "H Neg Non Just": 0.,
        "H Neg Just": 0.,
        "Ast Sem": column_sums['on_call_bonus'],
        "Ast Sem/JF": 0.,
        "Prime Interv.": column_sums['intervention_bonus'],
        "Prime Chef Equipe": column_sums['team_leader_bonus'],
        "Prime Transp. Caisse": column_sums['personal_tools_bonus'],
        "Maladie": column_sums['maladie'],
        "Arret Travail": column_sums['arret_travail'],
        "Congés Payés": column_sums['conges_payes'],
        "Congés Sans Solde": column_sums['conges_sans_solde'],
        "RTT": column_sums['rtt'],
        "Formation": column_sums['formation'],
        "Evénement Familial": column_sums['evenement_familial'],
        "Panier": column_sums['meal_nonus'],
        "frais": 0.,
        "H Samedi": column_sums['saturday_hours'],
        # "H Dimanche / Férié": column_sums['sunday_hours'] + column_sums['holyday_hours'],
        "H Dimanche": column_sums['sunday_hours'],
        "H Férié": column_sums['holyday_hours'],

    }
    return payroll
    

def generate_intervenant_fit(form: dict):
    data = form
    fit_dict = {
        "CLIENT": data["client"],
        "Nom du responsable client": np.nan,
        "AFFAIRE": data["affaire"],
        "Lundi": data["worked_hours"] if date_to_week_day(data["date"]) == 'lundi' else 0,
        "Mardi": data["worked_hours"] if date_to_week_day(data["date"]) == 'mardi' else 0,
        "Mercredi": data["worked_hours"] if date_to_week_day(data["date"]) == 'mercredi' else 0,
        "Jeudi": data["worked_hours"] if date_to_week_day(data["date"]) == 'jeudi' else 0,
        "Vendredi": data["worked_hours"] if date_to_week_day(data["date"]) == 'vendredi' else 0,
        "Samedi": data["worked_hours"] if date_to_week_day(data["date"]) == 'samedi' else 0,
        "Dimanche": data["worked_hours"] if date_to_week_day(data["date"]) == 'dimanche' else 0,
        "Travaux réalisés": data["activities"],
        "H.\njour": data["worked_hours"] - data["night_hours"],
        "H.\nnuit (1)": data["night_hours"],
        "H.\nroute": data["drive_hours"],
        "Panier (EUR)": data["meal_nonus"],
        "Déplacement(EUR)": data["mileage_allowances_bonus"],
        "Suppléments (EUR)": data["personal_tools_bonus"] + data["intervention_bonus"] + data["on_call_bonus"] + data["team_leader_bonus"],
        "Véh. Perso (VP)\nou\nSociété (VS)": "VP" if data["vehicule"] == 'Perso' else "VS",
        "Localisation": data["location"],
    }
    return fit_dict

def generate_society_payroll(form: dict):
    data = form
    payroll = {
        "Prestataire": data["employeur"],
        "Fournisseur": data["prestataire"],
        "year": data["year"],
        "month": data["month"],
        "client": data["client"],
        "affaire": data["affaire"],
        "intervenant": data["intervenant"],
        "vehicule": data["vehicule"],
        "Semaine": f'{data["year"]}-s{data["week"]}',
        "H Réal.": data["worked_hours"],
        "H Nuit": data["night_hours"],
        "H route": data["drive_hours"],

    }
    return payroll