mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-22 12:11:19 +00:00
Code cleanup
This commit is contained in:
@@ -327,7 +327,7 @@ trait AttachmentCollection
|
||||
foreach ($transaction['attachments'] as $attachment) {
|
||||
/** @var null|Attachment $object */
|
||||
$object = auth()->user()->attachments()->find($attachment['id']);
|
||||
$notes = (string)$object?->notes()->first()?->text;
|
||||
$notes = (string) $object?->notes()->first()?->text;
|
||||
|
||||
return '' !== $notes && $notes === $value;
|
||||
}
|
||||
@@ -351,7 +351,7 @@ trait AttachmentCollection
|
||||
foreach ($transaction['attachments'] as $attachment) {
|
||||
/** @var null|Attachment $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,7 +375,7 @@ trait AttachmentCollection
|
||||
foreach ($transaction['attachments'] as $attachment) {
|
||||
/** @var null|Attachment $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));
|
||||
}
|
||||
@@ -399,7 +399,7 @@ trait AttachmentCollection
|
||||
foreach ($transaction['attachments'] as $attachment) {
|
||||
/** @var null|Attachment $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));
|
||||
}
|
||||
@@ -423,7 +423,7 @@ trait AttachmentCollection
|
||||
foreach ($transaction['attachments'] as $attachment) {
|
||||
/** @var null|Attachment $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));
|
||||
}
|
||||
@@ -447,7 +447,7 @@ trait AttachmentCollection
|
||||
foreach ($transaction['attachments'] as $attachment) {
|
||||
/** @var null|Attachment $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));
|
||||
}
|
||||
@@ -471,7 +471,7 @@ trait AttachmentCollection
|
||||
foreach ($transaction['attachments'] as $attachment) {
|
||||
/** @var null|Attachment $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));
|
||||
}
|
||||
@@ -495,7 +495,7 @@ trait AttachmentCollection
|
||||
foreach ($transaction['attachments'] as $attachment) {
|
||||
/** @var null|Attachment $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));
|
||||
}
|
||||
|
@@ -195,7 +195,7 @@ trait MetaCollection
|
||||
|
||||
public function excludeInternalReference(string $internalReference): GroupCollectorInterface
|
||||
{
|
||||
$internalReference = (string)json_encode($internalReference);
|
||||
$internalReference = (string) json_encode($internalReference);
|
||||
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
@@ -216,7 +216,7 @@ trait MetaCollection
|
||||
|
||||
public function externalIdContains(string $externalId): GroupCollectorInterface
|
||||
{
|
||||
$externalId = (string)json_encode($externalId);
|
||||
$externalId = (string) json_encode($externalId);
|
||||
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
@@ -228,7 +228,7 @@ trait MetaCollection
|
||||
|
||||
public function externalIdDoesNotContain(string $externalId): GroupCollectorInterface
|
||||
{
|
||||
$externalId = (string)json_encode($externalId);
|
||||
$externalId = (string) json_encode($externalId);
|
||||
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
@@ -240,7 +240,7 @@ trait MetaCollection
|
||||
|
||||
public function externalIdDoesNotEnd(string $externalId): GroupCollectorInterface
|
||||
{
|
||||
$externalId = (string)json_encode($externalId);
|
||||
$externalId = (string) json_encode($externalId);
|
||||
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
@@ -252,7 +252,7 @@ trait MetaCollection
|
||||
|
||||
public function externalIdDoesNotStart(string $externalId): GroupCollectorInterface
|
||||
{
|
||||
$externalId = (string)json_encode($externalId);
|
||||
$externalId = (string) json_encode($externalId);
|
||||
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
@@ -264,7 +264,7 @@ trait MetaCollection
|
||||
|
||||
public function externalIdEnds(string $externalId): GroupCollectorInterface
|
||||
{
|
||||
$externalId = (string)json_encode($externalId);
|
||||
$externalId = (string) json_encode($externalId);
|
||||
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
@@ -276,7 +276,7 @@ trait MetaCollection
|
||||
|
||||
public function externalIdStarts(string $externalId): GroupCollectorInterface
|
||||
{
|
||||
$externalId = (string)json_encode($externalId);
|
||||
$externalId = (string) json_encode($externalId);
|
||||
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
@@ -289,7 +289,7 @@ trait MetaCollection
|
||||
public function externalUrlContains(string $url): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$url = (string)json_encode($url);
|
||||
$url = (string) json_encode($url);
|
||||
$url = str_replace('\\', '\\\\', trim($url, '"'));
|
||||
$this->query->where('journal_meta.name', '=', 'external_url');
|
||||
$this->query->whereLike('journal_meta.data', sprintf('%%%s%%', $url));
|
||||
@@ -300,7 +300,7 @@ trait MetaCollection
|
||||
public function externalUrlDoesNotContain(string $url): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$url = (string)json_encode($url);
|
||||
$url = (string) json_encode($url);
|
||||
$url = str_replace('\\', '\\\\', trim($url, '"'));
|
||||
$this->query->where('journal_meta.name', '=', 'external_url');
|
||||
$this->query->whereNotLike('journal_meta.data', sprintf('%%%s%%', $url));
|
||||
@@ -311,7 +311,7 @@ trait MetaCollection
|
||||
public function externalUrlDoesNotEnd(string $url): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$url = (string)json_encode($url);
|
||||
$url = (string) json_encode($url);
|
||||
$url = str_replace('\\', '\\\\', ltrim($url, '"'));
|
||||
$this->query->where('journal_meta.name', '=', 'external_url');
|
||||
$this->query->whereNotLike('journal_meta.data', sprintf('%%%s', $url));
|
||||
@@ -322,7 +322,7 @@ trait MetaCollection
|
||||
public function externalUrlDoesNotStart(string $url): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$url = (string)json_encode($url);
|
||||
$url = (string) json_encode($url);
|
||||
$url = str_replace('\\', '\\\\', rtrim($url, '"'));
|
||||
// var_dump($url);
|
||||
|
||||
@@ -335,7 +335,7 @@ trait MetaCollection
|
||||
public function externalUrlEnds(string $url): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$url = (string)json_encode($url);
|
||||
$url = (string) json_encode($url);
|
||||
$url = str_replace('\\', '\\\\', ltrim($url, '"'));
|
||||
$this->query->where('journal_meta.name', '=', 'external_url');
|
||||
$this->query->whereLike('journal_meta.data', sprintf('%%%s', $url));
|
||||
@@ -346,7 +346,7 @@ trait MetaCollection
|
||||
public function externalUrlStarts(string $url): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$url = (string)json_encode($url);
|
||||
$url = (string) json_encode($url);
|
||||
$url = str_replace('\\', '\\\\', rtrim($url, '"'));
|
||||
// var_dump($url);
|
||||
|
||||
@@ -397,7 +397,7 @@ trait MetaCollection
|
||||
|
||||
public function internalReferenceContains(string $internalReference): GroupCollectorInterface
|
||||
{
|
||||
$internalReference = (string)json_encode($internalReference);
|
||||
$internalReference = (string) json_encode($internalReference);
|
||||
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
||||
// var_dump($internalReference);
|
||||
// exit;
|
||||
@@ -411,7 +411,7 @@ trait MetaCollection
|
||||
|
||||
public function internalReferenceDoesNotContain(string $internalReference): GroupCollectorInterface
|
||||
{
|
||||
$internalReference = (string)json_encode($internalReference);
|
||||
$internalReference = (string) json_encode($internalReference);
|
||||
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
@@ -423,7 +423,7 @@ trait MetaCollection
|
||||
|
||||
public function internalReferenceDoesNotEnd(string $internalReference): GroupCollectorInterface
|
||||
{
|
||||
$internalReference = (string)json_encode($internalReference);
|
||||
$internalReference = (string) json_encode($internalReference);
|
||||
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
@@ -435,7 +435,7 @@ trait MetaCollection
|
||||
|
||||
public function internalReferenceDoesNotStart(string $internalReference): GroupCollectorInterface
|
||||
{
|
||||
$internalReference = (string)json_encode($internalReference);
|
||||
$internalReference = (string) json_encode($internalReference);
|
||||
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
@@ -447,7 +447,7 @@ trait MetaCollection
|
||||
|
||||
public function internalReferenceEnds(string $internalReference): GroupCollectorInterface
|
||||
{
|
||||
$internalReference = (string)json_encode($internalReference);
|
||||
$internalReference = (string) json_encode($internalReference);
|
||||
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
@@ -459,7 +459,7 @@ trait MetaCollection
|
||||
|
||||
public function internalReferenceStarts(string $internalReference): GroupCollectorInterface
|
||||
{
|
||||
$internalReference = (string)json_encode($internalReference);
|
||||
$internalReference = (string) json_encode($internalReference);
|
||||
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
@@ -712,7 +712,7 @@ trait MetaCollection
|
||||
|
||||
public function setInternalReference(string $internalReference): GroupCollectorInterface
|
||||
{
|
||||
$internalReference = (string)json_encode($internalReference);
|
||||
$internalReference = (string) json_encode($internalReference);
|
||||
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
|
@@ -125,7 +125,7 @@ trait TimeCollection
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
|
||||
) {
|
||||
return $transaction[$field]->day >= (int)$day;
|
||||
return $transaction[$field]->day >= (int) $day;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ trait TimeCollection
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
|
||||
) {
|
||||
return $transaction[$field]->day <= (int)$day;
|
||||
return $transaction[$field]->day <= (int) $day;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ trait TimeCollection
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
|
||||
) {
|
||||
return (int)$day === $transaction[$field]->day;
|
||||
return (int) $day === $transaction[$field]->day;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ trait TimeCollection
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
|
||||
) {
|
||||
return (int)$day !== $transaction[$field]->day;
|
||||
return (int) $day !== $transaction[$field]->day;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ trait TimeCollection
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
|
||||
) {
|
||||
return $transaction[$field]->month >= (int)$month;
|
||||
return $transaction[$field]->month >= (int) $month;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ trait TimeCollection
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
|
||||
) {
|
||||
return $transaction[$field]->month <= (int)$month;
|
||||
return $transaction[$field]->month <= (int) $month;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,7 +233,7 @@ trait TimeCollection
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
|
||||
) {
|
||||
return (int)$month === $transaction[$field]->month;
|
||||
return (int) $month === $transaction[$field]->month;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,7 +251,7 @@ trait TimeCollection
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
|
||||
) {
|
||||
return (int)$month !== $transaction[$field]->month;
|
||||
return (int) $month !== $transaction[$field]->month;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,7 +269,7 @@ trait TimeCollection
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
|
||||
) {
|
||||
return $transaction[$field]->year >= (int)$year;
|
||||
return $transaction[$field]->year >= (int) $year;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,7 +287,7 @@ trait TimeCollection
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
|
||||
) {
|
||||
return $transaction[$field]->year <= (int)$year;
|
||||
return $transaction[$field]->year <= (int) $year;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,7 +305,7 @@ trait TimeCollection
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
|
||||
) {
|
||||
return $year === (string)$transaction[$field]->year;
|
||||
return $year === (string) $transaction[$field]->year;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,7 +323,7 @@ trait TimeCollection
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
|
||||
) {
|
||||
return $year !== (string)$transaction[$field]->year;
|
||||
return $year !== (string) $transaction[$field]->year;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -292,7 +292,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
foreach ($params as $param) {
|
||||
$replace = sprintf('"%s"', $param);
|
||||
if (is_int($param)) {
|
||||
$replace = (string)$param;
|
||||
$replace = (string) $param;
|
||||
}
|
||||
$pos = strpos($query, '?');
|
||||
if (false !== $pos) {
|
||||
@@ -503,13 +503,13 @@ class GroupCollector implements GroupCollectorInterface
|
||||
|
||||
/** @var TransactionJournal $augumentedJournal */
|
||||
foreach ($collection as $augumentedJournal) {
|
||||
$groupId = (int)$augumentedJournal->transaction_group_id;
|
||||
$groupId = (int) $augumentedJournal->transaction_group_id;
|
||||
|
||||
if (!array_key_exists($groupId, $groups)) {
|
||||
// make new array
|
||||
$parsedGroup = $this->parseAugmentedJournal($augumentedJournal);
|
||||
$groupArray = [
|
||||
'id' => (int)$augumentedJournal->transaction_group_id,
|
||||
'id' => (int) $augumentedJournal->transaction_group_id,
|
||||
'user_id' => $augumentedJournal->user_id,
|
||||
'user_group_id' => $augumentedJournal->user_group_id,
|
||||
// Field transaction_group_title was added by the query.
|
||||
@@ -522,7 +522,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
'transactions' => [],
|
||||
];
|
||||
// Field transaction_journal_id was added by the query.
|
||||
$journalId = (int)$augumentedJournal->transaction_journal_id; // @phpstan-ignore-line
|
||||
$journalId = (int) $augumentedJournal->transaction_journal_id; // @phpstan-ignore-line
|
||||
$groupArray['transactions'][$journalId] = $parsedGroup;
|
||||
$groups[$groupId] = $groupArray;
|
||||
|
||||
@@ -530,7 +530,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
}
|
||||
// or parse the rest.
|
||||
// Field transaction_journal_id was added by the query.
|
||||
$journalId = (int)$augumentedJournal->transaction_journal_id; // @phpstan-ignore-line
|
||||
$journalId = (int) $augumentedJournal->transaction_journal_id; // @phpstan-ignore-line
|
||||
if (array_key_exists($journalId, $groups[$groupId]['transactions'])) {
|
||||
// append data to existing group + journal (for multiple tags or multiple attachments)
|
||||
$groups[$groupId]['transactions'][$journalId] = $this->mergeTags($groups[$groupId]['transactions'][$journalId], $augumentedJournal);
|
||||
@@ -583,7 +583,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
$dates = ['interest_date', 'payment_date', 'invoice_date', 'book_date', 'due_date', 'process_date'];
|
||||
if (array_key_exists('meta_name', $result) && in_array($result['meta_name'], $dates, true)) {
|
||||
$name = $result['meta_name'];
|
||||
if (array_key_exists('meta_data', $result) && '' !== (string)$result['meta_data']) {
|
||||
if (array_key_exists('meta_data', $result) && '' !== (string) $result['meta_data']) {
|
||||
$result[$name] = Carbon::createFromFormat('!Y-m-d', substr(json_decode($result['meta_data']), 0, 10));
|
||||
}
|
||||
}
|
||||
@@ -594,9 +594,9 @@ class GroupCollector implements GroupCollectorInterface
|
||||
// convert back to strings because SQLite is dumb like that.
|
||||
$result = $this->convertToStrings($result);
|
||||
|
||||
$result['reconciled'] = 1 === (int)$result['reconciled'];
|
||||
$result['reconciled'] = 1 === (int) $result['reconciled'];
|
||||
if (array_key_exists('tag_id', $result) && null !== $result['tag_id']) { // assume the other fields are present as well.
|
||||
$tagId = (int)$augumentedJournal['tag_id'];
|
||||
$tagId = (int) $augumentedJournal['tag_id'];
|
||||
$tagDate = null;
|
||||
|
||||
try {
|
||||
@@ -606,7 +606,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
}
|
||||
|
||||
$result['tags'][$tagId] = [
|
||||
'id' => (int)$result['tag_id'],
|
||||
'id' => (int) $result['tag_id'],
|
||||
'name' => $result['tag_name'],
|
||||
'date' => $tagDate,
|
||||
'description' => $result['tag_description'],
|
||||
@@ -615,8 +615,8 @@ class GroupCollector implements GroupCollectorInterface
|
||||
|
||||
// also merge attachments:
|
||||
if (array_key_exists('attachment_id', $result)) {
|
||||
$uploaded = 1 === (int)$result['attachment_uploaded'];
|
||||
$attachmentId = (int)$augumentedJournal['attachment_id'];
|
||||
$uploaded = 1 === (int) $result['attachment_uploaded'];
|
||||
$attachmentId = (int) $augumentedJournal['attachment_id'];
|
||||
if (0 !== $attachmentId && $uploaded) {
|
||||
$result['attachments'][$attachmentId] = [
|
||||
'id' => $attachmentId,
|
||||
@@ -642,7 +642,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
private function convertToInteger(array $array): array
|
||||
{
|
||||
foreach ($this->integerFields as $field) {
|
||||
$array[$field] = array_key_exists($field, $array) ? (int)$array[$field] : null;
|
||||
$array[$field] = array_key_exists($field, $array) ? (int) $array[$field] : null;
|
||||
}
|
||||
|
||||
return $array;
|
||||
@@ -651,7 +651,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
private function convertToStrings(array $array): array
|
||||
{
|
||||
foreach ($this->stringFields as $field) {
|
||||
$array[$field] = array_key_exists($field, $array) && null !== $array[$field] ? (string)$array[$field] : null;
|
||||
$array[$field] = array_key_exists($field, $array) && null !== $array[$field] ? (string) $array[$field] : null;
|
||||
}
|
||||
|
||||
return $array;
|
||||
@@ -661,7 +661,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
{
|
||||
$newArray = $newJournal->toArray();
|
||||
if (array_key_exists('tag_id', $newArray)) { // assume the other fields are present as well.
|
||||
$tagId = (int)$newJournal['tag_id'];
|
||||
$tagId = (int) $newJournal['tag_id'];
|
||||
|
||||
$tagDate = null;
|
||||
|
||||
@@ -672,7 +672,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
}
|
||||
|
||||
$existingJournal['tags'][$tagId] = [
|
||||
'id' => (int)$newArray['tag_id'],
|
||||
'id' => (int) $newArray['tag_id'],
|
||||
'name' => $newArray['tag_name'],
|
||||
'date' => $tagDate,
|
||||
'description' => $newArray['tag_description'],
|
||||
@@ -686,7 +686,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
{
|
||||
$newArray = $newJournal->toArray();
|
||||
if (array_key_exists('attachment_id', $newArray)) {
|
||||
$attachmentId = (int)$newJournal['attachment_id'];
|
||||
$attachmentId = (int) $newJournal['attachment_id'];
|
||||
|
||||
$existingJournal['attachments'][$attachmentId] = [
|
||||
'id' => $attachmentId,
|
||||
@@ -705,7 +705,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
foreach ($groups as $groudId => $group) {
|
||||
/** @var array $transaction */
|
||||
foreach ($group['transactions'] as $transaction) {
|
||||
$currencyId = (int)$transaction['currency_id'];
|
||||
$currencyId = (int) $transaction['currency_id'];
|
||||
if (null === $transaction['amount']) {
|
||||
throw new FireflyException(sprintf('Amount is NULL for a transaction in group #%d, please investigate.', $groudId));
|
||||
}
|
||||
@@ -721,7 +721,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
$groups[$groudId]['sums'][$currencyId]['amount'] = bcadd($groups[$groudId]['sums'][$currencyId]['amount'], $transaction['amount']);
|
||||
|
||||
if (null !== $transaction['foreign_amount'] && null !== $transaction['foreign_currency_id']) {
|
||||
$currencyId = (int)$transaction['foreign_currency_id'];
|
||||
$currencyId = (int) $transaction['foreign_currency_id'];
|
||||
|
||||
// set default:
|
||||
if (!array_key_exists($currencyId, $groups[$groudId]['sums'])) {
|
||||
|
Reference in New Issue
Block a user