1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

Fix for null reference

This commit is contained in:
Hillel Coren 2016-09-19 10:04:30 +03:00
parent 2657a3d31f
commit 767d4d148a
3 changed files with 13 additions and 7 deletions

View File

@ -42,12 +42,12 @@ class DashboardApiController extends BaseAPIController
$data = [
'id' => 1,
'paidToDate' => $paidToDate[0]->value ? $paidToDate[0]->value : 0,
'paidToDateCurrency' => $paidToDate[0]->currency_id ? $paidToDate[0]->currency_id : 0,
'balances' => $balances[0]->value ? $balances[0]->value : 0,
'balancesCurrency' => $balances[0]->currency_id ? $balances[0]->currency_id : 0,
'averageInvoice' => (count($averageInvoice) && $averageInvoice[0]->invoice_avg) ? $averageInvoice[0]->invoice_avg : 0,
'averageInvoiceCurrency' => $averageInvoice[0]->currency_id ? $averageInvoice[0]->currency_id : 0,
'paidToDate' => count($paidToDate) && $paidToDate[0]->value ? $paidToDate[0]->value : 0,
'paidToDateCurrency' => count($paidToDate) && $paidToDate[0]->currency_id ? $paidToDate[0]->currency_id : 0,
'balances' => count($balances) && $balances[0]->value ? $balances[0]->value : 0,
'balancesCurrency' => count($balances) && $balances[0]->currency_id ? $balances[0]->currency_id : 0,
'averageInvoice' => count($averageInvoice) && $averageInvoice[0]->invoice_avg ? $averageInvoice[0]->invoice_avg : 0,
'averageInvoiceCurrency' => count($averageInvoice) && $averageInvoice[0]->currency_id ? $averageInvoice[0]->currency_id : 0,
'invoicesSent' => $metrics ? $metrics->invoices_sent : 0,
'activeClients' => $metrics ? $metrics->active_clients : 0,
'activities' => $this->createCollection($activities, new ActivityTransformer(), ENTITY_ACTIVITY),

View File

@ -48,9 +48,15 @@ class HistoryUtils
$entity = $activity->client;
} else if ($activity->activity_type_id == ACTIVITY_TYPE_CREATE_TASK || $activity->activity_type_id == ACTIVITY_TYPE_UPDATE_TASK) {
$entity = $activity->task;
if ( ! $entity) {
continue;
}
$entity->setRelation('client', $activity->client);
} else {
$entity = $activity->invoice;
if ( ! $entity) {
continue;
}
$entity->setRelation('client', $activity->client);
}

View File

@ -24,7 +24,7 @@ class ActivityTransformer extends EntityTransformer
return [
'id' => $activity->key(),
'activity_type_id' => $activity->activity_type_id,
'client_id' => $activity->client->public_id,
'client_id' => $activity->client ? $activity->client->public_id : null,
'user_id' => $activity->user->public_id + 1,
'invoice_id' => $activity->invoice ? $activity->invoice->public_id : null,
'payment_id' => $activity->payment ? $activity->payment->public_id : null,