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