<?php
declare(strict_types=1);
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Annotation\ApiProperty;
use App\Trait\TimestampableEntity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Serializer\Annotation\MaxDepth;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;
#[ORM\Entity]
#[ApiResource(
iri: 'Hire',
collectionOperations: [],
itemOperations: [
'get' => [
'security' => "is_granted('ROLE_USER')",
"method" => "GET",
"path" => "/contracts/hires/{id}",
"openapi_context" => [
"tags" => ["Contract / Hire"]
]
]
],
attributes: ["pagination_enabled" => false]
)]
class Hire
{
use TimestampableEntity;
// public const INVOICE_STATUS_AWAITING_INVOICE = 'AWAITING_INVOICE';
// public const INVOICE_STATUS_AWAITING_PAYMENT = 'AWAITING_PAYMENT';
// public const INVOICE_STATUS_PAID = 'PAID';
// public const INVOICE_STATUS_CANCELED = 'CANCELED';
// public const INVOICE_STATUSES = [
// self::INVOICE_STATUS_AWAITING_INVOICE,
// self::INVOICE_STATUS_AWAITING_PAYMENT,
// self::INVOICE_STATUS_PAID,
// self::INVOICE_STATUS_CANCELED,
// ];
public const INVOICE_STATUS_INVOICED = 'INVOICED';
public const INVOICE_STATUS_NOT_INVOICED = 'NOT_INVOICED';
public const INVOICE_STATUS_PAID = 'PAID';
public const INVOICE_STATUS_CANCELED = 'CANCELED';
public const INVOICE_STATUSES = [
self::INVOICE_STATUS_INVOICED,
self::INVOICE_STATUS_NOT_INVOICED,
self::INVOICE_STATUS_PAID,
self::INVOICE_STATUS_CANCELED,
];
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'NONE')]
#[ORM\Column(type: 'uuid', unique: true)]
private ?UuidInterface $id = null;
#[ORM\Column(type: 'datetime', nullable: true)]
#[ApiProperty()]
#[Assert\Type(\DateTimeInterface::class)]
#[Groups([
'contract:collection:post',
'contract:item:get',
'contract:item:put'
])]
private ?\DateTimeInterface $hireBegin = null;
#[ApiProperty()]
#[Groups(['contract:item:get'])]
private ?string $hireBeginDate = null;
#[ApiProperty()]
#[Groups(['contract:item:get'])]
private ?string $hireBeginTime = null;
#[ORM\Column(type: 'datetime', nullable: true)]
#[ApiProperty()]
#[Assert\Type(\DateTimeInterface::class)]
#[Groups([
'contract:collection:post',
'contract:item:get',
'contract:item:put'
])]
private ?\DateTimeInterface $hireEnd = null;
#[ApiProperty()]
#[Groups(['contract:item:get'])]
private ?string $hireEndDate = null;
#[ApiProperty()]
#[Groups(['contract:item:get'])]
private ?string $hireEndTime = null;
#[ORM\Column(type: 'string', nullable: true)]
#[ApiProperty()]
#[Assert\Type('string')]
#[Groups([
'contract:collection:post',
'contract:item:get',
'contract:item:put'
])]
private ?string $fuelType = null;
#[ORM\Column(type: 'string', nullable: true)]
#[ApiProperty()]
#[Assert\Type('string')]
#[Groups([
'contract:collection:post',
'contract:item:get',
'contract:item:put'
])]
private ?string $fuelType2 = null;
#[ORM\Column(type: 'string', nullable: true)]
#[ApiProperty()]
#[Assert\Type('string')]
#[Groups([
'contract:collection:post',
'contract:item:get',
'contract:item:put'
])]
private ?string $fuelType3 = null;
#[ORM\Column(type: 'string', nullable: true)]
#[ApiProperty()]
#[Assert\Type('string')]
#[Groups([
'contract:collection:post',
'contract:item:get',
'contract:item:put'
])]
private ?string $price = null;
#[ORM\Column(type: 'string', nullable: true)]
#[ApiProperty()]
#[Assert\Type('string')]
#[Groups([
'contract:collection:post',
'contract:item:get',
'contract:item:put'
])]
private ?string $price2 = null;
#[ORM\Column(type: 'string', nullable: true)]
#[ApiProperty()]
#[Assert\Type('string')]
#[Groups([
'contract:collection:post',
'contract:item:get',
'contract:item:put'
])]
private ?string $price3 = null;
#[ORM\Column(type: 'string', nullable: true)]
#[ApiProperty()]
#[Assert\Type('string')]
#[Groups([
'contract:collection:post',
'contract:item:get',
'contract:item:put'
])]
private ?string $priceCurrency = null;
#[ORM\Column(type: 'string', nullable: true)]
#[ApiProperty()]
#[Assert\Type('string')]
#[Groups([
'contract:collection:post',
'contract:item:get',
'contract:item:put'
])]
private ?string $priceCurrency2 = null;
#[ORM\Column(type: 'string', nullable: true)]
#[ApiProperty()]
#[Assert\Type('string')]
#[Groups([
'contract:collection:post',
'contract:item:get',
'contract:item:put'
])]
private ?string $priceCurrency3 = null;
#[ORM\Column(type: 'boolean', nullable: true)]
#[ApiProperty()]
#[Groups([
'contract:collection:post',
'contract:item:get',
'contract:item:put'
])]
private ?bool $multiFuel = false;
#[ORM\Column(type: 'float', nullable: true)]
#[ApiProperty()]
#[Assert\Type('float')]
#[Groups([
'contract:collection:post',
'contract:item:get',
'contract:item:put'
])]
private ?float $hirePeriod = null;
#[ORM\Column(type: 'boolean', nullable: true)]
#[ApiProperty()]
#[Groups([
'contract:collection:post',
'contract:item:get',
'contract:item:put'
])]
private ?bool $offHire = false;
#[ORM\Column(type: 'datetime', nullable: true)]
#[ApiProperty()]
#[Assert\Type(\DateTimeInterface::class)]
#[Groups([
'contract:collection:post',
'contract:item:get',
'contract:item:put'
])]
private ?\DateTimeInterface $offHireBegin = null;
#[ApiProperty()]
#[Groups(['contract:item:get'])]
private ?string $offHireBeginDate = null;
#[ApiProperty()]
#[Groups(['contract:item:get'])]
private ?string $offHireBeginTime = null;
#[ORM\Column(type: 'datetime', nullable: true)]
#[ApiProperty()]
#[Assert\Type(\DateTimeInterface::class)]
#[Groups([
'contract:collection:post',
'contract:item:get',
'contract:item:put'
])]
private ?\DateTimeInterface $offHireEnd = null;
#[ApiProperty()]
#[Groups(['contract:item:get'])]
private ?string $offHireEndDate = null;
#[ApiProperty()]
#[Groups(['contract:item:get'])]
private ?string $offHireEndTime = null;
#[ORM\Column(type: 'string', nullable: true)]
#[ApiProperty()]
#[Assert\Type('string')]
#[Groups([
'contract:collection:post',
'contract:item:get',
'contract:item:put'
])]
private ?string $offHireCost = null;
#[ORM\Column(type: 'string', nullable: true)]
#[ApiProperty()]
#[Assert\Type('string')]
#[Groups([
'contract:collection:post',
'contract:item:get',
'contract:item:put'
])]
private ?string $offHireCostCurrency = null;
#[ORM\Column(type: 'float', nullable: true)]
#[ApiProperty()]
#[Assert\Type('float')]
#[Groups([
'contract:collection:post',
'contract:item:get',
'contract:item:put'
])]
private ?float $offHirePeriod = null;
// #[ORM\Column(type: 'string', nullable: true)]
// #[ApiProperty()]
// #[Assert\Type('string')]
// #[Groups([
// 'contract:collection:post',
// 'contract:item:get',
// 'contract:item:put'
// ])]
// private ?string $addressCommission = null;
#[ORM\Column(type: 'boolean', nullable: true)]
#[ApiProperty()]
#[Groups([
'contract:collection:post',
'contract:item:get',
'contract:item:put'
])]
private ?bool $extra = false;
#[ORM\Column(type: 'string', nullable: true)]
#[ApiProperty()]
#[Assert\Type('string')]
#[Groups([
'contract:collection:post',
'contract:item:get',
'contract:item:put'
])]
private ?string $extraCosts = null;
#[ORM\Column(type: 'string', nullable: true)]
#[ApiProperty()]
#[Assert\Type('string')]
#[Groups([
'contract:collection:post',
'contract:item:get',
'contract:item:put'
])]
private ?string $extraCostsCurrency = null;
#[ORM\Column(type: 'string', nullable: true)]
#[ApiProperty()]
#[Assert\Type('string')]
#[Groups([
'contract:collection:post',
'contract:item:get',
'contract:item:put'
])]
private ?string $extraCostsDescription = null;
#[ORM\Column(type: 'string', nullable: true)]
#[ApiProperty()]
#[Assert\Type('string')]
#[Groups([
'contract:collection:post',
'contract:item:get',
'contract:item:put'
])]
private ?string $totalInvoice = null;
#[ORM\Column(type: 'string', nullable: true)]
#[ApiProperty()]
#[Assert\Type('string')]
#[Groups([
'contract:collection:post',
'contract:item:get',
'contract:item:put'
])]
private ?string $totalInvoiceCurrency = null;
#[ORM\Column(type: 'string', nullable: true)]
#[ApiProperty()]
#[Assert\Type('string')]
#[Assert\Choice(
choices: self::INVOICE_STATUSES,
message: 'The status is not valid.'
)]
#[Groups([
'contract:collection:post',
'contract:item:get',
'contract:item:put'
])]
private ?string $invoiceStatus = self::INVOICE_STATUS_NOT_INVOICED;
#[ORM\Column(type: 'boolean', nullable: true)]
#[ApiProperty()]
#[Groups([
'contract:collection:post',
'contract:item:get',
'contract:item:put'
])]
private ?bool $bunker = false;
#[ORM\Column(type: 'boolean', nullable: true)]
#[ApiProperty()]
#[Groups([
'contract:collection:post',
'contract:item:get',
'contract:item:put'
])]
private ?bool $finalHire = false;
#[ORM\Column(type: 'integer')]
#[Assert\NotNull]
#[ApiProperty()]
#[Groups([
'contract:item:get',
'contract:item:put',
'contract:collection:get',
'contract:collection:post'
])]
private ?int $hireIndex = 0;
#[ORM\ManyToOne(
targetEntity: Contract::class,
inversedBy: 'hires'
)]
#[ORM\JoinColumn(nullable: true)]
#[ApiProperty()]
#[Groups([
'contract:collection:post',
'contract:item:get',
'contract:item:put'
])]
#[MaxDepth(1)]
private ?Contract $contract = null;
public function __construct()
{
$this->id = Uuid::uuid4();
}
public function getId(): ?UuidInterface
{
return $this->id;
}
public function getHireBegin(): ?\DateTimeInterface
{
return $this->hireBegin;
}
public function setHireBegin(?\DateTimeInterface $hireBegin): void
{
$this->hireBegin = $hireBegin;
}
public function getHireBeginDate(): ?string
{
return $this->hireBegin ? $this->hireBegin->format('Y-m-d') : null;
}
public function getHireBeginTime(): ?string
{
return $this->hireBegin ? $this->hireBegin->format('H:i') : null;
}
public function getHireEnd(): ?\DateTimeInterface
{
return $this->hireEnd;
}
public function setHireEnd(?\DateTimeInterface $hireEnd): void
{
$this->hireEnd = $hireEnd;
}
public function getHireEndDate(): ?string
{
return $this->hireEnd ? $this->hireEnd->format('Y-m-d') : null;
}
public function getHireEndTime(): ?string
{
return $this->hireEnd ? $this->hireEnd->format('H:i') : null;
}
public function getFuelType(): ?string
{
return $this->fuelType;
}
public function setFuelType(?string $fuelType): void
{
$this->fuelType = $fuelType;
}
public function getFuelType2(): ?string
{
return $this->fuelType2;
}
public function setFuelType2(?string $fuelType2): void
{
$this->fuelType2 = $fuelType2;
}
public function getFuelType3(): ?string
{
return $this->fuelType3;
}
public function setFuelType3(?string $fuelType3): void
{
$this->fuelType3 = $fuelType3;
}
public function getPrice(): ?string
{
return $this->price;
}
public function setPrice(?string $price): void
{
$this->price = $price;
}
public function getPrice2(): ?string
{
return $this->price2;
}
public function setPrice2(?string $price2): void
{
$this->price2 = $price2;
}
public function getPrice3(): ?string
{
return $this->price3;
}
public function setPrice3(?string $price3): void
{
$this->price3 = $price3;
}
public function getPriceCurrency(): ?string
{
return $this->priceCurrency;
}
public function setPriceCurrency(?string $priceCurrency): void
{
$this->priceCurrency = $priceCurrency;
}
public function getPriceCurrency2(): ?string
{
return $this->priceCurrency2;
}
public function setPriceCurrency2(?string $priceCurrency2): void
{
$this->priceCurrency2 = $priceCurrency2;
}
public function getPriceCurrency3(): ?string
{
return $this->priceCurrency3;
}
public function setPriceCurrency3(?string $priceCurrency3): void
{
$this->priceCurrency3 = $priceCurrency3;
}
public function getMultiFuel(): ?bool
{
return $this->multiFuel ?? false;
}
public function setMultiFuel(?bool $multiFuel): void
{
$this->multiFuel = $multiFuel;
}
public function getHirePeriod(): ?float
{
return $this->hirePeriod;
}
public function setHirePeriod(?float $hirePeriod): void
{
$this->hirePeriod = $hirePeriod;
}
public function setOffHireBegin(?\DateTimeInterface $offHireBegin): void
{
$this->offHireBegin = $offHireBegin;
}
public function getOffHireBegin(): ?\DateTimeInterface
{
return $this->offHireBegin;
}
public function getOffHireBeginDate(): ?string
{
return $this->offHireBegin ? $this->offHireBegin->format('Y-m-d') : null;
}
public function getOffHireBeginTime(): ?string
{
return $this->offHireBegin ? $this->offHireBegin->format('H:i') : null;
}
public function setOffHireEnd(?\DateTimeInterface $offHireEnd): void
{
$this->offHireEnd = $offHireEnd;
}
public function getOffHireEnd(): ?\DateTimeInterface
{
return $this->offHireEnd;
}
public function getOffHireEndDate(): ?string
{
return $this->offHireEnd ? $this->offHireEnd->format('Y-m-d') : null;
}
public function getOffHireEndTime(): ?string
{
return $this->offHireEnd ? $this->offHireEnd->format('H:i') : null;
}
public function getOffHireCost(): ?string
{
return $this->offHireCost;
}
public function setOffHireCost(?string $offHireCost): void
{
$this->offHireCost = $offHireCost;
}
public function getOffHireCostCurrency(): ?string
{
return $this->offHireCostCurrency;
}
public function setOffHireCostCurrency(?string $offHireCostCurrency): void
{
$this->offHireCostCurrency = $offHireCostCurrency;
}
public function getOffHirePeriod(): ?float
{
return $this->offHirePeriod;
}
public function setOffHirePeriod(?float $offHirePeriod): void
{
$this->offHirePeriod = $offHirePeriod;
}
// public function getAddressCommission(): ?string
// {
// return $this->addressCommission;
// }
// public function setAddressCommission(?string $addressCommission): void
// {
// $this->addressCommission = $addressCommission;
// }
public function getExtraCosts(): ?string
{
return $this->extraCosts;
}
public function setExtraCosts(?string $extraCosts): void
{
$this->extraCosts = $extraCosts;
}
public function getExtraCostsCurrency(): ?string
{
return $this->extraCostsCurrency;
}
public function setExtraCostsCurrency(?string $extraCostsCurrency): void
{
$this->extraCostsCurrency = $extraCostsCurrency;
}
public function getExtraCostsDescription(): ?string
{
return $this->extraCostsDescription;
}
public function setExtraCostsDescription(?string $extraCostsDescription): void
{
$this->extraCostsDescription = $extraCostsDescription;
}
public function getTotalInvoice(): ?string
{
return $this->totalInvoice;
}
public function setTotalInvoice(?string $totalInvoice): void
{
$this->totalInvoice = $totalInvoice;
}
public function getTotalInvoiceCurrency(): ?string
{
return $this->totalInvoiceCurrency;
}
public function setTotalInvoiceCurrency(?string $totalInvoiceCurrency): void
{
$this->totalInvoiceCurrency = $totalInvoiceCurrency;
}
public function getInvoiceStatus(): ?string
{
return $this->invoiceStatus;
}
public function setInvoiceStatus(?string $invoiceStatus): void
{
$this->invoiceStatus = $invoiceStatus;
}
public function getBunker(): ?bool
{
return $this->bunker ?? false;
}
public function setBunker(?bool $bunker): void
{
$this->bunker = $bunker;
}
public function getFinalHire(): ?bool
{
return $this->finalHire ?? false;
}
public function setFinalHire(?bool $finalHire): void
{
$this->finalHire = $finalHire;
}
public function setHireIndex(?int $hireIndex): void
{
$this->hireIndex = $hireIndex;
}
public function getHireIndex(): ?int
{
return $this->hireIndex;
}
public function setContract(?Contract $contract): void
{
$this->contract = $contract;
}
public function getContract(): ?Contract
{
return $this->contract;
}
public function getOffHire(): ?bool
{
return $this->offHire ?? false;
}
public function setOffHire(?bool $offHire): void
{
$this->offHire = $offHire;
}
public function getExtra(): ?bool
{
return $this->extra ?? false;
}
public function setExtra(?bool $extra): void
{
$this->extra = $extra;
}
}