src/Entity/Salary.php line 9

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SalaryRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. #[ORM\Entity(repositoryClassSalaryRepository::class)]
  6. class Salary
  7. {
  8.     #[ORM\Id]
  9.     #[ORM\GeneratedValue]
  10.     #[ORM\Column(type'integer')]
  11.     private $id;
  12.     #[ORM\ManyToOne(targetEntityUser::class, inversedBy'salaries')]
  13.     private $user;
  14.     #[ORM\ManyToOne(targetEntityOffice::class, inversedBy'salaries')]
  15.     private $office;
  16.     #[ORM\Column(type'float')]
  17.     private $amount;
  18.     #[ORM\Column(type'float')]
  19.     private $hourlyRate;
  20.     #[ORM\Column(type'date_immutable')]
  21.     private $validAt;
  22.     #[ORM\Column(type'date_immutable')]
  23.     private $createdAt;
  24.     #[ORM\ManyToOne(targetEntityUser::class)]
  25.     private $createdBy;
  26.     #[ORM\Column(type'datetime_immutable'nullabletrue)]
  27.     private $updatedAt;
  28.     #[ORM\ManyToOne(targetEntityUser::class)]
  29.     private $updatedBy;
  30.     #[ORM\Column(type'boolean'options: ['default' => false'nullable' => true])]
  31.     private ?bool $authentic false;
  32.     #[ORM\Column(length255nullabletrue)]
  33.     private ?string $fileUpload null;
  34.     public function getId(): ?int
  35.     {
  36.         return $this->id;
  37.     }
  38.     public function getUser(): ?User
  39.     {
  40.         return $this->user;
  41.     }
  42.     public function setUser(?User $user): self
  43.     {
  44.         $this->user $user;
  45.         return $this;
  46.     }
  47.     public function getOffice(): ?Office
  48.     {
  49.         return $this->office;
  50.     }
  51.     public function setOffice(?Office $office): self
  52.     {
  53.         $this->office $office;
  54.         return $this;
  55.     }
  56.     public function getAmount(): ?float
  57.     {
  58.         return $this->amount;
  59.     }
  60.     public function getAmountUsd(): ?float
  61.     {
  62.         global $kernel;
  63.         $currencyService $kernel->getContainer()->get('CurrencyService');
  64.         if($this->office){
  65.             return $currencyService->convertAtDate(date('Y-m-d'), $this->office->getCurrency(), 'USD'$this->amount);
  66.         } else {
  67.             return $currencyService->convertAtDate(date('Y-m-d'), $this->user->getOffice()->getCurrency(), 'USD'$this->amount);
  68.         }
  69.     }
  70.     public function setAmount(float $amount): self
  71.     {
  72.         $this->amount $amount;
  73.         return $this;
  74.     }
  75.     public function getHourlyRate(): ?float
  76.     {
  77.         return $this->hourlyRate;
  78.     }
  79.     public function getHourlyRateUsd(): ?float
  80.     {
  81.         global $kernel;
  82.         $currencyService $kernel->getContainer()->get('CurrencyService');
  83.         if($this->office){
  84.             return $currencyService->convertAtDate(date('Y-m-d'), $this->office->getCurrency(), 'USD'$this->hourlyRate);
  85.         } else {
  86.             return $currencyService->convertAtDate(date('Y-m-d'), $this->user->getOffice()->getCurrency(), 'USD'$this->hourlyRate);
  87.         }
  88.         
  89.     }
  90.     
  91.     public function setHourlyRate(float $hourlyRate): self
  92.     {
  93.         $this->hourlyRate $hourlyRate;
  94.         return $this;
  95.     }
  96.     public function getValidAt(): ?\DateTimeImmutable
  97.     {
  98.         return $this->validAt;
  99.     }
  100.     public function setValidAt(\DateTimeImmutable $validAt): self
  101.     {
  102.         $this->validAt $validAt;
  103.         return $this;
  104.     }
  105.     public function getCreatedAt(): ?\DateTimeImmutable
  106.     {
  107.         return $this->createdAt;
  108.     }
  109.     public function setCreatedAt(\DateTimeImmutable $createdAt): self
  110.     {
  111.         $this->createdAt $createdAt;
  112.         return $this;
  113.     }
  114.     public function getCreatedBy(): ?User
  115.     {
  116.         return $this->createdBy;
  117.     }
  118.     public function setCreatedBy(?User $createdBy): self
  119.     {
  120.         $this->createdBy $createdBy;
  121.         return $this;
  122.     }
  123.     public function getUpdatedAt(): ?\DateTimeImmutable
  124.     {
  125.         return $this->updatedAt;
  126.     }
  127.     public function setUpdatedAt(?\DateTimeImmutable $updatedAt): self
  128.     {
  129.         $this->updatedAt $updatedAt;
  130.         return $this;
  131.     }
  132.     public function getUpdatedBy(): ?User
  133.     {
  134.         return $this->updatedBy;
  135.     }
  136.     public function setUpdatedBy(?User $updatedBy): self
  137.     {
  138.         $this->updatedBy $updatedBy;
  139.         return $this;
  140.     }
  141.     public function isAuthentic(): ?bool
  142.     {
  143.         return $this->authentic;
  144.     }
  145.     public function setAuthentic(bool $authentic): self
  146.     {
  147.         $this->authentic $authentic;
  148.         return $this;
  149.     }
  150.     public function getFileUpload(): ?string
  151.     {
  152.         return $this->fileUpload;
  153.     }
  154.     public function setFileUpload(?string $fileUpload): self
  155.     {
  156.         $this->fileUpload $fileUpload;
  157.         return $this;
  158.     }
  159. }