| 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": 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 |
|
|