diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php
index 3207daeb5600..2297a7c2634e 100644
--- a/app/Models/Invoice.php
+++ b/app/Models/Invoice.php
@@ -1464,6 +1464,17 @@ class Invoice extends EntityModel implements BalanceAffecting
{
return $this->isQuote() ? 'valid_until' : 'due_date';
}
+
+ public function onlyHasTasks()
+ {
+ foreach ($this->invoice_items as $item) {
+ if ($item->invoice_item_type_id != INVOICE_ITEM_TYPE_TASK) {
+ return false;
+ }
+ }
+
+ return true;
+ }
}
Invoice::creating(function ($invoice) {
diff --git a/app/Ninja/Presenters/InvoicePresenter.php b/app/Ninja/Presenters/InvoicePresenter.php
index 6369373b7c80..baa3a0e1894d 100644
--- a/app/Ninja/Presenters/InvoicePresenter.php
+++ b/app/Ninja/Presenters/InvoicePresenter.php
@@ -239,6 +239,10 @@ class InvoicePresenter extends EntityPresenter
$actions[] = ['url' => url("quotes/{$invoice->quote->public_id}/edit"), 'label' => trans('texts.view_quote')];
}
+ if ($invoice->onlyHasTasks()) {
+ $actions[] = ['url' => 'javascript:onAddItemClick()', 'label' => trans('texts.add_item')];
+ }
+
if ($invoice->canBePaid()) {
$actions[] = ['url' => 'javascript:submitBulkAction("markPaid")', 'label' => trans('texts.mark_paid')];
$actions[] = ['url' => 'javascript:onPaymentClick()', 'label' => trans('texts.enter_payment')];
diff --git a/resources/views/invoices/edit_table.blade.php b/resources/views/invoices/edit_table.blade.php
index 3ff0a9bbcc09..f43c9375c2af 100644
--- a/resources/views/invoices/edit_table.blade.php
+++ b/resources/views/invoices/edit_table.blade.php
@@ -1,6 +1,8 @@
-
+exists || ! empty($tasks) ? 'data-bind="visible: $root.hasItems"' : '') !!}>
@if ($isTasks)
-
+
+
@endif
+
-
@@ -19,7 +21,7 @@