183 lines
4.7 KiB
PHP
183 lines
4.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Entity;
|
|
|
|
use App\Repository\EmployeeRttBalanceRepository;
|
|
use DateTimeImmutable;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
#[ORM\Entity(repositoryClass: EmployeeRttBalanceRepository::class)]
|
|
#[ORM\Table(name: 'employee_rtt_balances', options: ['comment' => 'Soldes RTT par employe et exercice (report N-1).'])]
|
|
#[ORM\UniqueConstraint(name: 'uniq_employee_rtt_balance', columns: ['employee_id', 'year'])]
|
|
#[ORM\Index(columns: ['employee_id', 'year'], name: 'idx_rtt_balance_employee_year')]
|
|
class EmployeeRttBalance
|
|
{
|
|
#[ORM\Id]
|
|
#[ORM\GeneratedValue]
|
|
#[ORM\Column(type: 'integer')]
|
|
private ?int $id = null;
|
|
|
|
#[ORM\ManyToOne(targetEntity: Employee::class)]
|
|
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
|
|
private ?Employee $employee = null;
|
|
|
|
#[ORM\Column(type: 'integer', options: ['comment' => 'Annee d exercice (year = annee de fin, ex: 2026 = 01/06/2025 -> 31/05/2026).'])]
|
|
private int $year = 0;
|
|
|
|
#[ORM\Column(type: 'integer', options: ['comment' => 'Mois de fin du report (1-12). Le report s affiche dans le mois suivant.', 'default' => 5])]
|
|
private int $month = 5;
|
|
|
|
#[ORM\Column(type: 'integer', options: ['comment' => 'Report N-1 base 25% en minutes.', 'default' => 0])]
|
|
private int $openingBase25Minutes = 0;
|
|
|
|
#[ORM\Column(type: 'integer', options: ['comment' => 'Report N-1 bonus 25% en minutes.', 'default' => 0])]
|
|
private int $openingBonus25Minutes = 0;
|
|
|
|
#[ORM\Column(type: 'integer', options: ['comment' => 'Report N-1 base 50% en minutes.', 'default' => 0])]
|
|
private int $openingBase50Minutes = 0;
|
|
|
|
#[ORM\Column(type: 'integer', options: ['comment' => 'Report N-1 bonus 50% en minutes.', 'default' => 0])]
|
|
private int $openingBonus50Minutes = 0;
|
|
|
|
#[ORM\Column(type: 'boolean', options: ['default' => false, 'comment' => 'Indique si le solde est fige (verrouille RH).'])]
|
|
private bool $isLocked = false;
|
|
|
|
#[ORM\Column(type: 'datetime_immutable')]
|
|
private DateTimeImmutable $createdAt;
|
|
|
|
#[ORM\Column(type: 'datetime_immutable')]
|
|
private DateTimeImmutable $updatedAt;
|
|
|
|
public function __construct()
|
|
{
|
|
$now = new DateTimeImmutable();
|
|
$this->createdAt = $now;
|
|
$this->updatedAt = $now;
|
|
}
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getEmployee(): ?Employee
|
|
{
|
|
return $this->employee;
|
|
}
|
|
|
|
public function setEmployee(Employee $employee): self
|
|
{
|
|
$this->employee = $employee;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getYear(): int
|
|
{
|
|
return $this->year;
|
|
}
|
|
|
|
public function setYear(int $year): self
|
|
{
|
|
$this->year = $year;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getMonth(): int
|
|
{
|
|
return $this->month;
|
|
}
|
|
|
|
public function setMonth(int $month): self
|
|
{
|
|
$this->month = $month;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getOpeningBase25Minutes(): int
|
|
{
|
|
return $this->openingBase25Minutes;
|
|
}
|
|
|
|
public function setOpeningBase25Minutes(int $openingBase25Minutes): self
|
|
{
|
|
$this->openingBase25Minutes = $openingBase25Minutes;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getOpeningBonus25Minutes(): int
|
|
{
|
|
return $this->openingBonus25Minutes;
|
|
}
|
|
|
|
public function setOpeningBonus25Minutes(int $openingBonus25Minutes): self
|
|
{
|
|
$this->openingBonus25Minutes = $openingBonus25Minutes;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getOpeningBase50Minutes(): int
|
|
{
|
|
return $this->openingBase50Minutes;
|
|
}
|
|
|
|
public function setOpeningBase50Minutes(int $openingBase50Minutes): self
|
|
{
|
|
$this->openingBase50Minutes = $openingBase50Minutes;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getOpeningBonus50Minutes(): int
|
|
{
|
|
return $this->openingBonus50Minutes;
|
|
}
|
|
|
|
public function setOpeningBonus50Minutes(int $openingBonus50Minutes): self
|
|
{
|
|
$this->openingBonus50Minutes = $openingBonus50Minutes;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getTotalOpeningMinutes(): int
|
|
{
|
|
return $this->openingBase25Minutes + $this->openingBonus25Minutes + $this->openingBase50Minutes + $this->openingBonus50Minutes;
|
|
}
|
|
|
|
public function isLocked(): bool
|
|
{
|
|
return $this->isLocked;
|
|
}
|
|
|
|
public function setIsLocked(bool $isLocked): self
|
|
{
|
|
$this->isLocked = $isLocked;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getCreatedAt(): DateTimeImmutable
|
|
{
|
|
return $this->createdAt;
|
|
}
|
|
|
|
public function getUpdatedAt(): DateTimeImmutable
|
|
{
|
|
return $this->updatedAt;
|
|
}
|
|
|
|
public function touch(): self
|
|
{
|
|
$this->updatedAt = new DateTimeImmutable();
|
|
|
|
return $this;
|
|
}
|
|
}
|