src/Entity/CommercialCondition.php line 52

Open in your IDE?
  1. <?php
  2. // @deprecated
  3. declare(strict_types=1);
  4. namespace App\Entity;
  5. use ApiPlatform\Core\Annotation\ApiProperty;
  6. use ApiPlatform\Core\Annotation\ApiResource;
  7. use App\Trait\TimestampableEntity;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\Common\Collections\Collection;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Symfony\Component\Serializer\Annotation\Groups;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. use Ramsey\Uuid\Uuid;
  14. use Ramsey\Uuid\UuidInterface;
  15. /**
  16.  * Represents the commercial conditions for a transaction.
  17.  *
  18.  * @see https://schema.org/Thing
  19.  */
  20. #[ORM\Entity]
  21. #[ApiResource(
  22.     iri'CommercialCondition',
  23.     itemOperations: [
  24.         'get' => ['normalization_context' => ['groups' => 'commercial_condition:item:get''enable_max_depth' => true]],
  25.         'put' => [
  26.             'normalization_context' => ['groups' => 'commercial_condition:item:put''enable_max_depth' => true],
  27.             'denormalization_context' => ['groups' => 'commercial_condition:item:put''enable_max_depth' => true],
  28.         ],
  29.         'delete' => [],
  30.     ],
  31.     collectionOperations: [
  32.         'get' => [
  33.             'normalization_context' => [
  34.                 'groups' => ['commercial_condition:collection:get''createdAt'],
  35.                 'enable_max_depth' => true,
  36.             ],
  37.         ],
  38.         'post' => [
  39.             'normalization_context' => ['groups' => 'commercial_condition:collection:post''enable_max_depth' => true],
  40.             'denormalization_context' => [
  41.                 'groups' => 'commercial_condition:collection:post',
  42.                 'enable_max_depth' => true,
  43.             ],
  44.         ],
  45.     ],
  46. )]
  47. class CommercialCondition
  48. {
  49.     use TimestampableEntity;
  50.     
  51.     #[ORM\Id]
  52.     #[ORM\GeneratedValue(strategy'NONE')]
  53.     #[ORM\Column(type'uuid'uniquetrue)]
  54.     private ?UuidInterface $id null;
  55.     /**
  56.      * The value of the freight.
  57.      */
  58.     #[ORM\Column(type'float'nullablefalse)]
  59.     #[ApiProperty(iri'https://schema.org/freightValue')]
  60.     #[Assert\NotBlank]
  61.     #[Assert\Type('float')]
  62.     #[Groups(['commercial_condition:collection:get''commercial_condition:collection:post''commercial_condition:item:get''commercial_condition:item:put'])]
  63.     private ?float $freightValue null;
  64.     /**
  65.      * The type of freight.
  66.      */
  67.     #[ORM\Column(type'string'nullablefalse)]
  68.     #[ApiProperty(iri'https://schema.org/freightType')]
  69.     #[Assert\NotBlank]
  70.     #[Assert\Type('string')]
  71.     #[Groups(['commercial_condition:collection:get''commercial_condition:collection:post''commercial_condition:item:get''commercial_condition:item:put'])]
  72.     private ?string $freightType null;
  73.     /**
  74.      * Additional values associated with the condition.
  75.      */
  76.     // #[ORM\ManyToMany(targetEntity: 'App\Entity\AdditionalValue')]
  77.     // #[ApiProperty(iri: 'https://schema.org/AdditionalValue')]
  78.     // #[Groups(['commercial_condition:collection:get', 'commercial_condition:collection:post', 'commercial_condition:item:get', 'commercial_condition:item:put'])]
  79.     // private Collection $additionalValues;
  80.     /**
  81.      * The daily demurrage value.
  82.      */
  83.     #[ORM\Column(type'float'nullablefalse)]
  84.     #[ApiProperty(iri'https://schema.org/demurrageValuePerDay')]
  85.     #[Assert\NotBlank]
  86.     #[Assert\Type('float')]
  87.     #[Groups(['commercial_condition:collection:get''commercial_condition:collection:post''commercial_condition:item:get''commercial_condition:item:put'])]
  88.     private ?float $demurrageValuePerDay null;
  89.     /**
  90.      * The commission associated with the commercial condition.
  91.      */
  92.     #[ORM\OneToOne(targetEntity'App\Entity\Commission')]
  93.     #[ApiProperty(iri'https://schema.org/Commission')]
  94.     #[ORM\JoinColumn(nullablefalse)]
  95.     #[Groups(['commercial_condition:collection:get''commercial_condition:collection:post''commercial_condition:item:get''commercial_condition:item:put'])]
  96.     private ?Commission $commission null;
  97.     public function __construct()
  98.     {
  99.         $this->id Uuid::uuid4();
  100.         // $this->additionalValues = new ArrayCollection();
  101.     }
  102.     public function getId(): ?UuidInterface
  103.     {
  104.         return $this->id;
  105.     }
  106.     public function setFreightValue(?float $freightValue): void
  107.     {
  108.         $this->freightValue $freightValue;
  109.     }
  110.     public function getFreightValue(): ?float
  111.     {
  112.         return $this->freightValue;
  113.     }
  114.     public function setFreightType(?string $freightType): void
  115.     {
  116.         $this->freightType $freightType;
  117.     }
  118.     public function getFreightType(): ?string
  119.     {
  120.         return $this->freightType;
  121.     }
  122.     // public function addAdditionalValue(AdditionalValue $additionalValue): void
  123.     // {
  124.     //     if (!$this->additionalValues->contains($additionalValue)) {
  125.     //         $this->additionalValues->add($additionalValue);
  126.     //     }
  127.     // }
  128.     // public function removeAdditionalValue(AdditionalValue $additionalValue): void
  129.     // {
  130.     //     $this->additionalValues->removeElement($additionalValue);
  131.     // }
  132.     // public function getAdditionalValues(): Collection
  133.     // {
  134.     //     return $this->additionalValues;
  135.     // }
  136.     public function setDemurrageValuePerDay(?float $demurrageValuePerDay): void
  137.     {
  138.         $this->demurrageValuePerDay $demurrageValuePerDay;
  139.     }
  140.     public function getDemurrageValuePerDay(): ?float
  141.     {
  142.         return $this->demurrageValuePerDay;
  143.     }
  144.     public function setCommission(?Commission $commission): void
  145.     {
  146.         $this->commission $commission;
  147.     }
  148.     public function getCommission(): ?Commission
  149.     {
  150.         return $this->commission;
  151.     }
  152. }