diff --git a/app/Http/Controllers/Modals/DocumentTransactions.php b/app/Http/Controllers/Modals/DocumentTransactions.php index 687d674f811..2e165453534 100644 --- a/app/Http/Controllers/Modals/DocumentTransactions.php +++ b/app/Http/Controllers/Modals/DocumentTransactions.php @@ -113,13 +113,7 @@ public function store(Document $document, Request $request) $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 85aec215873..17c16589d28 100644 --- a/app/Models/Document/Document.php +++ b/app/Models/Document/Document.php @@ -595,6 +595,26 @@ public function getLineActionsAttribute() '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 6474be88bc5..9375260fe23 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))