mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 02:26:58 +00:00
Catch null pointer
This commit is contained in:
@@ -193,6 +193,7 @@ class BillRepository implements BillRepositoryInterface
|
|||||||
$fields = ['bills.id', 'bills.created_at', 'bills.updated_at', 'bills.deleted_at', 'bills.user_id', 'bills.name', 'bills.amount_min',
|
$fields = ['bills.id', 'bills.created_at', 'bills.updated_at', 'bills.deleted_at', 'bills.user_id', 'bills.name', 'bills.amount_min',
|
||||||
'bills.amount_max', 'bills.date', 'bills.transaction_currency_id', 'bills.repeat_freq', 'bills.skip', 'bills.automatch', 'bills.active',];
|
'bills.amount_max', 'bills.date', 'bills.transaction_currency_id', 'bills.repeat_freq', 'bills.skip', 'bills.automatch', 'bills.active',];
|
||||||
$ids = $accounts->pluck('id')->toArray();
|
$ids = $accounts->pluck('id')->toArray();
|
||||||
|
|
||||||
return $this->user->bills()
|
return $this->user->bills()
|
||||||
->leftJoin(
|
->leftJoin(
|
||||||
'transaction_journals',
|
'transaction_journals',
|
||||||
@@ -411,6 +412,7 @@ class BillRepository implements BillRepositoryInterface
|
|||||||
foreach ($result as $currencyId => $arr) {
|
foreach ($result as $currencyId => $arr) {
|
||||||
$result[$currencyId]['avg'] = bcdiv($arr['sum'], (string)$arr['count']);
|
$result[$currencyId]['avg'] = bcdiv($arr['sum'], (string)$arr['count']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -438,6 +440,7 @@ class BillRepository implements BillRepositoryInterface
|
|||||||
public function getPaidDatesInRange(Bill $bill, Carbon $start, Carbon $end): Collection
|
public function getPaidDatesInRange(Bill $bill, Carbon $start, Carbon $end): Collection
|
||||||
{
|
{
|
||||||
Log::debug('Now in getPaidDatesInRange()');
|
Log::debug('Now in getPaidDatesInRange()');
|
||||||
|
|
||||||
return $bill->transactionJournals()
|
return $bill->transactionJournals()
|
||||||
->before($end)->after($start)->get(
|
->before($end)->after($start)->get(
|
||||||
[
|
[
|
||||||
@@ -560,6 +563,9 @@ class BillRepository implements BillRepositoryInterface
|
|||||||
foreach ($journals as $journal) {
|
foreach ($journals as $journal) {
|
||||||
/** @var Transaction $transaction */
|
/** @var Transaction $transaction */
|
||||||
$transaction = $journal->transactions()->where('amount', '<', 0)->first();
|
$transaction = $journal->transactions()->where('amount', '<', 0)->first();
|
||||||
|
if (null === $transaction) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$currencyId = (int)$journal->transaction_currency_id;
|
$currencyId = (int)$journal->transaction_currency_id;
|
||||||
$currency = $journal->transactionCurrency;
|
$currency = $journal->transactionCurrency;
|
||||||
$result[$currencyId] = $result[$currencyId] ?? [
|
$result[$currencyId] = $result[$currencyId] ?? [
|
||||||
@@ -583,6 +589,7 @@ class BillRepository implements BillRepositoryInterface
|
|||||||
foreach ($result as $currencyId => $arr) {
|
foreach ($result as $currencyId => $arr) {
|
||||||
$result[$currencyId]['avg'] = bcdiv($arr['sum'], (string)$arr['count']);
|
$result[$currencyId]['avg'] = bcdiv($arr['sum'], (string)$arr['count']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user