<?php
namespace App\Entity;
use App\Repository\SalaryRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: SalaryRepository::class)]
class Salary
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'salaries')]
private $user;
#[ORM\ManyToOne(targetEntity: Office::class, inversedBy: 'salaries')]
private $office;
#[ORM\Column(type: 'float')]
private $amount;
#[ORM\Column(type: 'float')]
private $hourlyRate;
#[ORM\Column(type: 'date_immutable')]
private $validAt;
#[ORM\Column(type: 'date_immutable')]
private $createdAt;
#[ORM\ManyToOne(targetEntity: User::class)]
private $createdBy;
#[ORM\Column(type: 'datetime_immutable', nullable: true)]
private $updatedAt;
#[ORM\ManyToOne(targetEntity: User::class)]
private $updatedBy;
#[ORM\Column(type: 'boolean', options: ['default' => false, 'nullable' => true])]
private ?bool $authentic = false;
#[ORM\Column(length: 255, nullable: true)]
private ?string $fileUpload = null;
public function getId(): ?int
{
return $this->id;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getOffice(): ?Office
{
return $this->office;
}
public function setOffice(?Office $office): self
{
$this->office = $office;
return $this;
}
public function getAmount(): ?float
{
return $this->amount;
}
public function getAmountUsd(): ?float
{
global $kernel;
$currencyService = $kernel->getContainer()->get('CurrencyService');
if($this->office){
return $currencyService->convertAtDate(date('Y-m-d'), $this->office->getCurrency(), 'USD', $this->amount);
} else {
return $currencyService->convertAtDate(date('Y-m-d'), $this->user->getOffice()->getCurrency(), 'USD', $this->amount);
}
}
public function setAmount(float $amount): self
{
$this->amount = $amount;
return $this;
}
public function getHourlyRate(): ?float
{
return $this->hourlyRate;
}
public function getHourlyRateUsd(): ?float
{
global $kernel;
$currencyService = $kernel->getContainer()->get('CurrencyService');
if($this->office){
return $currencyService->convertAtDate(date('Y-m-d'), $this->office->getCurrency(), 'USD', $this->hourlyRate);
} else {
return $currencyService->convertAtDate(date('Y-m-d'), $this->user->getOffice()->getCurrency(), 'USD', $this->hourlyRate);
}
}
public function setHourlyRate(float $hourlyRate): self
{
$this->hourlyRate = $hourlyRate;
return $this;
}
public function getValidAt(): ?\DateTimeImmutable
{
return $this->validAt;
}
public function setValidAt(\DateTimeImmutable $validAt): self
{
$this->validAt = $validAt;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getCreatedBy(): ?User
{
return $this->createdBy;
}
public function setCreatedBy(?User $createdBy): self
{
$this->createdBy = $createdBy;
return $this;
}
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeImmutable $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getUpdatedBy(): ?User
{
return $this->updatedBy;
}
public function setUpdatedBy(?User $updatedBy): self
{
$this->updatedBy = $updatedBy;
return $this;
}
public function isAuthentic(): ?bool
{
return $this->authentic;
}
public function setAuthentic(bool $authentic): self
{
$this->authentic = $authentic;
return $this;
}
public function getFileUpload(): ?string
{
return $this->fileUpload;
}
public function setFileUpload(?string $fileUpload): self
{
$this->fileUpload = $fileUpload;
return $this;
}
}