Merge branch 'develop' into adminlte4

# Conflicts:
#	composer.lock
#	yarn.lock
This commit is contained in:
James Cole
2023-07-21 18:26:19 +02:00
223 changed files with 2577 additions and 1772 deletions

View File

@@ -379,16 +379,16 @@
},
{
"name": "friendsofphp/php-cs-fixer",
"version": "v3.21.1",
"version": "v3.22.0",
"source": {
"type": "git",
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
"reference": "229b55b3eae4729a8e2a321441ba40fcb3720b86"
"reference": "92b019f6c8d79aa26349d0db7671d37440dc0ff3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/229b55b3eae4729a8e2a321441ba40fcb3720b86",
"reference": "229b55b3eae4729a8e2a321441ba40fcb3720b86",
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/92b019f6c8d79aa26349d0db7671d37440dc0ff3",
"reference": "92b019f6c8d79aa26349d0db7671d37440dc0ff3",
"shasum": ""
},
"require": {
@@ -398,7 +398,7 @@
"doctrine/lexer": "^2 || ^3",
"ext-json": "*",
"ext-tokenizer": "*",
"php": "^8.0.1",
"php": "^7.4 || ^8.0",
"sebastian/diff": "^4.0 || ^5.0",
"symfony/console": "^5.4 || ^6.0",
"symfony/event-dispatcher": "^5.4 || ^6.0",
@@ -412,6 +412,7 @@
"symfony/stopwatch": "^5.4 || ^6.0"
},
"require-dev": {
"facile-it/paraunit": "^1.3 || ^2.0",
"justinrainbow/json-schema": "^5.2",
"keradus/cli-executor": "^2.0",
"mikey179/vfsstream": "^1.6.11",
@@ -463,7 +464,7 @@
],
"support": {
"issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.21.1"
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.22.0"
},
"funding": [
{
@@ -471,7 +472,7 @@
"type": "github"
}
],
"time": "2023-07-05T21:50:25+00:00"
"time": "2023-07-16T23:08:06+00:00"
},
{
"name": "psr/cache",

View File

@@ -1,4 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ phpmd.xml
~ Copyright (c) 2023 james@firefly-iii.org
~
~ This file is part of Firefly III (https://github.com/firefly-iii).
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU Affero General Public License as
~ published by the Free Software Foundation, either version 3 of the
~ License, or (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU Affero General Public License for more details.
~
~ You should have received a copy of the GNU Affero General Public License
~ along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
<ruleset name="pcsg-generated-ruleset"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

View File

@@ -63,7 +63,7 @@ class PurgeController extends Controller
// piggies
$set = PiggyBank::leftJoin('accounts', 'accounts.id', 'piggy_banks.account_id')
->where('accounts.user_id', $user->id)->onlyTrashed()->get(['piggy_banks.*']);
->where('accounts.user_id', $user->id)->onlyTrashed()->get(['piggy_banks.*']);
/** @var PiggyBank $piggy */
foreach ($set as $piggy) {
$piggy->forceDelete();

View File

@@ -43,7 +43,7 @@ class CronController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/about/getCron
*
* @param CronRequest $request
* @param string $token
* @param string $token
*
* @return JsonResponse
* @throws ContainerExceptionInterface

View File

@@ -1,6 +1,6 @@
<?php
declare(strict_types=1);
/*
* ShowController.php
* Copyright (c) 2023 james@firefly-iii.org
@@ -21,6 +21,8 @@ declare(strict_types=1);
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Api\V2\Controllers\Model\Budget;
use FireflyIII\Api\V2\Controllers\Controller;

View File

@@ -126,6 +126,7 @@ class CorrectOpeningBalanceCurrencies extends Command
/**
* @param Account $account
* @param TransactionJournal $journal
*
* @return int
*/
private function setCorrectCurrency(Account $account, TransactionJournal $journal): int

View File

@@ -1,5 +1,26 @@
<?php
/*
* TriggerCreditCalculation.php
* Copyright (c) 2023 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Console\Commands\Correction;

View File

@@ -75,6 +75,7 @@ class UpdateGroupInformation extends Command
/**
* @param User $user
*
* @return void
*/
private function updateGroupInfo(User $user): void

View File

@@ -1,6 +1,6 @@
<?php
declare(strict_types=1);
/*
* ShowsFriendlyMessages.php
* Copyright (c) 2023 james@firefly-iii.org
@@ -21,6 +21,8 @@ declare(strict_types=1);
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Console\Commands;
/**
@@ -30,6 +32,7 @@ trait ShowsFriendlyMessages
{
/**
* @param string $message
*
* @return void
*/
public function friendlyError(string $message): void
@@ -39,6 +42,7 @@ trait ShowsFriendlyMessages
/**
* @param string $message
*
* @return void
*/
public function friendlyInfo(string $message): void
@@ -48,6 +52,7 @@ trait ShowsFriendlyMessages
/**
* @param string $message
*
* @return void
*/
public function friendlyNeutral(string $message): void
@@ -57,6 +62,7 @@ trait ShowsFriendlyMessages
/**
* @param string $message
*
* @return void
*/
public function friendlyLine(string $message): void
@@ -66,6 +72,7 @@ trait ShowsFriendlyMessages
/**
* @param string $message
*
* @return void
*/
public function friendlyPositive(string $message): void
@@ -75,6 +82,7 @@ trait ShowsFriendlyMessages
/**
* @param string $message
*
* @return void
*/
public function friendlyWarning(string $message): void

View File

@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Console\Commands\Upgrade;
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\BudgetLimit;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;

View File

@@ -25,7 +25,6 @@ namespace FireflyIII\Console\Commands\Upgrade;
use DB;
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Budget;
use FireflyIII\Models\Category;
use FireflyIII\Models\Transaction;

View File

@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Console\Commands\Upgrade;
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Note;
use FireflyIII\Models\TransactionJournalMeta;
use Illuminate\Console\Command;

View File

@@ -25,7 +25,6 @@ declare(strict_types=1);
namespace FireflyIII\Console\Commands\Upgrade;
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Recurrence;
use FireflyIII\Models\RecurrenceMeta;
use FireflyIII\Models\RecurrenceTransactionMeta;

View File

@@ -25,7 +25,6 @@ declare(strict_types=1);
namespace FireflyIII\Console\Commands\Upgrade;
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Recurrence;
use FireflyIII\Models\RecurrenceTransaction;
use FireflyIII\Models\TransactionType;
@@ -103,6 +102,7 @@ class MigrateRecurrenceType extends Command
/**
* @param Recurrence $recurrence
*
* @return void
*/
private function migrateRecurrence(Recurrence $recurrence): void

View File

@@ -25,7 +25,6 @@ declare(strict_types=1);
namespace FireflyIII\Console\Commands\Upgrade;
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Location;
use FireflyIII\Models\Tag;
use Illuminate\Console\Command;

View File

@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Console\Commands\Upgrade;
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\Transaction;

View File

@@ -25,7 +25,6 @@ declare(strict_types=1);
namespace FireflyIII\Console\Commands\Upgrade;
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Factory\AccountMetaFactory;
use FireflyIII\Models\Account;
use FireflyIII\Models\Transaction;

View File

@@ -25,7 +25,6 @@ declare(strict_types=1);
namespace FireflyIII\Console\Commands\Upgrade;
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\Transaction;

View File

@@ -1,6 +1,6 @@
<?php
declare(strict_types=1);
/*
* Created.php
* Copyright (c) 2023 james@firefly-iii.org
@@ -21,6 +21,8 @@ declare(strict_types=1);
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Events\Model\BudgetLimit;
use FireflyIII\Events\Event;

View File

@@ -1,8 +1,8 @@
<?php
declare(strict_types=1);
/*
* Created.php
* Deleted.php
* Copyright (c) 2023 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
@@ -21,6 +21,8 @@ declare(strict_types=1);
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Events\Model\BudgetLimit;
use FireflyIII\Events\Event;

View File

@@ -1,8 +1,8 @@
<?php
declare(strict_types=1);
/*
* Created.php
* Updated.php
* Copyright (c) 2023 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
@@ -21,6 +21,8 @@ declare(strict_types=1);
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Events\Model\BudgetLimit;
use FireflyIII\Events\Event;

View File

@@ -416,6 +416,7 @@ class TransactionJournalFactory
/**
* @param Account|null $sourceAccount
* @param Account|null $destinationAccount
*
* @return array
*/
private function reconciliationSanityCheck(?Account $sourceAccount, ?Account $destinationAccount): array
@@ -457,7 +458,7 @@ class TransactionJournalFactory
Log::debug('Now in getCurrencyByAccount()');
return match ($type) {
default => $this->getCurrency($currency, $source),
default => $this->getCurrency($currency, $source),
TransactionType::DEPOSIT => $this->getCurrency($currency, $destination),
};
}

View File

@@ -58,6 +58,7 @@ interface MessageGeneratorInterface
/**
* @param Collection $webhooks
*
* @return void
*/
public function setWebhooks(Collection $webhooks): void;

View File

@@ -103,6 +103,7 @@ class StandardMessageGenerator implements MessageGeneratorInterface
/**
* @param Webhook $webhook
*
* @throws FireflyException
* @throws JsonException
*/
@@ -118,6 +119,7 @@ class StandardMessageGenerator implements MessageGeneratorInterface
/**
* @param Webhook $webhook
* @param Model $model
*
* @throws FireflyException
* @throws JsonException
*/

View File

@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Handlers\Events;
use Exception;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Notifications\User\NewAccessToken;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Support\Facades\Log;

View File

@@ -42,6 +42,7 @@ class AdminEventHandler
{
/**
* @param InvitationCreated $event
*
* @return void
*/
public function sendInvitationNotification(InvitationCreated $event): void
@@ -79,6 +80,7 @@ class AdminEventHandler
* Send new version message to admin.
*
* @param NewVersionAvailable $event
*
* @return void
*/
public function sendNewVersion(NewVersionAvailable $event): void

View File

@@ -42,6 +42,7 @@ class AutomationHandler
* Respond to the creation of X journals.
*
* @param RequestedReportOnJournals $event
*
* @throws FireflyException
*/
public function reportJournals(RequestedReportOnJournals $event): void

View File

@@ -38,6 +38,7 @@ class BillEventHandler
{
/**
* @param WarnUserAboutBill $event
*
* @return void
*/
public function warnAboutBill(WarnUserAboutBill $event): void

View File

@@ -1,6 +1,6 @@
<?php
declare(strict_types=1);
/*
* BudgetLimitHandler.php
* Copyright (c) 2023 james@firefly-iii.org
@@ -21,6 +21,8 @@ declare(strict_types=1);
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Handlers\Events\Model;
use FireflyIII\Events\Model\BudgetLimit\Created;
@@ -44,6 +46,7 @@ class BudgetLimitHandler
{
/**
* @param Created $event
*
* @return void
*/
public function created(Created $event): void
@@ -54,6 +57,7 @@ class BudgetLimitHandler
/**
* @param BudgetLimit $budgetLimit
*
* @return void
*/
private function updateAvailableBudget(BudgetLimit $budgetLimit): void
@@ -73,7 +77,11 @@ class BudgetLimitHandler
$end = app('navigation')->endOfPeriod($end, $viewRange);
$budget = Budget::find($budgetLimit->budget_id);
if (null === $budget) {
Log::warning('Budget is null, cannot continue.');
Log::warning('Budget is null, probably deleted, find deleted version.');
$budget = Budget::withTrashed()->find($budgetLimit->budget_id);
}
if (null === $budget) {
Log::warning('Budget is still null, cannot continue, will delete budget limit.');
$budgetLimit->forceDelete();
return;
}
@@ -140,6 +148,7 @@ class BudgetLimitHandler
/**
* @param AvailableBudget $availableBudget
*
* @return void
*/
private function calculateAmount(AvailableBudget $availableBudget): void
@@ -205,6 +214,7 @@ class BudgetLimitHandler
/**
* @param BudgetLimit $budgetLimit
*
* @return string
*/
private function getDailyAmount(BudgetLimit $budgetLimit): string
@@ -228,6 +238,7 @@ class BudgetLimitHandler
/**
* @param Deleted $event
*
* @return void
*/
public function deleted(Deleted $event): void
@@ -240,6 +251,7 @@ class BudgetLimitHandler
/**
* @param Updated $event
*
* @return void
*/
public function updated(Updated $event): void

View File

@@ -329,6 +329,7 @@ class UserEventHandler
/**
* @param InvitationCreated $event
*
* @return void
* @throws FireflyException
*/
@@ -376,6 +377,7 @@ class UserEventHandler
/**
* @param ActuallyLoggedIn $event
*
* @throws FireflyException
*/
public function storeUserIPAddress(ActuallyLoggedIn $event): void

View File

@@ -38,6 +38,7 @@ trait AttachmentCollection
{
/**
* @param string $name
*
* @return GroupCollectorInterface
*/
public function attachmentNameContains(string $name): GroupCollectorInterface
@@ -116,6 +117,7 @@ trait AttachmentCollection
/**
* @param string $name
*
* @return GroupCollectorInterface
*/
public function attachmentNameDoesNotContain(string $name): GroupCollectorInterface
@@ -145,6 +147,7 @@ trait AttachmentCollection
/**
* @param string $name
*
* @return GroupCollectorInterface
*/
public function attachmentNameDoesNotEnd(string $name): GroupCollectorInterface
@@ -174,6 +177,7 @@ trait AttachmentCollection
/**
* @param string $name
*
* @return GroupCollectorInterface
*/
public function attachmentNameDoesNotStart(string $name): GroupCollectorInterface
@@ -203,6 +207,7 @@ trait AttachmentCollection
/**
* @param string $name
*
* @return GroupCollectorInterface
*/
public function attachmentNameEnds(string $name): GroupCollectorInterface
@@ -232,6 +237,7 @@ trait AttachmentCollection
/**
* @param string $name
*
* @return GroupCollectorInterface
*/
public function attachmentNameIs(string $name): GroupCollectorInterface
@@ -258,6 +264,7 @@ trait AttachmentCollection
/**
* @param string $name
*
* @return GroupCollectorInterface
*/
public function attachmentNameIsNot(string $name): GroupCollectorInterface
@@ -284,6 +291,7 @@ trait AttachmentCollection
/**
* @param string $name
*
* @return GroupCollectorInterface
*/
public function attachmentNameStarts(string $name): GroupCollectorInterface
@@ -313,6 +321,7 @@ trait AttachmentCollection
/**
* @param string $value
*
* @return GroupCollectorInterface
*/
public function attachmentNotesAre(string $value): GroupCollectorInterface
@@ -339,6 +348,7 @@ trait AttachmentCollection
/**
* @param string $value
*
* @return GroupCollectorInterface
*/
public function attachmentNotesAreNot(string $value): GroupCollectorInterface
@@ -365,6 +375,7 @@ trait AttachmentCollection
/**
* @param string $value
*
* @return GroupCollectorInterface
*/
public function attachmentNotesContains(string $value): GroupCollectorInterface
@@ -391,6 +402,7 @@ trait AttachmentCollection
/**
* @param string $value
*
* @return GroupCollectorInterface
*/
public function attachmentNotesDoNotContain(string $value): GroupCollectorInterface
@@ -417,6 +429,7 @@ trait AttachmentCollection
/**
* @param string $value
*
* @return GroupCollectorInterface
*/
public function attachmentNotesDoNotEnd(string $value): GroupCollectorInterface
@@ -443,6 +456,7 @@ trait AttachmentCollection
/**
* @param string $value
*
* @return GroupCollectorInterface
*/
public function attachmentNotesDoNotStart(string $value): GroupCollectorInterface
@@ -469,6 +483,7 @@ trait AttachmentCollection
/**
* @param string $value
*
* @return GroupCollectorInterface
*/
public function attachmentNotesEnds(string $value): GroupCollectorInterface
@@ -495,6 +510,7 @@ trait AttachmentCollection
/**
* @param string $value
*
* @return GroupCollectorInterface
*/
public function attachmentNotesStarts(string $value): GroupCollectorInterface

View File

@@ -33,6 +33,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
trait CollectorProperties
{
public const TEST = 'Test';
private bool $expandGroupSearch;
private array $fields;
private bool $hasAccountInfo;
private bool $hasBillInformation;

View File

@@ -64,8 +64,8 @@ trait MetaCollection
// 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->fields[] = 'bills.id as bill_id';
$this->fields[] = 'bills.name as bill_name';
$this->hasBillInformation = true;
}
@@ -104,8 +104,8 @@ trait MetaCollection
// 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->fields[] = 'budgets.id as budget_id';
$this->fields[] = 'budgets.name as budget_name';
$this->hasBudgetInformation = true;
}
@@ -157,8 +157,8 @@ trait MetaCollection
// 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->fields[] = 'categories.id as category_id';
$this->fields[] = 'categories.name as category_name';
$this->hasCatInformation = true;
}
@@ -226,8 +226,10 @@ trait MetaCollection
*/
public function excludeInternalReference(string $internalReference): GroupCollectorInterface
{
$this->joinMetaDataTables();
$internalReference = json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'internal_reference');
$this->query->where('journal_meta.data', 'NOT LIKE', sprintf('%%%s%%', $internalReference));
@@ -251,6 +253,9 @@ trait MetaCollection
*/
public function externalIdContains(string $externalId): GroupCollectorInterface
{
$externalId = json_encode($externalId);
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
$this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'external_id');
$this->query->where('journal_meta.data', 'LIKE', sprintf('%%%s%%', $externalId));
@@ -263,6 +268,9 @@ trait MetaCollection
*/
public function externalIdDoesNotContain(string $externalId): GroupCollectorInterface
{
$externalId = json_encode($externalId);
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
$this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'external_id');
$this->query->where('journal_meta.data', 'NOT LIKE', sprintf('%%%s%%', $externalId));
@@ -275,6 +283,9 @@ trait MetaCollection
*/
public function externalIdDoesNotEnd(string $externalId): GroupCollectorInterface
{
$externalId = json_encode($externalId);
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
$this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'external_id');
$this->query->where('journal_meta.data', 'NOT LIKE', sprintf('%%%s"', $externalId));
@@ -287,6 +298,9 @@ trait MetaCollection
*/
public function externalIdDoesNotStart(string $externalId): GroupCollectorInterface
{
$externalId = json_encode($externalId);
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
$this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'external_id');
$this->query->where('journal_meta.data', 'LIKE', sprintf('"%s%%', $externalId));
@@ -299,6 +313,9 @@ trait MetaCollection
*/
public function externalIdEnds(string $externalId): GroupCollectorInterface
{
$externalId = json_encode($externalId);
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
$this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'external_id');
$this->query->where('journal_meta.data', 'LIKE', sprintf('%%%s"', $externalId));
@@ -311,6 +328,9 @@ trait MetaCollection
*/
public function externalIdStarts(string $externalId): GroupCollectorInterface
{
$externalId = json_encode($externalId);
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
$this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'external_id');
$this->query->where('journal_meta.data', 'LIKE', sprintf('"%s%%', $externalId));
@@ -320,6 +340,7 @@ trait MetaCollection
/**
* @param string $url
*
* @return GroupCollectorInterface
*/
public function externalUrlContains(string $url): GroupCollectorInterface
@@ -335,6 +356,7 @@ trait MetaCollection
/**
* @param string $url
*
* @return GroupCollectorInterface
*/
public function externalUrlDoesNotContain(string $url): GroupCollectorInterface
@@ -350,6 +372,7 @@ trait MetaCollection
/**
* @param string $url
*
* @return GroupCollectorInterface
*/
public function externalUrlDoesNotEnd(string $url): GroupCollectorInterface
@@ -365,6 +388,7 @@ trait MetaCollection
/**
* @param string $url
*
* @return GroupCollectorInterface
*/
public function externalUrlDoesNotStart(string $url): GroupCollectorInterface
@@ -382,6 +406,7 @@ trait MetaCollection
/**
* @param string $url
*
* @return GroupCollectorInterface
*/
public function externalUrlEnds(string $url): GroupCollectorInterface
@@ -397,6 +422,7 @@ trait MetaCollection
/**
* @param string $url
*
* @return GroupCollectorInterface
*/
public function externalUrlStarts(string $url): GroupCollectorInterface
@@ -459,11 +485,16 @@ trait MetaCollection
/**
* @inheritDoc
*/
public function internalReferenceContains(string $externalId): GroupCollectorInterface
public function internalReferenceContains(string $internalReference): GroupCollectorInterface
{
$internalReference = json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
//var_dump($internalReference);
//exit;
$this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'internal_reference');
$this->query->where('journal_meta.data', 'LIKE', sprintf('%%%s%%', $externalId));
$this->query->where('journal_meta.data', 'LIKE', sprintf('%%%s%%', $internalReference));
return $this;
}
@@ -471,11 +502,14 @@ trait MetaCollection
/**
* @inheritDoc
*/
public function internalReferenceDoesNotContain(string $externalId): GroupCollectorInterface
public function internalReferenceDoesNotContain(string $internalReference): GroupCollectorInterface
{
$internalReference = json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'internal_reference');
$this->query->where('journal_meta.data', 'NOT LIKE', sprintf('%%%s%%', $externalId));
$this->query->where('journal_meta.data', 'NOT LIKE', sprintf('%%%s%%', $internalReference));
return $this;
}
@@ -483,11 +517,14 @@ trait MetaCollection
/**
* @inheritDoc
*/
public function internalReferenceDoesNotEnd(string $externalId): GroupCollectorInterface
public function internalReferenceDoesNotEnd(string $internalReference): GroupCollectorInterface
{
$internalReference = json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'internal_reference');
$this->query->where('journal_meta.data', 'NOT LIKE', sprintf('%%%s"', $externalId));
$this->query->where('journal_meta.data', 'NOT LIKE', sprintf('%%%s"', $internalReference));
return $this;
}
@@ -495,11 +532,14 @@ trait MetaCollection
/**
* @inheritDoc
*/
public function internalReferenceDoesNotStart(string $externalId): GroupCollectorInterface
public function internalReferenceDoesNotStart(string $internalReference): GroupCollectorInterface
{
$internalReference = json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'internal_reference');
$this->query->where('journal_meta.data', 'LIKE', sprintf('"%s%%', $externalId));
$this->query->where('journal_meta.data', 'LIKE', sprintf('"%s%%', $internalReference));
return $this;
}
@@ -507,11 +547,14 @@ trait MetaCollection
/**
* @inheritDoc
*/
public function internalReferenceEnds(string $externalId): GroupCollectorInterface
public function internalReferenceEnds(string $internalReference): GroupCollectorInterface
{
$internalReference = json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'internal_reference');
$this->query->where('journal_meta.data', 'LIKE', sprintf('%%%s"', $externalId));
$this->query->where('journal_meta.data', 'LIKE', sprintf('%%%s"', $internalReference));
return $this;
}
@@ -519,11 +562,14 @@ trait MetaCollection
/**
* @inheritDoc
*/
public function internalReferenceStarts(string $externalId): GroupCollectorInterface
public function internalReferenceStarts(string $internalReference): GroupCollectorInterface
{
$internalReference = json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'internal_reference');
$this->query->where('journal_meta.data', 'LIKE', sprintf('"%s%%', $externalId));
$this->query->where('journal_meta.data', 'LIKE', sprintf('"%s%%', $internalReference));
return $this;
}
@@ -557,7 +603,7 @@ trait MetaCollection
}
);
// add fields
$this->fields[] = 'notes.text as notes';
$this->fields[] = 'notes.text as notes';
$this->hasNotesInformation = true;
}
@@ -790,8 +836,10 @@ trait MetaCollection
*/
public function setInternalReference(string $internalReference): GroupCollectorInterface
{
$this->joinMetaDataTables();
$internalReference = json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'internal_reference');
$this->query->where('journal_meta.data', 'LIKE', sprintf('%%%s%%', $internalReference));
@@ -865,8 +913,8 @@ trait MetaCollection
$this->withTagInformation();
// this method adds a "postFilter" to the collector.
$list = $tags->pluck('tag')->toArray();
$filter = function (int $index, array $object) use ($list): bool {
$list = $tags->pluck('tag')->toArray();
$filter = function (int $index, array $object) use ($list): bool {
foreach ($object['transactions'] as $transaction) {
foreach ($transaction['tags'] as $tag) {
if (in_array($tag['name'], $list, true)) {

View File

@@ -34,6 +34,7 @@ trait TimeCollection
{
/**
* @param string $day
*
* @return GroupCollectorInterface
*/
public function dayAfter(string $day): GroupCollectorInterface
@@ -44,6 +45,7 @@ trait TimeCollection
/**
* @param string $day
*
* @return GroupCollectorInterface
*/
public function dayBefore(string $day): GroupCollectorInterface
@@ -54,6 +56,7 @@ trait TimeCollection
/**
* @param string $day
*
* @return GroupCollectorInterface
*/
public function dayIs(string $day): GroupCollectorInterface
@@ -64,6 +67,7 @@ trait TimeCollection
/**
* @param string $day
*
* @return GroupCollectorInterface
*/
public function dayIsNot(string $day): GroupCollectorInterface
@@ -76,6 +80,7 @@ trait TimeCollection
* @param Carbon $start
* @param Carbon $end
* @param string $field
*
* @return GroupCollectorInterface
*/
public function excludeMetaDateRange(Carbon $start, Carbon $end, string $field): GroupCollectorInterface
@@ -118,6 +123,7 @@ trait TimeCollection
* @param Carbon $start
* @param Carbon $end
* @param string $field
*
* @return GroupCollectorInterface
*/
public function excludeObjectRange(Carbon $start, Carbon $end, string $field): GroupCollectorInterface
@@ -134,6 +140,7 @@ trait TimeCollection
/**
* @param Carbon $start
* @param Carbon $end
*
* @return GroupCollectorInterface
*/
public function excludeRange(Carbon $start, Carbon $end): GroupCollectorInterface
@@ -153,6 +160,7 @@ trait TimeCollection
/**
* @param string $day
* @param string $field
*
* @return GroupCollectorInterface
*/
public function metaDayAfter(string $day, string $field): GroupCollectorInterface
@@ -176,6 +184,7 @@ trait TimeCollection
/**
* @param string $day
* @param string $field
*
* @return GroupCollectorInterface
*/
public function metaDayBefore(string $day, string $field): GroupCollectorInterface
@@ -199,6 +208,7 @@ trait TimeCollection
/**
* @param string $day
* @param string $field
*
* @return GroupCollectorInterface
*/
public function metaDayIs(string $day, string $field): GroupCollectorInterface
@@ -221,6 +231,7 @@ trait TimeCollection
/**
* @param string $day
* @param string $field
*
* @return GroupCollectorInterface
*/
public function metaDayIsNot(string $day, string $field): GroupCollectorInterface
@@ -243,6 +254,7 @@ trait TimeCollection
/**
* @param string $month
* @param string $field
*
* @return GroupCollectorInterface
*/
public function metaMonthAfter(string $month, string $field): GroupCollectorInterface
@@ -266,6 +278,7 @@ trait TimeCollection
/**
* @param string $month
* @param string $field
*
* @return GroupCollectorInterface
*/
public function metaMonthBefore(string $month, string $field): GroupCollectorInterface
@@ -289,6 +302,7 @@ trait TimeCollection
/**
* @param string $month
* @param string $field
*
* @return GroupCollectorInterface
*/
public function metaMonthIs(string $month, string $field): GroupCollectorInterface
@@ -311,6 +325,7 @@ trait TimeCollection
/**
* @param string $month
* @param string $field
*
* @return GroupCollectorInterface
*/
public function metaMonthIsNot(string $month, string $field): GroupCollectorInterface
@@ -333,6 +348,7 @@ trait TimeCollection
/**
* @param string $year
* @param string $field
*
* @return GroupCollectorInterface
*/
public function metaYearAfter(string $year, string $field): GroupCollectorInterface
@@ -356,6 +372,7 @@ trait TimeCollection
/**
* @param string $year
* @param string $field
*
* @return GroupCollectorInterface
*/
public function metaYearBefore(string $year, string $field): GroupCollectorInterface
@@ -379,6 +396,7 @@ trait TimeCollection
/**
* @param string $year
* @param string $field
*
* @return GroupCollectorInterface
*/
public function metaYearIs(string $year, string $field): GroupCollectorInterface
@@ -402,6 +420,7 @@ trait TimeCollection
/**
* @param string $year
* @param string $field
*
* @return GroupCollectorInterface
*/
public function metaYearIsNot(string $year, string $field): GroupCollectorInterface
@@ -423,6 +442,7 @@ trait TimeCollection
/**
* @param string $month
*
* @return GroupCollectorInterface
*/
public function monthAfter(string $month): GroupCollectorInterface
@@ -433,6 +453,7 @@ trait TimeCollection
/**
* @param string $month
*
* @return GroupCollectorInterface
*/
public function monthBefore(string $month): GroupCollectorInterface
@@ -443,6 +464,7 @@ trait TimeCollection
/**
* @param string $month
*
* @return GroupCollectorInterface
*/
public function monthIs(string $month): GroupCollectorInterface
@@ -453,6 +475,7 @@ trait TimeCollection
/**
* @param string $month
*
* @return GroupCollectorInterface
*/
public function monthIsNot(string $month): GroupCollectorInterface
@@ -464,6 +487,7 @@ trait TimeCollection
/**
* @param string $day
* @param string $field
*
* @return GroupCollectorInterface
*/
public function objectDayAfter(string $day, string $field): GroupCollectorInterface
@@ -475,6 +499,7 @@ trait TimeCollection
/**
* @param string $day
* @param string $field
*
* @return GroupCollectorInterface
*/
public function objectDayBefore(string $day, string $field): GroupCollectorInterface
@@ -486,6 +511,7 @@ trait TimeCollection
/**
* @param string $day
* @param string $field
*
* @return GroupCollectorInterface
*/
public function objectDayIs(string $day, string $field): GroupCollectorInterface
@@ -497,6 +523,7 @@ trait TimeCollection
/**
* @param string $day
* @param string $field
*
* @return GroupCollectorInterface
*/
public function objectDayIsNot(string $day, string $field): GroupCollectorInterface
@@ -508,6 +535,7 @@ trait TimeCollection
/**
* @param string $month
* @param string $field
*
* @return GroupCollectorInterface
*/
public function objectMonthAfter(string $month, string $field): GroupCollectorInterface
@@ -519,6 +547,7 @@ trait TimeCollection
/**
* @param string $month
* @param string $field
*
* @return GroupCollectorInterface
*/
public function objectMonthBefore(string $month, string $field): GroupCollectorInterface
@@ -530,6 +559,7 @@ trait TimeCollection
/**
* @param string $month
* @param string $field
*
* @return GroupCollectorInterface
*/
public function objectMonthIs(string $month, string $field): GroupCollectorInterface
@@ -541,6 +571,7 @@ trait TimeCollection
/**
* @param string $month
* @param string $field
*
* @return GroupCollectorInterface
*/
public function objectMonthIsNot(string $month, string $field): GroupCollectorInterface
@@ -552,6 +583,7 @@ trait TimeCollection
/**
* @param string $year
* @param string $field
*
* @return GroupCollectorInterface
*/
public function objectYearAfter(string $year, string $field): GroupCollectorInterface
@@ -563,6 +595,7 @@ trait TimeCollection
/**
* @param string $year
* @param string $field
*
* @return GroupCollectorInterface
*/
public function objectYearBefore(string $year, string $field): GroupCollectorInterface
@@ -574,6 +607,7 @@ trait TimeCollection
/**
* @param string $year
* @param string $field
*
* @return GroupCollectorInterface
*/
public function objectYearIs(string $year, string $field): GroupCollectorInterface
@@ -585,6 +619,7 @@ trait TimeCollection
/**
* @param string $year
* @param string $field
*
* @return GroupCollectorInterface
*/
public function objectYearIsNot(string $year, string $field): GroupCollectorInterface
@@ -643,6 +678,7 @@ trait TimeCollection
/**
* @param Carbon $date
* @param string $field
*
* @return GroupCollectorInterface
*/
public function setMetaAfter(Carbon $date, string $field): GroupCollectorInterface
@@ -667,6 +703,7 @@ trait TimeCollection
/**
* @param Carbon $date
* @param string $field
*
* @return GroupCollectorInterface
*/
public function setMetaBefore(Carbon $date, string $field): GroupCollectorInterface
@@ -691,6 +728,7 @@ trait TimeCollection
* @param Carbon $start
* @param Carbon $end
* @param string $field
*
* @return GroupCollectorInterface
*/
public function setMetaDateRange(Carbon $start, Carbon $end, string $field): GroupCollectorInterface
@@ -720,6 +758,7 @@ trait TimeCollection
/**
* @param Carbon $date
* @param string $field
*
* @return GroupCollectorInterface
*/
public function setObjectAfter(Carbon $date, string $field): GroupCollectorInterface
@@ -733,6 +772,7 @@ trait TimeCollection
/**
* @param Carbon $date
* @param string $field
*
* @return GroupCollectorInterface
*/
public function setObjectBefore(Carbon $date, string $field): GroupCollectorInterface
@@ -746,6 +786,7 @@ trait TimeCollection
* @param Carbon $start
* @param Carbon $end
* @param string $field
*
* @return GroupCollectorInterface
*/
public function setObjectRange(Carbon $start, Carbon $end, string $field): GroupCollectorInterface
@@ -800,6 +841,7 @@ trait TimeCollection
/**
* @param string $year
*
* @return GroupCollectorInterface
*/
public function yearAfter(string $year): GroupCollectorInterface
@@ -810,6 +852,7 @@ trait TimeCollection
/**
* @param string $year
*
* @return GroupCollectorInterface
*/
public function yearBefore(string $year): GroupCollectorInterface
@@ -820,6 +863,7 @@ trait TimeCollection
/**
* @param string $year
*
* @return GroupCollectorInterface
*/
public function yearIs(string $year): GroupCollectorInterface
@@ -830,6 +874,7 @@ trait TimeCollection
/**
* @param string $year
*
* @return GroupCollectorInterface
*/
public function yearIsNot(string $year): GroupCollectorInterface

View File

@@ -76,6 +76,7 @@ class GroupCollector implements GroupCollectorInterface
$this->hasNotesInformation = false;
$this->hasJoinedTagTables = false;
$this->hasJoinedAttTables = false;
$this->expandGroupSearch = false;
$this->hasJoinedMetaTables = false;
$this->integerFields = [
'transaction_group_id',
@@ -454,6 +455,14 @@ class GroupCollector implements GroupCollectorInterface
return $this;
}
/**
* @return bool
*/
public function getExpandGroupSearch(): bool
{
return $this->expandGroupSearch;
}
/**
* Return the transaction journals without group information. Is useful in some instances.
*
@@ -480,10 +489,16 @@ class GroupCollector implements GroupCollectorInterface
* Return the groups.
*
* @return Collection
* @throws FireflyException
*/
public function getGroups(): Collection
{
if ($this->expandGroupSearch) {
// get group ID's for the query:
$groupIds = $this->getCollectedGroupIds();
// add to query:
$this->query->orWhereIn('transaction_journals.transaction_group_id', $groupIds);
}
$result = $this->query->get($this->fields);
// now to parse this into an array.
@@ -505,6 +520,14 @@ class GroupCollector implements GroupCollectorInterface
return $collection;
}
/**
* @return array
*/
private function getCollectedGroupIds(): array
{
return $this->query->get(['transaction_journals.transaction_group_id'])->pluck('transaction_group_id')->toArray();
}
/**
* @param Collection $collection
*
@@ -516,7 +539,7 @@ class GroupCollector implements GroupCollectorInterface
$groups = [];
/** @var TransactionJournal $augumentedJournal */
foreach ($collection as $augumentedJournal) {
$groupId = $augumentedJournal->transaction_group_id;
$groupId = (int)$augumentedJournal->transaction_group_id;
if (!array_key_exists($groupId, $groups)) {
// make new array
@@ -664,6 +687,7 @@ class GroupCollector implements GroupCollectorInterface
/**
* @param array $array
*
* @return array
*/
private function convertToStrings(array $array): array
@@ -772,6 +796,7 @@ class GroupCollector implements GroupCollectorInterface
/**
* @param Collection $collection
*
* @return Collection
*/
private function postFilterCollection(Collection $collection): Collection
@@ -869,6 +894,14 @@ class GroupCollector implements GroupCollectorInterface
return $this;
}
/**
* @param bool $expandGroupSearch
*/
public function setExpandGroupSearch(bool $expandGroupSearch): void
{
$this->expandGroupSearch = $expandGroupSearch;
}
/**
* @inheritDoc
*/

View File

@@ -75,120 +75,140 @@ interface GroupCollectorInterface
/**
* @param string $name
*
* @return GroupCollectorInterface
*/
public function attachmentNameContains(string $name): GroupCollectorInterface;
/**
* @param string $name
*
* @return GroupCollectorInterface
*/
public function attachmentNameDoesNotContain(string $name): GroupCollectorInterface;
/**
* @param string $name
*
* @return GroupCollectorInterface
*/
public function attachmentNameDoesNotEnd(string $name): GroupCollectorInterface;
/**
* @param string $name
*
* @return GroupCollectorInterface
*/
public function attachmentNameDoesNotStart(string $name): GroupCollectorInterface;
/**
* @param string $name
*
* @return GroupCollectorInterface
*/
public function attachmentNameEnds(string $name): GroupCollectorInterface;
/**
* @param string $name
*
* @return GroupCollectorInterface
*/
public function attachmentNameIs(string $name): GroupCollectorInterface;
/**
* @param string $name
*
* @return GroupCollectorInterface
*/
public function attachmentNameIsNot(string $name): GroupCollectorInterface;
/**
* @param string $name
*
* @return GroupCollectorInterface
*/
public function attachmentNameStarts(string $name): GroupCollectorInterface;
/**
* @param string $value
*
* @return GroupCollectorInterface
*/
public function attachmentNotesAre(string $value): GroupCollectorInterface;
/**
* @param string $value
*
* @return GroupCollectorInterface
*/
public function attachmentNotesAreNot(string $value): GroupCollectorInterface;
/**
* @param string $value
*
* @return GroupCollectorInterface
*/
public function attachmentNotesContains(string $value): GroupCollectorInterface;
/**
* @param string $value
*
* @return GroupCollectorInterface
*/
public function attachmentNotesDoNotContain(string $value): GroupCollectorInterface;
/**
* @param string $value
*
* @return GroupCollectorInterface
*/
public function attachmentNotesDoNotEnd(string $value): GroupCollectorInterface;
/**
* @param string $value
*
* @return GroupCollectorInterface
*/
public function attachmentNotesDoNotStart(string $value): GroupCollectorInterface;
/**
* @param string $value
*
* @return GroupCollectorInterface
*/
public function attachmentNotesEnds(string $value): GroupCollectorInterface;
/**
* @param string $value
*
* @return GroupCollectorInterface
*/
public function attachmentNotesStarts(string $value): GroupCollectorInterface;
/**
* @param string $day
*
* @return GroupCollectorInterface
*/
public function dayAfter(string $day): GroupCollectorInterface;
/**
* @param string $day
*
* @return GroupCollectorInterface
*/
public function dayBefore(string $day): GroupCollectorInterface;
/**
* @param string $day
*
* @return GroupCollectorInterface
*/
public function dayIs(string $day): GroupCollectorInterface;
/**
* @param string $day
*
* @return GroupCollectorInterface
*/
public function dayIsNot(string $day): GroupCollectorInterface;
@@ -287,6 +307,7 @@ interface GroupCollectorInterface
* Exclude a set of categories.
*
* @param Collection $categories
*
* @return GroupCollectorInterface
*/
public function excludeCategories(Collection $categories): GroupCollectorInterface;
@@ -329,6 +350,7 @@ interface GroupCollectorInterface
/**
* @param string $url
*
* @return GroupCollectorInterface
*/
public function excludeExternalUrl(string $url): GroupCollectorInterface;
@@ -354,11 +376,11 @@ interface GroupCollectorInterface
/**
* Look for specific external ID's.
*
* @param string $externalId
* @param string $internalReference
*
* @return GroupCollectorInterface
*/
public function excludeInternalReference(string $externalId): GroupCollectorInterface;
public function excludeInternalReference(string $internalReference): GroupCollectorInterface;
/**
* Limit the result to NOT a set of specific transaction journals.
@@ -373,6 +395,7 @@ interface GroupCollectorInterface
* @param Carbon $start
* @param Carbon $end
* @param string $field
*
* @return GroupCollectorInterface
*/
public function excludeMetaDateRange(Carbon $start, Carbon $end, string $field): GroupCollectorInterface;
@@ -381,6 +404,7 @@ interface GroupCollectorInterface
* @param Carbon $start
* @param Carbon $end
* @param string $field
*
* @return GroupCollectorInterface
*/
public function excludeObjectRange(Carbon $start, Carbon $end, string $field): GroupCollectorInterface;
@@ -388,6 +412,7 @@ interface GroupCollectorInterface
/**
* @param Carbon $start
* @param Carbon $end
*
* @return GroupCollectorInterface
*/
public function excludeRange(Carbon $start, Carbon $end): GroupCollectorInterface;
@@ -433,72 +458,84 @@ interface GroupCollectorInterface
/**
* @param string $externalId
*
* @return GroupCollectorInterface
*/
public function externalIdContains(string $externalId): GroupCollectorInterface;
/**
* @param string $externalId
*
* @return GroupCollectorInterface
*/
public function externalIdDoesNotContain(string $externalId): GroupCollectorInterface;
/**
* @param string $externalId
*
* @return GroupCollectorInterface
*/
public function externalIdDoesNotEnd(string $externalId): GroupCollectorInterface;
/**
* @param string $externalId
*
* @return GroupCollectorInterface
*/
public function externalIdDoesNotStart(string $externalId): GroupCollectorInterface;
/**
* @param string $externalId
*
* @return GroupCollectorInterface
*/
public function externalIdEnds(string $externalId): GroupCollectorInterface;
/**
* @param string $externalId
*
* @return GroupCollectorInterface
*/
public function externalIdStarts(string $externalId): GroupCollectorInterface;
/**
* @param string $url
*
* @return GroupCollectorInterface
*/
public function externalUrlContains(string $url): GroupCollectorInterface;
/**
* @param string $url
*
* @return GroupCollectorInterface
*/
public function externalUrlDoesNotContain(string $url): GroupCollectorInterface;
/**
* @param string $url
*
* @return GroupCollectorInterface
*/
public function externalUrlDoesNotEnd(string $url): GroupCollectorInterface;
/**
* @param string $url
*
* @return GroupCollectorInterface
*/
public function externalUrlDoesNotStart(string $url): GroupCollectorInterface;
/**
* @param string $url
*
* @return GroupCollectorInterface
*/
public function externalUrlEnds(string $url): GroupCollectorInterface;
/**
* @param string $url
*
* @return GroupCollectorInterface
*/
public function externalUrlStarts(string $url): GroupCollectorInterface;
@@ -546,6 +583,11 @@ interface GroupCollectorInterface
*/
public function foreignAmountMore(string $amount): GroupCollectorInterface;
/**
* @return bool
*/
public function getExpandGroupSearch(): bool;
/**
* Return the transaction journals without group information. Is useful in some instances.
*
@@ -587,40 +629,46 @@ interface GroupCollectorInterface
public function hasNoAttachments(): GroupCollectorInterface;
/**
* @param string $externalId
* @param string $internalReference
*
* @return GroupCollectorInterface
*/
public function internalReferenceContains(string $externalId): GroupCollectorInterface;
public function internalReferenceContains(string $internalReference): GroupCollectorInterface;
/**
* @param string $externalId
* @param string $internalReference
*
* @return GroupCollectorInterface
*/
public function internalReferenceDoesNotContain(string $externalId): GroupCollectorInterface;
public function internalReferenceDoesNotContain(string $internalReference): GroupCollectorInterface;
/**
* @param string $externalId
* @param string $internalReference
*
* @return GroupCollectorInterface
*/
public function internalReferenceDoesNotEnd(string $externalId): GroupCollectorInterface;
public function internalReferenceDoesNotEnd(string $internalReference): GroupCollectorInterface;
/**
* @param string $externalId
* @param string $internalReference
*
* @return GroupCollectorInterface
*/
public function internalReferenceDoesNotStart(string $externalId): GroupCollectorInterface;
public function internalReferenceDoesNotStart(string $internalReference): GroupCollectorInterface;
/**
* @param string $externalId
* @param string $internalReference
*
* @return GroupCollectorInterface
*/
public function internalReferenceEnds(string $externalId): GroupCollectorInterface;
public function internalReferenceEnds(string $internalReference): GroupCollectorInterface;
/**
* @param string $externalId
* @param string $internalReference
*
* @return GroupCollectorInterface
*/
public function internalReferenceStarts(string $externalId): GroupCollectorInterface;
public function internalReferenceStarts(string $internalReference): GroupCollectorInterface;
/**
* Only journals that are reconciled.
@@ -639,6 +687,7 @@ interface GroupCollectorInterface
/**
* @param string $day
* @param string $field
*
* @return GroupCollectorInterface
*/
public function metaDayAfter(string $day, string $field): GroupCollectorInterface;
@@ -646,6 +695,7 @@ interface GroupCollectorInterface
/**
* @param string $day
* @param string $field
*
* @return GroupCollectorInterface
*/
public function metaDayBefore(string $day, string $field): GroupCollectorInterface;
@@ -653,6 +703,7 @@ interface GroupCollectorInterface
/**
* @param string $day
* @param string $field
*
* @return GroupCollectorInterface
*/
public function metaDayIs(string $day, string $field): GroupCollectorInterface;
@@ -660,6 +711,7 @@ interface GroupCollectorInterface
/**
* @param string $day
* @param string $field
*
* @return GroupCollectorInterface
*/
public function metaDayIsNot(string $day, string $field): GroupCollectorInterface;
@@ -667,6 +719,7 @@ interface GroupCollectorInterface
/**
* @param string $month
* @param string $field
*
* @return GroupCollectorInterface
*/
public function metaMonthAfter(string $month, string $field): GroupCollectorInterface;
@@ -674,6 +727,7 @@ interface GroupCollectorInterface
/**
* @param string $month
* @param string $field
*
* @return GroupCollectorInterface
*/
public function metaMonthBefore(string $month, string $field): GroupCollectorInterface;
@@ -681,6 +735,7 @@ interface GroupCollectorInterface
/**
* @param string $month
* @param string $field
*
* @return GroupCollectorInterface
*/
public function metaMonthIs(string $month, string $field): GroupCollectorInterface;
@@ -688,6 +743,7 @@ interface GroupCollectorInterface
/**
* @param string $month
* @param string $field
*
* @return GroupCollectorInterface
*/
public function metaMonthIsNot(string $month, string $field): GroupCollectorInterface;
@@ -695,6 +751,7 @@ interface GroupCollectorInterface
/**
* @param string $year
* @param string $field
*
* @return GroupCollectorInterface
*/
public function metaYearAfter(string $year, string $field): GroupCollectorInterface;
@@ -702,6 +759,7 @@ interface GroupCollectorInterface
/**
* @param string $year
* @param string $field
*
* @return GroupCollectorInterface
*/
public function metaYearBefore(string $year, string $field): GroupCollectorInterface;
@@ -709,6 +767,7 @@ interface GroupCollectorInterface
/**
* @param string $year
* @param string $field
*
* @return GroupCollectorInterface
*/
public function metaYearIs(string $year, string $field): GroupCollectorInterface;
@@ -716,30 +775,35 @@ interface GroupCollectorInterface
/**
* @param string $year
* @param string $field
*
* @return GroupCollectorInterface
*/
public function metaYearIsNot(string $year, string $field): GroupCollectorInterface;
/**
* @param string $month
*
* @return GroupCollectorInterface
*/
public function monthAfter(string $month): GroupCollectorInterface;
/**
* @param string $month
*
* @return GroupCollectorInterface
*/
public function monthBefore(string $month): GroupCollectorInterface;
/**
* @param string $month
*
* @return GroupCollectorInterface
*/
public function monthIs(string $month): GroupCollectorInterface;
/**
* @param string $month
*
* @return GroupCollectorInterface
*/
public function monthIsNot(string $month): GroupCollectorInterface;
@@ -767,6 +831,7 @@ interface GroupCollectorInterface
/**
* @param string $value
*
* @return GroupCollectorInterface
*/
public function notesDontStartWith(string $value): GroupCollectorInterface;
@@ -802,6 +867,7 @@ interface GroupCollectorInterface
/**
* @param string $day
* @param string $field
*
* @return GroupCollectorInterface
*/
public function objectDayAfter(string $day, string $field): GroupCollectorInterface;
@@ -809,6 +875,7 @@ interface GroupCollectorInterface
/**
* @param string $day
* @param string $field
*
* @return GroupCollectorInterface
*/
public function objectDayBefore(string $day, string $field): GroupCollectorInterface;
@@ -816,6 +883,7 @@ interface GroupCollectorInterface
/**
* @param string $day
* @param string $field
*
* @return GroupCollectorInterface
*/
public function objectDayIs(string $day, string $field): GroupCollectorInterface;
@@ -823,6 +891,7 @@ interface GroupCollectorInterface
/**
* @param string $day
* @param string $field
*
* @return GroupCollectorInterface
*/
public function objectDayIsNot(string $day, string $field): GroupCollectorInterface;
@@ -830,6 +899,7 @@ interface GroupCollectorInterface
/**
* @param string $month
* @param string $field
*
* @return GroupCollectorInterface
*/
public function objectMonthAfter(string $month, string $field): GroupCollectorInterface;
@@ -837,6 +907,7 @@ interface GroupCollectorInterface
/**
* @param string $month
* @param string $field
*
* @return GroupCollectorInterface
*/
public function objectMonthBefore(string $month, string $field): GroupCollectorInterface;
@@ -844,6 +915,7 @@ interface GroupCollectorInterface
/**
* @param string $month
* @param string $field
*
* @return GroupCollectorInterface
*/
public function objectMonthIs(string $month, string $field): GroupCollectorInterface;
@@ -851,6 +923,7 @@ interface GroupCollectorInterface
/**
* @param string $month
* @param string $field
*
* @return GroupCollectorInterface
*/
public function objectMonthIsNot(string $month, string $field): GroupCollectorInterface;
@@ -858,6 +931,7 @@ interface GroupCollectorInterface
/**
* @param string $year
* @param string $field
*
* @return GroupCollectorInterface
*/
public function objectYearAfter(string $year, string $field): GroupCollectorInterface;
@@ -865,6 +939,7 @@ interface GroupCollectorInterface
/**
* @param string $year
* @param string $field
*
* @return GroupCollectorInterface
*/
public function objectYearBefore(string $year, string $field): GroupCollectorInterface;
@@ -872,6 +947,7 @@ interface GroupCollectorInterface
/**
* @param string $year
* @param string $field
*
* @return GroupCollectorInterface
*/
public function objectYearIs(string $year, string $field): GroupCollectorInterface;
@@ -879,6 +955,7 @@ interface GroupCollectorInterface
/**
* @param string $year
* @param string $field
*
* @return GroupCollectorInterface
*/
public function objectYearIsNot(string $year, string $field): GroupCollectorInterface;
@@ -1000,6 +1077,11 @@ interface GroupCollectorInterface
*/
public function setDestinationAccounts(Collection $accounts): GroupCollectorInterface;
/**
* @param bool $expandGroupSearch
*/
public function setExpandGroupSearch(bool $expandGroupSearch);
/**
* Look for specific external ID's.
*
@@ -1011,6 +1093,7 @@ interface GroupCollectorInterface
/**
* @param string $url
*
* @return GroupCollectorInterface
*/
public function setExternalUrl(string $url): GroupCollectorInterface;
@@ -1036,11 +1119,11 @@ interface GroupCollectorInterface
/**
* Look for specific external ID's.
*
* @param string $externalId
* @param string $internalReference
*
* @return GroupCollectorInterface
*/
public function setInternalReference(string $externalId): GroupCollectorInterface;
public function setInternalReference(string $internalReference): GroupCollectorInterface;
/**
* Limit the result to a set of specific transaction journals.
@@ -1065,6 +1148,7 @@ interface GroupCollectorInterface
*
* @param Carbon $date
* @param string $field
*
* @return GroupCollectorInterface
*/
public function setMetaAfter(Carbon $date, string $field): GroupCollectorInterface;
@@ -1074,6 +1158,7 @@ interface GroupCollectorInterface
*
* @param Carbon $date
* @param string $field
*
* @return GroupCollectorInterface
*/
public function setMetaBefore(Carbon $date, string $field): GroupCollectorInterface;
@@ -1101,6 +1186,7 @@ interface GroupCollectorInterface
/**
* @param Carbon $date
* @param string $field
*
* @return GroupCollectorInterface
*/
public function setObjectAfter(Carbon $date, string $field): GroupCollectorInterface;
@@ -1108,6 +1194,7 @@ interface GroupCollectorInterface
/**
* @param Carbon $date
* @param string $field
*
* @return GroupCollectorInterface
*/
public function setObjectBefore(Carbon $date, string $field): GroupCollectorInterface;
@@ -1116,6 +1203,7 @@ interface GroupCollectorInterface
* @param Carbon $start
* @param Carbon $end
* @param string $field
*
* @return GroupCollectorInterface
*/
public function setObjectRange(Carbon $start, Carbon $end, string $field): GroupCollectorInterface;
@@ -1159,6 +1247,7 @@ interface GroupCollectorInterface
/**
* @param string $sepaCT
*
* @return GroupCollectorInterface
*/
public function setSepaCT(string $sepaCT): GroupCollectorInterface;
@@ -1332,6 +1421,7 @@ interface GroupCollectorInterface
* Transaction must have meta date field X.
*
* @param string $field
*
* @return GroupCollectorInterface
*/
public function withMetaDate(string $field): GroupCollectorInterface;
@@ -1397,25 +1487,31 @@ interface GroupCollectorInterface
/**
* @param string $year
*
* @return GroupCollectorInterface
*/
public function yearAfter(string $year): GroupCollectorInterface;
/**
* @param string $year
*
* @return GroupCollectorInterface
*/
public function yearBefore(string $year): GroupCollectorInterface;
/**
* @param string $year
*
* @return GroupCollectorInterface
*/
public function yearIs(string $year): GroupCollectorInterface;
/**
* @param string $year
*
* @return GroupCollectorInterface
*/
public function yearIsNot(string $year): GroupCollectorInterface;
}

View File

@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Helpers\Fiscal;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;

View File

@@ -49,6 +49,7 @@ interface NetWorthInterface
*
* @param Collection $accounts
* @param Carbon $date
*
* @return array
* @deprecated
*/

View File

@@ -155,9 +155,9 @@ class ReconcileController extends Controller
* Submit a new reconciliation.
*
* @param ReconciliationStoreRequest $request
* @param Account $account
* @param Carbon $start
* @param Carbon $end
* @param Account $account
* @param Carbon $start
* @param Carbon $end
*
* @return RedirectResponse|Redirector
* @throws DuplicateTransactionException

View File

@@ -131,6 +131,12 @@ class ShowController extends Controller
->setLimit($pageSize)
->setPage($page)->withAccountInformation()->withCategoryInformation()
->setRange($start, $end);
// this search will not include transaction groups where this asset account (or liability)
// is just part of ONE of the journals. To force this:
$collector->setExpandGroupSearch(true);
$groups = $collector->getPaginatedGroups();
$groups->setPath(route('accounts.show', [$account->id, $start->format('Y-m-d'), $end->format('Y-m-d')]));

View File

@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Admin;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Middleware\IsDemoUser;
use FireflyIII\Http\Requests\ConfigurationRequest;

View File

@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Admin;
use FireflyIII\Events\AdminRequestedTestMessage;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Middleware\IsDemoUser;
use FireflyIII\Support\Facades\FireflyConfig;
@@ -84,6 +83,7 @@ class HomeController extends Controller
/**
* @param Request $request
*
* @return RedirectResponse
*/
public function notifications(Request $request): RedirectResponse

View File

@@ -89,6 +89,7 @@ class UserController extends Controller
/**
* @param InvitedUser $invitedUser
*
* @return JsonResponse
*/
public function deleteInvite(InvitedUser $invitedUser): JsonResponse
@@ -192,6 +193,7 @@ class UserController extends Controller
/**
* @param InviteUserFormRequest $request
*
* @return RedirectResponse
*/
public function invite(InviteUserFormRequest $request): RedirectResponse

View File

@@ -35,7 +35,6 @@ use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use Illuminate\View\View;
use JsonException;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;

View File

@@ -517,6 +517,7 @@ class AccountController extends Controller
*
* @param Carbon $start
* @param Carbon $end
*
* @return JsonResponse
* @throws FireflyException
* @throws JsonException

View File

@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Chart;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Helpers\Report\NetWorthInterface;

View File

@@ -208,6 +208,7 @@ class CurrencyController extends Controller
/**
* @param Request $request
*
* @return JsonResponse
* @throws FireflyException
*/
@@ -300,6 +301,7 @@ class CurrencyController extends Controller
/**
* @param Request $request
*
* @return JsonResponse
*/
public function enableCurrency(Request $request): JsonResponse

View File

@@ -32,8 +32,6 @@ use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
/**
* Class RecurrenceController
@@ -148,11 +146,11 @@ class RecurrenceController extends Controller
*/
public function suggest(Request $request): JsonResponse
{
$string = '' === (string)$request->get('date') ? date('Y-m-d') : (string)$request->get('date');
$today = today(config('app.timezone'))->startOfDay();
$string = '' === (string)$request->get('date') ? date('Y-m-d') : (string)$request->get('date');
$today = today(config('app.timezone'))->startOfDay();
try {
$date = Carbon::createFromFormat('Y-m-d', $string, config('app.timezone'))->startOfDay();
} catch(InvalidFormatException $e) {
} catch (InvalidFormatException $e) {
$date = Carbon::today(config('app.timezone'));
}
$preSelected = (string)$request->get('pre_select');

View File

@@ -54,12 +54,12 @@ class ReportController extends Controller
app('view')->share('end', $attributes['endDate']);
$html = match ($attributes['location']) {
default => sprintf('Firefly III cannot handle "%s"-popups.', $attributes['location']),
default => sprintf('Firefly III cannot handle "%s"-popups.', $attributes['location']),
'budget-spent-amount' => $this->budgetSpentAmount($attributes),
'expense-entry' => $this->expenseEntry($attributes),
'income-entry' => $this->incomeEntry($attributes),
'category-entry' => $this->categoryEntry($attributes),
'budget-entry' => $this->budgetEntry($attributes),
'expense-entry' => $this->expenseEntry($attributes),
'income-entry' => $this->incomeEntry($attributes),
'category-entry' => $this->categoryEntry($attributes),
'budget-entry' => $this->budgetEntry($attributes),
};
return response()->json(['html' => $html]);
}

View File

@@ -133,6 +133,13 @@ class PreferencesController extends Controller
$frontPageAccounts = $accountIds;
}
// for the demo user, the slackUrl is automatically emptied.
// this isn't really secure but it means that the demo site has a semi-secret
// slackUrl.
if (auth()->user()->hasRole('demo')) {
$slackUrl = '';
}
return view(
'preferences.index',
compact(
@@ -198,12 +205,14 @@ class PreferencesController extends Controller
// slack URL:
$url = (string)$request->get('slackUrl');
if (str_starts_with($url, 'https://hooks.slack.com/services/')) {
app('preferences')->set('slack_webhook_url', $url);
}
if ('' === $url) {
app('preferences')->delete('slack_webhook_url');
if (!auth()->user()->hasRole('demo')) {
$url = (string)$request->get('slackUrl');
if (str_starts_with($url, 'https://hooks.slack.com/services/')) {
app('preferences')->set('slack_webhook_url', $url);
}
if ('' === $url) {
app('preferences')->delete('slack_webhook_url');
}
}
// custom fiscal year

View File

@@ -1,5 +1,26 @@
<?php
/*
* TriggerController.php
* Copyright (c) 2023 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
/*
* TriggerController.php
@@ -41,6 +62,7 @@ class TriggerController extends Controller
/**
* @param Recurrence $recurrence
* @param TriggerRecurrenceRequest $request
*
* @return RedirectResponse
*/
public function trigger(Recurrence $recurrence, TriggerRecurrenceRequest $request): RedirectResponse

View File

@@ -45,8 +45,8 @@ class BillController extends Controller
* @return mixed|string
* @throws FireflyException
*/
public function overview(Collection $accounts, Carbon $start, Carbon $end)
{ // chart properties for cache:
public function overview(Collection $accounts, Carbon $start, Carbon $end) // chart properties for cache:
{
$cache = new CacheProperties();
$cache->addProperty($start);
$cache->addProperty($end);

View File

@@ -313,11 +313,11 @@ class ReportController extends Controller
public function options(string $reportType)
{
$result = match ($reportType) {
default => $this->noReportOptions(),
default => $this->noReportOptions(),
'category' => $this->categoryReportOptions(),
'budget' => $this->budgetReportOptions(),
'tag' => $this->tagReportOptions(),
'double' => $this->doubleReportOptions(),
'budget' => $this->budgetReportOptions(),
'tag' => $this->tagReportOptions(),
'double' => $this->doubleReportOptions(),
};
return response()->json(['html' => $result]);
@@ -381,12 +381,12 @@ class ReportController extends Controller
}
$url = match ($reportType) {
default => route('reports.report.default', [$accounts, $start, $end]),
default => route('reports.report.default', [$accounts, $start, $end]),
'category' => route('reports.report.category', [$accounts, $categories, $start, $end]),
'audit' => route('reports.report.audit', [$accounts, $start, $end]),
'budget' => route('reports.report.budget', [$accounts, $budgets, $start, $end]),
'tag' => route('reports.report.tag', [$accounts, $tags, $start, $end]),
'double' => route('reports.report.double', [$accounts, $double, $start, $end]),
'audit' => route('reports.report.audit', [$accounts, $start, $end]),
'budget' => route('reports.report.budget', [$accounts, $budgets, $start, $end]),
'tag' => route('reports.report.tag', [$accounts, $tags, $start, $end]),
'double' => route('reports.report.double', [$accounts, $double, $start, $end]),
};
return redirect($url);

View File

@@ -241,6 +241,7 @@ class CreateController extends Controller
/**
* @param Request $request
*
* @return JsonResponse
*/
public function duplicate(Request $request): JsonResponse

View File

@@ -138,6 +138,7 @@ class InstallController extends Controller
/**
* @param string $command
* @param array $args
*
* @return bool
* @throws FireflyException
*/

View File

@@ -155,6 +155,7 @@ class LinkController extends Controller
* Switch link from A <> B to B <> A.
*
* @param Request $request
*
* @return RedirectResponse|Redirector
*/
public function switchLink(Request $request)

View File

@@ -39,6 +39,7 @@ class AcceptHeaders
*
* @param Request $request
* @param callable $next
*
* @return Response
* @throws BadHttpHeaderException
*/
@@ -78,6 +79,7 @@ class AcceptHeaders
/**
* @param string $content
* @param array $accepted
*
* @return bool
*/
private function acceptsHeader(string $content, array $accepted): bool

View File

@@ -121,6 +121,7 @@ class Authenticate
/**
* @param User|null $user
* @param array $guards
*
* @return void
* @throws AuthenticationException
*/

View File

@@ -86,6 +86,7 @@ class RuleFormRequest extends FormRequest
/**
* @param array $array
*
* @return array
*/
public static function replaceAmountTrigger(array $array): array

View File

@@ -1,9 +1,9 @@
<?php
declare(strict_types=1);
/*
* TriggerRecurrenceRequest.php
* Copyright (c) 2022 james@firefly-iii.org
* Copyright (c) 2023 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
@@ -21,6 +21,8 @@ declare(strict_types=1);
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Http\Requests;
use FireflyIII\Support\Request\ChecksLogin;

View File

@@ -314,6 +314,7 @@ class CreateAutoBudgetLimits implements ShouldQueue
/**
* @param AutoBudget $autoBudget
*
* @return void
*/
private function createAdjustedLimit(AutoBudget $autoBudget): void

View File

@@ -94,6 +94,7 @@ class DownloadExchangeRates implements ShouldQueue
/**
* @param TransactionCurrency $currency
*
* @return void
* @throws GuzzleException
*/
@@ -126,8 +127,9 @@ class DownloadExchangeRates implements ShouldQueue
/**
* @param TransactionCurrency $currency
* @param Carbon $date
* @param array $rates
* @param Carbon $date
* @param array $rates
*
* @return void
*/
private function saveRates(TransactionCurrency $currency, Carbon $date, array $rates): void
@@ -145,6 +147,7 @@ class DownloadExchangeRates implements ShouldQueue
/**
* @param string $code
*
* @return TransactionCurrency|null
*/
private function getCurrency(string $code): ?TransactionCurrency
@@ -175,8 +178,9 @@ class DownloadExchangeRates implements ShouldQueue
/**
* @param TransactionCurrency $from
* @param TransactionCurrency $to
* @param Carbon $date
* @param float $rate
* @param Carbon $date
* @param float $rate
*
* @return void
*/
private function saveRate(TransactionCurrency $from, TransactionCurrency $to, Carbon $date, float $rate): void

View File

@@ -97,6 +97,7 @@ class WarnAboutBills implements ShouldQueue
/**
* @param Bill $bill
*
* @return bool
*/
private function hasDateFields(Bill $bill): bool
@@ -115,6 +116,7 @@ class WarnAboutBills implements ShouldQueue
/**
* @param Bill $bill
* @param string $field
*
* @return bool
*/
private function needsWarning(Bill $bill, string $field): bool
@@ -134,6 +136,7 @@ class WarnAboutBills implements ShouldQueue
/**
* @param Bill $bill
* @param string $field
*
* @return int
*/
private function getDiff(Bill $bill, string $field): int
@@ -146,6 +149,7 @@ class WarnAboutBills implements ShouldQueue
/**
* @param Bill $bill
* @param string $field
*
* @return void
*/
private function sendWarning(Bill $bill, string $field): void

View File

@@ -34,13 +34,13 @@ use Illuminate\Support\Carbon;
/**
* Class UserGroup
*
* @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property string|null $deleted_at
* @property string $title
* @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property string|null $deleted_at
* @property string $title
* @property-read Collection|GroupMembership[] $groupMemberships
* @property-read int|null $group_memberships_count
* @property-read int|null $group_memberships_count
* @method static Builder|UserGroup newModelQuery()
* @method static Builder|UserGroup newQuery()
* @method static Builder|UserGroup query()
@@ -49,8 +49,8 @@ use Illuminate\Support\Carbon;
* @method static Builder|UserGroup whereId($value)
* @method static Builder|UserGroup whereTitle($value)
* @method static Builder|UserGroup whereUpdatedAt($value)
* @property-read Collection<int, Account> $accounts
* @property-read int|null $accounts_count
* @property-read Collection<int, Account> $accounts
* @property-read int|null $accounts_count
* @mixin Eloquent
*/
class UserGroup extends Model

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Notifications\Admin;
use FireflyIII\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Messages\SlackMessage;
@@ -52,6 +53,7 @@ class TestNotification extends Notification
* Get the array representation of the notification.
*
* @param mixed $notifiable
*
* @return array
*/
public function toArray($notifiable)
@@ -65,6 +67,7 @@ class TestNotification extends Notification
* Get the mail representation of the notification.
*
* @param mixed $notifiable
*
* @return MailMessage
*/
public function toMail($notifiable)
@@ -78,6 +81,7 @@ class TestNotification extends Notification
* Get the Slack representation of the notification.
*
* @param mixed $notifiable
*
* @return SlackMessage
*/
public function toSlack($notifiable)
@@ -89,10 +93,17 @@ class TestNotification extends Notification
* Get the notification's delivery channels.
*
* @param mixed $notifiable
*
* @return array
*/
public function via($notifiable)
{
return ['mail', 'slack'];
/** @var User|null $user */
$user = auth()->user();
$slackUrl = null === $user ? '' : (string)app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data;
if (str_starts_with($slackUrl, 'https://hooks.slack.com/services/')) {
return ['mail', 'slack'];
}
return ['mail'];
}
}

View File

@@ -25,6 +25,7 @@ declare(strict_types=1);
namespace FireflyIII\Notifications\Admin;
use FireflyIII\Models\InvitedUser;
use FireflyIII\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Messages\SlackMessage;
@@ -53,6 +54,7 @@ class UserInvitation extends Notification
* Get the array representation of the notification.
*
* @param mixed $notifiable
*
* @return array
*/
public function toArray($notifiable)
@@ -66,6 +68,7 @@ class UserInvitation extends Notification
* Get the mail representation of the notification.
*
* @param mixed $notifiable
*
* @return MailMessage
*/
public function toMail($notifiable)
@@ -79,6 +82,7 @@ class UserInvitation extends Notification
* Get the Slack representation of the notification.
*
* @param mixed $notifiable
*
* @return SlackMessage
*/
public function toSlack($notifiable)
@@ -92,10 +96,17 @@ class UserInvitation extends Notification
* Get the notification's delivery channels.
*
* @param mixed $notifiable
*
* @return array
*/
public function via($notifiable)
{
return ['mail', 'slack'];
/** @var User|null $user */
$user = auth()->user();
$slackUrl = null === $user ? '' : (string)app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data;
if (str_starts_with($slackUrl, 'https://hooks.slack.com/services/')) {
return ['mail', 'slack'];
}
return ['mail'];
}
}

View File

@@ -53,6 +53,7 @@ class UserRegistration extends Notification
* Get the array representation of the notification.
*
* @param mixed $notifiable
*
* @return array
*/
public function toArray($notifiable)
@@ -66,6 +67,7 @@ class UserRegistration extends Notification
* Get the mail representation of the notification.
*
* @param mixed $notifiable
*
* @return MailMessage
*/
public function toMail($notifiable)
@@ -79,6 +81,7 @@ class UserRegistration extends Notification
* Get the Slack representation of the notification.
*
* @param mixed $notifiable
*
* @return SlackMessage
*/
public function toSlack($notifiable)
@@ -90,10 +93,17 @@ class UserRegistration extends Notification
* Get the notification's delivery channels.
*
* @param mixed $notifiable
*
* @return array
*/
public function via($notifiable)
{
return ['mail', 'slack'];
/** @var User|null $user */
$user = auth()->user();
$slackUrl = null === $user ? '' : (string)app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data;
if (str_starts_with($slackUrl, 'https://hooks.slack.com/services/')) {
return ['mail', 'slack'];
}
return ['mail'];
}
}

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Notifications\Admin;
use FireflyIII\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Messages\SlackMessage;
@@ -53,6 +54,7 @@ class VersionCheckResult extends Notification
* Get the array representation of the notification.
*
* @param mixed $notifiable
*
* @return array
*/
public function toArray($notifiable)
@@ -66,6 +68,7 @@ class VersionCheckResult extends Notification
* Get the mail representation of the notification.
*
* @param mixed $notifiable
*
* @return MailMessage
*/
public function toMail($notifiable)
@@ -79,24 +82,43 @@ class VersionCheckResult extends Notification
* Get the Slack representation of the notification.
*
* @param mixed $notifiable
*
* @return SlackMessage
*/
public function toSlack($notifiable)
{
// return (new SlackMessage())->text($this->message)
// ->sectionBlock(function (SectionBlock $block) {
// $button = new ButtonElement('Button');
// $button->url('https://github.com/firefly-iii/firefly-iii/releases');
// $block->accessory($button);
// });
//// ->attachment(function ($attachment) {
//// $attachment->title('Firefly III @ GitHub', 'https://github.com/firefly-iii/firefly-iii/releases');
//// });
return (new SlackMessage())->content($this->message)
->attachment(function ($attachment) {
$attachment->title('Firefly III @ GitHub', 'https://github.com/firefly-iii/firefly-iii/releases');
});
->attachment(function ($attachment) {
$attachment->title('Firefly III @ GitHub', 'https://github.com/firefly-iii/firefly-iii/releases');
});
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
*
* @return array
*/
public function via($notifiable)
{
return ['mail', 'slack'];
/** @var User|null $user */
$user = auth()->user();
$slackUrl = null === $user ? '' : (string)app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data;
if (str_starts_with($slackUrl, 'https://hooks.slack.com/services/')) {
return ['mail', 'slack'];
}
return ['mail'];
}
}

View File

@@ -25,6 +25,7 @@ declare(strict_types=1);
namespace FireflyIII\Notifications\User;
use FireflyIII\Models\Bill;
use FireflyIII\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Messages\SlackMessage;
@@ -37,8 +38,8 @@ class BillReminder extends Notification
{
use Queueable;
private Bill $bill;
private int $diff;
private Bill $bill;
private int $diff;
private string $field;
/**
@@ -48,15 +49,16 @@ class BillReminder extends Notification
*/
public function __construct(Bill $bill, string $field, int $diff)
{
$this->bill = $bill;
$this->bill = $bill;
$this->field = $field;
$this->diff = $diff;
$this->diff = $diff;
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
*
* @return array
*/
public function toArray($notifiable)
@@ -70,6 +72,7 @@ class BillReminder extends Notification
* Get the mail representation of the notification.
*
* @param mixed $notifiable
*
* @return MailMessage
*/
public function toMail($notifiable)
@@ -88,6 +91,7 @@ class BillReminder extends Notification
* Get the Slack representation of the notification.
*
* @param mixed $notifiable
*
* @return SlackMessage
*/
public function toSlack($notifiable)
@@ -97,7 +101,7 @@ class BillReminder extends Notification
$message = (string)trans(sprintf('email.bill_warning_subject_now_%s', $this->field), ['diff' => $this->diff, 'name' => $this->bill->name]);
}
$bill = $this->bill;
$url = route('bills.show', [$bill->id]);
$url = route('bills.show', [$bill->id]);
return (new SlackMessage())
->warning()
->attachment(function ($attachment) use ($bill, $url) {
@@ -110,10 +114,17 @@ class BillReminder extends Notification
* Get the notification's delivery channels.
*
* @param mixed $notifiable
*
* @return array
*/
public function via($notifiable)
{
return ['mail', 'slack'];
/** @var User|null $user */
$user = auth()->user();
$slackUrl = null === $user ? '' : (string)app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data;
if (str_starts_with($slackUrl, 'https://hooks.slack.com/services/')) {
return ['mail', 'slack'];
}
return ['mail'];
}
}

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Notifications\User;
use FireflyIII\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Messages\SlackMessage;
@@ -49,6 +50,7 @@ class NewAccessToken extends Notification
* Get the array representation of the notification.
*
* @param mixed $notifiable
*
* @return array
*/
public function toArray($notifiable)
@@ -62,6 +64,7 @@ class NewAccessToken extends Notification
* Get the mail representation of the notification.
*
* @param mixed $notifiable
*
* @return MailMessage
*/
public function toMail($notifiable)
@@ -75,6 +78,7 @@ class NewAccessToken extends Notification
* Get the Slack representation of the notification.
*
* @param mixed $notifiable
*
* @return SlackMessage
*/
public function toSlack($notifiable)
@@ -86,10 +90,17 @@ class NewAccessToken extends Notification
* Get the notification's delivery channels.
*
* @param mixed $notifiable
*
* @return array
*/
public function via($notifiable)
{
return ['mail', 'slack'];
/** @var User|null $user */
$user = auth()->user();
$slackUrl = null === $user ? '' : (string)app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data;
if (str_starts_with($slackUrl, 'https://hooks.slack.com/services/')) {
return ['mail', 'slack'];
}
return ['mail'];
}
}

View File

@@ -51,6 +51,7 @@ class TransactionCreation extends Notification
* Get the array representation of the notification.
*
* @param mixed $notifiable
*
* @return array
*/
public function toArray($notifiable)
@@ -64,6 +65,7 @@ class TransactionCreation extends Notification
* Get the mail representation of the notification.
*
* @param mixed $notifiable
*
* @return MailMessage
*/
public function toMail($notifiable)
@@ -77,6 +79,7 @@ class TransactionCreation extends Notification
* Get the notification's delivery channels.
*
* @param mixed $notifiable
*
* @return array
*/
public function via($notifiable)

View File

@@ -25,11 +25,12 @@ declare(strict_types=1);
namespace FireflyIII\Notifications\User;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Messages\SlackMessage;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Facades\Log;
use Illuminate\Notifications\Messages\SlackMessage;
/**
* Class UserLogin
@@ -54,6 +55,7 @@ class UserLogin extends Notification
* Get the array representation of the notification.
*
* @param mixed $notifiable
*
* @return array
*/
public function toArray($notifiable)
@@ -67,6 +69,7 @@ class UserLogin extends Notification
* Get the mail representation of the notification.
*
* @param mixed $notifiable
*
* @return MailMessage
*/
public function toMail($notifiable)
@@ -92,6 +95,7 @@ class UserLogin extends Notification
* Get the Slack representation of the notification.
*
* @param mixed $notifiable
*
* @return SlackMessage
*/
public function toSlack($notifiable)
@@ -114,10 +118,17 @@ class UserLogin extends Notification
* Get the notification's delivery channels.
*
* @param mixed $notifiable
*
* @return array
*/
public function via($notifiable)
{
return ['mail', 'slack'];
/** @var User|null $user */
$user = auth()->user();
$slackUrl = null === $user ? '' : (string)app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data;
if (str_starts_with($slackUrl, 'https://hooks.slack.com/services/')) {
return ['mail', 'slack'];
}
return ['mail'];
}
}

View File

@@ -51,6 +51,7 @@ class UserNewPassword extends Notification
* Get the array representation of the notification.
*
* @param mixed $notifiable
*
* @return array
*/
public function toArray($notifiable)
@@ -64,6 +65,7 @@ class UserNewPassword extends Notification
* Get the mail representation of the notification.
*
* @param mixed $notifiable
*
* @return MailMessage
*/
public function toMail($notifiable)
@@ -77,6 +79,7 @@ class UserNewPassword extends Notification
* Get the notification's delivery channels.
*
* @param mixed $notifiable
*
* @return array
*/
public function via($notifiable)

View File

@@ -48,6 +48,7 @@ class UserRegistration extends Notification
* Get the array representation of the notification.
*
* @param mixed $notifiable
*
* @return array
*/
public function toArray($notifiable)
@@ -61,6 +62,7 @@ class UserRegistration extends Notification
* Get the mail representation of the notification.
*
* @param mixed $notifiable
*
* @return MailMessage
*/
public function toMail($notifiable)
@@ -74,6 +76,7 @@ class UserRegistration extends Notification
* Get the notification's delivery channels.
*
* @param mixed $notifiable
*
* @return array
*/
public function via($notifiable)

View File

@@ -47,7 +47,7 @@ class AppServiceProvider extends ServiceProvider
$headers = [
'Cache-Control' => 'no-store',
];
$uuid = (string)request()->header('X-Trace-Id');
$uuid = (string)request()->header('X-Trace-Id');
if ('' !== trim($uuid) && (preg_match('/^[a-f\d]{8}(-[a-f\d]{4}){4}[a-f\d]{8}$/i', trim($uuid)) === 1)) {
$headers['X-Trace-Id'] = $uuid;
}

View File

@@ -766,7 +766,7 @@ class AccountRepository implements AccountRepositoryInterface
/**
* @param Account $account
* @param array $data
* @param array $data
*
* @return Account
* @throws FireflyException

View File

@@ -1,6 +1,6 @@
<?php
declare(strict_types=1);
/*
* AccountRepository.php
* Copyright (c) 2023 james@firefly-iii.org
@@ -21,6 +21,8 @@ declare(strict_types=1);
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Repositories\Administration\Account;
use FireflyIII\Support\Repositories\Administration\AdministrationTrait;

View File

@@ -1,6 +1,6 @@
<?php
declare(strict_types=1);
/*
* AccountRepositoryInterface.php
* Copyright (c) 2023 james@firefly-iii.org
@@ -21,6 +21,8 @@ declare(strict_types=1);
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Repositories\Administration\Account;
use Illuminate\Support\Collection;

View File

@@ -35,12 +35,14 @@ interface ALERepositoryInterface
{
/**
* @param Model $model
*
* @return Collection
*/
public function getForObject(Model $model): Collection;
/**
* @param array $data
*
* @return AuditLogEntry
*/
public function store(array $data): AuditLogEntry;

View File

@@ -282,6 +282,7 @@ interface BillRepositoryInterface
*
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/
public function sumPaidInRange(Carbon $start, Carbon $end): array;
@@ -291,6 +292,7 @@ interface BillRepositoryInterface
*
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/
public function sumUnpaidInRange(Carbon $start, Carbon $end): array;

View File

@@ -171,6 +171,7 @@ class BudgetRepository implements BudgetRepositoryInterface
* @param BudgetLimit $limit
* @param Carbon $start
* @param Carbon $end
*
* @return int
*/
private function daysInOverlap(BudgetLimit $limit, Carbon $start, Carbon $end): int
@@ -374,6 +375,7 @@ class BudgetRepository implements BudgetRepositoryInterface
/**
* @param Budget $budget
* @param string $text
*
* @return void
*/
private function setNoteText(Budget $budget, string $text): void
@@ -405,6 +407,7 @@ class BudgetRepository implements BudgetRepositoryInterface
/**
* @param Budget $budget
* @param array $data
*
* @throws FireflyException
* @throws JsonException
*/

View File

@@ -57,6 +57,7 @@ interface BudgetRepositoryInterface
*
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/
public function budgetedInPeriod(Carbon $start, Carbon $end): array;
@@ -67,6 +68,7 @@ interface BudgetRepositoryInterface
* @param Budget $budget
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/
public function budgetedInPeriodForBudget(Budget $budget, Carbon $start, Carbon $end): array;
@@ -173,6 +175,7 @@ interface BudgetRepositoryInterface
/**
* @param Budget $budget
*
* @return string|null
*/
public function getNoteText(Budget $budget): ?string;

View File

@@ -288,6 +288,7 @@ class OperationsRepository implements OperationsRepositoryInterface
* @param Collection|null $accounts
* @param Collection|null $budgets
* @param TransactionCurrency|null $currency
*
* @return array
* @deprecated
*/

View File

@@ -473,6 +473,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
* @param TransactionCurrency $toCurrency
* @param Carbon $date
* @param float $rate
*
* @return CurrencyExchangeRate
*/
public function setExchangeRate(TransactionCurrency $fromCurrency, TransactionCurrency $toCurrency, Carbon $date, float $rate): CurrencyExchangeRate

View File

@@ -226,6 +226,7 @@ interface CurrencyRepositoryInterface
* @param TransactionCurrency $toCurrency
* @param Carbon $date
* @param float $rate
*
* @return CurrencyExchangeRate
*/
public function setExchangeRate(TransactionCurrency $fromCurrency, TransactionCurrency $toCurrency, Carbon $date, float $rate): CurrencyExchangeRate;

View File

@@ -172,6 +172,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
/**
* @param TransactionJournal $one
* @param TransactionJournal $two
*
* @return TransactionJournalLink|null
*/
public function getLink(TransactionJournal $one, TransactionJournal $two): ?TransactionJournalLink

View File

@@ -45,8 +45,9 @@ trait ModifiesPiggyBanks
/**
* @param PiggyBankRepetition $repetition
* @param string $amount
* @param TransactionJournal $journal
* @param string $amount
* @param TransactionJournal $journal
*
* @return void
*/
public function addAmountToRepetition(PiggyBankRepetition $repetition, string $amount, TransactionJournal $journal): void
@@ -63,9 +64,10 @@ trait ModifiesPiggyBanks
}
/**
* @param PiggyBank $piggyBank
* @param string $amount
* @param PiggyBank $piggyBank
* @param string $amount
* @param TransactionJournal|null $journal
*
* @return bool
*/
public function removeAmount(PiggyBank $piggyBank, string $amount, ?TransactionJournal $journal = null): bool
@@ -87,6 +89,7 @@ trait ModifiesPiggyBanks
* @param PiggyBank $piggyBank
* @param string $amount
* @param TransactionJournal|null $journal
*
* @return bool
*/
public function addAmount(PiggyBank $piggyBank, string $amount, ?TransactionJournal $journal = null): bool

View File

@@ -41,14 +41,16 @@ interface PiggyBankRepositoryInterface
* @param PiggyBank $piggyBank
* @param string $amount
* @param TransactionJournal|null $journal
*
* @return bool
*/
public function addAmount(PiggyBank $piggyBank, string $amount, ?TransactionJournal $journal = null): bool;
/**
* @param PiggyBankRepetition $repetition
* @param string $amount
* @param TransactionJournal $journal
* @param string $amount
* @param TransactionJournal $journal
*
* @return void
*/
public function addAmountToRepetition(PiggyBankRepetition $repetition, string $amount, TransactionJournal $journal): void;
@@ -203,6 +205,7 @@ interface PiggyBankRepositoryInterface
* @param PiggyBank $piggyBank
* @param string $amount
* @param TransactionJournal|null $journal
*
* @return bool
*/
public function removeAmount(PiggyBank $piggyBank, string $amount, ?TransactionJournal $journal = null): bool;

View File

@@ -42,6 +42,7 @@ interface RecurringRepositoryInterface
/**
* @param Recurrence $recurrence
* @param Carbon $date
*
* @return bool
*/
public function createdPreviously(Recurrence $recurrence, Carbon $date): bool;

View File

@@ -104,6 +104,7 @@ interface UserRepositoryInterface
/**
* @param InvitedUser $invite
*
* @return void
*/
public function deleteInvite(InvitedUser $invite): void;
@@ -158,6 +159,7 @@ interface UserRepositoryInterface
/**
* @param User $user
* @param int $groupId
*
* @return array
*/
public function getRolesInGroup(User $user, int $groupId): array;
@@ -182,12 +184,14 @@ interface UserRepositoryInterface
/**
* @param User|Authenticatable|null $user
* @param string $email
*
* @return InvitedUser
*/
public function inviteUser(User | Authenticatable | null $user, string $email): InvitedUser;
/**
* @param string $code
*
* @return void
*/
public function redeemCode(string $code): void;
@@ -245,6 +249,7 @@ interface UserRepositoryInterface
/**
* @param string $code
*
* @return bool
*/
public function validateInviteCode(string $code): bool;

View File

@@ -79,16 +79,16 @@ class BelongsUser implements Rule
Log::debug(sprintf('Going to validate %s', $attribute));
return match ($attribute) {
'piggy_bank_id' => $this->validatePiggyBankId((int)$value),
'piggy_bank_name' => $this->validatePiggyBankName($value),
'bill_id' => $this->validateBillId((int)$value),
'transaction_journal_id' => $this->validateJournalId((int)$value),
'bill_name' => $this->validateBillName($value),
'budget_id' => $this->validateBudgetId((int)$value),
'category_id' => $this->validateCategoryId((int)$value),
'budget_name' => $this->validateBudgetName($value),
'piggy_bank_id' => $this->validatePiggyBankId((int)$value),
'piggy_bank_name' => $this->validatePiggyBankName($value),
'bill_id' => $this->validateBillId((int)$value),
'transaction_journal_id' => $this->validateJournalId((int)$value),
'bill_name' => $this->validateBillName($value),
'budget_id' => $this->validateBudgetId((int)$value),
'category_id' => $this->validateCategoryId((int)$value),
'budget_name' => $this->validateBudgetName($value),
'source_id', 'destination_id' => $this->validateAccountId((int)$value),
default => throw new FireflyException(sprintf('Rule BelongUser cannot handle "%s"', $attribute)),
default => throw new FireflyException(sprintf('Rule BelongUser cannot handle "%s"', $attribute)),
};
}

View File

@@ -400,9 +400,10 @@ trait AccountServiceTrait
*
*
* @param Account $account
* @param string $direction
* @param string $openingBalance
* @param Carbon $openingBalanceDate
* @param string $direction
* @param string $openingBalance
* @param Carbon $openingBalanceDate
*
* @return TransactionGroup
* @throws FireflyException
* @throws JsonException
@@ -612,8 +613,8 @@ trait AccountServiceTrait
* Since opening balance and date can still be empty strings, it may fail.
*
* @param Account $account
* @param string $openingBalance
* @param Carbon $openingBalanceDate
* @param string $openingBalance
* @param Carbon $openingBalanceDate
*
* @return TransactionGroup
* @throws FireflyException

View File

@@ -206,10 +206,11 @@ class CreditRecalculateService
}
/**
* @param Account $account
* @param string $direction
* @param Account $account
* @param string $direction
* @param Transaction $transaction
* @param string $leftOfDebt
* @param string $leftOfDebt
*
* @return string
*/
private function processTransaction(Account $account, string $direction, Transaction $transaction, string $leftOfDebt): string

View File

@@ -244,6 +244,7 @@ trait JournalServiceTrait
/**
* @param array $types
*
* @return null|string
*/
private function getCreatableType(array $types): ?string

View File

@@ -243,6 +243,7 @@ class AccountUpdateService
/**
* @param array $array
*
* @return array
*/
private function getTypeIds(array $array): array

View File

@@ -42,7 +42,7 @@ class GroupUpdateService
* Update a transaction group.
*
* @param TransactionGroup $transactionGroup
* @param array $data
* @param array $data
*
* @return TransactionGroup
* @throws DuplicateTransactionException

View File

@@ -33,6 +33,7 @@ use FireflyIII\Services\Internal\Support\RecurringTransactionTrait;
use FireflyIII\Services\Internal\Support\TransactionTypeTrait;
use FireflyIII\User;
use Illuminate\Support\Facades\Log;
use JsonException;
/**
* Class RecurrenceUpdateService
@@ -211,9 +212,10 @@ class RecurrenceUpdateService
* TODO this method is very complex.
*
* @param Recurrence $recurrence
* @param array $transactions
* @param array $transactions
*
* @throws FireflyException
* @throws \JsonException
* @throws JsonException
*/
private function updateTransactions(Recurrence $recurrence, array $transactions): void
{
@@ -273,6 +275,7 @@ class RecurrenceUpdateService
/**
* @param Recurrence $recurrence
* @param array $combination
*
* @return void
*/
private function updateCombination(Recurrence $recurrence, array $combination): void
@@ -354,6 +357,7 @@ class RecurrenceUpdateService
/**
* @param Recurrence $recurrence
* @param int $transactionId
*
* @return void
*/
private function deleteTransaction(Recurrence $recurrence, int $transactionId): void

View File

@@ -49,6 +49,7 @@ class RemoteUserGuard implements Guard
*
* @param UserProvider $provider
* @param Application $app
*
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/

View File

@@ -1,8 +1,8 @@
<?php
declare(strict_types=1);
/**
/*
* Calculator.php
* Copyright (c) 2023 Antonio Spinelli https://github.com/tonicospinelli
*
* This file is part of Firefly III (https://github.com/firefly-iii).
@@ -21,10 +21,13 @@ declare(strict_types=1);
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Support\Calendar;
use Carbon\Carbon;
use FireflyIII\Support\Calendar\Exceptions\IntervalException;
use SplObjectStorage;
/**
* Class Calculator
@@ -32,57 +35,14 @@ use FireflyIII\Support\Calendar\Exceptions\IntervalException;
class Calculator
{
public const DEFAULT_INTERVAL = 1;
private static array $intervals = [];
private static ?\SplObjectStorage $intervalMap = null;
/**
* @return \SplObjectStorage
*/
private static function loadIntervalMap(): \SplObjectStorage
{
if (self::$intervalMap != null) {
return self::$intervalMap;
}
self::$intervalMap = new \SplObjectStorage();
foreach (Periodicity::cases() as $interval) {
$periodicityClass = __NAMESPACE__ . "\\Periodicity\\{$interval->name}";
self::$intervals[] = $interval->name;
self::$intervalMap->attach($interval, new $periodicityClass());
}
return self::$intervalMap;
}
/**
* @param Periodicity $periodicity
* @return bool
*/
private static function containsInterval(Periodicity $periodicity): bool
{
return self::loadIntervalMap()->contains($periodicity);
}
/**
* @param Periodicity $periodicity
* @return bool
*/
public function isAvailablePeriodicity(Periodicity $periodicity): bool
{
return self::containsInterval($periodicity);
}
/**
* @param int $skip
* @return int
*/
private function skipInterval(int $skip): int
{
return self::DEFAULT_INTERVAL + $skip;
}
private static ?SplObjectStorage $intervalMap = null;
private static array $intervals = [];
/**
* @param Carbon $epoch
* @param Periodicity $periodicity
* @param int $skipInterval
*
* @return Carbon
* @throws IntervalException
*/
@@ -98,4 +58,51 @@ class Calculator
return $periodicity->nextDate($epoch->clone(), $interval);
}
/**
* @param Periodicity $periodicity
*
* @return bool
*/
public function isAvailablePeriodicity(Periodicity $periodicity): bool
{
return self::containsInterval($periodicity);
}
/**
* @param Periodicity $periodicity
*
* @return bool
*/
private static function containsInterval(Periodicity $periodicity): bool
{
return self::loadIntervalMap()->contains($periodicity);
}
/**
* @return SplObjectStorage
*/
private static function loadIntervalMap(): SplObjectStorage
{
if (self::$intervalMap != null) {
return self::$intervalMap;
}
self::$intervalMap = new SplObjectStorage();
foreach (Periodicity::cases() as $interval) {
$periodicityClass = __NAMESPACE__ . "\\Periodicity\\{$interval->name}";
self::$intervals[] = $interval->name;
self::$intervalMap->attach($interval, new $periodicityClass());
}
return self::$intervalMap;
}
/**
* @param int $skip
*
* @return int
*/
private function skipInterval(int $skip): int
{
return self::DEFAULT_INTERVAL + $skip;
}
}

View File

@@ -1,8 +1,8 @@
<?php
declare(strict_types=1);
/**
/*
* IntervalException.php
* Copyright (c) 2023 Antonio Spinelli https://github.com/tonicospinelli
*
* This file is part of Firefly III (https://github.com/firefly-iii).
@@ -21,32 +21,36 @@ declare(strict_types=1);
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Support\Calendar\Exceptions;
use Exception;
use FireflyIII\Support\Calendar\Periodicity;
use Throwable;
/**
* Class IntervalException
*/
final class IntervalException extends \Exception
final class IntervalException extends Exception
{
public readonly array $availableIntervals;
public readonly Periodicity $periodicity;
protected $message = 'The periodicity %s is unknown. Choose one of available periodicity: %s';
public readonly Periodicity $periodicity;
public readonly array $availableIntervals;
/**
* @param Periodicity $periodicity
* @param array $intervals
* @param int $code
* @param \Throwable|null $previous
* @param Periodicity $periodicity
* @param array $intervals
* @param int $code
* @param Throwable|null $previous
*
* @return IntervalException
*/
public static function unavailable(
Periodicity $periodicity,
array $intervals,
int $code = 0,
?\Throwable $previous = null
?Throwable $previous = null
): IntervalException {
$message = sprintf(
'The periodicity %s is unknown. Choose one of available periodicity: %s',

Some files were not shown because too many files have changed in this diff Show More