mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
This commit is contained in:
parent
8e2546da9d
commit
1e733f4c8b
@ -182,7 +182,7 @@ trait MetaCollection
|
|||||||
|
|
||||||
public function excludeInternalReference(string $internalReference): GroupCollectorInterface
|
public function excludeInternalReference(string $internalReference): GroupCollectorInterface
|
||||||
{
|
{
|
||||||
$internalReference = (string) json_encode($internalReference);
|
$internalReference = (string)json_encode($internalReference);
|
||||||
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
||||||
|
|
||||||
$this->joinMetaDataTables();
|
$this->joinMetaDataTables();
|
||||||
@ -203,7 +203,7 @@ trait MetaCollection
|
|||||||
|
|
||||||
public function externalIdContains(string $externalId): GroupCollectorInterface
|
public function externalIdContains(string $externalId): GroupCollectorInterface
|
||||||
{
|
{
|
||||||
$externalId = (string) json_encode($externalId);
|
$externalId = (string)json_encode($externalId);
|
||||||
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
|
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
|
||||||
|
|
||||||
$this->joinMetaDataTables();
|
$this->joinMetaDataTables();
|
||||||
@ -215,7 +215,7 @@ trait MetaCollection
|
|||||||
|
|
||||||
public function externalIdDoesNotContain(string $externalId): GroupCollectorInterface
|
public function externalIdDoesNotContain(string $externalId): GroupCollectorInterface
|
||||||
{
|
{
|
||||||
$externalId = (string) json_encode($externalId);
|
$externalId = (string)json_encode($externalId);
|
||||||
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
|
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
|
||||||
|
|
||||||
$this->joinMetaDataTables();
|
$this->joinMetaDataTables();
|
||||||
@ -227,7 +227,7 @@ trait MetaCollection
|
|||||||
|
|
||||||
public function externalIdDoesNotEnd(string $externalId): GroupCollectorInterface
|
public function externalIdDoesNotEnd(string $externalId): GroupCollectorInterface
|
||||||
{
|
{
|
||||||
$externalId = (string) json_encode($externalId);
|
$externalId = (string)json_encode($externalId);
|
||||||
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
|
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
|
||||||
|
|
||||||
$this->joinMetaDataTables();
|
$this->joinMetaDataTables();
|
||||||
@ -239,7 +239,7 @@ trait MetaCollection
|
|||||||
|
|
||||||
public function externalIdDoesNotStart(string $externalId): GroupCollectorInterface
|
public function externalIdDoesNotStart(string $externalId): GroupCollectorInterface
|
||||||
{
|
{
|
||||||
$externalId = (string) json_encode($externalId);
|
$externalId = (string)json_encode($externalId);
|
||||||
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
|
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
|
||||||
|
|
||||||
$this->joinMetaDataTables();
|
$this->joinMetaDataTables();
|
||||||
@ -251,7 +251,7 @@ trait MetaCollection
|
|||||||
|
|
||||||
public function externalIdEnds(string $externalId): GroupCollectorInterface
|
public function externalIdEnds(string $externalId): GroupCollectorInterface
|
||||||
{
|
{
|
||||||
$externalId = (string) json_encode($externalId);
|
$externalId = (string)json_encode($externalId);
|
||||||
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
|
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
|
||||||
|
|
||||||
$this->joinMetaDataTables();
|
$this->joinMetaDataTables();
|
||||||
@ -263,7 +263,7 @@ trait MetaCollection
|
|||||||
|
|
||||||
public function externalIdStarts(string $externalId): GroupCollectorInterface
|
public function externalIdStarts(string $externalId): GroupCollectorInterface
|
||||||
{
|
{
|
||||||
$externalId = (string) json_encode($externalId);
|
$externalId = (string)json_encode($externalId);
|
||||||
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
|
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
|
||||||
|
|
||||||
$this->joinMetaDataTables();
|
$this->joinMetaDataTables();
|
||||||
@ -276,7 +276,7 @@ trait MetaCollection
|
|||||||
public function externalUrlContains(string $url): GroupCollectorInterface
|
public function externalUrlContains(string $url): GroupCollectorInterface
|
||||||
{
|
{
|
||||||
$this->joinMetaDataTables();
|
$this->joinMetaDataTables();
|
||||||
$url = (string) json_encode($url);
|
$url = (string)json_encode($url);
|
||||||
$url = str_replace('\\', '\\\\', trim($url, '"'));
|
$url = str_replace('\\', '\\\\', trim($url, '"'));
|
||||||
$this->query->where('journal_meta.name', '=', 'external_url');
|
$this->query->where('journal_meta.name', '=', 'external_url');
|
||||||
$this->query->where('journal_meta.data', 'LIKE', sprintf('%%%s%%', $url));
|
$this->query->where('journal_meta.data', 'LIKE', sprintf('%%%s%%', $url));
|
||||||
@ -287,7 +287,7 @@ trait MetaCollection
|
|||||||
public function externalUrlDoesNotContain(string $url): GroupCollectorInterface
|
public function externalUrlDoesNotContain(string $url): GroupCollectorInterface
|
||||||
{
|
{
|
||||||
$this->joinMetaDataTables();
|
$this->joinMetaDataTables();
|
||||||
$url = (string) json_encode($url);
|
$url = (string)json_encode($url);
|
||||||
$url = str_replace('\\', '\\\\', trim($url, '"'));
|
$url = str_replace('\\', '\\\\', trim($url, '"'));
|
||||||
$this->query->where('journal_meta.name', '=', 'external_url');
|
$this->query->where('journal_meta.name', '=', 'external_url');
|
||||||
$this->query->where('journal_meta.data', 'NOT LIKE', sprintf('%%%s%%', $url));
|
$this->query->where('journal_meta.data', 'NOT LIKE', sprintf('%%%s%%', $url));
|
||||||
@ -298,7 +298,7 @@ trait MetaCollection
|
|||||||
public function externalUrlDoesNotEnd(string $url): GroupCollectorInterface
|
public function externalUrlDoesNotEnd(string $url): GroupCollectorInterface
|
||||||
{
|
{
|
||||||
$this->joinMetaDataTables();
|
$this->joinMetaDataTables();
|
||||||
$url = (string) json_encode($url);
|
$url = (string)json_encode($url);
|
||||||
$url = str_replace('\\', '\\\\', ltrim($url, '"'));
|
$url = str_replace('\\', '\\\\', ltrim($url, '"'));
|
||||||
$this->query->where('journal_meta.name', '=', 'external_url');
|
$this->query->where('journal_meta.name', '=', 'external_url');
|
||||||
$this->query->where('journal_meta.data', 'NOT LIKE', sprintf('%%%s', $url));
|
$this->query->where('journal_meta.data', 'NOT LIKE', sprintf('%%%s', $url));
|
||||||
@ -309,7 +309,7 @@ trait MetaCollection
|
|||||||
public function externalUrlDoesNotStart(string $url): GroupCollectorInterface
|
public function externalUrlDoesNotStart(string $url): GroupCollectorInterface
|
||||||
{
|
{
|
||||||
$this->joinMetaDataTables();
|
$this->joinMetaDataTables();
|
||||||
$url = (string) json_encode($url);
|
$url = (string)json_encode($url);
|
||||||
$url = str_replace('\\', '\\\\', rtrim($url, '"'));
|
$url = str_replace('\\', '\\\\', rtrim($url, '"'));
|
||||||
// var_dump($url);
|
// var_dump($url);
|
||||||
|
|
||||||
@ -322,7 +322,7 @@ trait MetaCollection
|
|||||||
public function externalUrlEnds(string $url): GroupCollectorInterface
|
public function externalUrlEnds(string $url): GroupCollectorInterface
|
||||||
{
|
{
|
||||||
$this->joinMetaDataTables();
|
$this->joinMetaDataTables();
|
||||||
$url = (string) json_encode($url);
|
$url = (string)json_encode($url);
|
||||||
$url = str_replace('\\', '\\\\', ltrim($url, '"'));
|
$url = str_replace('\\', '\\\\', ltrim($url, '"'));
|
||||||
$this->query->where('journal_meta.name', '=', 'external_url');
|
$this->query->where('journal_meta.name', '=', 'external_url');
|
||||||
$this->query->where('journal_meta.data', 'LIKE', sprintf('%%%s', $url));
|
$this->query->where('journal_meta.data', 'LIKE', sprintf('%%%s', $url));
|
||||||
@ -333,7 +333,7 @@ trait MetaCollection
|
|||||||
public function externalUrlStarts(string $url): GroupCollectorInterface
|
public function externalUrlStarts(string $url): GroupCollectorInterface
|
||||||
{
|
{
|
||||||
$this->joinMetaDataTables();
|
$this->joinMetaDataTables();
|
||||||
$url = (string) json_encode($url);
|
$url = (string)json_encode($url);
|
||||||
$url = str_replace('\\', '\\\\', rtrim($url, '"'));
|
$url = str_replace('\\', '\\\\', rtrim($url, '"'));
|
||||||
// var_dump($url);
|
// var_dump($url);
|
||||||
|
|
||||||
@ -371,7 +371,7 @@ trait MetaCollection
|
|||||||
|
|
||||||
public function internalReferenceContains(string $internalReference): GroupCollectorInterface
|
public function internalReferenceContains(string $internalReference): GroupCollectorInterface
|
||||||
{
|
{
|
||||||
$internalReference = (string) json_encode($internalReference);
|
$internalReference = (string)json_encode($internalReference);
|
||||||
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
||||||
// var_dump($internalReference);
|
// var_dump($internalReference);
|
||||||
// exit;
|
// exit;
|
||||||
@ -385,7 +385,7 @@ trait MetaCollection
|
|||||||
|
|
||||||
public function internalReferenceDoesNotContain(string $internalReference): GroupCollectorInterface
|
public function internalReferenceDoesNotContain(string $internalReference): GroupCollectorInterface
|
||||||
{
|
{
|
||||||
$internalReference = (string) json_encode($internalReference);
|
$internalReference = (string)json_encode($internalReference);
|
||||||
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
||||||
|
|
||||||
$this->joinMetaDataTables();
|
$this->joinMetaDataTables();
|
||||||
@ -397,7 +397,7 @@ trait MetaCollection
|
|||||||
|
|
||||||
public function internalReferenceDoesNotEnd(string $internalReference): GroupCollectorInterface
|
public function internalReferenceDoesNotEnd(string $internalReference): GroupCollectorInterface
|
||||||
{
|
{
|
||||||
$internalReference = (string) json_encode($internalReference);
|
$internalReference = (string)json_encode($internalReference);
|
||||||
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
||||||
|
|
||||||
$this->joinMetaDataTables();
|
$this->joinMetaDataTables();
|
||||||
@ -409,7 +409,7 @@ trait MetaCollection
|
|||||||
|
|
||||||
public function internalReferenceDoesNotStart(string $internalReference): GroupCollectorInterface
|
public function internalReferenceDoesNotStart(string $internalReference): GroupCollectorInterface
|
||||||
{
|
{
|
||||||
$internalReference = (string) json_encode($internalReference);
|
$internalReference = (string)json_encode($internalReference);
|
||||||
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
||||||
|
|
||||||
$this->joinMetaDataTables();
|
$this->joinMetaDataTables();
|
||||||
@ -421,7 +421,7 @@ trait MetaCollection
|
|||||||
|
|
||||||
public function internalReferenceEnds(string $internalReference): GroupCollectorInterface
|
public function internalReferenceEnds(string $internalReference): GroupCollectorInterface
|
||||||
{
|
{
|
||||||
$internalReference = (string) json_encode($internalReference);
|
$internalReference = (string)json_encode($internalReference);
|
||||||
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
||||||
|
|
||||||
$this->joinMetaDataTables();
|
$this->joinMetaDataTables();
|
||||||
@ -433,7 +433,7 @@ trait MetaCollection
|
|||||||
|
|
||||||
public function internalReferenceStarts(string $internalReference): GroupCollectorInterface
|
public function internalReferenceStarts(string $internalReference): GroupCollectorInterface
|
||||||
{
|
{
|
||||||
$internalReference = (string) json_encode($internalReference);
|
$internalReference = (string)json_encode($internalReference);
|
||||||
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
||||||
|
|
||||||
$this->joinMetaDataTables();
|
$this->joinMetaDataTables();
|
||||||
@ -629,7 +629,7 @@ trait MetaCollection
|
|||||||
|
|
||||||
public function setInternalReference(string $internalReference): GroupCollectorInterface
|
public function setInternalReference(string $internalReference): GroupCollectorInterface
|
||||||
{
|
{
|
||||||
$internalReference = (string) json_encode($internalReference);
|
$internalReference = (string)json_encode($internalReference);
|
||||||
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
||||||
|
|
||||||
$this->joinMetaDataTables();
|
$this->joinMetaDataTables();
|
||||||
@ -682,6 +682,7 @@ trait MetaCollection
|
|||||||
$list = $tags->pluck('tag')->toArray();
|
$list = $tags->pluck('tag')->toArray();
|
||||||
$list = array_map('strtolower', $list);
|
$list = array_map('strtolower', $list);
|
||||||
$filter = static function (array $object) use ($list): bool|array {
|
$filter = static function (array $object) use ($list): bool|array {
|
||||||
|
$includedJournals = [];
|
||||||
$return = $object;
|
$return = $object;
|
||||||
unset($return['transactions']);
|
unset($return['transactions']);
|
||||||
$return['transactions'] = [];
|
$return['transactions'] = [];
|
||||||
@ -701,10 +702,15 @@ trait MetaCollection
|
|||||||
if (in_array(strtolower($tag['name']), $list, true)) {
|
if (in_array(strtolower($tag['name']), $list, true)) {
|
||||||
app('log')->debug(sprintf('Transaction has tag "%s" so count++.', $tag['name']));
|
app('log')->debug(sprintf('Transaction has tag "%s" so count++.', $tag['name']));
|
||||||
++$foundTagCount;
|
++$foundTagCount;
|
||||||
|
$journalId = $transaction['transaction_journal_id'];
|
||||||
|
// #8377 prevent adding a transaction twice when multiple tag searches find this transaction
|
||||||
|
if (!in_array($journalId, $includedJournals, true)) {
|
||||||
|
$includedJournals[] = $journalId;
|
||||||
$return['transactions'][] = $transaction;
|
$return['transactions'][] = $transaction;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Log::debug(sprintf('Found %d tags, need at least %d.', $foundTagCount, $expectedTagCount));
|
Log::debug(sprintf('Found %d tags, need at least %d.', $foundTagCount, $expectedTagCount));
|
||||||
|
|
||||||
// found at least the expected tags.
|
// found at least the expected tags.
|
||||||
|
@ -286,7 +286,7 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
foreach ($params as $param) {
|
foreach ($params as $param) {
|
||||||
$replace = sprintf('"%s"', $param);
|
$replace = sprintf('"%s"', $param);
|
||||||
if (is_int($param)) {
|
if (is_int($param)) {
|
||||||
$replace = (string) $param;
|
$replace = (string)$param;
|
||||||
}
|
}
|
||||||
$pos = strpos($query, '?');
|
$pos = strpos($query, '?');
|
||||||
if (false !== $pos) {
|
if (false !== $pos) {
|
||||||
@ -692,13 +692,13 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
|
|
||||||
/** @var TransactionJournal $augumentedJournal */
|
/** @var TransactionJournal $augumentedJournal */
|
||||||
foreach ($collection as $augumentedJournal) {
|
foreach ($collection as $augumentedJournal) {
|
||||||
$groupId = (int) $augumentedJournal->transaction_group_id;
|
$groupId = (int)$augumentedJournal->transaction_group_id;
|
||||||
|
|
||||||
if (!array_key_exists($groupId, $groups)) {
|
if (!array_key_exists($groupId, $groups)) {
|
||||||
// make new array
|
// make new array
|
||||||
$parsedGroup = $this->parseAugmentedJournal($augumentedJournal);
|
$parsedGroup = $this->parseAugmentedJournal($augumentedJournal);
|
||||||
$groupArray = [
|
$groupArray = [
|
||||||
'id' => (int) $augumentedJournal->transaction_group_id,
|
'id' => (int)$augumentedJournal->transaction_group_id,
|
||||||
'user_id' => $augumentedJournal->user_id,
|
'user_id' => $augumentedJournal->user_id,
|
||||||
'user_group_id' => $augumentedJournal->user_group_id,
|
'user_group_id' => $augumentedJournal->user_group_id,
|
||||||
// Field transaction_group_title was added by the query.
|
// Field transaction_group_title was added by the query.
|
||||||
@ -711,7 +711,7 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
'transactions' => [],
|
'transactions' => [],
|
||||||
];
|
];
|
||||||
// Field transaction_journal_id was added by the query.
|
// 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;
|
$groupArray['transactions'][$journalId] = $parsedGroup;
|
||||||
$groups[$groupId] = $groupArray;
|
$groups[$groupId] = $groupArray;
|
||||||
|
|
||||||
@ -719,7 +719,7 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
}
|
}
|
||||||
// or parse the rest.
|
// or parse the rest.
|
||||||
// Field transaction_journal_id was added by the query.
|
// 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'])) {
|
if (array_key_exists($journalId, $groups[$groupId]['transactions'])) {
|
||||||
// append data to existing group + journal (for multiple tags or multiple attachments)
|
// append data to existing group + journal (for multiple tags or multiple attachments)
|
||||||
$groups[$groupId]['transactions'][$journalId] = $this->mergeTags($groups[$groupId]['transactions'][$journalId], $augumentedJournal);
|
$groups[$groupId]['transactions'][$journalId] = $this->mergeTags($groups[$groupId]['transactions'][$journalId], $augumentedJournal);
|
||||||
@ -772,7 +772,7 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
$dates = ['interest_date', 'payment_date', 'invoice_date', 'book_date', 'due_date', 'process_date'];
|
$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)) {
|
if (array_key_exists('meta_name', $result) && in_array($result['meta_name'], $dates, true)) {
|
||||||
$name = $result['meta_name'];
|
$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));
|
$result[$name] = Carbon::createFromFormat('!Y-m-d', substr(json_decode($result['meta_data']), 0, 10));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -783,9 +783,9 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
// convert back to strings because SQLite is dumb like that.
|
// convert back to strings because SQLite is dumb like that.
|
||||||
$result = $this->convertToStrings($result);
|
$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.
|
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;
|
$tagDate = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -795,7 +795,7 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$result['tags'][$tagId] = [
|
$result['tags'][$tagId] = [
|
||||||
'id' => (int) $result['tag_id'],
|
'id' => (int)$result['tag_id'],
|
||||||
'name' => $result['tag_name'],
|
'name' => $result['tag_name'],
|
||||||
'date' => $tagDate,
|
'date' => $tagDate,
|
||||||
'description' => $result['tag_description'],
|
'description' => $result['tag_description'],
|
||||||
@ -804,8 +804,8 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
|
|
||||||
// also merge attachments:
|
// also merge attachments:
|
||||||
if (array_key_exists('attachment_id', $result)) {
|
if (array_key_exists('attachment_id', $result)) {
|
||||||
$uploaded = 1 === (int) $result['attachment_uploaded'];
|
$uploaded = 1 === (int)$result['attachment_uploaded'];
|
||||||
$attachmentId = (int) $augumentedJournal['attachment_id'];
|
$attachmentId = (int)$augumentedJournal['attachment_id'];
|
||||||
if (0 !== $attachmentId && $uploaded) {
|
if (0 !== $attachmentId && $uploaded) {
|
||||||
$result['attachments'][$attachmentId] = [
|
$result['attachments'][$attachmentId] = [
|
||||||
'id' => $attachmentId,
|
'id' => $attachmentId,
|
||||||
@ -831,7 +831,7 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
private function convertToInteger(array $array): array
|
private function convertToInteger(array $array): array
|
||||||
{
|
{
|
||||||
foreach ($this->integerFields as $field) {
|
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;
|
return $array;
|
||||||
@ -840,7 +840,7 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
private function convertToStrings(array $array): array
|
private function convertToStrings(array $array): array
|
||||||
{
|
{
|
||||||
foreach ($this->stringFields as $field) {
|
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;
|
return $array;
|
||||||
@ -850,7 +850,7 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
{
|
{
|
||||||
$newArray = $newJournal->toArray();
|
$newArray = $newJournal->toArray();
|
||||||
if (array_key_exists('tag_id', $newArray)) { // assume the other fields are present as well.
|
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;
|
$tagDate = null;
|
||||||
|
|
||||||
@ -861,7 +861,7 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$existingJournal['tags'][$tagId] = [
|
$existingJournal['tags'][$tagId] = [
|
||||||
'id' => (int) $newArray['tag_id'],
|
'id' => (int)$newArray['tag_id'],
|
||||||
'name' => $newArray['tag_name'],
|
'name' => $newArray['tag_name'],
|
||||||
'date' => $tagDate,
|
'date' => $tagDate,
|
||||||
'description' => $newArray['tag_description'],
|
'description' => $newArray['tag_description'],
|
||||||
@ -875,7 +875,7 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
{
|
{
|
||||||
$newArray = $newJournal->toArray();
|
$newArray = $newJournal->toArray();
|
||||||
if (array_key_exists('attachment_id', $newArray)) {
|
if (array_key_exists('attachment_id', $newArray)) {
|
||||||
$attachmentId = (int) $newJournal['attachment_id'];
|
$attachmentId = (int)$newJournal['attachment_id'];
|
||||||
|
|
||||||
$existingJournal['attachments'][$attachmentId] = [
|
$existingJournal['attachments'][$attachmentId] = [
|
||||||
'id' => $attachmentId,
|
'id' => $attachmentId,
|
||||||
@ -894,7 +894,7 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
foreach ($groups as $groudId => $group) {
|
foreach ($groups as $groudId => $group) {
|
||||||
/** @var array $transaction */
|
/** @var array $transaction */
|
||||||
foreach ($group['transactions'] as $transaction) {
|
foreach ($group['transactions'] as $transaction) {
|
||||||
$currencyId = (int) $transaction['currency_id'];
|
$currencyId = (int)$transaction['currency_id'];
|
||||||
if (null === $transaction['amount']) {
|
if (null === $transaction['amount']) {
|
||||||
throw new FireflyException(sprintf('Amount is NULL for a transaction in group #%d, please investigate.', $groudId));
|
throw new FireflyException(sprintf('Amount is NULL for a transaction in group #%d, please investigate.', $groudId));
|
||||||
}
|
}
|
||||||
@ -910,7 +910,7 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
$groups[$groudId]['sums'][$currencyId]['amount'] = bcadd($groups[$groudId]['sums'][$currencyId]['amount'], $transaction['amount']);
|
$groups[$groudId]['sums'][$currencyId]['amount'] = bcadd($groups[$groudId]['sums'][$currencyId]['amount'], $transaction['amount']);
|
||||||
|
|
||||||
if (null !== $transaction['foreign_amount'] && null !== $transaction['foreign_currency_id']) {
|
if (null !== $transaction['foreign_amount'] && null !== $transaction['foreign_currency_id']) {
|
||||||
$currencyId = (int) $transaction['foreign_currency_id'];
|
$currencyId = (int)$transaction['foreign_currency_id'];
|
||||||
|
|
||||||
// set default:
|
// set default:
|
||||||
if (!array_key_exists($currencyId, $groups[$groudId]['sums'])) {
|
if (!array_key_exists($currencyId, $groups[$groudId]['sums'])) {
|
||||||
@ -931,7 +931,6 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
private function postFilterCollection(Collection $collection): Collection
|
private function postFilterCollection(Collection $collection): Collection
|
||||||
{
|
{
|
||||||
$currentCollection = $collection;
|
$currentCollection = $collection;
|
||||||
|
|
||||||
app('log')->debug(sprintf('GroupCollector: postFilterCollection has %d filter(s) and %d transaction(s).', count($this->postFilters), count($currentCollection)));
|
app('log')->debug(sprintf('GroupCollector: postFilterCollection has %d filter(s) and %d transaction(s).', count($this->postFilters), count($currentCollection)));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1055,7 +1054,6 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
->orderBy('transaction_journals.order', 'ASC')
|
->orderBy('transaction_journals.order', 'ASC')
|
||||||
->orderBy('transaction_journals.id', 'DESC')
|
->orderBy('transaction_journals.id', 'DESC')
|
||||||
->orderBy('transaction_journals.description', 'DESC')
|
->orderBy('transaction_journals.description', 'DESC')
|
||||||
->orderBy('source.amount', 'DESC')
|
->orderBy('source.amount', 'DESC');
|
||||||
;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user