mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Various PSR12 code cleanup
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* AttachmentHelper.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -57,8 +58,8 @@ class AttachmentHelper implements AttachmentHelperInterface
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->maxUploadSize = (int) config('firefly.maxUploadSize');
|
||||
$this->allowedMimes = (array) config('firefly.allowedMimes');
|
||||
$this->maxUploadSize = (int)config('firefly.maxUploadSize');
|
||||
$this->allowedMimes = (array)config('firefly.allowedMimes');
|
||||
$this->errors = new MessageBag();
|
||||
$this->messages = new MessageBag();
|
||||
$this->attachments = new Collection();
|
||||
@@ -70,13 +71,13 @@ class AttachmentHelper implements AttachmentHelperInterface
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @param Attachment $attachment
|
||||
* @param Attachment $attachment
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAttachmentContent(Attachment $attachment): string
|
||||
{
|
||||
$encryptedData = (string) $this->uploadDisk->get(sprintf('at-%d.data', $attachment->id));
|
||||
$encryptedData = (string)$this->uploadDisk->get(sprintf('at-%d.data', $attachment->id));
|
||||
try {
|
||||
$unencryptedData = Crypt::decrypt($encryptedData); // verified
|
||||
} catch (DecryptException $e) {
|
||||
@@ -90,14 +91,14 @@ class AttachmentHelper implements AttachmentHelperInterface
|
||||
/**
|
||||
* Returns the file path relative to upload disk for an attachment,
|
||||
*
|
||||
* @param Attachment $attachment
|
||||
* @param Attachment $attachment
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @return string
|
||||
*/
|
||||
public function getAttachmentLocation(Attachment $attachment): string
|
||||
{
|
||||
return sprintf('%sat-%d.data', DIRECTORY_SEPARATOR, (int) $attachment->id);
|
||||
return sprintf('%sat-%d.data', DIRECTORY_SEPARATOR, (int)$attachment->id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,8 +137,8 @@ class AttachmentHelper implements AttachmentHelperInterface
|
||||
/**
|
||||
* Uploads a file as a string.
|
||||
*
|
||||
* @param Attachment $attachment
|
||||
* @param string $content
|
||||
* @param Attachment $attachment
|
||||
* @param string $content
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@@ -185,8 +186,8 @@ class AttachmentHelper implements AttachmentHelperInterface
|
||||
/**
|
||||
* Save attachments that get uploaded with models, through the app.
|
||||
*
|
||||
* @param object $model
|
||||
* @param array|null $files
|
||||
* @param object $model
|
||||
* @param array|null $files
|
||||
*
|
||||
* @return bool
|
||||
* @throws FireflyException
|
||||
@@ -218,8 +219,8 @@ class AttachmentHelper implements AttachmentHelperInterface
|
||||
/**
|
||||
* Process the upload of a file.
|
||||
*
|
||||
* @param UploadedFile $file
|
||||
* @param Model $model
|
||||
* @param UploadedFile $file
|
||||
* @param Model $model
|
||||
*
|
||||
* @return Attachment|null
|
||||
* @throws FireflyException
|
||||
@@ -265,7 +266,7 @@ class AttachmentHelper implements AttachmentHelperInterface
|
||||
$this->attachments->push($attachment);
|
||||
|
||||
$name = e($file->getClientOriginalName()); // add message:
|
||||
$msg = (string) trans('validation.file_attached', ['name' => $name]);
|
||||
$msg = (string)trans('validation.file_attached', ['name' => $name]);
|
||||
$this->messages->add('attachments', $msg);
|
||||
}
|
||||
|
||||
@@ -275,8 +276,8 @@ class AttachmentHelper implements AttachmentHelperInterface
|
||||
/**
|
||||
* Verify if the file was uploaded correctly.
|
||||
*
|
||||
* @param UploadedFile $file
|
||||
* @param Model $model
|
||||
* @param UploadedFile $file
|
||||
* @param Model $model
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@@ -308,7 +309,7 @@ class AttachmentHelper implements AttachmentHelperInterface
|
||||
/**
|
||||
* Verify if the mime of a file is valid.
|
||||
*
|
||||
* @param UploadedFile $file
|
||||
* @param UploadedFile $file
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@@ -322,7 +323,7 @@ class AttachmentHelper implements AttachmentHelperInterface
|
||||
$result = true;
|
||||
|
||||
if (!in_array($mime, $this->allowedMimes, true)) {
|
||||
$msg = (string) trans('validation.file_invalid_mime', ['name' => $name, 'mime' => $mime]);
|
||||
$msg = (string)trans('validation.file_invalid_mime', ['name' => $name, 'mime' => $mime]);
|
||||
$this->errors->add('attachments', $msg);
|
||||
Log::error($msg);
|
||||
|
||||
@@ -337,7 +338,7 @@ class AttachmentHelper implements AttachmentHelperInterface
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @param UploadedFile $file
|
||||
* @param UploadedFile $file
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@@ -347,7 +348,7 @@ class AttachmentHelper implements AttachmentHelperInterface
|
||||
$name = e($file->getClientOriginalName());
|
||||
$result = true;
|
||||
if ($size > $this->maxUploadSize) {
|
||||
$msg = (string) trans('validation.file_too_large', ['name' => $name]);
|
||||
$msg = (string)trans('validation.file_too_large', ['name' => $name]);
|
||||
$this->errors->add('attachments', $msg);
|
||||
Log::error($msg);
|
||||
|
||||
@@ -360,8 +361,8 @@ class AttachmentHelper implements AttachmentHelperInterface
|
||||
/**
|
||||
* Check if a model already has this file attached.
|
||||
*
|
||||
* @param UploadedFile $file
|
||||
* @param Model $model
|
||||
* @param UploadedFile $file
|
||||
* @param Model $model
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@@ -379,7 +380,7 @@ class AttachmentHelper implements AttachmentHelperInterface
|
||||
}
|
||||
$result = false;
|
||||
if ($count > 0) {
|
||||
$msg = (string) trans('validation.file_already_attached', ['name' => $name]);
|
||||
$msg = (string)trans('validation.file_already_attached', ['name' => $name]);
|
||||
$this->errors->add('attachments', $msg);
|
||||
Log::error($msg);
|
||||
$result = true;
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* AttachmentHelperInterface.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -34,7 +35,7 @@ interface AttachmentHelperInterface
|
||||
/**
|
||||
* Get content of an attachment.
|
||||
*
|
||||
* @param Attachment $attachment
|
||||
* @param Attachment $attachment
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -43,7 +44,7 @@ interface AttachmentHelperInterface
|
||||
/**
|
||||
* Get the location of an attachment.
|
||||
*
|
||||
* @param Attachment $attachment
|
||||
* @param Attachment $attachment
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -73,8 +74,8 @@ interface AttachmentHelperInterface
|
||||
/**
|
||||
* Uploads a file as a string.
|
||||
*
|
||||
* @param Attachment $attachment
|
||||
* @param string $content
|
||||
* @param Attachment $attachment
|
||||
* @param string $content
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@@ -83,8 +84,8 @@ interface AttachmentHelperInterface
|
||||
/**
|
||||
* Save attachments that got uploaded.
|
||||
*
|
||||
* @param object $model
|
||||
* @param null|array $files
|
||||
* @param object $model
|
||||
* @param null|array $files
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
|
@@ -36,7 +36,7 @@ trait AccountCollection
|
||||
/**
|
||||
* These accounts must not be included.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -56,7 +56,7 @@ trait AccountCollection
|
||||
/**
|
||||
* These accounts must not be destination accounts.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -75,7 +75,7 @@ trait AccountCollection
|
||||
/**
|
||||
* These accounts must not be source accounts.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -94,7 +94,7 @@ trait AccountCollection
|
||||
/**
|
||||
* Define which accounts can be part of the source and destination transactions.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -117,7 +117,7 @@ trait AccountCollection
|
||||
/**
|
||||
* Both source AND destination must be in this list of accounts.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -140,7 +140,7 @@ trait AccountCollection
|
||||
/**
|
||||
* Define which accounts can be part of the source and destination transactions.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -159,7 +159,7 @@ trait AccountCollection
|
||||
/**
|
||||
* Define which accounts can NOT be part of the source and destination transactions.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -182,7 +182,7 @@ trait AccountCollection
|
||||
/**
|
||||
* Define which accounts can be part of the source and destination transactions.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -201,7 +201,7 @@ trait AccountCollection
|
||||
/**
|
||||
* Either account can be set, but NOT both. This effectively excludes internal transfers.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
|
@@ -35,7 +35,7 @@ trait AmountCollection
|
||||
/**
|
||||
* Get transactions with a specific amount.
|
||||
*
|
||||
* @param string $amount
|
||||
* @param string $amount
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -67,7 +67,7 @@ trait AmountCollection
|
||||
/**
|
||||
* Get transactions where the amount is less than.
|
||||
*
|
||||
* @param string $amount
|
||||
* @param string $amount
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -85,7 +85,7 @@ trait AmountCollection
|
||||
/**
|
||||
* Get transactions where the amount is more than.
|
||||
*
|
||||
* @param string $amount
|
||||
* @param string $amount
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -103,7 +103,7 @@ trait AmountCollection
|
||||
/**
|
||||
* Get transactions with a specific foreign amount.
|
||||
*
|
||||
* @param string $amount
|
||||
* @param string $amount
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -122,7 +122,7 @@ trait AmountCollection
|
||||
/**
|
||||
* Get transactions with a specific foreign amount.
|
||||
*
|
||||
* @param string $amount
|
||||
* @param string $amount
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -141,7 +141,7 @@ trait AmountCollection
|
||||
/**
|
||||
* Get transactions where the amount is less than.
|
||||
*
|
||||
* @param string $amount
|
||||
* @param string $amount
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -160,7 +160,7 @@ trait AmountCollection
|
||||
/**
|
||||
* Get transactions where the amount is more than.
|
||||
*
|
||||
* @param string $amount
|
||||
* @param string $amount
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
|
@@ -37,7 +37,7 @@ use Log;
|
||||
trait AttachmentCollection
|
||||
{
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string $name
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function attachmentNameContains(string $name): GroupCollectorInterface
|
||||
@@ -49,33 +49,10 @@ trait AttachmentCollection
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
/** @var array $attachment */
|
||||
foreach ($transaction['attachments'] as $attachment) {
|
||||
$result = str_contains(strtolower($attachment['filename']), strtolower($name)) || str_contains(strtolower($attachment['title']), strtolower($name));
|
||||
if (true === $result) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
$this->postFilters[] = $filter;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function attachmentNameDoesNotContain(string $name): GroupCollectorInterface
|
||||
{
|
||||
$this->hasAttachments();
|
||||
$this->withAttachmentInformation();
|
||||
$filter = function (int $index, array $object) use ($name): bool {
|
||||
/** @var array $transaction */
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
/** @var array $attachment */
|
||||
foreach ($transaction['attachments'] as $attachment) {
|
||||
$result = !str_contains(strtolower($attachment['filename']), strtolower($name)) && !str_contains(strtolower($attachment['title']), strtolower($name));
|
||||
$result = str_contains(strtolower($attachment['filename']), strtolower($name)) || str_contains(
|
||||
strtolower($attachment['title']),
|
||||
strtolower($name)
|
||||
);
|
||||
if (true === $result) {
|
||||
return true;
|
||||
}
|
||||
@@ -137,10 +114,10 @@ trait AttachmentCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string $name
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function attachmentNameEnds(string $name): GroupCollectorInterface
|
||||
public function attachmentNameDoesNotContain(string $name): GroupCollectorInterface
|
||||
{
|
||||
$this->hasAttachments();
|
||||
$this->withAttachmentInformation();
|
||||
@@ -149,7 +126,10 @@ trait AttachmentCollection
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
/** @var array $attachment */
|
||||
foreach ($transaction['attachments'] as $attachment) {
|
||||
$result = str_ends_with(strtolower($attachment['filename']), strtolower($name)) || str_ends_with(strtolower($attachment['title']), strtolower($name));
|
||||
$result = !str_contains(strtolower($attachment['filename']), strtolower($name)) && !str_contains(
|
||||
strtolower($attachment['title']),
|
||||
strtolower($name)
|
||||
);
|
||||
if (true === $result) {
|
||||
return true;
|
||||
}
|
||||
@@ -163,7 +143,7 @@ trait AttachmentCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string $name
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function attachmentNameDoesNotEnd(string $name): GroupCollectorInterface
|
||||
@@ -175,7 +155,10 @@ trait AttachmentCollection
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
/** @var array $attachment */
|
||||
foreach ($transaction['attachments'] as $attachment) {
|
||||
$result = !str_ends_with(strtolower($attachment['filename']), strtolower($name)) && !str_ends_with(strtolower($attachment['title']), strtolower($name));
|
||||
$result = !str_ends_with(strtolower($attachment['filename']), strtolower($name)) && !str_ends_with(
|
||||
strtolower($attachment['title']),
|
||||
strtolower($name)
|
||||
);
|
||||
if (true === $result) {
|
||||
return true;
|
||||
}
|
||||
@@ -189,7 +172,65 @@ trait AttachmentCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string $name
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function attachmentNameDoesNotStart(string $name): GroupCollectorInterface
|
||||
{
|
||||
$this->hasAttachments();
|
||||
$this->withAttachmentInformation();
|
||||
$filter = function (int $index, array $object) use ($name): bool {
|
||||
/** @var array $transaction */
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
/** @var array $attachment */
|
||||
foreach ($transaction['attachments'] as $attachment) {
|
||||
$result = !str_starts_with(strtolower($attachment['filename']), strtolower($name)) && !str_starts_with(
|
||||
strtolower($attachment['title']),
|
||||
strtolower($name)
|
||||
);
|
||||
if (true === $result) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
$this->postFilters[] = $filter;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function attachmentNameEnds(string $name): GroupCollectorInterface
|
||||
{
|
||||
$this->hasAttachments();
|
||||
$this->withAttachmentInformation();
|
||||
$filter = function (int $index, array $object) use ($name): bool {
|
||||
/** @var array $transaction */
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
/** @var array $attachment */
|
||||
foreach ($transaction['attachments'] as $attachment) {
|
||||
$result = str_ends_with(strtolower($attachment['filename']), strtolower($name)) || str_ends_with(
|
||||
strtolower($attachment['title']),
|
||||
strtolower($name)
|
||||
);
|
||||
if (true === $result) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
$this->postFilters[] = $filter;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function attachmentNameIs(string $name): GroupCollectorInterface
|
||||
@@ -215,7 +256,7 @@ trait AttachmentCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string $name
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function attachmentNameIsNot(string $name): GroupCollectorInterface
|
||||
@@ -241,7 +282,7 @@ trait AttachmentCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string $name
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function attachmentNameStarts(string $name): GroupCollectorInterface
|
||||
@@ -253,7 +294,10 @@ trait AttachmentCollection
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
/** @var array $attachment */
|
||||
foreach ($transaction['attachments'] as $attachment) {
|
||||
$result = str_starts_with(strtolower($attachment['filename']), strtolower($name)) || str_starts_with(strtolower($attachment['title']), strtolower($name));
|
||||
$result = str_starts_with(strtolower($attachment['filename']), strtolower($name)) || str_starts_with(
|
||||
strtolower($attachment['title']),
|
||||
strtolower($name)
|
||||
);
|
||||
if (true === $result) {
|
||||
return true;
|
||||
}
|
||||
@@ -267,33 +311,7 @@ trait AttachmentCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function attachmentNameDoesNotStart(string $name): GroupCollectorInterface
|
||||
{
|
||||
$this->hasAttachments();
|
||||
$this->withAttachmentInformation();
|
||||
$filter = function (int $index, array $object) use ($name): bool {
|
||||
/** @var array $transaction */
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
/** @var array $attachment */
|
||||
foreach ($transaction['attachments'] as $attachment) {
|
||||
$result = !str_starts_with(strtolower($attachment['filename']), strtolower($name)) && !str_starts_with(strtolower($attachment['title']), strtolower($name));
|
||||
if (true === $result) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
$this->postFilters[] = $filter;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @param string $value
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function attachmentNotesAre(string $value): GroupCollectorInterface
|
||||
@@ -307,7 +325,7 @@ trait AttachmentCollection
|
||||
foreach ($transaction['attachments'] as $attachment) {
|
||||
/** @var 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;
|
||||
}
|
||||
}
|
||||
@@ -319,7 +337,7 @@ trait AttachmentCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @param string $value
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function attachmentNotesAreNot(string $value): GroupCollectorInterface
|
||||
@@ -333,7 +351,7 @@ trait AttachmentCollection
|
||||
foreach ($transaction['attachments'] as $attachment) {
|
||||
/** @var 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;
|
||||
}
|
||||
}
|
||||
@@ -345,7 +363,7 @@ trait AttachmentCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @param string $value
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function attachmentNotesContains(string $value): GroupCollectorInterface
|
||||
@@ -359,7 +377,7 @@ trait AttachmentCollection
|
||||
foreach ($transaction['attachments'] as $attachment) {
|
||||
/** @var 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));
|
||||
}
|
||||
}
|
||||
@@ -371,7 +389,7 @@ trait AttachmentCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @param string $value
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function attachmentNotesDoNotContain(string $value): GroupCollectorInterface
|
||||
@@ -385,7 +403,7 @@ trait AttachmentCollection
|
||||
foreach ($transaction['attachments'] as $attachment) {
|
||||
/** @var 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));
|
||||
}
|
||||
}
|
||||
@@ -397,33 +415,7 @@ trait AttachmentCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function attachmentNotesEnds(string $value): GroupCollectorInterface
|
||||
{
|
||||
$this->hasAttachments();
|
||||
$this->withAttachmentInformation();
|
||||
$filter = function (int $index, array $object) use ($value): bool {
|
||||
/** @var array $transaction */
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
/** @var array $attachment */
|
||||
foreach ($transaction['attachments'] as $attachment) {
|
||||
/** @var Attachment $object */
|
||||
$object = auth()->user()->attachments()->find($attachment['id']);
|
||||
$notes = (string) $object->notes()?->first()?->text;
|
||||
return $notes !== '' && str_ends_with(strtolower($notes), strtolower($value));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
$this->postFilters[] = $filter;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @param string $value
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function attachmentNotesDoNotEnd(string $value): GroupCollectorInterface
|
||||
@@ -437,7 +429,7 @@ trait AttachmentCollection
|
||||
foreach ($transaction['attachments'] as $attachment) {
|
||||
/** @var 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));
|
||||
}
|
||||
}
|
||||
@@ -449,33 +441,7 @@ trait AttachmentCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function attachmentNotesStarts(string $value): GroupCollectorInterface
|
||||
{
|
||||
$this->hasAttachments();
|
||||
$this->withAttachmentInformation();
|
||||
$filter = function (int $index, array $object) use ($value): bool {
|
||||
/** @var array $transaction */
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
/** @var array $attachment */
|
||||
foreach ($transaction['attachments'] as $attachment) {
|
||||
/** @var Attachment $object */
|
||||
$object = auth()->user()->attachments()->find($attachment['id']);
|
||||
$notes = (string) $object->notes()?->first()?->text;
|
||||
return $notes !== '' && str_starts_with(strtolower($notes), strtolower($value));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
$this->postFilters[] = $filter;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @param string $value
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function attachmentNotesDoNotStart(string $value): GroupCollectorInterface
|
||||
@@ -489,7 +455,7 @@ trait AttachmentCollection
|
||||
foreach ($transaction['attachments'] as $attachment) {
|
||||
/** @var 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));
|
||||
}
|
||||
}
|
||||
@@ -500,6 +466,58 @@ trait AttachmentCollection
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function attachmentNotesEnds(string $value): GroupCollectorInterface
|
||||
{
|
||||
$this->hasAttachments();
|
||||
$this->withAttachmentInformation();
|
||||
$filter = function (int $index, array $object) use ($value): bool {
|
||||
/** @var array $transaction */
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
/** @var array $attachment */
|
||||
foreach ($transaction['attachments'] as $attachment) {
|
||||
/** @var Attachment $object */
|
||||
$object = auth()->user()->attachments()->find($attachment['id']);
|
||||
$notes = (string)$object->notes()?->first()?->text;
|
||||
return $notes !== '' && str_ends_with(strtolower($notes), strtolower($value));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
$this->postFilters[] = $filter;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function attachmentNotesStarts(string $value): GroupCollectorInterface
|
||||
{
|
||||
$this->hasAttachments();
|
||||
$this->withAttachmentInformation();
|
||||
$filter = function (int $index, array $object) use ($value): bool {
|
||||
/** @var array $transaction */
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
/** @var array $attachment */
|
||||
foreach ($transaction['attachments'] as $attachment) {
|
||||
/** @var Attachment $object */
|
||||
$object = auth()->user()->attachments()->find($attachment['id']);
|
||||
$notes = (string)$object->notes()?->first()?->text;
|
||||
return $notes !== '' && str_starts_with(strtolower($notes), strtolower($value));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
$this->postFilters[] = $filter;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Has attachments
|
||||
*
|
||||
|
@@ -53,10 +53,29 @@ trait MetaCollection
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Will include bill name + ID, if any.
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function withBillInformation(): GroupCollectorInterface
|
||||
{
|
||||
if (false === $this->hasBillInformation) {
|
||||
// join bill table
|
||||
$this->query->leftJoin('bills', 'bills.id', '=', 'transaction_journals.bill_id');
|
||||
// add fields
|
||||
$this->fields[] = 'bills.id as bill_id';
|
||||
$this->fields[] = 'bills.name as bill_name';
|
||||
$this->hasBillInformation = true;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude a specific budget.
|
||||
*
|
||||
* @param Budget $budget
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -72,6 +91,27 @@ trait MetaCollection
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Will include budget ID + name, if any.
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function withBudgetInformation(): GroupCollectorInterface
|
||||
{
|
||||
if (false === $this->hasBudgetInformation) {
|
||||
// join link table
|
||||
$this->query->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id');
|
||||
// join cat table
|
||||
$this->query->leftJoin('budgets', 'budget_transaction_journal.budget_id', '=', 'budgets.id');
|
||||
// add fields
|
||||
$this->fields[] = 'budgets.id as budget_id';
|
||||
$this->fields[] = 'budgets.name as budget_name';
|
||||
$this->hasBudgetInformation = true;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@@ -104,10 +144,31 @@ trait MetaCollection
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Will include category ID + name, if any.
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function withCategoryInformation(): GroupCollectorInterface
|
||||
{
|
||||
if (false === $this->hasCatInformation) {
|
||||
// join link table
|
||||
$this->query->leftJoin('category_transaction_journal', 'category_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id');
|
||||
// join cat table
|
||||
$this->query->leftJoin('categories', 'category_transaction_journal.category_id', '=', 'categories.id');
|
||||
// add fields
|
||||
$this->fields[] = 'categories.id as category_id';
|
||||
$this->fields[] = 'categories.name as category_name';
|
||||
$this->hasCatInformation = true;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude a specific category.
|
||||
*
|
||||
* @param Category $category
|
||||
* @param Category $category
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -126,11 +187,11 @@ trait MetaCollection
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function externalIdContains(string $externalId): GroupCollectorInterface
|
||||
public function excludeExternalId(string $externalId): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'external_id');
|
||||
$this->query->where('journal_meta.data', 'LIKE', sprintf('%%%s%%', $externalId));
|
||||
$this->query->where('journal_meta.data', '!=', sprintf('%s', json_encode($externalId)));
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -138,11 +199,48 @@ trait MetaCollection
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function externalIdDoesNotContain(string $externalId): GroupCollectorInterface
|
||||
public function excludeExternalUrl(string $url): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'external_url');
|
||||
$this->query->where('journal_meta.data', '!=', json_encode($url));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function excludeInternalReference(string $internalReference): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
|
||||
$this->query->where('journal_meta.name', '=', 'internal_reference');
|
||||
$this->query->where('journal_meta.data', 'NOT LIKE', sprintf('%%%s%%', $internalReference));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function excludeRecurrenceId(string $recurringId): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'recurrence_id');
|
||||
$this->query->where('journal_meta.data', '!=', sprintf('%s', json_encode($recurringId)));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function externalIdContains(string $externalId): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'external_id');
|
||||
$this->query->where('journal_meta.data', 'NOT LIKE', sprintf('%%%s%%', $externalId));
|
||||
$this->query->where('journal_meta.data', 'LIKE', sprintf('%%%s%%', $externalId));
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -163,11 +261,11 @@ trait MetaCollection
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function externalIdEnds(string $externalId): GroupCollectorInterface
|
||||
public function externalIdDoesNotContain(string $externalId): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'external_id');
|
||||
$this->query->where('journal_meta.data', 'LIKE', sprintf('%%%s"', $externalId));
|
||||
$this->query->where('journal_meta.data', 'NOT LIKE', sprintf('%%%s%%', $externalId));
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -187,7 +285,7 @@ trait MetaCollection
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function externalIdStarts(string $externalId): GroupCollectorInterface
|
||||
public function externalIdDoesNotStart(string $externalId): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'external_id');
|
||||
@@ -199,7 +297,19 @@ trait MetaCollection
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function externalIdDoesNotStart(string $externalId): GroupCollectorInterface
|
||||
public function externalIdEnds(string $externalId): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'external_id');
|
||||
$this->query->where('journal_meta.data', 'LIKE', sprintf('%%%s"', $externalId));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function externalIdStarts(string $externalId): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'external_id');
|
||||
@@ -209,7 +319,7 @@ trait MetaCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
* @param string $url
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function externalUrlContains(string $url): GroupCollectorInterface
|
||||
@@ -224,7 +334,7 @@ trait MetaCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
* @param string $url
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function externalUrlDoesNotContain(string $url): GroupCollectorInterface
|
||||
@@ -237,8 +347,41 @@ trait MetaCollection
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
* @param string $url
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function externalUrlDoesNotEnd(string $url): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$url = json_encode($url);
|
||||
$url = str_replace('\\', '\\\\', ltrim($url, '"'));
|
||||
$this->query->where('journal_meta.name', '=', 'external_url');
|
||||
$this->query->where('journal_meta.data', 'NOT LIKE', sprintf('%%%s', $url));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function externalUrlDoesNotStart(string $url): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$url = json_encode($url);
|
||||
$url = str_replace('\\', '\\\\', rtrim($url, '"'));
|
||||
//var_dump($url);
|
||||
|
||||
$this->query->where('journal_meta.name', '=', 'external_url');
|
||||
$this->query->where('journal_meta.data', 'NOT LIKE', sprintf('%s%%', $url));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function externalUrlEnds(string $url): GroupCollectorInterface
|
||||
@@ -253,21 +396,7 @@ trait MetaCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function externalUrlDoesNotEnd(string $url): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$url = json_encode($url);
|
||||
$url = str_replace('\\', '\\\\', ltrim($url, '"'));
|
||||
$this->query->where('journal_meta.name', '=', 'external_url');
|
||||
$this->query->where('journal_meta.data', 'NOT LIKE', sprintf('%%%s', $url));
|
||||
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* @param string $url
|
||||
* @param string $url
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function externalUrlStarts(string $url): GroupCollectorInterface
|
||||
@@ -283,23 +412,6 @@ trait MetaCollection
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function externalUrlDoesNotStart(string $url): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$url = json_encode($url);
|
||||
$url = str_replace('\\', '\\\\', rtrim($url, '"'));
|
||||
//var_dump($url);
|
||||
|
||||
$this->query->where('journal_meta.name', '=', 'external_url');
|
||||
$this->query->where('journal_meta.data', 'NOT LIKE', sprintf('%s%%', $url));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Where has no tags.
|
||||
*
|
||||
@@ -368,18 +480,6 @@ trait MetaCollection
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function internalReferenceEnds(string $externalId): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'internal_reference');
|
||||
$this->query->where('journal_meta.data', 'LIKE', sprintf('%%%s"', $externalId));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@@ -392,18 +492,6 @@ trait MetaCollection
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function internalReferenceStarts(string $externalId): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'internal_reference');
|
||||
$this->query->where('journal_meta.data', 'LIKE', sprintf('"%s%%', $externalId));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@@ -417,7 +505,31 @@ trait MetaCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function internalReferenceEnds(string $externalId): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'internal_reference');
|
||||
$this->query->where('journal_meta.data', 'LIKE', sprintf('%%%s"', $externalId));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function internalReferenceStarts(string $externalId): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'internal_reference');
|
||||
$this->query->where('journal_meta.data', 'LIKE', sprintf('"%s%%', $externalId));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -453,7 +565,7 @@ trait MetaCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @param string $value
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -469,7 +581,7 @@ trait MetaCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @param string $value
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -485,7 +597,7 @@ trait MetaCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @param string $value
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -501,7 +613,7 @@ trait MetaCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @param string $value
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -514,7 +626,7 @@ trait MetaCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @param string $value
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -527,7 +639,7 @@ trait MetaCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @param string $value
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -543,7 +655,7 @@ trait MetaCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @param string $value
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -558,7 +670,7 @@ trait MetaCollection
|
||||
/**
|
||||
* Limit the search to a specific bill.
|
||||
*
|
||||
* @param Bill $bill
|
||||
* @param Bill $bill
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -570,29 +682,10 @@ trait MetaCollection
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Will include bill name + ID, if any.
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function withBillInformation(): GroupCollectorInterface
|
||||
{
|
||||
if (false === $this->hasBillInformation) {
|
||||
// join bill table
|
||||
$this->query->leftJoin('bills', 'bills.id', '=', 'transaction_journals.bill_id');
|
||||
// add fields
|
||||
$this->fields[] = 'bills.id as bill_id';
|
||||
$this->fields[] = 'bills.name as bill_name';
|
||||
$this->hasBillInformation = true;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Limit the search to a specific set of bills.
|
||||
*
|
||||
* @param Collection $bills
|
||||
* @param Collection $bills
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -607,7 +700,7 @@ trait MetaCollection
|
||||
/**
|
||||
* Limit the search to a specific budget.
|
||||
*
|
||||
* @param Budget $budget
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -619,31 +712,10 @@ trait MetaCollection
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Will include budget ID + name, if any.
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function withBudgetInformation(): GroupCollectorInterface
|
||||
{
|
||||
if (false === $this->hasBudgetInformation) {
|
||||
// join link table
|
||||
$this->query->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id');
|
||||
// join cat table
|
||||
$this->query->leftJoin('budgets', 'budget_transaction_journal.budget_id', '=', 'budgets.id');
|
||||
// add fields
|
||||
$this->fields[] = 'budgets.id as budget_id';
|
||||
$this->fields[] = 'budgets.name as budget_name';
|
||||
$this->hasBudgetInformation = true;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Limit the search to a specific set of budgets.
|
||||
*
|
||||
* @param Collection $budgets
|
||||
* @param Collection $budgets
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -660,7 +732,7 @@ trait MetaCollection
|
||||
/**
|
||||
* Limit the search to a specific bunch of categories.
|
||||
*
|
||||
* @param Collection $categories
|
||||
* @param Collection $categories
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -674,31 +746,10 @@ trait MetaCollection
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Will include category ID + name, if any.
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function withCategoryInformation(): GroupCollectorInterface
|
||||
{
|
||||
if (false === $this->hasCatInformation) {
|
||||
// join link table
|
||||
$this->query->leftJoin('category_transaction_journal', 'category_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id');
|
||||
// join cat table
|
||||
$this->query->leftJoin('categories', 'category_transaction_journal.category_id', '=', 'categories.id');
|
||||
// add fields
|
||||
$this->fields[] = 'categories.id as category_id';
|
||||
$this->fields[] = 'categories.name as category_name';
|
||||
$this->hasCatInformation = true;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Limit the search to a specific category.
|
||||
*
|
||||
* @param Category $category
|
||||
* @param Category $category
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -722,19 +773,6 @@ trait MetaCollection
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function excludeExternalId(string $externalId): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'external_id');
|
||||
$this->query->where('journal_meta.data', '!=', sprintf('%s', json_encode($externalId)));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@@ -747,18 +785,6 @@ trait MetaCollection
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function excludeExternalUrl(string $url): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'external_url');
|
||||
$this->query->where('journal_meta.data', '!=', json_encode($url));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@@ -772,19 +798,6 @@ trait MetaCollection
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function excludeInternalReference(string $internalReference): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
|
||||
$this->query->where('journal_meta.name', '=', 'internal_reference');
|
||||
$this->query->where('journal_meta.data', 'NOT LIKE', sprintf('%%%s%%', $internalReference));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@@ -800,11 +813,12 @@ trait MetaCollection
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function excludeRecurrenceId(string $recurringId): GroupCollectorInterface
|
||||
public function setSepaCT(string $sepaCT): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'recurrence_id');
|
||||
$this->query->where('journal_meta.data', '!=', sprintf('%s', json_encode($recurringId)));
|
||||
$this->query->where('journal_meta.name', '=', 'sepa_ct_id');
|
||||
$this->query->where('journal_meta.data', '=', sprintf('%s', json_encode($sepaCT)));
|
||||
$this->query->whereNull('journal_meta.deleted_at');
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -812,7 +826,7 @@ trait MetaCollection
|
||||
/**
|
||||
* Limit results to a specific tag.
|
||||
*
|
||||
* @param Tag $tag
|
||||
* @param Tag $tag
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -827,7 +841,7 @@ trait MetaCollection
|
||||
/**
|
||||
* Limit results to a specific set of tags.
|
||||
*
|
||||
* @param Collection $tags
|
||||
* @param Collection $tags
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -842,7 +856,7 @@ trait MetaCollection
|
||||
/**
|
||||
* Without tags
|
||||
*
|
||||
* @param Collection $tags
|
||||
* @param Collection $tags
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -921,10 +935,10 @@ trait MetaCollection
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function withExternalUrl(): GroupCollectorInterface
|
||||
public function withExternalId(): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'external_url');
|
||||
$this->query->where('journal_meta.name', '=', 'external_id');
|
||||
$this->query->whereNotNull('journal_meta.data');
|
||||
|
||||
return $this;
|
||||
@@ -933,10 +947,10 @@ trait MetaCollection
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function withExternalId(): GroupCollectorInterface
|
||||
public function withExternalUrl(): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'external_id');
|
||||
$this->query->where('journal_meta.name', '=', 'external_url');
|
||||
$this->query->whereNotNull('journal_meta.data');
|
||||
|
||||
return $this;
|
||||
@@ -980,26 +994,6 @@ trait MetaCollection
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function withoutExternalUrl(): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
// TODO not sure if this will work properly.
|
||||
$this->query->where(function (Builder $q1) {
|
||||
$q1->where(function (Builder $q2) {
|
||||
$q2->where('journal_meta.name', '=', 'external_url');
|
||||
$q2->whereNull('journal_meta.data');
|
||||
})->orWhere(function (Builder $q3) {
|
||||
$q3->where('journal_meta.name', '!=', 'external_url');
|
||||
})->orWhere(function (Builder $q4) {
|
||||
$q4->whereNull('journal_meta.name');
|
||||
});
|
||||
});
|
||||
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@@ -1021,6 +1015,27 @@ trait MetaCollection
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function withoutExternalUrl(): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
// TODO not sure if this will work properly.
|
||||
$this->query->where(function (Builder $q1) {
|
||||
$q1->where(function (Builder $q2) {
|
||||
$q2->where('journal_meta.name', '=', 'external_url');
|
||||
$q2->whereNull('journal_meta.data');
|
||||
})->orWhere(function (Builder $q3) {
|
||||
$q3->where('journal_meta.name', '!=', 'external_url');
|
||||
})->orWhere(function (Builder $q4) {
|
||||
$q4->whereNull('journal_meta.name');
|
||||
});
|
||||
});
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -1047,17 +1062,4 @@ trait MetaCollection
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setSepaCT(string $sepaCT): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', 'sepa_ct_id');
|
||||
$this->query->where('journal_meta.data', '=', sprintf('%s', json_encode($sepaCT)));
|
||||
$this->query->whereNull('journal_meta.deleted_at');
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@@ -33,7 +33,7 @@ use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
trait TimeCollection
|
||||
{
|
||||
/**
|
||||
* @param string $day
|
||||
* @param string $day
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function dayAfter(string $day): GroupCollectorInterface
|
||||
@@ -43,7 +43,7 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $day
|
||||
* @param string $day
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function dayBefore(string $day): GroupCollectorInterface
|
||||
@@ -53,7 +53,7 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $day
|
||||
* @param string $day
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function dayIs(string $day): GroupCollectorInterface
|
||||
@@ -63,7 +63,7 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $day
|
||||
* @param string $day
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function dayIsNot(string $day): GroupCollectorInterface
|
||||
@@ -73,9 +73,9 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param string $field
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param string $field
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function excludeMetaDateRange(Carbon $start, Carbon $end, string $field): GroupCollectorInterface
|
||||
@@ -103,9 +103,21 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param string $field
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function withMetaDate(string $field): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', $field);
|
||||
$this->query->whereNotNull('journal_meta.data');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param string $field
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function excludeObjectRange(Carbon $start, Carbon $end, string $field): GroupCollectorInterface
|
||||
@@ -120,8 +132,8 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function excludeRange(Carbon $start, Carbon $end): GroupCollectorInterface
|
||||
@@ -139,8 +151,8 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $day
|
||||
* @param string $field
|
||||
* @param string $day
|
||||
* @param string $field
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function metaDayAfter(string $day, string $field): GroupCollectorInterface
|
||||
@@ -150,7 +162,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,20 +174,8 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function withMetaDate(string $field): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$this->query->where('journal_meta.name', '=', $field);
|
||||
$this->query->whereNotNull('journal_meta.data');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $day
|
||||
* @param string $field
|
||||
* @param string $day
|
||||
* @param string $field
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function metaDayBefore(string $day, string $field): GroupCollectorInterface
|
||||
@@ -185,7 +185,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,8 +197,8 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $day
|
||||
* @param string $field
|
||||
* @param string $day
|
||||
* @param string $field
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function metaDayIs(string $day, string $field): GroupCollectorInterface
|
||||
@@ -208,7 +208,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,8 +219,8 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $day
|
||||
* @param string $field
|
||||
* @param string $day
|
||||
* @param string $field
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function metaDayIsNot(string $day, string $field): GroupCollectorInterface
|
||||
@@ -230,7 +230,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,8 +241,8 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $month
|
||||
* @param string $field
|
||||
* @param string $month
|
||||
* @param string $field
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function metaMonthAfter(string $month, string $field): GroupCollectorInterface
|
||||
@@ -252,7 +252,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,8 +264,8 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $month
|
||||
* @param string $field
|
||||
* @param string $month
|
||||
* @param string $field
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function metaMonthBefore(string $month, string $field): GroupCollectorInterface
|
||||
@@ -275,7 +275,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,8 +287,8 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $month
|
||||
* @param string $field
|
||||
* @param string $month
|
||||
* @param string $field
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function metaMonthIs(string $month, string $field): GroupCollectorInterface
|
||||
@@ -298,7 +298,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -309,8 +309,8 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $month
|
||||
* @param string $field
|
||||
* @param string $month
|
||||
* @param string $field
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function metaMonthIsNot(string $month, string $field): GroupCollectorInterface
|
||||
@@ -320,7 +320,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,8 +331,8 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $year
|
||||
* @param string $field
|
||||
* @param string $year
|
||||
* @param string $field
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function metaYearAfter(string $year, string $field): GroupCollectorInterface
|
||||
@@ -342,7 +342,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,8 +354,8 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $year
|
||||
* @param string $field
|
||||
* @param string $year
|
||||
* @param string $field
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function metaYearBefore(string $year, string $field): GroupCollectorInterface
|
||||
@@ -365,7 +365,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -377,8 +377,8 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $year
|
||||
* @param string $field
|
||||
* @param string $year
|
||||
* @param string $field
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function metaYearIs(string $year, string $field): GroupCollectorInterface
|
||||
@@ -388,7 +388,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -400,8 +400,8 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $year
|
||||
* @param string $field
|
||||
* @param string $year
|
||||
* @param string $field
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function metaYearIsNot(string $year, string $field): GroupCollectorInterface
|
||||
@@ -411,7 +411,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;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -422,7 +422,7 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $month
|
||||
* @param string $month
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function monthAfter(string $month): GroupCollectorInterface
|
||||
@@ -432,7 +432,7 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $month
|
||||
* @param string $month
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function monthBefore(string $month): GroupCollectorInterface
|
||||
@@ -442,7 +442,7 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $month
|
||||
* @param string $month
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function monthIs(string $month): GroupCollectorInterface
|
||||
@@ -452,7 +452,7 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $month
|
||||
* @param string $month
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function monthIsNot(string $month): GroupCollectorInterface
|
||||
@@ -462,8 +462,8 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $day
|
||||
* @param string $field
|
||||
* @param string $day
|
||||
* @param string $field
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function objectDayAfter(string $day, string $field): GroupCollectorInterface
|
||||
@@ -473,8 +473,8 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $day
|
||||
* @param string $field
|
||||
* @param string $day
|
||||
* @param string $field
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function objectDayBefore(string $day, string $field): GroupCollectorInterface
|
||||
@@ -484,8 +484,8 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $day
|
||||
* @param string $field
|
||||
* @param string $day
|
||||
* @param string $field
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function objectDayIs(string $day, string $field): GroupCollectorInterface
|
||||
@@ -495,8 +495,8 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $day
|
||||
* @param string $field
|
||||
* @param string $day
|
||||
* @param string $field
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function objectDayIsNot(string $day, string $field): GroupCollectorInterface
|
||||
@@ -506,8 +506,8 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $month
|
||||
* @param string $field
|
||||
* @param string $month
|
||||
* @param string $field
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function objectMonthAfter(string $month, string $field): GroupCollectorInterface
|
||||
@@ -517,8 +517,8 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $month
|
||||
* @param string $field
|
||||
* @param string $month
|
||||
* @param string $field
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function objectMonthBefore(string $month, string $field): GroupCollectorInterface
|
||||
@@ -528,8 +528,8 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $month
|
||||
* @param string $field
|
||||
* @param string $month
|
||||
* @param string $field
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function objectMonthIs(string $month, string $field): GroupCollectorInterface
|
||||
@@ -539,8 +539,8 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $month
|
||||
* @param string $field
|
||||
* @param string $month
|
||||
* @param string $field
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function objectMonthIsNot(string $month, string $field): GroupCollectorInterface
|
||||
@@ -550,8 +550,8 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $year
|
||||
* @param string $field
|
||||
* @param string $year
|
||||
* @param string $field
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function objectYearAfter(string $year, string $field): GroupCollectorInterface
|
||||
@@ -561,8 +561,8 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $year
|
||||
* @param string $field
|
||||
* @param string $year
|
||||
* @param string $field
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function objectYearBefore(string $year, string $field): GroupCollectorInterface
|
||||
@@ -572,8 +572,8 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $year
|
||||
* @param string $field
|
||||
* @param string $year
|
||||
* @param string $field
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function objectYearIs(string $year, string $field): GroupCollectorInterface
|
||||
@@ -583,8 +583,8 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $year
|
||||
* @param string $field
|
||||
* @param string $year
|
||||
* @param string $field
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function objectYearIsNot(string $year, string $field): GroupCollectorInterface
|
||||
@@ -596,7 +596,7 @@ trait TimeCollection
|
||||
/**
|
||||
* Collect transactions after a specific date.
|
||||
*
|
||||
* @param Carbon $date
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -611,7 +611,7 @@ trait TimeCollection
|
||||
/**
|
||||
* Collect transactions before a specific date.
|
||||
*
|
||||
* @param Carbon $date
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -626,7 +626,7 @@ trait TimeCollection
|
||||
/**
|
||||
* Collect transactions created on a specific date.
|
||||
*
|
||||
* @param Carbon $date
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -641,8 +641,8 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $date
|
||||
* @param string $field
|
||||
* @param Carbon $date
|
||||
* @param string $field
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function setMetaAfter(Carbon $date, string $field): GroupCollectorInterface
|
||||
@@ -665,8 +665,8 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $date
|
||||
* @param string $field
|
||||
* @param Carbon $date
|
||||
* @param string $field
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function setMetaBefore(Carbon $date, string $field): GroupCollectorInterface
|
||||
@@ -688,9 +688,9 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param string $field
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param string $field
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function setMetaDateRange(Carbon $start, Carbon $end, string $field): GroupCollectorInterface
|
||||
@@ -718,8 +718,8 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $date
|
||||
* @param string $field
|
||||
* @param Carbon $date
|
||||
* @param string $field
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function setObjectAfter(Carbon $date, string $field): GroupCollectorInterface
|
||||
@@ -731,8 +731,8 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $date
|
||||
* @param string $field
|
||||
* @param Carbon $date
|
||||
* @param string $field
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function setObjectBefore(Carbon $date, string $field): GroupCollectorInterface
|
||||
@@ -743,9 +743,9 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param string $field
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param string $field
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function setObjectRange(Carbon $start, Carbon $end, string $field): GroupCollectorInterface
|
||||
@@ -761,8 +761,8 @@ trait TimeCollection
|
||||
/**
|
||||
* Set the start and end time of the results to return.
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -784,7 +784,7 @@ trait TimeCollection
|
||||
/**
|
||||
* Collect transactions updated on a specific date.
|
||||
*
|
||||
* @param Carbon $date
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -799,7 +799,7 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $year
|
||||
* @param string $year
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function yearAfter(string $year): GroupCollectorInterface
|
||||
@@ -809,7 +809,7 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $year
|
||||
* @param string $year
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function yearBefore(string $year): GroupCollectorInterface
|
||||
@@ -819,7 +819,7 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $year
|
||||
* @param string $year
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function yearIs(string $year): GroupCollectorInterface
|
||||
@@ -829,7 +829,7 @@ trait TimeCollection
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $year
|
||||
* @param string $year
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function yearIsNot(string $year): GroupCollectorInterface
|
||||
|
@@ -315,7 +315,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
/**
|
||||
* Limit results to NOT a specific currency, either foreign or normal one.
|
||||
*
|
||||
* @param TransactionCurrency $currency
|
||||
* @param TransactionCurrency $currency
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -352,7 +352,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
/**
|
||||
* Limit the result to NOT a set of specific transaction groups.
|
||||
*
|
||||
* @param array $groupIds
|
||||
* @param array $groupIds
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -366,7 +366,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
/**
|
||||
* Limit the result to NOT a set of specific journals.
|
||||
*
|
||||
* @param array $journalIds
|
||||
* @param array $journalIds
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -386,7 +386,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
/**
|
||||
* Search for words in descriptions.
|
||||
*
|
||||
* @param array $array
|
||||
* @param array $array
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -500,7 +500,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $collection
|
||||
* @param Collection $collection
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
@@ -515,21 +515,21 @@ class GroupCollector implements GroupCollectorInterface
|
||||
// make new array
|
||||
$parsedGroup = $this->parseAugmentedJournal($augumentedJournal);
|
||||
$groupArray = [
|
||||
'id' => (int) $augumentedJournal->transaction_group_id,
|
||||
'user_id' => (int) $augumentedJournal->user_id,
|
||||
'id' => (int)$augumentedJournal->transaction_group_id,
|
||||
'user_id' => (int)$augumentedJournal->user_id,
|
||||
'title' => $augumentedJournal->transaction_group_title,
|
||||
'transaction_type' => $parsedGroup['transaction_type_type'],
|
||||
'count' => 1,
|
||||
'sums' => [],
|
||||
'transactions' => [],
|
||||
];
|
||||
$journalId = (int) $augumentedJournal->transaction_journal_id;
|
||||
$journalId = (int)$augumentedJournal->transaction_journal_id;
|
||||
$groupArray['transactions'][$journalId] = $parsedGroup;
|
||||
$groups[$groupId] = $groupArray;
|
||||
continue;
|
||||
}
|
||||
// or parse the rest.
|
||||
$journalId = (int) $augumentedJournal->transaction_journal_id;
|
||||
$journalId = (int)$augumentedJournal->transaction_journal_id;
|
||||
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);
|
||||
@@ -549,7 +549,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $augumentedJournal
|
||||
* @param TransactionJournal $augumentedJournal
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -582,7 +582,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));
|
||||
}
|
||||
}
|
||||
@@ -593,9 +593,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 {
|
||||
$tagDate = Carbon::parse($augumentedJournal['tag_date']);
|
||||
@@ -604,7 +604,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'],
|
||||
@@ -613,8 +613,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,
|
||||
@@ -624,7 +624,8 @@ class GroupCollector implements GroupCollectorInterface
|
||||
}
|
||||
}
|
||||
// unset various fields:
|
||||
unset($result['tag_id'], $result['meta_data'], $result['meta_name'],
|
||||
unset(
|
||||
$result['tag_id'], $result['meta_data'], $result['meta_name'],
|
||||
$result['tag_name'], $result['tag_date'], $result['tag_description'],
|
||||
$result['tag_latitude'], $result['tag_longitude'], $result['tag_zoom_level'],
|
||||
$result['attachment_filename'], $result['attachment_id']
|
||||
@@ -637,35 +638,35 @@ class GroupCollector implements GroupCollectorInterface
|
||||
/**
|
||||
* Convert a selected set of fields to arrays.
|
||||
*
|
||||
* @param array $array
|
||||
* @param array $array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $array
|
||||
* @param array $array
|
||||
* @return array
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $existingJournal
|
||||
* @param TransactionJournal $newJournal
|
||||
* @param array $existingJournal
|
||||
* @param TransactionJournal $newJournal
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -673,7 +674,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;
|
||||
try {
|
||||
@@ -683,7 +684,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'],
|
||||
@@ -694,8 +695,8 @@ class GroupCollector implements GroupCollectorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $existingJournal
|
||||
* @param TransactionJournal $newJournal
|
||||
* @param array $existingJournal
|
||||
* @param TransactionJournal $newJournal
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -703,7 +704,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,
|
||||
@@ -714,20 +715,20 @@ class GroupCollector implements GroupCollectorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $groups
|
||||
* @param array $groups
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function parseSums(array $groups): array
|
||||
{
|
||||
/**
|
||||
* @var int $groudId
|
||||
* @var int $groudId
|
||||
* @var array $group
|
||||
*/
|
||||
foreach ($groups as $groudId => $group) {
|
||||
/** @var array $transaction */
|
||||
foreach ($group['transactions'] as $transaction) {
|
||||
$currencyId = (int) $transaction['currency_id'];
|
||||
$currencyId = (int)$transaction['currency_id'];
|
||||
|
||||
// set default:
|
||||
if (!array_key_exists($currencyId, $groups[$groudId]['sums'])) {
|
||||
@@ -740,7 +741,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'])) {
|
||||
@@ -762,14 +763,14 @@ class GroupCollector implements GroupCollectorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $collection
|
||||
* @param Collection $collection
|
||||
* @return Collection
|
||||
*/
|
||||
private function postFilterCollection(Collection $collection): Collection
|
||||
{
|
||||
$currentCollection = $collection;
|
||||
/**
|
||||
* @var int $i
|
||||
* @var int $i
|
||||
* @var Closure $function
|
||||
*/
|
||||
foreach ($this->postFilters as $function) {
|
||||
@@ -778,7 +779,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
// and save it (or not) in the new collection.
|
||||
// that new collection is the next current collection
|
||||
/**
|
||||
* @var int $index
|
||||
* @var int $index
|
||||
* @var array $item
|
||||
*/
|
||||
foreach ($currentCollection as $ii => $item) {
|
||||
@@ -812,7 +813,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
/**
|
||||
* Limit the number of returned entries.
|
||||
*
|
||||
* @param int $limit
|
||||
* @param int $limit
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -845,7 +846,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
/**
|
||||
* Limit results to a specific currency, either foreign or normal one.
|
||||
*
|
||||
* @param TransactionCurrency $currency
|
||||
* @param TransactionCurrency $currency
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -874,7 +875,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
/**
|
||||
* Limit the result to a set of specific transaction groups.
|
||||
*
|
||||
* @param array $groupIds
|
||||
* @param array $groupIds
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -888,7 +889,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
/**
|
||||
* Limit the result to a set of specific journals.
|
||||
*
|
||||
* @param array $journalIds
|
||||
* @param array $journalIds
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -908,7 +909,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
/**
|
||||
* Set the page to get.
|
||||
*
|
||||
* @param int $page
|
||||
* @param int $page
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -924,7 +925,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
/**
|
||||
* Search for words in descriptions.
|
||||
*
|
||||
* @param array $array
|
||||
* @param array $array
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -960,7 +961,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
/**
|
||||
* Limit the search to one specific transaction group.
|
||||
*
|
||||
* @param TransactionGroup $transactionGroup
|
||||
* @param TransactionGroup $transactionGroup
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -974,7 +975,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
/**
|
||||
* Limit the included transaction types.
|
||||
*
|
||||
* @param array $types
|
||||
* @param array $types
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
@@ -988,7 +989,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
/**
|
||||
* Set the user object and start the query.
|
||||
*
|
||||
* @param User $user
|
||||
* @param User $user
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* FiscalHelper.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -25,6 +26,8 @@ namespace FireflyIII\Helpers\Fiscal;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use Log;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class FiscalHelper.
|
||||
@@ -43,12 +46,12 @@ class FiscalHelper implements FiscalHelperInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $date
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return Carbon date object
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function endOfFiscalYear(Carbon $date): Carbon
|
||||
{
|
||||
@@ -68,12 +71,12 @@ class FiscalHelper implements FiscalHelperInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $date
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return Carbon date object
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function startOfFiscalYear(Carbon $date): Carbon
|
||||
{
|
||||
@@ -82,7 +85,7 @@ class FiscalHelper implements FiscalHelperInterface
|
||||
if (true === $this->useCustomFiscalYear) {
|
||||
$prefStartStr = app('preferences')->get('fiscalYearStart', '01-01')->data;
|
||||
[$mth, $day] = explode('-', $prefStartStr);
|
||||
$startDate->day((int) $day)->month((int) $mth);
|
||||
$startDate->day((int)$day)->month((int)$mth);
|
||||
|
||||
// if start date is after passed date, sub 1 year.
|
||||
if ($startDate > $date) {
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* FiscalHelperInterface.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -33,7 +34,7 @@ interface FiscalHelperInterface
|
||||
* This method produces a clone of the Carbon date object passed, checks preferences
|
||||
* and calculates the last day of the fiscal year.
|
||||
*
|
||||
* @param Carbon $date
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return Carbon date object
|
||||
*/
|
||||
@@ -43,7 +44,7 @@ interface FiscalHelperInterface
|
||||
* This method produces a clone of the Carbon date object passed, checks preferences
|
||||
* and calculates the first day of the fiscal year.
|
||||
*
|
||||
* @param Carbon $date
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return Carbon date object
|
||||
*/
|
||||
|
@@ -32,8 +32,8 @@ use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Support\Collection;
|
||||
use JsonException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use JsonException;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -44,7 +44,7 @@ class NetWorth implements NetWorthInterface
|
||||
private AccountRepositoryInterface $accountRepository;
|
||||
|
||||
private CurrencyRepositoryInterface $currencyRepos;
|
||||
private User $user;
|
||||
private User $user;
|
||||
|
||||
/**
|
||||
* Returns the user's net worth in an array with the following layout:
|
||||
@@ -57,8 +57,8 @@ class NetWorth implements NetWorthInterface
|
||||
* This repeats for each currency the user has transactions in.
|
||||
* Result of this method is cached.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $date
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return array
|
||||
* @throws JsonException
|
||||
@@ -89,7 +89,7 @@ class NetWorth implements NetWorthInterface
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
Log::debug(sprintf('Now at account #%d: "%s"', $account->id, $account->name));
|
||||
$currencyId = (int) $this->accountRepository->getMetaValue($account, 'currency_id');
|
||||
$currencyId = (int)$this->accountRepository->getMetaValue($account, 'currency_id');
|
||||
$currencyId = 0 === $currencyId ? $default->id : $currencyId;
|
||||
|
||||
Log::debug(sprintf('Currency ID is #%d', $currencyId));
|
||||
@@ -100,7 +100,7 @@ class NetWorth implements NetWorthInterface
|
||||
Log::debug(sprintf('Balance for %s is %s', $date->format('Y-m-d'), $balance));
|
||||
|
||||
// always subtract virtual balance.
|
||||
$virtualBalance = (string) $account->virtual_balance;
|
||||
$virtualBalance = (string)$account->virtual_balance;
|
||||
if ('' !== $virtualBalance) {
|
||||
$balance = bcsub($balance, $virtualBalance);
|
||||
}
|
||||
@@ -129,7 +129,7 @@ class NetWorth implements NetWorthInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @param User $user
|
||||
*/
|
||||
public function setUser(User $user): void
|
||||
{
|
||||
@@ -159,19 +159,19 @@ class NetWorth implements NetWorthInterface
|
||||
$balance = $balances[$account->id] ?? '0';
|
||||
|
||||
// always subtract virtual balance.
|
||||
$virtualBalance = (string) $account->virtual_balance;
|
||||
$virtualBalance = (string)$account->virtual_balance;
|
||||
if ('' !== $virtualBalance) {
|
||||
$balance = bcsub($balance, $virtualBalance);
|
||||
}
|
||||
|
||||
$return[$currency->id] = $return[$currency->id] ?? [
|
||||
'id' => (string) $currency->id,
|
||||
'name' => $currency->name,
|
||||
'symbol' => $currency->symbol,
|
||||
'code' => $currency->code,
|
||||
'decimal_places' => $currency->decimal_places,
|
||||
'sum' => '0',
|
||||
];
|
||||
'id' => (string)$currency->id,
|
||||
'name' => $currency->name,
|
||||
'symbol' => $currency->symbol,
|
||||
'code' => $currency->code,
|
||||
'decimal_places' => $currency->decimal_places,
|
||||
'sum' => '0',
|
||||
];
|
||||
$return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], $balance);
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ class NetWorth implements NetWorthInterface
|
||||
$filtered = new Collection();
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
if (1 === (int) $this->accountRepository->getMetaValue($account, 'include_net_worth')) {
|
||||
if (1 === (int)$this->accountRepository->getMetaValue($account, 'include_net_worth')) {
|
||||
$filtered->push($account);
|
||||
}
|
||||
}
|
||||
|
@@ -44,15 +44,15 @@ interface NetWorthInterface
|
||||
* This repeats for each currency the user has transactions in.
|
||||
* Result of this method is cached.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $date
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $date
|
||||
* @return array
|
||||
* @deprecated
|
||||
*/
|
||||
public function getNetWorthByCurrency(Collection $accounts, Carbon $date): array;
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @param User $user
|
||||
*/
|
||||
public function setUser(User $user): void;
|
||||
|
||||
@@ -61,7 +61,7 @@ interface NetWorthInterface
|
||||
*
|
||||
* Same as above but cleaner function with less dependencies.
|
||||
*
|
||||
* @param Carbon $date
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PopupReport.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -42,9 +43,9 @@ class PopupReport implements PopupReportInterface
|
||||
/**
|
||||
* Collect the transactions for one account and one budget.
|
||||
*
|
||||
* @param Budget $budget
|
||||
* @param Account $account
|
||||
* @param array $attributes
|
||||
* @param Budget $budget
|
||||
* @param Account $account
|
||||
* @param array $attributes
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -64,8 +65,8 @@ class PopupReport implements PopupReportInterface
|
||||
/**
|
||||
* Collect the transactions for one account and no budget.
|
||||
*
|
||||
* @param Account $account
|
||||
* @param array $attributes
|
||||
* @param Account $account
|
||||
* @param array $attributes
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -77,7 +78,7 @@ class PopupReport implements PopupReportInterface
|
||||
if (null !== $currencyId) {
|
||||
/** @var CurrencyRepositoryInterface $repos */
|
||||
$repos = app(CurrencyRepositoryInterface::class);
|
||||
$currency = $repos->find((int) $currencyId);
|
||||
$currency = $repos->find((int)$currencyId);
|
||||
}
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
@@ -99,8 +100,8 @@ class PopupReport implements PopupReportInterface
|
||||
/**
|
||||
* Collect the transactions for a budget.
|
||||
*
|
||||
* @param Budget $budget
|
||||
* @param array $attributes
|
||||
* @param Budget $budget
|
||||
* @param array $attributes
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -112,7 +113,7 @@ class PopupReport implements PopupReportInterface
|
||||
if (null !== $currencyId) {
|
||||
/** @var CurrencyRepositoryInterface $repos */
|
||||
$repos = app(CurrencyRepositoryInterface::class);
|
||||
$currency = $repos->find((int) $currencyId);
|
||||
$currency = $repos->find((int)$currencyId);
|
||||
}
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
@@ -139,8 +140,8 @@ class PopupReport implements PopupReportInterface
|
||||
/**
|
||||
* Collect journals by a category.
|
||||
*
|
||||
* @param Category|null $category
|
||||
* @param array $attributes
|
||||
* @param Category|null $category
|
||||
* @param array $attributes
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -152,7 +153,7 @@ class PopupReport implements PopupReportInterface
|
||||
if (null !== $currencyId) {
|
||||
/** @var CurrencyRepositoryInterface $repos */
|
||||
$repos = app(CurrencyRepositoryInterface::class);
|
||||
$currency = $repos->find((int) $currencyId);
|
||||
$currency = $repos->find((int)$currencyId);
|
||||
}
|
||||
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
@@ -182,8 +183,8 @@ class PopupReport implements PopupReportInterface
|
||||
/**
|
||||
* Group transactions by expense.
|
||||
*
|
||||
* @param Account $account
|
||||
* @param array $attributes
|
||||
* @param Account $account
|
||||
* @param array $attributes
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -195,7 +196,7 @@ class PopupReport implements PopupReportInterface
|
||||
if (null !== $currencyId) {
|
||||
/** @var CurrencyRepositoryInterface $repos */
|
||||
$repos = app(CurrencyRepositoryInterface::class);
|
||||
$currency = $repos->find((int) $currencyId);
|
||||
$currency = $repos->find((int)$currencyId);
|
||||
}
|
||||
|
||||
/** @var JournalRepositoryInterface $repository */
|
||||
@@ -228,8 +229,8 @@ class PopupReport implements PopupReportInterface
|
||||
/**
|
||||
* Collect transactions by income.
|
||||
*
|
||||
* @param Account $account
|
||||
* @param array $attributes
|
||||
* @param Account $account
|
||||
* @param array $attributes
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PopupReportInterface.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -34,9 +35,9 @@ interface PopupReportInterface
|
||||
/**
|
||||
* Get balances for budget.
|
||||
*
|
||||
* @param Budget $budget
|
||||
* @param Account $account
|
||||
* @param array $attributes
|
||||
* @param Budget $budget
|
||||
* @param Account $account
|
||||
* @param array $attributes
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -45,8 +46,8 @@ interface PopupReportInterface
|
||||
/**
|
||||
* Get balances for transactions without a budget.
|
||||
*
|
||||
* @param Account $account
|
||||
* @param array $attributes
|
||||
* @param Account $account
|
||||
* @param array $attributes
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -55,8 +56,8 @@ interface PopupReportInterface
|
||||
/**
|
||||
* Group by budget.
|
||||
*
|
||||
* @param Budget $budget
|
||||
* @param array $attributes
|
||||
* @param Budget $budget
|
||||
* @param array $attributes
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -65,8 +66,8 @@ interface PopupReportInterface
|
||||
/**
|
||||
* Group by category.
|
||||
*
|
||||
* @param Category|null $category
|
||||
* @param array $attributes
|
||||
* @param Category|null $category
|
||||
* @param array $attributes
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -75,8 +76,8 @@ interface PopupReportInterface
|
||||
/**
|
||||
* Do something with expense. Sorry, I am not very inspirational here.
|
||||
*
|
||||
* @param Account $account
|
||||
* @param array $attributes
|
||||
* @param Account $account
|
||||
* @param array $attributes
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -85,8 +86,8 @@ interface PopupReportInterface
|
||||
/**
|
||||
* Do something with income. Sorry, I am not very inspirational here.
|
||||
*
|
||||
* @param Account $account
|
||||
* @param array $attributes
|
||||
* @param Account $account
|
||||
* @param array $attributes
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ReportHelper.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -43,7 +44,7 @@ class ReportHelper implements ReportHelperInterface
|
||||
/**
|
||||
* ReportHelper constructor.
|
||||
*
|
||||
* @param BudgetRepositoryInterface $budgetRepository
|
||||
* @param BudgetRepositoryInterface $budgetRepository
|
||||
*/
|
||||
public function __construct(BudgetRepositoryInterface $budgetRepository)
|
||||
{
|
||||
@@ -56,9 +57,9 @@ class ReportHelper implements ReportHelperInterface
|
||||
*
|
||||
* Excludes bills which have not had a payment on the mentioned accounts.
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -112,7 +113,7 @@ class ReportHelper implements ReportHelperInterface
|
||||
/**
|
||||
* Generate a list of months for the report.
|
||||
*
|
||||
* @param Carbon $date
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -141,7 +142,7 @@ class ReportHelper implements ReportHelperInterface
|
||||
$currentEnd = clone $start;
|
||||
$currentEnd->endOfMonth();
|
||||
$months[$year]['months'][] = [
|
||||
'formatted' => $start->isoFormat((string) trans('config.month_js')),
|
||||
'formatted' => $start->isoFormat((string)trans('config.month_js')),
|
||||
'start' => $start->format('Y-m-d'),
|
||||
'end' => $currentEnd->format('Y-m-d'),
|
||||
'month' => $start->month,
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ReportHelperInterface.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -36,9 +37,9 @@ interface ReportHelperInterface
|
||||
*
|
||||
* Excludes bills which have not had a payment on the mentioned accounts.
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -47,7 +48,7 @@ interface ReportHelperInterface
|
||||
/**
|
||||
* Generate a list of months.
|
||||
*
|
||||
* @param Carbon $date
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
|
@@ -26,6 +26,8 @@ namespace FireflyIII\Helpers\Update;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Services\FireflyIIIOrg\Update\UpdateRequestInterface;
|
||||
use Log;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Trait UpdateTrait
|
||||
@@ -40,8 +42,8 @@ trait UpdateTrait
|
||||
*
|
||||
* @return array
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function getLatestRelease(): array
|
||||
{
|
||||
|
@@ -31,7 +31,7 @@ use FireflyIII\Models\WebhookMessage;
|
||||
interface SignatureGeneratorInterface
|
||||
{
|
||||
/**
|
||||
* @param WebhookMessage $message
|
||||
* @param WebhookMessage $message
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
Reference in New Issue
Block a user