src/Entity/Document.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\DocumentRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use App\Entity\CancelReason ;
  8. use App\Entity\ExchangeReason;
  9. use App\Entity\ReturnReason ;
  10. use App\Entity\RefundReason ;
  11. use App\Entity\PosSession;
  12. use App\Entity\Warehouse;
  13. use JsonSerializable;
  14. /**
  15.  * @ORM\Entity(repositoryClass=DocumentRepository::class)
  16.  */
  17. class Document implements JsonSerializable
  18. {
  19.     public const MESSENGER_ORIGIN_CRM 'crm';
  20.     public const MESSENGER_ORIGIN_META_INBOX 'meta_inbox';
  21.     /**
  22.      * @ORM\Id
  23.      * @ORM\GeneratedValue
  24.      * @ORM\Column(type="integer")
  25.      */
  26.     private $id;
  27.     /**
  28.      * @ORM\Column(type="string", length=255)
  29.      */
  30.     private $type;
  31.     /**
  32.      * @ORM\Column(type="string", length=255)
  33.      */
  34.     private $status;
  35.     /**
  36.      * @ORM\Column(type="text")
  37.      */
  38.     private ?string $conditionDocument null;
  39.     /**
  40.      * @ORM\Column(type="string", length=255)
  41.      */
  42.     private $internalNbr;
  43.     /**
  44.      * @ORM\Column(type="string", length=255, nullable=true)
  45.      */
  46.     private $externalNbr;
  47.     /**
  48.      * @ORM\Column(type="datetime")
  49.      */
  50.     private $createdAt;
  51.     /**
  52.      * @ORM\Column(type="text", nullable=true)
  53.      */
  54.     private $object;
  55.     /**
  56.      * @ORM\Column(type="text", nullable=true)
  57.      */
  58.     private $note;
  59.    /**
  60.      * @ORM\Column(type="decimal", precision=12, scale=3, options={"default":"0.000", "comment": "Total HT brut (avant remise document)"})
  61.      */
  62.     private $totalAmountHt;
  63.     /**
  64.      * @ORM\Column(type="decimal", precision=12, scale=3, options={"default":"0.000"})
  65.      */
  66.     private $totalTva;
  67.     /**
  68.      * @ORM\Column( name="items_amount_ttc", type="decimal",  precision=12, scale=3, options={"default":"0.000","comment":"Total TTC articles (hors livraison)"} )
  69.      */
  70.     // Total TTC des articles uniquement (sans frais de livraison). Le champ total_amount_ttc reste = montant à payer (inclut livraison).
  71.     private $itemsAmountTtc "0.000";
  72.     /**
  73.      * @ORM\Column(name="total_amount_ttc", type="decimal", precision=12, scale=3, options={"default":"0.000","comment":"Total TTC net (après remise document)"})
  74.      */
  75.     private $totalAmountTtc;
  76.     /**
  77.      * @ORM\Column(type="string", length=255)
  78.      */
  79.     private $paymentMethod;
  80.     /**
  81.      * @ORM\Column(type="string", length=255, nullable=true)
  82.      */
  83.     private $paymentDeadline;
  84.     /**
  85.      * @ORM\Column(type="string", length=255, nullable=true)
  86.      */
  87.     private $paymentRef;
  88.     /**
  89.      * @ORM\Column(type="float", nullable=true)
  90.      */
  91.     private $discount;
  92.     /**
  93.      * @ORM\Column(type="string", length=255, nullable=true)
  94.      */
  95.     private $discountType;
  96.     /**
  97.      * @ORM\Column(type="float", nullable=true)
  98.      */
  99.     private $advancePayment;
  100.     /**
  101.      * @ORM\Column(type="string", length=255, nullable=true)
  102.      */
  103.     private $advancePaymentType;
  104.     /**
  105.      * @ORM\Column(type="string", length=255, nullable=true)
  106.      */
  107.     private $parcelTrackingNbr;
  108.     /**
  109.      * @ORM\OneToMany(targetEntity=DocumentProduit::class, mappedBy="document" ,cascade={"persist"})
  110.      */
  111.     private $documentProduits;
  112.     /**
  113.      * @ORM\OneToMany(targetEntity=DocumentDeclinationProduit::class, mappedBy="document" ,cascade={"persist"})
  114.      */
  115.     private $documentDeclinationProduits;
  116.     /**
  117.      * @ORM\Column(type="string", length=255)
  118.      */
  119.     private $category;
  120.     /**
  121.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="documents")
  122.      */
  123.     private $client;
  124.     /**
  125.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="userDocuments")
  126.      */
  127.     private $user;
  128.     /**
  129.      * @ORM\ManyToOne(targetEntity=User::class)
  130.      * @ORM\JoinColumn(name="reseller_user_id", referencedColumnName="id", nullable=true, onDelete="SET NULL")
  131.      */
  132.     private ?User $resellerUser null;
  133.     /**
  134.      * @ORM\ManyToOne(targetEntity=Document::class, inversedBy="documents")
  135.      */
  136.     private $document;
  137.     /**
  138.      * @ORM\OneToMany(targetEntity=Document::class, mappedBy="document")
  139.      */
  140.     private $documents;
  141.     /**
  142.      * @ORM\ManyToOne(targetEntity=Delivery::class, inversedBy="documents")
  143.      */
  144.     private $delivery;
  145.     /**
  146.      * @ORM\ManyToOne(targetEntity=Warehouse::class)
  147.      * @ORM\JoinColumn(name="warehouse_id", referencedColumnName="id", nullable=true, onDelete="SET NULL")
  148.      */
  149.     private ?Warehouse $warehouse null;
  150.     /**
  151.      * @ORM\Column(type="string", length=255, nullable=true)
  152.      */
  153.     private $urlPdf;
  154.     /**
  155.      * @ORM\Column(type="float", nullable=true)
  156.      */
  157.     private $deliveryDiscount;
  158.     /**
  159.      * @ORM\Column(type="string", length=255, nullable=true)
  160.      */
  161.     private $deliveryDiscountType;
  162.     /**
  163.      * @ORM\Column(type="float", nullable=true)
  164.      */
  165.     private $deliveryPrice;
  166.     /**
  167.      * @ORM\ManyToOne(targetEntity=Tva::class)
  168.      */
  169.     private $deliveryTva;
  170.     /**
  171.      * @ORM\Column(type="float", nullable=true)
  172.      */
  173.     private $deliveryTotal;
  174.    /**
  175.     * @ORM\Column(name="delivery_company_total", type="decimal", precision=12, scale=2, nullable=true)
  176.     */
  177.     private $deliveryCompanyTotal;
  178.     /**
  179.      * @ORM\Column(type="text", nullable=true)
  180.      */
  181.     private $adress;
  182.     /**
  183.      * @ORM\Column(name="temporary_stock_holder", type="string", length=255, nullable=true)
  184.      */
  185.     private ?string $temporaryStockHolder null;
  186.     /**
  187.      * @ORM\Column(name="temporary_stock_holder_type", type="string", length=20, nullable=true, options={"default":"other"})
  188.      */
  189.     private ?string $temporaryStockHolderType 'other';
  190.     /**
  191.      * @ORM\ManyToOne(targetEntity=User::class)
  192.      * @ORM\JoinColumn(name="temporary_stock_holder_user_id", referencedColumnName="id", nullable=true, onDelete="SET NULL")
  193.      */
  194.     private ?User $temporaryStockHolderUser null;
  195.     /**
  196.      * @ORM\ManyToOne(targetEntity=TemporaryStockOutReason::class)
  197.      * @ORM\JoinColumn(name="temporary_stock_out_reason_id", referencedColumnName="id", nullable=true, onDelete="SET NULL")
  198.      */
  199.     private ?TemporaryStockOutReason $temporaryStockOutReason null;
  200.     /**
  201.      * @ORM\Column(type="string", length=255, nullable=true)
  202.      */
  203.     private ?string $deliveryCustomerFullName null;
  204.     /**
  205.      * @ORM\Column(type="string", length=60, nullable=true)
  206.      */
  207.     private ?string $deliveryCustomerPhone null;
  208.     /**
  209.      * @ORM\Column(type="string", length=60, nullable=true)
  210.      */
  211.     private ?string $deliveryCustomerPhone2 null;
  212.     /**
  213.      * @ORM\Column(type="text", nullable=true)
  214.      */
  215.     private ?string $deliveryCustomerAddress null;
  216.     /**
  217.      * @ORM\Column(type="string", length=150, nullable=true)
  218.      */
  219.     private ?string $deliveryCustomerCity null;
  220.     /**
  221.      * @ORM\Column(type="string", length=150, nullable=true)
  222.      */
  223.     private ?string $deliveryCustomerRegion null;
  224.     /**
  225.      * @ORM\Column(type="text", nullable=true)
  226.      */
  227.     private ?string $deliveryCustomerNote null;
  228.     /**
  229.      * @ORM\Column(type="string", length=30, nullable=true)
  230.      */
  231.     private ?string $sourceSocialPlatform null;
  232.     /**
  233.      * @ORM\Column(type="integer", nullable=true)
  234.      */
  235.     private ?int $sourceSocialConversationId null;
  236.     /**
  237.      * @ORM\Column(type="integer", nullable=true)
  238.      */
  239.     private ?int $sourceSocialContactId null;
  240.     /**
  241.      * @ORM\Column(type="string", length=20, nullable=true)
  242.      */
  243.     private ?string $messengerOrigin null;
  244.     /**
  245.      * @ORM\OneToMany(targetEntity=Comment::class, mappedBy="document")
  246.      *  @ORM\OrderBy({"createAt" = "DESC"})
  247.      */
  248.     private $comments;
  249.     /**
  250.      * @ORM\ManyToOne(targetEntity=Supplier::class, inversedBy="documents")
  251.      */
  252.     private $supplier;
  253.     /**
  254.      * @ORM\Column(type="string", length=255, nullable=true)
  255.      */
  256.     private $urlTracking;
  257.     /**
  258.      * @ORM\Column(type="integer", nullable=true)
  259.      */
  260.     private $packagesNbr;
  261.     /**
  262.      * @ORM\OneToMany(targetEntity=Comment::class, mappedBy="documentComment")
  263.      */
  264.     private $documentComments;
  265.     /**
  266.      * @ORM\Column(name="promised_at", type="datetime", nullable=true, options={"comment":"Date promise client/fournisseur"})
  267.      */
  268.     private ?\DateTimeInterface $promisedAt null;
  269.     /**
  270.      * @ORM\Column(name="shipped_at", type="datetime", nullable=true)
  271.      */
  272.     private ?\DateTimeInterface $shippedAt null;
  273.     /**
  274.      * @ORM\Column(name="delivered_at", type="datetime", nullable=true)
  275.      */
  276.     private ?\DateTimeInterface $deliveredAt null;
  277.     /**
  278.      * @ORM\Column(type="datetime", nullable=true)
  279.      */
  280.     private $returnedAt;
  281.     /**
  282.      * @ORM\Column(type="datetime", nullable=true)
  283.      */
  284.     private $bonrecuAt;
  285.      /**
  286.      * @ORM\Column(type="datetime", nullable=true)
  287.      */
  288.     private $aPayerLe;
  289.     /**
  290.      * @ORM\ManyToOne(targetEntity=Source::class, inversedBy="documents")
  291.      */
  292.     private $source;
  293.     /**
  294.      * @ORM\Column(type="boolean")
  295.      */
  296.     private $isFreeDelivery;
  297.     /**
  298.      * @ORM\ManyToOne(targetEntity=User::class)
  299.      */
  300.     private $updatedBy;
  301.     /**
  302.      * @ORM\Column(type="datetime", nullable=true)
  303.      */
  304.     private $updatedAt;
  305.     /**
  306.      * @ORM\OneToMany(targetEntity=Activity::class, mappedBy="document")
  307.      */
  308.     private $activities;
  309.     /**
  310.      * @ORM\ManyToOne(targetEntity=Promotion::class)
  311.      */
  312.     private $promotion;
  313.     /**
  314.      * @ORM\Column(name="payment_status", type="string", length=32, options={"default":"non-paye"})
  315.      */
  316.     private $paymentStatus 'non-paye';
  317.     /**
  318.      * @ORM\Column(name="paid_at", type="datetime", nullable=true)
  319.      */
  320.     private $paidAt;
  321.     /**
  322.     * @ORM\Column(type="decimal", precision=12, scale=3,  options={"default": "0.000", "comment": "Total des encaissements TTC"})
  323.     */
  324.     private $totalPaid;
  325.     /**
  326.      * @ORM\Column(name="refund_amount", type="decimal", precision=12, scale=3, nullable=true)
  327.      */
  328.     private $refundAmount;
  329.     /**
  330.      * @ORM\Column(name="refunded_at", type="datetime", nullable=true)
  331.      */
  332.     private $refundedAt;
  333.     /**
  334.      * @ORM\Column( type="text", nullable=true,  options={ "comment"="Données saisies lors d’une commande site web (nom, adresse, email) à vérifier par un commercial. Champ vidé après validation." })
  335.      */
  336.     private ?string $webCheckPayload null;
  337.     /**
  338.      * @ORM\ManyToOne(targetEntity="App\Entity\CancelReason")
  339.      * @ORM\JoinColumn(name="cancel_reason_id", referencedColumnName="id", onDelete="SET NULL")
  340.      */
  341.     private $cancelReason;
  342.     /**
  343.      * @ORM\ManyToOne(targetEntity="App\Entity\RefundReason")
  344.      * @ORM\JoinColumn(name="refund_reason_id", referencedColumnName="id", onDelete="SET NULL")
  345.      */
  346.     private $refundReason;
  347.     /**
  348.      * @ORM\ManyToOne(targetEntity="App\Entity\ReturnReason")
  349.      * @ORM\JoinColumn(name="return_reason_id", referencedColumnName="id", onDelete="SET NULL", nullable=true)
  350.      */
  351.     private $returnReason;
  352.     /**
  353.      * @ORM\ManyToOne(targetEntity="App\Entity\ExchangeReason")
  354.      * @ORM\JoinColumn(name="exchange_reason_id", referencedColumnName="id", onDelete="SET NULL", nullable=true)
  355.      */
  356.     private $exchangeReason;
  357.     /**
  358.      * @ORM\Column(type="text", nullable=true)
  359.      */
  360.     private ?string $exchangeReasonNote null;
  361.     /**
  362.      * @ORM\Column(type="string", length=100, nullable=true)
  363.      */
  364.     private $region;
  365.     /**
  366.      * @ORM\Column(type="integer")
  367.      */
  368.     private int $publicNumber;
  369.     /**
  370.      * @ORM\Column(type="integer")
  371.      */
  372.     private int $publicYear;
  373.     /**
  374.      * @ORM\ManyToOne(targetEntity=PosSession::class, inversedBy="documents")
  375.      * @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
  376.      */
  377.     private ?PosSession $posSession null;
  378.     /**
  379.      * @ORM\OneToMany(targetEntity=PosPayment::class, mappedBy="document")
  380.      */
  381.     private $posPayments;
  382.     public function __construct()
  383.     {
  384.         $this->documentProduits = new ArrayCollection();
  385.         $this->documentDeclinationProduits = new ArrayCollection();
  386.         $this->documents = new ArrayCollection();
  387.         $this->comments = new ArrayCollection();
  388.         $this->documentComments = new ArrayCollection();
  389.         $this->activities = new ArrayCollection();
  390.         $this->posPayments = new ArrayCollection();
  391.     }
  392.     public function getId(): ?int
  393.     {
  394.         return $this->id;
  395.     }
  396.     public function getType(): ?string
  397.     {
  398.         return $this->type;
  399.     }
  400.     public function setType(string $type): self
  401.     {
  402.         $this->type $type;
  403.         return $this;
  404.     }
  405.     public function getStatus(): ?string
  406.     {
  407.         return $this->status;
  408.     }
  409.     public function setStatus(string $status): self
  410.     {
  411.         $this->status $status;
  412.         return $this;
  413.     }
  414.     public function getConditionDocument(): ?string
  415.     {
  416.         return $this->conditionDocument;
  417.     }
  418.     public function setConditionDocument(string $conditionDocument): self
  419.     {
  420.         $this->conditionDocument $conditionDocument;
  421.         return $this;
  422.     }
  423.     public function getInternalNbr(): ?string
  424.     {
  425.         return $this->internalNbr;
  426.     }
  427.     public function setInternalNbr(string $internalNbr): self
  428.     {
  429.         $this->internalNbr $internalNbr;
  430.         return $this;
  431.     }
  432.     public function getExternalNbr(): ?string
  433.     {
  434.         return $this->externalNbr;
  435.     }
  436.     public function setExternalNbr(?string $externalNbr): self
  437.     {
  438.         $this->externalNbr $externalNbr;
  439.         return $this;
  440.     }
  441.     public function getCreatedAt(): ?\DateTimeInterface
  442.     {
  443.         return $this->createdAt;
  444.     }
  445.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  446.     {
  447.         $this->createdAt $createdAt;
  448.         return $this;
  449.     }
  450.     public function getObject(): ?string
  451.     {
  452.         return $this->object;
  453.     }
  454.     public function setObject(?string $object): self
  455.     {
  456.         $this->object $object;
  457.         return $this;
  458.     }
  459.     public function getNote(): ?string
  460.     {
  461.         return $this->note;
  462.     }
  463.     public function setNote(?string $note): self
  464.     {
  465.         $this->note $note;
  466.         return $this;
  467.     }
  468.     public function getTotalAmountHt(): ?float
  469.     {
  470.         return $this->totalAmountHt;
  471.     }
  472.     public function setTotalAmountHt(float $totalAmountHt): self
  473.     {
  474.         $this->totalAmountHt $totalAmountHt;
  475.         return $this;
  476.     }
  477.     public function getTotalTva(): ?float
  478.     {
  479.         return $this->totalTva;
  480.     }
  481.     public function setTotalTva(float $totalTva): self
  482.     {
  483.         $this->totalTva $totalTva;
  484.         return $this;
  485.     }
  486.     public function getItemsAmountTtc(): ?string
  487.     {
  488.         return $this->itemsAmountTtc;
  489.     }
  490.     public function setItemsAmountTtc($itemsAmountTtc): self
  491.     {
  492.         // Valeur TTC hors livraison (decimal string recommandé avec Doctrine)
  493.         $this->itemsAmountTtc $itemsAmountTtc;
  494.         return $this;
  495.     }
  496.     public function getTotalAmountTtc(): ?string
  497.     {
  498.         return $this->totalAmountTtc;
  499.     }
  500.     public function getTotalToPay(): ?float
  501.     {
  502.         return $this->totalAmountTtc;
  503.     }
  504.     public function setTotalToPay(float $totalAmountTtc): self
  505.     {
  506.         $this->totalAmountTtc $totalAmountTtc;
  507.         return $this;
  508.     }
  509.     public function getPaymentMethod(): ?string
  510.     {
  511.         return $this->paymentMethod;
  512.     }
  513.     public function setPaymentMethod(string $paymentMethod): self
  514.     {
  515.         $this->paymentMethod $paymentMethod;
  516.         return $this;
  517.     }
  518.     public function getPaymentDeadline(): ?string
  519.     {
  520.         return $this->paymentDeadline;
  521.     }
  522.     public function setPaymentDeadline(?string $paymentDeadline): self
  523.     {
  524.         $this->paymentDeadline $paymentDeadline;
  525.         return $this;
  526.     }
  527.     public function getPaymentRef(): ?string
  528.     {
  529.         return $this->paymentRef;
  530.     }
  531.     public function setPaymentRef(?string $paymentRef): self
  532.     {
  533.         $this->paymentRef $paymentRef;
  534.         return $this;
  535.     }
  536.     public function getDiscount(): ?float
  537.     {
  538.         return $this->discount;
  539.     }
  540.     public function setDiscount(?float $discount): self
  541.     {
  542.         $this->discount $discount;
  543.         return $this;
  544.     }
  545.     public function getDiscountType(): ?string
  546.     {
  547.         return $this->discountType;
  548.     }
  549.     public function setDiscountType(?string $discountType): self
  550.     {
  551.         $this->discountType $discountType;
  552.         return $this;
  553.     }
  554.     public function getAdvancePayment(): ?float
  555.     {
  556.         return $this->advancePayment;
  557.     }
  558.     public function setAdvancePayment(?float $advancePayment): self
  559.     {
  560.         $this->advancePayment $advancePayment;
  561.         return $this;
  562.     }
  563.     public function getAdvancePaymentType(): ?string
  564.     {
  565.         return $this->advancePaymentType;
  566.     }
  567.     public function setAdvancePaymentType(?string $advancePaymentType): self
  568.     {
  569.         $this->advancePaymentType $advancePaymentType;
  570.         return $this;
  571.     }
  572.     public function getParcelTrackingNbr(): ?string
  573.     {
  574.         return $this->parcelTrackingNbr;
  575.     }
  576.     public function setParcelTrackingNbr(?string $parcelTrackingNbr): self
  577.     {
  578.         $this->parcelTrackingNbr $parcelTrackingNbr;
  579.         return $this;
  580.     }
  581.     /**
  582.      * @return Collection|DocumentProduit[]
  583.      */
  584.     public function getDocumentProduits(): Collection
  585.     {
  586.         return $this->documentProduits;
  587.     }
  588.     public function addDocumentProduit(DocumentProduit $documentProduit): self
  589.     {
  590.         if( !$this->documentProduits->contains($documentProduit)) {
  591.             $this->documentProduits[] = $documentProduit;
  592.             $documentProduit->setDocument($this);
  593.         }
  594.         return $this;
  595.     }
  596.     public function removeDocumentProduit(DocumentProduit $documentProduit): self
  597.     {
  598.         if( $this->documentProduits->removeElement($documentProduit)) {
  599.             // set the owning side to null (unless already changed)
  600.             if( $documentProduit->getDocument() === $this) {
  601.                 $documentProduit->setDocument(null);
  602.             }
  603.         }
  604.         return $this;
  605.     }
  606.     /**
  607.      * @return Collection|DocumentDeclinationProduit[]
  608.      */
  609.     public function getDocumentDeclinationProduits(): Collection
  610.     {
  611.         return $this->documentDeclinationProduits;
  612.     }
  613.     public function addDocumentDeclinationProduit(DocumentDeclinationProduit $documentDeclinationProduit): self
  614.     {
  615.         if( !$this->documentDeclinationProduits->contains($documentDeclinationProduit)) {
  616.             $this->documentDeclinationProduits[] = $documentDeclinationProduit;
  617.             $documentDeclinationProduit->setDocument($this);
  618.         }
  619.         return $this;
  620.     }
  621.     public function removeDocumentDeclinationProduit(DocumentDeclinationProduit $documentDeclinationProduit): self
  622.     {
  623.         if( $this->documentDeclinationProduits->removeElement($documentDeclinationProduit)) {
  624.             // set the owning side to null (unless already changed)
  625.             if( $documentDeclinationProduit->getDocument() === $this) {
  626.                 $documentDeclinationProduit->setDocument(null);
  627.             }
  628.         }
  629.         return $this;
  630.     }
  631.     public function getCategory(): ?string
  632.     {
  633.         return $this->category;
  634.     }
  635.     public function setCategory(string $category): self
  636.     {
  637.         $this->category $category;
  638.         return $this;
  639.     }
  640.     public function getClient(): ?User
  641.     {
  642.         return $this->client;
  643.     }
  644.     public function setClient(?User $client): self
  645.     {
  646.         $this->client $client;
  647.         return $this;
  648.     }
  649.     public function getUser(): ?User
  650.     {
  651.         return $this->user;
  652.     }
  653.     public function setUser(?User $user): self
  654.     {
  655.         $this->user $user;
  656.         return $this;
  657.     }
  658.     public function getResellerUser(): ?User
  659.     {
  660.         return $this->resellerUser;
  661.     }
  662.     public function setResellerUser(?User $resellerUser): self
  663.     {
  664.         $this->resellerUser $resellerUser;
  665.         return $this;
  666.     }
  667.     public function getDocument(): ?self
  668.     {
  669.         return $this->document;
  670.     }
  671.     public function setDocument(?self $document): self
  672.     {
  673.         $this->document $document;
  674.         return $this;
  675.     }
  676.     /**
  677.      * @return Collection|self[]
  678.      */
  679.     public function getDocuments(): Collection
  680.     {
  681.         return $this->documents;
  682.     }
  683.     public function addDocument(self $document): self
  684.     {
  685.         if( !$this->documents->contains($document)) {
  686.             $this->documents[] = $document;
  687.             $document->setDocument($this);
  688.         }
  689.         return $this;
  690.     }
  691.     public function removeDocument(self $document): self
  692.     {
  693.         if( $this->documents->removeElement($document)) {
  694.             // set the owning side to null (unless already changed)
  695.             if( $document->getDocument() === $this) {
  696.                 $document->setDocument(null);
  697.             }
  698.         }
  699.         return $this;
  700.     }
  701.     public function getDelivery(): ?Delivery
  702.     {
  703.         return $this->delivery;
  704.     }
  705.     public function setDelivery(?Delivery $delivery): self
  706.     {
  707.         $this->delivery $delivery;
  708.         return $this;
  709.     }
  710.     public function getUrlPdf(): ?string
  711.     {
  712.         return $this->urlPdf;
  713.     }
  714.     public function setUrlPdf(?string $urlPdf): self
  715.     {
  716.         $this->urlPdf $urlPdf;
  717.         return $this;
  718.     }
  719.     public function getDeliveryDiscount(): ?float
  720.     {
  721.         return $this->deliveryDiscount;
  722.     }
  723.     public function setDeliveryDiscount(?float $deliveryDiscount): self
  724.     {
  725.         $this->deliveryDiscount $deliveryDiscount;
  726.         return $this;
  727.     }
  728.     public function getDeliveryDiscountType(): ?string
  729.     {
  730.         return $this->deliveryDiscountType;
  731.     }
  732.     public function setDeliveryDiscountType(?string $deliveryDiscountType): self
  733.     {
  734.         $this->deliveryDiscountType $deliveryDiscountType;
  735.         return $this;
  736.     }
  737.     public function getDeliveryPrice(): ?float
  738.     {
  739.         return $this->deliveryPrice;
  740.     }
  741.     public function setDeliveryPrice(?float $deliveryPrice): self
  742.     {
  743.         $this->deliveryPrice $deliveryPrice;
  744.         return $this;
  745.     }
  746.     public function getDeliveryTva(): ?Tva
  747.     {
  748.         return $this->deliveryTva;
  749.     }
  750.     public function setDeliveryTva(?Tva $deliveryTva): self
  751.     {
  752.         $this->deliveryTva $deliveryTva;
  753.         return $this;
  754.     }
  755.     public function getDeliveryTotal(): ?float
  756.     {
  757.         return $this->deliveryTotal;
  758.     }
  759.     public function setDeliveryTotal(?float $deliveryTotal): self
  760.     {
  761.         $this->deliveryTotal $deliveryTotal;
  762.         return $this;
  763.     }
  764.     public function getDeliveryCompanyTotal(): ?string
  765.     {
  766.         return $this->deliveryCompanyTotal;
  767.     }
  768.     public function setDeliveryCompanyTotal(?string $deliveryCompanyTotal): self
  769.     {
  770.         $this->deliveryCompanyTotal $deliveryCompanyTotal;
  771.         return $this;
  772.     }
  773.     public function getAdress(): ?string
  774.     {
  775.         return $this->adress;
  776.     }
  777.     public function setAdress(?string $adress): self
  778.     {
  779.         $this->adress $adress;
  780.         return $this;
  781.     }
  782.     public function getDeliveryCustomerFullName(): ?string
  783.     {
  784.         return $this->deliveryCustomerFullName;
  785.     }
  786.     public function setDeliveryCustomerFullName(?string $deliveryCustomerFullName): self
  787.     {
  788.         $deliveryCustomerFullName trim((string) $deliveryCustomerFullName);
  789.         $this->deliveryCustomerFullName $deliveryCustomerFullName !== '' $deliveryCustomerFullName null;
  790.         return $this;
  791.     }
  792.     public function getDeliveryCustomerPhone(): ?string
  793.     {
  794.         return $this->deliveryCustomerPhone;
  795.     }
  796.     public function setDeliveryCustomerPhone(?string $deliveryCustomerPhone): self
  797.     {
  798.         $deliveryCustomerPhone trim((string) $deliveryCustomerPhone);
  799.         $this->deliveryCustomerPhone $deliveryCustomerPhone !== '' $deliveryCustomerPhone null;
  800.         return $this;
  801.     }
  802.     public function getDeliveryCustomerPhone2(): ?string
  803.     {
  804.         return $this->deliveryCustomerPhone2;
  805.     }
  806.     public function setDeliveryCustomerPhone2(?string $deliveryCustomerPhone2): self
  807.     {
  808.         $deliveryCustomerPhone2 trim((string) $deliveryCustomerPhone2);
  809.         $this->deliveryCustomerPhone2 $deliveryCustomerPhone2 !== '' $deliveryCustomerPhone2 null;
  810.         return $this;
  811.     }
  812.     public function getDeliveryCustomerAddress(): ?string
  813.     {
  814.         return $this->deliveryCustomerAddress;
  815.     }
  816.     public function setDeliveryCustomerAddress(?string $deliveryCustomerAddress): self
  817.     {
  818.         $deliveryCustomerAddress trim((string) $deliveryCustomerAddress);
  819.         $this->deliveryCustomerAddress $deliveryCustomerAddress !== '' $deliveryCustomerAddress null;
  820.         return $this;
  821.     }
  822.     public function getDeliveryCustomerCity(): ?string
  823.     {
  824.         return $this->deliveryCustomerCity;
  825.     }
  826.     public function setDeliveryCustomerCity(?string $deliveryCustomerCity): self
  827.     {
  828.         $deliveryCustomerCity trim((string) $deliveryCustomerCity);
  829.         $this->deliveryCustomerCity $deliveryCustomerCity !== '' $deliveryCustomerCity null;
  830.         return $this;
  831.     }
  832.     public function getDeliveryCustomerRegion(): ?string
  833.     {
  834.         return $this->deliveryCustomerRegion;
  835.     }
  836.     public function setDeliveryCustomerRegion(?string $deliveryCustomerRegion): self
  837.     {
  838.         $deliveryCustomerRegion trim((string) $deliveryCustomerRegion);
  839.         $this->deliveryCustomerRegion $deliveryCustomerRegion !== '' $deliveryCustomerRegion null;
  840.         return $this;
  841.     }
  842.     public function getDeliveryCustomerNote(): ?string
  843.     {
  844.         return $this->deliveryCustomerNote;
  845.     }
  846.     public function setDeliveryCustomerNote(?string $deliveryCustomerNote): self
  847.     {
  848.         $deliveryCustomerNote trim((string) $deliveryCustomerNote);
  849.         $this->deliveryCustomerNote $deliveryCustomerNote !== '' $deliveryCustomerNote null;
  850.         return $this;
  851.     }
  852.     public function getSourceSocialPlatform(): ?string
  853.     {
  854.         return $this->sourceSocialPlatform;
  855.     }
  856.     public function setSourceSocialPlatform(?string $sourceSocialPlatform): self
  857.     {
  858.         $this->sourceSocialPlatform $sourceSocialPlatform;
  859.         return $this;
  860.     }
  861.     public function getSourceSocialConversationId(): ?int
  862.     {
  863.         return $this->sourceSocialConversationId;
  864.     }
  865.     public function setSourceSocialConversationId(?int $sourceSocialConversationId): self
  866.     {
  867.         $this->sourceSocialConversationId $sourceSocialConversationId;
  868.         return $this;
  869.     }
  870.     public function getSourceSocialContactId(): ?int
  871.     {
  872.         return $this->sourceSocialContactId;
  873.     }
  874.     public function setSourceSocialContactId(?int $sourceSocialContactId): self
  875.     {
  876.         $this->sourceSocialContactId $sourceSocialContactId;
  877.         return $this;
  878.     }
  879.     public function getMessengerOrigin(): ?string
  880.     {
  881.         return $this->messengerOrigin;
  882.     }
  883.     public function setMessengerOrigin(?string $messengerOrigin): self
  884.     {
  885.         $this->messengerOrigin $messengerOrigin;
  886.         return $this;
  887.     }
  888.     /**
  889.      * @return Collection|Comment[]
  890.      */
  891.     public function getComments(): Collection
  892.     {
  893.         return $this->comments;
  894.     }
  895.     public function addComment(Comment $comment): self
  896.     {
  897.         if( !$this->comments->contains($comment)) {
  898.             $this->comments[] = $comment;
  899.             $comment->setDocument($this);
  900.         }
  901.         return $this;
  902.     }
  903.     public function removeComment(Comment $comment): self
  904.     {
  905.         if( $this->comments->removeElement($comment)) {
  906.             // set the owning side to null (unless already changed)
  907.             if( $comment->getDocument() === $this) {
  908.                 $comment->setDocument(null);
  909.             }
  910.         }
  911.         return $this;
  912.     }
  913.     public function getSupplier(): ?Supplier
  914.     {
  915.         return $this->supplier;
  916.     }
  917.     public function setSupplier(?Supplier $supplier): self
  918.     {
  919.         $this->supplier $supplier;
  920.         return $this;
  921.     }
  922.     public function getUrlTracking(): ?string
  923.     {
  924.         return $this->urlTracking;
  925.     }
  926.     public function setUrlTracking(?string $urlTracking): self
  927.     {
  928.         $this->urlTracking $urlTracking;
  929.         return $this;
  930.     }
  931.     public function getPackagesNbr(): ?int
  932.     {
  933.         return $this->packagesNbr;
  934.     }
  935.     public function setPackagesNbr(?int $packagesNbr): self
  936.     {
  937.         $this->packagesNbr $packagesNbr;
  938.         return $this;
  939.     }
  940.     /**
  941.      * @return Collection|Comment[]
  942.      */
  943.     public function getDocumentComments(): Collection
  944.     {
  945.         return $this->documentComments;
  946.     }
  947.     public function addDocumentComment(Comment $documentComment): self
  948.     {
  949.         if( !$this->documentComments->contains($documentComment)) {
  950.             $this->documentComments[] = $documentComment;
  951.             $documentComment->setDocumentComment($this);
  952.         }
  953.         return $this;
  954.     }
  955.     public function removeDocumentComment(Comment $documentComment): self
  956.     {
  957.         if( $this->documentComments->removeElement($documentComment)) {
  958.             // set the owning side to null (unless already changed)
  959.             if( $documentComment->getDocumentComment() === $this) {
  960.                 $documentComment->setDocumentComment(null);
  961.             }
  962.         }
  963.         return $this;
  964.     }
  965.     public function getPromisedAt(): ?\DateTimeInterface
  966.     {
  967.         return $this->promisedAt;
  968.     }
  969.     public function setPromisedAt(?\DateTimeInterface $promisedAt): self
  970.     {
  971.         $this->promisedAt $promisedAt;
  972.         return $this;
  973.     }
  974.     public function getWarehouse(): ?Warehouse
  975.     {
  976.         return $this->warehouse;
  977.     }
  978.     public function setWarehouse(?Warehouse $warehouse): self
  979.     {
  980.         $this->warehouse $warehouse;
  981.         return $this;
  982.     }
  983.     public function getUpdatedAt(): ?\DateTimeInterface
  984.     {
  985.         return $this->updatedAt;
  986.     }
  987.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  988.     {
  989.         $this->updatedAt $updatedAt;
  990.         return $this;
  991.     }
  992.     public function getShippedAt(): ?\DateTimeInterface
  993.     {
  994.         return $this->shippedAt;
  995.     }
  996.     public function setShippedAt(?\DateTimeInterface $shippedAt): self
  997.     {
  998.         $this->shippedAt $shippedAt;
  999.         return $this;
  1000.     }
  1001.     public function getDeliveredAt(): ?\DateTimeInterface
  1002.     {
  1003.         return $this->deliveredAt;
  1004.     }
  1005.     public function setDeliveredAt(?\DateTimeInterface $dt): self
  1006.     {
  1007.         $this->deliveredAt $dt; return $this;
  1008.     }
  1009.     public function getReturnedAt(): ?\DateTimeInterface
  1010.     {
  1011.         return $this->returnedAt;
  1012.     }
  1013.     public function setReturnedAt(?\DateTimeInterface $returnedAt): self
  1014.     {
  1015.         $this->returnedAt $returnedAt;
  1016.         return $this;
  1017.     }
  1018.     public function getTemporaryStockHolder(): ?string
  1019.     {
  1020.         return $this->temporaryStockHolder;
  1021.     }
  1022.     public function setTemporaryStockHolder(?string $temporaryStockHolder): self
  1023.     {
  1024.         $this->temporaryStockHolder $temporaryStockHolder !== null trim($temporaryStockHolder) : null;
  1025.         return $this;
  1026.     }
  1027.     public function getTemporaryStockHolderType(): ?string
  1028.     {
  1029.         return $this->temporaryStockHolderType ?: 'other';
  1030.     }
  1031.     public function setTemporaryStockHolderType(?string $temporaryStockHolderType): self
  1032.     {
  1033.         $temporaryStockHolderType trim((string) $temporaryStockHolderType);
  1034.         if (!in_array($temporaryStockHolderType, ['user''other'], true)) {
  1035.             $temporaryStockHolderType 'other';
  1036.         }
  1037.         $this->temporaryStockHolderType $temporaryStockHolderType;
  1038.         return $this;
  1039.     }
  1040.     public function getTemporaryStockHolderUser(): ?User
  1041.     {
  1042.         return $this->temporaryStockHolderUser;
  1043.     }
  1044.     public function setTemporaryStockHolderUser(?User $temporaryStockHolderUser): self
  1045.     {
  1046.         $this->temporaryStockHolderUser $temporaryStockHolderUser;
  1047.         return $this;
  1048.     }
  1049.     public function getTemporaryStockOutReason(): ?TemporaryStockOutReason
  1050.     {
  1051.         return $this->temporaryStockOutReason;
  1052.     }
  1053.     public function setTemporaryStockOutReason(?TemporaryStockOutReason $temporaryStockOutReason): self
  1054.     {
  1055.         $this->temporaryStockOutReason $temporaryStockOutReason;
  1056.         return $this;
  1057.     }
  1058.     public function getBonrecuAt(): ?\DateTimeInterface
  1059.     {
  1060.         return $this->bonrecuAt;
  1061.     }
  1062.     public function setBonrecuAt(?\DateTimeInterface $bonrecuAt): self
  1063.     {
  1064.         $this->bonrecuAt $bonrecuAt;
  1065.         return $this;
  1066.     }
  1067.     public function getAPayerLe(): ?\DateTimeInterface
  1068.     {
  1069.         return $this->aPayerLe;
  1070.     }
  1071.     public function setAPayerLe(?\DateTimeInterface $aPayerLe): self
  1072.     {
  1073.         $this->aPayerLe $aPayerLe;
  1074.         return $this;
  1075.     }
  1076.     public function getSource(): ?Source
  1077.     {
  1078.         return $this->source;
  1079.     }
  1080.     public function setSource(?Source $source): self
  1081.     {
  1082.         $this->source $source;
  1083.         return $this;
  1084.     }
  1085.     public function getIsFreeDelivery(): ?bool
  1086.     {
  1087.         return $this->isFreeDelivery;
  1088.     }
  1089.     public function setIsFreeDelivery(bool $isFreeDelivery): self
  1090.     {
  1091.         $this->isFreeDelivery $isFreeDelivery;
  1092.         return $this;
  1093.     }
  1094.     public function getWebCheckPayload(): ?string
  1095.     {
  1096.         return $this->webCheckPayload;
  1097.     }
  1098.     public function setWebCheckPayload(?string $value): self
  1099.     {
  1100.         $this->webCheckPayload $value;
  1101.         return $this;
  1102.     }
  1103.     /**
  1104.      * @return Collection|Activity[]
  1105.      */
  1106.     public function getActivities(): Collection
  1107.     {
  1108.         return $this->activities;
  1109.     }
  1110.     public function addActivity(Activity $activity): self
  1111.     {
  1112.         if( !$this->activities->contains($activity)) {
  1113.             $this->activities[] = $activity;
  1114.             $activity->setDocument($this);
  1115.         }
  1116.         return $this;
  1117.     }
  1118.     public function removeActivity(Activity $activity): self
  1119.     {
  1120.         if( $this->activities->removeElement($activity)) {
  1121.             // set the owning side to null (unless already changed)
  1122.             if( $activity->getDocument() === $this) {
  1123.                 $activity->setDocument(null);
  1124.             }
  1125.         }
  1126.         return $this;
  1127.     }
  1128.     public function getUpdatedBy(): ?User
  1129.     {
  1130.         return $this->user;
  1131.     }
  1132.     public function setUpdatedBy(?User $user): self
  1133.     {
  1134.         $this->updatedBy $user;
  1135.         return $this;
  1136.     }
  1137.     public function getPromotion(): ?Promotion
  1138.     {
  1139.         return $this->promotion;
  1140.     }
  1141.     public function setPromotion(?Promotion $promotion): self
  1142.     {
  1143.         $this->promotion $promotion;
  1144.         return $this;
  1145.     }
  1146.     public function getCancelReason(): ?CancelReason
  1147.     {
  1148.         return $this->cancelReason;
  1149.     }
  1150.     public function setCancelReason(?CancelReason $cancelReason): self
  1151.     {
  1152.         $this->cancelReason $cancelReason;
  1153.         return $this;
  1154.     }
  1155.     public function getRefundReason(): ?RefundReason
  1156.     {
  1157.         return $this->refundReason;
  1158.     }
  1159.     public function setRefundReason(?RefundReason $refundReason): self
  1160.     {
  1161.         $this->refundReason $refundReason;
  1162.         return $this;
  1163.     }
  1164.     public function getReturnReason(): ?ReturnReason
  1165.     {
  1166.         return $this->returnReason;
  1167.     }
  1168.     public function setReturnReason(?ReturnReason $returnReason): self
  1169.     {
  1170.         $this->returnReason $returnReason;
  1171.         return $this;
  1172.     }
  1173.     public function getExchangeReason(): ?ExchangeReason
  1174.     {
  1175.         return $this->exchangeReason;
  1176.     }
  1177.     public function setExchangeReason(?ExchangeReason $exchangeReason): self
  1178.     {
  1179.         $this->exchangeReason $exchangeReason;
  1180.         return $this;
  1181.     }
  1182.     public function getExchangeReasonNote(): ?string
  1183.     {
  1184.         return $this->exchangeReasonNote;
  1185.     }
  1186.     public function setExchangeReasonNote(?string $exchangeReasonNote): self
  1187.     {
  1188.         $this->exchangeReasonNote $exchangeReasonNote;
  1189.         return $this;
  1190.     }
  1191.     public function getPublicNumber(): int
  1192.     {
  1193.         return $this->publicNumber;
  1194.     }
  1195.     public function setPublicNumber(int $publicNumber): self
  1196.     {
  1197.         $this->publicNumber $publicNumber;
  1198.         return $this;
  1199.     }
  1200.     public function getPublicYear(): int
  1201.     {
  1202.         return $this->publicYear;
  1203.     }
  1204.     public function setPublicYear(int $publicYear): self
  1205.     {
  1206.         $this->publicYear $publicYear;
  1207.         return $this;
  1208.     }
  1209.     public function getPosSession(): ?PosSession
  1210.     {
  1211.         return $this->posSession;
  1212.     }
  1213.     public function setPosSession(?PosSession $posSession): self
  1214.     {
  1215.         $this->posSession $posSession;
  1216.         return $this;
  1217.     }
  1218.     /**
  1219.      * @return Collection|PosPayment[]
  1220.      */
  1221.     public function getPosPayments(): Collection
  1222.     {
  1223.         return $this->posPayments;
  1224.     }
  1225.     public function addPosPayment(PosPayment $posPayment): self
  1226.     {
  1227.         if (!$this->posPayments->contains($posPayment)) {
  1228.             $this->posPayments[] = $posPayment;
  1229.             $posPayment->setDocument($this);
  1230.         }
  1231.         return $this;
  1232.     }
  1233.     public function removePosPayment(PosPayment $posPayment): self
  1234.     {
  1235.         if ($this->posPayments->removeElement($posPayment)) {
  1236.             if ($posPayment->getDocument() === $this) {
  1237.                 $posPayment->setDocument(null);
  1238.             }
  1239.         }
  1240.         return $this;
  1241.     }
  1242.     #[\ReturnTypeWillChange]
  1243.     public function jsonSerialize()
  1244.     {
  1245.         return [
  1246.             'id' => $this->getId(),
  1247.             'totalToPay' => $this->getTotalToPayTtc() + $this->getDeliveryPrice(),
  1248.             'createdAt' => $this->getCreatedAt()->format('d/m/Y h:i'),
  1249.             'status' => $this->getStatus()
  1250.         ];
  1251.     }
  1252.     /* ---------- Getters/Setters paiement ---------- */
  1253.     public function getPaymentStatus(): ?string
  1254.     {
  1255.         return $this->paymentStatus;
  1256.     }
  1257.     public function setPaymentStatus(string $paymentStatus): self
  1258.     {
  1259.         $this->paymentStatus $paymentStatus;
  1260.         return $this;
  1261.     }
  1262.     public function getPaidAt(): ?\DateTimeInterface
  1263.     {
  1264.         return $this->paidAt;
  1265.     }
  1266.     public function setPaidAt(?\DateTimeInterface $paidAt): self
  1267.     {
  1268.         $this->paidAt $paidAt;
  1269.         return $this;
  1270.     }
  1271.     /**
  1272.      * Attention: Doctrine renvoie DECIMAL en string.
  1273.      * On garde string pour éviter les surprises d’arrondi.
  1274.      */
  1275.     public function getTotalPaid(): ?string
  1276.     {
  1277.         return $this->totalPaid;
  1278.     }
  1279.     public function setTotalPaid($totalPaid): self
  1280.     {
  1281.         // accepte float|string, on normalise à 3 décimales
  1282.         $this->totalPaid number_format((float)$totalPaid3'.''');
  1283.         return $this;
  1284.     }
  1285.     /** @ORM\PrePersist */
  1286.     public function ensureTotalPaid(): void
  1287.     {
  1288.         if ($this->totalPaid === null || $this->totalPaid === '') {
  1289.             $this->totalPaid '0.000';
  1290.         }
  1291.     }
  1292.     public function getRefundAmount(): ?string
  1293.     {
  1294.         return $this->refundAmount;
  1295.     }
  1296.     public function setRefundAmount($refundAmount): self
  1297.     {
  1298.         $this->refundAmount $refundAmount !== null
  1299.             number_format((float)$refundAmount3'.''')
  1300.             : null;
  1301.         return $this;
  1302.     }
  1303.     public function getRefundedAt(): ?\DateTimeInterface
  1304.     {
  1305.         return $this->refundedAt;
  1306.     }
  1307.     public function setRefundedAt(?\DateTimeInterface $refundedAt): self
  1308.     {
  1309.         $this->refundedAt $refundedAt;
  1310.         return $this;
  1311.     }
  1312.     public function getRegion(): ?string
  1313.     {
  1314.         return $this->region;
  1315.     }
  1316.     public function setRegion(?string $region): self
  1317.     {
  1318.         $this->region $region ?? '';
  1319.         return $this;
  1320.     }
  1321.     /* ---------- Helper historique ---------- */
  1322.     /** Ajoute proprement une étape dans condition_document */
  1323.     public function addConditionStep(string $label): self
  1324.     {
  1325.         $current trim((string)$this->getConditionDocument());
  1326.         $this->setConditionDocument($current !== '' $current.' -> '.$label $label);
  1327.         return $this;
  1328.     }
  1329. }