mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Fix a few null pointers.
This commit is contained in:
@@ -103,6 +103,9 @@ class NetWorth implements NetWorthInterface
|
|||||||
foreach ($accounts as $account) {
|
foreach ($accounts as $account) {
|
||||||
app('log')->debug(sprintf('Now at account #%d ("%s")', $account->id, $account->name));
|
app('log')->debug(sprintf('Now at account #%d ("%s")', $account->id, $account->name));
|
||||||
$currency = $this->getRepository()->getAccountCurrency($account);
|
$currency = $this->getRepository()->getAccountCurrency($account);
|
||||||
|
if(null === $currency) {
|
||||||
|
$currency = app('amount')->getDefaultCurrency();
|
||||||
|
}
|
||||||
$currencyId = $currency->id;
|
$currencyId = $currency->id;
|
||||||
$balance = '0';
|
$balance = '0';
|
||||||
$nativeBalance = '0';
|
$nativeBalance = '0';
|
||||||
|
@@ -25,7 +25,9 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Support;
|
namespace FireflyIII\Support;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Carbon\Exceptions\InvalidFormatException;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ParseDateString
|
* Class ParseDateString
|
||||||
@@ -151,8 +153,13 @@ class ParseDateString
|
|||||||
*/
|
*/
|
||||||
protected function parseDefaultDate(string $date): Carbon
|
protected function parseDefaultDate(string $date): Carbon
|
||||||
{
|
{
|
||||||
$result = Carbon::createFromFormat('Y-m-d', $date);
|
$result = false;
|
||||||
if(false === $result) {
|
try {
|
||||||
|
$result = Carbon::createFromFormat('Y-m-d', $date);
|
||||||
|
} catch (InvalidFormatException $e) {
|
||||||
|
Log::error(sprintf('parseDefaultDate("%s") ran into an error, but dont mind: %s', $date, $e->getMessage()));
|
||||||
|
}
|
||||||
|
if (false === $result) {
|
||||||
$result = today(config('app.timezone'))->startOfDay();
|
$result = today(config('app.timezone'))->startOfDay();
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
|
@@ -62,10 +62,14 @@ class BillTransformer extends AbstractTransformer
|
|||||||
{
|
{
|
||||||
$paidData = $this->paidData($bill);
|
$paidData = $this->paidData($bill);
|
||||||
$lastPaidDate = $this->getLastPaidDate($paidData);
|
$lastPaidDate = $this->getLastPaidDate($paidData);
|
||||||
$payDates = $this->calculator->getPayDates($this->parameters->get('start'), $this->parameters->get('end'), $bill->date, $bill->repeat_freq, $bill->skip, $lastPaidDate);
|
|
||||||
$currency = $bill->transactionCurrency;
|
// both params can be NULL, so just in case they are, add some wide margins:
|
||||||
$notes = $this->repository->getNoteText($bill);
|
$start = $this->parameters->get('start') ?? today()->subYears(10);
|
||||||
$notes = '' === $notes ? null : $notes;
|
$end = $this->parameters->get('end') ?? today()->addYears(10);
|
||||||
|
$payDates = $this->calculator->getPayDates($start, $end, $bill->date, $bill->repeat_freq, $bill->skip, $lastPaidDate);
|
||||||
|
$currency = $bill->transactionCurrency;
|
||||||
|
$notes = $this->repository->getNoteText($bill);
|
||||||
|
$notes = '' === $notes ? null : $notes;
|
||||||
$this->repository->setUser($bill->user);
|
$this->repository->setUser($bill->user);
|
||||||
|
|
||||||
$objectGroupId = null;
|
$objectGroupId = null;
|
||||||
@@ -105,10 +109,10 @@ class BillTransformer extends AbstractTransformer
|
|||||||
|
|
||||||
if (null !== $firstPayDate) {
|
if (null !== $firstPayDate) {
|
||||||
$nemDate = Carbon::createFromFormat('!Y-m-d', $firstPayDate, config('app.timezone'));
|
$nemDate = Carbon::createFromFormat('!Y-m-d', $firstPayDate, config('app.timezone'));
|
||||||
if(false === $nemDate) {
|
if (false === $nemDate) {
|
||||||
$nemDate = today(config('app.timezone'));
|
$nemDate = today(config('app.timezone'));
|
||||||
}
|
}
|
||||||
$nem = $nemDate->toAtomString();
|
$nem = $nemDate->toAtomString();
|
||||||
|
|
||||||
// nullify again when it's outside the current view range.
|
// nullify again when it's outside the current view range.
|
||||||
if ($nemDate->lt($this->parameters->get('start')) || $nemDate->gt($this->parameters->get('end'))) {
|
if ($nemDate->lt($this->parameters->get('start')) || $nemDate->gt($this->parameters->get('end'))) {
|
||||||
@@ -126,8 +130,8 @@ class BillTransformer extends AbstractTransformer
|
|||||||
|
|
||||||
$current = $payDatesFormatted[0] ?? null;
|
$current = $payDatesFormatted[0] ?? null;
|
||||||
if (null !== $current && !$nemDate->isToday()) {
|
if (null !== $current && !$nemDate->isToday()) {
|
||||||
$temp2 = Carbon::createFromFormat('Y-m-d\TH:i:sP', $current);
|
$temp2 = Carbon::createFromFormat('Y-m-d\TH:i:sP', $current);
|
||||||
if(false === $temp2) {
|
if (false === $temp2) {
|
||||||
$temp2 = today(config('app.timezone'));
|
$temp2 = today(config('app.timezone'));
|
||||||
}
|
}
|
||||||
$nemDiff = trans('firefly.bill_expected_date', ['date' => $temp2->diffForHumans(today(config('app.timezone')), CarbonInterface::DIFF_RELATIVE_TO_NOW)]);
|
$nemDiff = trans('firefly.bill_expected_date', ['date' => $temp2->diffForHumans(today(config('app.timezone')), CarbonInterface::DIFF_RELATIVE_TO_NOW)]);
|
||||||
|
@@ -170,7 +170,7 @@ You can contact me at [james@firefly-iii.org](mailto:james@firefly-iii.org), you
|
|||||||
- [GitHub Discussions for questions and support](https://github.com/firefly-iii/firefly-iii/discussions/)
|
- [GitHub Discussions for questions and support](https://github.com/firefly-iii/firefly-iii/discussions/)
|
||||||
- [Gitter.im for a good chat and a quick answer](https://gitter.im/firefly-iii/firefly-iii)
|
- [Gitter.im for a good chat and a quick answer](https://gitter.im/firefly-iii/firefly-iii)
|
||||||
- [GitHub Issues for bugs and issues](https://github.com/firefly-iii/firefly-iii/issues)
|
- [GitHub Issues for bugs and issues](https://github.com/firefly-iii/firefly-iii/issues)
|
||||||
- [Follow me around for news and updates on Twitter](https://twitter.com/Firefly_iii)
|
- [Follow me around for news and updates on Mastodon](https://fosstodon.org/@ff3)
|
||||||
|
|
||||||
## Acknowledgements
|
## Acknowledgements
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user