diff --git a/app/Libraries/Utils.php b/app/Libraries/Utils.php index 121e3cc5d6fd..5f2f61d543c0 100644 --- a/app/Libraries/Utils.php +++ b/app/Libraries/Utils.php @@ -22,6 +22,8 @@ use Nwidart\Modules\Facades\Module; class Utils { + protected static $cacheValues = []; + private static $weekdayNames = [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', ]; @@ -555,6 +557,9 @@ class Utils public static function getFromCache($id, $type) { + if (!empty(static::$cacheValues[$type]) && !empty(static::$cacheValues[$type][$id])) { + return static::$cacheValues[$type][$id]; + } $cache = Cache::get($type); if (! $cache) { @@ -567,7 +572,11 @@ class Utils return $item->id == $id; }); - return $data->first(); + $res = $data->first(); + if (!empty($res)) { + static::$cacheValues[$type][$id] = $res; + } + return $res; } public static function formatNumber($value, $currencyId = false, $precision = 0) diff --git a/app/Ninja/Reports/InvoiceReport.php b/app/Ninja/Reports/InvoiceReport.php index 1dce1b17b1b9..ddd410521cea 100644 --- a/app/Ninja/Reports/InvoiceReport.php +++ b/app/Ninja/Reports/InvoiceReport.php @@ -56,7 +56,7 @@ class InvoiceReport extends AbstractReport $clients = Client::scope() ->orderBy('name') ->withArchived() - ->with('contacts', 'user') + ->with('contacts', 'user', 'country', 'shipping_country') ->with(['invoices' => function ($query) use ($statusIds) { $query->invoices() ->withArchived() @@ -122,7 +122,7 @@ class InvoiceReport extends AbstractReport $invoice->po_number, $invoice->private_notes, $client->vat_number, - $invoice->user->getDisplayName(), + $client->user->getDisplayName(), trim(str_replace('
', ', ', $client->present()->address()), ', '), trim(str_replace('
', ', ', $client->present()->address(ADDRESS_SHIPPING)), ', '), ]; diff --git a/app/Ninja/Reports/TaxRateReport.php b/app/Ninja/Reports/TaxRateReport.php index 4cc9df12468c..588432b3596e 100644 --- a/app/Ninja/Reports/TaxRateReport.php +++ b/app/Ninja/Reports/TaxRateReport.php @@ -31,7 +31,9 @@ class TaxRateReport extends AbstractReport ->withArchived() ->with('contacts', 'user') ->with(['invoices' => function ($query) { - $query->with('invoice_items') + $query + ->with('account', 'client') + ->with('invoice_items') ->withArchived() ->invoices() ->where('is_public', '=', true);