src/Flexy/ShopBundle/Entity/Shipping/ShippingMethod.php line 22

  1. <?php
  2. namespace App\Flexy\ShopBundle\Entity\Shipping;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Flexy\ShopBundle\Entity\Order\Order;
  5. use App\Flexy\ShopBundle\Entity\Customer\CustomerGroup;
  6. use App\Flexy\ShopBundle\Entity\Taxes\ShippingTax;
  7. use App\Flexy\ShopBundle\Entity\Taxes\ValueAddedTax;
  8. use App\Repository\Flexy\ShopBundle\Entity\Shipping\ShippingRepository;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\Common\Collections\Collection;
  11. use App\Flexy\ShopBundle\Entity\Shipping\ShippingVehicleType;
  12. use Doctrine\ORM\Mapping as ORM;
  13. use Symfony\Component\Validator\Constraints as Assert;
  14. use Gedmo\Mapping\Annotation as Gedmo;
  15. use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity;
  16. #[ApiResource]
  17. #[ORM\Entity(repositoryClassShippingRepository::class)]
  18. #[Gedmo\SoftDeleteable(fieldName'deletedAt'timeAwarefalsehardDeletetrue)]
  19. class ShippingMethod implements \Stringable
  20. {
  21.     use SoftDeleteableEntity;
  22.     
  23.     #[ORM\Id]
  24.     #[ORM\GeneratedValue]
  25.     #[ORM\Column(type'integer')]
  26.     private $id;
  27.     #[ORM\Column(type'string'length255)]
  28.     private ?string $name null;
  29.     #[ORM\Column(type'text'nullabletrue)]
  30.     private ?string $description null;
  31.     #[ORM\Column(type'string'length255)]
  32.     private string $code "SHIP001";
  33.     #[ORM\Column(type'boolean'nullabletrue)]
  34.     private ?bool $isEnabled null;
  35.     #[ORM\Column(type'datetime_immutable'nullabletrue)]
  36.     private ?\DateTimeImmutable $createdAt null;
  37.     #[ORM\OneToMany(targetEntityShipment::class, mappedBy'method')]
  38.     private \Doctrine\Common\Collections\Collection|array $shippments;
  39.     #[ORM\Column(type'integer'nullabletrue)]
  40.     private ?int $processingDuration null;
  41.     #[ORM\Column(type'float'nullabletrue)]
  42.     private ?float $preparationDuration null;
  43.     #[ORM\Column(type'float'nullabletrue)]
  44.     private ?float $shippingDuration null;
  45.     #[ORM\Column(type'float'nullabletrue)]
  46.     private ?float $price null;
  47.     #[ORM\OneToMany(targetEntityShippingRule::class, mappedBy'shippingMethod'cascade: ['persist''remove'])]
  48.     #[Assert\Valid()]
  49.     private \Doctrine\Common\Collections\Collection|array $shippingRules;
  50.     #[ORM\OneToMany(targetEntityOrder::class, mappedBy'shippingMethod')]
  51.     private \Doctrine\Common\Collections\Collection|array $orders;
  52.     #[ORM\ManyToMany(targetEntityCityRegion::class, inversedBy'shippingMethods')]
  53.     private \Doctrine\Common\Collections\Collection|array $cityRegions;
  54.     #[ORM\ManyToOne(targetEntityShippingVehicleType::class, inversedBy'shippingMethods')]
  55.     #[ORM\JoinColumn(nullabletrue)]
  56.     private $shippingVehicleType;
  57.    #[ORM\ManyToOne(targetEntityCustomerGroup::class, inversedBy'shippingMethods')]
  58.     #[ORM\JoinColumn(nullabletrue)]
  59.     private $customerGroup;
  60.    #[ORM\Column(nullabletrue)]
  61.    private ?bool $isSeparatelyCalculated null;
  62.    #[ORM\Column(nullabletrue)]
  63.    private array $calculationMethod = [];
  64.    #[ORM\ManyToOne]
  65.    private ?ValueAddedTax $taxVAT null;
  66.    #[ORM\ManyToOne]
  67.    private ?ShippingTax $shippingTax null;
  68.    #[ORM\Column(nullabletrue)]
  69.    private ?float $declaredValueTax null;
  70.    #[ORM\Column(nullabletrue)]
  71.    private ?float $papersFees null;
  72.    #[ORM\Column(nullabletrue)]
  73.    private ?float $codCashFees null;
  74.    #[ORM\Column(nullabletrue)]
  75.    private ?float $codCheckOrBillFees null;
  76.    #[ORM\OneToMany(mappedBy'shippingMethod'targetEntityShippingCalculationMethod::class,cascade:["persist","remove"])]
  77.    private Collection $calculationMethods;
  78.    #[ORM\Column(nullabletrue)]
  79.    private ?bool $isTaxesIncludedInPrice null;
  80.     public function __toString(): string
  81.     {
  82.         return (string) $this->name;
  83.     }
  84.     public function __construct()
  85.     {
  86.         $this->shippments = new ArrayCollection();
  87.         $this->shippingRules = new ArrayCollection();
  88.         $this->orders = new ArrayCollection();
  89.         $this->cityRegions = new ArrayCollection();
  90.         $this->calculationMethods = new ArrayCollection();
  91.     }
  92.     public function getId(): ?int
  93.     {
  94.         return $this->id;
  95.     }
  96.     public function getName(): ?string
  97.     {
  98.         return $this->name;
  99.     }
  100.     public function setName(string $name): self
  101.     {
  102.         $this->name $name;
  103.         return $this;
  104.     }
  105.     public function getDescription(): ?string
  106.     {
  107.         return $this->description;
  108.     }
  109.     public function setDescription(?string $description): self
  110.     {
  111.         $this->description $description;
  112.         return $this;
  113.     }
  114.     public function getCode(): ?string
  115.     {
  116.         return $this->code;
  117.     }
  118.     public function setCode(string $code): self
  119.     {
  120.         $this->code $code;
  121.         return $this;
  122.     }
  123.     public function getIsEnabled(): ?bool
  124.     {
  125.         return $this->isEnabled;
  126.     }
  127.     public function setIsEnabled(?bool $isEnabled): self
  128.     {
  129.         $this->isEnabled $isEnabled;
  130.         return $this;
  131.     }
  132.     public function getCreatedAt(): ?\DateTimeImmutable
  133.     {
  134.         return $this->createdAt;
  135.     }
  136.     public function setCreatedAt(?\DateTimeImmutable $createdAt): self
  137.     {
  138.         $this->createdAt $createdAt;
  139.         return $this;
  140.     }
  141.     /**
  142.      * @return Collection|Shipment[]
  143.      */
  144.     public function getShipments(): Collection
  145.     {
  146.         return $this->shippments;
  147.     }
  148.     public function addShipment(Shipment $shippment): self
  149.     {
  150.         if (!$this->shippments->contains($shippment)) {
  151.             $this->shippments[] = $shippment;
  152.             $shippment->setMethod($this);
  153.         }
  154.         return $this;
  155.     }
  156.     public function removeShipment(Shipment $shippment): self
  157.     {
  158.         if ($this->shippments->removeElement($shippment)) {
  159.             // set the owning side to null (unless already changed)
  160.             if ($shippment->getMethod() === $this) {
  161.                 $shippment->setMethod(null);
  162.             }
  163.         }
  164.         return $this;
  165.     }
  166.     public function getProcessingDuration(): ?int
  167.     {
  168.         return $this->processingDuration;
  169.     }
  170.     public function setProcessingDuration(?int $processingDuration): self
  171.     {
  172.         $this->processingDuration $processingDuration;
  173.         return $this;
  174.     }
  175.     public function getPreparationDuration(): ?float
  176.     {
  177.         return $this->preparationDuration;
  178.     }
  179.     public function setPreparationDuration(?float $preparationDuration): self
  180.     {
  181.         $this->preparationDuration $preparationDuration;
  182.         return $this;
  183.     }
  184.     public function getShippingDuration(): ?float
  185.     {
  186.         return $this->shippingDuration;
  187.     }
  188.     public function setShippingDuration(?float $shippingDuration): self
  189.     {
  190.         $this->shippingDuration $shippingDuration;
  191.         return $this;
  192.     }
  193.     public function getPrice(): ?float
  194.     {
  195.         return $this->price;
  196.     }
  197.     public function setPrice(?float $price): self
  198.     {
  199.         $this->price $price;
  200.         return $this;
  201.     }
  202.     /**
  203.      * @return Collection<int, ShippingRule>
  204.      */
  205.     public function getShippingRules(): Collection
  206.     {
  207.         return $this->shippingRules;
  208.     }
  209.     public function addShippingRule(ShippingRule $shippingRule): self
  210.     {
  211.         if (!$this->shippingRules->contains($shippingRule)) {
  212.             $this->shippingRules[] = $shippingRule;
  213.             $shippingRule->setShippingMethod($this);
  214.         }
  215.         return $this;
  216.     }
  217.     public function removeShippingRule(ShippingRule $shippingRule): self
  218.     {
  219.         if ($this->shippingRules->removeElement($shippingRule)) {
  220.             // set the owning side to null (unless already changed)
  221.             if ($shippingRule->getShippingMethod() === $this) {
  222.                 $shippingRule->setShippingMethod(null);
  223.             }
  224.         }
  225.         return $this;
  226.     }
  227.     /**
  228.      * @return Collection<int, Order>
  229.      */
  230.     public function getOrders(): Collection
  231.     {
  232.         return $this->orders;
  233.     }
  234.     public function addOrder(Order $order): self
  235.     {
  236.         if (!$this->orders->contains($order)) {
  237.             $this->orders[] = $order;
  238.             $order->setShippingMethod($this);
  239.         }
  240.         return $this;
  241.     }
  242.     public function removeOrder(Order $order): self
  243.     {
  244.         if ($this->orders->removeElement($order)) {
  245.             // set the owning side to null (unless already changed)
  246.             if ($order->getShippingMethod() === $this) {
  247.                 $order->setShippingMethod(null);
  248.             }
  249.         }
  250.         return $this;
  251.     }
  252.     /**
  253.      * @return Collection<int, CityRegion>
  254.      */
  255.     public function getCityRegions(): Collection
  256.     {
  257.         return $this->cityRegions;
  258.     }
  259.     public function addCityRegion(CityRegion $cityRegion): self
  260.     {
  261.         if (!$this->cityRegions->contains($cityRegion)) {
  262.             $this->cityRegions[] = $cityRegion;
  263.             $cityRegion->addShippingMethod($this);
  264.         }
  265.         return $this;
  266.     }
  267.     public function removeCityRegion(CityRegion $cityRegion): self
  268.     {
  269.         if ($this->cityRegions->removeElement($cityRegion)) {
  270.             $cityRegion->removeShippingMethod($this);
  271.         }
  272.         return $this;
  273.     }
  274.     /**
  275.      * Get the value of shippingVehicleType
  276.      */ 
  277.     public function getShippingVehicleType()
  278.     {
  279.         return $this->shippingVehicleType;
  280.     }
  281.     /**
  282.      * Set the value of shippingVehicleType
  283.      *
  284.      * @return  self
  285.      */ 
  286.     public function setShippingVehicleType($shippingVehicleType)
  287.     {
  288.         $this->shippingVehicleType $shippingVehicleType;
  289.         return $this;
  290.     }
  291.     /**
  292.      * Get the value of customerGroup
  293.      */ 
  294.     public function getCustomerGroup()
  295.     {
  296.         return $this->customerGroup;
  297.     }
  298.     /**
  299.      * Set the value of customerGroup
  300.      *
  301.      * @return  self
  302.      */ 
  303.     public function setCustomerGroup($customerGroup)
  304.     {
  305.         $this->customerGroup $customerGroup;
  306.         return $this;
  307.     }
  308.     public function isIsSeparatelyCalculated(): ?bool
  309.     {
  310.         return $this->isSeparatelyCalculated;
  311.     }
  312.     public function setIsSeparatelyCalculated(?bool $isSeparatelyCalculated): self
  313.     {
  314.         $this->isSeparatelyCalculated $isSeparatelyCalculated;
  315.         return $this;
  316.     }
  317.     public function getCalculationMethod(): array
  318.     {
  319.         return $this->calculationMethod;
  320.     }
  321.     public function setCalculationMethod(?array $calculationMethod): self
  322.     {
  323.         $this->calculationMethod $calculationMethod;
  324.         return $this;
  325.     }
  326.     public function getTaxVAT(): ?ValueAddedTax
  327.     {
  328.         return $this->taxVAT;
  329.     }
  330.     public function setTaxVAT(?ValueAddedTax $taxVAT): self
  331.     {
  332.         $this->taxVAT $taxVAT;
  333.         return $this;
  334.     }
  335.     public function getShippingTax(): ?ShippingTax
  336.     {
  337.         return $this->shippingTax;
  338.     }
  339.     public function setShippingTax(?ShippingTax $shippingTax): self
  340.     {
  341.         $this->shippingTax $shippingTax;
  342.         return $this;
  343.     }
  344.     public function getDeclaredValueTax(): ?float
  345.     {
  346.         return $this->declaredValueTax;
  347.     }
  348.     public function setDeclaredValueTax(?float $declaredValueTax): self
  349.     {
  350.         $this->declaredValueTax $declaredValueTax;
  351.         return $this;
  352.     }
  353.     public function getPapersFees(): ?float
  354.     {
  355.         return $this->papersFees;
  356.     }
  357.     public function setPapersFees(?float $papersFees): self
  358.     {
  359.         $this->papersFees $papersFees;
  360.         return $this;
  361.     }
  362.     public function getCodCashFees(): ?float
  363.     {
  364.         return $this->codCashFees;
  365.     }
  366.     public function setCodCashFees(?float $codCashFees): self
  367.     {
  368.         $this->codCashFees $codCashFees;
  369.         return $this;
  370.     }
  371.     public function getCodCheckOrBillFees(): ?float
  372.     {
  373.         return $this->codCheckOrBillFees;
  374.     }
  375.     public function setCodCheckOrBillFees(?float $codCheckOrBillFees): self
  376.     {
  377.         $this->codCheckOrBillFees $codCheckOrBillFees;
  378.         return $this;
  379.     }
  380.     /**
  381.      * @return Collection<int, ShippingCalculationMethod>
  382.      */
  383.     public function getCalculationMethods(): Collection
  384.     {
  385.         return $this->calculationMethods;
  386.     }
  387.     public function addCalculationMethod(ShippingCalculationMethod $calculationMethod): self
  388.     {
  389.         if (!$this->calculationMethods->contains($calculationMethod)) {
  390.             $this->calculationMethods->add($calculationMethod);
  391.             $calculationMethod->setShippingMethod($this);
  392.         }
  393.         return $this;
  394.     }
  395.     public function removeCalculationMethod(ShippingCalculationMethod $calculationMethod): self
  396.     {
  397.         if ($this->calculationMethods->removeElement($calculationMethod)) {
  398.             // set the owning side to null (unless already changed)
  399.             if ($calculationMethod->getShippingMethod() === $this) {
  400.                 $calculationMethod->setShippingMethod(null);
  401.             }
  402.         }
  403.         return $this;
  404.     }
  405.     public function isIsTaxesIncludedInPrice(): ?bool
  406.     {
  407.         return $this->isTaxesIncludedInPrice;
  408.     }
  409.     public function setIsTaxesIncludedInPrice(?bool $isTaxesIncludedInPrice): self
  410.     {
  411.         $this->isTaxesIncludedInPrice $isTaxesIncludedInPrice;
  412.         return $this;
  413.     }
  414. }