<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\BFPaymentIntentEditionRepository")
*/
class BFPaymentIntentEdition
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\BFUser", inversedBy="bFPaymentIntentEditions")
* @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
*/
private $user;
/**
* @ORM\Column(type="string", length=255)
*/
private $stripeid;
/**
* @ORM\Column(type="datetime")
*/
private $creationdate;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $successdate;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $failedtime;
/**
* @ORM\OneToMany(targetEntity="App\Entity\BFOrderEdition", mappedBy="bFPaymentIntentEdition", cascade={"persist"}, orphanRemoval=true)
*/
private $ordereditions;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\BFEdition", inversedBy="bFPaymentIntentEditions")
* @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
*/
private $edition;
/**
* @ORM\Column(type="boolean")
*/
private $reclamation;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $refunddate;
/**
* @ORM\Column(type="string", length=255)
*/
private $email;
public function __construct()
{
$this->ordereditions = new ArrayCollection();
$this->creationdate= new \DateTime();
$this->reclamation=false;
}
public function getId(): ?int
{
return $this->id;
}
public function getUser(): ?BFUser
{
return $this->user;
}
public function setUser(?BFUser $user): self
{
$this->user = $user;
if($user!=null)
$this->setEmail($user->getEmail());
return $this;
}
public function getStripeid(): ?string
{
return $this->stripeid;
}
public function setStripeid(string $stripeid): self
{
$this->stripeid = $stripeid;
return $this;
}
public function getCreationdate(): ?\DateTimeInterface
{
return $this->creationdate;
}
public function setCreationdate(\DateTimeInterface $creationdate): self
{
$this->creationdate = $creationdate;
return $this;
}
public function getSuccessdate(): ?\DateTimeInterface
{
return $this->successdate;
}
public function setSuccessdate(?\DateTimeInterface $successdate): self
{
$this->successdate = $successdate;
return $this;
}
public function getFailedtime(): ?\DateTimeInterface
{
return $this->failedtime;
}
public function setFailedtime(?\DateTimeInterface $failedtime): self
{
$this->failedtime = $failedtime;
return $this;
}
/**
* @return Collection|BFOrderEdition[]
*/
public function getOrdereditions(): Collection
{
return $this->ordereditions;
}
public function addOrderedition(BFOrderEdition $orderedition): self
{
if (!$this->ordereditions->contains($orderedition)) {
$this->ordereditions[] = $orderedition;
$orderedition->setBFPaymentIntentEdition($this);
}
return $this;
}
public function removeOrderedition(BFOrderEdition $orderedition): self
{
if ($this->ordereditions->contains($orderedition)) {
$this->ordereditions->removeElement($orderedition);
// set the owning side to null (unless already changed)
if ($orderedition->getBFPaymentIntentEdition() === $this) {
$orderedition->setBFPaymentIntentEdition(null);
}
}
return $this;
}
public function getPrice(): ?int
{
$price = 0;
$bfordereditions = $this->getOrdereditions();
foreach($bfordereditions as $bforderedition)
{
$price+= $bforderedition->getProductedition()->getPrice() * $bforderedition->getQuantity();
}
return $price;
}
public function getDisplayprice(): ?float
{
return $this->getPrice()/100;
}
public function getBffees():?int
{
$bffees=0;
$bfordereditions = $this->getOrdereditions();
foreach($bfordereditions as $bforderedition)
{
$bffees+= $bforderedition->getQuantity() * $bforderedition->getFeebf();
}
return $bffees;
}
public function getDisplaybffees(): ?float
{
return $this->getBffees()/100;
}
public function getEdition(): ?BFEdition
{
return $this->edition;
}
public function setEdition(?BFEdition $edition): self
{
$this->edition = $edition;
return $this;
}
public function getStatus(): ?string
{
if($this->getRefunddate()!=null)
return 'refund';
if($this->getReclamation()==true)
return 'reclamation';
if($this->getSuccessdate()!=null)
return 'success';
if($this->getFailedtime()!=null)
return 'failed';
return 'inprogress';
}
public function getReclamation(): ?bool
{
return $this->reclamation;
}
public function setReclamation(bool $reclamation): self
{
$this->reclamation = $reclamation;
return $this;
}
public function getRefunddate(): ?\DateTimeInterface
{
return $this->refunddate;
}
public function setRefunddate(?\DateTimeInterface $refunddate): self
{
$this->refunddate = $refunddate;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
}