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

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