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

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