From 8c61a4ee731083f283c794fecde9892a21c2b354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Mon, 5 Sep 2022 18:19:11 +0300 Subject: [PATCH] close #2616 Enhancement: Add payment from invoice/bill index ( #3g3rnd2 ) --- .../Modals/DocumentTransactions.php | 8 +------- app/Models/Document/Document.php | 20 +++++++++++++++++++ .../documents/show/get-paid.blade.php | 2 +- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/Modals/DocumentTransactions.php b/app/Http/Controllers/Modals/DocumentTransactions.php index 687d674f8..2e1654535 100644 --- a/app/Http/Controllers/Modals/DocumentTransactions.php +++ b/app/Http/Controllers/Modals/DocumentTransactions.php @@ -113,13 +113,7 @@ class DocumentTransactions extends Controller $response = $this->ajaxDispatch(new CreateBankingDocumentTransaction($document, $request)); if ($response['success']) { - $route = config('type.document.' . $document->type . '.route.prefix'); - - if ($alias = config('type.document.' . $document->type . '.alias')) { - $route = $alias . '.' . $route; - } - - $response['redirect'] = route($route . '.show', $document->id); + $response['redirect'] = url()->previous(); $message = trans('messages.success.added', ['type' => trans_choice('general.payments', 1)]); diff --git a/app/Models/Document/Document.php b/app/Models/Document/Document.php index 85aec2158..17c16589d 100644 --- a/app/Models/Document/Document.php +++ b/app/Models/Document/Document.php @@ -595,6 +595,26 @@ class Document extends Model 'type' => 'divider', ]; + if ((empty($this->transactions->count()) || (! empty($this->transactions->count()) && $this->paid != $this->amount))) { + try { + $actions[] = [ + 'type' => 'button', + 'title' => trans('invoices.add_payment'), + 'icon' => 'payments', + 'url' => route('modals.documents.document.transactions.create', $this->id), + 'permission' => 'read-' . $group . '-' . $permission_prefix, + 'attributes' => [ + 'id' => 'index-more-actions-payment-' . $this->id, + '@click' => 'onPayment("' . $this->id . '")', + ], + ]; + } catch (\Exception $e) {} + + $actions[] = [ + 'type' => 'divider', + ]; + } + if ($this->status != 'cancelled') { try { $actions[] = [ diff --git a/resources/views/components/documents/show/get-paid.blade.php b/resources/views/components/documents/show/get-paid.blade.php index 6474be88b..9375260fe 100644 --- a/resources/views/components/documents/show/get-paid.blade.php +++ b/resources/views/components/documents/show/get-paid.blade.php @@ -11,7 +11,7 @@ @stack('timeline_get_paid_body_button_payment_start') @if (! $hideAddPayment) - @if(empty($document->transactions->count()) || (! empty($document->transactions->count()) && $document->paid != $document->amount)) + @if (empty($document->transactions->count()) || (! empty($document->transactions->count()) && $document->paid != $document->amount))