<?php
namespace App\Entity;
use App\Repository\TmpReceptionRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=TmpReceptionRepository::class)
*/
class TmpReception
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=15)
*/
private $volume;
/**
* @ORM\Column(type="string", length=15)
*/
private $tonne;
/**
* @ORM\Column(type="boolean")
*/
private $isflag;
/**
* @ORM\Column(type="string", length=10)
*/
private $unite;
/**
* @ORM\Column(type="string", length=255)
*/
private $nature;
/**
* @ORM\Column(type="string", length=255)
*/
private $classementdepot;
/**
* @ORM\Column(type="string", length=10)
*/
private $quantite;
/**
* @ORM\Column(type="string", length=100)
*/
private $flutterid;
/**
* @ORM\ManyToOne(targetEntity=Reception::class, inversedBy="tmpReceptions", cascade={"persist", "remove"})
*/
private $reception;
/**
* @ORM\ManyToOne(targetEntity=Utilisateur::class, inversedBy="tmpReceptions")
*/
private $user;
/**
* @ORM\ManyToOne(targetEntity=CategoriePrix::class, inversedBy="tmpReceptions")
* @ORM\JoinColumn(nullable=true)
*/
private $categoriePrix;
/**
* Prix forfaitaire manuel (si la valeur n'est pas dans CategoriePrix)
* @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
*/
private $prixFixe;
/**
* @ORM\OneToMany(targetEntity=TmpConteneurReception::class, mappedBy="tmpReception")
*/
private $tmpConteneurReceptions;
/**
* @ORM\OneToMany(targetEntity=PaiementReception::class, mappedBy="tmpReception")
*/
private $paiementReceptions;
private $totalLoaded;
public function __construct()
{
$this->tmpConteneurReceptions = new ArrayCollection();
$this->paiementReceptions = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
/**
* Obtenir le montant total déjà payé pour cet article
*/
public function getTotalPaye(): float
{
$total = 0.0;
foreach ($this->paiementReceptions as $paiement) {
$total += (float) $paiement->getMontantPaye();
}
return $total;
}
public function getPrixFixe(): ?string
{
return $this->prixFixe;
}
public function setPrixFixe(?string $prixFixe): self
{
$this->prixFixe = $prixFixe;
return $this;
}
/**
* Méthode utilitaire pour obtenir le tarif appliqué (Forfait ou Catégorie)
*/
public function getTarifApplique(): float
{
if ($this->prixFixe !== null) {
return (float) $this->prixFixe;
}
if ($this->categoriePrix !== null) {
return (float) $this->categoriePrix->getPrix(); // Adaptez getPrix() selon votre entité CategoriePrix
}
return 0.0;
}
public function getNature(): ?string
{
return strtoupper($this->nature);
}
public function setNature(string $nature): self
{
$this->nature = $nature;
return $this;
}
public function getFlutterid(): ?string
{
return $this->flutterid;
}
public function setFlutterid(string $flutterid): self
{
$this->flutterid = $flutterid;
return $this;
}
public function getQuantite(): ?string
{
return $this->quantite;
}
public function setQuantite(string $quantite): self
{
$this->quantite = $quantite;
return $this;
}
public function getVolume(): ?string
{
return $this->volume;
}
public function setVolume(string $volume): self
{
$this->volume = $volume;
return $this;
}
public function getTonne(): ?string
{
return $this->tonne;
}
public function setTonne(string $tonne): self
{
$this->tonne = $tonne;
return $this;
}
public function isIsflag(): ?bool
{
return $this->isflag;
}
public function setIsflag(bool $isflag): self
{
$this->isflag = $isflag;
return $this;
}
public function getUnite(): ?string
{
return $this->unite;
}
public function setUnite(string $unite): self
{
$this->unite = $unite;
return $this;
}
public function getReception(): ?Reception
{
return $this->reception;
}
public function setReception(?Reception $reception): self
{
$this->reception = $reception;
return $this;
}
public function getUser(): ?Utilisateur
{
return $this->user;
}
public function setUser(?Utilisateur $user): self
{
$this->user = $user;
return $this;
}
public function getCategoriePrix(): ?CategoriePrix
{
return $this->categoriePrix;
}
public function setCategoriePrix(?CategoriePrix $categoriePrix): self
{
$this->categoriePrix = $categoriePrix;
return $this;
}
public function getClassementdepot(): string
{
return $this->classementdepot;
}
public function setClassementdepot(string $classementdepot): self
{
$this->classementdepot = $classementdepot;
return $this;
}
/**
* @return Collection<int, TmpConteneurReception>
*/
public function getTmpConteneurReceptions(): Collection
{
return $this->tmpConteneurReceptions;
}
public function addTmpConteneurReception(TmpConteneurReception $tmpConteneurReception): self
{
if (!$this->tmpConteneurReceptions->contains($tmpConteneurReception)) {
$this->tmpConteneurReceptions[] = $tmpConteneurReception;
$tmpConteneurReception->setTmpReception($this);
}
return $this;
}
public function removeTmpConteneurReception(TmpConteneurReception $tmpConteneurReception): self
{
if ($this->tmpConteneurReceptions->removeElement($tmpConteneurReception)) {
if ($tmpConteneurReception->getTmpReception() === $this) {
$tmpConteneurReception->setTmpReception(null);
}
}
return $this;
}
public function getTotalLOADED()
{
$total = 0;
foreach($this->getTmpConteneurReceptions() as $v){
$total = $total + $v->getQuantite();
}
return $this->totalLoaded = $total;
}
/**
* @return Collection<int, PaiementReception>
*/
public function getPaiementReceptions(): Collection
{
return $this->paiementReceptions;
}
public function addPaiementReception(PaiementReception $paiementReception): self
{
if (!$this->paiementReceptions->contains($paiementReception)) {
$this->paiementReceptions[] = $paiementReception;
$paiementReception->setTmpReception($this);
}
return $this;
}
public function removePaiementReception(PaiementReception $paiementReception): self
{
if ($this->paiementReceptions->removeElement($paiementReception)) {
if ($paiementReception->getTmpReception() === $this) {
$paiementReception->setTmpReception(null);
}
}
return $this;
}
}