diff --git a/app/Models/Document/Document.php b/app/Models/Document/Document.php
index 323956a38..edf79ae79 100644
--- a/app/Models/Document/Document.php
+++ b/app/Models/Document/Document.php
@@ -538,17 +538,29 @@ class Document extends Model
if ($this->status != 'paid' && (empty($this->transactions->count()) || (! empty($this->transactions->count()) && $this->paid != $this->amount))) {
try {
- $actions[] = [
- 'type' => 'button',
- 'title' => trans('invoices.add_payment'),
- 'icon' => 'paid',
- 'url' => route('modals.documents.document.transactions.create', $this->id),
- 'permission' => 'read-' . $group . '-' . $permission_prefix,
- 'attributes' => [
- 'id' => 'index-line-actions-payment-' . $this->type . '-' . $this->id,
- '@click' => 'onAddPayment("' . route('modals.documents.document.transactions.create', $this->id) . '")',
- ],
- ];
+ if ($this->totals->count()) {
+ $actions[] = [
+ 'type' => 'button',
+ 'title' => trans('invoices.add_payment'),
+ 'icon' => 'paid',
+ 'url' => route('modals.documents.document.transactions.create', $this->id),
+ 'permission' => 'read-' . $group . '-' . $permission_prefix,
+ 'attributes' => [
+ 'id' => 'index-line-actions-payment-' . $this->type . '-' . $this->id,
+ '@click' => 'onAddPayment("' . route('modals.documents.document.transactions.create', $this->id) . '")',
+ ],
+ ];
+ } else {
+ $actions[] = [
+ 'type' => 'button',
+ 'title' => trans('invoices.messages.totals_required', ['type' => $this->type]),
+ 'icon' => 'paid',
+ 'permission' => 'read-' . $group . '-' . $permission_prefix,
+ 'attributes' => [
+ "disabled" => "disabled",
+ ],
+ ];
+ }
} catch (\Exception $e) {}
}
diff --git a/resources/lang/en-GB/invoices.php b/resources/lang/en-GB/invoices.php
index 5186448b9..99040dc6a 100644
--- a/resources/lang/en-GB/invoices.php
+++ b/resources/lang/en-GB/invoices.php
@@ -50,6 +50,8 @@ return [
'messages' => [
'email_required' => 'No email address for this customer!',
+ 'totals_required' => 'Invoice totals are required Please edit the :type and save it again.',
+
'draft' => 'This is a DRAFT invoice and will be reflected to charts after it gets sent.',
'status' => [
diff --git a/resources/views/components/documents/show/content.blade.php b/resources/views/components/documents/show/content.blade.php
index 34ec22538..174cf979d 100644
--- a/resources/views/components/documents/show/content.blade.php
+++ b/resources/views/components/documents/show/content.blade.php
@@ -34,6 +34,10 @@
@if ($document->status == 'draft')
@endif
+
+ @if (! $document->totals->count())
+
+ @endif
@endif
@stack('status_message_end')
diff --git a/resources/views/components/documents/show/get-paid.blade.php b/resources/views/components/documents/show/get-paid.blade.php
index 73822a701..01a720103 100644
--- a/resources/views/components/documents/show/get-paid.blade.php
+++ b/resources/views/components/documents/show/get-paid.blade.php
@@ -11,15 +11,23 @@
@stack('timeline_get_paid_body_button_payment_start')
@if (! $hideAddPayment)
- @if ($document->status != 'paid' && (empty($document->transactions->count()) || (! empty($document->transactions->count()) && $document->paid != $document->amount)))
- id) }}')"
- id="show-slider-actions-payment-{{ $document->type }}"
- class="px-3 py-1.5 mb-3 sm:mb-0 rounded-lg text-xs font-medium leading-6 bg-green hover:bg-green-700 text-white disabled:bg-green-100"
- override="class"
- >
- {{ trans('invoices.add_payment') }}
-
+ @if ($document->totals->count())
+ @if ($document->status != 'paid' && (empty($document->transactions->count()) || (! empty($document->transactions->count()) && $document->paid != $document->amount)))
+ id) }}')"
+ id="show-slider-actions-payment-{{ $document->type }}"
+ class="px-3 py-1.5 mb-3 sm:mb-0 rounded-lg text-xs font-medium leading-6 bg-green hover:bg-green-700 text-white disabled:bg-green-100"
+ override="class"
+ >
+ {{ trans('invoices.add_payment') }}
+
+ @endif
+ @else
+
+
+ {{ trans('invoices.add_payment') }}
+
+
@endif
@endif
diff --git a/resources/views/components/documents/show/make-payment.blade.php b/resources/views/components/documents/show/make-payment.blade.php
index c382bae9a..5b4dd39d5 100644
--- a/resources/views/components/documents/show/make-payment.blade.php
+++ b/resources/views/components/documents/show/make-payment.blade.php
@@ -11,15 +11,23 @@
@stack('timeline_get_paid_body_button_payment_start')
@if (! $hideAddPayment)
- @if ($document->status != 'paid' && (empty($document->transactions->count()) || (! empty($document->transactions->count()) && $document->paid != $document->amount)) )
- id) }}')"
- id="show-slider-actions-payment-{{ $document->type }}"
- class="px-3 py-1.5 mb-3 sm:mb-0 rounded-lg text-xs font-medium leading-6 bg-green hover:bg-green-700 text-white disabled:bg-green-100"
- override="class"
- >
- {{ trans('invoices.add_payment') }}
-
+ @if ($document->totals->count())
+ @if ($document->status != 'paid' && (empty($document->transactions->count()) || (! empty($document->transactions->count()) && $document->paid != $document->amount)) )
+ id) }}')"
+ id="show-slider-actions-payment-{{ $document->type }}"
+ class="px-3 py-1.5 mb-3 sm:mb-0 rounded-lg text-xs font-medium leading-6 bg-green hover:bg-green-700 text-white disabled:bg-green-100"
+ override="class"
+ >
+ {{ trans('invoices.add_payment') }}
+
+ @endif
+ @else
+
+
+ {{ trans('invoices.add_payment') }}
+
+
@endif
@endif