<?php
/**
* @author Quentin CHATELAIN (contact@scaledev.fr)
* @copyright 2021 - ScaleDEV SAS, 12 RUE CHARLES MORET, 10120 ST ANDRE LES VERGERS
* @license commercial
*/
declare(strict_types=1);
namespace Bluue\SalesBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Uid\Uuid;
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
use Gedmo\Mapping\Annotation as Gedmo;
use Bluue\SalesBundle\Repository\DocumentPaymentRepository;
use App\DoctrineExtensions\Timestampable\Traits\UserTimestampableEntity;
use App\DoctrineExtensions\SoftDeleteable\Traits\UserSoftDeleteableEntity;
/**
* @ORM\Entity(repositoryClass=DocumentPaymentRepository::class)
* @ORM\Table(name="sales_bundle__document_payment", indexes={
* @ORM\Index(name="deleted_at", columns={"deleted_at"}),
* @ORM\Index(name="created_at", columns={"created_at"}),
* @ORM\Index(name="updated_at", columns={"updated_at"})
* })
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=false)
*/
class DocumentPayment
{
use UserTimestampableEntity;
use UserSoftDeleteableEntity;
/**
* @ORM\Id
* @ORM\Column(type="uuid")
* @ORM\GeneratedValue(strategy="CUSTOM")
* @ORM\CustomIdGenerator(class=UuidGenerator::class)
*/
private ?Uuid $id = null;
/**
* @ORM\ManyToOne(targetEntity=Payment::class, inversedBy="document_payments")
* @ORM\JoinColumn(nullable=false)
*/
private ?Payment $payment = null;
/**
* @ORM\ManyToOne(targetEntity=Invoice::class, inversedBy="payments")
*/
private ?Invoice $invoice = null;
/**
* @ORM\ManyToOne(targetEntity=CreditNote::class, inversedBy="payments")
*/
private ?CreditNote $credit_note = null;
/**
* @ORM\Column(type="decimal", precision=20, scale=6, nullable="true")
*/
private ?string $amount = null;
/**
* @return Uuid|null
*/
public function getId(): ?Uuid
{
return $this->id;
}
/**
* @return Payment|null
*/
public function getPayment(): ?Payment
{
return $this->payment;
}
/**
* @param Payment|null $payment
* @return DocumentPayment
*/
public function setPayment(?Payment $payment): self
{
$this->payment = $payment;
return $this;
}
/**
* @return Invoice|null
*/
public function getInvoice(): ?Invoice
{
return $this->invoice;
}
/**
* @param Invoice|null $invoice
* @return DocumentPayment
*/
public function setInvoice(?Invoice $invoice): self
{
$this->invoice = $invoice;
return $this;
}
/**
* @return CreditNote|null
*/
public function getCreditNote(): ?CreditNote
{
return $this->credit_note;
}
/**
* @param CreditNote|null $credit_note
* @return DocumentPayment
*/
public function setCreditNote(?CreditNote $credit_note): self
{
$this->credit_note = $credit_note;
return $this;
}
/**
* @return string|null
*/
public function getAmount(): ?string
{
return $this->amount;
}
/**
* @param string|null $amount
* @return DocumentPayment
*/
public function setAmount(?string $amount): self
{
$this->amount = $amount;
return $this;
}
/**
* @return Invoice|CreditNote|null
*/
public function getDocument()
{
return $this->getInvoice() ?? $this->getCreditNote();
}
}