<?php
namespace App\Entity;
use App\Repository\FactureRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=FactureRepository::class)
*/
class Facture
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $montant;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="factures")
* @ORM\JoinColumn(nullable=false)
*/
private $user;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $paid_at;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $cancelled_at;
/**
* @ORM\Column(type="datetime")
*/
private $created_at;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $type_payement;
/**
* @ORM\OneToMany(targetEntity=Souscription::class, mappedBy="facture")
*/
private $souscriptions;
/**
* @ORM\Column(type="string", length=255)
*/
private $email;
/**
* @ORM\Column(type="string", length=255)
*/
private $nom;
/**
* @ORM\Column(type="string", length=255)
*/
private $adresse;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $adresse2;
/**
* @ORM\Column(type="string", length=255)
*/
private $pays;
/**
* @ORM\Column(type="string", length=255)
*/
private $ville;
/**
* @ORM\Column(type="string", length=255)
*/
private $region;
/**
* @ORM\Column(type="string", length=255)
*/
private $zip;
/**
* @ORM\Column(type="string", length=255)
*/
private $tel;
/**
* @ORM\Column(type="integer")
*/
private $status;
/**
* @ORM\Column(type="string", length=255)
*/
private $code;
const FULL_STATUS =['impayée','Payée','Annulée'];
public function __construct()
{
$this->souscriptions = new ArrayCollection();
$this->created_at = new \DateTime();
$this->status = 0;
}
public function getTax()
{
return floor(($this->montant*0.18) / 5 ) * 5;
}
public function getFullStatus()
{
return self::FULL_STATUS[$this->status];
}
public function getId(): ?int
{
return $this->id;
}
public function getMontant(): ?float
{
return $this->montant;
}
public function setMontant(?float $montant): self
{
$this->montant = $montant;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getPaidAt(): ?\DateTimeInterface
{
return $this->paid_at;
}
public function setPaidAt(?\DateTimeInterface $paid_at): self
{
$this->paid_at = $paid_at;
return $this;
}
public function getCancelledAt(): ?\DateTimeInterface
{
return $this->cancelled_at;
}
public function setCancelledAt(?\DateTimeInterface $cancelled_at): self
{
$this->cancelled_at = $cancelled_at;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->created_at;
}
public function setCreatedAt(\DateTimeInterface $created_at): self
{
$this->created_at = $created_at;
return $this;
}
public function getTypePayement(): ?int
{
return $this->type_payement;
}
public function setTypePayement(?int $type_payement): self
{
$this->type_payement = $type_payement;
return $this;
}
/**
* @return Collection|Souscription[]
*/
public function getSouscriptions(): Collection
{
return $this->souscriptions;
}
public function addSouscription(Souscription $souscription): self
{
if (!$this->souscriptions->contains($souscription)) {
$this->souscriptions[] = $souscription;
$souscription->setFacture($this);
}
return $this;
}
public function removeSouscription(Souscription $souscription): self
{
if ($this->souscriptions->contains($souscription)) {
$this->souscriptions->removeElement($souscription);
// set the owning side to null (unless already changed)
if ($souscription->getFacture() === $this) {
$souscription->setFacture(null);
}
}
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
public function getNom(): ?string
{
return $this->nom;
}
public function setNom(string $nom): self
{
$this->nom = $nom;
return $this;
}
public function getAdresse(): ?string
{
return $this->adresse;
}
public function setAdresse(string $adresse): self
{
$this->adresse = $adresse;
return $this;
}
public function getAdresse2(): ?string
{
return $this->adresse2;
}
public function setAdresse2(?string $adresse2): self
{
$this->adresse2 = $adresse2;
return $this;
}
public function getPays(): ?string
{
return $this->pays;
}
public function setPays(string $pays): self
{
$this->pays = $pays;
return $this;
}
public function getVille(): ?string
{
return $this->ville;
}
public function setVille(string $ville): self
{
$this->ville = $ville;
return $this;
}
public function getRegion(): ?string
{
return $this->region;
}
public function setRegion(string $region): self
{
$this->region = $region;
return $this;
}
public function getZip(): ?string
{
return $this->zip;
}
public function setZip(string $zip): self
{
$this->zip = $zip;
return $this;
}
public function getTel(): ?string
{
return $this->tel;
}
public function setTel(string $tel): self
{
$this->tel = $tel;
return $this;
}
public function getStatus(): ?int
{
return $this->status;
}
public function setStatus(int $status): self
{
$this->status = $status;
return $this;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(string $code): self
{
$this->code = $code;
return $this;
}
}