added new invoice status: canceled (#2922)
This commit is contained in:
@@ -144,6 +144,7 @@ class ExportController extends AbstractController
|
|||||||
/**
|
/**
|
||||||
* @param ExportQuery $query
|
* @param ExportQuery $query
|
||||||
* @return ExportItemInterface[]
|
* @return ExportItemInterface[]
|
||||||
|
* @throws TooManyItemsExportException
|
||||||
*/
|
*/
|
||||||
protected function getEntries(ExportQuery $query): array
|
protected function getEntries(ExportQuery $query): array
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ class Invoice
|
|||||||
{
|
{
|
||||||
public const STATUS_PENDING = 'pending';
|
public const STATUS_PENDING = 'pending';
|
||||||
public const STATUS_PAID = 'paid';
|
public const STATUS_PAID = 'paid';
|
||||||
|
public const STATUS_CANCELED = 'canceled';
|
||||||
public const STATUS_NEW = 'new';
|
public const STATUS_NEW = 'new';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -306,6 +307,16 @@ class Invoice
|
|||||||
return $this;
|
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
|
public function getDueDays(): int
|
||||||
{
|
{
|
||||||
return $this->dueDays;
|
return $this->dueDays;
|
||||||
|
|||||||
@@ -30,12 +30,18 @@ class InvoiceSubscriber extends AbstractActionsSubscriber
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($invoice->isNew() || $invoice->isPaid()) {
|
if (!$invoice->isPending()) {
|
||||||
$event->addAction('invoice.pending', ['url' => $this->path('admin_invoice_status', ['id' => $invoice->getId(), 'status' => 'pending'])]);
|
$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']);
|
$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->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);
|
$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)
|
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) {
|
switch ($status) {
|
||||||
case Invoice::STATUS_NEW:
|
case Invoice::STATUS_NEW:
|
||||||
$invoice->setIsNew();
|
$invoice->setIsNew();
|
||||||
@@ -255,6 +251,13 @@ final class ServiceInvoice
|
|||||||
case Invoice::STATUS_PAID:
|
case Invoice::STATUS_PAID:
|
||||||
$invoice->setIsPaid();
|
$invoice->setIsPaid();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Invoice::STATUS_CANCELED:
|
||||||
|
$invoice->setIsCanceled();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new \InvalidArgumentException('Unknown invoice status');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->invoiceRepository->saveInvoice($invoice);
|
$this->invoiceRepository->saveInvoice($invoice);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
{{ tables.datatable_header(tableName, columns, query, {}) }}
|
{{ tables.datatable_header(tableName, columns, query, {}) }}
|
||||||
{% for entry in entries %}
|
{% 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, '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, '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>
|
<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') }}
|
{{ widgets.label('status.pending'|trans, 'warning') }}
|
||||||
{% elseif invoice.paid %}
|
{% elseif invoice.paid %}
|
||||||
{{ widgets.label('status.paid'|trans, 'success') }}
|
{{ widgets.label('status.paid'|trans, 'success') }}
|
||||||
|
{% elseif invoice.canceled %}
|
||||||
|
{{ widgets.label('status.canceled'|trans, 'gray') }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
{% macro invoice_due_date(invoice) %}
|
{% macro invoice_due_date(invoice) %}
|
||||||
{% import "macros/widgets.html.twig" as widgets %}
|
{% 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') }}
|
{{ widgets.label(invoice.dueDate|date_short, 'danger') }}
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ widgets.label(invoice.dueDate|date_short, 'primary') }}
|
{{ widgets.label(invoice.dueDate|date_short, 'primary') }}
|
||||||
|
|||||||
@@ -94,6 +94,10 @@
|
|||||||
<source>invoice.paid</source>
|
<source>invoice.paid</source>
|
||||||
<target>Rechnung bezahlt</target>
|
<target>Rechnung bezahlt</target>
|
||||||
</trans-unit>
|
</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">
|
<trans-unit id="38M3a4J" resname="filter">
|
||||||
<source>filter</source>
|
<source>filter</source>
|
||||||
<target>Daten filtern</target>
|
<target>Daten filtern</target>
|
||||||
|
|||||||
@@ -94,6 +94,10 @@
|
|||||||
<source>invoice.paid</source>
|
<source>invoice.paid</source>
|
||||||
<target>Invoice paid</target>
|
<target>Invoice paid</target>
|
||||||
</trans-unit>
|
</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">
|
<trans-unit id="38M3a4J" resname="filter">
|
||||||
<source>filter</source>
|
<source>filter</source>
|
||||||
<target>Filter data</target>
|
<target>Filter data</target>
|
||||||
|
|||||||
@@ -1083,6 +1083,10 @@
|
|||||||
<source>status.paid</source>
|
<source>status.paid</source>
|
||||||
<target>Bezahlt</target>
|
<target>Bezahlt</target>
|
||||||
</trans-unit>
|
</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">
|
<trans-unit id="crrlEUA" resname="preview.skipped_rows">
|
||||||
<source>preview.skipped_rows</source>
|
<source>preview.skipped_rows</source>
|
||||||
<target>Überspringe Vorschau von %rows% weiteren Zeilen …</target>
|
<target>Überspringe Vorschau von %rows% weiteren Zeilen …</target>
|
||||||
|
|||||||
@@ -1083,6 +1083,10 @@
|
|||||||
<source>status.paid</source>
|
<source>status.paid</source>
|
||||||
<target>Paid</target>
|
<target>Paid</target>
|
||||||
</trans-unit>
|
</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">
|
<trans-unit id="crrlEUA" resname="preview.skipped_rows">
|
||||||
<source>preview.skipped_rows</source>
|
<source>preview.skipped_rows</source>
|
||||||
<target>Skipped preview of %rows% more rows …</target>
|
<target>Skipped preview of %rows% more rows …</target>
|
||||||
|
|||||||
Reference in New Issue
Block a user