added comment field to invoice (#3045)

This commit is contained in:
Kevin Papst
2021-12-30 21:49:30 +01:00
committed by GitHub
parent f7b3f4ed76
commit cc809183ae
13 changed files with 190 additions and 52 deletions

View File

@@ -12,6 +12,7 @@ namespace App\Entity;
use App\Export\Annotation as Exporter;
use App\Invoice\InvoiceModel;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as Serializer;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert;
@@ -26,7 +27,7 @@ use Symfony\Component\Validator\Constraints as Assert;
* @UniqueEntity("invoiceNumber")
* @UniqueEntity("invoiceFilename")
*
* @Exporter\Order({"id", "createdAt", "invoiceNumber", "status", "customer", "subtotal", "total", "tax", "currency", "vat", "dueDays", "dueDate", "paymentDate", "user", "invoiceFilename"})
* @Exporter\Order({"id", "createdAt", "invoiceNumber", "status", "customer", "subtotal", "total", "tax", "currency", "vat", "dueDays", "dueDate", "paymentDate", "user", "invoiceFilename", "comment"})
* @Exporter\Expose("customer", label="label.customer", exp="object.getCustomer() === null ? null : object.getCustomer().getName()")
* @Exporter\Expose("customerNumber", label="label.number", exp="object.getCustomer() === null ? null : object.getCustomer().getNumber()")
* @Exporter\Expose("dueDate", label="invoice.due_days", type="datetime", exp="object.getDueDate() === null ? null : object.getDueDate()")
@@ -62,6 +63,18 @@ class Invoice
*/
private $invoiceNumber;
/**
* @var string
*
* @Serializer\Expose()
* @Serializer\Groups({"Customer_Entity"})
*
* @Exporter\Expose(label="label.comment")
*
* @ORM\Column(name="comment", type="text", nullable=true)
*/
private $comment;
/**
* @var Customer|null
*
@@ -177,7 +190,7 @@ class Invoice
private $localized = false;
/**
* @var \DateTime
* @var \DateTime|null
*
* @ORM\Column(name="payment_date", type="date", nullable=true)
*/
@@ -312,6 +325,20 @@ class Invoice
return $this->status === self::STATUS_CANCELED;
}
public function getStatus(): string
{
return $this->status;
}
public function setStatus(string $status): void
{
if (!\in_array($status, [self::STATUS_NEW, self::STATUS_PENDING, self::STATUS_PAID, self::STATUS_CANCELED])) {
throw new \InvalidArgumentException('Unknown invoice status');
}
$this->status = $status;
}
public function setIsCanceled(): void
{
$this->status = self::STATUS_CANCELED;
@@ -362,4 +389,14 @@ class Invoice
return $this;
}
public function setComment(?string $comment): void
{
$this->comment = $comment;
}
public function getComment(): ?string
{
return $this->comment;
}
}