src/Entity/Document.php line 14

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 JsonSerializable;
  8. /**
  9.  * @ORM\Entity(repositoryClass=DocumentRepository::class)
  10.  */
  11. class Document implements JsonSerializable
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="string", length=255)
  21.      */
  22.     private $type;
  23.     /**
  24.      * @ORM\Column(type="string", length=255)
  25.      */
  26.     private $status;
  27.     /**
  28.      * @ORM\Column(type="string", length=255)
  29.      */
  30.     private $conditionDocument;
  31.     /**
  32.      * @ORM\Column(type="string", length=255)
  33.      */
  34.     private $internalNbr;
  35.     /**
  36.      * @ORM\Column(type="string", length=255, nullable=true)
  37.      */
  38.     private $externalNbr;
  39.     /**
  40.      * @ORM\Column(type="datetime")
  41.      */
  42.     private $createdAt;
  43.     /**
  44.      * @ORM\Column(type="datetime")
  45.      */
  46.     private $endAt;
  47.     /**
  48.      * @ORM\Column(type="text", nullable=true)
  49.      */
  50.     private $object;
  51.     /**
  52.      * @ORM\Column(type="text", nullable=true)
  53.      */
  54.     private $note;
  55.     /**
  56.      * @ORM\Column(type="float")
  57.      */
  58.     private $totalAmountHt;
  59.     /**
  60.      * @ORM\Column(type="float")
  61.      */
  62.     private $totalTva;
  63.     /**
  64.      * @ORM\Column(type="float")
  65.      */
  66.     private $totalAmountTtc;
  67.     /**
  68.      * @ORM\Column(type="string", length=255)
  69.      */
  70.     private $paymentMethod;
  71.     /**
  72.      * @ORM\Column(type="string", length=255, nullable=true)
  73.      */
  74.     private $paymentDeadline;
  75.     /**
  76.      * @ORM\Column(type="float", nullable=true)
  77.      */
  78.     private $discount;
  79.     /**
  80.      * @ORM\Column(type="string", length=255, nullable=true)
  81.      */
  82.     private $discountType;
  83.     /**
  84.      * @ORM\Column(type="float", nullable=true)
  85.      */
  86.     private $advancePayment;
  87.     /**
  88.      * @ORM\Column(type="string", length=255, nullable=true)
  89.      */
  90.     private $advancePaymentType;
  91.     /**
  92.      * @ORM\Column(type="string", length=255, nullable=true)
  93.      */
  94.     private $parcelTrackingNbr;
  95.     /**
  96.      * @ORM\OneToMany(targetEntity=DocumentProduit::class, mappedBy="document" ,cascade={"persist"})
  97.      */
  98.     private $documentProduits;
  99.     /**
  100.      * @ORM\OneToMany(targetEntity=DocumentDeclinationProduit::class, mappedBy="document" ,cascade={"persist"})
  101.      */
  102.     private $documentDeclinationProduits;
  103.     /**
  104.      * @ORM\Column(type="string", length=255)
  105.      */
  106.     private $category;
  107.     /**
  108.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="documents")
  109.      */
  110.     private $client;
  111.     /**
  112.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="userDocuments")
  113.      */
  114.     private $user;
  115.     /**
  116.      * @ORM\ManyToOne(targetEntity=Document::class, inversedBy="documents")
  117.      */
  118.     private $document;
  119.     /**
  120.      * @ORM\OneToMany(targetEntity=Document::class, mappedBy="document")
  121.      */
  122.     private $documents;
  123.     /**
  124.      * @ORM\ManyToOne(targetEntity=Delivery::class, inversedBy="documents")
  125.      */
  126.     private $delivery;
  127.     /**
  128.      * @ORM\Column(type="string", length=255, nullable=true)
  129.      */
  130.     private $urlPdf;
  131.     /**
  132.      * @ORM\Column(type="float", nullable=true)
  133.      */
  134.     private $deliveryDiscount;
  135.     /**
  136.      * @ORM\Column(type="string", length=255, nullable=true)
  137.      */
  138.     private $deliveryDiscountType;
  139.     /**
  140.      * @ORM\Column(type="float", nullable=true)
  141.      */
  142.     private $deliveryPrice;
  143.     /**
  144.      * @ORM\ManyToOne(targetEntity=Tva::class)
  145.      */
  146.     private $deliveryTva;
  147.     /**
  148.      * @ORM\Column(type="float", nullable=true)
  149.      */
  150.     private $deliveryTotal;
  151.     /**
  152.      * @ORM\Column(type="text", nullable=true)
  153.      */
  154.     private $adress;
  155.     /**
  156.      * @ORM\OneToMany(targetEntity=Comment::class, mappedBy="document")
  157.      *  @ORM\OrderBy({"createAt" = "DESC"})
  158.      */
  159.     private $comments;
  160.     /**
  161.      * @ORM\ManyToOne(targetEntity=Supplier::class, inversedBy="documents")
  162.      */
  163.     private $supplier;
  164.     /**
  165.      * @ORM\Column(type="string", length=255, nullable=true)
  166.      */
  167.     private $urlTracking;
  168.     /**
  169.      * @ORM\Column(type="integer", nullable=true)
  170.      */
  171.     private $packagesNbr;
  172.     /**
  173.      * @ORM\OneToMany(targetEntity=Comment::class, mappedBy="documentComment")
  174.      */
  175.     private $documentComments;
  176.     /**
  177.      * @ORM\Column(type="datetime", nullable=true)
  178.      */
  179.     private $deliveryAt;
  180.     /**
  181.      * @ORM\Column(type="datetime", nullable=true)
  182.      */
  183.     private $bonlivraisonAt;
  184.     /**
  185.      * @ORM\Column(type="datetime", nullable=true)
  186.      */
  187.     private $bonrecuAt;
  188.     /**
  189.      * @ORM\ManyToOne(targetEntity=Resource::class, inversedBy="documents")
  190.      */
  191.     private $resource;
  192.     /**
  193.      * @ORM\Column(type="boolean")
  194.      */
  195.     private $isFreeDelivery;
  196.     /**
  197.      * @ORM\ManyToOne(targetEntity=User::class)
  198.      */
  199.     private $updatedBy;
  200.     /**
  201.      * @ORM\Column(type="datetime", nullable=true)
  202.      */
  203.     private $updatedAt;
  204.     /**
  205.      * @ORM\OneToMany(targetEntity=Activity::class, mappedBy="document")
  206.      */
  207.     private $activities;
  208.     /**
  209.      * @ORM\ManyToOne(targetEntity=Promotion::class)
  210.      */
  211.     private $promotion;
  212.     public function __construct()
  213.     {
  214.         $this->documentProduits = new ArrayCollection();
  215.         $this->documentDeclinationProduits = new ArrayCollection();
  216.         $this->documents = new ArrayCollection();
  217.         $this->comments = new ArrayCollection();
  218.         $this->documentComments = new ArrayCollection();
  219.         $this->activities = new ArrayCollection();
  220.     }
  221.     public function getId(): ?int
  222.     {
  223.         return $this->id;
  224.     }
  225.     public function getType(): ?string
  226.     {
  227.         return $this->type;
  228.     }
  229.     public function setType(string $type): self
  230.     {
  231.         $this->type $type;
  232.         return $this;
  233.     }
  234.     public function getStatus(): ?string
  235.     {
  236.         return $this->status;
  237.     }
  238.     public function setStatus(string $status): self
  239.     {
  240.         $this->status $status;
  241.         return $this;
  242.     }
  243.     public function getConditionDocument(): ?string
  244.     {
  245.         return $this->conditionDocument;
  246.     }
  247.     public function setConditionDocument(string $conditionDocument): self
  248.     {
  249.         $this->conditionDocument $conditionDocument;
  250.         return $this;
  251.     }
  252.     public function getInternalNbr(): ?string
  253.     {
  254.         return $this->internalNbr;
  255.     }
  256.     public function setInternalNbr(string $internalNbr): self
  257.     {
  258.         $this->internalNbr $internalNbr;
  259.         return $this;
  260.     }
  261.     public function getExternalNbr(): ?string
  262.     {
  263.         return $this->externalNbr;
  264.     }
  265.     public function setExternalNbr(string $externalNbr): self
  266.     {
  267.         $this->externalNbr $externalNbr;
  268.         return $this;
  269.     }
  270.     public function getCreatedAt(): ?\DateTimeInterface
  271.     {
  272.         return $this->createdAt;
  273.     }
  274.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  275.     {
  276.         $this->createdAt $createdAt;
  277.         return $this;
  278.     }
  279.     public function getEndAt(): ?\DateTimeInterface
  280.     {
  281.         return $this->endAt;
  282.     }
  283.     public function setEndAt(\DateTimeInterface $endAt): self
  284.     {
  285.         $this->endAt $endAt;
  286.         return $this;
  287.     }
  288.     public function getObject(): ?string
  289.     {
  290.         return $this->object;
  291.     }
  292.     public function setObject(?string $object): self
  293.     {
  294.         $this->object $object;
  295.         return $this;
  296.     }
  297.     public function getNote(): ?string
  298.     {
  299.         return $this->note;
  300.     }
  301.     public function setNote(?string $note): self
  302.     {
  303.         $this->note $note;
  304.         return $this;
  305.     }
  306.     public function getTotalAmountHt(): ?float
  307.     {
  308.         return $this->totalAmountHt;
  309.     }
  310.     public function setTotalAmountHt(float $totalAmountHt): self
  311.     {
  312.         $this->totalAmountHt $totalAmountHt;
  313.         return $this;
  314.     }
  315.     public function getTotalTva(): ?float
  316.     {
  317.         return $this->totalTva;
  318.     }
  319.     public function setTotalTva(float $totalTva): self
  320.     {
  321.         $this->totalTva $totalTva;
  322.         return $this;
  323.     }
  324.     public function getTotalAmountTtc(): ?float
  325.     {
  326.         return $this->totalAmountTtc;
  327.     }
  328.     public function setTotalAmountTtc(float $totalAmountTtc): self
  329.     {
  330.         $this->totalAmountTtc $totalAmountTtc;
  331.         return $this;
  332.     }
  333.     public function getPaymentMethod(): ?string
  334.     {
  335.         return $this->paymentMethod;
  336.     }
  337.     public function setPaymentMethod(string $paymentMethod): self
  338.     {
  339.         $this->paymentMethod $paymentMethod;
  340.         return $this;
  341.     }
  342.     public function getPaymentDeadline(): ?string
  343.     {
  344.         return $this->paymentDeadline;
  345.     }
  346.     public function setPaymentDeadline(?string $paymentDeadline): self
  347.     {
  348.         $this->paymentDeadline $paymentDeadline;
  349.         return $this;
  350.     }
  351.     public function getDiscount(): ?float
  352.     {
  353.         return $this->discount;
  354.     }
  355.     public function setDiscount(?float $discount): self
  356.     {
  357.         $this->discount $discount;
  358.         return $this;
  359.     }
  360.     public function getDiscountType(): ?string
  361.     {
  362.         return $this->discountType;
  363.     }
  364.     public function setDiscountType(?string $discountType): self
  365.     {
  366.         $this->discountType $discountType;
  367.         return $this;
  368.     }
  369.     public function getAdvancePayment(): ?float
  370.     {
  371.         return $this->advancePayment;
  372.     }
  373.     public function setAdvancePayment(?float $advancePayment): self
  374.     {
  375.         $this->advancePayment $advancePayment;
  376.         return $this;
  377.     }
  378.     public function getAdvancePaymentType(): ?string
  379.     {
  380.         return $this->advancePaymentType;
  381.     }
  382.     public function setAdvancePaymentType(?string $advancePaymentType): self
  383.     {
  384.         $this->advancePaymentType $advancePaymentType;
  385.         return $this;
  386.     }
  387.     public function getParcelTrackingNbr(): ?string
  388.     {
  389.         return $this->parcelTrackingNbr;
  390.     }
  391.     public function setParcelTrackingNbr(?string $parcelTrackingNbr): self
  392.     {
  393.         $this->parcelTrackingNbr $parcelTrackingNbr;
  394.         return $this;
  395.     }
  396.     /**
  397.      * @return Collection|DocumentProduit[]
  398.      */
  399.     public function getDocumentProduits(): Collection
  400.     {
  401.         return $this->documentProduits;
  402.     }
  403.     public function addDocumentProduit(DocumentProduit $documentProduit): self
  404.     {
  405.         if( !$this->documentProduits->contains($documentProduit)) {
  406.             $this->documentProduits[] = $documentProduit;
  407.             $documentProduit->setDocument($this);
  408.         }
  409.         return $this;
  410.     }
  411.     public function removeDocumentProduit(DocumentProduit $documentProduit): self
  412.     {
  413.         if( $this->documentProduits->removeElement($documentProduit)) {
  414.             // set the owning side to null (unless already changed)
  415.             if( $documentProduit->getDocument() === $this) {
  416.                 $documentProduit->setDocument(null);
  417.             }
  418.         }
  419.         return $this;
  420.     }
  421.     /**
  422.      * @return Collection|DocumentDeclinationProduit[]
  423.      */
  424.     public function getDocumentDeclinationProduits(): Collection
  425.     {
  426.         return $this->documentDeclinationProduits;
  427.     }
  428.     public function addDocumentDeclinationProduit(DocumentDeclinationProduit $documentDeclinationProduit): self
  429.     {
  430.         if( !$this->documentDeclinationProduits->contains($documentDeclinationProduit)) {
  431.             $this->documentDeclinationProduits[] = $documentDeclinationProduit;
  432.             $documentDeclinationProduit->setDocument($this);
  433.         }
  434.         return $this;
  435.     }
  436.     public function removeDocumentDeclinationProduit(DocumentDeclinationProduit $documentDeclinationProduit): self
  437.     {
  438.         if( $this->documentDeclinationProduits->removeElement($documentDeclinationProduit)) {
  439.             // set the owning side to null (unless already changed)
  440.             if( $documentDeclinationProduit->getDocument() === $this) {
  441.                 $documentDeclinationProduit->setDocument(null);
  442.             }
  443.         }
  444.         return $this;
  445.     }
  446.     public function getCategory(): ?string
  447.     {
  448.         return $this->category;
  449.     }
  450.     public function setCategory(string $category): self
  451.     {
  452.         $this->category $category;
  453.         return $this;
  454.     }
  455.     public function getClient(): ?User
  456.     {
  457.         return $this->client;
  458.     }
  459.     public function setClient(?User $client): self
  460.     {
  461.         $this->client $client;
  462.         return $this;
  463.     }
  464.     public function getUser(): ?User
  465.     {
  466.         return $this->user;
  467.     }
  468.     public function setUser(?User $user): self
  469.     {
  470.         $this->user $user;
  471.         return $this;
  472.     }
  473.     public function getDocument(): ?self
  474.     {
  475.         return $this->document;
  476.     }
  477.     public function setDocument(?self $document): self
  478.     {
  479.         $this->document $document;
  480.         return $this;
  481.     }
  482.     /**
  483.      * @return Collection|self[]
  484.      */
  485.     public function getDocuments(): Collection
  486.     {
  487.         return $this->documents;
  488.     }
  489.     public function addDocument(self $document): self
  490.     {
  491.         if( !$this->documents->contains($document)) {
  492.             $this->documents[] = $document;
  493.             $document->setDocument($this);
  494.         }
  495.         return $this;
  496.     }
  497.     public function removeDocument(self $document): self
  498.     {
  499.         if( $this->documents->removeElement($document)) {
  500.             // set the owning side to null (unless already changed)
  501.             if( $document->getDocument() === $this) {
  502.                 $document->setDocument(null);
  503.             }
  504.         }
  505.         return $this;
  506.     }
  507.     public function getDelivery(): ?Delivery
  508.     {
  509.         return $this->delivery;
  510.     }
  511.     public function setDelivery(?Delivery $delivery): self
  512.     {
  513.         $this->delivery $delivery;
  514.         return $this;
  515.     }
  516.     public function getUrlPdf(): ?string
  517.     {
  518.         return $this->urlPdf;
  519.     }
  520.     public function setUrlPdf(?string $urlPdf): self
  521.     {
  522.         $this->urlPdf $urlPdf;
  523.         return $this;
  524.     }
  525.     public function getDeliveryDiscount(): ?float
  526.     {
  527.         return $this->deliveryDiscount;
  528.     }
  529.     public function setDeliveryDiscount(?float $deliveryDiscount): self
  530.     {
  531.         $this->deliveryDiscount $deliveryDiscount;
  532.         return $this;
  533.     }
  534.     public function getDeliveryDiscountType(): ?string
  535.     {
  536.         return $this->deliveryDiscountType;
  537.     }
  538.     public function setDeliveryDiscountType(?string $deliveryDiscountType): self
  539.     {
  540.         $this->deliveryDiscountType $deliveryDiscountType;
  541.         return $this;
  542.     }
  543.     public function getDeliveryPrice(): ?float
  544.     {
  545.         return $this->deliveryPrice;
  546.     }
  547.     public function setDeliveryPrice(?float $deliveryPrice): self
  548.     {
  549.         $this->deliveryPrice $deliveryPrice;
  550.         return $this;
  551.     }
  552.     public function getDeliveryTva(): ?Tva
  553.     {
  554.         return $this->deliveryTva;
  555.     }
  556.     public function setDeliveryTva(?Tva $deliveryTva): self
  557.     {
  558.         $this->deliveryTva $deliveryTva;
  559.         return $this;
  560.     }
  561.     public function getDeliveryTotal(): ?float
  562.     {
  563.         return $this->deliveryTotal;
  564.     }
  565.     public function setDeliveryTotal(?float $deliveryTotal): self
  566.     {
  567.         $this->deliveryTotal $deliveryTotal;
  568.         return $this;
  569.     }
  570.     public function getAdress(): ?string
  571.     {
  572.         return $this->adress;
  573.     }
  574.     public function setAdress(?string $adress): self
  575.     {
  576.         $this->adress $adress;
  577.         return $this;
  578.     }
  579.     /**
  580.      * @return Collection|Comment[]
  581.      */
  582.     public function getComments(): Collection
  583.     {
  584.         return $this->comments;
  585.     }
  586.     public function addComment(Comment $comment): self
  587.     {
  588.         if( !$this->comments->contains($comment)) {
  589.             $this->comments[] = $comment;
  590.             $comment->setDocument($this);
  591.         }
  592.         return $this;
  593.     }
  594.     public function removeComment(Comment $comment): self
  595.     {
  596.         if( $this->comments->removeElement($comment)) {
  597.             // set the owning side to null (unless already changed)
  598.             if( $comment->getDocument() === $this) {
  599.                 $comment->setDocument(null);
  600.             }
  601.         }
  602.         return $this;
  603.     }
  604.     public function getSupplier(): ?Supplier
  605.     {
  606.         return $this->supplier;
  607.     }
  608.     public function setSupplier(?Supplier $supplier): self
  609.     {
  610.         $this->supplier $supplier;
  611.         return $this;
  612.     }
  613.     public function getUrlTracking(): ?string
  614.     {
  615.         return $this->urlTracking;
  616.     }
  617.     public function setUrlTracking(?string $urlTracking): self
  618.     {
  619.         $this->urlTracking $urlTracking;
  620.         return $this;
  621.     }
  622.     public function getPackagesNbr(): ?int
  623.     {
  624.         return $this->packagesNbr;
  625.     }
  626.     public function setPackagesNbr(?int $packagesNbr): self
  627.     {
  628.         $this->packagesNbr $packagesNbr;
  629.         return $this;
  630.     }
  631.     /**
  632.      * @return Collection|Comment[]
  633.      */
  634.     public function getDocumentComments(): Collection
  635.     {
  636.         return $this->documentComments;
  637.     }
  638.     public function addDocumentComment(Comment $documentComment): self
  639.     {
  640.         if( !$this->documentComments->contains($documentComment)) {
  641.             $this->documentComments[] = $documentComment;
  642.             $documentComment->setDocumentComment($this);
  643.         }
  644.         return $this;
  645.     }
  646.     public function removeDocumentComment(Comment $documentComment): self
  647.     {
  648.         if( $this->documentComments->removeElement($documentComment)) {
  649.             // set the owning side to null (unless already changed)
  650.             if( $documentComment->getDocumentComment() === $this) {
  651.                 $documentComment->setDocumentComment(null);
  652.             }
  653.         }
  654.         return $this;
  655.     }
  656.     public function getDeliveryAt(): ?\DateTimeInterface
  657.     {
  658.         return $this->deliveryAt;
  659.     }
  660.     public function setDeliveryAt(?\DateTimeInterface $deliveryAt): self
  661.     {
  662.         $this->deliveryAt $deliveryAt;
  663.         return $this;
  664.     }
  665.     public function getUpdatedAt(): ?\DateTimeInterface
  666.     {
  667.         return $this->deliveryAt;
  668.     }
  669.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  670.     {
  671.         $this->updatedAt $updatedAt;
  672.         return $this;
  673.     }
  674.     public function getBonlivraisonAt(): ?\DateTimeInterface
  675.     {
  676.         return $this->bonlivraisonAt;
  677.     }
  678.     public function setBonlivraisonAt(?\DateTimeInterface $bonlivraisonAt): self
  679.     {
  680.         $this->bonlivraisonAt $bonlivraisonAt;
  681.         return $this;
  682.     }
  683.     public function getBonrecuAt(): ?\DateTimeInterface
  684.     {
  685.         return $this->bonrecuAt;
  686.     }
  687.     public function setBonrecuAt(?\DateTimeInterface $bonrecuAt): self
  688.     {
  689.         $this->bonrecuAt $bonrecuAt;
  690.         return $this;
  691.     }
  692.     public function getResource(): ?Resource
  693.     {
  694.         return $this->resource;
  695.     }
  696.     public function setResource(?Resource $resource): self
  697.     {
  698.         $this->resource $resource;
  699.         return $this;
  700.     }
  701.     public function getIsFreeDelivery(): ?bool
  702.     {
  703.         return $this->isFreeDelivery;
  704.     }
  705.     public function setIsFreeDelivery(bool $isFreeDelivery): self
  706.     {
  707.         $this->isFreeDelivery $isFreeDelivery;
  708.         return $this;
  709.     }
  710.     /**
  711.      * @return Collection|Activity[]
  712.      */
  713.     public function getActivities(): Collection
  714.     {
  715.         return $this->activities;
  716.     }
  717.     public function addActivity(Activity $activity): self
  718.     {
  719.         if( !$this->activities->contains($activity)) {
  720.             $this->activities[] = $activity;
  721.             $activity->setDocument($this);
  722.         }
  723.         return $this;
  724.     }
  725.     public function removeActivity(Activity $activity): self
  726.     {
  727.         if( $this->activities->removeElement($activity)) {
  728.             // set the owning side to null (unless already changed)
  729.             if( $activity->getDocument() === $this) {
  730.                 $activity->setDocument(null);
  731.             }
  732.         }
  733.         return $this;
  734.     }
  735.     public function getUpdatedBy(): ?User
  736.     {
  737.         return $this->user;
  738.     }
  739.     public function setUpdatedBy(?User $user): self
  740.     {
  741.         $this->updatedBy $user;
  742.         return $this;
  743.     }
  744.     public function getPromotion(): ?Promotion
  745.     {
  746.         return $this->promotion;
  747.     }
  748.     public function setPromotion(?Promotion $promotion): self
  749.     {
  750.         $this->promotion $promotion;
  751.         return $this;
  752.     }
  753.     public function jsonSerialize()
  754.     {
  755.         return array(
  756.             'id' => $this->getId(),
  757.             'totalClient' => $this->getTotalAmountTtc() + $this->getDeliveryPrice(),
  758.             'createdAt' => $this->getCreatedAt()->format('d/m/Y h:i'),
  759.             'status' => $this->getStatus()
  760.         );
  761.     }
  762. }