diff --git a/app/Http/Controllers/Modals/DocumentTransactions.php b/app/Http/Controllers/Modals/DocumentTransactions.php index 39879ea9c..9df1b6a9b 100644 --- a/app/Http/Controllers/Modals/DocumentTransactions.php +++ b/app/Http/Controllers/Modals/DocumentTransactions.php @@ -55,12 +55,12 @@ class DocumentTransactions extends Controller $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 @@ class DocumentTransactions extends Controller $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 9a3c1951b..e7c0501ad 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 @@ - - - - {{ 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 3306b936b..e15f9f68f 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 @@ - - - - {{ 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 -