src/Entity/WorkerActivityLeaveEntitlement.php line 30

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\WorkerActivityLeaveEntitlementRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Serializer\Annotation\Groups;
  6. /**
  7.  * WorkerActivityLeaveEntitlement — bir SÖZLEŞMENİN (worker_activity) bir YIL için izin hakkı.
  8.  *
  9.  * Kullanıcı kararı 2026-09-19: izin hakkı sözleşme bazlıdır ("her activity'de farklı olabilir"),
  10.  * yıl bazında tutulur; önceki yıldan DEVİR (carry-over) ve devrin SON KULLANMA tarihi burada.
  11.  *
  12.  * ⚠️ İZİN GÜNLERİ BURADA DEĞİL. Hangi günlerin izin olduğu Timesheet'in gün-JSON'unda (`H`)
  13.  *    yaşar — tek doğruluk kaynağı (module-timesheetv2 kararı, 2026-09-17). Bu tablo yalnız
  14.  *    HAK + DEVİR girdisidir; bakiye = hak + kullanılabilir devir − Timesheet'teki H günleri
  15.  *    (LeaveEntitlementService::balances). Timesheet'e ASLA yazmaz.
  16.  *
  17.  * Satır yoksa hak = sözleşmenin bilinen son hakkı, o da yoksa
  18.  * TimesheetLeaveService::ANNUAL_LEAVE_ENTITLEMENT_DAYS (30, K1 fallback).
  19.  *
  20.  * @ORM\Entity(repositoryClass=WorkerActivityLeaveEntitlementRepository::class)
  21.  * @ORM\Table(
  22.  *     name="worker_activity_leave_entitlements",
  23.  *     uniqueConstraints={@ORM\UniqueConstraint(name="uniq_activity_leave_year", columns={"worker_activity_id", "year"})},
  24.  *     options={"comment": "Sozlesme + yil bazinda izin hakki ve onceki yildan devir. Gunler Timesheet'te (H)."}
  25.  * )
  26.  */
  27. class WorkerActivityLeaveEntitlement
  28. {
  29.     /**
  30.      * @ORM\Id
  31.      * @ORM\GeneratedValue
  32.      * @ORM\Column(type="integer")
  33.      * @Groups({
  34.      *     "worker_activity_leave_entitlement@ref",
  35.      *     "worker_activity_leave_entitlement@base",
  36.      *     "worker_activity_leave_entitlement@core"
  37.      * })
  38.      */
  39.     private $id;
  40.     /**
  41.      * @ORM\ManyToOne(targetEntity=WorkerActivities::class, inversedBy="leave_entitlements")
  42.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  43.      * @Groups({"worker_activity_leave_entitlement@worker_activity"})
  44.      */
  45.     private $worker_activity;
  46.     /**
  47.      * Hakkın geçerli olduğu takvim yılı.
  48.      *
  49.      * @ORM\Column(type="smallint")
  50.      * @Groups({
  51.      *     "worker_activity_leave_entitlement@base",
  52.      *     "worker_activity_leave_entitlement@core"
  53.      * })
  54.      */
  55.     private $year;
  56.     /**
  57.      * O yıl için yıllık izin hakkı (gün). Ondalık: yarım gün hakları tanımlanabilir olsun diye
  58.      * (tüketim bugün tam gün — Timesheet gün bazlı).
  59.      *
  60.      * @ORM\Column(type="decimal", precision=4, scale=1)
  61.      * @Groups({"worker_activity_leave_entitlement@core"})
  62.      */
  63.     private $entitlement_days = '0.0';
  64.     /**
  65.      * Önceki yıldan devreden gün. Elle girilir (kaydedilmiş anlık görüntü — geçmiş yılın
  66.      * Timesheet'i sonradan düzenlenebildiği için canlı hesap sessizce oynardı).
  67.      *
  68.      * @ORM\Column(type="decimal", precision=4, scale=1)
  69.      * @Groups({"worker_activity_leave_entitlement@core"})
  70.      */
  71.     private $carry_over_days = '0.0';
  72.     /**
  73.      * Devrin son kullanma tarihi (BUrlG §7/3 varsayılanı 31 Mart). NULL = yıl sonu.
  74.      * Bu tarihten sonraki H günleri devirden düşmez; kalan devir "verfallen" sayılır.
  75.      *
  76.      * @ORM\Column(type="date_immutable", nullable=true)
  77.      * @Groups({"worker_activity_leave_entitlement@core"})
  78.      */
  79.     private $carry_over_expires_at;
  80.     /**
  81.      * @ORM\Column(type="string", length=255, nullable=true)
  82.      * @Groups({"worker_activity_leave_entitlement@core"})
  83.      */
  84.     private $note;
  85.     /**
  86.      * @ORM\Column(type="datetime_immutable")
  87.      * @Groups({"worker_activity_leave_entitlement@core"})
  88.      */
  89.     private $created_at;
  90.     /**
  91.      * @ORM\Column(type="datetime_immutable", nullable=true)
  92.      * @Groups({"worker_activity_leave_entitlement@core"})
  93.      */
  94.     private $updated_at;
  95.     public function __construct()
  96.     {
  97.         $this->created_at = new \DateTimeImmutable('now');
  98.     }
  99.     public function getId(): ?int
  100.     {
  101.         return $this->id;
  102.     }
  103.     public function getWorkerActivity(): ?WorkerActivities
  104.     {
  105.         return $this->worker_activity;
  106.     }
  107.     public function setWorkerActivity(?WorkerActivities $worker_activity): self
  108.     {
  109.         $this->worker_activity = $worker_activity;
  110.         return $this;
  111.     }
  112.     public function getYear(): ?int
  113.     {
  114.         return $this->year;
  115.     }
  116.     public function setYear(int $year): self
  117.     {
  118.         $this->year = $year;
  119.         return $this;
  120.     }
  121.     public function getEntitlementDays(): ?string
  122.     {
  123.         return $this->entitlement_days;
  124.     }
  125.     public function setEntitlementDays($entitlement_days): self
  126.     {
  127.         $this->entitlement_days = (string) $entitlement_days;
  128.         return $this;
  129.     }
  130.     public function getCarryOverDays(): ?string
  131.     {
  132.         return $this->carry_over_days;
  133.     }
  134.     public function setCarryOverDays($carry_over_days): self
  135.     {
  136.         $this->carry_over_days = (string) ($carry_over_days === null || $carry_over_days === '' ? '0.0' : $carry_over_days);
  137.         return $this;
  138.     }
  139.     public function getCarryOverExpiresAt(): ?\DateTimeImmutable
  140.     {
  141.         return $this->carry_over_expires_at;
  142.     }
  143.     public function setCarryOverExpiresAt(?\DateTimeImmutable $carry_over_expires_at): self
  144.     {
  145.         $this->carry_over_expires_at = $carry_over_expires_at;
  146.         return $this;
  147.     }
  148.     public function getNote(): ?string
  149.     {
  150.         return $this->note;
  151.     }
  152.     public function setNote(?string $note): self
  153.     {
  154.         $this->note = $note;
  155.         return $this;
  156.     }
  157.     public function getCreatedAt(): ?\DateTimeImmutable
  158.     {
  159.         return $this->created_at;
  160.     }
  161.     public function setCreatedAt(\DateTimeImmutable $created_at): self
  162.     {
  163.         $this->created_at = $created_at;
  164.         return $this;
  165.     }
  166.     public function getUpdatedAt(): ?\DateTimeImmutable
  167.     {
  168.         return $this->updated_at;
  169.     }
  170.     public function setUpdatedAt(?\DateTimeImmutable $updated_at): self
  171.     {
  172.         $this->updated_at = $updated_at;
  173.         return $this;
  174.     }
  175. }