added new invoice status: canceled (#2922)
This commit is contained in:
@@ -144,6 +144,7 @@ class ExportController extends AbstractController
|
||||
/**
|
||||
* @param ExportQuery $query
|
||||
* @return ExportItemInterface[]
|
||||
* @throws TooManyItemsExportException
|
||||
*/
|
||||
protected function getEntries(ExportQuery $query): array
|
||||
{
|
||||
|
||||
@@ -37,6 +37,7 @@ class Invoice
|
||||
{
|
||||
public const STATUS_PENDING = 'pending';
|
||||
public const STATUS_PAID = 'paid';
|
||||
public const STATUS_CANCELED = 'canceled';
|
||||
public const STATUS_NEW = 'new';
|
||||
|
||||
/**
|
||||
@@ -306,6 +307,16 @@ class Invoice
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isCanceled(): bool
|
||||
{
|
||||
return $this->status === self::STATUS_CANCELED;
|
||||
}
|
||||
|
||||
public function setIsCanceled(): void
|
||||
{
|
||||
$this->status = self::STATUS_CANCELED;
|
||||
}
|
||||
|
||||
public function getDueDays(): int
|
||||
{
|
||||
return $this->dueDays;
|
||||
|
||||
@@ -30,12 +30,18 @@ class InvoiceSubscriber extends AbstractActionsSubscriber
|
||||
return;
|
||||
}
|
||||
|
||||
if ($invoice->isNew() || $invoice->isPaid()) {
|
||||
if (!$invoice->isPending()) {
|
||||
$event->addAction('invoice.pending', ['url' => $this->path('admin_invoice_status', ['id' => $invoice->getId(), 'status' => 'pending'])]);
|
||||
} elseif ($invoice->isPending()) {
|
||||
} else {
|
||||
$event->addAction('invoice.paid', ['url' => $this->path('admin_invoice_status', ['id' => $invoice->getId(), 'status' => 'paid']), 'class' => 'modal-ajax-form']);
|
||||
}
|
||||
|
||||
if (!$invoice->isCanceled()) {
|
||||
$event->addAction('invoice.cancel', ['url' => $this->path('admin_invoice_status', ['id' => $invoice->getId(), 'status' => 'canceled'])]);
|
||||
}
|
||||
|
||||
$event->addDivider();
|
||||
|
||||
$event->addAction('download', ['url' => $this->path('admin_invoice_download', ['id' => $invoice->getId()]), 'target' => '_blank']);
|
||||
$event->addDelete($this->path('admin_invoice_delete', ['id' => $invoice->getId(), 'token' => $payload['token']]), false);
|
||||
}
|
||||
|
||||
@@ -239,10 +239,6 @@ final class ServiceInvoice
|
||||
|
||||
public function changeInvoiceStatus(Invoice $invoice, string $status)
|
||||
{
|
||||
if (!\in_array($status, [Invoice::STATUS_NEW, Invoice::STATUS_PENDING, Invoice::STATUS_PAID])) {
|
||||
throw new \InvalidArgumentException('Unknown invoice status');
|
||||
}
|
||||
|
||||
switch ($status) {
|
||||
case Invoice::STATUS_NEW:
|
||||
$invoice->setIsNew();
|
||||
@@ -255,6 +251,13 @@ final class ServiceInvoice
|
||||
case Invoice::STATUS_PAID:
|
||||
$invoice->setIsPaid();
|
||||
break;
|
||||
|
||||
case Invoice::STATUS_CANCELED:
|
||||
$invoice->setIsCanceled();
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new \InvalidArgumentException('Unknown invoice status');
|
||||
}
|
||||
|
||||
$this->invoiceRepository->saveInvoice($invoice);
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
{% else %}
|
||||
{{ tables.datatable_header(tableName, columns, query, {}) }}
|
||||
{% for entry in entries %}
|
||||
<tr class="alternative-link open-edit" data-href="{{ path('admin_invoice_download', {'id': entry.id}) }}">
|
||||
<tr class="alternative-link open-edit{% if entry.canceled %} warning text-muted{% endif %}" data-href="{{ path('admin_invoice_download', {'id': entry.id}) }}">
|
||||
<td class="{{ tables.data_table_column_class(tableName, columns, 'date') }}">{{ entry.createdAt|date_short }}</td>
|
||||
<td class="{{ tables.data_table_column_class(tableName, columns, 'user') }}">{{ widgets.user_avatar(entry.user) }} {{ widgets.username(entry.user) }}</td>
|
||||
<td class="{{ tables.data_table_column_class(tableName, columns, 'customer') }}">{{ widgets.label_customer(entry.customer) }}</td>
|
||||
|
||||
@@ -12,12 +12,16 @@
|
||||
{{ widgets.label('status.pending'|trans, 'warning') }}
|
||||
{% elseif invoice.paid %}
|
||||
{{ widgets.label('status.paid'|trans, 'success') }}
|
||||
{% elseif invoice.canceled %}
|
||||
{{ widgets.label('status.canceled'|trans, 'gray') }}
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro invoice_due_date(invoice) %}
|
||||
{% import "macros/widgets.html.twig" as widgets %}
|
||||
{% if invoice.overdue and not invoice.paid %}
|
||||
{% if invoice.canceled %}
|
||||
{{ widgets.label('status.canceled'|trans, 'gray') }}
|
||||
{% elseif invoice.overdue and not invoice.paid %}
|
||||
{{ widgets.label(invoice.dueDate|date_short, 'danger') }}
|
||||
{% else %}
|
||||
{{ widgets.label(invoice.dueDate|date_short, 'primary') }}
|
||||
|
||||
@@ -94,6 +94,10 @@
|
||||
<source>invoice.paid</source>
|
||||
<target>Rechnung bezahlt</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="7d1V9FU" resname="invoice.cancel">
|
||||
<source>invoice.cancel</source>
|
||||
<target>Rechnung stornieren</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="38M3a4J" resname="filter">
|
||||
<source>filter</source>
|
||||
<target>Daten filtern</target>
|
||||
|
||||
@@ -94,6 +94,10 @@
|
||||
<source>invoice.paid</source>
|
||||
<target>Invoice paid</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="7d1V9FU" resname="invoice.cancel">
|
||||
<source>invoice.cancel</source>
|
||||
<target>Cancel invoice</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="38M3a4J" resname="filter">
|
||||
<source>filter</source>
|
||||
<target>Filter data</target>
|
||||
|
||||
@@ -1083,6 +1083,10 @@
|
||||
<source>status.paid</source>
|
||||
<target>Bezahlt</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="Z1s7pAw" resname="status.canceled">
|
||||
<source>status.canceled</source>
|
||||
<target>Storniert</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="crrlEUA" resname="preview.skipped_rows">
|
||||
<source>preview.skipped_rows</source>
|
||||
<target>Überspringe Vorschau von %rows% weiteren Zeilen …</target>
|
||||
|
||||
@@ -1083,6 +1083,10 @@
|
||||
<source>status.paid</source>
|
||||
<target>Paid</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="Z1s7pAw" resname="status.canceled">
|
||||
<source>status.canceled</source>
|
||||
<target>Canceled</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="crrlEUA" resname="preview.skipped_rows">
|
||||
<source>preview.skipped_rows</source>
|
||||
<target>Skipped preview of %rows% more rows …</target>
|
||||
|
||||
Reference in New Issue
Block a user