diff --git a/app/Traits/Documents.php b/app/Traits/Documents.php index c47b559a4..21934977e 100644 --- a/app/Traits/Documents.php +++ b/app/Traits/Documents.php @@ -207,7 +207,7 @@ trait Documents $today = Date::today()->toDateString(); // Eager load transactions with currency to prevent N+1 queries when calling getAmountConvertedToDefault() - $documents = $documents ?: Document::type($type)->with(['transactions.currency'])->future(); + $documents = $documents ?: Document::type($type)->with(['transactions', 'transactions.currency'])->future(); $documents->each(function ($document) use (&$totals, $today) { if (! in_array($document->status, $this->getDocumentStatusesForFuture())) { diff --git a/app/View/Components/Contacts/Show/Content.php b/app/View/Components/Contacts/Show/Content.php index 5c020b6c5..c365f28d8 100644 --- a/app/View/Components/Contacts/Show/Content.php +++ b/app/View/Components/Contacts/Show/Content.php @@ -37,7 +37,7 @@ class Content extends Component $docs = $this->contact->isCustomer() ? 'invoices' : 'bills'; // Eager load transactions with currency to prevent N+1 queries when calling getAmountConvertedToDefault() - $this->documents = $this->contact->$docs()->with(['transactions.currency'])->get(); + $this->documents = $this->contact->$docs()->with(['transactions', 'transactions.currency'])->get(); $this->counts['documents'] = $this->documents->count();