src/Entity/Hire.php line 33

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use ApiPlatform\Core\Annotation\ApiProperty;
  6. use App\Trait\TimestampableEntity;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. use Symfony\Component\Serializer\Annotation\MaxDepth;
  11. use Ramsey\Uuid\Uuid;
  12. use Ramsey\Uuid\UuidInterface;
  13. #[ORM\Entity]
  14. #[ApiResource(
  15.     iri'Hire',
  16.     collectionOperations: [],
  17.     itemOperations: [
  18.         'get' => [
  19.             'security' => "is_granted('ROLE_USER')",
  20.             "method" => "GET",
  21.             "path" => "/contracts/hires/{id}",
  22.             "openapi_context" => [
  23.                 "tags" => ["Contract / Hire"]
  24.             ]
  25.         ]
  26.     ],
  27.     attributes: ["pagination_enabled" => false]
  28. )]
  29. class Hire
  30. {
  31.     use TimestampableEntity;
  32.     // public const INVOICE_STATUS_AWAITING_INVOICE = 'AWAITING_INVOICE';
  33.     // public const INVOICE_STATUS_AWAITING_PAYMENT = 'AWAITING_PAYMENT';
  34.     // public const INVOICE_STATUS_PAID = 'PAID';
  35.     // public const INVOICE_STATUS_CANCELED = 'CANCELED';
  36.     // public const INVOICE_STATUSES = [
  37.     //     self::INVOICE_STATUS_AWAITING_INVOICE,
  38.     //     self::INVOICE_STATUS_AWAITING_PAYMENT,
  39.     //     self::INVOICE_STATUS_PAID,
  40.     //     self::INVOICE_STATUS_CANCELED,
  41.     // ];
  42.     public const INVOICE_STATUS_INVOICED 'INVOICED';
  43.     public const INVOICE_STATUS_NOT_INVOICED 'NOT_INVOICED';
  44.     public const INVOICE_STATUS_PAID 'PAID';
  45.     public const INVOICE_STATUS_CANCELED 'CANCELED';
  46.    
  47.     public const INVOICE_STATUSES = [
  48.         self::INVOICE_STATUS_INVOICED,
  49.         self::INVOICE_STATUS_NOT_INVOICED,
  50.         self::INVOICE_STATUS_PAID,
  51.         self::INVOICE_STATUS_CANCELED,
  52.     ];
  53.     
  54.     #[ORM\Id]
  55.     #[ORM\GeneratedValue(strategy'NONE')]
  56.     #[ORM\Column(type'uuid'uniquetrue)]
  57.     private ?UuidInterface $id null;
  58.     #[ORM\Column(type'datetime'nullabletrue)]
  59.     #[ApiProperty()]
  60.     #[Assert\Type(\DateTimeInterface::class)]
  61.     #[Groups([
  62.         'contract:collection:post'
  63.         'contract:item:get'
  64.         'contract:item:put'
  65.     ])]
  66.     private ?\DateTimeInterface $hireBegin null;
  67.     #[ApiProperty()]
  68.     #[Groups(['contract:item:get'])]
  69.     private ?string $hireBeginDate null;
  70.     #[ApiProperty()]
  71.     #[Groups(['contract:item:get'])]
  72.     private ?string $hireBeginTime null;
  73.     #[ORM\Column(type'datetime'nullabletrue)]
  74.     #[ApiProperty()]
  75.     #[Assert\Type(\DateTimeInterface::class)]
  76.     #[Groups([
  77.         'contract:collection:post'
  78.         'contract:item:get'
  79.         'contract:item:put'
  80.     ])]
  81.     private ?\DateTimeInterface $hireEnd null;
  82.     #[ApiProperty()]
  83.     #[Groups(['contract:item:get'])]
  84.     private ?string $hireEndDate null;
  85.     #[ApiProperty()]
  86.     #[Groups(['contract:item:get'])]
  87.     private ?string $hireEndTime null;
  88.     #[ORM\Column(type'string'nullabletrue)]
  89.     #[ApiProperty()]
  90.     #[Assert\Type('string')]
  91.     #[Groups([
  92.         'contract:collection:post'
  93.         'contract:item:get'
  94.         'contract:item:put'
  95.     ])]
  96.     private ?string $fuelType null;
  97.     #[ORM\Column(type'string'nullabletrue)]
  98.     #[ApiProperty()]
  99.     #[Assert\Type('string')]
  100.     #[Groups([
  101.         'contract:collection:post'
  102.         'contract:item:get'
  103.         'contract:item:put'
  104.     ])]
  105.     private ?string $fuelType2 null;
  106.     #[ORM\Column(type'string'nullabletrue)]
  107.     #[ApiProperty()]
  108.     #[Assert\Type('string')]
  109.     #[Groups([
  110.         'contract:collection:post'
  111.         'contract:item:get'
  112.         'contract:item:put'
  113.     ])]
  114.     private ?string $fuelType3 null;
  115.     #[ORM\Column(type'string'nullabletrue)]
  116.     #[ApiProperty()]
  117.     #[Assert\Type('string')]
  118.     #[Groups([
  119.         'contract:collection:post'
  120.         'contract:item:get'
  121.         'contract:item:put'
  122.     ])]
  123.     private ?string $price null;
  124.     #[ORM\Column(type'string'nullabletrue)]
  125.     #[ApiProperty()]
  126.     #[Assert\Type('string')]
  127.     #[Groups([
  128.         'contract:collection:post'
  129.         'contract:item:get'
  130.         'contract:item:put'
  131.     ])]
  132.     private ?string $price2 null;
  133.     #[ORM\Column(type'string'nullabletrue)]
  134.     #[ApiProperty()]
  135.     #[Assert\Type('string')]
  136.     #[Groups([
  137.         'contract:collection:post'
  138.         'contract:item:get'
  139.         'contract:item:put'
  140.     ])]
  141.     private ?string $price3 null;
  142.     #[ORM\Column(type'string'nullabletrue)]
  143.     #[ApiProperty()]
  144.     #[Assert\Type('string')]
  145.     #[Groups([
  146.         'contract:collection:post'
  147.         'contract:item:get'
  148.         'contract:item:put'
  149.     ])]
  150.     private ?string $priceCurrency null;
  151.     #[ORM\Column(type'string'nullabletrue)]
  152.     #[ApiProperty()]
  153.     #[Assert\Type('string')]
  154.     #[Groups([
  155.         'contract:collection:post'
  156.         'contract:item:get'
  157.         'contract:item:put'
  158.     ])]
  159.     private ?string $priceCurrency2 null;
  160.     #[ORM\Column(type'string'nullabletrue)]
  161.     #[ApiProperty()]
  162.     #[Assert\Type('string')]
  163.     #[Groups([
  164.         'contract:collection:post'
  165.         'contract:item:get'
  166.         'contract:item:put'
  167.     ])]
  168.     private ?string $priceCurrency3 null;
  169.     #[ORM\Column(type'boolean'nullabletrue)]
  170.     #[ApiProperty()]
  171.     #[Groups([
  172.         'contract:collection:post'
  173.         'contract:item:get'
  174.         'contract:item:put'
  175.     ])]
  176.     private ?bool $multiFuel false;
  177.     #[ORM\Column(type'float'nullabletrue)]
  178.     #[ApiProperty()]
  179.     #[Assert\Type('float')]
  180.     #[Groups([
  181.         'contract:collection:post'
  182.         'contract:item:get'
  183.         'contract:item:put'
  184.     ])]
  185.     private ?float $hirePeriod null;
  186.     #[ORM\Column(type'boolean'nullabletrue)]
  187.     #[ApiProperty()]
  188.     #[Groups([
  189.         'contract:collection:post'
  190.         'contract:item:get'
  191.         'contract:item:put'
  192.     ])]
  193.     private ?bool $offHire false;
  194.     #[ORM\Column(type'datetime'nullabletrue)]
  195.     #[ApiProperty()]
  196.     #[Assert\Type(\DateTimeInterface::class)]
  197.     #[Groups([
  198.         'contract:collection:post'
  199.         'contract:item:get'
  200.         'contract:item:put'
  201.     ])]
  202.     private ?\DateTimeInterface $offHireBegin null;
  203.     #[ApiProperty()]
  204.     #[Groups(['contract:item:get'])]
  205.     private ?string $offHireBeginDate null;
  206.     #[ApiProperty()]
  207.     #[Groups(['contract:item:get'])]
  208.     private ?string $offHireBeginTime null;
  209.     #[ORM\Column(type'datetime'nullabletrue)]
  210.     #[ApiProperty()]
  211.     #[Assert\Type(\DateTimeInterface::class)]
  212.     #[Groups([
  213.         'contract:collection:post'
  214.         'contract:item:get'
  215.         'contract:item:put'
  216.     ])]
  217.     private ?\DateTimeInterface $offHireEnd null;
  218.     #[ApiProperty()]
  219.     #[Groups(['contract:item:get'])]
  220.     private ?string $offHireEndDate null;
  221.     #[ApiProperty()]
  222.     #[Groups(['contract:item:get'])]
  223.     private ?string $offHireEndTime null;
  224.     #[ORM\Column(type'string'nullabletrue)]
  225.     #[ApiProperty()]
  226.     #[Assert\Type('string')]
  227.     #[Groups([
  228.         'contract:collection:post'
  229.         'contract:item:get'
  230.         'contract:item:put'
  231.     ])]
  232.     private ?string $offHireCost null;
  233.     #[ORM\Column(type'string'nullabletrue)]
  234.     #[ApiProperty()]
  235.     #[Assert\Type('string')]
  236.     #[Groups([
  237.         'contract:collection:post'
  238.         'contract:item:get'
  239.         'contract:item:put'
  240.     ])]
  241.     private ?string $offHireCostCurrency null;
  242.     #[ORM\Column(type'float'nullabletrue)]
  243.     #[ApiProperty()]
  244.     #[Assert\Type('float')]
  245.     #[Groups([
  246.         'contract:collection:post'
  247.         'contract:item:get'
  248.         'contract:item:put'
  249.     ])]
  250.     private ?float $offHirePeriod null;
  251.     // #[ORM\Column(type: 'string', nullable: true)]
  252.     // #[ApiProperty()]
  253.     // #[Assert\Type('string')]
  254.     // #[Groups([
  255.     //     'contract:collection:post', 
  256.     //     'contract:item:get', 
  257.     //     'contract:item:put'
  258.     // ])]
  259.     // private ?string $addressCommission = null;
  260.     #[ORM\Column(type'boolean'nullabletrue)]
  261.     #[ApiProperty()]
  262.     #[Groups([
  263.         'contract:collection:post'
  264.         'contract:item:get'
  265.         'contract:item:put'
  266.     ])]
  267.     private ?bool $extra false;
  268.     
  269.     #[ORM\Column(type'string'nullabletrue)]
  270.     #[ApiProperty()]
  271.     #[Assert\Type('string')]
  272.     #[Groups([
  273.         'contract:collection:post'
  274.         'contract:item:get'
  275.         'contract:item:put'
  276.     ])]
  277.     private ?string $extraCosts null;
  278.     #[ORM\Column(type'string'nullabletrue)]
  279.     #[ApiProperty()]
  280.     #[Assert\Type('string')]
  281.     #[Groups([
  282.         'contract:collection:post'
  283.         'contract:item:get'
  284.         'contract:item:put'
  285.     ])]
  286.     private ?string $extraCostsCurrency null;
  287.     #[ORM\Column(type'string'nullabletrue)]
  288.     #[ApiProperty()]
  289.     #[Assert\Type('string')]
  290.     #[Groups([
  291.         'contract:collection:post'
  292.         'contract:item:get'
  293.         'contract:item:put'
  294.     ])]
  295.     private ?string $extraCostsDescription null;
  296.     #[ORM\Column(type'string'nullabletrue)]
  297.     #[ApiProperty()]
  298.     #[Assert\Type('string')]
  299.     #[Groups([
  300.         'contract:collection:post'
  301.         'contract:item:get'
  302.         'contract:item:put'
  303.     ])]
  304.     private ?string $totalInvoice null;
  305.     #[ORM\Column(type'string'nullabletrue)]
  306.     #[ApiProperty()]
  307.     #[Assert\Type('string')]
  308.     #[Groups([
  309.         'contract:collection:post'
  310.         'contract:item:get'
  311.         'contract:item:put'
  312.     ])]
  313.     private ?string $totalInvoiceCurrency null;
  314.     #[ORM\Column(type'string'nullabletrue)]
  315.     #[ApiProperty()]
  316.     #[Assert\Type('string')]
  317.     #[Assert\Choice(
  318.         choicesself::INVOICE_STATUSES
  319.         message'The status is not valid.'
  320.     )]
  321.     #[Groups([
  322.         'contract:collection:post'
  323.         'contract:item:get'
  324.         'contract:item:put'
  325.     ])]
  326.     private ?string $invoiceStatus self::INVOICE_STATUS_NOT_INVOICED;
  327.     #[ORM\Column(type'boolean'nullabletrue)]
  328.     #[ApiProperty()]
  329.     #[Groups([
  330.         'contract:collection:post'
  331.         'contract:item:get'
  332.         'contract:item:put'
  333.     ])]
  334.     private ?bool $bunker false;
  335.     #[ORM\Column(type'boolean'nullabletrue)]
  336.     #[ApiProperty()]
  337.     #[Groups([
  338.         'contract:collection:post'
  339.         'contract:item:get'
  340.         'contract:item:put'
  341.     ])]
  342.     private ?bool $finalHire false;
  343.     #[ORM\Column(type'integer')]
  344.     #[Assert\NotNull]
  345.     #[ApiProperty()]
  346.     #[Groups([
  347.         'contract:item:get'
  348.         'contract:item:put'
  349.         'contract:collection:get'
  350.         'contract:collection:post'
  351.     ])]
  352.     private ?int $hireIndex 0;
  353.     #[ORM\ManyToOne(
  354.         targetEntityContract::class, 
  355.         inversedBy'hires'
  356.     )]
  357.     #[ORM\JoinColumn(nullabletrue)]
  358.     #[ApiProperty()]
  359.     #[Groups([
  360.         'contract:collection:post'
  361.         'contract:item:get'
  362.         'contract:item:put'
  363.     ])]
  364.     #[MaxDepth(1)]
  365.     private ?Contract $contract null;
  366.     public function __construct()
  367.     {
  368.         $this->id Uuid::uuid4();
  369.     }
  370.     public function getId(): ?UuidInterface
  371.     {
  372.         return $this->id;
  373.     }
  374.     public function getHireBegin(): ?\DateTimeInterface
  375.     {
  376.         return $this->hireBegin;
  377.     }
  378.     public function setHireBegin(?\DateTimeInterface $hireBegin): void
  379.     {
  380.         $this->hireBegin $hireBegin;
  381.     }
  382.     public function getHireBeginDate(): ?string
  383.     {
  384.         return $this->hireBegin $this->hireBegin->format('Y-m-d') : null;
  385.     }
  386.     public function getHireBeginTime(): ?string
  387.     {
  388.         return $this->hireBegin $this->hireBegin->format('H:i') : null;
  389.     }
  390.     public function getHireEnd(): ?\DateTimeInterface
  391.     {
  392.         return $this->hireEnd;
  393.     }
  394.     public function setHireEnd(?\DateTimeInterface $hireEnd): void
  395.     {
  396.         $this->hireEnd $hireEnd;
  397.     }
  398.     public function getHireEndDate(): ?string
  399.     {
  400.         return $this->hireEnd $this->hireEnd->format('Y-m-d') : null;
  401.     }
  402.     public function getHireEndTime(): ?string
  403.     {
  404.         return $this->hireEnd $this->hireEnd->format('H:i') : null;
  405.     }
  406.     public function getFuelType(): ?string
  407.     {
  408.         return $this->fuelType;
  409.     }
  410.     public function setFuelType(?string $fuelType): void
  411.     {
  412.         $this->fuelType $fuelType;
  413.     }
  414.     public function getFuelType2(): ?string
  415.     {
  416.         return $this->fuelType2;
  417.     }
  418.     public function setFuelType2(?string $fuelType2): void
  419.     {
  420.         $this->fuelType2 $fuelType2;
  421.     }
  422.     public function getFuelType3(): ?string
  423.     {
  424.         return $this->fuelType3;
  425.     }
  426.     public function setFuelType3(?string $fuelType3): void
  427.     {
  428.         $this->fuelType3 $fuelType3;
  429.     }
  430.     public function getPrice(): ?string
  431.     {
  432.         return $this->price;
  433.     }
  434.     public function setPrice(?string $price): void
  435.     {
  436.         $this->price $price;
  437.     }
  438.     
  439.     public function getPrice2(): ?string
  440.     {
  441.         return $this->price2;
  442.     }
  443.     public function setPrice2(?string $price2): void
  444.     {
  445.         $this->price2 $price2;
  446.     }
  447.     
  448.     public function getPrice3(): ?string
  449.     {
  450.         return $this->price3;
  451.     }
  452.     public function setPrice3(?string $price3): void
  453.     {
  454.         $this->price3 $price3;
  455.     }
  456.     
  457.     public function getPriceCurrency(): ?string
  458.     {
  459.         return $this->priceCurrency;
  460.     }
  461.     public function setPriceCurrency(?string $priceCurrency): void
  462.     {
  463.         $this->priceCurrency $priceCurrency;
  464.     }
  465.     public function getPriceCurrency2(): ?string
  466.     {
  467.         return $this->priceCurrency2;
  468.     }
  469.     public function setPriceCurrency2(?string $priceCurrency2): void
  470.     {
  471.         $this->priceCurrency2 $priceCurrency2;
  472.     }
  473.     
  474.     public function getPriceCurrency3(): ?string
  475.     {
  476.         return $this->priceCurrency3;
  477.     }
  478.     public function setPriceCurrency3(?string $priceCurrency3): void
  479.     {
  480.         $this->priceCurrency3 $priceCurrency3;
  481.     }
  482.     public function getMultiFuel(): ?bool
  483.     {
  484.         return $this->multiFuel ?? false;
  485.     }
  486.     public function setMultiFuel(?bool $multiFuel): void
  487.     {
  488.         $this->multiFuel $multiFuel;
  489.     }
  490.     public function getHirePeriod(): ?float
  491.     {
  492.         return $this->hirePeriod;
  493.     }
  494.     public function setHirePeriod(?float $hirePeriod): void
  495.     {
  496.         $this->hirePeriod $hirePeriod;
  497.     }
  498.     
  499.     public function setOffHireBegin(?\DateTimeInterface $offHireBegin): void
  500.     {
  501.         $this->offHireBegin $offHireBegin;
  502.     }
  503.     public function getOffHireBegin(): ?\DateTimeInterface
  504.     {
  505.         return $this->offHireBegin;
  506.     }
  507.     public function getOffHireBeginDate(): ?string
  508.     {
  509.         return $this->offHireBegin $this->offHireBegin->format('Y-m-d') : null;
  510.     }
  511.     public function getOffHireBeginTime(): ?string
  512.     {
  513.         return $this->offHireBegin $this->offHireBegin->format('H:i') : null;
  514.     }
  515.     public function setOffHireEnd(?\DateTimeInterface $offHireEnd): void
  516.     {
  517.         $this->offHireEnd $offHireEnd;
  518.     }
  519.     public function getOffHireEnd(): ?\DateTimeInterface
  520.     {
  521.         return $this->offHireEnd;
  522.     }
  523.     public function getOffHireEndDate(): ?string
  524.     {
  525.         return $this->offHireEnd $this->offHireEnd->format('Y-m-d') : null;
  526.     }
  527.     public function getOffHireEndTime(): ?string
  528.     {
  529.         return $this->offHireEnd $this->offHireEnd->format('H:i') : null;
  530.     }
  531.     public function getOffHireCost(): ?string
  532.     {
  533.         return $this->offHireCost;
  534.     }
  535.     public function setOffHireCost(?string $offHireCost): void
  536.     {
  537.         $this->offHireCost $offHireCost;
  538.     }
  539.     public function getOffHireCostCurrency(): ?string
  540.     {
  541.         return $this->offHireCostCurrency;
  542.     }
  543.     public function setOffHireCostCurrency(?string $offHireCostCurrency): void
  544.     {
  545.         $this->offHireCostCurrency $offHireCostCurrency;
  546.     }
  547.     public function getOffHirePeriod(): ?float
  548.     {
  549.         return $this->offHirePeriod;
  550.     }
  551.     public function setOffHirePeriod(?float $offHirePeriod): void
  552.     {
  553.         $this->offHirePeriod $offHirePeriod;
  554.     }
  555.     // public function getAddressCommission(): ?string
  556.     // {
  557.     //     return $this->addressCommission;
  558.     // }
  559.     // public function setAddressCommission(?string $addressCommission): void
  560.     // {
  561.     //     $this->addressCommission = $addressCommission;
  562.     // }
  563.     public function getExtraCosts(): ?string
  564.     {
  565.         return $this->extraCosts;
  566.     }
  567.     public function setExtraCosts(?string $extraCosts): void
  568.     {
  569.         $this->extraCosts $extraCosts;
  570.     }
  571.     public function getExtraCostsCurrency(): ?string
  572.     {
  573.         return $this->extraCostsCurrency;
  574.     }
  575.     public function setExtraCostsCurrency(?string $extraCostsCurrency): void
  576.     {
  577.         $this->extraCostsCurrency $extraCostsCurrency;
  578.     }
  579.     public function getExtraCostsDescription(): ?string
  580.     {
  581.         return $this->extraCostsDescription;
  582.     }
  583.     public function setExtraCostsDescription(?string $extraCostsDescription): void
  584.     {
  585.         $this->extraCostsDescription $extraCostsDescription;
  586.     }
  587.     public function getTotalInvoice(): ?string
  588.     {
  589.         return $this->totalInvoice;
  590.     }
  591.     public function setTotalInvoice(?string $totalInvoice): void
  592.     {
  593.         $this->totalInvoice $totalInvoice;
  594.     }
  595.     public function getTotalInvoiceCurrency(): ?string
  596.     {
  597.         return $this->totalInvoiceCurrency;
  598.     }
  599.     public function setTotalInvoiceCurrency(?string $totalInvoiceCurrency): void
  600.     {
  601.         $this->totalInvoiceCurrency $totalInvoiceCurrency;
  602.     }
  603.     public function getInvoiceStatus(): ?string
  604.     {
  605.         return $this->invoiceStatus;
  606.     }
  607.     public function setInvoiceStatus(?string $invoiceStatus): void
  608.     {
  609.         $this->invoiceStatus $invoiceStatus;
  610.     }
  611.     public function getBunker(): ?bool
  612.     {
  613.         return $this->bunker ?? false;
  614.     }
  615.     public function setBunker(?bool $bunker): void
  616.     {
  617.         $this->bunker $bunker;
  618.     }
  619.     public function getFinalHire(): ?bool
  620.     {
  621.         return $this->finalHire ?? false;
  622.     }
  623.     public function setFinalHire(?bool $finalHire): void
  624.     {
  625.         $this->finalHire $finalHire;
  626.     }
  627.     public function setHireIndex(?int $hireIndex): void
  628.     {
  629.         $this->hireIndex $hireIndex;
  630.     }
  631.     public function getHireIndex(): ?int
  632.     {
  633.         return $this->hireIndex;
  634.     }
  635.     public function setContract(?Contract $contract): void
  636.     {
  637.         $this->contract $contract;
  638.     }
  639.     public function getContract(): ?Contract
  640.     {
  641.         return $this->contract;
  642.     }
  643.     public function getOffHire(): ?bool
  644.     {
  645.         return $this->offHire ?? false;
  646.     }
  647.     public function setOffHire(?bool $offHire): void
  648.     {
  649.         $this->offHire $offHire;
  650.     }
  651.     public function getExtra(): ?bool
  652.     {
  653.         return $this->extra ?? false;
  654.     }
  655.     public function setExtra(?bool $extra): void
  656.     {
  657.         $this->extra $extra;
  658.     }
  659. }