src/Entity/Paie.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PaieRepository;
  4. use Doctrine\DBAL\Types\Types;
  5. use Doctrine\ORM\Mapping as ORM;
  6. #[ORM\Entity(repositoryClassPaieRepository::class)]
  7. class Paie
  8. {
  9.     #[ORM\Id]
  10.     #[ORM\GeneratedValue]
  11.     #[ORM\Column]
  12.     private ?int $id null;
  13.     #[ORM\ManyToOne(inversedBy'paies')]
  14.     #[ORM\JoinColumn(nullablefalse)]
  15.     private ?Employe $employe null;
  16.     #[ORM\Column(typeTypes::INTEGER)]
  17.     private ?int $mois null;
  18.     #[ORM\Column(typeTypes::INTEGER)]
  19.     private ?int $annee null;
  20.     #[ORM\Column(typeTypes::DECIMALprecision10scale2)]
  21.     private ?string $salaireBase null;
  22.     #[ORM\Column(typeTypes::DECIMALprecision10scale2nullabletrue)]
  23.     private ?string $primes null;
  24.     #[ORM\Column(typeTypes::DECIMALprecision10scale2nullabletrue)]
  25.     private ?string $heuresSupplementaires null;
  26.     #[ORM\Column(typeTypes::DECIMALprecision10scale2nullabletrue)]
  27.     private ?string $avantages null;
  28.     #[ORM\Column(typeTypes::DECIMALprecision10scale2)]
  29.     private ?string $salaireBrut null;
  30.     #[ORM\Column(typeTypes::DECIMALprecision10scale2nullabletrue)]
  31.     private ?string $cotisationsSociales null;
  32.     #[ORM\Column(typeTypes::DECIMALprecision10scale2nullabletrue)]
  33.     private ?string $impots null;
  34.     #[ORM\Column(typeTypes::DECIMALprecision10scale2nullabletrue)]
  35.     private ?string $autresDeductions null;
  36.     #[ORM\Column(typeTypes::DECIMALprecision10scale2)]
  37.     private ?string $totalDeductions null;
  38.     #[ORM\Column(typeTypes::DECIMALprecision10scale2)]
  39.     private ?string $salaireNet null;
  40.     #[ORM\Column(typeTypes::DECIMALprecision5scale2nullabletrue)]
  41.     private ?string $joursPresence null;
  42.     #[ORM\Column(typeTypes::DECIMALprecision5scale2nullabletrue)]
  43.     private ?string $joursAbsence null;
  44.     #[ORM\Column(typeTypes::DECIMALprecision5scale2nullabletrue)]
  45.     private ?string $joursConges null;
  46.     #[ORM\Column(length50)]
  47.     private ?string $statut 'brouillon'// brouillon, validé, payé
  48.     #[ORM\Column(typeTypes::DATE_MUTABLEnullabletrue)]
  49.     private ?\DateTimeInterface $datePaiement null;
  50.     #[ORM\Column(length50nullabletrue)]
  51.     private ?string $modePaiement null// virement, especes, cheque
  52.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  53.     private ?string $notes null;
  54.     #[ORM\Column]
  55.     private ?\DateTimeImmutable $createdAt null;
  56.     #[ORM\ManyToOne(targetEntityUser::class)]
  57.     private ?User $createdBy null;
  58.     #[ORM\Column(nullabletrue)]
  59.     private ?\DateTimeImmutable $validatedAt null;
  60.     #[ORM\ManyToOne(targetEntityUser::class)]
  61.     private ?User $validatedBy null;
  62.     public function __construct()
  63.     {
  64.         $this->createdAt = new \DateTimeImmutable();
  65.     }
  66.     public function getId(): ?int
  67.     {
  68.         return $this->id;
  69.     }
  70.     public function getEmploye(): ?Employe
  71.     {
  72.         return $this->employe;
  73.     }
  74.     public function setEmploye(?Employe $employe): static
  75.     {
  76.         $this->employe $employe;
  77.         return $this;
  78.     }
  79.     public function getMois(): ?int
  80.     {
  81.         return $this->mois;
  82.     }
  83.     public function setMois(int $mois): static
  84.     {
  85.         $this->mois $mois;
  86.         return $this;
  87.     }
  88.     public function getAnnee(): ?int
  89.     {
  90.         return $this->annee;
  91.     }
  92.     public function setAnnee(int $annee): static
  93.     {
  94.         $this->annee $annee;
  95.         return $this;
  96.     }
  97.     public function getSalaireBase(): ?string
  98.     {
  99.         return $this->salaireBase;
  100.     }
  101.     public function setSalaireBase(string $salaireBase): static
  102.     {
  103.         $this->salaireBase $salaireBase;
  104.         return $this;
  105.     }
  106.     public function getPrimes(): ?string
  107.     {
  108.         return $this->primes;
  109.     }
  110.     public function setPrimes(?string $primes): static
  111.     {
  112.         $this->primes $primes;
  113.         return $this;
  114.     }
  115.     public function getHeuresSupplementaires(): ?string
  116.     {
  117.         return $this->heuresSupplementaires;
  118.     }
  119.     public function setHeuresSupplementaires(?string $heuresSupplementaires): static
  120.     {
  121.         $this->heuresSupplementaires $heuresSupplementaires;
  122.         return $this;
  123.     }
  124.     public function getAvantages(): ?string
  125.     {
  126.         return $this->avantages;
  127.     }
  128.     public function setAvantages(?string $avantages): static
  129.     {
  130.         $this->avantages $avantages;
  131.         return $this;
  132.     }
  133.     public function getSalaireBrut(): ?string
  134.     {
  135.         return $this->salaireBrut;
  136.     }
  137.     public function setSalaireBrut(string $salaireBrut): static
  138.     {
  139.         $this->salaireBrut $salaireBrut;
  140.         return $this;
  141.     }
  142.     public function getCotisationsSociales(): ?string
  143.     {
  144.         return $this->cotisationsSociales;
  145.     }
  146.     public function setCotisationsSociales(?string $cotisationsSociales): static
  147.     {
  148.         $this->cotisationsSociales $cotisationsSociales;
  149.         return $this;
  150.     }
  151.     public function getImpots(): ?string
  152.     {
  153.         return $this->impots;
  154.     }
  155.     public function setImpots(?string $impots): static
  156.     {
  157.         $this->impots $impots;
  158.         return $this;
  159.     }
  160.     public function getAutresDeductions(): ?string
  161.     {
  162.         return $this->autresDeductions;
  163.     }
  164.     public function setAutresDeductions(?string $autresDeductions): static
  165.     {
  166.         $this->autresDeductions $autresDeductions;
  167.         return $this;
  168.     }
  169.     public function getTotalDeductions(): ?string
  170.     {
  171.         return $this->totalDeductions;
  172.     }
  173.     public function setTotalDeductions(string $totalDeductions): static
  174.     {
  175.         $this->totalDeductions $totalDeductions;
  176.         return $this;
  177.     }
  178.     public function getSalaireNet(): ?string
  179.     {
  180.         return $this->salaireNet;
  181.     }
  182.     public function setSalaireNet(string $salaireNet): static
  183.     {
  184.         $this->salaireNet $salaireNet;
  185.         return $this;
  186.     }
  187.     public function getJoursPresence(): ?string
  188.     {
  189.         return $this->joursPresence;
  190.     }
  191.     public function setJoursPresence(?string $joursPresence): static
  192.     {
  193.         $this->joursPresence $joursPresence;
  194.         return $this;
  195.     }
  196.     public function getJoursAbsence(): ?string
  197.     {
  198.         return $this->joursAbsence;
  199.     }
  200.     public function setJoursAbsence(?string $joursAbsence): static
  201.     {
  202.         $this->joursAbsence $joursAbsence;
  203.         return $this;
  204.     }
  205.     public function getJoursConges(): ?string
  206.     {
  207.         return $this->joursConges;
  208.     }
  209.     public function setJoursConges(?string $joursConges): static
  210.     {
  211.         $this->joursConges $joursConges;
  212.         return $this;
  213.     }
  214.     public function getStatut(): ?string
  215.     {
  216.         return $this->statut;
  217.     }
  218.     public function setStatut(string $statut): static
  219.     {
  220.         $this->statut $statut;
  221.         return $this;
  222.     }
  223.     public function getDatePaiement(): ?\DateTimeInterface
  224.     {
  225.         return $this->datePaiement;
  226.     }
  227.     public function setDatePaiement(?\DateTimeInterface $datePaiement): static
  228.     {
  229.         $this->datePaiement $datePaiement;
  230.         return $this;
  231.     }
  232.     public function getModePaiement(): ?string
  233.     {
  234.         return $this->modePaiement;
  235.     }
  236.     public function setModePaiement(?string $modePaiement): static
  237.     {
  238.         $this->modePaiement $modePaiement;
  239.         return $this;
  240.     }
  241.     public function getNotes(): ?string
  242.     {
  243.         return $this->notes;
  244.     }
  245.     public function setNotes(?string $notes): static
  246.     {
  247.         $this->notes $notes;
  248.         return $this;
  249.     }
  250.     public function getCreatedAt(): ?\DateTimeImmutable
  251.     {
  252.         return $this->createdAt;
  253.     }
  254.     public function setCreatedAt(\DateTimeImmutable $createdAt): static
  255.     {
  256.         $this->createdAt $createdAt;
  257.         return $this;
  258.     }
  259.     public function getCreatedBy(): ?User
  260.     {
  261.         return $this->createdBy;
  262.     }
  263.     public function setCreatedBy(?User $createdBy): static
  264.     {
  265.         $this->createdBy $createdBy;
  266.         return $this;
  267.     }
  268.     public function getValidatedAt(): ?\DateTimeImmutable
  269.     {
  270.         return $this->validatedAt;
  271.     }
  272.     public function setValidatedAt(?\DateTimeImmutable $validatedAt): static
  273.     {
  274.         $this->validatedAt $validatedAt;
  275.         return $this;
  276.     }
  277.     public function getValidatedBy(): ?User
  278.     {
  279.         return $this->validatedBy;
  280.     }
  281.     public function setValidatedBy(?User $validatedBy): static
  282.     {
  283.         $this->validatedBy $validatedBy;
  284.         return $this;
  285.     }
  286.     public function calculerSalaireBrut(): void
  287.     {
  288.         $base floatval($this->salaireBase ?? 0);
  289.         $primes floatval($this->primes ?? 0);
  290.         $heuresSup floatval($this->heuresSupplementaires ?? 0);
  291.         $avantages floatval($this->avantages ?? 0);
  292.         $this->salaireBrut number_format($base $primes $heuresSup $avantages2'.''');
  293.     }
  294.     public function calculerTotalDeductions(): void
  295.     {
  296.         $cotisations floatval($this->cotisationsSociales ?? 0);
  297.         $impots floatval($this->impots ?? 0);
  298.         $autres floatval($this->autresDeductions ?? 0);
  299.         $this->totalDeductions number_format($cotisations $impots $autres2'.''');
  300.     }
  301.     public function calculerSalaireNet(): void
  302.     {
  303.         $this->calculerSalaireBrut();
  304.         $this->calculerTotalDeductions();
  305.         $brut floatval($this->salaireBrut ?? 0);
  306.         $deductions floatval($this->totalDeductions ?? 0);
  307.         $this->salaireNet number_format($brut $deductions2'.''');
  308.     }
  309.     public function getPeriode(): string
  310.     {
  311.         if ($this->mois && $this->annee) {
  312.             $moisNom = ['''Janvier''Février''Mars''Avril''Mai''Juin'
  313.                         'Juillet''Août''Septembre''Octobre''Novembre''Décembre'];
  314.             return $moisNom[$this->mois] . ' ' $this->annee;
  315.         }
  316.         return '';
  317.     }
  318.     public function __toString(): string
  319.     {
  320.         return $this->getPeriode() . ' - ' . ($this->employe $this->employe->getNomComplet() : '');
  321.     }
  322. }