mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-03 11:08:28 +00:00
fix various phpstan errors
This commit is contained in:
@@ -34,7 +34,6 @@ use Hash;
|
|||||||
use Illuminate\Contracts\Validation\Validator as ValidatorContract;
|
use Illuminate\Contracts\Validation\Validator as ValidatorContract;
|
||||||
use Illuminate\Routing\Route;
|
use Illuminate\Routing\Route;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
use InvalidArgumentException;
|
|
||||||
use Psr\Container\ContainerExceptionInterface;
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
use Psr\Container\NotFoundExceptionInterface;
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
use Route as RouteFacade;
|
use Route as RouteFacade;
|
||||||
@@ -171,21 +170,15 @@ trait RequestInformation
|
|||||||
{
|
{
|
||||||
$attributes['location'] = $attributes['location'] ?? '';
|
$attributes['location'] = $attributes['location'] ?? '';
|
||||||
$attributes['accounts'] = AccountList::routeBinder($attributes['accounts'] ?? '', new Route('get', '', []));
|
$attributes['accounts'] = AccountList::routeBinder($attributes['accounts'] ?? '', new Route('get', '', []));
|
||||||
try {
|
$date = Carbon::createFromFormat('Ymd', $attributes['startDate']);
|
||||||
$date = Carbon::createFromFormat('Ymd', $attributes['startDate']);
|
if (false === $date) {
|
||||||
} catch (InvalidArgumentException $e) {
|
|
||||||
app('log')->debug(sprintf('Not important error message: %s', $e->getMessage()));
|
|
||||||
$date = today(config('app.timezone'));
|
$date = today(config('app.timezone'));
|
||||||
|
|
||||||
}
|
}
|
||||||
$date->startOfMonth();
|
$date->startOfMonth();
|
||||||
$attributes['startDate'] = $date;
|
$attributes['startDate'] = $date;
|
||||||
unset($date);
|
|
||||||
|
|
||||||
try {
|
$date2 = Carbon::createFromFormat('Ymd', $attributes['endDate']);
|
||||||
$date2 = Carbon::createFromFormat('Ymd', $attributes['endDate']);
|
if (false === $date2) {
|
||||||
} catch (InvalidArgumentException $e) {
|
|
||||||
app('log')->debug(sprintf('Not important error message: %s', $e->getMessage()));
|
|
||||||
$date2 = today(config('app.timezone'));
|
$date2 = today(config('app.timezone'));
|
||||||
}
|
}
|
||||||
$date2->endOfDay();
|
$date2->endOfDay();
|
||||||
|
@@ -43,7 +43,7 @@ class AuditProcessor
|
|||||||
if (auth()->check()) {
|
if (auth()->check()) {
|
||||||
$message = sprintf(
|
$message = sprintf(
|
||||||
'AUDIT: %s (%s (%s) -> %s:%s)',
|
'AUDIT: %s (%s (%s) -> %s:%s)',
|
||||||
$record['message'],
|
$record['message'], // @phpstan-ignore-line
|
||||||
app('request')->ip(),
|
app('request')->ip(),
|
||||||
auth()->user()->email,
|
auth()->user()->email,
|
||||||
request()->method(),
|
request()->method(),
|
||||||
@@ -54,7 +54,7 @@ class AuditProcessor
|
|||||||
|
|
||||||
$message = sprintf(
|
$message = sprintf(
|
||||||
'AUDIT: %s (%s -> %s:%s)',
|
'AUDIT: %s (%s -> %s:%s)',
|
||||||
$record['message'],
|
$record['message'], // @phpstan-ignore-line
|
||||||
app('request')->ip(),
|
app('request')->ip(),
|
||||||
request()->method(),
|
request()->method(),
|
||||||
request()->url()
|
request()->url()
|
||||||
|
@@ -89,10 +89,10 @@ class Navigation
|
|||||||
|
|
||||||
if (!array_key_exists($repeatFreq, $functionMap)) {
|
if (!array_key_exists($repeatFreq, $functionMap)) {
|
||||||
Log::error(sprintf(
|
Log::error(sprintf(
|
||||||
'The periodicity %s is unknown. Choose one of available periodicity: %s',
|
'The periodicity %s is unknown. Choose one of available periodicity: %s',
|
||||||
$repeatFreq,
|
$repeatFreq,
|
||||||
implode(', ', array_keys($functionMap))
|
implode(', ', array_keys($functionMap))
|
||||||
));
|
));
|
||||||
return $theDate;
|
return $theDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -352,12 +352,12 @@ class Navigation
|
|||||||
public function diffInPeriods(string $period, int $skip, Carbon $beginning, Carbon $end): int
|
public function diffInPeriods(string $period, int $skip, Carbon $beginning, Carbon $end): int
|
||||||
{
|
{
|
||||||
Log::debug(sprintf(
|
Log::debug(sprintf(
|
||||||
'diffInPeriods: %s (skip: %d), between %s and %s.',
|
'diffInPeriods: %s (skip: %d), between %s and %s.',
|
||||||
$period,
|
$period,
|
||||||
$skip,
|
$skip,
|
||||||
$beginning->format('Y-m-d'),
|
$beginning->format('Y-m-d'),
|
||||||
$end->format('Y-m-d')
|
$end->format('Y-m-d')
|
||||||
));
|
));
|
||||||
$map = [
|
$map = [
|
||||||
'daily' => 'floatDiffInDays',
|
'daily' => 'floatDiffInDays',
|
||||||
'weekly' => 'floatDiffInWeeks',
|
'weekly' => 'floatDiffInWeeks',
|
||||||
@@ -394,11 +394,11 @@ class Navigation
|
|||||||
$parameter = $skip + 1;
|
$parameter = $skip + 1;
|
||||||
$diff = ceil($diff / $parameter) * $parameter;
|
$diff = ceil($diff / $parameter) * $parameter;
|
||||||
Log::debug(sprintf(
|
Log::debug(sprintf(
|
||||||
'diffInPeriods: skip is %d, so param is %d, and diff becomes %d',
|
'diffInPeriods: skip is %d, so param is %d, and diff becomes %d',
|
||||||
$skip,
|
$skip,
|
||||||
$parameter,
|
$parameter,
|
||||||
$diff
|
$diff
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (int)$diff;
|
return (int)$diff;
|
||||||
@@ -456,7 +456,11 @@ class Navigation
|
|||||||
*/
|
*/
|
||||||
public function getViewRange(bool $correct): string
|
public function getViewRange(bool $correct): string
|
||||||
{
|
{
|
||||||
$range = (string)app('preferences')->get('viewRange', '1M')?->data ?? '1M';
|
$range = app('preferences')->get('viewRange', '1M')?->data ?? '1M';
|
||||||
|
if (is_array($range)) {
|
||||||
|
$range = '1M';
|
||||||
|
}
|
||||||
|
$range = (string)$range;
|
||||||
if (!$correct) {
|
if (!$correct) {
|
||||||
return $range;
|
return $range;
|
||||||
}
|
}
|
||||||
|
@@ -88,7 +88,7 @@ class ParseDateString
|
|||||||
|
|
||||||
// if regex for YYYY-MM-DD:
|
// if regex for YYYY-MM-DD:
|
||||||
$pattern = '/^(19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12]\d|3[01])$/';
|
$pattern = '/^(19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12]\d|3[01])$/';
|
||||||
if (preg_match($pattern, $date)) {
|
if (false !== preg_match($pattern, $date)) {
|
||||||
return $this->parseDefaultDate($date);
|
return $this->parseDefaultDate($date);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,7 +151,11 @@ class ParseDateString
|
|||||||
*/
|
*/
|
||||||
protected function parseDefaultDate(string $date): Carbon
|
protected function parseDefaultDate(string $date): Carbon
|
||||||
{
|
{
|
||||||
return Carbon::createFromFormat('Y-m-d', $date);
|
$result = Carbon::createFromFormat('Y-m-d', $date);
|
||||||
|
if(false === $result) {
|
||||||
|
$result = today(config('app.timezone'))->startOfDay();
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -254,7 +258,7 @@ class ParseDateString
|
|||||||
{
|
{
|
||||||
// if regex for xxxx-xx-DD:
|
// if regex for xxxx-xx-DD:
|
||||||
$pattern = '/^xxxx-xx-(0[1-9]|[12]\d|3[01])$/';
|
$pattern = '/^xxxx-xx-(0[1-9]|[12]\d|3[01])$/';
|
||||||
if (preg_match($pattern, $date)) {
|
if (false !== preg_match($pattern, $date)) {
|
||||||
app('log')->debug(sprintf('"%s" is a day range.', $date));
|
app('log')->debug(sprintf('"%s" is a day range.', $date));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -289,7 +293,7 @@ class ParseDateString
|
|||||||
{
|
{
|
||||||
// if regex for xxxx-MM-xx:
|
// if regex for xxxx-MM-xx:
|
||||||
$pattern = '/^xxxx-(0[1-9]|1[012])-xx$/';
|
$pattern = '/^xxxx-(0[1-9]|1[012])-xx$/';
|
||||||
if (preg_match($pattern, $date)) {
|
if (false !== preg_match($pattern, $date)) {
|
||||||
app('log')->debug(sprintf('"%s" is a month range.', $date));
|
app('log')->debug(sprintf('"%s" is a month range.', $date));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -325,7 +329,7 @@ class ParseDateString
|
|||||||
{
|
{
|
||||||
// if regex for YYYY-xx-xx:
|
// if regex for YYYY-xx-xx:
|
||||||
$pattern = '/^(19|20)\d\d-xx-xx$/';
|
$pattern = '/^(19|20)\d\d-xx-xx$/';
|
||||||
if (preg_match($pattern, $date)) {
|
if (false !== preg_match($pattern, $date)) {
|
||||||
app('log')->debug(sprintf('"%s" is a year range.', $date));
|
app('log')->debug(sprintf('"%s" is a year range.', $date));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -361,7 +365,7 @@ class ParseDateString
|
|||||||
{
|
{
|
||||||
// if regex for xxxx-MM-DD:
|
// if regex for xxxx-MM-DD:
|
||||||
$pattern = '/^xxxx-(0[1-9]|1[012])-(0[1-9]|[12]\d|3[01])$/';
|
$pattern = '/^xxxx-(0[1-9]|1[012])-(0[1-9]|[12]\d|3[01])$/';
|
||||||
if (preg_match($pattern, $date)) {
|
if (false !== preg_match($pattern, $date)) {
|
||||||
app('log')->debug(sprintf('"%s" is a month/day range.', $date));
|
app('log')->debug(sprintf('"%s" is a month/day range.', $date));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -398,7 +402,7 @@ class ParseDateString
|
|||||||
{
|
{
|
||||||
// if regex for YYYY-xx-DD:
|
// if regex for YYYY-xx-DD:
|
||||||
$pattern = '/^(19|20)\d\d-xx-(0[1-9]|[12]\d|3[01])$/';
|
$pattern = '/^(19|20)\d\d-xx-(0[1-9]|[12]\d|3[01])$/';
|
||||||
if (preg_match($pattern, $date)) {
|
if (false !== preg_match($pattern, $date)) {
|
||||||
app('log')->debug(sprintf('"%s" is a day/year range.', $date));
|
app('log')->debug(sprintf('"%s" is a day/year range.', $date));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -435,7 +439,7 @@ class ParseDateString
|
|||||||
{
|
{
|
||||||
// if regex for YYYY-MM-xx:
|
// if regex for YYYY-MM-xx:
|
||||||
$pattern = '/^(19|20)\d\d-(0[1-9]|1[012])-xx$/';
|
$pattern = '/^(19|20)\d\d-(0[1-9]|1[012])-xx$/';
|
||||||
if (preg_match($pattern, $date)) {
|
if (false !== preg_match($pattern, $date)) {
|
||||||
app('log')->debug(sprintf('"%s" is a month/year range.', $date));
|
app('log')->debug(sprintf('"%s" is a month/year range.', $date));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@@ -168,7 +168,7 @@ class Preferences
|
|||||||
}
|
}
|
||||||
if (null === $pref) {
|
if (null === $pref) {
|
||||||
$pref = new Preference();
|
$pref = new Preference();
|
||||||
$pref->user_id = $user->id;
|
$pref->user_id = (int) $user->id;
|
||||||
$pref->name = $name;
|
$pref->name = $name;
|
||||||
}
|
}
|
||||||
$pref->data = $value;
|
$pref->data = $value;
|
||||||
@@ -286,7 +286,7 @@ class Preferences
|
|||||||
$lastActivity = implode(',', $lastActivity);
|
$lastActivity = implode(',', $lastActivity);
|
||||||
}
|
}
|
||||||
|
|
||||||
return hash('sha256', $lastActivity);
|
return hash('sha256', (string) $lastActivity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -45,7 +45,7 @@ trait FiltersWeekends
|
|||||||
protected function filterWeekends(RecurrenceRepetition $repetition, array $dates): array
|
protected function filterWeekends(RecurrenceRepetition $repetition, array $dates): array
|
||||||
{
|
{
|
||||||
app('log')->debug(sprintf('Now in %s', __METHOD__));
|
app('log')->debug(sprintf('Now in %s', __METHOD__));
|
||||||
if ((int)$repetition->weekend === RecurrenceRepetition::WEEKEND_DO_NOTHING) {
|
if ($repetition->weekend === RecurrenceRepetition::WEEKEND_DO_NOTHING) {
|
||||||
app('log')->debug('Repetition will not be filtered on weekend days.');
|
app('log')->debug('Repetition will not be filtered on weekend days.');
|
||||||
|
|
||||||
return $dates;
|
return $dates;
|
||||||
|
@@ -213,12 +213,12 @@ class OperatorQuerySearch implements SearchInterface
|
|||||||
// is an operator that needs no context, and value is false, then prohibited = true.
|
// is an operator that needs no context, and value is false, then prohibited = true.
|
||||||
if ('false' === $value && in_array($operator, $this->validOperators, true) && false === $context && !$prohibited) {
|
if ('false' === $value && in_array($operator, $this->validOperators, true) && false === $context && !$prohibited) {
|
||||||
$prohibited = true;
|
$prohibited = true;
|
||||||
$value = 'true';
|
$value = 'true';
|
||||||
}
|
}
|
||||||
// if the operator is prohibited, but the value is false, do an uno reverse
|
// if the operator is prohibited, but the value is false, do an uno reverse
|
||||||
if ('false' === $value && $prohibited && in_array($operator, $this->validOperators, true) && false === $context) {
|
if ('false' === $value && $prohibited && in_array($operator, $this->validOperators, true) && false === $context) {
|
||||||
$prohibited = false;
|
$prohibited = false;
|
||||||
$value = 'true';
|
$value = 'true';
|
||||||
}
|
}
|
||||||
|
|
||||||
// must be valid operator:
|
// must be valid operator:
|
||||||
@@ -264,14 +264,14 @@ class OperatorQuerySearch implements SearchInterface
|
|||||||
default:
|
default:
|
||||||
app('log')->error(sprintf('No such operator: %s', $operator));
|
app('log')->error(sprintf('No such operator: %s', $operator));
|
||||||
throw new FireflyException(sprintf('Unsupported search operator: "%s"', $operator));
|
throw new FireflyException(sprintf('Unsupported search operator: "%s"', $operator));
|
||||||
// some search operators are ignored, basically:
|
// some search operators are ignored, basically:
|
||||||
case 'user_action':
|
case 'user_action':
|
||||||
app('log')->info(sprintf('Ignore search operator "%s"', $operator));
|
app('log')->info(sprintf('Ignore search operator "%s"', $operator));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
//
|
//
|
||||||
// all account related searches:
|
// all account related searches:
|
||||||
//
|
//
|
||||||
case 'account_is':
|
case 'account_is':
|
||||||
$this->searchAccount($value, 3, 4);
|
$this->searchAccount($value, 3, 4);
|
||||||
break;
|
break;
|
||||||
@@ -502,9 +502,9 @@ class OperatorQuerySearch implements SearchInterface
|
|||||||
$this->collector->findNothing();
|
$this->collector->findNothing();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
//
|
//
|
||||||
// cash account
|
// cash account
|
||||||
//
|
//
|
||||||
case 'source_is_cash':
|
case 'source_is_cash':
|
||||||
$account = $this->getCashAccount();
|
$account = $this->getCashAccount();
|
||||||
$this->collector->setSourceAccounts(new Collection([$account]));
|
$this->collector->setSourceAccounts(new Collection([$account]));
|
||||||
@@ -529,9 +529,9 @@ class OperatorQuerySearch implements SearchInterface
|
|||||||
$account = $this->getCashAccount();
|
$account = $this->getCashAccount();
|
||||||
$this->collector->excludeAccounts(new Collection([$account]));
|
$this->collector->excludeAccounts(new Collection([$account]));
|
||||||
break;
|
break;
|
||||||
//
|
//
|
||||||
// description
|
// description
|
||||||
//
|
//
|
||||||
case 'description_starts':
|
case 'description_starts':
|
||||||
$this->collector->descriptionStarts([$value]);
|
$this->collector->descriptionStarts([$value]);
|
||||||
break;
|
break;
|
||||||
@@ -558,9 +558,9 @@ class OperatorQuerySearch implements SearchInterface
|
|||||||
case '-description_is':
|
case '-description_is':
|
||||||
$this->collector->descriptionIsNot($value);
|
$this->collector->descriptionIsNot($value);
|
||||||
break;
|
break;
|
||||||
//
|
//
|
||||||
// currency
|
// currency
|
||||||
//
|
//
|
||||||
case 'currency_is':
|
case 'currency_is':
|
||||||
$currency = $this->findCurrency($value);
|
$currency = $this->findCurrency($value);
|
||||||
if (null !== $currency) {
|
if (null !== $currency) {
|
||||||
@@ -597,9 +597,9 @@ class OperatorQuerySearch implements SearchInterface
|
|||||||
$this->collector->findNothing();
|
$this->collector->findNothing();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
//
|
//
|
||||||
// attachments
|
// attachments
|
||||||
//
|
//
|
||||||
case 'has_attachments':
|
case 'has_attachments':
|
||||||
case '-has_no_attachments':
|
case '-has_no_attachments':
|
||||||
app('log')->debug('Set collector to filter on attachments.');
|
app('log')->debug('Set collector to filter on attachments.');
|
||||||
@@ -610,8 +610,8 @@ class OperatorQuerySearch implements SearchInterface
|
|||||||
app('log')->debug('Set collector to filter on NO attachments.');
|
app('log')->debug('Set collector to filter on NO attachments.');
|
||||||
$this->collector->hasNoAttachments();
|
$this->collector->hasNoAttachments();
|
||||||
break;
|
break;
|
||||||
//
|
//
|
||||||
// categories
|
// categories
|
||||||
case '-has_any_category':
|
case '-has_any_category':
|
||||||
case 'has_no_category':
|
case 'has_no_category':
|
||||||
$this->collector->withoutCategory();
|
$this->collector->withoutCategory();
|
||||||
@@ -689,9 +689,9 @@ class OperatorQuerySearch implements SearchInterface
|
|||||||
$this->collector->findNothing();
|
$this->collector->findNothing();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
//
|
//
|
||||||
// budgets
|
// budgets
|
||||||
//
|
//
|
||||||
case '-has_any_budget':
|
case '-has_any_budget':
|
||||||
case 'has_no_budget':
|
case 'has_no_budget':
|
||||||
$this->collector->withoutBudget();
|
$this->collector->withoutBudget();
|
||||||
@@ -770,9 +770,9 @@ class OperatorQuerySearch implements SearchInterface
|
|||||||
$this->collector->findNothing();
|
$this->collector->findNothing();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
//
|
//
|
||||||
// bill
|
// bill
|
||||||
//
|
//
|
||||||
case '-has_any_bill':
|
case '-has_any_bill':
|
||||||
case 'has_no_bill':
|
case 'has_no_bill':
|
||||||
$this->collector->withoutBill();
|
$this->collector->withoutBill();
|
||||||
@@ -849,9 +849,9 @@ class OperatorQuerySearch implements SearchInterface
|
|||||||
$this->collector->findNothing();
|
$this->collector->findNothing();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
//
|
//
|
||||||
// tags
|
// tags
|
||||||
//
|
//
|
||||||
case '-has_any_tag':
|
case '-has_any_tag':
|
||||||
case 'has_no_tag':
|
case 'has_no_tag':
|
||||||
$this->collector->withoutTags();
|
$this->collector->withoutTags();
|
||||||
@@ -879,9 +879,9 @@ class OperatorQuerySearch implements SearchInterface
|
|||||||
$this->collector->setWithoutSpecificTags($result);
|
$this->collector->setWithoutSpecificTags($result);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
//
|
//
|
||||||
// notes
|
// notes
|
||||||
//
|
//
|
||||||
case 'notes_contains':
|
case 'notes_contains':
|
||||||
$this->collector->notesContain($value);
|
$this->collector->notesContain($value);
|
||||||
break;
|
break;
|
||||||
@@ -920,9 +920,9 @@ class OperatorQuerySearch implements SearchInterface
|
|||||||
case '-reconciled':
|
case '-reconciled':
|
||||||
$this->collector->isNotReconciled();
|
$this->collector->isNotReconciled();
|
||||||
break;
|
break;
|
||||||
//
|
//
|
||||||
// amount
|
// amount
|
||||||
//
|
//
|
||||||
case 'amount_is':
|
case 'amount_is':
|
||||||
// strip comma's, make dots.
|
// strip comma's, make dots.
|
||||||
app('log')->debug(sprintf('Original value "%s"', $value));
|
app('log')->debug(sprintf('Original value "%s"', $value));
|
||||||
@@ -993,9 +993,9 @@ class OperatorQuerySearch implements SearchInterface
|
|||||||
app('log')->debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount));
|
app('log')->debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount));
|
||||||
$this->collector->foreignAmountMore($amount);
|
$this->collector->foreignAmountMore($amount);
|
||||||
break;
|
break;
|
||||||
//
|
//
|
||||||
// transaction type
|
// transaction type
|
||||||
//
|
//
|
||||||
case 'transaction_type':
|
case 'transaction_type':
|
||||||
$this->collector->setTypes([ucfirst($value)]);
|
$this->collector->setTypes([ucfirst($value)]);
|
||||||
app('log')->debug(sprintf('Set "%s" using collector with value "%s"', $operator, $value));
|
app('log')->debug(sprintf('Set "%s" using collector with value "%s"', $operator, $value));
|
||||||
@@ -1004,9 +1004,9 @@ class OperatorQuerySearch implements SearchInterface
|
|||||||
$this->collector->excludeTypes([ucfirst($value)]);
|
$this->collector->excludeTypes([ucfirst($value)]);
|
||||||
app('log')->debug(sprintf('Set "%s" using collector with value "%s"', $operator, $value));
|
app('log')->debug(sprintf('Set "%s" using collector with value "%s"', $operator, $value));
|
||||||
break;
|
break;
|
||||||
//
|
//
|
||||||
// dates
|
// dates
|
||||||
//
|
//
|
||||||
case '-date_on':
|
case '-date_on':
|
||||||
case 'date_on':
|
case 'date_on':
|
||||||
$range = $this->parseDateRange($operator, $value);
|
$range = $this->parseDateRange($operator, $value);
|
||||||
@@ -1156,9 +1156,9 @@ class OperatorQuerySearch implements SearchInterface
|
|||||||
$range = $this->parseDateRange($operator, $value);
|
$range = $this->parseDateRange($operator, $value);
|
||||||
$this->setObjectDateAfterParams('updated_at', $range);
|
$this->setObjectDateAfterParams('updated_at', $range);
|
||||||
return false;
|
return false;
|
||||||
//
|
//
|
||||||
// external URL
|
// external URL
|
||||||
//
|
//
|
||||||
case '-any_external_url':
|
case '-any_external_url':
|
||||||
case 'no_external_url':
|
case 'no_external_url':
|
||||||
$this->collector->withoutExternalUrl();
|
$this->collector->withoutExternalUrl();
|
||||||
@@ -1201,9 +1201,9 @@ class OperatorQuerySearch implements SearchInterface
|
|||||||
$this->collector->externalUrlDoesNotEnd($value);
|
$this->collector->externalUrlDoesNotEnd($value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//
|
//
|
||||||
// other fields
|
// other fields
|
||||||
//
|
//
|
||||||
case 'external_id_is':
|
case 'external_id_is':
|
||||||
$this->collector->setExternalId($value);
|
$this->collector->setExternalId($value);
|
||||||
break;
|
break;
|
||||||
@@ -1593,43 +1593,59 @@ class OperatorQuerySearch implements SearchInterface
|
|||||||
default:
|
default:
|
||||||
throw new FireflyException(sprintf('Cannot handle key "%s" in setExactParameters()', $key));
|
throw new FireflyException(sprintf('Cannot handle key "%s" in setExactParameters()', $key));
|
||||||
case 'exact':
|
case 'exact':
|
||||||
app('log')->debug(sprintf('Set date_is_exact value "%s"', $value->format('Y-m-d')));
|
if ($value instanceof Carbon) {
|
||||||
$this->collector->setRange($value, $value);
|
app('log')->debug(sprintf('Set date_is_exact value "%s"', $value->format('Y-m-d')));
|
||||||
$this->operators->push(['type' => 'date_on', 'value' => $value->format('Y-m-d'),]);
|
$this->collector->setRange($value, $value);
|
||||||
|
$this->operators->push(['type' => 'date_on', 'value' => $value->format('Y-m-d'),]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'exact_not':
|
case 'exact_not':
|
||||||
$this->collector->excludeRange($value, $value);
|
if ($value instanceof Carbon) {
|
||||||
$this->operators->push(['type' => 'not_date_on', 'value' => $value->format('Y-m-d'),]);
|
$this->collector->excludeRange($value, $value);
|
||||||
|
$this->operators->push(['type' => 'not_date_on', 'value' => $value->format('Y-m-d'),]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'year':
|
case 'year':
|
||||||
app('log')->debug(sprintf('Set date_is_exact YEAR value "%s"', $value));
|
if (is_string($value)) {
|
||||||
$this->collector->yearIs($value);
|
app('log')->debug(sprintf('Set date_is_exact YEAR value "%s"', $value));
|
||||||
$this->operators->push(['type' => 'date_on_year', 'value' => $value,]);
|
$this->collector->yearIs($value);
|
||||||
|
$this->operators->push(['type' => 'date_on_year', 'value' => $value,]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'year_not':
|
case 'year_not':
|
||||||
app('log')->debug(sprintf('Set date_is_exact_not YEAR value "%s"', $value));
|
if (is_string($value)) {
|
||||||
$this->collector->yearIsNot($value);
|
app('log')->debug(sprintf('Set date_is_exact_not YEAR value "%s"', $value));
|
||||||
$this->operators->push(['type' => 'not_date_on_year', 'value' => $value,]);
|
$this->collector->yearIsNot($value);
|
||||||
|
$this->operators->push(['type' => 'not_date_on_year', 'value' => $value,]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'month':
|
case 'month':
|
||||||
app('log')->debug(sprintf('Set date_is_exact MONTH value "%s"', $value));
|
if (is_string($value)) {
|
||||||
$this->collector->monthIs($value);
|
app('log')->debug(sprintf('Set date_is_exact MONTH value "%s"', $value));
|
||||||
$this->operators->push(['type' => 'date_on_month', 'value' => $value,]);
|
$this->collector->monthIs($value);
|
||||||
|
$this->operators->push(['type' => 'date_on_month', 'value' => $value,]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'month_not':
|
case 'month_not':
|
||||||
app('log')->debug(sprintf('Set date_is_exact not MONTH value "%s"', $value));
|
if (is_string($value)) {
|
||||||
$this->collector->monthIsNot($value);
|
app('log')->debug(sprintf('Set date_is_exact not MONTH value "%s"', $value));
|
||||||
$this->operators->push(['type' => 'not_date_on_month', 'value' => $value,]);
|
$this->collector->monthIsNot($value);
|
||||||
|
$this->operators->push(['type' => 'not_date_on_month', 'value' => $value,]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'day':
|
case 'day':
|
||||||
app('log')->debug(sprintf('Set date_is_exact DAY value "%s"', $value));
|
if (is_string($value)) {
|
||||||
$this->collector->dayIs($value);
|
app('log')->debug(sprintf('Set date_is_exact DAY value "%s"', $value));
|
||||||
$this->operators->push(['type' => 'date_on_day', 'value' => $value,]);
|
$this->collector->dayIs($value);
|
||||||
|
$this->operators->push(['type' => 'date_on_day', 'value' => $value,]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'day_not':
|
case 'day_not':
|
||||||
app('log')->debug(sprintf('Set not date_is_exact DAY value "%s"', $value));
|
if (is_string($value)) {
|
||||||
$this->collector->dayIsNot($value);
|
app('log')->debug(sprintf('Set not date_is_exact DAY value "%s"', $value));
|
||||||
$this->operators->push(['type' => 'not_date_on_day', 'value' => $value,]);
|
$this->collector->dayIsNot($value);
|
||||||
|
$this->operators->push(['type' => 'not_date_on_day', 'value' => $value,]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1651,23 +1667,31 @@ class OperatorQuerySearch implements SearchInterface
|
|||||||
default:
|
default:
|
||||||
throw new FireflyException(sprintf('Cannot handle key "%s" in setDateBeforeParams()', $key));
|
throw new FireflyException(sprintf('Cannot handle key "%s" in setDateBeforeParams()', $key));
|
||||||
case 'exact':
|
case 'exact':
|
||||||
$this->collector->setBefore($value);
|
if ($value instanceof Carbon) {
|
||||||
$this->operators->push(['type' => 'date_before', 'value' => $value->format('Y-m-d'),]);
|
$this->collector->setBefore($value);
|
||||||
|
$this->operators->push(['type' => 'date_before', 'value' => $value->format('Y-m-d'),]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'year':
|
case 'year':
|
||||||
app('log')->debug(sprintf('Set date_is_before YEAR value "%s"', $value));
|
if (is_string($value)) {
|
||||||
$this->collector->yearBefore($value);
|
app('log')->debug(sprintf('Set date_is_before YEAR value "%s"', $value));
|
||||||
$this->operators->push(['type' => 'date_before_year', 'value' => $value,]);
|
$this->collector->yearBefore($value);
|
||||||
|
$this->operators->push(['type' => 'date_before_year', 'value' => $value,]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'month':
|
case 'month':
|
||||||
app('log')->debug(sprintf('Set date_is_before MONTH value "%s"', $value));
|
if (is_string($value)) {
|
||||||
$this->collector->monthBefore($value);
|
app('log')->debug(sprintf('Set date_is_before MONTH value "%s"', $value));
|
||||||
$this->operators->push(['type' => 'date_before_month', 'value' => $value,]);
|
$this->collector->monthBefore($value);
|
||||||
|
$this->operators->push(['type' => 'date_before_month', 'value' => $value,]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'day':
|
case 'day':
|
||||||
app('log')->debug(sprintf('Set date_is_before DAY value "%s"', $value));
|
if (is_string($value)) {
|
||||||
$this->collector->dayBefore($value);
|
app('log')->debug(sprintf('Set date_is_before DAY value "%s"', $value));
|
||||||
$this->operators->push(['type' => 'date_before_day', 'value' => $value,]);
|
$this->collector->dayBefore($value);
|
||||||
|
$this->operators->push(['type' => 'date_before_day', 'value' => $value,]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1689,23 +1713,31 @@ class OperatorQuerySearch implements SearchInterface
|
|||||||
default:
|
default:
|
||||||
throw new FireflyException(sprintf('Cannot handle key "%s" in setDateAfterParams()', $key));
|
throw new FireflyException(sprintf('Cannot handle key "%s" in setDateAfterParams()', $key));
|
||||||
case 'exact':
|
case 'exact':
|
||||||
$this->collector->setAfter($value);
|
if ($value instanceof Carbon) {
|
||||||
$this->operators->push(['type' => 'date_after', 'value' => $value->format('Y-m-d'),]);
|
$this->collector->setAfter($value);
|
||||||
|
$this->operators->push(['type' => 'date_after', 'value' => $value->format('Y-m-d'),]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'year':
|
case 'year':
|
||||||
app('log')->debug(sprintf('Set date_is_after YEAR value "%s"', $value));
|
if (is_string($value)) {
|
||||||
$this->collector->yearAfter($value);
|
app('log')->debug(sprintf('Set date_is_after YEAR value "%s"', $value));
|
||||||
$this->operators->push(['type' => 'date_after_year', 'value' => $value,]);
|
$this->collector->yearAfter($value);
|
||||||
|
$this->operators->push(['type' => 'date_after_year', 'value' => $value,]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'month':
|
case 'month':
|
||||||
app('log')->debug(sprintf('Set date_is_after MONTH value "%s"', $value));
|
if (is_string($value)) {
|
||||||
$this->collector->monthAfter($value);
|
app('log')->debug(sprintf('Set date_is_after MONTH value "%s"', $value));
|
||||||
$this->operators->push(['type' => 'date_after_month', 'value' => $value,]);
|
$this->collector->monthAfter($value);
|
||||||
|
$this->operators->push(['type' => 'date_after_month', 'value' => $value,]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'day':
|
case 'day':
|
||||||
app('log')->debug(sprintf('Set date_is_after DAY value "%s"', $value));
|
if (is_string($value)) {
|
||||||
$this->collector->dayAfter($value);
|
app('log')->debug(sprintf('Set date_is_after DAY value "%s"', $value));
|
||||||
$this->operators->push(['type' => 'date_after_day', 'value' => $value,]);
|
$this->collector->dayAfter($value);
|
||||||
|
$this->operators->push(['type' => 'date_after_day', 'value' => $value,]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1727,44 +1759,60 @@ class OperatorQuerySearch implements SearchInterface
|
|||||||
default:
|
default:
|
||||||
throw new FireflyException(sprintf('Cannot handle key "%s" in setExactMetaDateParams()', $key));
|
throw new FireflyException(sprintf('Cannot handle key "%s" in setExactMetaDateParams()', $key));
|
||||||
case 'exact':
|
case 'exact':
|
||||||
app('log')->debug(sprintf('Set %s_is_exact value "%s"', $field, $value->format('Y-m-d')));
|
if ($value instanceof Carbon) {
|
||||||
$this->collector->setMetaDateRange($value, $value, $field);
|
app('log')->debug(sprintf('Set %s_is_exact value "%s"', $field, $value->format('Y-m-d')));
|
||||||
$this->operators->push(['type' => sprintf('%s_on', $field), 'value' => $value->format('Y-m-d'),]);
|
$this->collector->setMetaDateRange($value, $value, $field);
|
||||||
|
$this->operators->push(['type' => sprintf('%s_on', $field), 'value' => $value->format('Y-m-d'),]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'exact_not':
|
case 'exact_not':
|
||||||
app('log')->debug(sprintf('Set NOT %s_is_exact value "%s"', $field, $value->format('Y-m-d')));
|
if ($value instanceof Carbon) {
|
||||||
$this->collector->excludeMetaDateRange($value, $value, $field);
|
app('log')->debug(sprintf('Set NOT %s_is_exact value "%s"', $field, $value->format('Y-m-d')));
|
||||||
$this->operators->push(['type' => sprintf('not_%s_on', $field), 'value' => $value->format('Y-m-d'),]);
|
$this->collector->excludeMetaDateRange($value, $value, $field);
|
||||||
|
$this->operators->push(['type' => sprintf('not_%s_on', $field), 'value' => $value->format('Y-m-d'),]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'year':
|
case 'year':
|
||||||
app('log')->debug(sprintf('Set %s_is_exact YEAR value "%s"', $field, $value));
|
if (is_string($value)) {
|
||||||
$this->collector->metaYearIs($value, $field);
|
app('log')->debug(sprintf('Set %s_is_exact YEAR value "%s"', $field, $value));
|
||||||
$this->operators->push(['type' => sprintf('%s_on_year', $field), 'value' => $value,]);
|
$this->collector->metaYearIs($value, $field);
|
||||||
|
$this->operators->push(['type' => sprintf('%s_on_year', $field), 'value' => $value,]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'year_not':
|
case 'year_not':
|
||||||
app('log')->debug(sprintf('Set NOT %s_is_exact YEAR value "%s"', $field, $value));
|
if (is_string($value)) {
|
||||||
$this->collector->metaYearIsNot($value, $field);
|
app('log')->debug(sprintf('Set NOT %s_is_exact YEAR value "%s"', $field, $value));
|
||||||
$this->operators->push(['type' => sprintf('not_%s_on_year', $field), 'value' => $value,]);
|
$this->collector->metaYearIsNot($value, $field);
|
||||||
|
$this->operators->push(['type' => sprintf('not_%s_on_year', $field), 'value' => $value,]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'month':
|
case 'month':
|
||||||
app('log')->debug(sprintf('Set %s_is_exact MONTH value "%s"', $field, $value));
|
if (is_string($value)) {
|
||||||
$this->collector->metaMonthIs($value, $field);
|
app('log')->debug(sprintf('Set %s_is_exact MONTH value "%s"', $field, $value));
|
||||||
$this->operators->push(['type' => sprintf('%s_on_month', $field), 'value' => $value,]);
|
$this->collector->metaMonthIs($value, $field);
|
||||||
|
$this->operators->push(['type' => sprintf('%s_on_month', $field), 'value' => $value,]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'month_not':
|
case 'month_not':
|
||||||
app('log')->debug(sprintf('Set NOT %s_is_exact MONTH value "%s"', $field, $value));
|
if (is_string($value)) {
|
||||||
$this->collector->metaMonthIsNot($value, $field);
|
app('log')->debug(sprintf('Set NOT %s_is_exact MONTH value "%s"', $field, $value));
|
||||||
$this->operators->push(['type' => sprintf('not_%s_on_month', $field), 'value' => $value,]);
|
$this->collector->metaMonthIsNot($value, $field);
|
||||||
|
$this->operators->push(['type' => sprintf('not_%s_on_month', $field), 'value' => $value,]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'day':
|
case 'day':
|
||||||
app('log')->debug(sprintf('Set %s_is_exact DAY value "%s"', $field, $value));
|
if (is_string($value)) {
|
||||||
$this->collector->metaDayIs($value, $field);
|
app('log')->debug(sprintf('Set %s_is_exact DAY value "%s"', $field, $value));
|
||||||
$this->operators->push(['type' => sprintf('%s_on_day', $field), 'value' => $value,]);
|
$this->collector->metaDayIs($value, $field);
|
||||||
|
$this->operators->push(['type' => sprintf('%s_on_day', $field), 'value' => $value,]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'day_not':
|
case 'day_not':
|
||||||
app('log')->debug(sprintf('Set NOT %s_is_exact DAY value "%s"', $field, $value));
|
if (is_string($value)) {
|
||||||
$this->collector->metaDayIsNot($value, $field);
|
app('log')->debug(sprintf('Set NOT %s_is_exact DAY value "%s"', $field, $value));
|
||||||
$this->operators->push(['type' => sprintf('not_%s_on_day', $field), 'value' => $value,]);
|
$this->collector->metaDayIsNot($value, $field);
|
||||||
|
$this->operators->push(['type' => sprintf('not_%s_on_day', $field), 'value' => $value,]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1785,23 +1833,31 @@ class OperatorQuerySearch implements SearchInterface
|
|||||||
default:
|
default:
|
||||||
throw new FireflyException(sprintf('Cannot handle key "%s" in setMetaDateBeforeParams()', $key));
|
throw new FireflyException(sprintf('Cannot handle key "%s" in setMetaDateBeforeParams()', $key));
|
||||||
case 'exact':
|
case 'exact':
|
||||||
$this->collector->setMetaBefore($value, $field);
|
if ($value instanceof Carbon) {
|
||||||
$this->operators->push(['type' => sprintf('%s_before', $field), 'value' => $value->format('Y-m-d'),]);
|
$this->collector->setMetaBefore($value, $field);
|
||||||
|
$this->operators->push(['type' => sprintf('%s_before', $field), 'value' => $value->format('Y-m-d'),]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'year':
|
case 'year':
|
||||||
app('log')->debug(sprintf('Set %s_is_before YEAR value "%s"', $field, $value));
|
if (is_string($value)) {
|
||||||
$this->collector->metaYearBefore($value, $field);
|
app('log')->debug(sprintf('Set %s_is_before YEAR value "%s"', $field, $value));
|
||||||
$this->operators->push(['type' => sprintf('%s_before_year', $field), 'value' => $value,]);
|
$this->collector->metaYearBefore($value, $field);
|
||||||
|
$this->operators->push(['type' => sprintf('%s_before_year', $field), 'value' => $value,]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'month':
|
case 'month':
|
||||||
app('log')->debug(sprintf('Set %s_is_before MONTH value "%s"', $field, $value));
|
if (is_string($value)) {
|
||||||
$this->collector->metaMonthBefore($value, $field);
|
app('log')->debug(sprintf('Set %s_is_before MONTH value "%s"', $field, $value));
|
||||||
$this->operators->push(['type' => sprintf('%s_before_month', $field), 'value' => $value,]);
|
$this->collector->metaMonthBefore($value, $field);
|
||||||
|
$this->operators->push(['type' => sprintf('%s_before_month', $field), 'value' => $value,]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'day':
|
case 'day':
|
||||||
app('log')->debug(sprintf('Set %s_is_before DAY value "%s"', $field, $value));
|
if (is_string($value)) {
|
||||||
$this->collector->metaDayBefore($value, $field);
|
app('log')->debug(sprintf('Set %s_is_before DAY value "%s"', $field, $value));
|
||||||
$this->operators->push(['type' => sprintf('%s_before_day', $field), 'value' => $value,]);
|
$this->collector->metaDayBefore($value, $field);
|
||||||
|
$this->operators->push(['type' => sprintf('%s_before_day', $field), 'value' => $value,]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1822,23 +1878,31 @@ class OperatorQuerySearch implements SearchInterface
|
|||||||
default:
|
default:
|
||||||
throw new FireflyException(sprintf('Cannot handle key "%s" in setMetaDateAfterParams()', $key));
|
throw new FireflyException(sprintf('Cannot handle key "%s" in setMetaDateAfterParams()', $key));
|
||||||
case 'exact':
|
case 'exact':
|
||||||
$this->collector->setMetaAfter($value, $field);
|
if ($value instanceof Carbon) {
|
||||||
$this->operators->push(['type' => sprintf('%s_after', $field), 'value' => $value->format('Y-m-d'),]);
|
$this->collector->setMetaAfter($value, $field);
|
||||||
|
$this->operators->push(['type' => sprintf('%s_after', $field), 'value' => $value->format('Y-m-d'),]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'year':
|
case 'year':
|
||||||
app('log')->debug(sprintf('Set %s_is_after YEAR value "%s"', $field, $value));
|
if (is_string($value)) {
|
||||||
$this->collector->metaYearAfter($value, $field);
|
app('log')->debug(sprintf('Set %s_is_after YEAR value "%s"', $field, $value));
|
||||||
$this->operators->push(['type' => sprintf('%s_after_year', $field), 'value' => $value,]);
|
$this->collector->metaYearAfter($value, $field);
|
||||||
|
$this->operators->push(['type' => sprintf('%s_after_year', $field), 'value' => $value,]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'month':
|
case 'month':
|
||||||
app('log')->debug(sprintf('Set %s_is_after MONTH value "%s"', $field, $value));
|
if (is_string($value)) {
|
||||||
$this->collector->metaMonthAfter($value, $field);
|
app('log')->debug(sprintf('Set %s_is_after MONTH value "%s"', $field, $value));
|
||||||
$this->operators->push(['type' => sprintf('%s_after_month', $field), 'value' => $value,]);
|
$this->collector->metaMonthAfter($value, $field);
|
||||||
|
$this->operators->push(['type' => sprintf('%s_after_month', $field), 'value' => $value,]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'day':
|
case 'day':
|
||||||
app('log')->debug(sprintf('Set %s_is_after DAY value "%s"', $field, $value));
|
if (is_string($value)) {
|
||||||
$this->collector->metaDayAfter($value, $field);
|
app('log')->debug(sprintf('Set %s_is_after DAY value "%s"', $field, $value));
|
||||||
$this->operators->push(['type' => sprintf('%s_after_day', $field), 'value' => $value,]);
|
$this->collector->metaDayAfter($value, $field);
|
||||||
|
$this->operators->push(['type' => sprintf('%s_after_day', $field), 'value' => $value,]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1859,44 +1923,60 @@ class OperatorQuerySearch implements SearchInterface
|
|||||||
default:
|
default:
|
||||||
throw new FireflyException(sprintf('Cannot handle key "%s" in setExactObjectDateParams()', $key));
|
throw new FireflyException(sprintf('Cannot handle key "%s" in setExactObjectDateParams()', $key));
|
||||||
case 'exact':
|
case 'exact':
|
||||||
app('log')->debug(sprintf('Set %s_is_exact value "%s"', $field, $value->format('Y-m-d')));
|
if ($value instanceof Carbon) {
|
||||||
$this->collector->setObjectRange($value, clone $value, $field);
|
app('log')->debug(sprintf('Set %s_is_exact value "%s"', $field, $value->format('Y-m-d')));
|
||||||
$this->operators->push(['type' => sprintf('%s_on', $field), 'value' => $value->format('Y-m-d'),]);
|
$this->collector->setObjectRange($value, clone $value, $field);
|
||||||
|
$this->operators->push(['type' => sprintf('%s_on', $field), 'value' => $value->format('Y-m-d'),]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'exact_not':
|
case 'exact_not':
|
||||||
app('log')->debug(sprintf('Set NOT %s_is_exact value "%s"', $field, $value->format('Y-m-d')));
|
if ($value instanceof Carbon) {
|
||||||
$this->collector->excludeObjectRange($value, clone $value, $field);
|
app('log')->debug(sprintf('Set NOT %s_is_exact value "%s"', $field, $value->format('Y-m-d')));
|
||||||
$this->operators->push(['type' => sprintf('not_%s_on', $field), 'value' => $value->format('Y-m-d'),]);
|
$this->collector->excludeObjectRange($value, clone $value, $field);
|
||||||
|
$this->operators->push(['type' => sprintf('not_%s_on', $field), 'value' => $value->format('Y-m-d'),]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'year':
|
case 'year':
|
||||||
app('log')->debug(sprintf('Set %s_is_exact YEAR value "%s"', $field, $value));
|
if (is_string($value)) {
|
||||||
$this->collector->objectYearIs($value, $field);
|
app('log')->debug(sprintf('Set %s_is_exact YEAR value "%s"', $field, $value));
|
||||||
$this->operators->push(['type' => sprintf('%s_on_year', $field), 'value' => $value,]);
|
$this->collector->objectYearIs($value, $field);
|
||||||
|
$this->operators->push(['type' => sprintf('%s_on_year', $field), 'value' => $value,]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'year_not':
|
case 'year_not':
|
||||||
app('log')->debug(sprintf('Set NOT %s_is_exact YEAR value "%s"', $field, $value));
|
if (is_string($value)) {
|
||||||
$this->collector->objectYearIsNot($value, $field);
|
app('log')->debug(sprintf('Set NOT %s_is_exact YEAR value "%s"', $field, $value));
|
||||||
$this->operators->push(['type' => sprintf('not_%s_on_year', $field), 'value' => $value,]);
|
$this->collector->objectYearIsNot($value, $field);
|
||||||
|
$this->operators->push(['type' => sprintf('not_%s_on_year', $field), 'value' => $value,]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'month':
|
case 'month':
|
||||||
app('log')->debug(sprintf('Set %s_is_exact MONTH value "%s"', $field, $value));
|
if (is_string($value)) {
|
||||||
$this->collector->objectMonthIs($value, $field);
|
app('log')->debug(sprintf('Set %s_is_exact MONTH value "%s"', $field, $value));
|
||||||
$this->operators->push(['type' => sprintf('%s_on_month', $field), 'value' => $value,]);
|
$this->collector->objectMonthIs($value, $field);
|
||||||
|
$this->operators->push(['type' => sprintf('%s_on_month', $field), 'value' => $value,]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'month_not':
|
case 'month_not':
|
||||||
app('log')->debug(sprintf('Set NOT %s_is_exact MONTH value "%s"', $field, $value));
|
if (is_string($value)) {
|
||||||
$this->collector->objectMonthIsNot($value, $field);
|
app('log')->debug(sprintf('Set NOT %s_is_exact MONTH value "%s"', $field, $value));
|
||||||
$this->operators->push(['type' => sprintf('not_%s_on_month', $field), 'value' => $value,]);
|
$this->collector->objectMonthIsNot($value, $field);
|
||||||
|
$this->operators->push(['type' => sprintf('not_%s_on_month', $field), 'value' => $value,]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'day':
|
case 'day':
|
||||||
app('log')->debug(sprintf('Set %s_is_exact DAY value "%s"', $field, $value));
|
if (is_string($value)) {
|
||||||
$this->collector->objectDayIs($value, $field);
|
app('log')->debug(sprintf('Set %s_is_exact DAY value "%s"', $field, $value));
|
||||||
$this->operators->push(['type' => sprintf('%s_on_day', $field), 'value' => $value,]);
|
$this->collector->objectDayIs($value, $field);
|
||||||
|
$this->operators->push(['type' => sprintf('%s_on_day', $field), 'value' => $value,]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'day_not':
|
case 'day_not':
|
||||||
app('log')->debug(sprintf('Set NOT %s_is_exact DAY value "%s"', $field, $value));
|
if (is_string($value)) {
|
||||||
$this->collector->objectDayIsNot($value, $field);
|
app('log')->debug(sprintf('Set NOT %s_is_exact DAY value "%s"', $field, $value));
|
||||||
$this->operators->push(['type' => sprintf('not_%s_on_day', $field), 'value' => $value,]);
|
$this->collector->objectDayIsNot($value, $field);
|
||||||
|
$this->operators->push(['type' => sprintf('not_%s_on_day', $field), 'value' => $value,]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1918,23 +1998,31 @@ class OperatorQuerySearch implements SearchInterface
|
|||||||
default:
|
default:
|
||||||
throw new FireflyException(sprintf('Cannot handle key "%s" in setObjectDateBeforeParams()', $key));
|
throw new FireflyException(sprintf('Cannot handle key "%s" in setObjectDateBeforeParams()', $key));
|
||||||
case 'exact':
|
case 'exact':
|
||||||
$this->collector->setObjectBefore($value, $field);
|
if ($value instanceof Carbon) {
|
||||||
$this->operators->push(['type' => sprintf('%s_before', $field), 'value' => $value->format('Y-m-d'),]);
|
$this->collector->setObjectBefore($value, $field);
|
||||||
|
$this->operators->push(['type' => sprintf('%s_before', $field), 'value' => $value->format('Y-m-d'),]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'year':
|
case 'year':
|
||||||
app('log')->debug(sprintf('Set date_is_before YEAR value "%s"', $value));
|
if (is_string($value)) {
|
||||||
$this->collector->objectYearBefore($value, $field);
|
app('log')->debug(sprintf('Set date_is_before YEAR value "%s"', $value));
|
||||||
$this->operators->push(['type' => sprintf('%s_before_year', $field), 'value' => $value,]);
|
$this->collector->objectYearBefore($value, $field);
|
||||||
|
$this->operators->push(['type' => sprintf('%s_before_year', $field), 'value' => $value,]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'month':
|
case 'month':
|
||||||
app('log')->debug(sprintf('Set date_is_before MONTH value "%s"', $value));
|
if (is_string($value)) {
|
||||||
$this->collector->objectMonthBefore($value, $field);
|
app('log')->debug(sprintf('Set date_is_before MONTH value "%s"', $value));
|
||||||
$this->operators->push(['type' => sprintf('%s_before_month', $field), 'value' => $value,]);
|
$this->collector->objectMonthBefore($value, $field);
|
||||||
|
$this->operators->push(['type' => sprintf('%s_before_month', $field), 'value' => $value,]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'day':
|
case 'day':
|
||||||
app('log')->debug(sprintf('Set date_is_before DAY value "%s"', $value));
|
if (is_string($value)) {
|
||||||
$this->collector->objectDayBefore($value, $field);
|
app('log')->debug(sprintf('Set date_is_before DAY value "%s"', $value));
|
||||||
$this->operators->push(['type' => sprintf('%s_before_day', $field), 'value' => $value,]);
|
$this->collector->objectDayBefore($value, $field);
|
||||||
|
$this->operators->push(['type' => sprintf('%s_before_day', $field), 'value' => $value,]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1956,23 +2044,31 @@ class OperatorQuerySearch implements SearchInterface
|
|||||||
default:
|
default:
|
||||||
throw new FireflyException(sprintf('Cannot handle key "%s" in setObjectDateAfterParams()', $key));
|
throw new FireflyException(sprintf('Cannot handle key "%s" in setObjectDateAfterParams()', $key));
|
||||||
case 'exact':
|
case 'exact':
|
||||||
$this->collector->setObjectAfter($value, $field);
|
if ($value instanceof Carbon) {
|
||||||
$this->operators->push(['type' => sprintf('%s_after', $field), 'value' => $value->format('Y-m-d'),]);
|
$this->collector->setObjectAfter($value, $field);
|
||||||
|
$this->operators->push(['type' => sprintf('%s_after', $field), 'value' => $value->format('Y-m-d'),]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'year':
|
case 'year':
|
||||||
app('log')->debug(sprintf('Set date_is_after YEAR value "%s"', $value));
|
if (is_string($value)) {
|
||||||
$this->collector->objectYearAfter($value, $field);
|
app('log')->debug(sprintf('Set date_is_after YEAR value "%s"', $value));
|
||||||
$this->operators->push(['type' => sprintf('%s_after_year', $field), 'value' => $value,]);
|
$this->collector->objectYearAfter($value, $field);
|
||||||
|
$this->operators->push(['type' => sprintf('%s_after_year', $field), 'value' => $value,]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'month':
|
case 'month':
|
||||||
app('log')->debug(sprintf('Set date_is_after MONTH value "%s"', $value));
|
if (is_string($value)) {
|
||||||
$this->collector->objectMonthAfter($value, $field);
|
app('log')->debug(sprintf('Set date_is_after MONTH value "%s"', $value));
|
||||||
$this->operators->push(['type' => sprintf('%s_after_month', $field), 'value' => $value,]);
|
$this->collector->objectMonthAfter($value, $field);
|
||||||
|
$this->operators->push(['type' => sprintf('%s_after_month', $field), 'value' => $value,]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'day':
|
case 'day':
|
||||||
app('log')->debug(sprintf('Set date_is_after DAY value "%s"', $value));
|
if (is_string($value)) {
|
||||||
$this->collector->objectDayAfter($value, $field);
|
app('log')->debug(sprintf('Set date_is_after DAY value "%s"', $value));
|
||||||
$this->operators->push(['type' => sprintf('%s_after_day', $field), 'value' => $value,]);
|
$this->collector->objectDayAfter($value, $field);
|
||||||
|
$this->operators->push(['type' => sprintf('%s_after_day', $field), 'value' => $value,]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -152,7 +152,7 @@ class Steam
|
|||||||
->orderBy('transaction_journals.date', 'ASC')
|
->orderBy('transaction_journals.date', 'ASC')
|
||||||
->whereNull('transaction_journals.deleted_at')
|
->whereNull('transaction_journals.deleted_at')
|
||||||
->get(
|
->get(
|
||||||
[
|
[ // @phpstan-ignore-line
|
||||||
'transaction_journals.date',
|
'transaction_journals.date',
|
||||||
'transactions.transaction_currency_id',
|
'transactions.transaction_currency_id',
|
||||||
DB::raw('SUM(transactions.amount) AS modified'),
|
DB::raw('SUM(transactions.amount) AS modified'),
|
||||||
@@ -295,7 +295,10 @@ class Steam
|
|||||||
$currentBalance = $startBalance;
|
$currentBalance = $startBalance;
|
||||||
/** @var Transaction $transaction */
|
/** @var Transaction $transaction */
|
||||||
foreach ($set as $transaction) {
|
foreach ($set as $transaction) {
|
||||||
$day = Carbon::createFromFormat('Y-m-d H:i:s', $transaction['date'], config('app.timezone'));
|
$day = Carbon::createFromFormat('Y-m-d H:i:s', $transaction['date'], config('app.timezone'));
|
||||||
|
if (false === $day) {
|
||||||
|
$day = today(config('app.timezone'));
|
||||||
|
}
|
||||||
$format = $day->format('Y-m-d');
|
$format = $day->format('Y-m-d');
|
||||||
// if the transaction is in the expected currency, change nothing.
|
// if the transaction is in the expected currency, change nothing.
|
||||||
if ((int)$transaction['transaction_currency_id'] === $native->id) {
|
if ((int)$transaction['transaction_currency_id'] === $native->id) {
|
||||||
@@ -449,6 +452,9 @@ class Steam
|
|||||||
foreach ($new as $index => $set) {
|
foreach ($new as $index => $set) {
|
||||||
foreach ($set as $transaction) {
|
foreach ($set as $transaction) {
|
||||||
$date = Carbon::createFromFormat('Y-m-d H:i:s', $transaction['date']);
|
$date = Carbon::createFromFormat('Y-m-d H:i:s', $transaction['date']);
|
||||||
|
if(false === $date) {
|
||||||
|
$date = today(config('app.timezone'));
|
||||||
|
}
|
||||||
$rate = $converter->getCurrencyRate($currency, $native, $date);
|
$rate = $converter->getCurrencyRate($currency, $native, $date);
|
||||||
$convertedAmount = bcmul($transaction['amount'], $rate);
|
$convertedAmount = bcmul($transaction['amount'], $rate);
|
||||||
$balance = bcadd($balance, $convertedAmount);
|
$balance = bcadd($balance, $convertedAmount);
|
||||||
@@ -598,7 +604,7 @@ class Steam
|
|||||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||||
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
||||||
->groupBy('transactions.transaction_currency_id');
|
->groupBy('transactions.transaction_currency_id');
|
||||||
$balances = $query->get(['transactions.transaction_currency_id', DB::raw('SUM(transactions.amount) as sum_for_currency')]);
|
$balances = $query->get(['transactions.transaction_currency_id', DB::raw('SUM(transactions.amount) as sum_for_currency')]); // @phpstan-ignore-line
|
||||||
$return = [];
|
$return = [];
|
||||||
/** @var stdClass $entry */
|
/** @var stdClass $entry */
|
||||||
foreach ($balances as $entry) {
|
foreach ($balances as $entry) {
|
||||||
@@ -717,7 +723,7 @@ class Steam
|
|||||||
} catch (Exception $e) { // intentional generic exception
|
} catch (Exception $e) { // intentional generic exception
|
||||||
throw new FireflyException($e->getMessage(), 0, $e);
|
throw new FireflyException($e->getMessage(), 0, $e);
|
||||||
}
|
}
|
||||||
return $hostName;
|
return (string)$hostName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -732,7 +738,7 @@ class Steam
|
|||||||
$set = auth()->user()->transactions()
|
$set = auth()->user()->transactions()
|
||||||
->whereIn('transactions.account_id', $accounts)
|
->whereIn('transactions.account_id', $accounts)
|
||||||
->groupBy(['transactions.account_id', 'transaction_journals.user_id'])
|
->groupBy(['transactions.account_id', 'transaction_journals.user_id'])
|
||||||
->get(['transactions.account_id', DB::raw('MAX(transaction_journals.date) AS max_date')]);
|
->get(['transactions.account_id', DB::raw('MAX(transaction_journals.date) AS max_date')]); // @phpstan-ignore-line
|
||||||
|
|
||||||
/** @var Transaction $entry */
|
/** @var Transaction $entry */
|
||||||
foreach ($set as $entry) {
|
foreach ($set as $entry) {
|
||||||
@@ -755,9 +761,14 @@ class Steam
|
|||||||
public function getLocale(): string // get preference
|
public function getLocale(): string // get preference
|
||||||
{
|
{
|
||||||
$locale = app('preferences')->get('locale', config('firefly.default_locale', 'equal'))->data;
|
$locale = app('preferences')->get('locale', config('firefly.default_locale', 'equal'))->data;
|
||||||
|
if (is_array($locale)) {
|
||||||
|
$locale = 'equal';
|
||||||
|
}
|
||||||
if ('equal' === $locale) {
|
if ('equal' === $locale) {
|
||||||
$locale = $this->getLanguage();
|
$locale = $this->getLanguage();
|
||||||
}
|
}
|
||||||
|
$locale = (string)$locale;
|
||||||
|
|
||||||
|
|
||||||
// Check for Windows to replace the locale correctly.
|
// Check for Windows to replace the locale correctly.
|
||||||
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
|
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
|
||||||
@@ -879,10 +890,10 @@ class Steam
|
|||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
$number = substr($value, 0, strpos($value, 'E'));
|
$number = substr($value, 0, (int) strpos($value, 'E'));
|
||||||
if (str_contains($number, '.')) {
|
if (str_contains($number, '.')) {
|
||||||
$post = strlen(substr($number, strpos($number, '.') + 1));
|
$post = strlen(substr($number, (int) strpos($number, '.') + 1));
|
||||||
$mantis = substr($value, strpos($value, 'E') + 1);
|
$mantis = substr($value, (int) strpos($value, 'E') + 1);
|
||||||
if ($mantis < 0) {
|
if ($mantis < 0) {
|
||||||
$post += abs((int)$mantis);
|
$post += abs((int)$mantis);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user