src/Flexy/ShopBundle/Entity/Accounting/Invoice.php line 20
<?php
namespace App\Flexy\ShopBundle\Entity\Accounting;
use ApiPlatform\Metadata\ApiResource;
use App\Flexy\ShopBundle\Entity\Customer\Customer;
use App\Flexy\ShopBundle\Entity\Customer\CustomerWalletPoint;
use App\Flexy\ShopBundle\Entity\Order\Order;
use App\Flexy\ShopBundle\Entity\Payment\PaymentMethod;
use App\Repository\Flexy\ShopBundle\Entity\Accounting\InvoiceRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: InvoiceRepository::class)]
#[ApiResource]
class Invoice
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\OneToMany(mappedBy: 'invoice', targetEntity: Order::class)]
private Collection $orders;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $description = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $createdAt = null;
#[ORM\ManyToOne(inversedBy: 'invoices', cascade: ['persist'])]
#[Assert\Valid]
private ?Customer $customer = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $firstName = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $lastName = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $companyName = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $address = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $city = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $country = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $postcode = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $email = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $tel = null;
#[ORM\Column(nullable: true)]
private ?float $payedAmount = null;
#[ORM\Column(type: 'float', nullable: true)]
private $walletPaymentAmount = 0;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $tokenStripe;
#[ORM\ManyToOne(inversedBy: 'invoices')]
private ?PaymentMethod $paymentMethod = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $status = "draft";
#[ORM\OneToMany(mappedBy: 'invoice', targetEntity: CustomerWalletPoint::class)]
private Collection $customerWalletPoints;
#[ORM\Column(length: 255, nullable: true)]
private ?string $source = null;
public function __construct()
{
$this->orders = new ArrayCollection();
$this->customerWalletPoints = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
/**
* @return Collection<int, Order>
*/
public function getOrders(): Collection
{
return $this->orders;
}
public function addOrder(Order $order): self
{
if (!$this->orders->contains($order)) {
$this->orders->add($order);
$order->setInvoice($this);
}
return $this;
}
public function removeOrder(Order $order): self
{
if ($this->orders->removeElement($order)) {
// set the owning side to null (unless already changed)
if ($order->getInvoice() === $this) {
$order->setInvoice(null);
}
}
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(?\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getCustomer(): ?Customer
{
return $this->customer;
}
public function setCustomer(?Customer $customer): self
{
$this->customer = $customer;
return $this;
}
/**
* Get the value of firstName
*/
public function getFirstName()
{
return $this->firstName;
}
/**
* Set the value of firstName
*
* @return self
*/
public function setFirstName($firstName)
{
$this->firstName = $firstName;
return $this;
}
/**
* Get the value of lastName
*/
public function getLastName()
{
return $this->lastName;
}
/**
* Set the value of lastName
*
* @return self
*/
public function setLastName($lastName)
{
$this->lastName = $lastName;
return $this;
}
/**
* Get the value of companyName
*/
public function getCompanyName()
{
return $this->companyName;
}
/**
* Set the value of companyName
*
* @return self
*/
public function setCompanyName($companyName)
{
$this->companyName = $companyName;
return $this;
}
/**
* Get the value of tel
*/
public function getTel()
{
return $this->tel;
}
/**
* Set the value of tel
*
* @return self
*/
public function setTel($tel)
{
$this->tel = $tel;
return $this;
}
/**
* Get the value of email
*/
public function getEmail()
{
return $this->email;
}
/**
* Set the value of email
*
* @return self
*/
public function setEmail($email)
{
$this->email = $email;
return $this;
}
/**
* Get the value of postcode
*/
public function getPostcode()
{
return $this->postcode;
}
/**
* Set the value of postcode
*
* @return self
*/
public function setPostcode($postcode)
{
$this->postcode = $postcode;
return $this;
}
/**
* Get the value of country
*/
public function getCountry()
{
return $this->country;
}
/**
* Set the value of country
*
* @return self
*/
public function setCountry($country)
{
$this->country = $country;
return $this;
}
/**
* Get the value of city
*/
public function getCity()
{
return $this->city;
}
/**
* Set the value of city
*
* @return self
*/
public function setCity($city)
{
$this->city = $city;
return $this;
}
/**
* Get the value of address
*/
public function getAddress()
{
return $this->address;
}
/**
* Set the value of address
*
* @return self
*/
public function setAddress($address)
{
$this->address = $address;
return $this;
}
public function getTotalAmount(){
$totalAmount = 0;
foreach($this->getOrders() as $singleOrder){
$totalAmount = $totalAmount + $singleOrder->getTotalAmount();
}
return $totalAmount;
}
public function getPayedAmount(): ?float
{
return $this->payedAmount;
}
public function setPayedAmount(?float $payedAmount): self
{
$this->payedAmount = $payedAmount;
return $this;
}
/**
* Get the value of walletPaymentAmount
*/
public function getWalletPaymentAmount()
{
return $this->walletPaymentAmount;
}
/**
* Set the value of walletPaymentAmount
*
* @return self
*/
public function setWalletPaymentAmount($walletPaymentAmount)
{
$this->walletPaymentAmount = $walletPaymentAmount;
return $this;
}
/**
* Get the value of tokenStripe
*/
public function getTokenStripe()
{
return $this->tokenStripe;
}
/**
* Set the value of tokenStripe
*
* @return self
*/
public function setTokenStripe($tokenStripe)
{
$this->tokenStripe = $tokenStripe;
return $this;
}
public function getPaymentMethod(): ?PaymentMethod
{
return $this->paymentMethod;
}
public function setPaymentMethod(?PaymentMethod $paymentMethod): self
{
$this->paymentMethod = $paymentMethod;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(?string $status): self
{
$this->status = $status;
return $this;
}
/**
* @return Collection<int, CustomerWalletPoint>
*/
public function getCustomerWalletPoints(): Collection
{
return $this->customerWalletPoints;
}
public function addCustomerWalletPoint(CustomerWalletPoint $customerWalletPoint): self
{
if (!$this->customerWalletPoints->contains($customerWalletPoint)) {
$this->customerWalletPoints->add($customerWalletPoint);
$customerWalletPoint->setInvoice($this);
}
return $this;
}
public function removeCustomerWalletPoint(CustomerWalletPoint $customerWalletPoint): self
{
if ($this->customerWalletPoints->removeElement($customerWalletPoint)) {
// set the owning side to null (unless already changed)
if ($customerWalletPoint->getInvoice() === $this) {
$customerWalletPoint->setInvoice(null);
}
}
return $this;
}
public function getSource(): ?string
{
return $this->source;
}
public function setSource(?string $source): self
{
$this->source = $source;
return $this;
}
}