src/Entity/SaleOrder.php line 25

Open in your IDE?
  1. <?php
  2.     namespace App\Entity;
  3.     use App\Repository\SaleOrderRepository;
  4.     use App\Traits\DateTrait;
  5.     use Doctrine\Common\Collections\ArrayCollection;
  6.     use Doctrine\Common\Collections\Collection;
  7.     use Doctrine\ORM\Mapping as ORM;
  8.     use JMS\Serializer\Annotation as Serializer;
  9.     use JMS\Serializer\Annotation\Expose;
  10.     use JMS\Serializer\Annotation\Groups;
  11.     use JMS\Serializer\Annotation\SerializedName;
  12.     use ReflectionClass;
  13.     /**
  14.      * @ORM\Entity(repositoryClass=SaleOrderRepository::class)
  15.      * @ORM\Table(indexes={
  16.      *      @ORM\Index(columns={"status"})
  17.      * })
  18.      *
  19.      * @Serializer\ExclusionPolicy("ALL")
  20.      */
  21.     class SaleOrder
  22.     {
  23.         use DateTrait;
  24.         /**
  25.          * Identifiant interne auto incrémenté
  26.          *
  27.          * @ORM\Id
  28.          * @ORM\GeneratedValue
  29.          * @ORM\Column(type="integer")
  30.          *
  31.          * @Expose
  32.          * @Groups({
  33.          *     "sale_order:id",
  34.          *     "sale_order:list",
  35.          *     "sale_order:updated",
  36.          *     "sale_order:item",
  37.          *     "sale_order",
  38.          *     "get:read",
  39.          *     "post:read",
  40.          *     "export_order_datatable"
  41.          * })
  42.          */
  43.         private ?int $id NULL;
  44.         /**
  45.          * Total de la commande HT
  46.          *
  47.          * @ORM\Column(type="decimal", precision=8, scale=2)
  48.          *
  49.          * @Expose
  50.          * @Groups({
  51.          *     "sale_order:list",
  52.          *     "sale_order:updated",
  53.          *     "sale_order:item",
  54.          *     "sale_order",
  55.          *     "get:read",
  56.          *     "export_order_datatable"
  57.          * })
  58.          */
  59.         private float $total 0.00;
  60.         /**
  61.          * Méthode d'expédition
  62.          *
  63.          * @ORM\Column(type="string", length=64, nullable=true)
  64.          *
  65.          * @Expose
  66.          * @Groups({
  67.          *     "sale_order:item",
  68.          *     "sale_order:updated",
  69.          *     "sale_order",
  70.          *     "get:read"
  71.          * })
  72.          */
  73.         private ?string $shippingMethod NULL;
  74.         /**
  75.          * Statut de la commande
  76.          * @ORM\Column(type="string", length=32, options={"default":"pending_processing"})
  77.          *
  78.          * @Expose
  79.          * @Groups({
  80.          *     "sale_order:status",
  81.          *     "sale_order:list",
  82.          *     "sale_order:updated",
  83.          *     "sale_order:item",
  84.          *     "sale_order",
  85.          *     "get:read",
  86.          *     "post:read",
  87.          *     "export_order_datatable"
  88.          * })
  89.          */
  90.         private string $status 'pending_processing';
  91.         /**
  92.          * @ORM\OneToOne(targetEntity=BankReturn::class, cascade={"persist", "remove"})
  93.          */
  94.         private ?BankReturn $bankReturn NULL;
  95.         /**
  96.          * Utilisateur
  97.          *
  98.          * @ORM\ManyToOne(targetEntity=User::class, inversedBy="orders")
  99.          *
  100.          * @Expose
  101.          * @Groups({
  102.          *     "sale_order:user",
  103.          *     "sale_order:item",
  104.          *     "sale_order:post",
  105.          *     "sale_order",
  106.          *     "get:read",
  107.          *     "post:read",
  108.          *     "export_order_datatable"
  109.          * })
  110.          */
  111.         private ?User $user NULL;
  112.         /**
  113.          * Motif d'annulation
  114.          * @ORM\Column(type="text", nullable=true)
  115.          *
  116.          * @Expose
  117.          * @Groups({
  118.          *     "sale_order:item",
  119.          *     "sale_order:updated",
  120.          *     "sale_order"
  121.          * })
  122.          */
  123.         private ?string $cancelMotif NULL;
  124.         /**
  125.          * Prix de la livraison
  126.          *
  127.          * @ORM\Column(type="decimal", precision=8, scale=2)
  128.          *
  129.          * @Expose
  130.          * @Groups({
  131.          *     "sale_order:item",
  132.          *     "sale_order:updated",
  133.          *     "sale_order",
  134.          *     "get:read"
  135.          * })
  136.          */
  137.         private $shippingPrice;
  138.         /**
  139.          * Référence interne
  140.          *
  141.          * @ORM\Column(type="string", length=64, nullable=true)
  142.          *
  143.          * @Expose
  144.          * @Groups({
  145.          *     "sale_order:item",
  146.          *     "sale_order"
  147.          * })
  148.          */
  149.         private ?string $internalReference NULL;
  150.         /**
  151.          * Commentaire
  152.          *
  153.          * @ORM\Column(type="text", nullable=true)
  154.          *
  155.          * @Expose
  156.          * @Groups({
  157.          *     "sale_order:item",
  158.          *     "sale_order",
  159.          *     "get:read"
  160.          * })
  161.          */
  162.         private ?string $comment NULL;
  163.         /**
  164.          * @ORM\Column(type="boolean", options={"default":false})
  165.          *
  166.          * @Expose
  167.          * @Groups({
  168.          *     "sale_order",
  169.          *     "get:read"
  170.          * })
  171.          */
  172.         private bool $isManagedByCustomer FALSE;
  173.         /**
  174.          * @ORM\Column(type="decimal", precision=8, scale=2, nullable=true)
  175.          *
  176.          * @Expose
  177.          * @Groups({
  178.          *     "sale_order",
  179.          *     "sale_order:updated"
  180.          * })
  181.          */
  182.         private $feesOrder;
  183.         /**
  184.          * @ORM\Column(type="decimal", precision=8, scale=2, nullable=true)
  185.          *
  186.          * @Expose
  187.          * @Groups({"sale_order"})
  188.          */
  189.         private $extraCbPayment;
  190.         /**
  191.          * @deprecated NON UTILISÉ
  192.          *
  193.          * @ORM\Column(type="decimal", precision=8, scale=2, nullable=true)
  194.          *
  195.          * @Expose
  196.          * @Groups({"sale_order"})
  197.          */
  198.         private $totalBonusUsed;
  199.         /**
  200.          * @deprecated
  201.          * @ORM\ManyToOne(targetEntity=SaleOrder::class, inversedBy="saleOrders")
  202.          */
  203.         private ?SaleOrder $saleorderGrouped NULL;
  204.         /**
  205.          * @deprecated
  206.          * @ORM\OneToMany(targetEntity=SaleOrder::class, mappedBy="saleorderGrouped")
  207.          */
  208.         private Collection $saleOrders;
  209.         /**
  210.          * @ORM\Column(type="boolean", nullable=true)
  211.          *
  212.          * @Expose
  213.          * @Groups({"sale_order"})
  214.          */
  215.         private ?bool $notBillable NULL;
  216.         /**
  217.          * @ORM\Column(type="array", nullable=true)
  218.          *
  219.          * @Expose
  220.          * @Groups({"sale_order","get:read"})
  221.          */
  222.         private ?array $otherinformations = [];
  223.         /**
  224.          * Adresse de livraison
  225.          *
  226.          * @ORM\OneToOne(targetEntity=SaleOrderAddress::class, orphanRemoval=true, cascade={"persist", "remove"})
  227.          * @ORM\JoinColumn(onDelete="SET NULL")
  228.          *
  229.          * @Expose
  230.          * @Groups({"sale_order:item", "sale_order:post", "get:read"})
  231.          */
  232.         private ?SaleOrderAddress $shippingAddress NULL;
  233.         /**
  234.          * Adresse de facturation
  235.          *
  236.          * @ORM\OneToOne(targetEntity=SaleOrderAddress::class, orphanRemoval=true, cascade={"persist", "remove"})
  237.          * @ORM\JoinColumn(onDelete="SET NULL")
  238.          *
  239.          * @Expose
  240.          * @Groups({"sale_order:item", "sale_order:post", "get:read"})
  241.          */
  242.         private ?SaleOrderAddress $billingAddress NULL;
  243.         /**
  244.          * Liste des produits commandés
  245.          * @ORM\OneToMany(targetEntity=SaleOrderItem::class, mappedBy="saleOrder", cascade={"persist", "remove"})
  246.          *
  247.          * @Expose
  248.          * @Groups({"sale_order:item", "sale_order:post", "get:read", "export_order_datatable"})
  249.          */
  250.         private Collection $items;
  251.         /**
  252.          * @ORM\OneToMany(targetEntity=SaleOrderShipment::class, mappedBy="saleOrder", cascade={"remove"})
  253.          *
  254.          * @Expose
  255.          * @Groups({
  256.          *     "sale_order",
  257.          *     "sale_order:updated",
  258.          *     "get:read",
  259.          *     "export_order_datatable"
  260.          * })
  261.          */
  262.         private Collection $shipments;
  263.         /**
  264.          * @ORM\OneToOne(targetEntity=Cart::class, inversedBy="saleOrder", cascade={"persist", "remove"})
  265.          */
  266.         private ?Cart $cart NULL;
  267.         /**
  268.          * @ORM\OneToMany(targetEntity=PointTransaction::class, mappedBy="saleOrder", cascade={"remove"})
  269.          */
  270.         private Collection $pointTransactions;
  271.         /**
  272.          * @ORM\Column(type="integer", nullable=true)
  273.          */
  274.         private ?int $oldId NULL;
  275.         /**
  276.          * @ORM\OneToOne(targetEntity=SaleOrderInvoice::class, inversedBy="saleOrder", cascade={"persist", "remove"})
  277.          */
  278.         private ?SaleOrderInvoice $invoice NULL;
  279.         /**
  280.          * @ORM\Column(type="text", nullable=true)
  281.          */
  282.         private $categoryValues;
  283.         /**
  284.          * @ORM\Column(type="string", length=255, nullable=true)
  285.          */
  286.         private $customQuestion;
  287.         /**
  288.          * @ORM\Column(type="float", nullable=true)
  289.          */
  290.         private $orderRate;
  291.         /**
  292.          * @ORM\Column(type="boolean", options={"default":false})
  293.          */
  294.         private bool $isTrip FALSE;
  295.         // virtual property
  296.         private ?string $agency null;
  297.         public function __construct()
  298.         {
  299.             $this->saleOrders        = new ArrayCollection();
  300.             $this->items             = new ArrayCollection();
  301.             $this->shipments         = new ArrayCollection();
  302.             $this->pointTransactions = new ArrayCollection();
  303.         }
  304.         public static function getStatuses()
  305.         {
  306.             $statuses = [];
  307.             $reflect  = new ReflectionClassSaleOrder::class );
  308.             foreach ( $reflect->getConstants() as $k => $const ) {
  309.                 if ( preg_match"/^(STATUS)/"$k ) ) {
  310.                     $statuses$const ] = 'capsule.order.status.' $const;
  311.                 }
  312.             }
  313.             return $statuses;
  314.         }
  315.         /**
  316.          * Retourne la société de l'admin adhérent (spécial algorel)
  317.          *
  318.          * @Serializer\VirtualProperty()
  319.          * @SerializedName("agency")
  320.          * @Expose()
  321.          * @Groups({"get:read"})
  322.          *
  323.          */
  324.         public function getAgency(): ?string
  325.         {
  326.             return $this->agency;
  327.         }
  328.         public function setAgency( ?string $agency ): self
  329.         {
  330.             $this->agency $agency;
  331.             return $this;
  332.         }
  333.         /**
  334.          * Retourne le cumul des produits + frais de port + frais de commande
  335.          *
  336.          * @Serializer\VirtualProperty()
  337.          * @SerializedName("totalAmount")
  338.          * @Expose()
  339.          * @Groups({"sale_order","sale_order:item", "sale_order:post", "get:read", "export_order_datatable"})
  340.          *
  341.          * @return float
  342.          */
  343.         public function getTotalAmount(): float
  344.         {
  345.             return $this->total $this->shippingPrice + ( $this->feesOrder ?? );
  346.         }
  347.         /**
  348.          * Retourne le cumul en point des produits + frais de port + frais de commande
  349.          *
  350.          * @Serializer\VirtualProperty()
  351.          * @SerializedName("totalRateAmount")
  352.          * @Expose()
  353.          * @Groups({"sale_order","sale_order:item", "sale_order:post", "get:read", "export_order_datatable"})
  354.          *
  355.          * @return int
  356.          */
  357.         public function getRateTotalAmount(): int
  358.         {
  359.             return ceil(
  360.                 ( $this->total $this->getOrderRate() ) + ( $this->shippingPrice $this->getOrderRate() ) + ( ( $this->feesOrder ?? ) * $this->getOrderRate() )
  361.             );
  362.         }
  363.         /**
  364.          * @Serializer\VirtualProperty()
  365.          * @Serializer\SerializedName("array_category_values")
  366.          *
  367.          * @Expose()
  368.          * @Groups({ "sale_order:array_category_values", "export_order_datatable" })
  369.          */
  370.         public function getArrayCategoryValues()
  371.         {
  372.             return json_decode$this->categoryValuesTRUE ) ?? [];
  373.         }
  374.         /*
  375.          * ============================================================================================
  376.          * =============================== FONCTIONS CUSTOM ===========================================
  377.          * ============================================================================================
  378.          */
  379.         /**
  380.          * @return string[]
  381.          */
  382.         public static function getOrderedStatus(): array
  383.         {
  384.             return [
  385.                 \App\Constants\SaleOrder::STATUS_SHIPPED,
  386.                 \App\Constants\SaleOrder::STATUS_PROCESSING,
  387.                 \App\Constants\SaleOrder::STATUS_TO_SHIP,
  388.                 \App\Constants\SaleOrder::STATUS_PARTIALLY_SHIPPED,
  389.             ];
  390.         }
  391.         public function __toString()
  392.         {
  393.             return $this->getSku();
  394.         }
  395.         public function getSku()
  396.         {
  397.             return 'SP' str_pad$this->getId(), 10'0'STR_PAD_LEFT );
  398.         }
  399.         public function getId(): ?int
  400.         {
  401.             return $this->id;
  402.         }
  403.         public function getAddressTypeSaleOrderAddress $Address )
  404.         {
  405.             if ( $this->billingAddress === $Address ) {
  406.                 return SaleOrderAddress::BILLING_ADDRESS;
  407.             } elseif ( $this->shippingAddress === $Address ) {
  408.                 return SaleOrderAddress::SHIPPING_ADDRESS;
  409.             }
  410.             return FALSE;
  411.         }
  412.         public function getItemByReferenceWithStatus$reference$statuses )
  413.         {
  414.             foreach ( $this->getItems() as $item ) {
  415.                 if ( $item->getReference() == $reference && in_array$item->getStatus(), $statuses ) ) {
  416.                     return $item;
  417.                 }
  418.             }
  419.             return NULL;
  420.         }
  421.         /**
  422.          * @return Collection|SaleOrderItem[]
  423.          */
  424.         public function getItems(): Collection
  425.         {
  426.             return $this->items;
  427.         }
  428.         /**
  429.          * @param Collection $items
  430.          *
  431.          * @return $this
  432.          */
  433.         public function setItemsCollection $items ): SaleOrder
  434.         {
  435.             $this->items $items;
  436.             return $this;
  437.         }
  438.         public function getStatus(): ?string
  439.         {
  440.             return $this->status;
  441.         }
  442.         public function setStatusstring $status ): self
  443.         {
  444.             $this->status $status;
  445.             return $this;
  446.         }
  447.         public function getItemsByReferenceWithStatus$reference$statuses = [] )
  448.         {
  449.             $items = [];
  450.             foreach ( $this->getItems() as $item ) {
  451.                 if ( $item->getReference() == $reference ) {
  452.                     if ( empty( $statuses ) || in_array$item->getStatus(), $statuses ) ) {
  453.                         $items[] = $item;
  454.                     }
  455.                 }
  456.             }
  457.             return $items;
  458.         }
  459.         /**
  460.          * Count items matching reference & status
  461.          *
  462.          * @param string $reference
  463.          * @param array $statuses
  464.          * @param bool $in
  465.          *
  466.          * @return int
  467.          */
  468.         public function countItemsByReferenceWithStatusstring $reference, array $statuses$in TRUE ): int
  469.         {
  470.             $totalRef $cnt 0;
  471.             foreach ( $this->getItems() as $item ) {
  472.                 if ( $item->getReference() == $reference ) {
  473.                     $totalRef++;
  474.                     if ( in_array$item->getStatus(), $statuses ) ) {
  475.                         $cnt++;
  476.                     }
  477.                 }
  478.             }
  479.             return ( $in ) ? $cnt : ( $totalRef $cnt );
  480.         }
  481.         /*
  482.          * ============================================================================================
  483.          * ============================== FIN FONCTIONS CUSTOM ========================================
  484.          * ============================================================================================
  485.          */
  486.         /**
  487.          * Count items matching status
  488.          *
  489.          * @param         $statuses
  490.          * @param bool $in
  491.          *
  492.          * @return int
  493.          */
  494.         public function countItemsWithStatus$statusesbool $in TRUE ): int
  495.         {
  496.             $cnt 0;
  497.             foreach ( $this->getItems() as $item ) {
  498.                 if ( in_array$item->getStatus(), $statuses ) ) {
  499.                     $cnt++;
  500.                 }
  501.             }
  502.             return ( $in ) ? $cnt : ( count$this->getItems() ) - $cnt );
  503.         }
  504.         /**
  505.          * Get an item from order matching reference
  506.          *
  507.          * @param $reference
  508.          *
  509.          * @return SaleOrderItem|null
  510.          */
  511.         public function getItemByReference$reference )
  512.         {
  513.             foreach ( $this->getItems() as $item ) {
  514.                 if ( $item->getReference() == $reference ) {
  515.                     return $item;
  516.                 }
  517.             }
  518.             return NULL;
  519.         }
  520.         public function hasAllItemsStatesCanceled()
  521.         {
  522.             return $this->hasAllItemsStateSaleOrderItem::STATUS_CANCELED );
  523.         }
  524.         private function hasAllItemsState$state )
  525.         {
  526.             foreach ( $this->getItems() as $item ) {
  527.                 if ( $item->getStatus() != $state ) {
  528.                     return FALSE;
  529.                 }
  530.             }
  531.             return TRUE;
  532.         }
  533.         public function getTotal(): ?string
  534.         {
  535.             return $this->total;
  536.         }
  537.         public function setTotalstring $total ): self
  538.         {
  539.             $this->total $total;
  540.             return $this;
  541.         }
  542.         public function getShippingMethod(): ?string
  543.         {
  544.             return $this->shippingMethod;
  545.         }
  546.         public function setShippingMethod( ?string $shippingMethod ): self
  547.         {
  548.             $this->shippingMethod $shippingMethod;
  549.             return $this;
  550.         }
  551.         public function getCancelMotif(): ?string
  552.         {
  553.             return $this->cancelMotif;
  554.         }
  555.         public function setCancelMotif( ?string $cancelMotif ): self
  556.         {
  557.             $this->cancelMotif $cancelMotif;
  558.             return $this;
  559.         }
  560.         public function getShippingPrice(): ?string
  561.         {
  562.             return $this->shippingPrice;
  563.         }
  564.         public function setShippingPricestring $shippingPrice ): self
  565.         {
  566.             $this->shippingPrice $shippingPrice;
  567.             return $this;
  568.         }
  569.         public function getInternalReference(): ?string
  570.         {
  571.             return $this->internalReference;
  572.         }
  573.         public function setInternalReference( ?string $internalReference ): self
  574.         {
  575.             $this->internalReference $internalReference;
  576.             return $this;
  577.         }
  578.         public function getComment(): ?string
  579.         {
  580.             return $this->comment;
  581.         }
  582.         public function setComment( ?string $comment ): self
  583.         {
  584.             $this->comment $comment;
  585.             return $this;
  586.         }
  587.         public function getIsManagedByCustomer(): ?bool
  588.         {
  589.             return $this->isManagedByCustomer;
  590.         }
  591.         public function setIsManagedByCustomerbool $isManagedByCustomer ): self
  592.         {
  593.             $this->isManagedByCustomer $isManagedByCustomer;
  594.             return $this;
  595.         }
  596.         public function getFeesOrder(): ?string
  597.         {
  598.             return $this->feesOrder;
  599.         }
  600.         public function setFeesOrder( ?string $feesOrder ): self
  601.         {
  602.             $this->feesOrder $feesOrder;
  603.             return $this;
  604.         }
  605.         public function getExtraCbPayment(): ?string
  606.         {
  607.             return $this->extraCbPayment;
  608.         }
  609.         public function setExtraCbPayment( ?string $extraCbPayment ): self
  610.         {
  611.             $this->extraCbPayment $extraCbPayment;
  612.             return $this;
  613.         }
  614.         /**
  615.          * @return string|null
  616.          * @deprecated NON UTILSÉ
  617.          */
  618.         public function getTotalBonusUsed(): ?string
  619.         {
  620.             return $this->totalBonusUsed;
  621.         }
  622.         /**
  623.          * @param string|null $totalBonusUsed
  624.          *
  625.          * @return $this
  626.          * @deprecated NON UTILSÉ
  627.          */
  628.         public function setTotalBonusUsed( ?string $totalBonusUsed ): self
  629.         {
  630.             $this->totalBonusUsed $totalBonusUsed;
  631.             return $this;
  632.         }
  633.         public function getNotBillable(): ?bool
  634.         {
  635.             return $this->notBillable;
  636.         }
  637.         public function setNotBillable( ?bool $notBillable ): self
  638.         {
  639.             $this->notBillable $notBillable;
  640.             return $this;
  641.         }
  642.         public function getOtherinformations(): ?array
  643.         {
  644.             return $this->otherinformations;
  645.         }
  646.         public function setOtherinformations( ?array $otherinformations ): self
  647.         {
  648.             $this->otherinformations $otherinformations;
  649.             return $this;
  650.         }
  651.         public function getBankReturn(): ?BankReturn
  652.         {
  653.             return $this->bankReturn;
  654.         }
  655.         public function setBankReturn( ?BankReturn $bankReturn ): self
  656.         {
  657.             $this->bankReturn $bankReturn;
  658.             return $this;
  659.         }
  660.         public function getUser(): ?User
  661.         {
  662.             return $this->user;
  663.         }
  664.         public function setUser( ?User $user ): self
  665.         {
  666.             $this->user $user;
  667.             return $this;
  668.         }
  669.         /**
  670.          * @return Collection|SaleOrder[]
  671.          */
  672.         public function getSaleOrders(): Collection
  673.         {
  674.             return $this->saleOrders;
  675.         }
  676.         /**
  677.          * @param SaleOrder $saleOrder
  678.          *
  679.          * @return $this
  680.          * @deprecated
  681.          */
  682.         public function addSaleOrderSaleOrder $saleOrder ): self
  683.         {
  684.             if ( !$this->saleOrders->contains$saleOrder ) ) {
  685.                 $this->saleOrders[] = $saleOrder;
  686.                 $saleOrder->setSaleorderGrouped$this );
  687.             }
  688.             return $this;
  689.         }
  690.         /**
  691.          * @param SaleOrder $saleOrder
  692.          *
  693.          * @return $this
  694.          * @deprecated
  695.          */
  696.         public function removeSaleOrderSaleOrder $saleOrder ): self
  697.         {
  698.             if ( $this->saleOrders->removeElement$saleOrder ) ) {
  699.                 // set the owning side to null (unless already changed)
  700.                 if ( $saleOrder->getSaleorderGrouped() === $this ) {
  701.                     $saleOrder->setSaleorderGroupedNULL );
  702.                 }
  703.             }
  704.             return $this;
  705.         }
  706.         /**
  707.          * @deprecated
  708.          */
  709.         public function getSaleorderGrouped(): ?SaleOrder
  710.         {
  711.             return $this->saleorderGrouped;
  712.         }
  713.         /**
  714.          * @deprecated
  715.          */
  716.         public function setSaleorderGrouped( ?self $saleorderGrouped ): SaleOrder
  717.         {
  718.             $this->saleorderGrouped $saleorderGrouped;
  719.             return $this;
  720.         }
  721.         public function getShippingAddress(): ?SaleOrderAddress
  722.         {
  723.             return $this->shippingAddress;
  724.         }
  725.         public function setShippingAddress( ?SaleOrderAddress $shippingAddress ): self
  726.         {
  727.             $this->shippingAddress $shippingAddress;
  728.             return $this;
  729.         }
  730.         public function getBillingAddress(): ?SaleOrderAddress
  731.         {
  732.             return $this->billingAddress;
  733.         }
  734.         public function setBillingAddress( ?SaleOrderAddress $billingAddress ): self
  735.         {
  736.             $this->billingAddress $billingAddress;
  737.             return $this;
  738.         }
  739.         public function addItemSaleOrderItem $item ): self
  740.         {
  741.             if ( !$this->items->contains$item ) ) {
  742.                 $this->items[] = $item;
  743.                 $item->setSaleOrder$this );
  744.             }
  745.             return $this;
  746.         }
  747.         public function removeItemSaleOrderItem $item ): self
  748.         {
  749.             if ( $this->items->removeElement$item ) ) {
  750.                 // set the owning side to null (unless already changed)
  751.                 if ( $item->getSaleOrder() === $this ) {
  752.                     $item->setSaleOrderNULL );
  753.                 }
  754.             }
  755.             return $this;
  756.         }
  757.         /**
  758.          * @return Collection|SaleOrderShipment[]
  759.          */
  760.         public function getShipments(): Collection
  761.         {
  762.             return $this->shipments;
  763.         }
  764.         public function addShipmentSaleOrderShipment $shipment ): self
  765.         {
  766.             if ( !$this->shipments->contains$shipment ) ) {
  767.                 $this->shipments[] = $shipment;
  768.                 $shipment->setSaleOrder$this );
  769.             }
  770.             return $this;
  771.         }
  772.         public function removeShipmentSaleOrderShipment $shipment ): self
  773.         {
  774.             if ( $this->shipments->removeElement$shipment ) ) {
  775.                 // set the owning side to null (unless already changed)
  776.                 if ( $shipment->getSaleOrder() === $this ) {
  777.                     $shipment->setSaleOrderNULL );
  778.                 }
  779.             }
  780.             return $this;
  781.         }
  782.         public function getCart(): ?Cart
  783.         {
  784.             return $this->cart;
  785.         }
  786.         public function setCart( ?Cart $cart ): self
  787.         {
  788.             $this->cart $cart;
  789.             return $this;
  790.         }
  791.         /**
  792.          * @Serializer\VirtualProperty()
  793.          *
  794.          * @Expose
  795.          * @Groups ({"get:read"})
  796.          * @SerializedName ("shipping_method")
  797.          */
  798.         public function getApiShippingMethod()
  799.         {
  800.             return $this->shippingMethod;
  801.         }
  802.         /**
  803.          * @return Collection|PointTransaction[]
  804.          */
  805.         public function getPointTransactions(): Collection
  806.         {
  807.             return $this->pointTransactions;
  808.         }
  809.         public function addPointTransactionPointTransaction $pointTransaction ): self
  810.         {
  811.             if ( !$this->pointTransactions->contains$pointTransaction ) ) {
  812.                 $this->pointTransactions[] = $pointTransaction;
  813.                 $pointTransaction->setSaleOrder$this );
  814.             }
  815.             return $this;
  816.         }
  817.         public function removePointTransactionPointTransaction $pointTransaction ): self
  818.         {
  819.             if ( $this->pointTransactions->removeElement$pointTransaction ) ) {
  820.                 // set the owning side to null (unless already changed)
  821.                 if ( $pointTransaction->getSaleOrder() === $this ) {
  822.                     $pointTransaction->setSaleOrderNULL );
  823.                 }
  824.             }
  825.             return $this;
  826.         }
  827.         public function getOldId(): ?int
  828.         {
  829.             return $this->oldId;
  830.         }
  831.         public function setOldId( ?int $oldId ): self
  832.         {
  833.             $this->oldId $oldId;
  834.             return $this;
  835.         }
  836.         public function getInvoice(): ?SaleOrderInvoice
  837.         {
  838.             return $this->invoice;
  839.         }
  840.         public function setInvoice( ?SaleOrderInvoice $invoice ): self
  841.         {
  842.             $this->invoice $invoice;
  843.             return $this;
  844.         }
  845.         public function getCategoryValues(): ?string
  846.         {
  847.             return $this->categoryValues;
  848.         }
  849.         public function setCategoryValues( ?string $categoryValues ): self
  850.         {
  851.             $this->categoryValues $categoryValues;
  852.             return $this;
  853.         }
  854.         public function getCustomQuestion(): ?string
  855.         {
  856.             return $this->customQuestion;
  857.         }
  858.         public function setCustomQuestion( ?string $customQuestion ): self
  859.         {
  860.             $this->customQuestion $customQuestion;
  861.             return $this;
  862.         }
  863.         public function getOrderRate(): float
  864.         {
  865.             return $this->orderRate ?? 1;
  866.         }
  867.         public function setOrderRatefloat $orderRate ): self
  868.         {
  869.             $this->orderRate $orderRate;
  870.             return $this;
  871.         }
  872.         public function isIsTrip(): ?bool
  873.         {
  874.             return $this->isTrip;
  875.         }
  876.         public function setIsTripbool $isTrip ): self
  877.         {
  878.             $this->isTrip $isTrip;
  879.             return $this;
  880.         }
  881.     }