src/Flexy/ShopBundle/Entity/Order/Order.php line 45

  1. <?php
  2. namespace App\Flexy\ShopBundle\Entity\Order;
  3. use ApiPlatform\Core\Annotation\ApiFilter;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  6. use App\Entity\LogHistory;
  7. use App\Entity\User;
  8. use App\Flexy\ShopBundle\Entity\Accounting\Invoice;
  9. use App\Flexy\ShopBundle\Entity\Customer\Customer;
  10. use App\Flexy\ShopBundle\Entity\Payment\ModalityPayment;
  11. use App\Flexy\ShopBundle\Entity\Product\ProductSubscription;
  12. use App\Flexy\ShopBundle\Entity\Shipping\Shipment;
  13. use App\Flexy\ShopBundle\Entity\Customer\CustomerWalletPoint;
  14. use App\Flexy\ShopBundle\Entity\Payment\PaymentMethod;
  15. use App\Flexy\ShopBundle\Entity\Promotion\Coupon;
  16. use App\Flexy\ShopBundle\Entity\Shipping\CityRegion;
  17. use App\Flexy\ShopBundle\Entity\Resource\Agent;
  18. use App\Flexy\ShopBundle\Entity\Shipping\ShippingMethod;
  19. use App\Flexy\ShopBundle\Entity\Store\Store;
  20. use App\Flexy\ShopBundle\Entity\Vendor\Vendor;
  21. use App\Flexy\ShopBundle\Repository\Order\OrderRepository;
  22. use Doctrine\Common\Collections\ArrayCollection;
  23. use Doctrine\Common\Collections\Collection;
  24. use Doctrine\DBAL\Types\Types;
  25. use Doctrine\ORM\Mapping as ORM;
  26. use Doctrine\ORM\Mapping\Entity;
  27. use Doctrine\ORM\Mapping\InheritanceType;
  28. use Gedmo\Mapping\Annotation as Gedmo;
  29. use Symfony\Component\Serializer\Annotation\Groups;
  30. use Symfony\Component\Validator\Constraints as Assert;
  31. #[ApiResource(
  32.     normalizationContext: ['groups' => ['read']],
  33.     denormalizationContext: ['groups' => ['write']],
  34. )]
  35. #[ApiFilter(SearchFilter::class, properties: ['status' => 'exact','customer'=>'exact','statusShipping' => 'exact'])]
  36. #[ORM\Table(name'`order`')]
  37. #[ORM\Entity(repositoryClassOrderRepository::class)]
  38. #[InheritanceType('JOINED')]
  39. #[Gedmo\SoftDeleteable(fieldName'deletedAt'timeAwarefalsehardDeletetrue)]
  40. #[Gedmo\Loggable(logEntryClass:LogHistory::class)]
  41. class Order implements \Stringable
  42. {
  43.     #[ORM\Id]
  44.     #[ORM\GeneratedValue]
  45.     #[ORM\Column(type'integer')]
  46.     #[Groups(['read'])]
  47.     private $id;
  48.     #[Groups(['read'])]
  49.     #[ORM\Column(type'datetime'nullabletrue)]
  50.     private ?\DateTime $createdAt null;
  51.     #[Groups(['read','write'])]
  52.     #[ORM\Column(type'text'nullabletrue)]
  53.     #[Gedmo\Versioned]
  54.     private ?string $description null;
  55.     #[Groups(['read','write'])]
  56.     #[ORM\ManyToOne(targetEntityCustomer::class, inversedBy'orders'cascade: ['persist'])]
  57.     #[Assert\Valid]
  58.     #[Gedmo\Versioned]
  59.     private ?\App\Flexy\ShopBundle\Entity\Customer\Customer $customer null;
  60.     #[Groups(['read','write'])]
  61.     #[ORM\OneToMany(targetEntityOrderItem::class, mappedBy'parentOrder'cascade: ['persist''remove'])]
  62.     #[Assert\Valid]
  63.     
  64.     private \Doctrine\Common\Collections\Collection|array $orderItems;
  65.     
  66.     #[ORM\OneToMany(targetEntityAdjustment::class, mappedBy'parentOrder')]
  67.     private \Doctrine\Common\Collections\Collection|array $adjustments;
  68.     #[ORM\Column(type'string'length255nullabletrue)]
  69.     #[Groups(['read','write'])]
  70.     private ?string $firstName null;
  71.     #[ORM\Column(type'string'length255nullabletrue)]
  72.     #[Groups(['read','write'])]
  73.     private ?string $lastName null;
  74.     #[ORM\Column(type'string'length255nullabletrue)]
  75.     #[Groups(['read','write'])]
  76.     private ?string $companyName null;
  77.     #[ORM\Column(type'string'length255nullabletrue)]
  78.     #[Groups(['read','write'])]
  79.     private ?string $address null;
  80.     #[ORM\Column(type'string'length255nullabletrue)]
  81.     #[Groups(['read','write'])]
  82.     private ?string $city null;
  83.     #[ORM\Column(type'string'length255nullabletrue)]
  84.     #[Groups(['read','write'])]
  85.     private ?string $country null;
  86.     #[ORM\Column(type'string'length255nullabletrue)]
  87.     private ?string $department null;
  88.     #[ORM\Column(type'string'length255nullabletrue)]
  89.     private ?string $postcode null;
  90.     #[ORM\Column(type'string'length255nullabletrue)]
  91.     #[Groups(['read','write'])]
  92.     private ?string $email null;
  93.     #[ORM\Column(type'string'length255nullabletrue)]
  94.     #[Groups(['read','write'])]
  95.     private ?string $tel null;
  96.     #[ORM\Column(type'text'nullabletrue)]
  97.     private ?string $comment null;
  98.     #[ORM\ManyToOne(targetEntityDemandeFund::class, inversedBy'orders')]
  99.     private ?\App\Flexy\ShopBundle\Entity\Order\DemandeFund $demandeFund null;
  100.     #[Groups(['read','write'])]
  101.     #[ORM\Column(type'string'length255nullabletrue)]
  102.     #[Gedmo\Versioned]
  103.     private ?string $status "draft";
  104.     #[Groups(['read','write'])]
  105.     #[ORM\Column(type'string'length255nullabletrue)]
  106.     #[Gedmo\Versioned]
  107.     private ?string $statusShipping "draft";
  108.     
  109.     #[ORM\Column(type'string'length255nullabletrue)]
  110.     private ?string $source null;
  111.     #[ORM\Column(type'text'nullabletrue)]
  112.     private $deliveryAt;
  113.     #[ORM\Column(type'text'nullabletrue)]
  114.     private $recoveryAt;
  115.     #[ORM\Column(type'string'length255nullabletrue)]
  116.     private ?string $oldOrderNumber null;
  117.     #[ORM\Column(type'float'nullabletrue)]
  118.     private ?float $reduction null;
  119.     #[ORM\Column(type'float'nullabletrue)]
  120.     private $distance 0;
  121.     #[ORM\ManyToOne(targetEntityShippingMethod::class, inversedBy'orders'cascade: ['persist'])]
  122.     #[Groups(['read','write'])]
  123.     #[Gedmo\Versioned]
  124.     private ?\App\Flexy\ShopBundle\Entity\Shipping\ShippingMethod $shippingMethod null;
  125.     #[ORM\ManyToOne(targetEntityAgent::class, inversedBy'orders')]
  126.     #[Groups(['read','write'])]
  127.     #[Gedmo\Versioned]
  128.     private ?\App\Flexy\ShopBundle\Entity\Resource\Agent $agent null;
  129.     #[Groups(['read','write'])]
  130.     #[ORM\ManyToOne(targetEntitypaymentMethod::class, inversedBy'orders'cascade: ['persist'])]
  131.     #[ORM\JoinColumn(nullabletrueonDelete'CASCADE')]
  132.     
  133.     private ?\App\Flexy\ShopBundle\Entity\Payment\PaymentMethod $paymentMethod null;
  134.     #[ORM\Column(type'float'nullabletrue)]
  135.     #[Groups(['read','write'])]
  136.     #[Gedmo\Versioned]
  137.     private ?float $payedAmount null;
  138.     #[ORM\Column(type'datetime'nullabletrue)]
  139.     #[Groups(['read','write'])]
  140.     #[Gedmo\Versioned]
  141.     private ?\DateTimeInterface $startProcessingAt null;
  142.     #[ORM\Column(type'string'length255nullabletrue)]
  143.     private ?string $deliveryType null;
  144.     #[ORM\Column(type'datetime'nullabletrue)]
  145.     #[Groups(['read','write'])]
  146.     #[Gedmo\Versioned]
  147.     private ?\DateTimeInterface $startDeliveryAt null;
  148.     #[ORM\OneToMany(targetEntityCustomerWalletPoint::class, cascade: ['persist''remove'], orphanRemovaltruemappedBy'originOrder')]
  149.     private \Doctrine\Common\Collections\Collection|array $customerWalletPoints;
  150.     #[ORM\ManyToOne(targetEntityCoupon::class, inversedBy'orders')]
  151.     #[Groups(['read','write'])]
  152.     private ?\App\Flexy\ShopBundle\Entity\Promotion\Coupon $coupon null;
  153.     #[ORM\ManyToOne(targetEntityAgent::class, inversedBy'ordersToDolist')]
  154.     private ?\App\Flexy\ShopBundle\Entity\Resource\Agent $agentToDo null;
  155.     #[ORM\Column(type'boolean'nullabletrue)]
  156.     private ?bool $isToDo null;
  157.     #[ORM\ManyToOne(targetEntityCityRegion::class, inversedBy'orders')]
  158.     private ?\App\Flexy\ShopBundle\Entity\Shipping\CityRegion $cityRegionShipping null;
  159.     #[ORM\ManyToOne(targetEntityCityRegion::class, inversedBy'collectedOrders')]
  160.     private $cityRegionCollect;
  161.     #[ORM\ManyToOne(targetEntityVendor::class, inversedBy'orders')]
  162.     private ?\App\Flexy\ShopBundle\Entity\Vendor\Vendor $vendor null;
  163.     #[ORM\Column(type'text'nullabletrue)]
  164.     #[Groups(['read','write'])]
  165.     private ?string $collectAddress null;
  166.     #[ORM\Column(type'text'nullabletrue)]
  167.     #[Groups(['read','write'])]
  168.     private ?string $shippingAddress null;
  169.     #[ORM\Column(type'string'length255nullabletrue)]
  170.     #[Groups(['read','write'])]
  171.     private ?string $collectTel null;
  172.     #[ORM\Column(type'boolean'nullabletrue)]
  173.     #[Groups(['read','write'])]
  174.     private ?bool $isHeavy null;
  175.     #[Groups(['read','write'])]
  176.     #[ORM\Column(type'float'nullabletrue)]
  177.     private $shippingTips 0;
  178.     #[Groups(['read','write'])]
  179.      #[ORM\Column(type'float'nullabletrue)]
  180.     private $walletPaymentAmount 0;
  181.     
  182.     #[ORM\Column(type'boolean'nullabletrue)]
  183.     private $isChecked;
  184.     #[ORM\Column(type'string'length255nullabletrue)]
  185.     private $tokenStripe;
  186.     #[ORM\Column(length255nullabletrue)]
  187.     #[Groups(['read','write'])]
  188.     private ?string $orderType "order";
  189.     #[ORM\Column(nullabletrue)]
  190.     private ?\DateTimeImmutable $deletedAt null;
  191.     #[ORM\ManyToOne(inversedBy'orders')]
  192.     private ?Store $store null;
  193.     #[ORM\OneToOne(inversedBy'relatedOrder'cascade: ['persist''remove'])]
  194.     private ?Shipment $shipment null;
  195.     #[ORM\ManyToOne(inversedBy'orders')]
  196.     private ?Invoice $invoice null;
  197.     #[ORM\Column(typeTypes::STRING,nullabletrue)]
  198.     #[Gedmo\Blameable(on'create')]
  199.     private $createdBy;
  200.     #[ORM\OneToOne(mappedBy'relatedOrder'cascade: ['persist''remove'])]
  201.     private ?ProductSubscription $productSubscription null;
  202.     #[ORM\Column(length255nullabletrue)]
  203.     private ?string $qr_image null;
  204.     #[ORM\OneToMany(mappedBy'parent_order_ticket'targetEntityTicketsCustomer::class)]
  205.     private Collection $ticketsCustomers;
  206.     #[ORM\Column(length255nullabletrue)]
  207.     private ?string $status_server null;
  208.     #[ORM\OneToMany(mappedBy'order_source'cascade: ['persist''remove'], orphanRemovaltruetargetEntityModalityPayment::class)]
  209.     private Collection $modalityPayments;
  210.     
  211.     #[ORM\OneToOne(inversedBy'usedByOrder'targetEntityself::class, cascade: ['persist''remove'])]
  212.     private ?self $originOrder null;
  213.     
  214.     #[ORM\OneToOne(mappedBy'originOrder'targetEntityself::class, cascade: ['persist''remove'])]
  215.     private ?self $usedByOrder null;
  216.     #[ORM\Column(nullabletrue)]
  217.     private ?int $invoiceNumber null;
  218.     
  219.     #[ORM\Column(nullabletrue)]
  220.     private ?float $reduction_meat null;
  221.     
  222.     #[ORM\OneToMany(mappedBy'sourceOrder'targetEntityNotificationOrder::class)]
  223.     private Collection $notificationOrders;
  224.     
  225.     #[ORM\Column(nullabletrue)]
  226.     private ?int $nbrPerson null;
  227.     public function __construct()
  228.     {
  229.         $this->orderItems = new ArrayCollection();
  230.         $this->adjustments = new ArrayCollection();
  231.         $this->createdAt = new \DateTime();
  232.         $this->customerWalletPoints = new ArrayCollection();
  233.         $this->ticketsCustomers = new ArrayCollection();
  234.         $this->modalityPayments = new ArrayCollection();
  235.         $this->notificationOrders = new ArrayCollection();
  236.         
  237.         
  238.     }
  239.     
  240.      public function __clone()
  241.     {
  242.         $this->id null// RĆ©initialiser l'ID
  243.         $this->originOrder null
  244.         $this->shipmentnull
  245.         $this->createdAt = new \DateTime();
  246.        
  247.     }
  248.    
  249.     public function __toString(): string
  250.     {
  251.         return $this->getOrderNumber();
  252.     }
  253.     public function getId(): ?int
  254.     {
  255.         return $this->id;
  256.     }
  257.     #[Groups(['read'])]
  258.     public function getOrderNumber($secondaryPrefix=null)
  259.     {
  260.         $prefix "CMD-";
  261.         if($this->getOrderType()=="invoice"){
  262.             $prefix "FA-";
  263.         }else if($this->getOrderType()=="quote"){
  264.             $prefix "DEV-";
  265.         }
  266.         $orderNumber $prefix.$this->createdAt->format("y"). (int) $this->createdAt->format("m").str_pad((string) $this->id3"0"STR_PAD_LEFT);
  267.         if($secondaryPrefix){
  268.             $orderNumber $prefix.$this->createdAt->format("y"). (int) $this->createdAt->format("m").str_pad((string) $this->id3"0"STR_PAD_LEFT)."-".$secondaryPrefix;
  269.         }
  270.         return $orderNumber;
  271.     }
  272.     
  273.      public function getOrderNumberFormatted()
  274.     {
  275.         
  276.      
  277.         if($this->getOrderType()=="invoice"){
  278.             $prefix "FA-";
  279.         }else if($this->getOrderType()=="quote"){
  280.             $prefix "DEV-";
  281.         }else{
  282.             $prefix "CMD-";
  283.         }
  284.         return $prefix.$this->createdAt->format("ym").str_pad($this->getOrderNumber(), 8'0'STR_PAD_LEFT);
  285.     }
  286.   
  287.     public function getIdPrefixedInvoice()
  288.     {
  289.         $prefix "FA-";
  290.         if(!$this->invoiceNumber){
  291.             return "";
  292.         }
  293.         return $prefix.str_pad($this->getInvoiceNumber(), 5'0'STR_PAD_LEFT);
  294.     }
  295.     #[Groups(['read'])]
  296.     public function getIdPrefixed()
  297.     {
  298.         return $this->getOrderNumber();
  299.     }
  300.     public function getCreatedAt(): ?\DateTime
  301.     {
  302.         return $this->createdAt;
  303.     }
  304.     public function setCreatedAt(?\DateTime $createdAt): self
  305.     {
  306.         $this->createdAt $createdAt;
  307.         return $this;
  308.     }
  309.     public function getCustomer(): ?Customer
  310.     {
  311.         return $this->customer;
  312.     }
  313.     public function setCustomer(?Customer $customer): self
  314.     {
  315.         $this->customer $customer;
  316.         return $this;
  317.     }
  318.     public function getCategoriesProduct(){
  319.         $categories = [];
  320.         foreach($this->getOrderItems() as $singleOrderItem){
  321.             if($singleOrderItem->getProduct()){
  322.                 if($singleOrderItem->getProduct()->getParentCategory()){
  323.                     $categories[] = $singleOrderItem->getProduct()->getParentCategory()->getName();
  324.                 }
  325.                 
  326.             }
  327.         }
  328.         return $categories;
  329.     }
  330.     public function getSubCategoriesProduct(){
  331.         $categories = [];
  332.         foreach($this->getOrderItems() as $singleOrderItem){
  333.             if($singleOrderItem->getProduct()){
  334.                 foreach($singleOrderItem->getProduct()->getCategoriesProduct() as $singleCategory){
  335.                     if(!in_array($singleCategory->getName(),$categories)){
  336.                         $categories[] = $singleCategory->getName();
  337.                     }
  338.                     
  339.                 }
  340.                 
  341.             }
  342.         }
  343.         return $categories;
  344.     }
  345.     /**
  346.      * @return Collection|OrderItem[]
  347.      */
  348.     public function getOrderItems(): Collection
  349.     {
  350.         return $this->orderItems;
  351.     }
  352.     public function addOrderItem(OrderItem $orderItem): self
  353.     {
  354.         if (!$this->orderItems->contains($orderItem)) {
  355.             $this->orderItems[] = $orderItem;
  356.             $orderItem->setParentOrder($this);
  357.         }
  358.         return $this;
  359.     }
  360.     public function removeOrderItem(OrderItem $orderItem): self
  361.     {
  362.         if ($this->orderItems->removeElement($orderItem)) {
  363.             // set the owning side to null (unless already changed)
  364.             if ($orderItem->getParentOrder() === $this) {
  365.                 $orderItem->setParentOrder(null);
  366.             }
  367.         }
  368.         return $this;
  369.     }
  370.     /**
  371.      * @return Collection|Adjustment[]
  372.      */
  373.     public function getAdjustments(): Collection
  374.     {
  375.         return $this->adjustments;
  376.     }
  377.     public function addAdjustment(Adjustment $adjustment): self
  378.     {
  379.         if (!$this->adjustments->contains($adjustment)) {
  380.             $this->adjustments[] = $adjustment;
  381.             $adjustment->setParentOrder($this);
  382.         }
  383.         return $this;
  384.     }
  385.     public function removeAdjustment(Adjustment $adjustment): self
  386.     {
  387.         if ($this->adjustments->removeElement($adjustment)) {
  388.             // set the owning side to null (unless already changed)
  389.             if ($adjustment->getParentOrder() === $this) {
  390.                 $adjustment->setParentOrder(null);
  391.             }
  392.         }
  393.         return $this;
  394.     }
  395.     #[Groups(['read'])]
  396.     public function getReductionOnCoupon(){
  397.         $reductionCoupon=0;
  398.         if($this->getCoupon()){
  399.             if($this->getCoupon()->getTypeReduction()=="percent"){
  400.                 $reductionCoupon = ($this->getTotalAmount()/100)*$this->getCoupon()->getValueReduction();
  401.             }else{
  402.                 $reductionCoupon $this->getCoupon()->getValueReduction();
  403.             }
  404.         }
  405.         return  number_format($reductionCoupon,2,",","");
  406.     }
  407.     public function getFirstName(): ?string
  408.     {
  409.         return $this->firstName;
  410.     }
  411.     public function setFirstName(string $firstName): self
  412.     {
  413.         $this->firstName $firstName;
  414.         return $this;
  415.     }
  416.     public function getLastName(): ?string
  417.     {
  418.         return $this->lastName;
  419.     }
  420.     public function setLastName(string $lastName): self
  421.     {
  422.         $this->lastName $lastName;
  423.         return $this;
  424.     }
  425.     public function getCompanyName(): ?string
  426.     {
  427.         return $this->companyName;
  428.     }
  429.     public function setCompanyName(?string $companyName): self
  430.     {
  431.         $this->companyName $companyName;
  432.         return $this;
  433.     }
  434.     public function getAddress(): ?string
  435.     {
  436.         return $this->address;
  437.     }
  438.     public function setAddress(string $address): self
  439.     {
  440.         $this->address $address;
  441.         return $this;
  442.     }
  443.     public function getCity(): ?string
  444.     {
  445.         return $this->city;
  446.     }
  447.     public function setCity(string $city): self
  448.     {
  449.         $this->city $city;
  450.         return $this;
  451.     }
  452.     public function getCountry(): ?string
  453.     {
  454.         return $this->country;
  455.     }
  456.     public function setCountry(string $country): self
  457.     {
  458.         $this->country $country;
  459.         return $this;
  460.     }
  461.     public function getDepartment(): ?string
  462.     {
  463.         return $this->department;
  464.     }
  465.     public function setDepartment(?string $department): self
  466.     {
  467.         $this->department $department;
  468.         return $this;
  469.     }
  470.     public function getPostcode(): ?string
  471.     {
  472.         return $this->postcode;
  473.     }
  474.     public function setPostcode(?string $postcode): self
  475.     {
  476.         $this->postcode $postcode;
  477.         return $this;
  478.     }
  479.     public function getEmail(): ?string
  480.     {
  481.         return $this->email;
  482.     }
  483.     public function setEmail(string $email): self
  484.     {
  485.         $this->email $email;
  486.         return $this;
  487.     }
  488.     public function getTel(): ?string
  489.     {
  490.         return $this->tel;
  491.     }
  492.     public function setTel(string $tel): self
  493.     {
  494.         $this->tel $tel;
  495.         return $this;
  496.     }
  497.     public function getComment(): ?string
  498.     {
  499.         return $this->comment;
  500.     }
  501.     public function setComment(?string $comment): self
  502.     {
  503.         $this->comment $comment;
  504.         return $this;
  505.     }
  506.   
  507.     #[Groups(['read'])]
  508.     public function getTotalAmount(){
  509.         $total=0;
  510.         foreach($this->orderItems as $singleOrderItem){
  511.             $total $total + ($singleOrderItem->getTotalAmount());
  512.         }
  513.         return $total;
  514.         
  515.     }
  516.     #[Groups(['read'])]
  517.     public function getFullTotalAmount(){
  518.         
  519.         
  520.         $total = ((float)$this->getTotalAmount() + (float)$this->getShippingFees() + (float)$this->getShippingTips()) - (float)$this->getReductionOnCoupon() - (float)$this->getWalletPaymentAmount() ;
  521.         return $total;
  522.         
  523.     }
  524.     //needs optimisation
  525.     #[Groups(['read'])]
  526.     public function getShippingFees(){
  527.         $fees 0;
  528.         if($this->getShippingMethod()){
  529.             if($this->getShippingMethod()->isIsSeparatelyCalculated()){
  530.                 $fees $this->getShippingMethod()->getPrice();
  531.             
  532.                 foreach($this->getShippingMethod()->getShippingRules() as $shippingRule){
  533.     
  534.     
  535.                     if($shippingRule->getTypeCalculation() == "distance"){
  536.                         if( $shippingRule->getMin() < $this->getDistance()  and   $shippingRule->getMax() >= $this->getDistance() ){
  537.                             $fees =  $this->getDistance() * $shippingRule->getValueCalculation();
  538.     
  539.                             /*Condition for TLCS may be it works for all people*/
  540.                             if ($fees $this->getShippingMethod()->getPrice()){
  541.                                 $fees $this->getShippingMethod()->getPrice();
  542.                             }
  543.                             /*Condition for TLCS may be it works for all people*/
  544.                         }
  545.                         
  546.                     }
  547.                         else{
  548.                             if(
  549.                             $shippingRule->getMin() < $this->getTotalAmount() and $shippingRule->getMax() >=  $this->getTotalAmount()
  550.                             
  551.                             ){
  552.                                 if($shippingRule->getTypeCalculation() == "percent"){
  553.                                     $fees = ($this->getTotalAmount() / 100 ) * $shippingRule->getValueCalculation();
  554.                                 }
  555.                                 else{
  556.                                     $fees =  $shippingRule->getValueCalculation();
  557.                                 }
  558.                             }
  559.                         
  560.                     }
  561.     
  562.                     
  563.                 }
  564.             }
  565.             
  566.         }
  567.     
  568.         
  569.         
  570.         return $fees;
  571.     }
  572.     #[Groups(['read'])]
  573.     public function getTotalReduction(){
  574.         $total=0;
  575.         
  576.         foreach($this->orderItems as $singleOrderItem){
  577.             $total $total + ($singleOrderItem->getReduction());
  578.         }
  579.         return $total;
  580.     }
  581.     public function getReductionOnTotal(){
  582.         $reductionAmount 0;
  583.         
  584.         if($this->getReduction() and $this->getReduction()>0){
  585.             $reductionAmount = ($this->getTotalAmount() / 100) * $this->getReduction();
  586.         }
  587.         return $reductionAmount;
  588.     }
  589.     #[Groups(['read'])]
  590.     public function getAmountPayedByCredit(){
  591.         $total=0;
  592.         foreach($this->getCustomerWalletPoints() as $singleWalletPoints){
  593.             if($singleWalletPoints->getPoints()<0){
  594.                 $total $total + ($singleWalletPoints->getPoints());
  595.             }
  596.             
  597.         }
  598.         return $total;
  599.     }
  600.     #[Groups(['read'])]
  601.     public function getAmountEarnedAsCredit(){
  602.         $total=0;
  603.         foreach($this->getCustomerWalletPoints() as $singleWalletPoints){
  604.             if($singleWalletPoints->getPoints()>0){
  605.                 $total $total + ($singleWalletPoints->getPoints());
  606.             }
  607.             
  608.         }
  609.         return $total;
  610.     }
  611.     public function getDemandeFund(): ?DemandeFund
  612.     {
  613.         return $this->demandeFund;
  614.     }
  615.     public function setDemandeFund(?DemandeFund $demandeFund): self
  616.     {
  617.         $this->demandeFund $demandeFund;
  618.         return $this;
  619.     }
  620.     public function getStatus(): ?string
  621.     {
  622.         $status "order_finance_verification_pending";
  623.         if($this->status)
  624.         {
  625.             $status $this->status;
  626.         }
  627.         return $status;
  628.     }
  629.     public function setStatus(?string $status): self
  630.     {
  631.         $this->status $status;
  632.         return $this;
  633.     }
  634.     // BySamir : TO CLEAN
  635.  
  636.     public function getSource(): ?string
  637.     {
  638.         return $this->source;
  639.     }
  640.     public function setSource(?string $source): self
  641.     {
  642.         $this->source $source;
  643.         return $this;
  644.     }
  645.     public function getDeliveryAt()
  646.     {
  647.         return $this->deliveryAt;
  648.     }
  649.     public function setDeliveryAt($deliveryAt)
  650.     {
  651.         $this->deliveryAt $deliveryAt;
  652.         return $this;
  653.     }
  654.     public function getRecoveryAt()
  655.     {
  656.         return $this->recoveryAt;
  657.     }
  658.     public function setRecoveryAt($recoveryAt)
  659.     {
  660.         $this->recoveryAt $recoveryAt;
  661.         return $this;
  662.     }
  663.     public function getReduction(): ?float
  664.     {
  665.         return $this->reduction;
  666.     }
  667.     public function setReduction(?float $reduction): self
  668.     {
  669.         $this->reduction $reduction;
  670.         return $this;
  671.     }
  672.     public function getShippingMethod(): ?ShippingMethod
  673.     {
  674.         return $this->shippingMethod;
  675.     }
  676.     public function setShippingMethod(?ShippingMethod $shippingMethod): self
  677.     {
  678.         $this->shippingMethod $shippingMethod;
  679.         return $this;
  680.     }
  681.     public function getAgent(): ?Agent
  682.     {
  683.         return $this->agent;
  684.     }
  685.     public function setAgent(?Agent $agent): self
  686.     {
  687.         $this->agent $agent;
  688.         return $this;
  689.     }
  690.     public function getPaymentMethod(): ?paymentMethod
  691.     {
  692.         return $this->paymentMethod;
  693.     }
  694.     public function setPaymentMethod(?paymentMethod $paymentMethod): self
  695.     {
  696.         $this->paymentMethod $paymentMethod;
  697.         return $this;
  698.     }
  699.     public function getPayedAmount(): ?float
  700.     {
  701.         return $this->payedAmount;
  702.     }
  703.     public function setPayedAmount(?float $payedAmount): self
  704.     {
  705.         $this->payedAmount $payedAmount;
  706.         return $this;
  707.     }
  708.     public function getStartProcessingAt(): ?\DateTimeInterface
  709.     {
  710.         return $this->startProcessingAt;
  711.     }
  712.     public function setStartProcessingAt(?\DateTimeInterface $startProcessingAt): self
  713.     {
  714.         $this->startProcessingAt $startProcessingAt;
  715.         return $this;
  716.     }
  717.     public function getDeliveryType(): ?string
  718.     {
  719.         return $this->deliveryType;
  720.     }
  721.     public function setDeliveryType(?string $deliveryType): self
  722.     {
  723.         $this->deliveryType $deliveryType;
  724.         return $this;
  725.     }
  726.     public function getStartDeliveryAt(): ?\DateTimeInterface
  727.     {
  728.         return $this->startDeliveryAt;
  729.     }
  730.     public function setStartDeliveryAt(?\DateTimeInterface $startDeliveryAt): self
  731.     {
  732.         $this->startDeliveryAt $startDeliveryAt;
  733.         return $this;
  734.     }
  735.     /**
  736.      * @return Collection<int, CustomerWalletPoint>
  737.      */
  738.     public function getCustomerWalletPoints(): Collection
  739.     {
  740.         return $this->customerWalletPoints;
  741.     }
  742.     public function addCustomerWalletPoint(CustomerWalletPoint $customerWalletPoint): self
  743.     {
  744.         if (!$this->customerWalletPoints->contains($customerWalletPoint)) {
  745.             $this->customerWalletPoints[] = $customerWalletPoint;
  746.             $customerWalletPoint->setOriginOrder($this);
  747.         }
  748.         return $this;
  749.     }
  750.     public function removeCustomerWalletPoint(CustomerWalletPoint $customerWalletPoint): self
  751.     {
  752.         if ($this->customerWalletPoints->removeElement($customerWalletPoint)) {
  753.             // set the owning side to null (unless already changed)
  754.             if ($customerWalletPoint->getOriginOrder() === $this) {
  755.                 $customerWalletPoint->setOriginOrder(null);
  756.             }
  757.         }
  758.         return $this;
  759.     }
  760.     public function getCoupon(): ?Coupon
  761.     {
  762.         return $this->coupon;
  763.     }
  764.     public function setCoupon(?Coupon $coupon): self
  765.     {
  766.         $this->coupon $coupon;
  767.         return $this;
  768.     }
  769.     public function getAgentToDo(): ?Agent
  770.     {
  771.         return $this->agentToDo;
  772.     }
  773.     public function setAgentToDo(?Agent $agentToDo): self
  774.     {
  775.         $this->agentToDo $agentToDo;
  776.         return $this;
  777.     }
  778.     public function getIsToDo(): ?bool
  779.     {
  780.         return $this->isToDo;
  781.     }
  782.     public function setIsToDo(?bool $isToDo): self
  783.     {
  784.         $this->isToDo $isToDo;
  785.         return $this;
  786.     }
  787.     public function getCityRegionShipping(): ?CityRegion
  788.     {
  789.         return $this->cityRegionShipping;
  790.     }
  791.     public function setCityRegionShipping(?CityRegion $cityRegionShipping): self
  792.     {
  793.         $this->cityRegionShipping $cityRegionShipping;
  794.         return $this;
  795.     }
  796.     public function getVendor(): ?Vendor
  797.     {
  798.         return $this->vendor;
  799.     }
  800.     public function setVendor(?Vendor $vendor): self
  801.     {
  802.         $this->vendor $vendor;
  803.         return $this;
  804.     }
  805.     public function getCollectAddress(): ?string
  806.     {
  807.         return $this->collectAddress;
  808.     }
  809.     public function setCollectAddress(?string $collectAddress): self
  810.     {
  811.         $this->collectAddress $collectAddress;
  812.         return $this;
  813.     }
  814.     public function getCollectTel(): ?string
  815.     {
  816.         return $this->collectTel;
  817.     }
  818.     public function setCollectTel(?string $collectTel): self
  819.     {
  820.         $this->collectTel $collectTel;
  821.         return $this;
  822.     }
  823.     public function getIsHeavy(): ?bool
  824.     {
  825.         return $this->isHeavy;
  826.     }
  827.     public function setIsHeavy(?bool $isHeavy): self
  828.     {
  829.         $this->isHeavy $isHeavy;
  830.         return $this;
  831.     }
  832.     #[Groups(['read'])]
  833.     public function getShippingTips(): ?float
  834.     {
  835.         return $this->shippingTips;
  836.     }
  837.     public function setShippingTips(?float $shippingTips): self
  838.     {
  839.         $this->shippingTips $shippingTips;
  840.         return $this;
  841.     }
  842.  
  843.     
  844.     /**
  845.      * Get the value of isChecked
  846.      */ 
  847.     public function getIsChecked()
  848.     {
  849.         return $this->isChecked;
  850.     }
  851.     /**
  852.      * Set the value of isChecked
  853.      *
  854.      * @return  self
  855.      */ 
  856.     public function setIsChecked($isChecked)
  857.     {
  858.         $this->isChecked $isChecked;
  859.         return $this;
  860.     }
  861.     /**
  862.      * Get the value of walletPaymentAmount
  863.      */ 
  864.     public function getWalletPaymentAmount()
  865.     {
  866.         return $this->walletPaymentAmount;
  867.     }
  868.     /**
  869.      * Set the value of walletPaymentAmount
  870.      *
  871.      * @return  self
  872.      */ 
  873.     public function setWalletPaymentAmount($walletPaymentAmount)
  874.     {
  875.         $this->walletPaymentAmount $walletPaymentAmount;
  876.         return $this;
  877.     }
  878.     /**
  879.      * Get the value of cityRegionCollect
  880.      */ 
  881.     public function getCityRegionCollect()
  882.     {
  883.         return $this->cityRegionCollect;
  884.     }
  885.     /**
  886.      * Set the value of cityRegionCollect
  887.      *
  888.      * @return  self
  889.      */ 
  890.     public function setCityRegionCollect($cityRegionCollect)
  891.     {
  892.         $this->cityRegionCollect $cityRegionCollect;
  893.         return $this;
  894.     }
  895.     /**
  896.      * Get the value of distance
  897.      */ 
  898.     public function getDistance()
  899.     {
  900.         return $this->distance;
  901.     }
  902.     /**
  903.      * Set the value of distance
  904.      *
  905.      * @return  self
  906.      */ 
  907.     public function setDistance($distance)
  908.     {
  909.         $this->distance $distance;
  910.         return $this;
  911.     }
  912.     /**
  913.      * Get the value of tokenStripe
  914.      */ 
  915.     public function getTokenStripe()
  916.     {
  917.         return $this->tokenStripe;
  918.     }
  919.     /**
  920.      * Set the value of tokenStripe
  921.      *
  922.      * @return  self
  923.      */ 
  924.     public function setTokenStripe($tokenStripe)
  925.     {
  926.         $this->tokenStripe $tokenStripe;
  927.         return $this;
  928.     }
  929.     public function getOrderType(): ?string
  930.     {
  931.         return $this->orderType;
  932.     }
  933.     public function setOrderType(?string $orderType): self
  934.     {
  935.         $this->orderType $orderType;
  936.         return $this;
  937.     }
  938.     /**
  939.      * Get the value of deletedAt
  940.      */ 
  941.     public function getDeletedAt()
  942.     {
  943.         return $this->deletedAt;
  944.     }
  945.     /**
  946.      * Set the value of deletedAt
  947.      *
  948.      * @return  self
  949.      */ 
  950.     public function setDeletedAt($deletedAt)
  951.     {
  952.         $this->deletedAt $deletedAt;
  953.         return $this;
  954.     }
  955.     public function getStore(): ?Store
  956.     {
  957.         return $this->store;
  958.     }
  959.     public function setStore(?Store $store): self
  960.     {
  961.         $this->store $store;
  962.         return $this;
  963.     }
  964.     public function getShipment(): ?Shipment
  965.     {
  966.         return $this->shipment;
  967.     }
  968.     public function setShipment(?Shipment $shipment): self
  969.     {
  970.         $this->shipment $shipment;
  971.         return $this;
  972.     }
  973.     public function getInvoice(): ?Invoice
  974.     {
  975.         return $this->invoice;
  976.     }
  977.     public function setInvoice(?Invoice $invoice): self
  978.     {
  979.         $this->invoice $invoice;
  980.         return $this;
  981.     }
  982.     /**
  983.      * Get the value of shippingAddress
  984.      */ 
  985.     public function getShippingAddress()
  986.     {
  987.         return $this->shippingAddress;
  988.     }
  989.     /**
  990.      * Set the value of shippingAddress
  991.      *
  992.      * @return  self
  993.      */ 
  994.     public function setShippingAddress($shippingAddress)
  995.     {
  996.         $this->shippingAddress $shippingAddress;
  997.         return $this;
  998.     }
  999.     public function getCreatedBy()
  1000.     {
  1001.         return $this->createdBy;
  1002.     }
  1003.     public function getDescription(): ?string
  1004.     {
  1005.         return $this->description;
  1006.     }
  1007.     public function setDescription(?string $description): self
  1008.     {
  1009.         $this->description $description;
  1010.         return $this;
  1011.     }
  1012.     #[Groups(['read'])]
  1013.     public function getStartProcessingAtText()
  1014.     {
  1015.         $value null;
  1016.         if($this->startDeliveryAt){
  1017.             $intervalDate = clone $this->startProcessingAt;
  1018.         $intervalInMinutes $this->shippingMethod->getShippingDuration() * 60;
  1019.         $intervalDate->modify(" + ".$intervalInMinutes." minutes");
  1020.         
  1021.         $value $this->startProcessingAt->format("Y-m-d H:i") ." - ".$intervalDate->format("H:i");
  1022.         }
  1023.         
  1024.         
  1025.         return $value;
  1026.         
  1027.     }
  1028.     #[Groups(['read'])]
  1029.     public function getStartDeliveryAtText()
  1030.     {
  1031.         
  1032.         $value null;
  1033.         if($this->startDeliveryAt){
  1034.             $intervalDate = clone $this->startDeliveryAt;
  1035.             $intervalInMinutes $this->shippingMethod->getShippingDuration() * 60;
  1036.             $intervalDate->modify(" + ".$intervalInMinutes." minutes");
  1037.             $value $this->startDeliveryAt->format("Y-m-d H:i") ." - ".$intervalDate->format("H:i");
  1038.         }
  1039.         
  1040.         
  1041.         return $value;
  1042.     }
  1043.     #[Groups(['read'])]
  1044.     public function getShippingMethodText()
  1045.     {
  1046.         $value null
  1047.         if($this->shippingMethod){
  1048.             $value $this->shippingMethod->getName();
  1049.         }
  1050.         return $value;
  1051.         
  1052.     }
  1053.     #[Groups(['read'])]
  1054.     public function getPaymentMethodText()
  1055.     {   
  1056.         $value null
  1057.         if($this->paymentMethod){
  1058.             $value $this->paymentMethod->getName();
  1059.         }
  1060.         return $value;
  1061.     }
  1062.     #[Groups(['read'])]
  1063.     public function getTotalProducts()
  1064.     {   
  1065.         $value 0
  1066.         foreach($this->getOrderItems() as $singleOrderItem){
  1067.             $value $value $singleOrderItem->getQuantity();
  1068.         }
  1069.         
  1070.         return $value;
  1071.     }
  1072.     public function getProductSubscription(): ?ProductSubscription
  1073.     {
  1074.         return $this->productSubscription;
  1075.     }
  1076.     public function setProductSubscription(?ProductSubscription $productSubscription): self
  1077.     {
  1078.         // unset the owning side of the relation if necessary
  1079.         if ($productSubscription === null && $this->productSubscription !== null) {
  1080.             $this->productSubscription->setRelatedOrder(null);
  1081.         }
  1082.         // set the owning side of the relation if necessary
  1083.         if ($productSubscription !== null && $productSubscription->getRelatedOrder() !== $this) {
  1084.             $productSubscription->setRelatedOrder($this);
  1085.         }
  1086.         $this->productSubscription $productSubscription;
  1087.         return $this;
  1088.     }
  1089.     /**
  1090.      * Get the value of statusShipping
  1091.      */ 
  1092.     public function getStatusShipping()
  1093.     {
  1094.         return $this->statusShipping;
  1095.     }
  1096.     /**
  1097.      * Set the value of statusShipping
  1098.      *
  1099.      * @return  self
  1100.      */ 
  1101.     public function setStatusShipping($statusShipping)
  1102.     {
  1103.         $this->statusShipping $statusShipping;
  1104.         return $this;
  1105.     }
  1106.     public function getQrImage(): ?string
  1107.     {
  1108.         return $this->qr_image;
  1109.     }
  1110.     public function setQrImage(?string $qr_image): static
  1111.     {
  1112.         $this->qr_image $qr_image;
  1113.         return $this;
  1114.     }
  1115.     
  1116.     public function getOriginOrder(): ?self
  1117.         {
  1118.             return $this->originOrder;
  1119.         }
  1120.         public function setOriginOrder(?self $originOrder): static
  1121.         {
  1122.             $this->originOrder $originOrder;
  1123.             return $this;
  1124.         }
  1125.     /**
  1126.      * @return Collection<int, TicketsCustomer>
  1127.      */
  1128.     public function getTicketsCustomers(): Collection
  1129.     {
  1130.         return $this->ticketsCustomers;
  1131.     }
  1132.     public function addTicketsCustomer(TicketsCustomer $ticketsCustomer): static
  1133.     {
  1134.         if (!$this->ticketsCustomers->contains($ticketsCustomer)) {
  1135.             $this->ticketsCustomers->add($ticketsCustomer);
  1136.             $ticketsCustomer->setParentOrderTicket($this);
  1137.         }
  1138.         return $this;
  1139.     }
  1140.     public function removeTicketsCustomer(TicketsCustomer $ticketsCustomer): static
  1141.     {
  1142.         if ($this->ticketsCustomers->removeElement($ticketsCustomer)) {
  1143.             // set the owning side to null (unless already changed)
  1144.             if ($ticketsCustomer->getParentOrderTicket() === $this) {
  1145.                 $ticketsCustomer->setParentOrderTicket(null);
  1146.             }
  1147.         }
  1148.         return $this;
  1149.     }
  1150.     public function getStatusServer(): ?string
  1151.     {
  1152.         return $this->status_server;
  1153.     }
  1154.     public function setStatusServer(?string $status_server): static
  1155.     {
  1156.         $this->status_server $status_server;
  1157.         return $this;
  1158.     }
  1159.     
  1160.     public function getUsedByOrder(): ?self
  1161.     {
  1162.         return $this->usedByOrder;
  1163.     }
  1164.     public function setUsedByOrder(?self $usedByOrder): static
  1165.     {
  1166.         // unset the owning side of the relation if necessary
  1167.         if ($usedByOrder === null && $this->usedByOrder !== null) {
  1168.             $this->usedByOrder->setOriginOrder(null);
  1169.         }
  1170.         // set the owning side of the relation if necessary
  1171.         if ($usedByOrder !== null && $usedByOrder->getOriginOrder() !== $this) {
  1172.             $usedByOrder->setOriginOrder($this);
  1173.         }
  1174.         $this->usedByOrder $usedByOrder;
  1175.         return $this;
  1176.     }
  1177.     
  1178.     public function getInvoiceNumber(): ?int
  1179.         {   
  1180.             if(!$this->invoiceNumber){
  1181.                 //return $this->getId();
  1182.             }
  1183.             return $this->invoiceNumber;
  1184.         }
  1185.     public function setInvoiceNumber(?int $invoiceNumber): static
  1186.         {
  1187.             $this->invoiceNumber $invoiceNumber;
  1188.             return $this;
  1189.         }
  1190.         
  1191.     /**
  1192.      * @return Collection<int, ModalityPayment>
  1193.      */
  1194.     public function getModalityPayments(): Collection
  1195.     {
  1196.         return $this->modalityPayments;
  1197.     }
  1198.     public function addModalityPayment(ModalityPayment $modalityPayment): static
  1199.     {
  1200.         /*if (!$this->modalityPayments->contains($modalityPayment)) {
  1201.             $this->modalityPayments->add($modalityPayment);
  1202.             $modalityPayment->setOrderSource($this);
  1203.         }*/
  1204.         if (!$this->modalityPayments->contains($modalityPayment)) {
  1205.             $this->modalityPayments->add($modalityPayment);
  1206.         }
  1207.           // Assurer que ModalityPayment connaĆ®t bien son Order source
  1208.        $modalityPayment->setOrderSource($this);
  1209.        
  1210.         return $this;
  1211.     }
  1212.     public function removeModalityPayment(ModalityPayment $modalityPayment): static
  1213.     {
  1214.         if ($this->modalityPayments->removeElement($modalityPayment)) {
  1215.             // set the owning side to null (unless already changed)
  1216.             if ($modalityPayment->getOrderSource() === $this) {
  1217.                 $modalityPayment->setOrderSource(null);
  1218.             }
  1219.         }
  1220.         return $this;
  1221.     }
  1222.     
  1223.      public function getReductionMeat(): ?float
  1224.     {
  1225.         return $this->reduction_meat;
  1226.     }
  1227.     public function setReductionMeat(?float $reduction_meat): static
  1228.     {
  1229.         $this->reduction_meat $reduction_meat;
  1230.         return $this;
  1231.     }
  1232.     
  1233.      /**
  1234.      * @return Collection<int, NotificationOrder>
  1235.      */
  1236.     public function getNotificationOrders(): Collection
  1237.     {
  1238.         return $this->notificationOrders;
  1239.     }
  1240.     public function addNotificationOrder(NotificationOrder $notificationOrder): static
  1241.     {
  1242.         if (!$this->notificationOrders->contains($notificationOrder)) {
  1243.             $this->notificationOrders->add($notificationOrder);
  1244.             $notificationOrder->setSourceOrder($this);
  1245.         }
  1246.         return $this;
  1247.     }
  1248.     public function removeNotificationOrder(NotificationOrder $notificationOrder): static
  1249.     {
  1250.         if ($this->notificationOrders->removeElement($notificationOrder)) {
  1251.             // set the owning side to null (unless already changed)
  1252.             if ($notificationOrder->getSourceOrder() === $this) {
  1253.                 $notificationOrder->setSourceOrder(null);
  1254.             }
  1255.         }
  1256.         return $this;
  1257.     }
  1258.     
  1259.     public function getNbrPerson(): ?int
  1260.     {
  1261.         return $this->nbrPerson;
  1262.     }
  1263.     public function setNbrPerson(?int $nbrPerson): static
  1264.     {
  1265.         $this->nbrPerson $nbrPerson;
  1266.         return $this;
  1267.     }
  1268.     
  1269.  
  1270. }