Various code cleanup

This commit is contained in:
James Cole
2023-01-03 06:48:53 +01:00
parent 6784fe4436
commit 07e4e93632
47 changed files with 118 additions and 211 deletions

View File

@@ -323,9 +323,9 @@ trait AttachmentCollection
foreach ($object['transactions'] as $transaction) {
/** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) {
/** @var Attachment $object */
/** @var Attachment|null $object */
$object = auth()->user()->attachments()->find($attachment['id']);
$notes = (string)$object->notes()?->first()?->text;
$notes = (string)$object?->notes()->first()?->text;
return $notes !== '' && $notes === $value;
}
}
@@ -349,9 +349,9 @@ trait AttachmentCollection
foreach ($object['transactions'] as $transaction) {
/** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) {
/** @var Attachment $object */
/** @var Attachment|null $object */
$object = auth()->user()->attachments()->find($attachment['id']);
$notes = (string)$object->notes()?->first()?->text;
$notes = (string)$object?->notes()->first()?->text;
return $notes !== '' && $notes !== $value;
}
}
@@ -375,9 +375,9 @@ trait AttachmentCollection
foreach ($object['transactions'] as $transaction) {
/** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) {
/** @var Attachment $object */
/** @var Attachment|null $object */
$object = auth()->user()->attachments()->find($attachment['id']);
$notes = (string)$object->notes()?->first()?->text;
$notes = (string)$object?->notes()->first()?->text;
return $notes !== '' && str_contains(strtolower($notes), strtolower($value));
}
}
@@ -401,9 +401,9 @@ trait AttachmentCollection
foreach ($object['transactions'] as $transaction) {
/** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) {
/** @var Attachment $object */
/** @var Attachment|null $object */
$object = auth()->user()->attachments()->find($attachment['id']);
$notes = (string)$object->notes()?->first()?->text;
$notes = (string)$object?->notes()->first()?->text;
return $notes !== '' && !str_contains(strtolower($notes), strtolower($value));
}
}
@@ -427,9 +427,9 @@ trait AttachmentCollection
foreach ($object['transactions'] as $transaction) {
/** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) {
/** @var Attachment $object */
/** @var Attachment|null $object */
$object = auth()->user()->attachments()->find($attachment['id']);
$notes = (string)$object->notes()?->first()?->text;
$notes = (string)$object?->notes()->first()?->text;
return $notes !== '' && !str_ends_with(strtolower($notes), strtolower($value));
}
}
@@ -453,9 +453,9 @@ trait AttachmentCollection
foreach ($object['transactions'] as $transaction) {
/** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) {
/** @var Attachment $object */
/** @var Attachment|null $object */
$object = auth()->user()->attachments()->find($attachment['id']);
$notes = (string)$object->notes()?->first()?->text;
$notes = (string)$object?->notes()->first()?->text;
return $notes !== '' && !str_starts_with(strtolower($notes), strtolower($value));
}
}
@@ -479,9 +479,9 @@ trait AttachmentCollection
foreach ($object['transactions'] as $transaction) {
/** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) {
/** @var Attachment $object */
/** @var Attachment|null $object */
$object = auth()->user()->attachments()->find($attachment['id']);
$notes = (string)$object->notes()?->first()?->text;
$notes = (string)$object?->notes()->first()?->text;
return $notes !== '' && str_ends_with(strtolower($notes), strtolower($value));
}
}
@@ -505,9 +505,9 @@ trait AttachmentCollection
foreach ($object['transactions'] as $transaction) {
/** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) {
/** @var Attachment $object */
/** @var Attachment|null $object */
$object = auth()->user()->attachments()->find($attachment['id']);
$notes = (string)$object->notes()?->first()?->text;
$notes = (string)$object?->notes()->first()?->text;
return $notes !== '' && str_starts_with(strtolower($notes), strtolower($value));
}
}

View File

@@ -25,6 +25,7 @@ namespace FireflyIII\Helpers\Collector;
use Carbon\Carbon;
use Carbon\Exceptions\InvalidDateException;
use Carbon\Exceptions\InvalidFormatException;
use Closure;
use Exception;
use FireflyIII\Exceptions\FireflyException;
@@ -602,7 +603,7 @@ class GroupCollector implements GroupCollectorInterface
$tagDate = null;
try {
$tagDate = Carbon::parse($augumentedJournal['tag_date']);
} catch (InvalidDateException $e) {
} catch (InvalidFormatException $e) {
Log::debug(sprintf('Could not parse date: %s', $e->getMessage()));
}
@@ -682,7 +683,7 @@ class GroupCollector implements GroupCollectorInterface
$tagDate = null;
try {
$tagDate = Carbon::parse($newArray['tag_date']);
} catch (InvalidDateException $e) {
} catch (InvalidFormatException $e) {
Log::debug(sprintf('Could not parse date: %s', $e->getMessage()));
}
@@ -754,10 +755,7 @@ class GroupCollector implements GroupCollectorInterface
$groups[$groudId]['sums'][$currencyId]['currency_decimal_places'] = $transaction['foreign_currency_decimal_places'];
$groups[$groudId]['sums'][$currencyId]['amount'] = '0';
}
$groups[$groudId]['sums'][$currencyId]['amount'] = bcadd(
$groups[$groudId]['sums'][$currencyId]['amount'],
$transaction['foreign_amount'] ?? '0'
);
$groups[$groudId]['sums'][$currencyId]['amount'] = bcadd($groups[$groudId]['sums'][$currencyId]['amount'], $transaction['foreign_amount']);
}
}
}