Fixed missing document totals relation then add payment button action..
This commit is contained in:
parent
1d7b1404a3
commit
962d678156
@ -538,6 +538,7 @@ class Document extends Model
|
||||
|
||||
if ($this->status != 'paid' && (empty($this->transactions->count()) || (! empty($this->transactions->count()) && $this->paid != $this->amount))) {
|
||||
try {
|
||||
if ($this->totals->count()) {
|
||||
$actions[] = [
|
||||
'type' => 'button',
|
||||
'title' => trans('invoices.add_payment'),
|
||||
@ -549,6 +550,17 @@ class Document extends Model
|
||||
'@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) {}
|
||||
}
|
||||
|
||||
|
@ -50,6 +50,8 @@ return [
|
||||
|
||||
'messages' => [
|
||||
'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.',
|
||||
|
||||
'status' => [
|
||||
|
@ -34,6 +34,10 @@
|
||||
@if ($document->status == 'draft')
|
||||
<x-documents.show.message type="status" background-color="bg-red-100" text-color="text-red-600" message="{!! trans($textStatusMessage) !!}" />
|
||||
@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
|
||||
|
||||
@stack('status_message_end')
|
||||
|
@ -11,6 +11,7 @@
|
||||
@stack('timeline_get_paid_body_button_payment_start')
|
||||
|
||||
@if (! $hideAddPayment)
|
||||
@if ($document->totals->count())
|
||||
@if ($document->status != 'paid' && (empty($document->transactions->count()) || (! empty($document->transactions->count()) && $document->paid != $document->amount)))
|
||||
<x-button
|
||||
@click="onAddPayment('{{ route('modals.documents.document.transactions.create', $document->id) }}')"
|
||||
@ -21,6 +22,13 @@
|
||||
{{ 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
|
||||
|
||||
@stack('timeline_get_paid_body_button_payment_end')
|
||||
|
@ -11,6 +11,7 @@
|
||||
@stack('timeline_get_paid_body_button_payment_start')
|
||||
|
||||
@if (! $hideAddPayment)
|
||||
@if ($document->totals->count())
|
||||
@if ($document->status != 'paid' && (empty($document->transactions->count()) || (! empty($document->transactions->count()) && $document->paid != $document->amount)) )
|
||||
<x-button
|
||||
@click="onAddPayment('{{ route('modals.documents.document.transactions.create', $document->id) }}')"
|
||||
@ -21,6 +22,13 @@
|
||||
{{ 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
|
||||
|
||||
@stack('timeline_get_paid_body_button_payment_end')
|
||||
|
Loading…
x
Reference in New Issue
Block a user