<?php
declare(strict_types=1);
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use App\Trait\TimestampableEntity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\MaxDepth;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;
/**
* @see https://schema.org/Thing
*
* @author Jordi Fernandes Alves <jfadev@gmail.com>
*/
#[ORM\Entity]
#[ApiResource(
iri: 'Contract',
itemOperations: [
'get' => ['normalization_context' => ['groups' => 'contract:item:get', 'enable_max_depth' => true]],
'put' => [
'normalization_context' => ['groups' => 'contract:item:put', 'enable_max_depth' => true],
'denormalization_context' => ['groups' => 'contract:item:put', 'enable_max_depth' => true],
],
'delete' => [],
],
collectionOperations: [
'get' => [
'normalization_context' => [
'groups' => ['contract:collection:get', 'createdAt'],
'enable_max_depth' => true,
],
],
'post' => [
'normalization_context' => ['groups' => 'contract:collection:post', 'enable_max_depth' => true],
'denormalization_context' => ['groups' => 'contract:collection:post', 'enable_max_depth' => true],
],
],
)]
#[ApiFilter(
SearchFilter::class,
properties: [
'contractNumber' => 'start',
'contractType' => 'exact',
'vessel.vesselName' => 'partial',
'charterer.companyName' => 'partial',
'owner.companyName' => 'partial',
'broker.name' => 'partial',
'operator.name' => 'partial',
'laycanStart' => 'start',
'laycanEnd' => 'start',
'status' => 'exact',
'createdAt' => 'start'
],
)]
#[ApiFilter(
OrderFilter::class,
properties: [
'contractNumber',
'contractType',
'vessel.vesselName',
'charterer.companyName',
'owner.companyName',
'broker.name',
'operator.name',
'laycanStart',
'laycanEnd',
'status',
'createdAt'
],
)]
class Contract
{
use TimestampableEntity;
public const COST_TYPES = [
'PMT',
'LUMPSUM'
];
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'NONE')]
#[ORM\Column(type: 'uuid', unique: true)]
private ?UuidInterface $id = null;
#[ORM\Column(type: 'string', nullable: false, unique: true)]
#[ApiProperty(iri: 'https://schema.org/contractNumber')]
#[Assert\NotBlank]
#[Assert\Type('string')]
#[Groups(['contract:item:get', 'contract:item:put', 'contract:collection:get', 'contract:collection:post'])]
private ?string $contractNumber = null;
#[ORM\Column(type: 'date', nullable: true)]
#[ApiProperty(iri: 'https://schema.org/contractDate')]
// #[Assert\NotBlank]
#[Assert\Type(\DateTimeInterface::class)]
#[Groups(['contract:item:get', 'contract:item:put', 'contract:collection:get', 'contract:collection:post'])]
private ?\DateTimeInterface $contractDate = null;
#[ORM\Column(type: 'string', nullable: true)]
#[ApiProperty(iri: 'https://schema.org/contractType')]
#[Assert\NotBlank]
#[Assert\Type('string')]
#[Groups(['contract:item:get', 'contract:item:put', 'contract:collection:get', 'contract:collection:post'])]
private ?string $contractType = null;
#[ORM\Column(type: 'datetime', nullable: true)]
#[ApiProperty(iri: 'https://schema.org/laycanStart')]
// #[Assert\NotBlank]
#[Assert\Type(\DateTimeInterface::class)]
#[Groups(['contract:item:get', 'contract:item:put', 'contract:collection:get', 'contract:collection:post'])]
private ?\DateTimeInterface $laycanStart = null;
#[ApiProperty(iri: 'https://schema.org/laycanStartDate')]
#[Groups(['contract:item:get'])]
private ?string $laycanStartDate = null;
#[ApiProperty(iri: 'https://schema.org/laycanStartTime')]
#[Groups(['contract:item:get'])]
private ?string $laycanStartTime = null;
#[ORM\Column(type: 'datetime', nullable: true)]
#[ApiProperty(iri: 'https://schema.org/laycanEnd')]
// #[Assert\NotBlank]
#[Assert\Type(\DateTimeInterface::class)]
#[Groups(['contract:item:get', 'contract:item:put', 'contract:collection:get', 'contract:collection:post'])]
private ?\DateTimeInterface $laycanEnd = null;
#[ApiProperty(iri: 'https://schema.org/laycanEndDate')]
#[Groups(['contract:item:get'])]
private ?string $laycanEndDate = null;
#[ApiProperty(iri: 'https://schema.org/laycanEndTime')]
#[Groups(['contract:item:get'])]
private ?string $laycanEndTime = null;
#[ORM\ManyToOne(targetEntity: 'App\Entity\Vessel', inversedBy: 'contracts')]
#[ORM\JoinColumn(nullable: true)]
#[ApiProperty(iri: 'https://schema.org/vessel')]
#[Groups(['contract:item:get', 'contract:item:put', 'contract:collection:get', 'contract:collection:post'])]
private ?Vessel $vessel = null;
#[ORM\ManyToOne(targetEntity: 'App\Entity\Owner', inversedBy: 'contracts')]
#[ORM\JoinColumn(nullable: true)]
#[ApiProperty(iri: 'https://schema.org/Owner')]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
#[MaxDepth(1)]
private ?Owner $owner = null;
#[ORM\ManyToOne(targetEntity: 'App\Entity\Charterer', inversedBy: 'contracts')]
#[ORM\JoinColumn(nullable: true)]
#[ApiProperty(iri: 'https://schema.org/Charterer')]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
#[MaxDepth(1)]
private ?Charterer $charterer = null;
#[ORM\ManyToOne(targetEntity: 'App\Entity\User', inversedBy: 'contracts')]
#[ORM\JoinColumn(nullable: true)]
#[ApiProperty(iri: 'https://schema.org/broker')]
#[Groups(['contract:item:get', 'contract:item:put', 'contract:collection:get', 'contract:collection:post'])]
#[MaxDepth(1)]
private ?User $broker = null;
#[ORM\ManyToOne(targetEntity: 'App\Entity\User', inversedBy: 'operations')]
#[ORM\JoinColumn(nullable: true)]
#[ApiProperty(iri: 'https://schema.org/operator')]
#[Groups(['contract:item:get', 'contract:item:put', 'contract:collection:get', 'contract:collection:post'])]
#[MaxDepth(1)]
private ?User $operator = null;
#[ORM\Column(type: 'string', nullable: false)]
#[ApiProperty(iri: 'https://schema.org/status')]
#[Assert\NotBlank]
#[Assert\Type('string')]
#[Groups(['contract:item:get', 'contract:item:put', 'contract:collection:get', 'contract:collection:post'])]
private ?string $status = null;
#[ORM\Column(type: 'string', nullable: true)]
#[Assert\Type('string')]
#[ApiProperty(iri: 'https://schema.org/freightCost')]
#[Groups(['contract:item:get', 'contract:item:put', 'contract:collection:get', 'contract:collection:post'])]
private ?string $freightCost = null;
#[ORM\Column(type: 'string', nullable: true)]
#[Assert\Type('string')]
#[ApiProperty(iri: 'https://schema.org/currency')]
#[Groups(['contract:item:get', 'contract:item:put', 'contract:collection:get', 'contract:collection:post'])]
private ?string $freightCostCurrency = null;
#[ORM\Column(type: 'string', nullable: true)]
#[Assert\Type('string')]
#[Assert\Choice(choices: self::COST_TYPES, message: 'The type is not valid.')]
#[ApiProperty(iri: 'https://schema.org/freightType')]
#[Groups(['contract:item:get', 'contract:item:put', 'contract:collection:get', 'contract:collection:post'])]
private ?string $freightType = null;
#[ORM\Column(type: 'string', nullable: true)]
#[Assert\Type('string')]
#[ApiProperty(iri: 'https://schema.org/demurragePerDay')]
#[Groups(['contract:item:get', 'contract:item:put', 'contract:collection:get', 'contract:collection:post'])]
private ?string $demurragePerDay = null;
#[ORM\Column(type: 'string', nullable: true)]
#[Assert\Type('string')]
#[ApiProperty(iri: 'https://schema.org/currency')]
#[Groups(['contract:item:get', 'contract:item:put', 'contract:collection:get', 'contract:collection:post'])]
private ?string $demurragePerDayCurrency = null;
#[ORM\OneToMany(targetEntity: 'App\Entity\AdditionalCost', mappedBy: 'contract', cascade: ['persist', 'remove'], orphanRemoval: true)]
##[ORM\OrderBy(['taskIndex' => 'ASC'])]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
#[MaxDepth(1)]
private ?Collection $additionalCosts = null;
#[ORM\Column(type: 'string', nullable: true)]
#[Assert\Type('string')]
#[ApiProperty(iri: 'https://schema.org/addressCommission')]
#[Groups(['contract:item:get', 'contract:item:put', 'contract:collection:get', 'contract:collection:post'])]
private ?string $addressCommission = null;
#[ORM\Column(type: 'string', nullable: true)]
#[Assert\Type('string')]
#[ApiProperty(iri: 'https://schema.org/brokerageCommission')]
#[Groups(['contract:item:get', 'contract:item:put', 'contract:collection:get', 'contract:collection:post'])]
private ?string $brokerageCommission = null;
#[ORM\Column(type: 'integer', nullable: true)]
#[ApiProperty(iri: 'https://schema.org/liftingsMin')]
#[Assert\Type('integer')]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
private ?int $liftingsMin = null;
#[ORM\Column(type: 'integer', nullable: true)]
#[ApiProperty(iri: 'https://schema.org/liftingsMax')]
#[Assert\Type('integer')]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
private ?int $liftingsMax = null;
#[ORM\OneToMany(mappedBy: 'contract', targetEntity: Media::class, cascade: ["remove"], orphanRemoval: true)]
#[ApiProperty(iri: 'https://schema.org/documents')]
#[Groups(['contract:item:get', 'contract:item:put', 'contract:collection:get', 'contract:collection:post'])]
#[MaxDepth(1)]
private ?Collection $documents = null;
#[ORM\OneToMany(targetEntity: 'App\Entity\PortCall', mappedBy: 'contract', cascade: ['persist', 'remove'], orphanRemoval: true)]
##[ORM\OrderBy(['taskIndex' => 'ASC'])]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
#[MaxDepth(1)]
private ?Collection $portCalls = null;
#[ORM\OneToMany(targetEntity: 'App\Entity\ReportedPort', mappedBy: 'contract', cascade: ['persist', 'remove'], orphanRemoval: true)]
// #[ORM\OrderBy(['taskIndex' => 'ASC'])]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
#[MaxDepth(1)]
private ?Collection $reportedPorts = null;
#[ORM\OneToMany(targetEntity: 'App\Entity\ReportedIncident', mappedBy: 'contract', cascade: ['persist', 'remove'], orphanRemoval: true)]
// #[ORM\OrderBy(['taskIndex' => 'ASC'])]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
#[MaxDepth(1)]
private ?Collection $reportedIncidents = null;
#[ORM\OneToMany(targetEntity: 'App\Entity\ContractCargo', mappedBy: 'contract', cascade: ['persist', 'remove'], orphanRemoval: true)]
##[ORM\OrderBy(['taskIndex' => 'ASC'])]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
#[MaxDepth(1)]
private ?Collection $cargoItems = null;
#[ORM\OneToMany(targetEntity: 'App\Entity\Payment', mappedBy: 'contract', cascade: ['persist', 'remove'], orphanRemoval: true)]
##[ORM\OrderBy(['taskIndex' => 'ASC'])]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
#[MaxDepth(1)]
private ?Collection $payments = null;
#[ORM\OneToMany(targetEntity: 'App\Entity\Hire', mappedBy: 'contract', cascade: ['persist', 'remove'], orphanRemoval: true)]
##[ORM\OrderBy(['taskIndex' => 'ASC'])]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
#[MaxDepth(1)]
private ?Collection $hires = null;
// #[ORM\OneToMany(targetEntity: 'App\Entity\Lifting', mappedBy: 'contract', cascade: ['persist', 'remove'], orphanRemoval: true)]
// ##[ORM\OrderBy(['taskIndex' => 'ASC'])]
// #[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
// #[MaxDepth(1)]
// private ?Collection $liftings = null;
#[ORM\OneToMany(targetEntity: 'App\Entity\Contract', mappedBy: 'contractCoa', cascade: ['persist', 'remove'], orphanRemoval: true)]
##[ORM\OrderBy(['taskIndex' => 'ASC'])]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
#[MaxDepth(2)]
private ?Collection $liftings = null;
#[ORM\ManyToOne(targetEntity: 'App\Entity\Checklist', inversedBy: 'contracts')]
#[ORM\JoinColumn(nullable: true)]
#[ApiProperty(iri: 'https://schema.org/Checklist')]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
#[MaxDepth(1)]
private ?Checklist $checklist = null;
#[ORM\ManyToMany(targetEntity: 'App\Entity\Task')]
#[ORM\InverseJoinColumn(unique: true)]
#[ApiProperty(iri: 'https://schema.org/checkedTasks')]
#[Groups(['contract:item:get', 'contract:item:put', 'contract:collection:get', 'contract:collection:post'])]
#[MaxDepth(1)]
private ?Collection $checkedTasks = null;
#[ORM\Column(type: 'text', nullable: true)]
#[ApiProperty(iri: 'https://schema.org/observation')]
#[Assert\Type('string')]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
private ?string $checklistNotes = null;
#[ORM\Column(type: 'string', nullable: true)]
#[ApiProperty(iri: 'https://schema.org/demurrageStatus')]
// #[Assert\NotBlank]
#[Assert\Type('string')]
#[Groups(['contract:item:get', 'contract:item:put', 'contract:collection:get', 'contract:collection:post'])]
private ?string $demurrageStatus = null;
#[ORM\Column(type: 'integer', nullable: true)]
#[ApiProperty(iri: 'https://schema.org/demurrageTimeBar')]
#[Assert\Type('integer')]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
private ?int $demurrageTimeBar = null;
#[ORM\Column(type: 'date', nullable: true)]
#[ApiProperty(iri: 'https://schema.org/demurragePaymentDate')]
// #[Assert\NotBlank]
#[Assert\Type(\DateTimeInterface::class)]
#[Groups(['contract:item:get', 'contract:item:put', 'contract:collection:get', 'contract:collection:post'])]
private ?\DateTimeInterface $demurragePaymentDate = null;
#[ORM\Column(type: 'string', nullable: true)]
#[Assert\Type('string')]
#[ApiProperty(iri: 'https://schema.org/finalDemurrageCost')]
#[Groups(['contract:item:get', 'contract:item:put', 'contract:collection:get', 'contract:collection:post'])]
private ?string $finalDemurrageCost = null;
#[ORM\Column(type: 'string', nullable: true)]
#[Assert\Type('string')]
#[ApiProperty(iri: 'https://schema.org/currency')]
#[Groups(['contract:item:get', 'contract:item:put', 'contract:collection:get', 'contract:collection:post'])]
private ?string $finalDemurrageCostCurrency = null;
#[ORM\Column(type: 'string', nullable: true)]
#[Assert\Type('string')]
#[ApiProperty(iri: 'https://schema.org/demurragePaidByCharterer')]
#[Groups(['contract:item:get', 'contract:item:put', 'contract:collection:get', 'contract:collection:post'])]
private ?string $demurragePaidByCharterer = null;
#[ORM\Column(type: 'string', nullable: true)]
#[Assert\Type('string')]
#[ApiProperty(iri: 'https://schema.org/currency')]
#[Groups(['contract:item:get', 'contract:item:put', 'contract:collection:get', 'contract:collection:post'])]
private ?string $demurragePaidByChartererCurrency = null;
#[ORM\Column(type: 'datetime', nullable: true)]
#[ApiProperty(iri: 'https://schema.org/etaArrival')]
// #[Assert\NotBlank]
#[Assert\Type(\DateTimeInterface::class)]
#[Groups(['contract:item:get', 'contract:item:put', 'contract:collection:get', 'contract:collection:post'])]
private ?\DateTimeInterface $etaArrival = null;
#[ApiProperty(iri: 'https://schema.org/etaArrivalDate')]
#[Groups(['contract:item:get'])]
private ?string $etaArrivalDate = null;
#[ApiProperty(iri: 'https://schema.org/etaArrivalTime')]
#[Groups(['contract:item:get'])]
private ?string $etaArrivalTime = null;
#[ORM\Column(type: 'datetime', nullable: true)]
#[ApiProperty(iri: 'https://schema.org/deliveredArrival')]
// #[Assert\NotBlank]
#[Assert\Type(\DateTimeInterface::class)]
#[Groups(['contract:item:get', 'contract:item:put', 'contract:collection:get', 'contract:collection:post'])]
private ?\DateTimeInterface $deliveredArrival = null;
#[ApiProperty(iri: 'https://schema.org/deliveredArrivalDate')]
#[Groups(['contract:item:get'])]
private ?string $deliveredArrivalDate = null;
#[ApiProperty(iri: 'https://schema.org/deliveredArrivalTime')]
#[Groups(['contract:item:get'])]
private ?string $deliveredArrivalTime = null;
#[ORM\Column(type: 'integer', nullable: true)]
#[ApiProperty(iri: 'https://schema.org/deliveryAproxNotice1')]
#[Assert\Type('integer')]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
private ?int $deliveryAproxNotice1 = null;
#[ORM\Column(type: 'integer', nullable: true)]
#[ApiProperty(iri: 'https://schema.org/deliveryAproxNotice2')]
#[Assert\Type('integer')]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
private ?int $deliveryAproxNotice2 = null;
#[ORM\Column(type: 'integer', nullable: true)]
#[ApiProperty(iri: 'https://schema.org/deliveryAproxNotice3')]
#[Assert\Type('integer')]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
private ?int $deliveryAproxNotice3 = null;
#[ORM\Column(type: 'integer', nullable: true)]
#[ApiProperty(iri: 'https://schema.org/deliveryAproxNotice4')]
#[Assert\Type('integer')]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
private ?int $deliveryAproxNotice4 = null;
#[ORM\Column(type: 'integer', nullable: true)]
#[ApiProperty(iri: 'https://schema.org/deliveryAproxNotice5')]
#[Assert\Type('integer')]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
private ?int $deliveryAproxNotice5 = null;
#[ORM\Column(type: 'integer', nullable: true)]
#[ApiProperty(iri: 'https://schema.org/deliveryAproxNotice6')]
#[Assert\Type('integer')]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
private ?int $deliveryAproxNotice6 = null;
#[ORM\Column(type: 'integer', nullable: true)]
#[ApiProperty(iri: 'https://schema.org/deliveryAproxNotice7')]
#[Assert\Type('integer')]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
private ?int $deliveryAproxNotice7 = null;
#[ORM\Column(type: 'integer', nullable: true)]
#[ApiProperty(iri: 'https://schema.org/deliveryFirmNotice1')]
#[Assert\Type('integer')]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
private ?int $deliveryFirmNotice1 = null;
#[ORM\Column(type: 'integer', nullable: true)]
#[ApiProperty(iri: 'https://schema.org/deliveryFirmNotice2')]
#[Assert\Type('integer')]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
private ?int $deliveryFirmNotice2 = null;
#[ORM\Column(type: 'integer', nullable: true)]
#[ApiProperty(iri: 'https://schema.org/deliveryFirmNotice3')]
#[Assert\Type('integer')]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
private ?int $deliveryFirmNotice3 = null;
#[ORM\Column(type: 'integer', nullable: true)]
#[ApiProperty(iri: 'https://schema.org/deliveryFirmNotice4')]
#[Assert\Type('integer')]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
private ?int $deliveryFirmNotice4 = null;
#[ORM\Column(type: 'integer', nullable: true)]
#[ApiProperty(iri: 'https://schema.org/deliveryFirmNotice5')]
#[Assert\Type('integer')]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
private ?int $deliveryFirmNotice5 = null;
#[ORM\Column(type: 'integer', nullable: true)]
#[ApiProperty(iri: 'https://schema.org/deliveryFirmNotice6')]
#[Assert\Type('integer')]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
private ?int $deliveryFirmNotice6 = null;
#[ORM\Column(type: 'integer', nullable: true)]
#[ApiProperty(iri: 'https://schema.org/deliveryFirmNotice7')]
#[Assert\Type('integer')]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
private ?int $deliveryFirmNotice7 = null;
#[ORM\Column(type: 'boolean', nullable: true)]
#[ApiProperty(iri: 'https://schema.org/deliveryNoticesNotAplicable')]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
private ?bool $deliveryNoticesNotAplicable = null;
#[ORM\Column(type: 'boolean', nullable: true)]
#[ApiProperty(iri: 'https://schema.org/shipDelivered')]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
private ?bool $shipDelivered = null;
#[ORM\ManyToOne(targetEntity: 'App\Entity\Port', inversedBy: 'deliveryPorts1')]
#[ORM\JoinColumn(nullable: true)]
#[ApiProperty(iri: 'https://schema.org/port')]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
#[MaxDepth(1)]
private ?Port $deliveryPort1 = null;
#[ORM\ManyToOne(targetEntity: 'App\Entity\Port', inversedBy: 'deliveryPorts2')]
#[ORM\JoinColumn(nullable: true)]
#[ApiProperty(iri: 'https://schema.org/port')]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
#[MaxDepth(1)]
private ?Port $deliveryPort2 = null;
#[ORM\Column(type: 'string', nullable: true)]
#[Assert\Type('string')]
#[ApiProperty(iri: 'https://schema.org/hirePerDay')]
#[Groups(['contract:item:get', 'contract:item:put', 'contract:collection:get', 'contract:collection:post'])]
private ?string $hirePerDay = null;
#[ORM\Column(type: 'string', nullable: true)]
#[Assert\Type('string')]
#[ApiProperty(iri: 'https://schema.org/currency')]
#[Groups(['contract:item:get', 'contract:item:put', 'contract:collection:get', 'contract:collection:post'])]
private ?string $hirePerDayCurrency = null;
#[ORM\Column(type: 'integer', nullable: true)]
#[ApiProperty(iri: 'https://schema.org/period')]
#[Assert\Type('integer')]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
private ?int $period = null;
#[ORM\OneToMany(targetEntity: 'App\Entity\DeliveryNotice', mappedBy: 'contract', cascade: ['persist', 'remove'], orphanRemoval: true)]
##[ORM\OrderBy(['taskIndex' => 'ASC'])]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
#[MaxDepth(1)]
private ?Collection $deliveryNotices = null;
#[ORM\Column(type: 'text', nullable: true)]
#[ApiProperty(iri: 'https://schema.org/observation')]
#[Assert\Type('string')]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
private ?string $reportDescription = null;
#[ORM\Column(type: 'boolean', nullable: true)]
#[ApiProperty(iri: 'https://schema.org/vesselArrivedWithinTheLaycan')]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
private ?bool $vesselArrivedWithinTheLaycan = false;
#[ORM\Column(type: 'boolean', nullable: true)]
#[ApiProperty(iri: 'https://schema.org/vesselWasSubstituted')]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
private ?bool $vesselWasSubstituted = false;
#[ORM\Column(type: 'boolean', nullable: true)]
#[ApiProperty(iri: 'https://schema.org/addendumIssued')]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
private ?bool $addendumIssued = false;
#[ORM\Column(type: 'text', nullable: true)]
#[ApiProperty(iri: 'https://schema.org/observation')]
#[Assert\Type('string')]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
private ?string $addendumDescription = null;
#[ORM\ManyToOne(targetEntity: 'App\Entity\Contract', inversedBy: 'liftings')]
#[ORM\JoinColumn(nullable: true)]
#[ApiProperty(iri: 'https://schema.org/Contract')]
#[Groups(['contract:collection:get', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
#[MaxDepth(1)]
private ?Contract $contractCoa = null;
#[ApiProperty(iri: 'https://schema.org/cargoVolumeM3')]
#[Groups(['contract:item:get'])]
private ?string $cargoVolumeM3 = null;
#[ApiProperty(iri: 'https://schema.org/cargoVolumeMT')]
#[Groups(['contract:item:get'])]
private ?string $cargoVolumeMT = null;
public function __construct()
{
$this->id = Uuid::uuid4();
$this->documents = new ArrayCollection();
$this->portCalls = new ArrayCollection();
$this->reportedPorts = new ArrayCollection();
$this->reportedIncidents = new ArrayCollection();
$this->cargoItems = new ArrayCollection();
$this->checkedTasks = new ArrayCollection();
$this->payments = new ArrayCollection();
$this->hires = new ArrayCollection();
$this->liftings = new ArrayCollection();
$this->deliveryNotices = new ArrayCollection();
}
public function getId(): ?UuidInterface
{
return $this->id;
}
public function setContractNumber(?string $contractNumber): void
{
$this->contractNumber = $contractNumber;
}
public function getContractNumber(): ?string
{
return $this->contractNumber;
}
public function setContractDate(?\DateTimeInterface $contractDate): void
{
$this->contractDate = $contractDate;
}
public function getContractDate(): ?string
{
return $this->contractDate?->format('Y-m-d');
}
public function setContractType(?string $contractType): void
{
$this->contractType = $contractType;
}
public function getContractType(): ?string
{
return $this->contractType;
}
public function setLaycanStart(?\DateTimeInterface $laycanStart): void
{
$this->laycanStart = $laycanStart;
}
public function getLaycanStart(): ?\DateTimeInterface
{
return $this->laycanStart;
}
public function getLaycanStartDate(): ?string
{
return $this->laycanStart ? $this->laycanStart->format('Y-m-d') : null;
}
public function getLaycanStartTime(): ?string
{
return $this->laycanStart ? $this->laycanStart->format('H:i') : null;
}
public function setLaycanEnd(?\DateTimeInterface $laycanEnd): void
{
$this->laycanEnd = $laycanEnd;
}
public function getLaycanEnd(): ?\DateTimeInterface
{
return $this->laycanEnd;
}
public function getLaycanEndDate(): ?string
{
return $this->laycanEnd ? $this->laycanEnd->format('Y-m-d') : null;
}
public function getLaycanEndTime(): ?string
{
return $this->laycanEnd ? $this->laycanEnd->format('H:i') : null;
}
public function setVessel(?Vessel $vessel): void
{
$this->vessel = $vessel;
}
public function getVessel(): ?Vessel
{
return $this->vessel;
}
public function setOwner(?Owner $owner): void
{
$this->owner = $owner;
}
public function getOwner(): ?Owner
{
return $this->owner;
}
public function setCharterer(?Charterer $charterer): void
{
$this->charterer = $charterer;
}
public function getCharterer(): ?Charterer
{
return $this->charterer;
}
public function addDocument(Media $document): void
{
$document->setContract($this);
$this->documents[] = $document;
}
public function removeDocument(Media $document): void
{
$this->documents->removeElement($document);
}
public function getDocuments(): Collection
{
return $this->documents;
}
public function setBroker(?User $broker): void
{
$this->broker = $broker;
}
public function getBroker(): ?User
{
return $this->broker;
}
public function setOperator(?User $operator): void
{
$this->operator = $operator;
}
public function getOperator(): ?User
{
return $this->operator;
}
public function setDemurragePerDay(?string $demurragePerDay): void
{
$this->demurragePerDay = $demurragePerDay;
}
public function getDemurragePerDay(): ?string
{
return $this->demurragePerDay;
}
public function getDemurragePerDayCurrency(): ?string
{
return $this->demurragePerDayCurrency;
}
public function setDemurragePerDayCurrency(?string $demurragePerDayCurrency): void
{
$this->demurragePerDayCurrency = $demurragePerDayCurrency;
}
public function setAddressCommission(?string $addressCommission): void
{
$this->addressCommission = $addressCommission;
}
public function getAddressCommission(): ?string
{
return $this->addressCommission;
}
public function setbrokerageCommission(?string $brokerageCommission): void
{
$this->brokerageCommission = $brokerageCommission;
}
public function getbrokerageCommission(): ?string
{
return $this->brokerageCommission;
}
public function setLiftingsMin(?int $liftingsMin): void
{
$this->liftingsMin = $liftingsMin;
}
public function getLiftingsMin(): ?int
{
return $this->liftingsMin;
}
public function setLiftingsMax(?int $liftingsMax): void
{
$this->liftingsMax = $liftingsMax;
}
public function getLiftingsMax(): ?int
{
return $this->liftingsMax;
}
public function addPortCall(PortCall $portCall): void
{
$portCall->setContract($this);
$this->portCalls[] = $portCall;
}
public function removePortCall(PortCall $portCall): void
{
$this->portCalls->removeElement($portCall);
}
public function getPortCalls(): Collection
{
return $this->portCalls;
}
public function addReportedPort(ReportedPort $reportedPort): void
{
$reportedPort->setContract($this);
$this->reportedPorts[] = $reportedPort;
}
public function removeReportedPort(ReportedPort $reportedPort): void
{
$this->reportedPorts->removeElement($reportedPort);
}
public function getReportedPorts(): Collection
{
return $this->reportedPorts;
}
public function addReportedIncident(ReportedIncident $reportedIncident): void
{
$reportedIncident->setContract($this);
$this->reportedIncidents[] = $reportedIncident;
}
public function removeReportedIncident(ReportedIncident $reportedIncident): void
{
$this->reportedIncidents->removeElement($reportedIncident);
}
public function getReportedIncidents(): Collection
{
return $this->reportedIncidents;
}
public function addCargoItem(ContractCargo $cargoItem): void
{
$cargoItem->setContract($this);
$this->cargoItems[] = $cargoItem;
}
public function removeCargoItem(ContractCargo $cargoItem): void
{
$this->cargoItems->removeElement($cargoItem);
}
public function getCargoItems(): Collection
{
return $this->cargoItems;
}
public function getPayments(): Collection
{
return $this->payments;
}
public function addPayment(Payment $payment): void
{
$payment->setContract($this);
$this->payments[] = $payment;
}
public function removePayment(Payment $payment): void
{
$this->payments->removeElement($payment);
}
public function getHires(): Collection
{
return $this->hires;
}
public function addHire(Hire $hire): void
{
$hire->setContract($this);
$this->hires[] = $hire;
}
public function removeHire(Hire $hire): void
{
$this->hires->removeElement($hire);
}
// public function addLifting(Lifting $lifting): void
// {
// $lifting->setContract($this);
// $this->liftings[] = $lifting;
// }
// public function removeLifting(Lifting $lifting): void
// {
// $this->liftings->removeElement($lifting);
// }
// public function getLiftings(): Collection
// {
// return $this->liftings;
// }
public function addLifting(Contract $lifting): void
{
$lifting->setContractCoa($this);
$this->liftings[] = $lifting;
}
public function removeLifting(Contract $lifting): void
{
$this->liftings->removeElement($lifting);
}
public function getLiftings(): Collection
{
return $this->liftings;
}
public function getFreightCost(): ?string
{
return $this->freightCost;
}
public function setFreightCost(?string $freightCost): void
{
$this->freightCost = $freightCost;
}
public function getFreightCostCurrency(): ?string
{
return $this->freightCostCurrency;
}
public function setFreightCostCurrency(?string $freightCostCurrency): void
{
$this->freightCostCurrency = $freightCostCurrency;
}
public function getFreightType(): ?string
{
return $this->freightType;
}
public function setFreightType(?string $freightType): void
{
$this->freightType = $freightType;
}
public function addAdditionalCost(AdditionalCost $additionalCost): void
{
$additionalCost->setContract($this);
$this->additionalCosts[] = $additionalCost;
}
public function removeAdditionalCost(AdditionalCost $additionalCost): void
{
$this->additionalCosts->removeElement($additionalCost);
}
public function getAdditionalCosts(): ?Collection
{
return $this->additionalCosts;
}
public function setStatus(?string $status): void
{
$this->status = $status;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setChecklist(?Checklist $checklist): void
{
$this->checklist = $checklist;
}
public function getChecklist(): ?Checklist
{
return $this->checklist;
}
public function addCheckedTask(Task $checkedTask): void
{
$this->checkedTasks[] = $checkedTask;
}
public function removeCheckedTask(Task $checkedTask): void
{
$this->checkedTasks->removeElement($checkedTask);
}
public function getCheckedTasks(): Collection
{
return $this->checkedTasks;
}
public function setChecklistNotes(?string $checklistNotes): void
{
$this->checklistNotes = $checklistNotes;
}
public function getChecklistNotes(): ?string
{
return $this->checklistNotes;
}
public function setDemurrageStatus(?string $demurrageStatus): void
{
$this->demurrageStatus = $demurrageStatus;
}
public function getDemurrageStatus(): ?string
{
return $this->demurrageStatus;
}
public function setDemurrageTimeBar(?int $demurrageTimeBar): void
{
$this->demurrageTimeBar = $demurrageTimeBar;
}
public function getDemurrageTimeBar(): ?int
{
return $this->demurrageTimeBar;
}
public function setDemurragePaymentDate(?\DateTimeInterface $demurragePaymentDate): void
{
$this->demurragePaymentDate = $demurragePaymentDate;
}
public function getDemurragePaymentDate(): ?string
{
return $this->demurragePaymentDate?->format('Y-m-d');
}
public function getDemurragePaidByCharterer(): ?string
{
return $this->demurragePaidByCharterer;
}
public function setDemurragePaidByCharterer(?string $demurragePaidByCharterer): void
{
$this->demurragePaidByCharterer = $demurragePaidByCharterer;
}
public function getDemurragePaidByChartererCurrency(): ?string
{
return $this->demurragePaidByChartererCurrency;
}
public function setDemurragePaidByChartererCurrency(?string $demurragePaidByChartererCurrency): void
{
$this->demurragePaidByChartererCurrency = $demurragePaidByChartererCurrency;
}
public function getFinalDemurrageCost(): ?string
{
return $this->finalDemurrageCost;
}
public function setFinalDemurrageCost(?string $finalDemurrageCost): void
{
$this->finalDemurrageCost = $finalDemurrageCost;
}
public function getFinalDemurrageCostCurrency(): ?string
{
return $this->finalDemurrageCostCurrency;
}
public function setFinalDemurrageCostCurrency(?string $finalDemurrageCostCurrency): void
{
$this->finalDemurrageCostCurrency = $finalDemurrageCostCurrency;
}
public function getEtaArrival(): ?\DateTimeInterface
{
return $this->etaArrival;
}
public function getEtaArrivalDate(): ?string
{
return $this->etaArrival ? $this->etaArrival->format('Y-m-d') : null;
}
public function getEtaArrivalTime(): ?string
{
return $this->etaArrival ? $this->etaArrival->format('H:i') : null;
}
public function setEtaArrival(?\DateTimeInterface $etaArrival): void
{
$this->etaArrival = $etaArrival;
}
public function getDeliveredArrival(): ?\DateTimeInterface
{
return $this->deliveredArrival;
}
public function getDeliveredArrivalDate(): ?string
{
return $this->deliveredArrival ? $this->deliveredArrival->format('Y-m-d') : null;
}
public function getDeliveredArrivalTime(): ?string
{
return $this->deliveredArrival ? $this->deliveredArrival->format('H:i') : null;
}
public function setDeliveredArrival(?\DateTimeInterface $deliveredArrival): void
{
$this->deliveredArrival = $deliveredArrival;
}
public function getDeliveryAproxNotice1(): ?int
{
return $this->deliveryAproxNotice1;
}
public function setDeliveryAproxNotice1(?int $deliveryAproxNotice1): void
{
$this->deliveryAproxNotice1 = $deliveryAproxNotice1;
}
public function getDeliveryAproxNotice2(): ?int
{
return $this->deliveryAproxNotice2;
}
public function setDeliveryAproxNotice2(?int $deliveryAproxNotice2): void
{
$this->deliveryAproxNotice2 = $deliveryAproxNotice2;
}
public function getDeliveryAproxNotice3(): ?int
{
return $this->deliveryAproxNotice3;
}
public function setDeliveryAproxNotice3(?int $deliveryAproxNotice3): void
{
$this->deliveryAproxNotice3 = $deliveryAproxNotice3;
}
public function getDeliveryAproxNotice4(): ?int
{
return $this->deliveryAproxNotice4;
}
public function setDeliveryAproxNotice4(?int $deliveryAproxNotice4): void
{
$this->deliveryAproxNotice4 = $deliveryAproxNotice4;
}
public function getDeliveryAproxNotice5(): ?int
{
return $this->deliveryAproxNotice5;
}
public function setDeliveryAproxNotice5(?int $deliveryAproxNotice5): void
{
$this->deliveryAproxNotice5 = $deliveryAproxNotice5;
}
public function getDeliveryAproxNotice6(): ?int
{
return $this->deliveryAproxNotice6;
}
public function setDeliveryAproxNotice6(?int $deliveryAproxNotice6): void
{
$this->deliveryAproxNotice6 = $deliveryAproxNotice6;
}
public function getDeliveryAproxNotice7(): ?int
{
return $this->deliveryAproxNotice7;
}
public function setDeliveryAproxNotice7(?int $deliveryAproxNotice7): void
{
$this->deliveryAproxNotice7 = $deliveryAproxNotice7;
}
public function getDeliveryFirmNotice1(): ?int
{
return $this->deliveryFirmNotice1;
}
public function setDeliveryFirmNotice1(?int $deliveryFirmNotice1): void
{
$this->deliveryFirmNotice1 = $deliveryFirmNotice1;
}
public function getDeliveryFirmNotice2(): ?int
{
return $this->deliveryFirmNotice2;
}
public function setDeliveryFirmNotice2(?int $deliveryFirmNotice2): void
{
$this->deliveryFirmNotice2 = $deliveryFirmNotice2;
}
public function getDeliveryFirmNotice3(): ?int
{
return $this->deliveryFirmNotice3;
}
public function setDeliveryFirmNotice3(?int $deliveryFirmNotice3): void
{
$this->deliveryFirmNotice3 = $deliveryFirmNotice3;
}
public function getDeliveryFirmNotice4(): ?int
{
return $this->deliveryFirmNotice4;
}
public function setDeliveryFirmNotice4(?int $deliveryFirmNotice4): void
{
$this->deliveryFirmNotice4 = $deliveryFirmNotice4;
}
public function getDeliveryFirmNotice5(): ?int
{
return $this->deliveryFirmNotice5;
}
public function setDeliveryFirmNotice5(?int $deliveryFirmNotice5): void
{
$this->deliveryFirmNotice5 = $deliveryFirmNotice5;
}
public function getDeliveryFirmNotice6(): ?int
{
return $this->deliveryFirmNotice6;
}
public function setDeliveryFirmNotice6(?int $deliveryFirmNotice6): void
{
$this->deliveryFirmNotice6 = $deliveryFirmNotice6;
}
public function getDeliveryFirmNotice7(): ?int
{
return $this->deliveryFirmNotice7;
}
public function setDeliveryFirmNotice7(?int $deliveryFirmNotice7): void
{
$this->deliveryFirmNotice7 = $deliveryFirmNotice7;
}
public function getDeliveryNoticesNotAplicable(): ?bool
{
return $this->deliveryNoticesNotAplicable;
}
public function setDeliveryNoticesNotAplicable(?bool $deliveryNoticesNotAplicable): void
{
$this->deliveryNoticesNotAplicable = $deliveryNoticesNotAplicable;
}
public function getShipDelivered(): ?bool
{
return $this->shipDelivered;
}
public function setShipDelivered(?bool $shipDelivered): void
{
$this->shipDelivered = $shipDelivered;
}
public function getDeliveryPort1(): ?Port
{
return $this->deliveryPort1;
}
public function setDeliveryPort1(?Port $deliveryPort1): void
{
$this->deliveryPort1 = $deliveryPort1;
}
public function getDeliveryPort2(): ?Port
{
return $this->deliveryPort2;
}
public function setDeliveryPort2(?Port $deliveryPort2): void
{
$this->deliveryPort2 = $deliveryPort2;
}
public function getHirePerDay(): ?string
{
return $this->hirePerDay;
}
public function setHirePerDay(?string $hirePerDay): void
{
$this->hirePerDay = $hirePerDay;
}
public function getHirePerDayCurrency(): ?string
{
return $this->hirePerDayCurrency;
}
public function setHirePerDayCurrency(?string $hirePerDayCurrency): void
{
$this->hirePerDayCurrency = $hirePerDayCurrency;
}
public function getPeriod(): ?int
{
return $this->period;
}
public function setPeriod(?int $period): void
{
$this->period = $period;
}
public function addDeliveryNotice(DeliveryNotice $deliveryNotice): void
{
$deliveryNotice->setContract($this);
$this->deliveryNotices[] = $deliveryNotice;
}
public function removeDeliveryNotice(DeliveryNotice $deliveryNotice): void
{
$this->deliveryNotices->removeElement($deliveryNotice);
}
public function getDeliveryNotices(): ?Collection
{
return $this->deliveryNotices;
}
public function setReportDescription(?string $reportDescription): void
{
$this->reportDescription = $reportDescription;
}
public function getReportDescription(): ?string
{
return $this->reportDescription;
}
public function getVesselArrivedWithinTheLaycan(): ?bool
{
return $this->vesselArrivedWithinTheLaycan;
}
public function setVesselArrivedWithinTheLaycan(?bool $vesselArrivedWithinTheLaycan): void
{
$this->vesselArrivedWithinTheLaycan = $vesselArrivedWithinTheLaycan;
}
public function getVesselWasSubstituted(): ?bool
{
return $this->vesselWasSubstituted;
}
public function setVesselWasSubstituted(?bool $vesselWasSubstituted): void
{
$this->vesselWasSubstituted = $vesselWasSubstituted;
}
public function getAddendumIssued(): ?bool
{
return $this->addendumIssued;
}
public function setAddendumIssued(?bool $addendumIssued): void
{
$this->addendumIssued = $addendumIssued;
}
public function setAddendumDescription(?string $addendumDescription): void
{
$this->addendumDescription = $addendumDescription;
}
public function getAddendumDescription(): ?string
{
return $this->addendumDescription;
}
public function setContractCoa(?Contract $contract): void
{
$this->contractCoa = $contract;
}
public function getContractCoa(): ?Contract
{
return $this->contractCoa;
}
public function getCargoVolumeM3(): ?string
{
$totalVolume = 0.0;
foreach ($this->getCargoItems() as $cargoItem) {
$totalVolume += (float) $cargoItem->getQuantityM3();
}
return number_format($totalVolume, 3, '.', '');
}
public function getCargoVolumeMT(): ?string
{
$totalVolume = 0.0;
foreach ($this->getCargoItems() as $cargoItem) {
$totalVolume += (float) $cargoItem->getQuantityMT();
}
return number_format($totalVolume, 3, '.', '');
}
}