src/Entity/Gestiform/Formations/Devis/Devis.php line 23
<?phpnamespace App\Entity\Gestiform\Formations\Devis;use DateTime;use DateTimeInterface;use App\Entity\AbstractEntity;use App\Entity\Common\Upload;use App\Entity\Gestiform\Admin\MasterListe\Masterlistelg;use App\Entity\Gestiform\Admin\Societe;use App\Entity\Gestiform\Formations\Dossier\Dossier;use App\Entity\Gestiform\Formations\Entreprise\Contact;use App\Entity\Gestiform\Formations\Entreprise\Entreprise;use App\Entity\Gestiform\Formations\Financement\Financement;use App\Entity\Gestiform\Users\Employe;use App\Repository\Gestiform\Formations\Devis\DevisRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Serializer\Annotation as Serializer;#[ORM\Entity(repositoryClass: DevisRepository::class)]class Devis extends AbstractEntity{#[ORM\Column(type: 'datetime', nullable: true)]private ?DateTime $start = null;#[ORM\Column(type: 'datetime', nullable: true)]private ?DateTime $end = null;#[ORM\JoinColumn(nullable: true)]#[ORM\ManyToOne(targetEntity: Masterlistelg::class, cascade: ['persist', 'remove'])]private ?Masterlistelg $state = null;#[Serializer\Ignore]#[ORM\JoinColumn(nullable: true)]#[ORM\ManyToOne(targetEntity: Employe::class)]private ?Employe $referentCommercial = null;#[Serializer\Ignore]#[ORM\JoinColumn(nullable: true)]#[ORM\ManyToOne(targetEntity: Contact::class)]private ?Contact $contactEntreprise = null;#[ORM\JoinColumn(nullable: true)]#[ORM\ManyToOne(targetEntity: Societe::class)]private ?Societe $societeSource = null;#[ORM\Column(type: 'string', length: 50, nullable: true)]private ?string $code = null;#[ORM\Column(type: 'string', length: 50, nullable: true)]private ?string $repas = null;#[ORM\JoinColumn(nullable: true)]#[ORM\OneToOne(targetEntity: Upload::class, cascade: ['persist', 'remove'])]private ?Upload $signatureFile = null;#[ORM\Column(type: 'text', nullable: true)]private ?string $signature = null;#[Serializer\Ignore]#[ORM\ManyToOne(targetEntity: Dossier::class, cascade: ['persist'], inversedBy: 'deviss')]private ?Dossier $dossier = null;#[ORM\ManyToMany(targetEntity: Dossier::class, mappedBy: 'devisEntreprises')]private Collection $dossiers;#[ORM\Column(type: 'boolean', nullable: true)]private ?bool $calendrierPerso = null;#[ORM\Column(type: 'boolean', nullable: true)]private ?bool $devisApprenant = null;#[ORM\Column(type: 'boolean', nullable: true)]private ?bool $valide = null;#[ORM\Column(type: 'boolean', nullable: true)]private ?bool $devisEntreprise = null;#[ORM\ManyToOne(targetEntity: Entreprise::class, inversedBy: 'deviss')]private ?Entreprise $entreprise = null;#[ORM\Column(type: 'boolean', nullable: true)]private ?bool $sourceAppli = null;#[ORM\Column(type: 'boolean', nullable: true)]private ?bool $sourceFront = null;#[ORM\Column(type: 'boolean', nullable: true)]private ?bool $devisInter = null;#[ORM\Column(type: 'boolean', nullable: true)]private ?bool $devisIntra = null;#[ORM\Column(type: 'integer', nullable: true)]private ?int $nbApprenants = null;#[ORM\Column(type: 'boolean', nullable: true)]private ?bool $sourceCalendrier = false;#[ORM\Column(type: 'boolean', nullable: true)]private ?bool $chezClient = null;#[ORM\Column(type: 'boolean', nullable: true)]private ?bool $chezOf = null;#[ORM\Column(type: 'datetime', nullable: true)]private ?DateTime $debutFormation = null;#[ORM\Column(type: 'datetime', nullable: true)]private ?DateTime $finFormation = null;#[ORM\Column(type: 'text', nullable: true)]private ?string $commentaire = null;#[ORM\Column(type: 'decimal', precision: 10, scale: 2, nullable: true)]private ?string $montantHT = null;#[ORM\Column(type: 'decimal', precision: 10, scale: 2, nullable: true)]private ?string $remisePourC = null;#[ORM\Column(type: 'decimal', precision: 10, scale: 2, nullable: true)]private ?string $remise = null;#[ORM\Column(type: 'decimal', precision: 10, scale: 2, nullable: true)]private ?string $montantPied = null;#[ORM\Column(type: 'decimal', precision: 10, scale: 2, nullable: true)]private ?string $totalHT = null;#[ORM\JoinColumn(nullable: true)]#[ORM\ManyToOne(targetEntity: Masterlistelg::class)]private ?Masterlistelg $codeTva = null;#[ORM\Column(type: 'decimal', precision: 10, scale: 2, nullable: true)]private ?string $tauxTva = null;#[ORM\Column(type: 'decimal', precision: 10, scale: 2, nullable: true)]private ?string $montantTva = null;#[ORM\Column(type: 'decimal', precision: 10, scale: 2, nullable: true)]private ?string $montantTtc = null;#[ORM\Column(type: 'decimal', precision: 10, scale: 2, nullable: true)]private ?string $totalValidation = null;#[Serializer\Ignore]#[ORM\OneToMany(mappedBy: 'devis', targetEntity: DevisLigne::class, cascade: ['persist'], orphanRemoval: true)]private Collection $devisLignes;#[ORM\OneToMany(mappedBy: 'devis', targetEntity: Financement::class, cascade: ['persist'])]private Collection $financements;public function __construct(){$this->dossiers = new ArrayCollection();$this->devisLignes = new ArrayCollection();$this->financements = new ArrayCollection();}public function getCode(): ?string{return $this->code;}public function setCode(?string $code): self{$this->code = $code;return $this;}public function getRepas(): ?string{return $this->repas;}public function setRepas(?string $repas): self{$this->repas = $repas;return $this;}public function getSignature(): ?string{return $this->signature;}public function setSignature(?string $signature): self{$this->signature = $signature;return $this;}public function isCalendrierPerso(): ?bool{return $this->calendrierPerso;}public function setCalendrierPerso(?bool $calendrierPerso): self{$this->calendrierPerso = $calendrierPerso;return $this;}public function isDevisApprenant(): ?bool{return $this->devisApprenant;}public function setDevisApprenant(?bool $devisApprenant): self{$this->devisApprenant = $devisApprenant;return $this;}public function isValide(): ?bool{return $this->valide;}public function setValide(?bool $valide): self{$this->valide = $valide;return $this;}public function isDevisEntreprise(): ?bool{return $this->devisEntreprise;}public function setDevisEntreprise(?bool $devisEntreprise): self{$this->devisEntreprise = $devisEntreprise;return $this;}public function isSourceAppli(): ?bool{return $this->sourceAppli;}public function setSourceAppli(?bool $sourceAppli): self{$this->sourceAppli = $sourceAppli;return $this;}public function isSourceFront(): ?bool{return $this->sourceFront;}public function setSourceFront(?bool $sourceFront): self{$this->sourceFront = $sourceFront;return $this;}public function isDevisInter(): ?bool{return $this->devisInter;}public function setDevisInter(?bool $devisInter): self{$this->devisInter = $devisInter;return $this;}public function isDevisIntra(): ?bool{return $this->devisIntra;}public function setDevisIntra(?bool $devisIntra): self{$this->devisIntra = $devisIntra;return $this;}public function getNbApprenants(): ?int{return $this->nbApprenants;}public function setNbApprenants(?int $nbApprenants): self{$this->nbApprenants = $nbApprenants;return $this;}public function isSourceCalendrier(): ?bool{return $this->sourceCalendrier;}public function setSourceCalendrier(?bool $sourceCalendrier): self{$this->sourceCalendrier = $sourceCalendrier;return $this;}public function isChezClient(): ?bool{return $this->chezClient;}public function setChezClient(?bool $chezClient): self{$this->chezClient = $chezClient;return $this;}public function isChezOf(): ?bool{return $this->chezOf;}public function setChezOf(?bool $chezOf): self{$this->chezOf = $chezOf;return $this;}public function getDebutFormation(): ?DateTimeInterface{return $this->debutFormation;}public function setDebutFormation(?DateTimeInterface $debutFormation): self{$this->debutFormation = $debutFormation;return $this;}public function getFinFormation(): ?DateTimeInterface{return $this->finFormation;}public function setFinFormation(?DateTimeInterface $finFormation): self{$this->finFormation = $finFormation;return $this;}public function getCommentaire(): ?string{return $this->commentaire;}public function setCommentaire(?string $commentaire): self{$this->commentaire = $commentaire;return $this;}public function getMontantHT(): ?float{return $this->montantHT;}public function setMontantHT(?float $montantHT): self{$this->montantHT = $montantHT;return $this;}public function getRemisePourC(): ?float{return $this->remisePourC;}public function setRemisePourC(?float $remisePourC): self{$this->remisePourC = $remisePourC;return $this;}public function getRemise(): ?float{return $this->remise;}public function setRemise(?float $remise): self{$this->remise = $remise;return $this;}public function getMontantPied(): ?float{return $this->montantPied;}public function setMontantPied(?float $montantPied): self{$this->montantPied = $montantPied;return $this;}public function getTotalHT(): ?float{return $this->totalHT;}public function setTotalHT(?float $totalHT): self{$this->totalHT = $totalHT;return $this;}public function getCodeTva(): ?Masterlistelg{return $this->codeTva;}public function setCodeTva(?Masterlistelg $codeTva): self{$this->codeTva = $codeTva;return $this;}public function getTauxTva(): ?float{return $this->tauxTva;}public function setTauxTva(?float $tauxTva): self{$this->tauxTva = $tauxTva;return $this;}public function getMontantTva(): ?float{return $this->montantTva;}public function setMontantTva(?float $montantTva): self{$this->montantTva = $montantTva;return $this;}public function getMontantTtc(): ?float{return $this->montantTtc;}public function setMontantTtc(?float $montantTtc): self{$this->montantTtc = $montantTtc;return $this;}public function getTotalValidation(): ?float{return $this->totalValidation;}public function setTotalValidation(?float $totalValidation): self{$this->totalValidation = $totalValidation;return $this;}public function getState(): ?Masterlistelg{return $this->state;}public function setState(?Masterlistelg $state): self{$this->state = $state;return $this;}public function getReferentCommercial(): ?Employe{return $this->referentCommercial;}public function setReferentCommercial(?Employe $referentCommercial): self{$this->referentCommercial = $referentCommercial;return $this;}public function getContactEntreprise(): ?Contact{return $this->contactEntreprise;}public function setContactEntreprise(?Contact $contactEntreprise): self{$this->contactEntreprise = $contactEntreprise;return $this;}public function getSocieteSource(): ?Societe{return $this->societeSource;}public function setSocieteSource(?Societe $societeSource): self{$this->societeSource = $societeSource;return $this;}public function getSignatureFile(): ?Upload{return $this->signatureFile;}public function setSignatureFile(?Upload $signatureFile): self{$this->signatureFile = $signatureFile;return $this;}public function getDossier(): ?Dossier{return $this->dossier;}public function setDossier(?Dossier $dossier): self{$this->dossier = $dossier;return $this;}/*** @return Collection<int, Dossier>*/public function getDossiers(): Collection{return $this->dossiers;}public function addDossier(Dossier $dossier): self{if (!$this->dossiers->contains($dossier)) {$this->dossiers->add($dossier);$dossier->addDevisEntreprise($this);}return $this;}public function removeDossier(Dossier $dossier): self{if ($this->dossiers->removeElement($dossier)) {$dossier->removeDevisEntreprise($this);}return $this;}public function getEntreprise(): ?Entreprise{return $this->entreprise;}public function setEntreprise(?Entreprise $entreprise): self{$this->entreprise = $entreprise;return $this;}/*** @return Collection<int, DevisLigne>*/public function getDevisLignes(): Collection{return $this->devisLignes;}public function addDevisLigne(DevisLigne $devisLigne): self{if (!$this->devisLignes->contains($devisLigne)) {$this->devisLignes->add($devisLigne);$devisLigne->setDevis($this);}return $this;}public function removeDevisLigne(DevisLigne $devisLigne): self{// set the owning side to null (unless already changed)if ($this->devisLignes->removeElement($devisLigne) && $devisLigne->getDevis() === $this) {$devisLigne->setDevis(null);}return $this;}public function isSessionsExiste(): bool{$sessionsExiste = false;foreach ($this->devisLignes as $devisLigne) {$sessionsExiste = true;if (is_null($devisLigne->getSession())) {$sessionsExiste = false;}}return $sessionsExiste;}public function calculerMoyenneCoutUnitaireHT(): float{$totalHT = 0;$totalDuree = 0;foreach ($this->getDevisLignes() as $ligne) {$totalHT += $ligne->getMontantHT() ?? 0;$totalDuree += $ligne->getDuree() ?? 0;}return $totalDuree > 0 ? $totalHT / $totalDuree : 0;}/*** @return Collection<int, Financement>*/public function getFinancements(): Collection{return $this->financements;}public function addFinancement(Financement $financement): self{if (!$this->financements->contains($financement)) {$this->financements->add($financement);$financement->setDevis($this);}return $this;}public function removeFinancement(Financement $financement): self{// set the owning side to null (unless already changed)if ($this->financements->removeElement($financement) && $financement->getDevis() === $this) {$financement->setDevis(null);}return $this;}public function getStart(): ?DateTime{return $this->start;}public function setStart(?DateTime $start): self{$this->start = $start;return $this;}public function getEnd(): ?DateTime{return $this->end;}public function setEnd(?DateTime $end): self{$this->end = $end;return $this;}public function getAllFrais(): float{$resultat = 0;foreach ($this->getDevisLignes() as $ligne) {if (!$ligne->isChargeHT()) {$resultat += $ligne->getMontantHT();}}return $resultat;}public function getDetailFinancement(): array{$resultat = [];$resultat['nbfinancements'] = 0;$resultat['montantht'] = 0;$resultat['montanttva'] = 0;$resultat['montantttc'] = 0;foreach ($this->getFinancements() as $ligne) {$resultat['montantht'] += $ligne->getMontantHt();$resultat['montanttva'] += $ligne->getMontantTva();$resultat['montantttc'] += $ligne->getMontantTtc();++$resultat['nbfinancements'];}return $resultat;}}