Fixed missing document totals relation then add payment button action..
This commit is contained in:
parent
1d7b1404a3
commit
962d678156
@ -538,17 +538,29 @@ class Document extends Model
|
|||||||
|
|
||||||
if ($this->status != 'paid' && (empty($this->transactions->count()) || (! empty($this->transactions->count()) && $this->paid != $this->amount))) {
|
if ($this->status != 'paid' && (empty($this->transactions->count()) || (! empty($this->transactions->count()) && $this->paid != $this->amount))) {
|
||||||
try {
|
try {
|
||||||
$actions[] = [
|
if ($this->totals->count()) {
|
||||||
'type' => 'button',
|
$actions[] = [
|
||||||
'title' => trans('invoices.add_payment'),
|
'type' => 'button',
|
||||||
'icon' => 'paid',
|
'title' => trans('invoices.add_payment'),
|
||||||
'url' => route('modals.documents.document.transactions.create', $this->id),
|
'icon' => 'paid',
|
||||||
'permission' => 'read-' . $group . '-' . $permission_prefix,
|
'url' => route('modals.documents.document.transactions.create', $this->id),
|
||||||
'attributes' => [
|
'permission' => 'read-' . $group . '-' . $permission_prefix,
|
||||||
'id' => 'index-line-actions-payment-' . $this->type . '-' . $this->id,
|
'attributes' => [
|
||||||
'@click' => 'onAddPayment("' . route('modals.documents.document.transactions.create', $this->id) . '")',
|
'id' => 'index-line-actions-payment-' . $this->type . '-' . $this->id,
|
||||||
],
|
'@click' => 'onAddPayment("' . route('modals.documents.document.transactions.create', $this->id) . '")',
|
||||||
];
|
],
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
$actions[] = [
|
||||||
|
'type' => 'button',
|
||||||
|
'title' => trans('invoices.messages.totals_required', ['type' => $this->type]),
|
||||||
|
'icon' => 'paid',
|
||||||
|
'permission' => 'read-' . $group . '-' . $permission_prefix,
|
||||||
|
'attributes' => [
|
||||||
|
"disabled" => "disabled",
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
} catch (\Exception $e) {}
|
} catch (\Exception $e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,6 +50,8 @@ return [
|
|||||||
|
|
||||||
'messages' => [
|
'messages' => [
|
||||||
'email_required' => 'No email address for this customer!',
|
'email_required' => 'No email address for this customer!',
|
||||||
|
'totals_required' => 'Invoice totals are required Please edit the :type and save it again.',
|
||||||
|
|
||||||
'draft' => 'This is a <b>DRAFT</b> invoice and will be reflected to charts after it gets sent.',
|
'draft' => 'This is a <b>DRAFT</b> invoice and will be reflected to charts after it gets sent.',
|
||||||
|
|
||||||
'status' => [
|
'status' => [
|
||||||
|
@ -34,6 +34,10 @@
|
|||||||
@if ($document->status == 'draft')
|
@if ($document->status == 'draft')
|
||||||
<x-documents.show.message type="status" background-color="bg-red-100" text-color="text-red-600" message="{!! trans($textStatusMessage) !!}" />
|
<x-documents.show.message type="status" background-color="bg-red-100" text-color="text-red-600" message="{!! trans($textStatusMessage) !!}" />
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
@if (! $document->totals->count())
|
||||||
|
<x-documents.show.message type="status" background-color="bg-red-100" text-color="text-red-600" message="{!! trans('invoices.messages.totals_required', ['type' => $type]) !!}" />
|
||||||
|
@endif
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@stack('status_message_end')
|
@stack('status_message_end')
|
||||||
|
@ -11,15 +11,23 @@
|
|||||||
@stack('timeline_get_paid_body_button_payment_start')
|
@stack('timeline_get_paid_body_button_payment_start')
|
||||||
|
|
||||||
@if (! $hideAddPayment)
|
@if (! $hideAddPayment)
|
||||||
@if ($document->status != 'paid' && (empty($document->transactions->count()) || (! empty($document->transactions->count()) && $document->paid != $document->amount)))
|
@if ($document->totals->count())
|
||||||
<x-button
|
@if ($document->status != 'paid' && (empty($document->transactions->count()) || (! empty($document->transactions->count()) && $document->paid != $document->amount)))
|
||||||
@click="onAddPayment('{{ route('modals.documents.document.transactions.create', $document->id) }}')"
|
<x-button
|
||||||
id="show-slider-actions-payment-{{ $document->type }}"
|
@click="onAddPayment('{{ route('modals.documents.document.transactions.create', $document->id) }}')"
|
||||||
class="px-3 py-1.5 mb-3 sm:mb-0 rounded-lg text-xs font-medium leading-6 bg-green hover:bg-green-700 text-white disabled:bg-green-100"
|
id="show-slider-actions-payment-{{ $document->type }}"
|
||||||
override="class"
|
class="px-3 py-1.5 mb-3 sm:mb-0 rounded-lg text-xs font-medium leading-6 bg-green hover:bg-green-700 text-white disabled:bg-green-100"
|
||||||
>
|
override="class"
|
||||||
{{ trans('invoices.add_payment') }}
|
>
|
||||||
</x-button>
|
{{ trans('invoices.add_payment') }}
|
||||||
|
</x-button>
|
||||||
|
@endif
|
||||||
|
@else
|
||||||
|
<x-tooltip message="{{ trans('invoices.messages.totals_required', ['type' => $type]) }}" placement="top">
|
||||||
|
<x-dropdown.button disabled="disabled">
|
||||||
|
{{ trans('invoices.add_payment') }}
|
||||||
|
</x-dropdown.button>
|
||||||
|
</x-tooltip>
|
||||||
@endif
|
@endif
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
@ -11,15 +11,23 @@
|
|||||||
@stack('timeline_get_paid_body_button_payment_start')
|
@stack('timeline_get_paid_body_button_payment_start')
|
||||||
|
|
||||||
@if (! $hideAddPayment)
|
@if (! $hideAddPayment)
|
||||||
@if ($document->status != 'paid' && (empty($document->transactions->count()) || (! empty($document->transactions->count()) && $document->paid != $document->amount)) )
|
@if ($document->totals->count())
|
||||||
<x-button
|
@if ($document->status != 'paid' && (empty($document->transactions->count()) || (! empty($document->transactions->count()) && $document->paid != $document->amount)) )
|
||||||
@click="onAddPayment('{{ route('modals.documents.document.transactions.create', $document->id) }}')"
|
<x-button
|
||||||
id="show-slider-actions-payment-{{ $document->type }}"
|
@click="onAddPayment('{{ route('modals.documents.document.transactions.create', $document->id) }}')"
|
||||||
class="px-3 py-1.5 mb-3 sm:mb-0 rounded-lg text-xs font-medium leading-6 bg-green hover:bg-green-700 text-white disabled:bg-green-100"
|
id="show-slider-actions-payment-{{ $document->type }}"
|
||||||
override="class"
|
class="px-3 py-1.5 mb-3 sm:mb-0 rounded-lg text-xs font-medium leading-6 bg-green hover:bg-green-700 text-white disabled:bg-green-100"
|
||||||
>
|
override="class"
|
||||||
{{ trans('invoices.add_payment') }}
|
>
|
||||||
</x-button>
|
{{ trans('invoices.add_payment') }}
|
||||||
|
</x-button>
|
||||||
|
@endif
|
||||||
|
@else
|
||||||
|
<x-tooltip message="{{ trans('invoices.messages.totals_required', ['type' => $type]) }}" placement="top">
|
||||||
|
<x-button disabled="disabled">
|
||||||
|
{{ trans('invoices.add_payment') }}
|
||||||
|
</x-button>
|
||||||
|
</x-tooltip>
|
||||||
@endif
|
@endif
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user