From ef00815557bdeaa86bfc9f7c5e7ecd56ad662271 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Wed, 18 Aug 2021 15:15:14 +0300 Subject: [PATCH 1/2] Transaction not edit, duplicate, delete etc button for Transferred --- app/Models/Banking/Transaction.php | 10 ++++++++++ .../transactions/show/top-buttons.blade.php | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/app/Models/Banking/Transaction.php b/app/Models/Banking/Transaction.php index cb7281a05..f6b1b778b 100644 --- a/app/Models/Banking/Transaction.php +++ b/app/Models/Banking/Transaction.php @@ -349,6 +349,16 @@ class Transaction extends Model } } + /** + * Check if the record is attached to a transfer. + * + * @return bool + */ + public function getHasTransferRelationAttribute() + { + return (bool) (optional($this->category)->id == optional($this->category)->transfer()); + } + /** * Get the title of type. * diff --git a/resources/views/components/transactions/show/top-buttons.blade.php b/resources/views/components/transactions/show/top-buttons.blade.php index 9481840e9..56a63bf0e 100644 --- a/resources/views/components/transactions/show/top-buttons.blade.php +++ b/resources/views/components/transactions/show/top-buttons.blade.php @@ -8,6 +8,7 @@ From 06d0ac18f6939230973fe6929c5aa92ee42852c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Wed, 18 Aug 2021 15:37:45 +0300 Subject: [PATCH 2/2] Transfer added created by and show page account link --- .../View/Components/TransferShow.php | 28 ++++++++++++++++++- app/Jobs/Banking/CreateTransfer.php | 3 ++ .../transfers/show/content.blade.php | 2 ++ .../transfers/show/header.blade.php | 8 ++++-- 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/app/Abstracts/View/Components/TransferShow.php b/app/Abstracts/View/Components/TransferShow.php index ba62cd890..f6045640a 100644 --- a/app/Abstracts/View/Components/TransferShow.php +++ b/app/Abstracts/View/Components/TransferShow.php @@ -101,6 +101,12 @@ abstract class TransferShow extends Component /** @var string */ public $routeButtonDelete; + /** @var string */ + public $routeFromAccountShow; + + /** @var string */ + public $routeToAccountShow; + /** @var string */ public $textDeleteModal; @@ -267,7 +273,7 @@ abstract class TransferShow extends Component bool $hideButtonGroupDivider1 = false, bool $hideButtonGroupDivider2 = false, bool $hideButtonGroupDivider3 = false, string $permissionCreate = '', string $permissionUpdate = '', string $permissionDelete = '', string $routeButtonAddNew = '', string $routeButtonEdit = '', string $routeButtonDuplicate = '', string $routeButtonPrint = '', string $signedUrl = '', - string $routeButtonEmail = '', string $routeButtonPdf = '', string $routeButtonDelete = '', + string $routeButtonEmail = '', string $routeButtonPdf = '', string $routeButtonDelete = '', string $routeFromAccountShow = '', string $routeToAccountShow = '', string $textDeleteModal = '', bool $hideHeader = false, bool $hideHeaderFromAccount = false, bool $hideHeaderToAccount = false, bool $hideHeaderAmount = false, bool $hideHeaderPaidAt = false, string $textHeaderFromAccount = '', string $textHeaderToAccount = '', string $textHeaderAmount = '', string $textHeaderPaidAt = '', @@ -324,6 +330,8 @@ abstract class TransferShow extends Component $this->routeButtonEmail = $this->getRouteButtonEmail($routeButtonEmail); $this->routeButtonPdf = $this->getRouteButtonPdf($routeButtonPdf); $this->routeButtonDelete = $this->getRouteButtonDelete($routeButtonDelete); + $this->routeFromAccountShow = $this->getRouteFromAccountShow($routeFromAccountShow); + $this->routeToAccountShow = $this->getRouteToAccountShow($routeToAccountShow); // Navbar Text $this->textDeleteModal = $textDeleteModal; @@ -501,6 +509,24 @@ abstract class TransferShow extends Component return 'transfers.destroy'; } + protected function getRouteFromAccountShow($routeFromAccountShow) + { + if (!empty($routeFromAccountShow)) { + return $routeFromAccountShow; + } + + return 'accounts.show'; + } + + protected function getRouteToAccountShow($routeToAccountShow) + { + if (!empty($routeToAccountShow)) { + return $routeToAccountShow; + } + + return 'accounts.show'; + } + protected function getPermissionCreate($permissionCreate) { if (!empty($permissionCreate)) { diff --git a/app/Jobs/Banking/CreateTransfer.php b/app/Jobs/Banking/CreateTransfer.php index 7f5927774..6203a0a98 100644 --- a/app/Jobs/Banking/CreateTransfer.php +++ b/app/Jobs/Banking/CreateTransfer.php @@ -55,6 +55,7 @@ class CreateTransfer extends Job 'category_id' => Category::transfer(), // Transfer Category ID 'payment_method' => $this->request->get('payment_method'), 'reference' => $this->request->get('reference'), + 'created_by' => $this->request->get('created_by'), ]); $amount = $this->request->get('amount'); @@ -77,12 +78,14 @@ class CreateTransfer extends Job 'category_id' => Category::transfer(), // Transfer Category ID 'payment_method' => $this->request->get('payment_method'), 'reference' => $this->request->get('reference'), + 'created_by' => $this->request->get('created_by'), ]); $this->transfer = Transfer::create([ 'company_id' => $this->request['company_id'], 'expense_transaction_id' => $expense_transaction->id, 'income_transaction_id' => $income_transaction->id, + 'created_by' => $this->request->get('created_by'), ]); // Upload attachment diff --git a/resources/views/components/transfers/show/content.blade.php b/resources/views/components/transfers/show/content.blade.php index aeb4624e3..e47fa613a 100644 --- a/resources/views/components/transfers/show/content.blade.php +++ b/resources/views/components/transfers/show/content.blade.php @@ -8,6 +8,8 @@ hide-header-to-account="{{ $hideHeaderToAccount }}" text-header-to-account="{{ $textHeaderToAccount }}" class-header-to-account="{{ $classHeaderToAccount }}" + route-from-account-show="{{ $routeFromAccountShow }}" + route-to-account-show="{{ $routeToAccountShow }}" hide-header-amount="{{ $hideHeaderAmount }}" text-header-amount="{{ $textHeaderAmount }}" class-header-amount="{{ $classHeaderAmount }}" diff --git a/resources/views/components/transfers/show/header.blade.php b/resources/views/components/transfers/show/header.blade.php index f5dea97d5..f0d0c5da9 100644 --- a/resources/views/components/transfers/show/header.blade.php +++ b/resources/views/components/transfers/show/header.blade.php @@ -7,7 +7,9 @@ - {{ $transfer->expense_transaction->account->name }} + + {{ $transfer->expense_transaction->account->name }} +

@@ -23,7 +25,9 @@ - {{ $transfer->income_transaction->account->name }} + + {{ $transfer->income_transaction->account->name }} +