<?php
namespace App\Entity;
use App\Repository\CubageLivraisonRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Blameable\Traits\BlameableEntity;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use GollumSF\EntityRelationSetter\ManyToOneSetter;
use GollumSF\EntityRelationSetter\OneToManySetter;
use GollumSF\RestBundle\Serializer\Transform\UnserializerTransformInterface;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Table()
* @ORM\Entity(repositoryClass=CubageLivraisonRepository::class)
*/
class CubageLivraison implements UnserializerTransformInterface {
use BlameableEntity;
use TimestampableEntity;
use ManyToOneSetter;
use OneToManySetter;
/**
* @ORM\Column(type="integer", length=25, options={"unsigned"=true})
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @Groups({
* "cubageLivraison_get", "cubageLivraison_getc",
* "cubageLivraisonPlateforme_get", "cubageLivraisonPlateforme_getc",
* "get", "getC",
* "chantier_get",
* "livraison_get",
* })
*
* @var int
*/
private $id;
/**
* @ORM\Column(type="datetime")
* @Groups({
* "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
* "livraison_post", "livraison_put",
* "plateforme_get", "plateforme_getc",
* "cubageLivraisonPlateforme_get", "cubageLivraisonPlateforme_getc",
* })
*
* @Assert\NotNull(groups={"cubageLivraison_post", "cubageLivraison_put"})
*
* @var \DateTime
*/
private $date;
/**
* @ORM\ManyToOne(targetEntity=Chauffeur::class, inversedBy="cubageLivraisons", fetch="EAGER")
* @Groups({
* "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
* "livraison_post", "livraison_put",
* "plateforme_get", "plateforme_getc",
* "cubageLivraisonPlateforme_get", "cubageLivraisonPlateforme_getc",
* })
*
* @Assert\NotNull(groups={"cubageLivraison_post", "cubageLivraison_put"})
*
* @var string
*/
private $chauffeur;
/**
* @ORM\Column(type="string", nullable=true)
* @Groups({
* "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
* "livraison_post", "livraison_put",
* "plateforme_get", "plateforme_getc",
* "cubageLivraisonPlateforme_get", "cubageLivraisonPlateforme_getc",
* })
*
* @Assert\Length(max=255, groups={"cubageLivraison_post", "cubageLivraison_put"})
*
* @var string
*/
private $bl;
/**
* @ORM\Column(type="string", nullable=true)
* @Groups({
* "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
* "livraison_post", "livraison_put",
* "plateforme_get", "plateforme_getc",
* "cubageLivraisonPlateforme_get", "cubageLivraisonPlateforme_getc",
* })
*
* @Assert\Length(max=255, groups={"livraison_post", "livraison_put"})
*
* @var string
*/
private $numfacture;
/**
* @ORM\ManyToOne(targetEntity=Tiers::class, inversedBy="cubageLivraisons", fetch="EAGER")
* @Groups({
* "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
* "livraison_post", "livraison_put",
* })
*
* @Assert\NotNull(groups={"cubageLivraison_post", "cubageLivraison_put"})
*
* @var Tiers
*/
private $scierie;
/**
* @ORM\ManyToOne(targetEntity=Livraison::class, inversedBy="cubageLivraisons")
* @Groups({
* "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
* })
*
* @Assert\NotNull(groups={"cubageLivraison_post", "cubageLivraison_put"})
*
* @var Livraison
*/
private $livraison;
/**
* @ORM\Column(type="boolean")
* @Groups({
* "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
* })
*
* @Assert\NotNull(groups={"cubageLivraison_post", "cubageLivraison_put"})
*
* @var bool
*/
private $estimer = false;
/**
* @ORM\Column(type="boolean")
* @Groups({
* "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
* "cubageLivraisonPlateforme_get", "cubageLivraisonPlateforme_getc",
* "plateforme_get", "plateforme_getc",
* "chantier_get",
* })
*
* @Assert\NotNull(groups={"cubageLivraison_post", "cubageLivraison_put"})
*
* @var bool
*/
private $boisFini = false; // indique qu'il n y a plus de bois de ce type sur chantier
/**
* @ORM\ManyToOne(targetEntity=BoisType::class, inversedBy="cubageLivraisons", fetch="EAGER")
* @Groups({
* "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
* "chantier_get",
* "livraison_get",
* })
*
* @Assert\NotNull(groups={"cubageLivraison_post", "cubageLivraison_put"})
*
* @var BoisType
*/
private $boisType;
/**
* @ORM\ManyToOne(targetEntity=BoisQuality::class, inversedBy="cubageLivraisons", fetch="EAGER")
* @Groups({
* "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
* "chantier_get",
* "livraison_get",
* })
*
* @Assert\NotNull(groups={"cubageLivraison_post", "cubageLivraison_put"})
*
* @var BoisQuality
*/
private $boisQuality;
/**
* @ORM\ManyToOne(targetEntity=BoisSize::class, inversedBy="cubageLivraisons", fetch="EAGER")
* @Groups({
* "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
* "chantier_get",
* "livraison_get",
* })
*
* @Assert\NotNull(groups={"cubageLivraison_post", "cubageLivraison_put"})
*
* @var BoisSize
*/
private $boisSize;
/**
* @ORM\ManyToOne(targetEntity=Marquage::class, inversedBy="cubageLivraisons")
* @Groups({
* "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
* "chantier_get",
* "livraison_get",
* })
*
* @var Marquage
*/
private $marquage;
/**
* @ORM\Column(type="float")
* @Groups({
* "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
* "cubageLivraisonPlateforme_get", "cubageLivraisonPlateforme_getc",
* "chantier_get",
* "livraison_get",
* })
*
* @Assert\NotNull(groups={"cubageLivraison_post", "cubageLivraison_put"})
*
* @var float
*/
private $volumeInner;
/**
* @ORM\Column(type="boolean")
* @Groups({
* "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
* "chantier_get",
* "livraison_get",
* })
*
* @Assert\NotNull(groups={"cubageLivraison_post", "cubageLivraison_put"})
*
* @var bool
*/
private $volumeApproximatif = true;
/**
* @ORM\Column(type="float", nullable=true)
* @Groups({
* "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put"
* })
*
* @var float
*/
private $volumeOutter;
/**
* @ORM\Column(type="float", nullable=true)
* @Groups({
* "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put"
* })
*
* @var float
*/
private $coef;
/**
* @ORM\Column(type="float", nullable=true)
* @Groups({
* "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put"
* })
*
* @var float
*/
private $volumeStere;
/**
* @ORM\Column(type="float", nullable=true)
* @Groups({
* "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put"
* })
*
* @var float
*/
private $coefStere;
/**
* @ORM\Column(type="float", nullable=true)
* @Groups({
* "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put"
* })
*
* @var float
*/
private $volumeTonne;
/**
* @ORM\Column(type="float", nullable=true)
* @Groups({
* "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put"
* })
*
* @var float
*/
private $coefTonne;
/**
* @ORM\Column(type="float", nullable=true)
* @Groups({
* "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
* "livraison_get",
* })
*
* @var float
*/
private $prixM3;
/**
* @ORM\Column(type="float", nullable=true)
* @Groups({
* "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
* "livraison_get",
* })
*
* @var float
*/
private $prixStere;
/**
* @ORM\Column(type="float", nullable=true)
* @Groups({
* "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
* "livraison_get",
* })
*
* @var float
*/
private $prixTonne;
/**
* @ORM\Column(type="float", nullable=true)
* @Groups({
* "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
* "livraison_get",
* })
*
* @var float
*/
private $prixCamion;
/**
* @ORM\ManyToOne(targetEntity=Chantier::class, inversedBy="cubageLivraisons", fetch="EAGER")
* @Groups({
* "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post",
* "plateforme_get", "plateforme_getc",
* "cubageLivraisonPlateforme_get", "cubageLivraisonPlateforme_getc",
* "livraison_get",
* })
*
* @Assert\NotNull(groups={"cubageLivraison_post", "cubageLivraison_put"})
*
* @var Chantier
*/
private $chantier;
/**
* @ORM\OneToMany(targetEntity=DocumentCubageLivraison::class, mappedBy="cubageLivraison", cascade={"remove"})
* @Groups({
* "cubageLivraison_get", "cubageLivraison_getc",
* })
*
* @var DocumentCubageLivraison[]|ArrayCollection
*/
private $documentCubageLivraisons;
/**
* @ORM\ManyToOne(targetEntity=CubageLivraisonPlateforme::class, inversedBy="cubageLivraisons", fetch="EAGER")
* @Groups({
* "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
* "chantier_get",
* })
*
* @var CubageLivraisonPlateforme
*/
private $cubageLivraisonPlateforme;
public function __construct() {
$this->documentCubageLivraisons = new ArrayCollection();
}
/////////////
// Getters //
/////////////
public function getId(): ?int {
return $this->id;
}
public function getDate(): ?\DateTime {
return $this->date;
}
public function getChauffeur(): ?Chauffeur {
return $this->chauffeur;
}
public function getBl(): ?string {
return $this->bl;
}
public function getNumfacture(): ?string {
return $this->numfacture;
}
public function getScierie(): ?Tiers {
return $this->scierie;
}
public function getLivraison(): ?Livraison {
return $this->livraison;
}
public function getEstimer(): ?bool {
return $this->estimer;
}
public function getBoisFini(): ?bool {
return $this->boisFini;
}
public function getVolumeApproximatif(): ?bool {
return $this->volumeApproximatif;
}
public function getBoisType(): ?BoisType {
return $this->boisType;
}
public function getBoisQuality(): ?BoisQuality {
return $this->boisQuality;
}
public function getBoisSize(): ?BoisSize {
return $this->boisSize;
}
public function getMarquage(): ?Marquage {
return $this->marquage;
}
public function getVolumeInner(): ?float {
return $this->volumeInner;
}
public function getVolumeOutter(): ?float {
return $this->volumeOutter;
}
public function getCoef(): ?float {
return $this->coef;
}
public function getVolumeStere(): ?float {
return $this->volumeStere;
}
public function getCoefStere(): ?float {
return $this->coefStere;
}
public function getVolumeTonne(): ?float {
return $this->volumeTonne;
}
public function getCoefTonne(): ?float {
return $this->coefTonne;
}
public function getPrixM3(): ?float {
return $this->prixM3;
}
public function getPrixStere(): ?float {
return $this->prixStere;
}
public function getPrixTonne(): ?float {
return $this->prixTonne;
}
public function getPrixCamion(): ?float {
return $this->prixCamion;
}
public function getChantier(): ?Chantier {
return $this->chantier;
}
/**
* @return DocumentCubageLivraison[]|ArrayCollection
*/
public function getDocumentCubageLivraisons() {
return $this->documentCubageLivraisons;
}
public function getCubageLivraisonPlateforme(): ?CubageLivraisonPlateforme {
return $this->cubageLivraisonPlateforme;
}
/////////////
// Setters //
/////////////
public function setDate(?\DateTime $date): self {
$this->date = $date;
return $this;
}
public function setChauffeur(?Chauffeur $chauffeur): self {
return $this->manyToOneSet($chauffeur);
}
public function setBl(?string $bl): self {
$this->bl = $bl;
return $this;
}
public function setNumfacture(?string $bl): self {
$this->numfacture = $bl;
return $this;
}
public function setScierie(?Tiers $scierie): self {
return $this->manyToOneSet($scierie, 'scierie', 'cubageLivraison');
}
public function setLivraison(?Livraison $value): self {
return $this->manyToOneSet($value);
}
public function setEstimer(?bool $estimer): self {
$this->estimer = $estimer;
return $this;
}
public function setBoisFini(?bool $boisFini): self {
$this->boisFini = $boisFini;
return $this;
}
public function setVolumeApproximatif(?bool $volumeApproximatif): self {
$this->volumeApproximatif = $volumeApproximatif;
return $this;
}
public function setBoisType(?BoisType $boisType): self {
return $this->manyToOneSet($boisType);
}
public function setBoisQuality(?BoisQuality $boisQuality): self {
return $this->manyToOneSet($boisQuality);
}
public function setBoisSize(?BoisSize $boisSize): self {
return $this->manyToOneSet($boisSize);
}
public function setMarquage(?Marquage $marquage): self {
return $this->manyToOneSet($marquage);
}
public function setVolumeInner(?float $volumeInner): self {
$this->volumeInner = $volumeInner;
return $this;
}
public function setVolumeOutter(?float $volumeOutter): self {
$this->volumeOutter = $volumeOutter;
return $this;
}
public function setCoef(?float $coef): self {
$this->coef = $coef;
return $this;
}
public function setVolumeStere(?float $volumeStere): self {
$this->volumeStere = $volumeStere;
return $this;
}
public function setCoefStere(?float $coef): self {
$this->coefStere = $coef;
return $this;
}
public function setVolumeTonne(?float $volumeStere): self {
$this->volumeTonne = $volumeStere;
return $this;
}
public function setCoefTonne(?float $coef): self {
$this->coefTonne = $coef;
return $this;
}
public function setPrixM3(?float $prixM3): self {
$this->prixM3 = $prixM3;
return $this;
}
public function setPrixStere(?float $prixStere): self {
$this->prixStere = $prixStere;
return $this;
}
public function setPrixTonne(?float $prixTonne): self {
$this->prixTonne = $prixTonne;
return $this;
}
public function setPrixCamion(?float $prixCamion): self {
$this->prixCamion = $prixCamion;
return $this;
}
public function setChantier(?Chantier $chantier): self {
return $this->manyToOneSet($chantier);
}
public function setCubageLivraisonPlateforme (?CubageLivraisonPlateforme $cubageLivraisonPlateforme): self {
return $this->manyToOneSet($cubageLivraisonPlateforme);
}
/////////
// Add //
/////////
public function addDocumentCubageLivraison(DocumentCubageLivraison $document): self {
return $this->oneToManyAdd($document);
}
////////////
// Remove //
////////////
public function removeDocumentCubageLivraison(DocumentCubageLivraison $document): self {
return $this->oneToManyRemove($document);
}
///////////////
// Serialize //
///////////////
/**
* @param $data
* @param string[] $groups
*/
public function unserializeTransform($data, array $groups): void {
if ($this->volumeOutter && $this->coef) {
$this->volumeInner = round($this->volumeOutter * $this->coef, 2);
} else
if ($this->volumeInner && $this->coef) {
$this->volumeOutter = round($this->volumeInner / $this->coef, 2);
} else
if ($this->volumeInner && $this->volumeOutter) {
$this->coef = round($this->volumeInner / $this->volumeOutter, 2);
}
}
}