mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Fix various code.
This commit is contained in:
@@ -36,6 +36,8 @@ use Illuminate\Database\Query\JoinClause;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use function Safe\json_encode;
|
||||
|
||||
/**
|
||||
* Trait MetaCollection
|
||||
*/
|
||||
@@ -167,7 +169,7 @@ trait MetaCollection
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'external_id');
|
||||
$this->query->where('journal_meta.data', '!=', sprintf('%s', \Safe\json_encode($externalId)));
|
||||
$this->query->where('journal_meta.data', '!=', sprintf('%s', json_encode($externalId)));
|
||||
$this->query->whereNull('journal_meta.deleted_at');
|
||||
|
||||
return $this;
|
||||
@@ -190,14 +192,14 @@ trait MetaCollection
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'external_url');
|
||||
$this->query->where('journal_meta.data', '!=', \Safe\json_encode($url));
|
||||
$this->query->where('journal_meta.data', '!=', json_encode($url));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function excludeInternalReference(string $internalReference): GroupCollectorInterface
|
||||
{
|
||||
$internalReference = (string) \Safe\json_encode($internalReference);
|
||||
$internalReference = (string) json_encode($internalReference);
|
||||
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
@@ -211,14 +213,14 @@ trait MetaCollection
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'recurrence_id');
|
||||
$this->query->where('journal_meta.data', '!=', sprintf('%s', \Safe\json_encode($recurringId)));
|
||||
$this->query->where('journal_meta.data', '!=', sprintf('%s', json_encode($recurringId)));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function externalIdContains(string $externalId): GroupCollectorInterface
|
||||
{
|
||||
$externalId = (string) \Safe\json_encode($externalId);
|
||||
$externalId = (string) json_encode($externalId);
|
||||
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
@@ -230,7 +232,7 @@ trait MetaCollection
|
||||
|
||||
public function externalIdDoesNotContain(string $externalId): GroupCollectorInterface
|
||||
{
|
||||
$externalId = (string) \Safe\json_encode($externalId);
|
||||
$externalId = (string) json_encode($externalId);
|
||||
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
@@ -242,7 +244,7 @@ trait MetaCollection
|
||||
|
||||
public function externalIdDoesNotEnd(string $externalId): GroupCollectorInterface
|
||||
{
|
||||
$externalId = (string) \Safe\json_encode($externalId);
|
||||
$externalId = (string) json_encode($externalId);
|
||||
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
@@ -254,7 +256,7 @@ trait MetaCollection
|
||||
|
||||
public function externalIdDoesNotStart(string $externalId): GroupCollectorInterface
|
||||
{
|
||||
$externalId = (string) \Safe\json_encode($externalId);
|
||||
$externalId = (string) json_encode($externalId);
|
||||
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
@@ -266,7 +268,7 @@ trait MetaCollection
|
||||
|
||||
public function externalIdEnds(string $externalId): GroupCollectorInterface
|
||||
{
|
||||
$externalId = (string) \Safe\json_encode($externalId);
|
||||
$externalId = (string) json_encode($externalId);
|
||||
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
@@ -278,7 +280,7 @@ trait MetaCollection
|
||||
|
||||
public function externalIdStarts(string $externalId): GroupCollectorInterface
|
||||
{
|
||||
$externalId = (string) \Safe\json_encode($externalId);
|
||||
$externalId = (string) json_encode($externalId);
|
||||
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
@@ -291,7 +293,7 @@ trait MetaCollection
|
||||
public function externalUrlContains(string $url): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$url = (string) \Safe\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));
|
||||
@@ -302,7 +304,7 @@ trait MetaCollection
|
||||
public function externalUrlDoesNotContain(string $url): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$url = (string) \Safe\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));
|
||||
@@ -313,7 +315,7 @@ trait MetaCollection
|
||||
public function externalUrlDoesNotEnd(string $url): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$url = (string) \Safe\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));
|
||||
@@ -324,7 +326,7 @@ trait MetaCollection
|
||||
public function externalUrlDoesNotStart(string $url): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$url = (string) \Safe\json_encode($url);
|
||||
$url = (string) json_encode($url);
|
||||
$url = str_replace('\\', '\\\\', rtrim($url, '"'));
|
||||
// var_dump($url);
|
||||
|
||||
@@ -337,7 +339,7 @@ trait MetaCollection
|
||||
public function externalUrlEnds(string $url): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$url = (string) \Safe\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));
|
||||
@@ -348,7 +350,7 @@ trait MetaCollection
|
||||
public function externalUrlStarts(string $url): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$url = (string) \Safe\json_encode($url);
|
||||
$url = (string) json_encode($url);
|
||||
$url = str_replace('\\', '\\\\', rtrim($url, '"'));
|
||||
// var_dump($url);
|
||||
|
||||
@@ -399,7 +401,7 @@ trait MetaCollection
|
||||
|
||||
public function internalReferenceContains(string $internalReference): GroupCollectorInterface
|
||||
{
|
||||
$internalReference = (string) \Safe\json_encode($internalReference);
|
||||
$internalReference = (string) json_encode($internalReference);
|
||||
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
||||
// var_dump($internalReference);
|
||||
// exit;
|
||||
@@ -414,7 +416,7 @@ trait MetaCollection
|
||||
|
||||
public function internalReferenceDoesNotContain(string $internalReference): GroupCollectorInterface
|
||||
{
|
||||
$internalReference = (string) \Safe\json_encode($internalReference);
|
||||
$internalReference = (string) json_encode($internalReference);
|
||||
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
@@ -427,7 +429,7 @@ trait MetaCollection
|
||||
|
||||
public function internalReferenceDoesNotEnd(string $internalReference): GroupCollectorInterface
|
||||
{
|
||||
$internalReference = (string) \Safe\json_encode($internalReference);
|
||||
$internalReference = (string) json_encode($internalReference);
|
||||
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
@@ -440,7 +442,7 @@ trait MetaCollection
|
||||
|
||||
public function internalReferenceDoesNotStart(string $internalReference): GroupCollectorInterface
|
||||
{
|
||||
$internalReference = (string) \Safe\json_encode($internalReference);
|
||||
$internalReference = (string) json_encode($internalReference);
|
||||
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
@@ -453,7 +455,7 @@ trait MetaCollection
|
||||
|
||||
public function internalReferenceEnds(string $internalReference): GroupCollectorInterface
|
||||
{
|
||||
$internalReference = (string) \Safe\json_encode($internalReference);
|
||||
$internalReference = (string) json_encode($internalReference);
|
||||
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
@@ -466,7 +468,7 @@ trait MetaCollection
|
||||
|
||||
public function internalReferenceStarts(string $internalReference): GroupCollectorInterface
|
||||
{
|
||||
$internalReference = (string) \Safe\json_encode($internalReference);
|
||||
$internalReference = (string) json_encode($internalReference);
|
||||
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
@@ -704,7 +706,7 @@ trait MetaCollection
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'external_id');
|
||||
$this->query->where('journal_meta.data', '=', sprintf('%s', \Safe\json_encode($externalId)));
|
||||
$this->query->where('journal_meta.data', '=', sprintf('%s', json_encode($externalId)));
|
||||
$this->query->whereNull('journal_meta.deleted_at');
|
||||
|
||||
return $this;
|
||||
@@ -714,7 +716,7 @@ trait MetaCollection
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'external_url');
|
||||
$this->query->where('journal_meta.data', '=', \Safe\json_encode($url));
|
||||
$this->query->where('journal_meta.data', '=', json_encode($url));
|
||||
$this->query->whereNull('journal_meta.deleted_at');
|
||||
|
||||
return $this;
|
||||
@@ -722,12 +724,12 @@ trait MetaCollection
|
||||
|
||||
public function setInternalReference(string $internalReference): GroupCollectorInterface
|
||||
{
|
||||
$internalReference = (string) \Safe\json_encode($internalReference);
|
||||
$internalReference = (string) json_encode($internalReference);
|
||||
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'internal_reference');
|
||||
$this->query->where('journal_meta.data', '=', sprintf('%s', \Safe\json_encode($internalReference)));
|
||||
$this->query->where('journal_meta.data', '=', sprintf('%s', json_encode($internalReference)));
|
||||
$this->query->whereNull('journal_meta.deleted_at');
|
||||
|
||||
return $this;
|
||||
@@ -737,7 +739,7 @@ trait MetaCollection
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'recurrence_id');
|
||||
$this->query->where('journal_meta.data', '=', sprintf('%s', \Safe\json_encode($recurringId)));
|
||||
$this->query->where('journal_meta.data', '=', sprintf('%s', json_encode($recurringId)));
|
||||
$this->query->whereNull('journal_meta.deleted_at');
|
||||
|
||||
return $this;
|
||||
@@ -747,7 +749,7 @@ trait MetaCollection
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'sepa_ct_id');
|
||||
$this->query->where('journal_meta.data', '=', sprintf('%s', \Safe\json_encode($sepaCT)));
|
||||
$this->query->where('journal_meta.data', '=', sprintf('%s', json_encode($sepaCT)));
|
||||
$this->query->whereNull('journal_meta.deleted_at');
|
||||
|
||||
return $this;
|
||||
|
@@ -73,7 +73,11 @@ trait TimeCollection
|
||||
$filter = static function (array $object) use ($field, $start, $end): bool {
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon) {
|
||||
return $transaction[$field]->lt($start) || $transaction[$field]->gt($end);
|
||||
if ($transaction[$field]->lt($start)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $transaction[$field]->gt($end);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -589,17 +593,17 @@ trait TimeCollection
|
||||
*/
|
||||
public function setRange(?Carbon $start, ?Carbon $end): GroupCollectorInterface
|
||||
{
|
||||
if (null !== $start && null !== $end && $end < $start) {
|
||||
if ($start instanceof Carbon && $end instanceof Carbon && $end < $start) {
|
||||
[$start, $end] = [$end, $start];
|
||||
}
|
||||
// always got to end of day / start of day for ranges.
|
||||
$startStr = $start?->format('Y-m-d 00:00:00');
|
||||
$endStr = $end?->format('Y-m-d 23:59:59');
|
||||
|
||||
if (null !== $start) {
|
||||
if ($start instanceof Carbon) {
|
||||
$this->query->where('transaction_journals.date', '>=', $startStr);
|
||||
}
|
||||
if (null !== $end) {
|
||||
if ($end instanceof Carbon) {
|
||||
$this->query->where('transaction_journals.date', '<=', $endStr);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user