215 lines
5.1 KiB
C
215 lines
5.1 KiB
C
#include <stdio.h>
|
|
#include <assert.h>
|
|
|
|
#define RED "\033[31m"
|
|
#define BOLD "\033[1m"
|
|
#define NOCOLOR "\033[0m"
|
|
|
|
#define NET2BRUT 1.282194f
|
|
|
|
typedef enum Role {
|
|
DEV,
|
|
DESIGNER,
|
|
GRAPHISTE,
|
|
PROJECT_MANAGER,
|
|
ROLE_COUNT,
|
|
} Role;
|
|
|
|
const char* role_name[] = {
|
|
[DEV] = "Developpeur",
|
|
[DESIGNER] = "Designer",
|
|
[GRAPHISTE] = "Graphiste",
|
|
[PROJECT_MANAGER] = "Project Manager",
|
|
};
|
|
|
|
static_assert(
|
|
sizeof(role_name)/sizeof(*role_name) == ROLE_COUNT,
|
|
"mettre a jour la liste des noms des roles ou enum Role"
|
|
);
|
|
|
|
float role_salaire[] = {
|
|
[DEV] = 17.857142f,
|
|
[DESIGNER] = 14.878571f,
|
|
[GRAPHISTE] = 14.285714f,
|
|
[PROJECT_MANAGER] = 16.666666f,
|
|
};
|
|
|
|
static_assert(
|
|
sizeof(role_salaire)/sizeof(*role_salaire) == ROLE_COUNT,
|
|
"mettre a jour la liste des salaires des roles ou enum Role"
|
|
);
|
|
|
|
|
|
typedef enum Niveau {
|
|
JUNIOR,
|
|
SENIOR,
|
|
EXPERT,
|
|
NIVEAU_COUNT,
|
|
} Niveau;
|
|
|
|
const char* niveau_name[] = {
|
|
[JUNIOR] = "Junior",
|
|
[SENIOR] = "Senior",
|
|
[EXPERT] = "Expert",
|
|
};
|
|
|
|
static_assert(
|
|
sizeof(niveau_name)/sizeof(*niveau_name) == NIVEAU_COUNT,
|
|
"mettre a jour la liste des noms des niveaux ou enum Niveau"
|
|
);
|
|
|
|
float niveau_salaire[] = {
|
|
[JUNIOR] = 1.0f,
|
|
// [JUNIOR] = 0.61f,
|
|
[SENIOR] = 1.5f,
|
|
[EXPERT] = 2.0f,
|
|
};
|
|
|
|
static_assert(
|
|
sizeof(niveau_salaire)/sizeof(*niveau_salaire) == NIVEAU_COUNT,
|
|
"mettre a jour la liste des salaires des niveaux ou enum Niveau"
|
|
);
|
|
|
|
|
|
typedef enum Personne {
|
|
HAMZA,
|
|
DORIAN,
|
|
EBRAL,
|
|
LIAM,
|
|
PERSONNE_COUNT,
|
|
} Personne;
|
|
|
|
const char* personne_name[] = {
|
|
[HAMZA] = "Hamza",
|
|
[DORIAN] = "Dorian",
|
|
[EBRAL] = "Ebral",
|
|
[LIAM] = "Liam",
|
|
};
|
|
|
|
static_assert(
|
|
sizeof(personne_name)/sizeof(*personne_name) == PERSONNE_COUNT,
|
|
"mettre a jour la liste des noms ou enum Personne"
|
|
);
|
|
|
|
|
|
typedef struct Employee {
|
|
int anciennete;
|
|
int nb_heure;
|
|
int nb_role;
|
|
Role role[ROLE_COUNT];
|
|
float pourcentage[ROLE_COUNT];
|
|
Niveau niveau[ROLE_COUNT];
|
|
} Employee;
|
|
|
|
Employee employees[] = {
|
|
#include "fiche.c"
|
|
};
|
|
|
|
const int nb_employee = sizeof(employees)/sizeof(*employees);
|
|
|
|
static_assert(
|
|
sizeof(employees)/sizeof(*employees) == PERSONNE_COUNT,
|
|
"mettre a jour la liste des employees ou enum Personne"
|
|
);
|
|
|
|
// budget net
|
|
// float budget = 1426.3f / NET2BRUT;
|
|
float budget = 7207.2f / NET2BRUT;
|
|
|
|
void print_employees()
|
|
{
|
|
float salaire_normal[nb_employee];
|
|
|
|
for (int i = 0; i < nb_employee; i++) {
|
|
printf(
|
|
BOLD"%s"NOCOLOR" (%ih, %ians): \n",
|
|
personne_name[i], employees[i].nb_heure, employees[i].anciennete
|
|
);
|
|
float total_pourcentage = 0.0f;
|
|
for (int y = 0; y < employees[i].nb_role; y++) {
|
|
total_pourcentage += employees[i].pourcentage[y];
|
|
float salaire_role =
|
|
role_salaire[employees[i].role[y]]
|
|
* employees[i].pourcentage[y]/100
|
|
* employees[i].nb_heure
|
|
* niveau_salaire[employees[i].niveau[y]]
|
|
* (100+employees[i].anciennete)/100;
|
|
salaire_normal[i] += salaire_role;
|
|
printf(
|
|
" - (%.01f%%) %s %s = "
|
|
BOLD"%.02f€"NOCOLOR" net, "
|
|
BOLD"%.02f€"NOCOLOR" brut\n",
|
|
|
|
employees[i].pourcentage[y],
|
|
role_name[employees[i].role[y]],
|
|
niveau_name[employees[i].niveau[y]],
|
|
salaire_role,
|
|
salaire_role * NET2BRUT
|
|
);
|
|
}
|
|
if (total_pourcentage != 100) {
|
|
printf(
|
|
BOLD RED"[ERROR]"NOCOLOR
|
|
" pourcentage total different de 100%% (%.03f%%)\n",
|
|
total_pourcentage
|
|
);
|
|
} else {
|
|
printf(
|
|
" - [TOTAL] = "
|
|
BOLD"%.02f€"NOCOLOR" net, "
|
|
BOLD"%.02f€"NOCOLOR" brut\n",
|
|
|
|
salaire_normal[i],
|
|
salaire_normal[i] * NET2BRUT
|
|
);
|
|
}
|
|
printf("\n");
|
|
}
|
|
|
|
float salaire_normal_total = 0.0f;
|
|
for (int i = 0; i < nb_employee; i++) {
|
|
salaire_normal_total += salaire_normal[i];
|
|
}
|
|
printf(
|
|
"[TOTAL] budget salaire employees = "
|
|
BOLD"%.02f€"NOCOLOR" net, "
|
|
BOLD"%.02f€"NOCOLOR" brut\n\n",
|
|
|
|
salaire_normal_total,
|
|
salaire_normal_total * NET2BRUT
|
|
);
|
|
|
|
float salaire_budget_total = 0.0f;
|
|
float salaire_budget[nb_employee];
|
|
for (int i = 0; i < nb_employee; i++) {
|
|
salaire_budget[i] = salaire_normal[i] * budget / salaire_normal_total;
|
|
salaire_budget_total += salaire_budget[i];
|
|
printf(
|
|
"%s: "
|
|
"net: ("BOLD"%.02f€ -> %.02f€"NOCOLOR") "
|
|
"brut: ("BOLD"%.02f€ -> %.02f€"NOCOLOR")\n",
|
|
|
|
personne_name[i],
|
|
salaire_normal[i],
|
|
salaire_budget[i],
|
|
salaire_normal[i] * NET2BRUT,
|
|
salaire_budget[i] * NET2BRUT
|
|
);
|
|
|
|
}
|
|
|
|
printf(
|
|
"\n[TOTAL] salaire employees %% budget = "
|
|
BOLD"%.02f€"NOCOLOR" net, "
|
|
BOLD"%.02f€"NOCOLOR" brut\n",
|
|
|
|
salaire_budget_total,
|
|
salaire_budget_total * NET2BRUT
|
|
);
|
|
}
|
|
|
|
int main()
|
|
{
|
|
print_employees();
|
|
}
|