From e1b47a6f8abdbfbd9cfac66e89f327c64d6a0f37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Thu, 24 Aug 2023 12:21:15 +0300 Subject: [PATCH] Fixed recurring template end button issue ( #866au7m2v ) --- app/Models/Banking/Transaction.php | 24 ++++++++++--------- app/Models/Document/Document.php | 24 ++++++++++--------- .../documents/show/more-buttons.blade.php | 2 +- .../transactions/show/more-buttons.blade.php | 2 +- 4 files changed, 28 insertions(+), 24 deletions(-) diff --git a/app/Models/Banking/Transaction.php b/app/Models/Banking/Transaction.php index 20fcdedd6..f4fab4b7b 100644 --- a/app/Models/Banking/Transaction.php +++ b/app/Models/Banking/Transaction.php @@ -610,17 +610,19 @@ class Transaction extends Model } catch (\Exception $e) {} } } else { - try { - $actions[] = [ - 'title' => trans('general.end'), - 'icon' => 'block', - 'url' => route($prefix. '.end', $this->id), - 'permission' => 'update-banking-transactions', - 'attributes' => [ - 'id' => 'index-line-actions-end-' . $this->type . '-' . $this->id, - ], - ]; - } catch (\Exception $e) {} + if ($this->recurring && $this->recurring->status != 'ended') { + try { + $actions[] = [ + 'title' => trans('general.end'), + 'icon' => 'block', + 'url' => route($prefix. '.end', $this->id), + 'permission' => 'update-banking-transactions', + 'attributes' => [ + 'id' => 'index-line-actions-end-' . $this->type . '-' . $this->id, + ], + ]; + } catch (\Exception $e) {} + } } return $actions; diff --git a/app/Models/Document/Document.php b/app/Models/Document/Document.php index 314eb2eb3..aa6d4f26a 100644 --- a/app/Models/Document/Document.php +++ b/app/Models/Document/Document.php @@ -672,17 +672,19 @@ class Document extends Model ]; } catch (\Exception $e) {} } else { - try { - $actions[] = [ - 'title' => trans('general.end'), - 'icon' => 'block', - 'url' => route($prefix. '.end', $this->id), - 'permission' => 'update-' . $group . '-' . $permission_prefix, - 'attributes' => [ - 'id' => 'index-line-actions-end-' . $this->type . '-' . $this->id, - ], - ]; - } catch (\Exception $e) {} + if ($this->recurring && $this->recurring->status != 'ended') { + try { + $actions[] = [ + 'title' => trans('general.end'), + 'icon' => 'block', + 'url' => route($prefix. '.end', $this->id), + 'permission' => 'update-' . $group . '-' . $permission_prefix, + 'attributes' => [ + 'id' => 'index-line-actions-end-' . $this->type . '-' . $this->id, + ], + ]; + } catch (\Exception $e) {} + } } return $actions; diff --git a/resources/views/components/documents/show/more-buttons.blade.php b/resources/views/components/documents/show/more-buttons.blade.php index 3f6421010..9a84c9023 100644 --- a/resources/views/components/documents/show/more-buttons.blade.php +++ b/resources/views/components/documents/show/more-buttons.blade.php @@ -98,7 +98,7 @@ @stack('end_button_start') - @if (! $hideEnd && $document->recurring) + @if (! $hideEnd && $document->recurring && $document->recurring->status != 'ended') {{ trans('recurring.end') }} diff --git a/resources/views/components/transactions/show/more-buttons.blade.php b/resources/views/components/transactions/show/more-buttons.blade.php index 51eda8727..14fcd2c1c 100644 --- a/resources/views/components/transactions/show/more-buttons.blade.php +++ b/resources/views/components/transactions/show/more-buttons.blade.php @@ -107,7 +107,7 @@ @stack('button_end_start') - @if (! $hideButtonEnd) + @if (! $hideButtonEnd && $transaction->recurring && $transaction->recurring->status != 'ended') {{ trans('recurring.end') }}