mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-10 12:24:50 +00:00
Use PSR-12 code style
This commit is contained in:
@@ -103,7 +103,10 @@ class AppendBudgetLimitPeriods extends Command
|
||||
|
||||
if (null === $period) {
|
||||
$message = sprintf(
|
||||
'Could not guesstimate budget limit #%d (%s - %s) period.', $limit->id, $limit->start_date->format('Y-m-d'), $limit->end_date->format('Y-m-d')
|
||||
'Could not guesstimate budget limit #%d (%s - %s) period.',
|
||||
$limit->id,
|
||||
$limit->start_date->format('Y-m-d'),
|
||||
$limit->end_date->format('Y-m-d')
|
||||
);
|
||||
$this->warn($message);
|
||||
Log::warning($message);
|
||||
@@ -114,10 +117,13 @@ class AppendBudgetLimitPeriods extends Command
|
||||
$limit->save();
|
||||
|
||||
$msg = sprintf(
|
||||
'Budget limit #%d (%s - %s) period is "%s".', $limit->id, $limit->start_date->format('Y-m-d'), $limit->end_date->format('Y-m-d'), $period
|
||||
'Budget limit #%d (%s - %s) period is "%s".',
|
||||
$limit->id,
|
||||
$limit->start_date->format('Y-m-d'),
|
||||
$limit->end_date->format('Y-m-d'),
|
||||
$period
|
||||
);
|
||||
Log::debug($msg);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,8 +165,8 @@ class AppendBudgetLimitPeriods extends Command
|
||||
$start = ['1-1', '1-7'];
|
||||
$end = ['30-6', '31-12'];
|
||||
if (
|
||||
in_array($limit->start_date->format('j-n'), $start) // start of quarter
|
||||
&& in_array($limit->end_date->format('j-n'), $end) // end of quarter
|
||||
in_array($limit->start_date->format('j-n'), $start, true) // start of quarter
|
||||
&& in_array($limit->end_date->format('j-n'), $end, true) // end of quarter
|
||||
&& 5 === $limit->start_date->diffInMonths($limit->end_date)
|
||||
) {
|
||||
return 'half_year';
|
||||
|
||||
@@ -60,7 +60,6 @@ class BackToJournals extends Command
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
|
||||
$start = microtime(true);
|
||||
if (!$this->isMigrated()) {
|
||||
$this->error('Please run firefly-iii:migrate-to-groups first.');
|
||||
@@ -128,7 +127,7 @@ class BackToJournals extends Command
|
||||
*/
|
||||
private function migrateBudgets(): void
|
||||
{
|
||||
$journals = new Collection;
|
||||
$journals = new Collection();
|
||||
$allIds = $this->getIdsForBudgets();
|
||||
$chunks = array_chunk($allIds, 500);
|
||||
foreach ($chunks as $journalIds) {
|
||||
@@ -164,16 +163,13 @@ class BackToJournals extends Command
|
||||
*/
|
||||
private function migrateBudgetsForJournal(TransactionJournal $journal): void
|
||||
{
|
||||
|
||||
// grab category from first transaction
|
||||
/** @var Transaction $transaction */
|
||||
$transaction = $journal->transactions->first();
|
||||
if (null === $transaction) {
|
||||
|
||||
$this->info(sprintf('Transaction journal #%d has no transactions. Will be fixed later.', $journal->id));
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
/** @var Budget $budget */
|
||||
$budget = $transaction->budgets->first();
|
||||
@@ -201,7 +197,7 @@ class BackToJournals extends Command
|
||||
private function migrateCategories(): void
|
||||
{
|
||||
Log::debug('Now in migrateCategories()');
|
||||
$journals = new Collection;
|
||||
$journals = new Collection();
|
||||
$allIds = $this->getIdsForCategories();
|
||||
|
||||
Log::debug(sprintf('Total: %d', count($allIds)));
|
||||
@@ -247,11 +243,9 @@ class BackToJournals extends Command
|
||||
/** @var Transaction $transaction */
|
||||
$transaction = $journal->transactions->first();
|
||||
if (null === $transaction) {
|
||||
|
||||
$this->info(sprintf('Transaction journal #%d has no transactions. Will be fixed later.', $journal->id));
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
/** @var Category $category */
|
||||
$category = $transaction->categories->first();
|
||||
|
||||
@@ -56,7 +56,6 @@ class MigrateAttachments extends Command
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
|
||||
$start = microtime(true);
|
||||
if ($this->isExecuted() && true !== $this->option('force')) {
|
||||
$this->warn('This command has already been executed.');
|
||||
@@ -70,15 +69,13 @@ class MigrateAttachments extends Command
|
||||
|
||||
/** @var Attachment $att */
|
||||
foreach ($attachments as $att) {
|
||||
|
||||
// move description:
|
||||
$attDescription = (string) $att->description;
|
||||
if ('' !== $attDescription) {
|
||||
|
||||
// find or create note:
|
||||
$note = $att->notes()->first();
|
||||
if (null === $note) {
|
||||
$note = new Note;
|
||||
$note = new Note();
|
||||
$note->noteable()->associate($att);
|
||||
}
|
||||
$note->text = $attDescription;
|
||||
|
||||
@@ -81,7 +81,6 @@ class MigrateJournalNotes extends Command
|
||||
Log::debug(sprintf('Migrated meta note #%d to Note #%d', $meta->id, $note->id));
|
||||
try {
|
||||
$meta->delete();
|
||||
|
||||
} catch (Exception $e) { // @phpstan-ignore-line
|
||||
Log::error(sprintf('Could not delete old meta entry #%d: %s', $meta->id, $e->getMessage()));
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ use Illuminate\Console\Command;
|
||||
*/
|
||||
class MigrateTagLocations extends Command
|
||||
{
|
||||
|
||||
public const CONFIG_NAME = '500_migrate_tag_locations';
|
||||
/**
|
||||
* The console command description.
|
||||
@@ -114,7 +113,7 @@ class MigrateTagLocations extends Command
|
||||
*/
|
||||
private function migrateLocationDetails(Tag $tag): void
|
||||
{
|
||||
$location = new Location;
|
||||
$location = new Location();
|
||||
$location->longitude = $tag->longitude;
|
||||
$location->latitude = $tag->latitude;
|
||||
$location->zoom_level = $tag->zoomLevel;
|
||||
|
||||
@@ -59,7 +59,7 @@ class MigrateToGroups extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'firefly-iii:migrate-to-groups {--F|force : Force the migration, even if it fired before.}';
|
||||
protected $signature = 'firefly-iii:migrate-to-groups {--F|force : Force the migration, even if it fired before.}';
|
||||
private JournalCLIRepositoryInterface $cliRepository;
|
||||
private int $count;
|
||||
private TransactionGroupFactory $groupFactory;
|
||||
@@ -169,11 +169,9 @@ class MigrateToGroups extends Command
|
||||
{
|
||||
// double check transaction count.
|
||||
if ($journal->transactions->count() <= 2) {
|
||||
|
||||
Log::debug(sprintf('Will not try to convert journal #%d because it has 2 or less transactions.', $journal->id));
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
Log::debug(sprintf('Will now try to convert journal #%d', $journal->id));
|
||||
|
||||
@@ -221,7 +219,6 @@ class MigrateToGroups extends Command
|
||||
$opposingTr = $this->findOpposingTransaction($journal, $transaction);
|
||||
|
||||
if (null === $opposingTr) {
|
||||
|
||||
$this->error(
|
||||
sprintf(
|
||||
'Journal #%d has no opposing transaction for transaction #%d. Cannot upgrade this entry.',
|
||||
@@ -230,7 +227,6 @@ class MigrateToGroups extends Command
|
||||
)
|
||||
);
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
// overrule journal category with transaction category.
|
||||
|
||||
@@ -166,7 +166,6 @@ class MigrateToRules extends Command
|
||||
foreach ($bills as $bill) {
|
||||
$this->migrateBill($ruleGroup, $bill, $lang);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -159,26 +159,25 @@ class OtherCurrenciesCorrections extends Command
|
||||
$leadTransaction = $this->getLeadTransaction($journal);
|
||||
|
||||
if (null === $leadTransaction) {
|
||||
|
||||
$this->error(sprintf('Could not reliably determine which transaction is in the lead for transaction journal #%d.', $journal->id));
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
$account = $leadTransaction->account;
|
||||
$currency = $this->getCurrency($account);
|
||||
if (null === $currency) {
|
||||
|
||||
$this->error(
|
||||
sprintf(
|
||||
'Account #%d ("%s") has no currency preference, so transaction journal #%d can\'t be corrected', $account->id, $account->name, $journal->id
|
||||
'Account #%d ("%s") has no currency preference, so transaction journal #%d can\'t be corrected',
|
||||
$account->id,
|
||||
$account->name,
|
||||
$journal->id
|
||||
)
|
||||
);
|
||||
$this->count++;
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
// fix each transaction:
|
||||
$journal->transactions->each(
|
||||
@@ -227,13 +226,19 @@ class OtherCurrenciesCorrections extends Command
|
||||
case TransactionType::OPENING_BALANCE:
|
||||
// whichever isn't an initial balance account:
|
||||
$lead = $journal->transactions()->leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')->leftJoin(
|
||||
'account_types', 'accounts.account_type_id', '=', 'account_types.id'
|
||||
'account_types',
|
||||
'accounts.account_type_id',
|
||||
'=',
|
||||
'account_types.id'
|
||||
)->where('account_types.type', '!=', AccountType::INITIAL_BALANCE)->first(['transactions.*']);
|
||||
break;
|
||||
case TransactionType::RECONCILIATION:
|
||||
// whichever isn't the reconciliation account:
|
||||
$lead = $journal->transactions()->leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')->leftJoin(
|
||||
'account_types', 'accounts.account_type_id', '=', 'account_types.id'
|
||||
'account_types',
|
||||
'accounts.account_type_id',
|
||||
'=',
|
||||
'account_types.id'
|
||||
)->where('account_types.type', '!=', AccountType::RECONCILIATION)->first(['transactions.*']);
|
||||
break;
|
||||
}
|
||||
@@ -257,11 +262,9 @@ class OtherCurrenciesCorrections extends Command
|
||||
}
|
||||
$currency = $this->accountRepos->getAccountCurrency($account);
|
||||
if (null === $currency) {
|
||||
|
||||
$this->accountCurrencies[$accountId] = 0;
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
$this->accountCurrencies[$accountId] = $currency;
|
||||
|
||||
|
||||
@@ -163,7 +163,6 @@ class TransactionIdentifier extends Command
|
||||
}
|
||||
++$identifier;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -183,7 +182,6 @@ class TransactionIdentifier extends Command
|
||||
->where('amount', $amount)->where('identifier', '=', 0)
|
||||
->whereNotIn('id', $exclude)
|
||||
->first();
|
||||
|
||||
} catch (QueryException $e) {
|
||||
Log::error($e->getMessage());
|
||||
$this->error('Firefly III could not find the "identifier" field in the "transactions" table.');
|
||||
|
||||
@@ -51,7 +51,7 @@ class TransferCurrenciesCorrections extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'firefly-iii:transfer-currencies {--F|force : Force the execution of this command.}';
|
||||
protected $signature = 'firefly-iii:transfer-currencies {--F|force : Force the execution of this command.}';
|
||||
private array $accountCurrencies;
|
||||
private AccountRepositoryInterface $accountRepos;
|
||||
private JournalCLIRepositoryInterface $cliRepos;
|
||||
@@ -284,11 +284,9 @@ class TransferCurrenciesCorrections extends Command
|
||||
}
|
||||
$currency = $this->accountRepos->getAccountCurrency($account);
|
||||
if (null === $currency) {
|
||||
|
||||
$this->accountCurrencies[$accountId] = 0;
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
$this->accountCurrencies[$accountId] = $currency;
|
||||
|
||||
|
||||
@@ -55,7 +55,6 @@ class UpgradeDatabase extends Command
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
|
||||
$this->callInitialCommands();
|
||||
$commands = [
|
||||
// there are 14 upgrade commands.
|
||||
|
||||
@@ -201,5 +201,4 @@ class UpgradeLiabilities extends Command
|
||||
{
|
||||
app('fireflyconfig')->set(self::CONFIG_NAME, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user