Merge pull request #2924 from aleksanderd/ninja-fixes-develop

Ninja fixes #2917
This commit is contained in:
Hillel Coren 2019-08-08 09:17:13 +03:00 committed by GitHub
commit f8c7ae1a73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 4 deletions

View File

@ -22,6 +22,8 @@ use Nwidart\Modules\Facades\Module;
class Utils class Utils
{ {
protected static $cacheValues = [];
private static $weekdayNames = [ private static $weekdayNames = [
'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday',
]; ];
@ -555,6 +557,9 @@ class Utils
public static function getFromCache($id, $type) 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); $cache = Cache::get($type);
if (! $cache) { if (! $cache) {
@ -567,7 +572,11 @@ class Utils
return $item->id == $id; 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) public static function formatNumber($value, $currencyId = false, $precision = 0)

View File

@ -56,7 +56,7 @@ class InvoiceReport extends AbstractReport
$clients = Client::scope() $clients = Client::scope()
->orderBy('name') ->orderBy('name')
->withArchived() ->withArchived()
->with('contacts', 'user') ->with('contacts', 'user', 'country', 'shipping_country')
->with(['invoices' => function ($query) use ($statusIds) { ->with(['invoices' => function ($query) use ($statusIds) {
$query->invoices() $query->invoices()
->withArchived() ->withArchived()
@ -122,7 +122,7 @@ class InvoiceReport extends AbstractReport
$invoice->po_number, $invoice->po_number,
$invoice->private_notes, $invoice->private_notes,
$client->vat_number, $client->vat_number,
$invoice->user->getDisplayName(), $client->user->getDisplayName(),
trim(str_replace('<br/>', ', ', $client->present()->address()), ', '), trim(str_replace('<br/>', ', ', $client->present()->address()), ', '),
trim(str_replace('<br/>', ', ', $client->present()->address(ADDRESS_SHIPPING)), ', '), trim(str_replace('<br/>', ', ', $client->present()->address(ADDRESS_SHIPPING)), ', '),
]; ];

View File

@ -31,7 +31,9 @@ class TaxRateReport extends AbstractReport
->withArchived() ->withArchived()
->with('contacts', 'user') ->with('contacts', 'user')
->with(['invoices' => function ($query) { ->with(['invoices' => function ($query) {
$query->with('invoice_items') $query
->with('account', 'client')
->with('invoice_items')
->withArchived() ->withArchived()
->invoices() ->invoices()
->where('is_public', '=', true); ->where('is_public', '=', true);