diff --git a/app/Models/Banking/Transaction.php b/app/Models/Banking/Transaction.php index f0939d374..6e57559e7 100644 --- a/app/Models/Banking/Transaction.php +++ b/app/Models/Banking/Transaction.php @@ -72,7 +72,7 @@ class Transaction extends Model * * @var array */ - public $sortable = ['type', 'number', 'paid_at', 'amount','category.name', 'account.name', 'customer.name', 'invoice.document_number']; + public $sortable = ['type', 'number', 'paid_at', 'amount', 'category.name', 'account.name', 'customer.name', 'invoice.document_number']; /** * Clonable relationships. @@ -552,17 +552,19 @@ class Transaction extends Model } catch (\Exception $e) {} try { - $actions[] = [ - 'type' => 'button', - 'title' => trans('invoices.send_mail'), - 'icon' => 'email', - 'url' => route('modals.transactions.emails.create', $this->id), - 'permission' => 'read-banking-transactions', - 'attributes' => [ - 'id' => 'index-more-actions-send-email-' . $this->id, - '@click' => 'onEmail("' . route('modals.transactions.emails.create', $this->id) . '")', - ], - ]; + if (! empty($this->contact) && $this->contact->email) { + $actions[] = [ + 'type' => 'button', + 'title' => trans('invoices.send_mail'), + 'icon' => 'email', + 'url' => route('modals.transactions.emails.create', $this->id), + 'permission' => 'read-banking-transactions', + 'attributes' => [ + 'id' => 'index-more-actions-send-email-' . $this->id, + '@click' => 'onEmail("' . route('modals.transactions.emails.create', $this->id) . '")', + ], + ]; + } } catch (\Exception $e) {} $actions[] = [ diff --git a/app/Models/Document/Document.php b/app/Models/Document/Document.php index df5587684..d5ca3237a 100644 --- a/app/Models/Document/Document.php +++ b/app/Models/Document/Document.php @@ -575,7 +575,7 @@ class Document extends Model } catch (\Exception $e) {} try { - if ($this->type == 'invoice') { + if (! empty($this->contact) && $this->contact->email && $this->type == 'invoice') { $actions[] = [ 'type' => 'button', 'title' => trans('invoices.send_mail'), diff --git a/resources/assets/js/views/banking/transactions.js b/resources/assets/js/views/banking/transactions.js index 8f5735c3b..b68954255 100644 --- a/resources/assets/js/views/banking/transactions.js +++ b/resources/assets/js/views/banking/transactions.js @@ -52,7 +52,7 @@ const app = new Vue({ this.component = Vue.component('add-new-component', (resolve, reject) => { resolve({ - template: '