src/Entity/SaleOrderItem.php line 23

Open in your IDE?
  1. <?php
  2.     
  3.     namespace App\Entity;
  4.     
  5.     use App\Repository\SaleOrderItemRepository;
  6.     use App\Traits\DateTrait;
  7.     use Doctrine\Common\Collections\ArrayCollection;
  8.     use Doctrine\Common\Collections\Collection;
  9.     use Doctrine\ORM\Mapping as ORM;
  10.     use JMS\Serializer\Annotation as Serializer;
  11.     use JMS\Serializer\Annotation\Expose;
  12.     use JMS\Serializer\Annotation\Groups;
  13.     use JMS\Serializer\Annotation\SerializedName;
  14.     /**
  15.      * @ORM\Table(indexes={
  16.      *      @ORM\Index(columns={"status"})
  17.      * })
  18.      * @ORM\Entity(repositoryClass=SaleOrderItemRepository::class)
  19.      *
  20.      * @Serializer\ExclusionPolicy("ALL")
  21.      */
  22.     class SaleOrderItem
  23.     {
  24.         use DateTrait;
  25.         
  26.         public const STATUS_PROCESSING    'processing';
  27.         public const STATUS_NOT_CONFIRMED 'not_confirmed';
  28.         public const STATUS_CANCELED      'canceled';
  29.         public const STATUS_SHIPPED       'shipped';
  30.         
  31.         /**
  32.          * @ORM\Id
  33.          * @ORM\GeneratedValue
  34.          * @ORM\Column(type="integer")
  35.          *
  36.          * @Expose
  37.          * @Groups({"get:read", "sale_oder_item:list"})
  38.          */
  39.         private ?int $id NULL;
  40.         
  41.         /**
  42.          * Identifiant unique
  43.          *
  44.          * @ORM\Column(type="string", length=16)
  45.          *
  46.          * @Expose
  47.          * @Groups({"sale_order:item", "sale_oder_item:list", "sale_order:post", "get:read"})
  48.          */
  49.         private ?string $sku NULL;
  50.         
  51.         /**
  52.          * Anciennement '$order' mais c'est un mot reservĂ© (mysql) on ne peut plus l'utiliser
  53.          *
  54.          * @ORM\ManyToOne(targetEntity=SaleOrder::class, inversedBy="items")
  55.          * @ORM\JoinColumn(nullable=false, name="order_id")
  56.          */
  57.         private ?SaleOrder $saleOrder NULL;
  58.         
  59.         /**
  60.          * QuantitĂ©
  61.          *
  62.          * @ORM\Column(type="integer")
  63.          *
  64.          * @Expose
  65.          * @Groups({"sale_order:item", "sale_oder_item:list", "sale_order:post", "get:read","export_order_datatable"})
  66.          */
  67.         private ?int $quantity NULL;
  68.         
  69.         /**
  70.          * @ORM\Column(type="integer", nullable=true)
  71.          *
  72.          * @Expose
  73.          * @Groups({"sale_order:item", "sale_oder_item:list","get:read"})
  74.          */
  75.         private ?int $quantityNoBatch NULL;
  76.         
  77.         /**
  78.          * @ORM\Column(type="string", length=100, options={"default":self::STATUS_PROCESSING})
  79.          *
  80.          * @Expose
  81.          * @Groups({"get:read", "sale_oder_item:list"})
  82.          */
  83.         private string $status self::STATUS_PROCESSING;
  84.         
  85.         /**
  86.          * @ORM\Column(type="string", length=255)
  87.          *
  88.          * @Expose
  89.          * @Groups({"get:read"})
  90.          */
  91.         private ?string $reference NULL;
  92.         
  93.         /**
  94.          * @ORM\Column(type="string", length=255)
  95.          *
  96.          * @Expose
  97.          * @Groups({"sale_order:item", "sale_oder_item:list", "get:read","export_order_datatable"})
  98.          */
  99.         private ?string $name NULL;
  100.         
  101.         /**
  102.          * @ORM\Column(type="text", nullable=true)
  103.          *
  104.          * @Expose
  105.          * @Groups({"get:read"})
  106.          */
  107.         private ?string $description NULL;
  108.         
  109.         /**
  110.          * @ORM\Column(type="string", length=255)
  111.          *
  112.          * @Expose
  113.          * @Groups({"get:read", "sale_oder_item:list"})
  114.          */
  115.         private ?string $gamme NULL;
  116.         
  117.         /**
  118.          * @ORM\Column(type="decimal", precision=12, scale=4, nullable=true)
  119.          *
  120.          * @Expose
  121.          * @Groups({"get:read", "sale_oder_item:list"})
  122.          * @SerializedName ("price_h_t")
  123.          */
  124.         private ?string $priceHT NULL;
  125.         
  126.         /**
  127.          * @ORM\Column(type="decimal", precision=12, scale=4, nullable=true)
  128.          */
  129.         private ?string $priceTTC NULL;
  130.         
  131.         /**
  132.          * @ORM\Column(type="decimal", precision=12, scale=4, nullable=true)
  133.          */
  134.         private ?string $unitPoint NULL;
  135.         
  136.         /**
  137.          * @ORM\Column(type="string", length=255, nullable=true)
  138.          *
  139.          * @Expose
  140.          * @Groups({"get:read"})
  141.          */
  142.         private ?string $imageUrl NULL;
  143.         
  144.         /**
  145.          * @ORM\Column(type="string", length=255, nullable=true)
  146.          */
  147.         private ?string $imageThumbnailUrl NULL;
  148.         
  149.         /**
  150.          * @ORM\Column(type="decimal", precision=12, scale=4, nullable=true)
  151.          *
  152.          * @Expose
  153.          * @Groups({"get:read"})
  154.          */
  155.         private ?string $taxableAmount NULL;
  156.         
  157.         /**
  158.          * @ORM\OneToMany(targetEntity=SaleOrderParticipant::class, mappedBy="saleOrderItem")
  159.          */
  160.         private Collection $participants;
  161.         
  162.         /**
  163.          * @ORM\OneToMany(targetEntity=SaleOrderItemOption::class, mappedBy="item")
  164.          */
  165.         private Collection $options;
  166.         
  167.         /**
  168.          * @ORM\Column(type="text", nullable=true)
  169.          */
  170.         private $categoryValues;
  171.         
  172.         
  173.         public function __construct()
  174.         {
  175.             $this->participants = new ArrayCollection();
  176.             $this->options      = new ArrayCollection();
  177.         }
  178.         
  179.         
  180.         public function __clone()
  181.         {
  182.             if ( $this->id ) {
  183.                 $this->setIdNULL );
  184.                 $this->setSaleOrderNULL );
  185.             }
  186.         }
  187.         
  188.         
  189.         public function __toString()
  190.         {
  191.             return $this->getSku();
  192.         }
  193.         
  194.         
  195.         /*
  196.          * ============================================================================================
  197.          * =============================== FONCTIONS CUSTOM ===========================================
  198.          * ============================================================================================
  199.          */
  200.         
  201.         public function getSku(): ?string
  202.         {
  203.             return $this->sku;
  204.         }
  205.         
  206.         
  207.         public function setSku( ?string $sku ): self
  208.         {
  209.             $this->sku $sku;
  210.             
  211.             return $this;
  212.         }
  213.         
  214.         
  215.         /**
  216.          * @Serializer\VirtualProperty()
  217.          * @Serializer\SerializedName("array_category_values")
  218.          */
  219.         public function getArrayCategoryValues()
  220.         {
  221.             return json_decode$this->categoryValuesTRUE ) ?? [];
  222.         }
  223.         
  224.         
  225.         /**
  226.          * @param string $slug
  227.          * @param int    $value
  228.          *
  229.          * @return $this
  230.          */
  231.         public function modifyValueToCategorystring $slugint $value ): self
  232.         {
  233.             $newArray             $this->getArrayCategoryValues();
  234.             $newArray$slug ]    = $value;
  235.             $this->categoryValues json_encode$newArray );
  236.             
  237.             return $this;
  238.         }
  239.         
  240.         
  241.         /**
  242.          * @param float $multiplication
  243.          *
  244.          * @return $this
  245.          */
  246.         public function multiplicationCategoryValuesfloat $multiplication ): self
  247.         {
  248.             $newArray $this->getArrayCategoryValues();
  249.             
  250.             foreach ( $newArray as $cat => $val ) {
  251.                 $newArray$cat ] = $val $multiplication;
  252.             }
  253.             
  254.             $this->categoryValues json_encode$newArray );
  255.             
  256.             return $this;
  257.         }
  258.         
  259.         
  260.         /*
  261.          * ============================================================================================
  262.          * ============================== FIN FONCTIONS CUSTOM ========================================
  263.          * ============================================================================================
  264.          */
  265.         
  266.         public function getTotalPrice()
  267.         {
  268.             return $this->getQuantity() * $this->getPriceHT();
  269.         }
  270.         
  271.         
  272.         public function getQuantity(): ?int
  273.         {
  274.             return $this->quantity;
  275.         }
  276.         
  277.         
  278.         public function setQuantityint $quantity ): self
  279.         {
  280.             $this->quantity $quantity;
  281.             
  282.             return $this;
  283.         }
  284.         
  285.         
  286.         public function getPriceHT(): ?string
  287.         {
  288.             return $this->priceHT;
  289.         }
  290.         
  291.         
  292.         public function setPriceHT( ?string $priceHT ): self
  293.         {
  294.             $this->priceHT $priceHT;
  295.             
  296.             return $this;
  297.         }
  298.         
  299.         
  300.         public function getTotalPoint()
  301.         {
  302.             return ( $this->unitPoint $this->quantity );
  303.         }
  304.         
  305.         
  306.         public function setId$id )
  307.         {
  308.             $this->id $id;
  309.         }
  310.         
  311.         
  312.         public function getId(): ?int
  313.         {
  314.             return $this->id;
  315.         }
  316.         
  317.         
  318.         public function getQuantityNoBatch(): ?int
  319.         {
  320.             return $this->quantityNoBatch;
  321.         }
  322.         
  323.         
  324.         public function setQuantityNoBatch( ?int $quantityNoBatch ): self
  325.         {
  326.             $this->quantityNoBatch $quantityNoBatch;
  327.             
  328.             return $this;
  329.         }
  330.         
  331.         
  332.         public function getStatus(): string
  333.         {
  334.             return $this->status;
  335.         }
  336.         
  337.         
  338.         public function setStatusstring $status ): self
  339.         {
  340.             $this->status $status;
  341.             
  342.             return $this;
  343.         }
  344.         
  345.         
  346.         public function getReference(): ?string
  347.         {
  348.             return $this->reference;
  349.         }
  350.         
  351.         
  352.         public function setReference( ?string $reference ): self
  353.         {
  354.             $this->reference $reference;
  355.             
  356.             return $this;
  357.         }
  358.         
  359.         
  360.         public function getName(): ?string
  361.         {
  362.             return $this->name;
  363.         }
  364.         
  365.         
  366.         public function setName( ?string $name ): self
  367.         {
  368.             $this->name $name;
  369.             
  370.             return $this;
  371.         }
  372.         
  373.         
  374.         public function getDescription(): ?string
  375.         {
  376.             return $this->description;
  377.         }
  378.         
  379.         
  380.         public function setDescription( ?string $description ): self
  381.         {
  382.             $this->description $description;
  383.             
  384.             return $this;
  385.         }
  386.         
  387.         
  388.         public function getGamme(): ?string
  389.         {
  390.             return $this->gamme;
  391.         }
  392.         
  393.         
  394.         public function setGamme( ?string $gamme ): self
  395.         {
  396.             $this->gamme $gamme;
  397.             
  398.             return $this;
  399.         }
  400.         
  401.         
  402.         public function getPriceTTC(): ?string
  403.         {
  404.             return $this->priceTTC;
  405.         }
  406.         
  407.         
  408.         public function setPriceTTC( ?string $priceTTC ): self
  409.         {
  410.             $this->priceTTC $priceTTC;
  411.             
  412.             return $this;
  413.         }
  414.         
  415.         
  416.         public function getUnitPoint(): ?string
  417.         {
  418.             return $this->unitPoint;
  419.         }
  420.         
  421.         
  422.         public function setUnitPoint( ?string $unitPoint ): self
  423.         {
  424.             $this->unitPoint $unitPoint;
  425.             
  426.             return $this;
  427.         }
  428.         
  429.         
  430.         public function getImageUrl(): ?string
  431.         {
  432.             return $this->imageUrl;
  433.         }
  434.         
  435.         
  436.         public function setImageUrl( ?string $imageUrl ): self
  437.         {
  438.             $this->imageUrl $imageUrl;
  439.             
  440.             return $this;
  441.         }
  442.         
  443.         
  444.         public function getImageThumbnailUrl(): ?string
  445.         {
  446.             return $this->imageThumbnailUrl;
  447.         }
  448.         
  449.         
  450.         public function setImageThumbnailUrl( ?string $imageThumbnailUrl ): self
  451.         {
  452.             $this->imageThumbnailUrl $imageThumbnailUrl;
  453.             
  454.             return $this;
  455.         }
  456.         
  457.         
  458.         public function getTaxableAmount(): ?string
  459.         {
  460.             return $this->taxableAmount;
  461.         }
  462.         
  463.         
  464.         public function setTaxableAmount( ?string $taxableAmount ): self
  465.         {
  466.             $this->taxableAmount $taxableAmount;
  467.             
  468.             return $this;
  469.         }
  470.         
  471.         
  472.         public function getSaleOrder(): ?SaleOrder
  473.         {
  474.             return $this->saleOrder;
  475.         }
  476.         
  477.         
  478.         public function setSaleOrder( ?SaleOrder $saleOrder ): self
  479.         {
  480.             $this->saleOrder $saleOrder;
  481.             
  482.             return $this;
  483.         }
  484.         
  485.         
  486.         /**
  487.          * @return Collection|SaleOrderParticipant[]
  488.          */
  489.         public function getParticipants(): Collection
  490.         {
  491.             return $this->participants;
  492.         }
  493.         
  494.         
  495.         public function addParticipantSaleOrderParticipant $participant ): self
  496.         {
  497.             if ( !$this->participants->contains$participant ) ) {
  498.                 $this->participants[] = $participant;
  499.                 $participant->setSaleOrderItem$this );
  500.             }
  501.             
  502.             return $this;
  503.         }
  504.         
  505.         
  506.         public function removeParticipantSaleOrderParticipant $participant ): self
  507.         {
  508.             if ( $this->participants->removeElement$participant ) ) {
  509.                 // set the owning side to null (unless already changed)
  510.                 if ( $participant->getSaleOrderItem() === $this ) {
  511.                     $participant->setSaleOrderItemNULL );
  512.                 }
  513.             }
  514.             
  515.             return $this;
  516.         }
  517.         
  518.         
  519.         /**
  520.          * @return Collection|SaleOrderItemOption[]
  521.          */
  522.         public function getOptions(): Collection
  523.         {
  524.             return $this->options;
  525.         }
  526.         
  527.         
  528.         public function addOptionSaleOrderItemOption $option ): self
  529.         {
  530.             if ( !$this->options->contains$option ) ) {
  531.                 $this->options[] = $option;
  532.                 $option->setItem$this );
  533.             }
  534.             
  535.             return $this;
  536.         }
  537.         
  538.         
  539.         public function removeOptionSaleOrderItemOption $option ): self
  540.         {
  541.             if ( $this->options->removeElement$option ) ) {
  542.                 // set the owning side to null (unless already changed)
  543.                 if ( $option->getItem() === $this ) {
  544.                     $option->setItemNULL );
  545.                 }
  546.             }
  547.             
  548.             return $this;
  549.         }
  550.         
  551.         
  552.         public function getCategoryValues(): ?string
  553.         {
  554.             return $this->categoryValues;
  555.         }
  556.         
  557.         
  558.         public function setCategoryValues( ?string $categoryValues ): self
  559.         {
  560.             $this->categoryValues $categoryValues;
  561.             
  562.             return $this;
  563.         }
  564.         
  565.     }