<?php
// @deprecated
declare(strict_types=1);
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Trait\TimestampableEntity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;
/**
* Represents the commercial conditions for a transaction.
*
* @see https://schema.org/Thing
*/
#[ORM\Entity]
#[ApiResource(
iri: 'CommercialCondition',
itemOperations: [
'get' => ['normalization_context' => ['groups' => 'commercial_condition:item:get', 'enable_max_depth' => true]],
'put' => [
'normalization_context' => ['groups' => 'commercial_condition:item:put', 'enable_max_depth' => true],
'denormalization_context' => ['groups' => 'commercial_condition:item:put', 'enable_max_depth' => true],
],
'delete' => [],
],
collectionOperations: [
'get' => [
'normalization_context' => [
'groups' => ['commercial_condition:collection:get', 'createdAt'],
'enable_max_depth' => true,
],
],
'post' => [
'normalization_context' => ['groups' => 'commercial_condition:collection:post', 'enable_max_depth' => true],
'denormalization_context' => [
'groups' => 'commercial_condition:collection:post',
'enable_max_depth' => true,
],
],
],
)]
class CommercialCondition
{
use TimestampableEntity;
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'NONE')]
#[ORM\Column(type: 'uuid', unique: true)]
private ?UuidInterface $id = null;
/**
* The value of the freight.
*/
#[ORM\Column(type: 'float', nullable: false)]
#[ApiProperty(iri: 'https://schema.org/freightValue')]
#[Assert\NotBlank]
#[Assert\Type('float')]
#[Groups(['commercial_condition:collection:get', 'commercial_condition:collection:post', 'commercial_condition:item:get', 'commercial_condition:item:put'])]
private ?float $freightValue = null;
/**
* The type of freight.
*/
#[ORM\Column(type: 'string', nullable: false)]
#[ApiProperty(iri: 'https://schema.org/freightType')]
#[Assert\NotBlank]
#[Assert\Type('string')]
#[Groups(['commercial_condition:collection:get', 'commercial_condition:collection:post', 'commercial_condition:item:get', 'commercial_condition:item:put'])]
private ?string $freightType = null;
/**
* Additional values associated with the condition.
*/
// #[ORM\ManyToMany(targetEntity: 'App\Entity\AdditionalValue')]
// #[ApiProperty(iri: 'https://schema.org/AdditionalValue')]
// #[Groups(['commercial_condition:collection:get', 'commercial_condition:collection:post', 'commercial_condition:item:get', 'commercial_condition:item:put'])]
// private Collection $additionalValues;
/**
* The daily demurrage value.
*/
#[ORM\Column(type: 'float', nullable: false)]
#[ApiProperty(iri: 'https://schema.org/demurrageValuePerDay')]
#[Assert\NotBlank]
#[Assert\Type('float')]
#[Groups(['commercial_condition:collection:get', 'commercial_condition:collection:post', 'commercial_condition:item:get', 'commercial_condition:item:put'])]
private ?float $demurrageValuePerDay = null;
/**
* The commission associated with the commercial condition.
*/
#[ORM\OneToOne(targetEntity: 'App\Entity\Commission')]
#[ApiProperty(iri: 'https://schema.org/Commission')]
#[ORM\JoinColumn(nullable: false)]
#[Groups(['commercial_condition:collection:get', 'commercial_condition:collection:post', 'commercial_condition:item:get', 'commercial_condition:item:put'])]
private ?Commission $commission = null;
public function __construct()
{
$this->id = Uuid::uuid4();
// $this->additionalValues = new ArrayCollection();
}
public function getId(): ?UuidInterface
{
return $this->id;
}
public function setFreightValue(?float $freightValue): void
{
$this->freightValue = $freightValue;
}
public function getFreightValue(): ?float
{
return $this->freightValue;
}
public function setFreightType(?string $freightType): void
{
$this->freightType = $freightType;
}
public function getFreightType(): ?string
{
return $this->freightType;
}
// public function addAdditionalValue(AdditionalValue $additionalValue): void
// {
// if (!$this->additionalValues->contains($additionalValue)) {
// $this->additionalValues->add($additionalValue);
// }
// }
// public function removeAdditionalValue(AdditionalValue $additionalValue): void
// {
// $this->additionalValues->removeElement($additionalValue);
// }
// public function getAdditionalValues(): Collection
// {
// return $this->additionalValues;
// }
public function setDemurrageValuePerDay(?float $demurrageValuePerDay): void
{
$this->demurrageValuePerDay = $demurrageValuePerDay;
}
public function getDemurrageValuePerDay(): ?float
{
return $this->demurrageValuePerDay;
}
public function setCommission(?Commission $commission): void
{
$this->commission = $commission;
}
public function getCommission(): ?Commission
{
return $this->commission;
}
}