Fixed missing document totals relation then add payment button action..
This commit is contained in:
		@@ -538,17 +538,29 @@ class Document extends Model
 | 
			
		||||
 | 
			
		||||
        if ($this->status != 'paid' && (empty($this->transactions->count()) || (! empty($this->transactions->count()) && $this->paid != $this->amount))) {
 | 
			
		||||
            try {
 | 
			
		||||
                $actions[] = [
 | 
			
		||||
                    'type' => 'button',
 | 
			
		||||
                    'title' => trans('invoices.add_payment'),
 | 
			
		||||
                    'icon' => 'paid',
 | 
			
		||||
                    'url' => route('modals.documents.document.transactions.create', $this->id),
 | 
			
		||||
                    'permission' => 'read-' . $group . '-' . $permission_prefix,
 | 
			
		||||
                    'attributes' => [
 | 
			
		||||
                        'id' => 'index-line-actions-payment-' . $this->type . '-' . $this->id,
 | 
			
		||||
                        '@click' => 'onAddPayment("' . route('modals.documents.document.transactions.create', $this->id) . '")',
 | 
			
		||||
                    ],
 | 
			
		||||
                ];
 | 
			
		||||
                if ($this->totals->count()) {
 | 
			
		||||
                    $actions[] = [
 | 
			
		||||
                        'type' => 'button',
 | 
			
		||||
                        'title' => trans('invoices.add_payment'),
 | 
			
		||||
                        'icon' => 'paid',
 | 
			
		||||
                        'url' => route('modals.documents.document.transactions.create', $this->id),
 | 
			
		||||
                        'permission' => 'read-' . $group . '-' . $permission_prefix,
 | 
			
		||||
                        'attributes' => [
 | 
			
		||||
                            '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) {}
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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,15 +11,23 @@
 | 
			
		||||
            @stack('timeline_get_paid_body_button_payment_start')
 | 
			
		||||
 | 
			
		||||
            @if (! $hideAddPayment)
 | 
			
		||||
                @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) }}')"
 | 
			
		||||
                        id="show-slider-actions-payment-{{ $document->type }}"
 | 
			
		||||
                        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>
 | 
			
		||||
                @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) }}')"
 | 
			
		||||
                            id="show-slider-actions-payment-{{ $document->type }}"
 | 
			
		||||
                            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>
 | 
			
		||||
                    @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
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -11,15 +11,23 @@
 | 
			
		||||
            @stack('timeline_get_paid_body_button_payment_start')
 | 
			
		||||
 | 
			
		||||
            @if (! $hideAddPayment)
 | 
			
		||||
                @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) }}')"
 | 
			
		||||
                        id="show-slider-actions-payment-{{ $document->type }}"
 | 
			
		||||
                        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>
 | 
			
		||||
                @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) }}')"
 | 
			
		||||
                            id="show-slider-actions-payment-{{ $document->type }}"
 | 
			
		||||
                            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>
 | 
			
		||||
                    @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
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user