diff --git a/app/Http/Controllers/Modals/DocumentTransactions.php b/app/Http/Controllers/Modals/DocumentTransactions.php index 39879ea9c75..9df1b6a9b95 100644 --- a/app/Http/Controllers/Modals/DocumentTransactions.php +++ b/app/Http/Controllers/Modals/DocumentTransactions.php @@ -55,12 +55,12 @@ public function create(Document $document) $document->{$document_total->code} = $document_total->amount; } - $total = money($document->total, $currency->code)->format(); + $total = money($document?->total ?? 0, $currency->code)->format(); $document->grand_total = money($total, $currency->code, false)->getAmount(); if (! empty($paid)) { - $document->grand_total = round($document->total - $paid, $currency->precision); + $document->grand_total = round($document?->total ?? 0 - $paid, $currency->precision); } $amount = $document->grand_total; @@ -163,12 +163,12 @@ public function edit(Document $document, Transaction $transaction) $document->{$document_total->code} = $document_total->amount; } - $total = money($document->total, $currency->code)->format(); + $total = money($document?->total ?? 0, $currency->code)->format(); $document->grand_total = money($total, $currency->code, false)->getAmount(); if (! empty($paid)) { - $document->grand_total = round($document->total - $paid, $currency->precision); + $document->grand_total = round($document?->total ?? 0 - $paid, $currency->precision); } $document->paid_at = $transaction->paid_at; diff --git a/resources/views/components/documents/show/get-paid.blade.php b/resources/views/components/documents/show/get-paid.blade.php index 9a3c1951bd4..e7c0501aded 100644 --- a/resources/views/components/documents/show/get-paid.blade.php +++ b/resources/views/components/documents/show/get-paid.blade.php @@ -94,16 +94,26 @@ class="py-1.5 mb-3 sm:mb-0 text-xs bg-transparent hover:bg-transparent font-medi - - - - {{ trans('general.title.edit', ['type' => trans_choice('general.payments', 1)]) }} - - + @if ($document->totals->count()) + + + {{ trans('general.title.edit', ['type' => trans_choice('general.payments', 1)]) }} + + + @else + + + + {{ trans('general.title.edit', ['type' => trans_choice('general.payments', 1)]) }} + + + + @endif - diff --git a/resources/views/components/documents/show/make-payment.blade.php b/resources/views/components/documents/show/make-payment.blade.php index 3306b936b50..e15f9f68fa5 100644 --- a/resources/views/components/documents/show/make-payment.blade.php +++ b/resources/views/components/documents/show/make-payment.blade.php @@ -77,16 +77,26 @@ class="px-3 py-1.5 mb-3 sm:mb-0 rounded-lg text-xs font-medium leading-6 bg-gree - - - - {{ trans('general.title.edit', ['type' => trans_choice('general.payments', 1)]) }} - - + @if ($document->totals->count()) + + + {{ trans('general.title.edit', ['type' => trans_choice('general.payments', 1)]) }} + + + @else + + + + {{ trans('general.title.edit', ['type' => trans_choice('general.payments', 1)]) }} + + + + @endif -