mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
Use PSR-12 code style
This commit is contained in:
37
.ci/phpcs.sh
Executable file
37
.ci/phpcs.sh
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#
|
||||
# phpstan.sh
|
||||
# Copyright (c) 2021 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/>.
|
||||
#
|
||||
|
||||
# Install composer packages
|
||||
#composer install --no-scripts --no-ansi
|
||||
|
||||
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
|
||||
# enable test .env file.
|
||||
# cp .ci/.env.ci .env
|
||||
|
||||
# clean up php code
|
||||
cd $SCRIPT_DIR/php-cs-fixer
|
||||
composer update
|
||||
./vendor/bin/php-cs-fixer fix $SCRIPT_DIR/../app/Console --config $SCRIPT_DIR/php-cs-fixer/.php-cs-fixer.php --allow-risky=yes
|
||||
cd $SCRIPT_DIR/..
|
||||
|
||||
exit 0
|
@@ -28,12 +28,6 @@ SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
# enable test .env file.
|
||||
# cp .ci/.env.ci .env
|
||||
|
||||
# clean up php code
|
||||
cd $SCRIPT_DIR/php-cs-fixer
|
||||
composer update
|
||||
./vendor/bin/php-cs-fixer fix $SCRIPT_DIR/../app/Console --config $SCRIPT_DIR/php-cs-fixer/.php-cs-fixer.php --allow-risky=yes
|
||||
cd $SCRIPT_DIR/..
|
||||
|
||||
# Do static code analysis.
|
||||
# ./vendor/bin/phpstan analyse -c .ci/phpstan.neon --no-progress
|
||||
./vendor/bin/phpstan analyse -c .ci/phpstan.neon
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands\Correction;
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Transaction;
|
||||
@@ -135,7 +136,7 @@ class CorrectOpeningBalanceCurrencies extends Command
|
||||
*
|
||||
* @return TransactionCurrency
|
||||
* @throws JsonException
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function getCurrency(Account $account): TransactionCurrency
|
||||
{
|
||||
@@ -155,7 +156,7 @@ class CorrectOpeningBalanceCurrencies extends Command
|
||||
private function setCurrency(TransactionJournal $journal, TransactionCurrency $currency): int
|
||||
{
|
||||
$count = 0;
|
||||
if ((int) $journal->transaction_currency_id !== (int) $currency->id) {
|
||||
if ((int)$journal->transaction_currency_id !== (int)$currency->id) {
|
||||
$journal->transaction_currency_id = $currency->id;
|
||||
$journal->save();
|
||||
$count = 1;
|
||||
@@ -163,7 +164,7 @@ class CorrectOpeningBalanceCurrencies extends Command
|
||||
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($journal->transactions as $transaction) {
|
||||
if ((int) $transaction->transaction_currency_id !== (int) $currency->id) {
|
||||
if ((int)$transaction->transaction_currency_id !== (int)$currency->id) {
|
||||
$transaction->transaction_currency_id = $currency->id;
|
||||
$transaction->save();
|
||||
$count = 1;
|
||||
|
@@ -72,17 +72,17 @@ class DeleteEmptyJournals extends Command
|
||||
$total = 0;
|
||||
/** @var Transaction $row */
|
||||
foreach ($set as $row) {
|
||||
$count = (int) $row->the_count;
|
||||
$count = (int)$row->the_count;
|
||||
if (1 === $count % 2) {
|
||||
// uneven number, delete journal and transactions:
|
||||
try {
|
||||
TransactionJournal::find((int) $row->transaction_journal_id)->delete();
|
||||
TransactionJournal::find((int)$row->transaction_journal_id)->delete();
|
||||
} catch (Exception $e) { // @phpstan-ignore-line
|
||||
Log::info(sprintf('Could not delete journal: %s', $e->getMessage()));
|
||||
}
|
||||
|
||||
|
||||
Transaction::where('transaction_journal_id', (int) $row->transaction_journal_id)->delete();
|
||||
Transaction::where('transaction_journal_id', (int)$row->transaction_journal_id)->delete();
|
||||
$this->info(sprintf('Deleted transaction journal #%d because it had an uneven number of transactions.', $row->transaction_journal_id));
|
||||
$total++;
|
||||
}
|
||||
|
@@ -66,6 +66,34 @@ class DeleteOrphanedTransactions extends Command
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function deleteOrphanedJournals(): void
|
||||
{
|
||||
$set = TransactionJournal::leftJoin('transaction_groups', 'transaction_journals.transaction_group_id', 'transaction_groups.id')
|
||||
->whereNotNull('transaction_groups.deleted_at')
|
||||
->whereNull('transaction_journals.deleted_at')
|
||||
->get(['transaction_journals.id', 'transaction_journals.transaction_group_id']);
|
||||
$count = $set->count();
|
||||
if (0 === $count) {
|
||||
$this->info('No orphaned journals.');
|
||||
}
|
||||
if ($count > 0) {
|
||||
$this->info(sprintf('Found %d orphaned journal(s).', $count));
|
||||
foreach ($set as $entry) {
|
||||
$journal = TransactionJournal::withTrashed()->find((int)$entry->id);
|
||||
if (null !== $journal) {
|
||||
$journal->delete();
|
||||
$this->info(
|
||||
sprintf(
|
||||
'Journal #%d (part of deleted transaction group #%d) has been deleted as well.',
|
||||
$entry->id,
|
||||
$entry->transaction_group_id
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -84,7 +112,7 @@ class DeleteOrphanedTransactions extends Command
|
||||
);
|
||||
/** @var stdClass $entry */
|
||||
foreach ($set as $entry) {
|
||||
$transaction = Transaction::find((int) $entry->transaction_id);
|
||||
$transaction = Transaction::find((int)$entry->transaction_id);
|
||||
if (null !== $transaction) {
|
||||
$transaction->delete();
|
||||
$this->info(
|
||||
@@ -115,7 +143,7 @@ class DeleteOrphanedTransactions extends Command
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($set as $transaction) {
|
||||
// delete journals
|
||||
$journal = TransactionJournal::find((int) $transaction->transaction_journal_id);
|
||||
$journal = TransactionJournal::find((int)$transaction->transaction_journal_id);
|
||||
if ($journal) {
|
||||
try {
|
||||
$journal->delete();
|
||||
@@ -123,7 +151,7 @@ class DeleteOrphanedTransactions extends Command
|
||||
Log::info(sprintf('Could not delete journal %s', $e->getMessage()));
|
||||
}
|
||||
}
|
||||
Transaction::where('transaction_journal_id', (int) $transaction->transaction_journal_id)->delete();
|
||||
Transaction::where('transaction_journal_id', (int)$transaction->transaction_journal_id)->delete();
|
||||
$this->line(
|
||||
sprintf(
|
||||
'Deleted transaction journal #%d because account #%d was already deleted.',
|
||||
@@ -137,32 +165,4 @@ class DeleteOrphanedTransactions extends Command
|
||||
$this->info('No orphaned accounts.');
|
||||
}
|
||||
}
|
||||
|
||||
private function deleteOrphanedJournals(): void
|
||||
{
|
||||
$set = TransactionJournal::leftJoin('transaction_groups', 'transaction_journals.transaction_group_id', 'transaction_groups.id')
|
||||
->whereNotNull('transaction_groups.deleted_at')
|
||||
->whereNull('transaction_journals.deleted_at')
|
||||
->get(['transaction_journals.id', 'transaction_journals.transaction_group_id']);
|
||||
$count = $set->count();
|
||||
if (0 === $count) {
|
||||
$this->info('No orphaned journals.');
|
||||
}
|
||||
if ($count > 0) {
|
||||
$this->info(sprintf('Found %d orphaned journal(s).', $count));
|
||||
foreach ($set as $entry) {
|
||||
$journal = TransactionJournal::withTrashed()->find((int) $entry->id);
|
||||
if (null !== $journal) {
|
||||
$journal->delete();
|
||||
$this->info(
|
||||
sprintf(
|
||||
'Journal #%d (part of deleted transaction group #%d) has been deleted as well.',
|
||||
$entry->id,
|
||||
$entry->transaction_group_id
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -63,26 +63,26 @@ class EnableCurrencies extends Command
|
||||
/** @var Collection $meta */
|
||||
$meta = AccountMeta::where('name', 'currency_id')->groupBy('data')->get(['data']);
|
||||
foreach ($meta as $entry) {
|
||||
$found[] = (int) $entry->data;
|
||||
$found[] = (int)$entry->data;
|
||||
}
|
||||
|
||||
// get all from journals:
|
||||
$journals = TransactionJournal::groupBy('transaction_currency_id')->get(['transaction_currency_id']);
|
||||
foreach ($journals as $entry) {
|
||||
$found[] = (int) $entry->transaction_currency_id;
|
||||
$found[] = (int)$entry->transaction_currency_id;
|
||||
}
|
||||
|
||||
// get all from transactions
|
||||
$transactions = Transaction::groupBy('transaction_currency_id', 'foreign_currency_id')->get(['transaction_currency_id', 'foreign_currency_id']);
|
||||
foreach ($transactions as $entry) {
|
||||
$found[] = (int) $entry->transaction_currency_id;
|
||||
$found[] = (int) $entry->foreign_currency_id;
|
||||
$found[] = (int)$entry->transaction_currency_id;
|
||||
$found[] = (int)$entry->foreign_currency_id;
|
||||
}
|
||||
|
||||
// get all from budget limits
|
||||
$limits = BudgetLimit::groupBy('transaction_currency_id')->get(['transaction_currency_id']);
|
||||
foreach ($limits as $entry) {
|
||||
$found[] = (int) $entry->transaction_currency_id;
|
||||
$found[] = (int)$entry->transaction_currency_id;
|
||||
}
|
||||
|
||||
$found = array_values(array_unique($found));
|
||||
|
@@ -88,7 +88,7 @@ class FixFrontpageAccounts extends Command
|
||||
if (is_array($data)) {
|
||||
/** @var string $accountId */
|
||||
foreach ($data as $accountId) {
|
||||
$accountIdInt = (int) $accountId;
|
||||
$accountIdInt = (int)$accountId;
|
||||
$account = $repository->find($accountIdInt);
|
||||
if (null !== $account
|
||||
&& in_array($account->accountType->type, [AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE], true)
|
||||
|
@@ -61,8 +61,8 @@ class FixGroupAccounts extends Command
|
||||
->get(['transaction_group_id', DB::raw('COUNT(transaction_group_id) as the_count')]);
|
||||
/** @var TransactionJournal $journal */
|
||||
foreach ($res as $journal) {
|
||||
if ((int) $journal->the_count > 1) {
|
||||
$groups[] = (int) $journal->transaction_group_id;
|
||||
if ((int)$journal->the_count > 1) {
|
||||
$groups[] = (int)$journal->transaction_group_id;
|
||||
}
|
||||
}
|
||||
$handler = new UpdatedGroupEventHandler();
|
||||
|
@@ -57,7 +57,7 @@ class FixIbans extends Command
|
||||
foreach ($accounts as $account) {
|
||||
$iban = $account->iban;
|
||||
if (str_contains($iban, ' ')) {
|
||||
$iban = app('steam')->filterSpaces((string) $account->iban);
|
||||
$iban = app('steam')->filterSpaces((string)$account->iban);
|
||||
if ('' !== $iban) {
|
||||
$account->iban = $iban;
|
||||
$account->save();
|
||||
|
@@ -68,7 +68,7 @@ class FixLongDescriptions extends Command
|
||||
$groups = TransactionGroup::get(['id', 'title']);
|
||||
/** @var TransactionGroup $group */
|
||||
foreach ($groups as $group) {
|
||||
if (strlen((string) $group->title) > self::MAX_LENGTH) {
|
||||
if (strlen((string)$group->title) > self::MAX_LENGTH) {
|
||||
$group->title = substr($group->title, 0, self::MAX_LENGTH);
|
||||
$group->save();
|
||||
$this->line(sprintf('Truncated description of transaction group #%d', $group->id));
|
||||
|
@@ -105,7 +105,7 @@ class FixTransactionTypes extends Command
|
||||
|
||||
return false;
|
||||
}
|
||||
$expectedType = (string) config(sprintf('firefly.account_to_transaction.%s.%s', $source->accountType->type, $destination->accountType->type));
|
||||
$expectedType = (string)config(sprintf('firefly.account_to_transaction.%s.%s', $source->accountType->type, $destination->accountType->type));
|
||||
if ($expectedType !== $type) {
|
||||
$this->line(
|
||||
sprintf(
|
||||
|
@@ -65,11 +65,11 @@ class FixUnevenAmount extends Command
|
||||
->get(['transaction_journal_id', DB::raw('SUM(amount) AS the_sum')]);
|
||||
/** @var stdClass $entry */
|
||||
foreach ($journals as $entry) {
|
||||
if (0 !== bccomp((string) $entry->the_sum, '0')) {
|
||||
if (0 !== bccomp((string)$entry->the_sum, '0')) {
|
||||
$message = sprintf('Sum of journal #%d is %s instead of zero.', $entry->transaction_journal_id, $entry->the_sum);
|
||||
$this->warn($message);
|
||||
Log::warning($message);
|
||||
$this->fixJournal((int) $entry->transaction_journal_id);
|
||||
$this->fixJournal((int)$entry->transaction_journal_id);
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
@@ -110,7 +110,7 @@ class FixUnevenAmount extends Command
|
||||
return;
|
||||
}
|
||||
|
||||
$amount = bcmul('-1', (string) $source->amount);
|
||||
$amount = bcmul('-1', (string)$source->amount);
|
||||
|
||||
// fix amount of destination:
|
||||
/** @var Transaction $destination */
|
||||
|
@@ -32,6 +32,8 @@ use Illuminate\Console\Command;
|
||||
use Illuminate\Contracts\Encryption\DecryptException;
|
||||
use JsonException;
|
||||
use Log;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
@@ -109,8 +111,8 @@ class DecryptDatabase extends Command
|
||||
* @param string $table
|
||||
*
|
||||
* @return bool
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
private function isDecrypted(string $table): bool
|
||||
{
|
||||
@@ -122,7 +124,7 @@ class DecryptDatabase extends Command
|
||||
Log::error($e->getMessage());
|
||||
}
|
||||
if (null !== $configVar) {
|
||||
return (bool) $configVar->data;
|
||||
return (bool)$configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -152,7 +154,7 @@ class DecryptDatabase extends Command
|
||||
if (null === $original) {
|
||||
return;
|
||||
}
|
||||
$id = (int) $row->id;
|
||||
$id = (int)$row->id;
|
||||
$value = '';
|
||||
|
||||
try {
|
||||
@@ -217,7 +219,7 @@ class DecryptDatabase extends Command
|
||||
}
|
||||
|
||||
/** @var Preference $object */
|
||||
$object = Preference::find((int) $id);
|
||||
$object = Preference::find((int)$id);
|
||||
if (null !== $object) {
|
||||
$object->data = $newValue;
|
||||
$object->save();
|
||||
|
@@ -234,7 +234,7 @@ class ExportData extends Command
|
||||
$accounts = new Collection();
|
||||
$accountList = $this->option('accounts');
|
||||
$types = [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE];
|
||||
if (null !== $accountList && '' !== (string) $accountList) {
|
||||
if (null !== $accountList && '' !== (string)$accountList) {
|
||||
$accountIds = explode(',', $accountList);
|
||||
$accounts = $this->accountRepository->getAccountsById($accountIds);
|
||||
}
|
||||
@@ -262,7 +262,7 @@ class ExportData extends Command
|
||||
*/
|
||||
private function getExportDirectory(): string
|
||||
{
|
||||
$directory = (string) $this->option('export_directory');
|
||||
$directory = (string)$this->option('export_directory');
|
||||
if (null === $directory) {
|
||||
$directory = './';
|
||||
}
|
||||
|
@@ -68,7 +68,7 @@ class ReportSum extends Command
|
||||
|
||||
/** @var User $user */
|
||||
foreach ($userRepository->all() as $user) {
|
||||
$sum = (string) $user->transactions()->sum('amount');
|
||||
$sum = (string)$user->transactions()->sum('amount');
|
||||
if (0 !== bccomp($sum, '0')) {
|
||||
$message = sprintf('Error: Transactions for user #%d (%s) are off by %s!', $user->id, $user->email, $sum);
|
||||
$this->error($message);
|
||||
|
@@ -47,19 +47,18 @@ use Illuminate\Console\Command;
|
||||
*/
|
||||
class UpdateGroupInformation extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'firefly-iii:upgrade-group-information';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Makes sure that every object is linked to a group';
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'firefly-iii:upgrade-group-information';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -87,10 +86,22 @@ class UpdateGroupInformation extends Command
|
||||
$this->warn(sprintf('User "%s" has no group.', $user->email));
|
||||
return;
|
||||
}
|
||||
$set = [Account::class, Attachment::class, AvailableBudget::class,
|
||||
Bill::class, Budget::class, Category::class, CurrencyExchangeRate::class,
|
||||
Recurrence::class, RuleGroup::class, Rule::class, Tag::class, TransactionGroup::class,
|
||||
TransactionJournal::class, Webhook::class];
|
||||
$set = [
|
||||
Account::class,
|
||||
Attachment::class,
|
||||
AvailableBudget::class,
|
||||
Bill::class,
|
||||
Budget::class,
|
||||
Category::class,
|
||||
CurrencyExchangeRate::class,
|
||||
Recurrence::class,
|
||||
RuleGroup::class,
|
||||
Rule::class,
|
||||
Tag::class,
|
||||
TransactionGroup::class,
|
||||
TransactionJournal::class,
|
||||
Webhook::class,
|
||||
];
|
||||
foreach ($set as $className) {
|
||||
$this->updateGroupInfoForObject($user, $group, $className);
|
||||
}
|
||||
|
@@ -212,7 +212,7 @@ class ApplyRules extends Command
|
||||
$accountRepository = app(AccountRepositoryInterface::class);
|
||||
$accountRepository->setUser($this->getUser());
|
||||
foreach ($accountList as $accountId) {
|
||||
$accountId = (int) $accountId;
|
||||
$accountId = (int)$accountId;
|
||||
$account = $accountRepository->find($accountId);
|
||||
if (null !== $account && in_array($account->accountType->type, $this->acceptedAccounts, true)) {
|
||||
$finalList->push($account);
|
||||
@@ -242,7 +242,7 @@ class ApplyRules extends Command
|
||||
$ruleGroupList = explode(',', $ruleGroupString);
|
||||
|
||||
foreach ($ruleGroupList as $ruleGroupId) {
|
||||
$ruleGroup = $this->ruleGroupRepository->find((int) $ruleGroupId);
|
||||
$ruleGroup = $this->ruleGroupRepository->find((int)$ruleGroupId);
|
||||
if ($ruleGroup->active) {
|
||||
$this->ruleGroupSelection[] = $ruleGroup->id;
|
||||
}
|
||||
@@ -267,7 +267,7 @@ class ApplyRules extends Command
|
||||
$ruleList = explode(',', $ruleString);
|
||||
|
||||
foreach ($ruleList as $ruleId) {
|
||||
$rule = $this->ruleRepository->find((int) $ruleId);
|
||||
$rule = $this->ruleRepository->find((int)$ruleId);
|
||||
if (null !== $rule && $rule->active) {
|
||||
$this->ruleSelection[] = $rule->id;
|
||||
}
|
||||
|
@@ -68,7 +68,7 @@ class Cron extends Command
|
||||
} catch (InvalidArgumentException $e) {
|
||||
$this->error(sprintf('"%s" is not a valid date', $this->option('date')));
|
||||
}
|
||||
$force = (bool) $this->option('force');
|
||||
$force = (bool)$this->option('force');
|
||||
|
||||
/*
|
||||
* Fire recurring transaction cron job.
|
||||
@@ -121,6 +121,33 @@ class Cron extends Command
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $force
|
||||
* @param Carbon|null $date
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function exchangeRatesCronJob(bool $force, ?Carbon $date): void
|
||||
{
|
||||
$exchangeRates = new ExchangeRatesCronjob();
|
||||
$exchangeRates->setForce($force);
|
||||
// set date in cron job:
|
||||
if (null !== $date) {
|
||||
$exchangeRates->setDate($date);
|
||||
}
|
||||
|
||||
$exchangeRates->fire();
|
||||
|
||||
if ($exchangeRates->jobErrored) {
|
||||
$this->error(sprintf('Error in "exchange rates" cron: %s', $exchangeRates->message));
|
||||
}
|
||||
if ($exchangeRates->jobFired) {
|
||||
$this->line(sprintf('"Exchange rates" cron fired: %s', $exchangeRates->message));
|
||||
}
|
||||
if ($exchangeRates->jobSucceeded) {
|
||||
$this->info(sprintf('"Exchange rates" cron ran with success: %s', $exchangeRates->message));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $force
|
||||
* @param Carbon|null $date
|
||||
@@ -202,31 +229,4 @@ class Cron extends Command
|
||||
$this->info(sprintf('"Send bill warnings" cron ran with success: %s', $autoBudget->message));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $force
|
||||
* @param Carbon|null $date
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function exchangeRatesCronJob(bool $force, ?Carbon $date): void
|
||||
{
|
||||
$exchangeRates = new ExchangeRatesCronjob();
|
||||
$exchangeRates->setForce($force);
|
||||
// set date in cron job:
|
||||
if (null !== $date) {
|
||||
$exchangeRates->setDate($date);
|
||||
}
|
||||
|
||||
$exchangeRates->fire();
|
||||
|
||||
if ($exchangeRates->jobErrored) {
|
||||
$this->error(sprintf('Error in "exchange rates" cron: %s', $exchangeRates->message));
|
||||
}
|
||||
if ($exchangeRates->jobFired) {
|
||||
$this->line(sprintf('"Exchange rates" cron fired: %s', $exchangeRates->message));
|
||||
}
|
||||
if ($exchangeRates->jobSucceeded) {
|
||||
$this->info(sprintf('"Exchange rates" cron ran with success: %s', $exchangeRates->message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -34,6 +34,8 @@ use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class AccountCurrencies
|
||||
@@ -109,14 +111,14 @@ class AccountCurrencies extends Command
|
||||
/**
|
||||
* @return bool
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
private function isExecuted(): bool
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
if (null !== $configVar) {
|
||||
return (bool) $configVar->data;
|
||||
return (bool)$configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -129,7 +131,7 @@ class AccountCurrencies extends Command
|
||||
{
|
||||
Log::debug('Now in updateAccountCurrencies()');
|
||||
$users = $this->userRepos->all();
|
||||
$defaultCurrencyCode = (string) config('firefly.default_currency', 'EUR');
|
||||
$defaultCurrencyCode = (string)config('firefly.default_currency', 'EUR');
|
||||
Log::debug(sprintf('Default currency is %s', $defaultCurrencyCode));
|
||||
foreach ($users as $user) {
|
||||
$this->updateCurrenciesForUser($user, $defaultCurrencyCode);
|
||||
@@ -180,13 +182,13 @@ class AccountCurrencies extends Command
|
||||
Log::debug(sprintf('Now in updateAccount(%d, %s)', $account->id, $currency->code));
|
||||
$this->accountRepos->setUser($account->user);
|
||||
|
||||
$accountCurrency = (int) $this->accountRepos->getMetaValue($account, 'currency_id');
|
||||
$accountCurrency = (int)$this->accountRepos->getMetaValue($account, 'currency_id');
|
||||
Log::debug(sprintf('Account currency is #%d', $accountCurrency));
|
||||
|
||||
$openingBalance = $this->accountRepos->getOpeningBalance($account);
|
||||
$obCurrency = 0;
|
||||
if (null !== $openingBalance) {
|
||||
$obCurrency = (int) $openingBalance->transaction_currency_id;
|
||||
$obCurrency = (int)$openingBalance->transaction_currency_id;
|
||||
Log::debug('Account has opening balance.');
|
||||
}
|
||||
Log::debug(sprintf('Account OB currency is #%d.', $obCurrency));
|
||||
|
@@ -27,6 +27,8 @@ use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\BudgetLimit;
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
class AppendBudgetLimitPeriods extends Command
|
||||
{
|
||||
@@ -72,14 +74,14 @@ class AppendBudgetLimitPeriods extends Command
|
||||
/**
|
||||
* @return bool
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
private function isExecuted(): bool
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
|
||||
return (bool) $configVar->data;
|
||||
return (bool)$configVar->data;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -32,6 +32,8 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class BackToJournals
|
||||
@@ -85,27 +87,27 @@ class BackToJournals extends Command
|
||||
/**
|
||||
* @return bool
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
private function isMigrated(): bool
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(MigrateToGroups::CONFIG_NAME, false);
|
||||
|
||||
return (bool) $configVar->data;
|
||||
return (bool)$configVar->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
private function isExecuted(): bool
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
|
||||
return (bool) $configVar->data;
|
||||
return (bool)$configVar->data;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -179,7 +181,7 @@ class BackToJournals extends Command
|
||||
// both have a budget, but they don't match.
|
||||
if (null !== $budget && null !== $journalBudget && $budget->id !== $journalBudget->id) {
|
||||
// sync to journal:
|
||||
$journal->budgets()->sync([(int) $budget->id]);
|
||||
$journal->budgets()->sync([(int)$budget->id]);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -187,7 +189,7 @@ class BackToJournals extends Command
|
||||
// transaction has a budget, but the journal doesn't.
|
||||
if (null !== $budget && null === $journalBudget) {
|
||||
// sync to journal:
|
||||
$journal->budgets()->sync([(int) $budget->id]);
|
||||
$journal->budgets()->sync([(int)$budget->id]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,12 +257,12 @@ class BackToJournals extends Command
|
||||
// both have a category, but they don't match.
|
||||
if (null !== $category && null !== $journalCategory && $category->id !== $journalCategory->id) {
|
||||
// sync to journal:
|
||||
$journal->categories()->sync([(int) $category->id]);
|
||||
$journal->categories()->sync([(int)$category->id]);
|
||||
}
|
||||
|
||||
// transaction has a category, but the journal doesn't.
|
||||
if (null !== $category && null === $journalCategory) {
|
||||
$journal->categories()->sync([(int) $category->id]);
|
||||
$journal->categories()->sync([(int)$category->id]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -27,6 +27,8 @@ use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\BudgetLimit;
|
||||
use Illuminate\Console\Command;
|
||||
use JsonException;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class BudgetLimitCurrency
|
||||
@@ -99,14 +101,14 @@ class BudgetLimitCurrency extends Command
|
||||
/**
|
||||
* @return bool
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
private function isExecuted(): bool
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
if (null !== $configVar) {
|
||||
return (bool) $configVar->data;
|
||||
return (bool)$configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@@ -28,6 +28,8 @@ use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Collection;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class CCLiabilities
|
||||
@@ -96,14 +98,14 @@ class CCLiabilities extends Command
|
||||
/**
|
||||
* @return bool
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
private function isExecuted(): bool
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
if (null !== $configVar) {
|
||||
return (bool) $configVar->data;
|
||||
return (bool)$configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@@ -31,6 +31,8 @@ use FireflyIII\Models\UserRole;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class CreateGroupMemberships
|
||||
@@ -77,14 +79,14 @@ class CreateGroupMemberships extends Command
|
||||
/**
|
||||
* @return bool
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
private function isExecuted(): bool
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
if (null !== $configVar) {
|
||||
return (bool) $configVar->data;
|
||||
return (bool)$configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@@ -28,6 +28,8 @@ use FireflyIII\Models\Attachment;
|
||||
use FireflyIII\Models\Note;
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class MigrateAttachments
|
||||
@@ -70,7 +72,7 @@ class MigrateAttachments extends Command
|
||||
/** @var Attachment $att */
|
||||
foreach ($attachments as $att) {
|
||||
// move description:
|
||||
$attDescription = (string) $att->description;
|
||||
$attDescription = (string)$att->description;
|
||||
if ('' !== $attDescription) {
|
||||
// find or create note:
|
||||
$note = $att->notes()->first();
|
||||
@@ -105,14 +107,14 @@ class MigrateAttachments extends Command
|
||||
/**
|
||||
* @return bool
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
private function isExecuted(): bool
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
if (null !== $configVar) {
|
||||
return (bool) $configVar->data;
|
||||
return (bool)$configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@@ -29,6 +29,8 @@ use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\TransactionJournalMeta;
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class MigrateJournalNotes
|
||||
@@ -105,14 +107,14 @@ class MigrateJournalNotes extends Command
|
||||
/**
|
||||
* @return bool
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
private function isExecuted(): bool
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
if (null !== $configVar) {
|
||||
return (bool) $configVar->data;
|
||||
return (bool)$configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@@ -29,6 +29,8 @@ use FireflyIII\Models\RecurrenceMeta;
|
||||
use FireflyIII\Models\RecurrenceTransactionMeta;
|
||||
use Illuminate\Console\Command;
|
||||
use JsonException;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class MigrateRecurrenceMeta
|
||||
@@ -84,14 +86,14 @@ class MigrateRecurrenceMeta extends Command
|
||||
/**
|
||||
* @return bool
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
private function isExecuted(): bool
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
if (null !== $configVar) {
|
||||
return (bool) $configVar->data;
|
||||
return (bool)$configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@@ -29,6 +29,8 @@ use FireflyIII\Models\Recurrence;
|
||||
use FireflyIII\Models\RecurrenceTransaction;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use Illuminate\Console\Command;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class MigrateRecurrenceType
|
||||
@@ -77,14 +79,14 @@ class MigrateRecurrenceType extends Command
|
||||
/**
|
||||
* @return bool
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
private function isExecuted(): bool
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
if (null !== $configVar) {
|
||||
return (bool) $configVar->data;
|
||||
return (bool)$configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -106,7 +108,7 @@ class MigrateRecurrenceType extends Command
|
||||
|
||||
private function migrateRecurrence(Recurrence $recurrence): void
|
||||
{
|
||||
$originalType = (int) $recurrence->transaction_type_id;
|
||||
$originalType = (int)$recurrence->transaction_type_id;
|
||||
$newType = $this->getInvalidType();
|
||||
$recurrence->transaction_type_id = $newType->id;
|
||||
$recurrence->save();
|
||||
|
@@ -28,6 +28,8 @@ use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Location;
|
||||
use FireflyIII\Models\Tag;
|
||||
use Illuminate\Console\Command;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class MigrateTagLocations
|
||||
@@ -74,14 +76,14 @@ class MigrateTagLocations extends Command
|
||||
/**
|
||||
* @return bool
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
private function isExecuted(): bool
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
if (null !== $configVar) {
|
||||
return (bool) $configVar->data;
|
||||
return (bool)$configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@@ -37,6 +37,8 @@ use FireflyIII\Services\Internal\Destroy\JournalDestroyService;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* This command will take split transactions and migrate them to "transaction groups".
|
||||
@@ -129,14 +131,14 @@ class MigrateToGroups extends Command
|
||||
/**
|
||||
* @return bool
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
private function isMigrated(): bool
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
if (null !== $configVar) {
|
||||
return (bool) $configVar->data;
|
||||
return (bool)$configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -326,7 +328,7 @@ class MigrateToGroups extends Command
|
||||
{
|
||||
$set = $journal->transactions->filter(
|
||||
static function (Transaction $subject) use ($transaction) {
|
||||
$amount = (float) $transaction->amount * -1 === (float) $subject->amount;
|
||||
$amount = (float)$transaction->amount * -1 === (float)$subject->amount;
|
||||
$identifier = $transaction->identifier === $subject->identifier;
|
||||
Log::debug(sprintf('Amount the same? %s', var_export($amount, true)));
|
||||
Log::debug(sprintf('ID the same? %s', var_export($identifier, true)));
|
||||
@@ -354,7 +356,7 @@ class MigrateToGroups extends Command
|
||||
if (null !== $budget) {
|
||||
Log::debug(sprintf('Return budget #%d, from transaction #%d', $budget->id, $left->id));
|
||||
|
||||
return (int) $budget->id;
|
||||
return (int)$budget->id;
|
||||
}
|
||||
|
||||
// try to get a budget ID from the right transaction:
|
||||
@@ -363,7 +365,7 @@ class MigrateToGroups extends Command
|
||||
if (null !== $budget) {
|
||||
Log::debug(sprintf('Return budget #%d, from transaction #%d', $budget->id, $right->id));
|
||||
|
||||
return (int) $budget->id;
|
||||
return (int)$budget->id;
|
||||
}
|
||||
Log::debug('Neither left or right have a budget, return NULL');
|
||||
|
||||
@@ -387,7 +389,7 @@ class MigrateToGroups extends Command
|
||||
if (null !== $category) {
|
||||
Log::debug(sprintf('Return category #%d, from transaction #%d', $category->id, $left->id));
|
||||
|
||||
return (int) $category->id;
|
||||
return (int)$category->id;
|
||||
}
|
||||
|
||||
// try to get a category ID from the left transaction:
|
||||
@@ -396,7 +398,7 @@ class MigrateToGroups extends Command
|
||||
if (null !== $category) {
|
||||
Log::debug(sprintf('Return category #%d, from transaction #%d', $category->id, $category->id));
|
||||
|
||||
return (int) $category->id;
|
||||
return (int)$category->id;
|
||||
}
|
||||
Log::debug('Neither left or right have a category, return NULL');
|
||||
|
||||
|
@@ -33,6 +33,8 @@ use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Console\Command;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class MigrateToRules
|
||||
@@ -120,14 +122,14 @@ class MigrateToRules extends Command
|
||||
/**
|
||||
* @return bool
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
private function isExecuted(): bool
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
if (null !== $configVar) {
|
||||
return (bool) $configVar->data;
|
||||
return (bool)$configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -148,14 +150,14 @@ class MigrateToRules extends Command
|
||||
|
||||
/** @var Preference $lang */
|
||||
$lang = app('preferences')->getForUser($user, 'language', 'en_US');
|
||||
$groupTitle = (string) trans('firefly.rulegroup_for_bills_title', [], $lang->data);
|
||||
$groupTitle = (string)trans('firefly.rulegroup_for_bills_title', [], $lang->data);
|
||||
$ruleGroup = $this->ruleGroupRepository->findByTitle($groupTitle);
|
||||
|
||||
if (null === $ruleGroup) {
|
||||
$ruleGroup = $this->ruleGroupRepository->store(
|
||||
[
|
||||
'title' => (string) trans('firefly.rulegroup_for_bills_title', [], $lang->data),
|
||||
'description' => (string) trans('firefly.rulegroup_for_bills_description', [], $lang->data),
|
||||
'title' => (string)trans('firefly.rulegroup_for_bills_title', [], $lang->data),
|
||||
'description' => (string)trans('firefly.rulegroup_for_bills_description', [], $lang->data),
|
||||
'active' => true,
|
||||
]
|
||||
);
|
||||
@@ -186,8 +188,8 @@ class MigrateToRules extends Command
|
||||
'active' => true,
|
||||
'strict' => false,
|
||||
'stop_processing' => false, // field is no longer used.
|
||||
'title' => (string) trans('firefly.rule_for_bill_title', ['name' => $bill->name], $language->data),
|
||||
'description' => (string) trans('firefly.rule_for_bill_description', ['name' => $bill->name], $language->data),
|
||||
'title' => (string)trans('firefly.rule_for_bill_title', ['name' => $bill->name], $language->data),
|
||||
'description' => (string)trans('firefly.rule_for_bill_description', ['name' => $bill->name], $language->data),
|
||||
'trigger' => 'store-journal',
|
||||
'triggers' => [
|
||||
[
|
||||
|
@@ -35,6 +35,8 @@ use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalCLIRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Illuminate\Console\Command;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class OtherCurrenciesCorrections
|
||||
@@ -115,14 +117,14 @@ class OtherCurrenciesCorrections extends Command
|
||||
/**
|
||||
* @return bool
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
private function isExecuted(): bool
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
if (null !== $configVar) {
|
||||
return (bool) $configVar->data;
|
||||
return (bool)$configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -188,8 +190,8 @@ class OtherCurrenciesCorrections extends Command
|
||||
}
|
||||
|
||||
// when mismatch in transaction:
|
||||
if ((int) $transaction->transaction_currency_id !== (int) $currency->id) {
|
||||
$transaction->foreign_currency_id = (int) $transaction->transaction_currency_id;
|
||||
if ((int)$transaction->transaction_currency_id !== (int)$currency->id) {
|
||||
$transaction->foreign_currency_id = (int)$transaction->transaction_currency_id;
|
||||
$transaction->foreign_amount = $transaction->amount;
|
||||
$transaction->transaction_currency_id = $currency->id;
|
||||
$transaction->save();
|
||||
|
@@ -26,6 +26,8 @@ namespace FireflyIII\Console\Commands\Upgrade;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\AccountMeta;
|
||||
use Illuminate\Console\Command;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class RenameAccountMeta
|
||||
@@ -99,14 +101,14 @@ class RenameAccountMeta extends Command
|
||||
/**
|
||||
* @return bool
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
private function isExecuted(): bool
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
if (null !== $configVar) {
|
||||
return (bool) $configVar->data;
|
||||
return (bool)$configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@@ -31,6 +31,8 @@ use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Log;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
use Schema;
|
||||
|
||||
/**
|
||||
@@ -123,14 +125,14 @@ class TransactionIdentifier extends Command
|
||||
/**
|
||||
* @return bool
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
private function isExecuted(): bool
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
if (null !== $configVar) {
|
||||
return (bool) $configVar->data;
|
||||
return (bool)$configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -174,7 +176,7 @@ class TransactionIdentifier extends Command
|
||||
private function findOpposing(Transaction $transaction, array $exclude): ?Transaction
|
||||
{
|
||||
// find opposing:
|
||||
$amount = bcmul((string) $transaction->amount, '-1');
|
||||
$amount = bcmul((string)$transaction->amount, '-1');
|
||||
|
||||
try {
|
||||
/** @var Transaction $opposing */
|
||||
|
@@ -33,6 +33,8 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalCLIRepositoryInterface;
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class TransferCurrenciesCorrections
|
||||
@@ -69,8 +71,8 @@ class TransferCurrenciesCorrections extends Command
|
||||
*
|
||||
* @return int
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
@@ -137,14 +139,14 @@ class TransferCurrenciesCorrections extends Command
|
||||
/**
|
||||
* @return bool
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
private function isExecuted(): bool
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
if (null !== $configVar) {
|
||||
return (bool) $configVar->data;
|
||||
return (bool)$configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -371,7 +373,7 @@ class TransferCurrenciesCorrections extends Command
|
||||
if (null === $this->sourceTransaction->transaction_currency_id && null !== $this->sourceCurrency) {
|
||||
$this->sourceTransaction
|
||||
->transaction_currency_id
|
||||
= (int) $this->sourceCurrency->id;
|
||||
= (int)$this->sourceCurrency->id;
|
||||
$message = sprintf(
|
||||
'Transaction #%d has no currency setting, now set to %s.',
|
||||
$this->sourceTransaction->id,
|
||||
@@ -392,7 +394,7 @@ class TransferCurrenciesCorrections extends Command
|
||||
{
|
||||
if (null !== $this->sourceCurrency
|
||||
&& null === $this->sourceTransaction->foreign_amount
|
||||
&& (int) $this->sourceTransaction->transaction_currency_id !== (int) $this->sourceCurrency->id
|
||||
&& (int)$this->sourceTransaction->transaction_currency_id !== (int)$this->sourceCurrency->id
|
||||
) {
|
||||
$message = sprintf(
|
||||
'Transaction #%d has a currency setting #%d that should be #%d. Amount remains %s, currency is changed.',
|
||||
@@ -404,7 +406,7 @@ class TransferCurrenciesCorrections extends Command
|
||||
Log::debug($message);
|
||||
$this->line($message);
|
||||
$this->count++;
|
||||
$this->sourceTransaction->transaction_currency_id = (int) $this->sourceCurrency->id;
|
||||
$this->sourceTransaction->transaction_currency_id = (int)$this->sourceCurrency->id;
|
||||
$this->sourceTransaction->save();
|
||||
}
|
||||
}
|
||||
@@ -418,7 +420,7 @@ class TransferCurrenciesCorrections extends Command
|
||||
if (null === $this->destinationTransaction->transaction_currency_id && null !== $this->destinationCurrency) {
|
||||
$this->destinationTransaction
|
||||
->transaction_currency_id
|
||||
= (int) $this->destinationCurrency->id;
|
||||
= (int)$this->destinationCurrency->id;
|
||||
$message = sprintf(
|
||||
'Transaction #%d has no currency setting, now set to %s.',
|
||||
$this->destinationTransaction->id,
|
||||
@@ -439,7 +441,7 @@ class TransferCurrenciesCorrections extends Command
|
||||
{
|
||||
if (null !== $this->destinationCurrency
|
||||
&& null === $this->destinationTransaction->foreign_amount
|
||||
&& (int) $this->destinationTransaction->transaction_currency_id !== (int) $this->destinationCurrency->id
|
||||
&& (int)$this->destinationTransaction->transaction_currency_id !== (int)$this->destinationCurrency->id
|
||||
) {
|
||||
$message = sprintf(
|
||||
'Transaction #%d has a currency setting #%d that should be #%d. Amount remains %s, currency is changed.',
|
||||
@@ -451,7 +453,7 @@ class TransferCurrenciesCorrections extends Command
|
||||
Log::debug($message);
|
||||
$this->line($message);
|
||||
$this->count++;
|
||||
$this->destinationTransaction->transaction_currency_id = (int) $this->destinationCurrency->id;
|
||||
$this->destinationTransaction->transaction_currency_id = (int)$this->destinationCurrency->id;
|
||||
$this->destinationTransaction->save();
|
||||
}
|
||||
}
|
||||
@@ -463,7 +465,7 @@ class TransferCurrenciesCorrections extends Command
|
||||
*/
|
||||
private function fixInvalidForeignCurrency(): void
|
||||
{
|
||||
if ((int) $this->destinationCurrency->id === (int) $this->sourceCurrency->id) {
|
||||
if ((int)$this->destinationCurrency->id === (int)$this->sourceCurrency->id) {
|
||||
// update both transactions to match:
|
||||
$this->sourceTransaction->foreign_amount = null;
|
||||
$this->sourceTransaction->foreign_currency_id = null;
|
||||
@@ -497,7 +499,7 @@ class TransferCurrenciesCorrections extends Command
|
||||
*/
|
||||
private function fixMismatchedForeignCurrency(): void
|
||||
{
|
||||
if ((int) $this->sourceCurrency->id !== (int) $this->destinationCurrency->id) {
|
||||
if ((int)$this->sourceCurrency->id !== (int)$this->destinationCurrency->id) {
|
||||
$this->sourceTransaction->transaction_currency_id = $this->sourceCurrency->id;
|
||||
$this->sourceTransaction->foreign_currency_id = $this->destinationCurrency->id;
|
||||
$this->destinationTransaction->transaction_currency_id = $this->sourceCurrency->id;
|
||||
@@ -517,7 +519,7 @@ class TransferCurrenciesCorrections extends Command
|
||||
private function fixSourceNullForeignAmount(): void
|
||||
{
|
||||
if (null === $this->sourceTransaction->foreign_amount && null !== $this->destinationTransaction->foreign_amount) {
|
||||
$this->sourceTransaction->foreign_amount = bcmul((string) $this->destinationTransaction->foreign_amount, '-1');
|
||||
$this->sourceTransaction->foreign_amount = bcmul((string)$this->destinationTransaction->foreign_amount, '-1');
|
||||
$this->sourceTransaction->save();
|
||||
$this->count++;
|
||||
Log::debug(
|
||||
@@ -537,7 +539,7 @@ class TransferCurrenciesCorrections extends Command
|
||||
private function fixDestNullForeignAmount(): void
|
||||
{
|
||||
if (null === $this->destinationTransaction->foreign_amount && null !== $this->sourceTransaction->foreign_amount) {
|
||||
$this->destinationTransaction->foreign_amount = bcmul((string) $this->sourceTransaction->foreign_amount, '-1');
|
||||
$this->destinationTransaction->foreign_amount = bcmul((string)$this->sourceTransaction->foreign_amount, '-1');
|
||||
$this->destinationTransaction->save();
|
||||
$this->count++;
|
||||
Log::debug(
|
||||
@@ -557,7 +559,7 @@ class TransferCurrenciesCorrections extends Command
|
||||
*/
|
||||
private function fixTransactionJournalCurrency(TransactionJournal $journal): void
|
||||
{
|
||||
if ((int) $journal->transaction_currency_id !== (int) $this->sourceCurrency->id) {
|
||||
if ((int)$journal->transaction_currency_id !== (int)$this->sourceCurrency->id) {
|
||||
$oldCurrencyCode = $journal->transactionCurrency->code ?? '(nothing)';
|
||||
$journal->transaction_currency_id = $this->sourceCurrency->id;
|
||||
$message = sprintf(
|
||||
|
@@ -121,9 +121,9 @@ class UpgradeDatabase extends Command
|
||||
echo $result;
|
||||
}
|
||||
// set new DB version.
|
||||
app('fireflyconfig')->set('db_version', (int) config('firefly.db_version'));
|
||||
app('fireflyconfig')->set('db_version', (int)config('firefly.db_version'));
|
||||
// index will set FF3 version.
|
||||
app('fireflyconfig')->set('ff3_version', (string) config('firefly.version'));
|
||||
app('fireflyconfig')->set('ff3_version', (string)config('firefly.version'));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -34,6 +34,8 @@ use FireflyIII\Services\Internal\Support\CreditRecalculateService;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class UpgradeLiabilities
|
||||
@@ -81,14 +83,14 @@ class UpgradeLiabilities extends Command
|
||||
/**
|
||||
* @return bool
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
private function isExecuted(): bool
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
if (null !== $configVar) {
|
||||
return (bool) $configVar->data;
|
||||
return (bool)$configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -161,10 +163,10 @@ class UpgradeLiabilities extends Command
|
||||
return;
|
||||
}
|
||||
// source MUST be the liability.
|
||||
if ((int) $destination->account_id === (int) $account->id) {
|
||||
if ((int)$destination->account_id === (int)$account->id) {
|
||||
Log::debug(sprintf('Must switch around, because account #%d is the destination.', $destination->account_id));
|
||||
// so if not, switch things around:
|
||||
$sourceAccountId = (int) $source->account_id;
|
||||
$sourceAccountId = (int)$source->account_id;
|
||||
$source->account_id = $destination->account_id;
|
||||
$destination->account_id = $sourceAccountId;
|
||||
$source->save();
|
||||
|
@@ -54,10 +54,10 @@ class UpgradeFireflyInstructions extends Command
|
||||
public function handle(): int
|
||||
{
|
||||
$this->generateInstallationId();
|
||||
if ('update' === (string) $this->argument('task')) {
|
||||
if ('update' === (string)$this->argument('task')) {
|
||||
$this->updateInstructions();
|
||||
}
|
||||
if ('install' === (string) $this->argument('task')) {
|
||||
if ('install' === (string)$this->argument('task')) {
|
||||
$this->installInstructions();
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ class UpgradeFireflyInstructions extends Command
|
||||
{
|
||||
$parts = explode("\n", wordwrap($text));
|
||||
foreach ($parts as $string) {
|
||||
$this->line('| ' . sprintf('%-77s', $string) . '|');
|
||||
$this->line('| '.sprintf('%-77s', $string).'|');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ class UpgradeFireflyInstructions extends Command
|
||||
{
|
||||
$parts = explode("\n", wordwrap($text));
|
||||
foreach ($parts as $string) {
|
||||
$this->info('| ' . sprintf('%-77s', $string) . '|');
|
||||
$this->info('| '.sprintf('%-77s', $string).'|');
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -43,7 +43,7 @@ trait VerifiesAccessToken
|
||||
*/
|
||||
public function getUser(): User
|
||||
{
|
||||
$userId = (int) $this->option('user');
|
||||
$userId = (int)$this->option('user');
|
||||
/** @var UserRepositoryInterface $repository */
|
||||
$repository = app(UserRepositoryInterface::class);
|
||||
$user = $repository->find($userId);
|
||||
@@ -71,8 +71,8 @@ trait VerifiesAccessToken
|
||||
*/
|
||||
protected function verifyAccessToken(): bool
|
||||
{
|
||||
$userId = (int) $this->option('user');
|
||||
$token = (string) $this->option('token');
|
||||
$userId = (int)$this->option('user');
|
||||
$token = (string)$this->option('token');
|
||||
/** @var UserRepositoryInterface $repository */
|
||||
$repository = app(UserRepositoryInterface::class);
|
||||
$user = $repository->find($userId);
|
||||
|
@@ -25,6 +25,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use League\Flysystem\FilesystemException;
|
||||
use Log;
|
||||
use Storage;
|
||||
|
||||
@@ -50,7 +51,7 @@ class VerifySecurityAlerts extends Command
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
* @throws \League\Flysystem\FilesystemException
|
||||
* @throws FilesystemException
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
|
Reference in New Issue
Block a user