Skip to content

Commit

Permalink
close #2616 Enhancement: Add payment from invoice/bill index ( #3g3rn…
Browse files Browse the repository at this point in the history
…d2 )
  • Loading branch information
cuneytsenturk committed Sep 5, 2022
1 parent cf565f5 commit 8c61a4e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
8 changes: 1 addition & 7 deletions app/Http/Controllers/Modals/DocumentTransactions.php
Expand Up @@ -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)]);

Expand Down
20 changes: 20 additions & 0 deletions app/Models/Document/Document.php
Expand Up @@ -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[] = [
Expand Down
Expand Up @@ -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))
<x-button
@click="onPayment"
id="button-payment"
Expand Down

0 comments on commit 8c61a4e

Please sign in to comment.