src/Entity/Gestiform/Formations/Devis/Devis.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Gestiform\Formations\Devis;
  3. use App\Entity\AbstractEntity;
  4. use App\Entity\Common\Upload;
  5. use App\Entity\Gestiform\Admin\MasterListe\Masterlistelg;
  6. use App\Entity\Gestiform\Admin\Societe;
  7. use App\Entity\Gestiform\Formations\Dossier\Dossier;
  8. use App\Entity\Gestiform\Formations\Entreprise\Contact;
  9. use App\Entity\Gestiform\Formations\Entreprise\Entreprise;
  10. use App\Entity\Gestiform\Formations\Financement\Financement;
  11. use App\Entity\Gestiform\Users\Employe;
  12. use App\Repository\Gestiform\Formations\Devis\DevisRepository;
  13. use Doctrine\Common\Collections\ArrayCollection;
  14. use Doctrine\Common\Collections\Collection;
  15. use Doctrine\ORM\Mapping as ORM;
  16. use Symfony\Component\Serializer\Annotation as Serializer;
  17. /**
  18.  * @ORM\Entity(repositoryClass=DevisRepository::class)
  19.  */
  20. class Devis extends AbstractEntity
  21. {
  22.     /**
  23.      * @ORM\Column(type="datetime", nullable=true)
  24.      */
  25.     private ?\DateTime $start null;
  26.     /**
  27.      * @ORM\Column(type="datetime", nullable=true)
  28.      */
  29.     private ?\DateTime $end null;
  30.     /**
  31.      * @ORM\ManyToOne(targetEntity=Masterlistelg::class, cascade={"persist", "remove"})
  32.      * @ORM\JoinColumn(nullable=true)
  33.      */
  34.     private ?Masterlistelg $state null;
  35.     /**
  36.      * @ORM\ManyToOne(targetEntity=Employe::class)
  37.      * @ORM\JoinColumn(nullable=true)
  38.      * @Serializer\Ignore()
  39.      */
  40.     private ?Employe $referentCommercial null;
  41.     /**
  42.      * @ORM\ManyToOne(targetEntity=Contact::class)
  43.      * @ORM\JoinColumn(nullable=true)
  44.      * @Serializer\Ignore()
  45.      */
  46.     private ?Contact $contactEntreprise null;
  47.     /**
  48.      * @ORM\ManyToOne(targetEntity=Societe::class)
  49.      * @ORM\JoinColumn(nullable=true)
  50.      */
  51.     private ?Societe $societeSource null;
  52.     /**
  53.      * @ORM\Column(type="string", length=50, nullable=true)
  54.      */
  55.     private ?string $code null;
  56.     /**
  57.      * @ORM\Column(type="string", length=50, nullable=true)
  58.      */
  59.     private ?string $repas null;
  60.     /**
  61.      * @ORM\OneToOne(targetEntity=Upload::class, cascade={"persist", "remove"})
  62.      * @ORM\JoinColumn(nullable=true)
  63.      */
  64.     private ?Upload $signatureFile null;
  65.     /**
  66.      * @ORM\Column(type="text", nullable=true)
  67.      */
  68.     private ?string $signature null;
  69.     /**
  70.      * @ORM\ManyToOne(targetEntity=Dossier::class, inversedBy="deviss",cascade={"persist"})
  71.      * @Serializer\Ignore()
  72.      */
  73.     private ?Dossier $dossier null;
  74.     /**
  75.      * @ORM\ManyToMany(targetEntity=Dossier::class, mappedBy="devisEntreprises")
  76.      */
  77.     private Collection $dossiers;
  78.     /**
  79.      * @ORM\Column(type="boolean",nullable=true)
  80.      */
  81.     private ?bool $calendrierPerso null;
  82.     /**
  83.      * @ORM\Column(type="boolean",nullable=true)
  84.      */
  85.     private ?bool $devisApprenant null;
  86.     /**
  87.      * @ORM\Column(type="boolean",nullable=true)
  88.      */
  89.     private ?bool $valide null;
  90.     /**
  91.      * @ORM\Column(type="boolean",nullable=true)
  92.      */
  93.     private ?bool $devisEntreprise null;
  94.     /**
  95.      * @ORM\ManyToOne(targetEntity=Entreprise::class, inversedBy="deviss")
  96.      */
  97.     private ?Entreprise $entreprise null;
  98.     /**
  99.      * @ORM\Column(type="boolean",nullable=true)
  100.      */
  101.     private ?bool $sourceAppli null;
  102.     /**
  103.      * @ORM\Column(type="boolean",nullable=true)
  104.      */
  105.     private ?bool $sourceFront null;
  106.     /**
  107.      * @ORM\Column(type="boolean",nullable=true)
  108.      */
  109.     private ?bool $devisInter null;
  110.     /**
  111.      * @ORM\Column(type="boolean",nullable=true)
  112.      */
  113.     private ?bool $devisIntra null;
  114.     /**
  115.      * @ORM\Column(type="integer", nullable=true)
  116.      */
  117.     private ?int $nbApprenants null;
  118.     /**
  119.      * @ORM\Column(type="boolean",nullable=true)
  120.      */
  121.     private ?bool $sourceCalendrier false;
  122.     /**
  123.      * @ORM\Column(type="boolean",nullable=true)
  124.      */
  125.     private ?bool $chezClient null;
  126.     /**
  127.      * @ORM\Column(type="boolean",nullable=true)
  128.      */
  129.     private ?bool $chezOf null;
  130.     /**
  131.      * @ORM\Column(type="datetime", nullable=true)
  132.      */
  133.     private ?\DateTime $debutFormation null;
  134.     /**
  135.      * @ORM\Column(type="datetime", nullable=true)
  136.      */
  137.     private ?\DateTime $finFormation null;
  138.     /**
  139.      * @ORM\Column(type="text", nullable=true)
  140.      */
  141.     private ?string $commentaire null;
  142.     /**
  143.      * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
  144.      */
  145.     private ?float $montantHT null;
  146.     /**
  147.      * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
  148.      */
  149.     private ?float $remisePourC null;
  150.     /**
  151.      * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
  152.      */
  153.     private ?float $remise null;
  154.     /**
  155.      * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
  156.      */
  157.     private ?float $montantPied null;
  158.     /**
  159.      * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
  160.      */
  161.     private ?float $totalHT null;
  162.     /**
  163.      * @ORM\ManyToOne(targetEntity=Masterlistelg::class)
  164.      * @ORM\JoinColumn(nullable=true)
  165.      */
  166.     private ?Masterlistelg $codeTva null;
  167.     /**
  168.      * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
  169.      */
  170.     private ?float $tauxTva null;
  171.     /**
  172.      * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
  173.      */
  174.     private ?float $montantTva null;
  175.     /**
  176.      * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
  177.      */
  178.     private ?float $montantTtc null;
  179.     /**
  180.      * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
  181.      */
  182.     private ?float $totalValidation null;
  183.     /**
  184.      * @ORM\OneToMany(targetEntity=DevisLigne::class, mappedBy="devis", orphanRemoval=true, cascade={"persist"})
  185.      * @Serializer\Ignore()
  186.      */
  187.     private Collection $devisLignes;
  188.     /**
  189.      * @ORM\OneToMany(targetEntity=Financement::class, mappedBy="devis",cascade={"persist"})
  190.      */
  191.     private Collection $financements;
  192.     public function __construct()
  193.     {
  194.         $this->dossiers = new ArrayCollection();
  195.         $this->devisLignes = new ArrayCollection();
  196.         $this->financements = new ArrayCollection();
  197.     }
  198.     public function getCode(): ?string
  199.     {
  200.         return $this->code;
  201.     }
  202.     public function setCode(?string $code): self
  203.     {
  204.         $this->code $code;
  205.         return $this;
  206.     }
  207.     public function getRepas(): ?string
  208.     {
  209.         return $this->repas;
  210.     }
  211.     public function setRepas(?string $repas): self
  212.     {
  213.         $this->repas $repas;
  214.         return $this;
  215.     }
  216.     public function getSignature(): ?string
  217.     {
  218.         return $this->signature;
  219.     }
  220.     public function setSignature(?string $signature): self
  221.     {
  222.         $this->signature $signature;
  223.         return $this;
  224.     }
  225.     public function isCalendrierPerso(): ?bool
  226.     {
  227.         return $this->calendrierPerso;
  228.     }
  229.     public function setCalendrierPerso(?bool $calendrierPerso): self
  230.     {
  231.         $this->calendrierPerso $calendrierPerso;
  232.         return $this;
  233.     }
  234.     public function isDevisApprenant(): ?bool
  235.     {
  236.         return $this->devisApprenant;
  237.     }
  238.     public function setDevisApprenant(?bool $devisApprenant): self
  239.     {
  240.         $this->devisApprenant $devisApprenant;
  241.         return $this;
  242.     }
  243.     public function isValide(): ?bool
  244.     {
  245.         return $this->valide;
  246.     }
  247.     public function setValide(?bool $valide): self
  248.     {
  249.         $this->valide $valide;
  250.         return $this;
  251.     }
  252.     public function isDevisEntreprise(): ?bool
  253.     {
  254.         return $this->devisEntreprise;
  255.     }
  256.     public function setDevisEntreprise(?bool $devisEntreprise): self
  257.     {
  258.         $this->devisEntreprise $devisEntreprise;
  259.         return $this;
  260.     }
  261.     public function isSourceAppli(): ?bool
  262.     {
  263.         return $this->sourceAppli;
  264.     }
  265.     public function setSourceAppli(?bool $sourceAppli): self
  266.     {
  267.         $this->sourceAppli $sourceAppli;
  268.         return $this;
  269.     }
  270.     public function isSourceFront(): ?bool
  271.     {
  272.         return $this->sourceFront;
  273.     }
  274.     public function setSourceFront(?bool $sourceFront): self
  275.     {
  276.         $this->sourceFront $sourceFront;
  277.         return $this;
  278.     }
  279.     public function isDevisInter(): ?bool
  280.     {
  281.         return $this->devisInter;
  282.     }
  283.     public function setDevisInter(?bool $devisInter): self
  284.     {
  285.         $this->devisInter $devisInter;
  286.         return $this;
  287.     }
  288.     public function isDevisIntra(): ?bool
  289.     {
  290.         return $this->devisIntra;
  291.     }
  292.     public function setDevisIntra(?bool $devisIntra): self
  293.     {
  294.         $this->devisIntra $devisIntra;
  295.         return $this;
  296.     }
  297.     public function getNbApprenants(): ?int
  298.     {
  299.         return $this->nbApprenants;
  300.     }
  301.     public function setNbApprenants(?int $nbApprenants): self
  302.     {
  303.         $this->nbApprenants $nbApprenants;
  304.         return $this;
  305.     }
  306.     public function isSourceCalendrier(): ?bool
  307.     {
  308.         return $this->sourceCalendrier;
  309.     }
  310.     public function setSourceCalendrier(?bool $sourceCalendrier): self
  311.     {
  312.         $this->sourceCalendrier $sourceCalendrier;
  313.         return $this;
  314.     }
  315.     public function isChezClient(): ?bool
  316.     {
  317.         return $this->chezClient;
  318.     }
  319.     public function setChezClient(?bool $chezClient): self
  320.     {
  321.         $this->chezClient $chezClient;
  322.         return $this;
  323.     }
  324.     public function isChezOf(): ?bool
  325.     {
  326.         return $this->chezOf;
  327.     }
  328.     public function setChezOf(?bool $chezOf): self
  329.     {
  330.         $this->chezOf $chezOf;
  331.         return $this;
  332.     }
  333.     public function getDebutFormation(): ?\DateTimeInterface
  334.     {
  335.         return $this->debutFormation;
  336.     }
  337.     public function setDebutFormation(?\DateTimeInterface $debutFormation): self
  338.     {
  339.         $this->debutFormation $debutFormation;
  340.         return $this;
  341.     }
  342.     public function getFinFormation(): ?\DateTimeInterface
  343.     {
  344.         return $this->finFormation;
  345.     }
  346.     public function setFinFormation(?\DateTimeInterface $finFormation): self
  347.     {
  348.         $this->finFormation $finFormation;
  349.         return $this;
  350.     }
  351.     public function getCommentaire(): ?string
  352.     {
  353.         return $this->commentaire;
  354.     }
  355.     public function setCommentaire(?string $commentaire): self
  356.     {
  357.         $this->commentaire $commentaire;
  358.         return $this;
  359.     }
  360.     public function getMontantHT(): ?string
  361.     {
  362.         return $this->montantHT;
  363.     }
  364.     public function setMontantHT(string $montantHT): self
  365.     {
  366.         $this->montantHT $montantHT;
  367.         return $this;
  368.     }
  369.     public function getRemisePourC(): ?string
  370.     {
  371.         return $this->remisePourC;
  372.     }
  373.     public function setRemisePourC(string $remisePourC): self
  374.     {
  375.         $this->remisePourC $remisePourC;
  376.         return $this;
  377.     }
  378.     public function getRemise(): ?string
  379.     {
  380.         return $this->remise;
  381.     }
  382.     public function setRemise(string $remise): self
  383.     {
  384.         $this->remise $remise;
  385.         return $this;
  386.     }
  387.     public function getMontantPied(): ?string
  388.     {
  389.         return $this->montantPied;
  390.     }
  391.     public function setMontantPied(string $montantPied): self
  392.     {
  393.         $this->montantPied $montantPied;
  394.         return $this;
  395.     }
  396.     public function getTotalHT(): ?string
  397.     {
  398.         return $this->totalHT;
  399.     }
  400.     public function setTotalHT(string $totalHT): self
  401.     {
  402.         $this->totalHT $totalHT;
  403.         return $this;
  404.     }
  405.     public function getCodeTva(): ?Masterlistelg
  406.     {
  407.         return $this->codeTva;
  408.     }
  409.     public function setCodeTva(?Masterlistelg $codeTva): self
  410.     {
  411.         $this->codeTva $codeTva;
  412.         return $this;
  413.     }
  414.     public function getTauxTva(): ?string
  415.     {
  416.         return $this->tauxTva;
  417.     }
  418.     public function setTauxTva(?string $tauxTva): self
  419.     {
  420.         $this->tauxTva $tauxTva;
  421.         return $this;
  422.     }
  423.     public function getMontantTva(): ?string
  424.     {
  425.         return $this->montantTva;
  426.     }
  427.     public function setMontantTva(?string $montantTva): self
  428.     {
  429.         $this->montantTva $montantTva;
  430.         return $this;
  431.     }
  432.     public function getMontantTtc(): ?string
  433.     {
  434.         return $this->montantTtc;
  435.     }
  436.     public function setMontantTtc(?string $montantTtc): self
  437.     {
  438.         $this->montantTtc $montantTtc;
  439.         return $this;
  440.     }
  441.     public function getTotalValidation(): ?string
  442.     {
  443.         return $this->totalValidation;
  444.     }
  445.     public function setTotalValidation(?string $totalValidation): self
  446.     {
  447.         $this->totalValidation $totalValidation;
  448.         return $this;
  449.     }
  450.     public function getState(): ?Masterlistelg
  451.     {
  452.         return $this->state;
  453.     }
  454.     public function setState(?Masterlistelg $state): self
  455.     {
  456.         $this->state $state;
  457.         return $this;
  458.     }
  459.     public function getReferentCommercial(): ?Employe
  460.     {
  461.         return $this->referentCommercial;
  462.     }
  463.     public function setReferentCommercial(?Employe $referentCommercial): self
  464.     {
  465.         $this->referentCommercial $referentCommercial;
  466.         return $this;
  467.     }
  468.     public function getContactEntreprise(): ?Contact
  469.     {
  470.         return $this->contactEntreprise;
  471.     }
  472.     public function setContactEntreprise(?Contact $contactEntreprise): self
  473.     {
  474.         $this->contactEntreprise $contactEntreprise;
  475.         return $this;
  476.     }
  477.     public function getSocieteSource(): ?Societe
  478.     {
  479.         return $this->societeSource;
  480.     }
  481.     public function setSocieteSource(?Societe $societeSource): self
  482.     {
  483.         $this->societeSource $societeSource;
  484.         return $this;
  485.     }
  486.     public function getSignatureFile(): ?Upload
  487.     {
  488.         return $this->signatureFile;
  489.     }
  490.     public function setSignatureFile(?Upload $signatureFile): self
  491.     {
  492.         $this->signatureFile $signatureFile;
  493.         return $this;
  494.     }
  495.     public function getDossier(): ?Dossier
  496.     {
  497.         return $this->dossier;
  498.     }
  499.     public function setDossier(?Dossier $dossier): self
  500.     {
  501.         $this->dossier $dossier;
  502.         return $this;
  503.     }
  504.     /**
  505.      * @return Collection<int, Dossier>
  506.      */
  507.     public function getDossiers(): Collection
  508.     {
  509.         return $this->dossiers;
  510.     }
  511.     public function addDossier(Dossier $dossier): self
  512.     {
  513.         if (!$this->dossiers->contains($dossier)) {
  514.             $this->dossiers->add($dossier);
  515.             $dossier->addDevisEntreprise($this);
  516.         }
  517.         return $this;
  518.     }
  519.     public function removeDossier(Dossier $dossier): self
  520.     {
  521.         if ($this->dossiers->removeElement($dossier)) {
  522.             $dossier->removeDevisEntreprise($this);
  523.         }
  524.         return $this;
  525.     }
  526.     public function getEntreprise(): ?Entreprise
  527.     {
  528.         return $this->entreprise;
  529.     }
  530.     public function setEntreprise(?Entreprise $entreprise): self
  531.     {
  532.         $this->entreprise $entreprise;
  533.         return $this;
  534.     }
  535.     /**
  536.      * @return Collection<int, DevisLigne>
  537.      */
  538.     public function getDevisLignes(): Collection
  539.     {
  540.         return $this->devisLignes;
  541.     }
  542.     public function addDevisLigne(DevisLigne $devisLigne): self
  543.     {
  544.         if (!$this->devisLignes->contains($devisLigne)) {
  545.             $this->devisLignes->add($devisLigne);
  546.             $devisLigne->setDevis($this);
  547.         }
  548.         return $this;
  549.     }
  550.     public function removeDevisLigne(DevisLigne $devisLigne): self
  551.     {
  552.         if ($this->devisLignes->removeElement($devisLigne)) {
  553.             // set the owning side to null (unless already changed)
  554.             if ($devisLigne->getDevis() === $this) {
  555.                 $devisLigne->setDevis(null);
  556.             }
  557.         }
  558.         return $this;
  559.     }
  560.     public function isSessionsExiste(): bool
  561.     {
  562.         $sessionsExiste false;
  563.         foreach ($this->devisLignes as $devisLigne) {
  564.             $sessionsExiste true;
  565.             if (is_null($devisLigne->getSession()))
  566.                 $sessionsExiste false;
  567.         }
  568.         return $sessionsExiste;
  569.     }
  570.     public function calculerMoyenneCoutUnitaireHT(): float
  571.     {
  572.         $totalHT 0;
  573.         $totalDuree 0;
  574.         foreach ($this->getDevisLignes() as $ligne) {
  575.             $totalHT += $ligne->getMontantHT() ?? 0;
  576.             $totalDuree += $ligne->getDuree() ?? 0;
  577.         }
  578.         return $totalDuree $totalHT $totalDuree 0;
  579.     }
  580.     public function getDetailCoutUnitaireHT(): array
  581.     {
  582.         $details = [];
  583.         foreach ($this->getDevisLignes() as $ligne) {
  584.             $libelle $ligne->getDesignation();
  585.             $montantHT $ligne->getMontantHT() ?? 0;
  586.             $duree $ligne->getDuree() ?? 0;
  587.             $moyenneCoutHoraire $duree $montantHT $duree 0;
  588.             $details[] = [
  589.                 'designation' => $libelle,
  590.                 'moyParHeure' => round($moyenneCoutHoraire2)
  591.             ];
  592.         }
  593.         return $details;
  594.     }
  595.     /**
  596.      * @return Collection<int, Financement>
  597.      */
  598.     public function getFinancements(): Collection
  599.     {
  600.         return $this->financements;
  601.     }
  602.     public function addFinancement(Financement $financement): self
  603.     {
  604.         if (!$this->financements->contains($financement)) {
  605.             $this->financements->add($financement);
  606.             $financement->setDevis($this);
  607.         }
  608.         return $this;
  609.     }
  610.     public function removeFinancement(Financement $financement): self
  611.     {
  612.         // set the owning side to null (unless already changed)
  613.         if ($this->financements->removeElement($financement) && $financement->getDevis() === $this) {
  614.             $financement->setDevis(null);
  615.         }
  616.         return $this;
  617.     }
  618.     public function getStart(): ?\DateTime
  619.     {
  620.         return $this->start;
  621.     }
  622.     public function setStart(?\DateTime $start): self
  623.     {
  624.         $this->start $start;
  625.         return $this;
  626.     }
  627.     public function getEnd(): ?\DateTime
  628.     {
  629.         return $this->end;
  630.     }
  631.     public function setEnd(?\DateTime $end): self
  632.     {
  633.         $this->end $end;
  634.         return $this;
  635.     }
  636.     public function getAllFrais(): float
  637.     {
  638.         $resultat 0;
  639.         foreach ($this->getDevisLignes() as $ligne) {
  640.                 if (!$ligne->isChargeHT()) {
  641.                     $resultat += $ligne->getMontantHT();
  642.                 }
  643.             }
  644.         return $resultat;
  645.     }
  646.     public function getDetailFinancement(): array
  647.     {
  648.         $resultat = [];
  649.         $resultat['nbfinancements'] = 0;
  650.         $resultat['montantht'] = 0;
  651.         $resultat['montanttva'] = 0;
  652.         $resultat['montantttc'] = 0;
  653.         foreach ($this->getFinancements() as $ligne) {
  654.             $resultat['montantht'] += $ligne->getMontantHt();
  655.             $resultat['montanttva'] += $ligne->getMontantTva();
  656.             $resultat['montantttc'] += $ligne->getMontantTtc();
  657.             ++$resultat['nbfinancements'];
  658.         }
  659.         return $resultat;
  660.     }
  661. }