mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Use PSR-12 code style
This commit is contained in:
@@ -62,8 +62,7 @@ class CorrectOpeningBalanceCurrencies extends Command
|
||||
{
|
||||
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||
// get all OB journals:
|
||||
$set = TransactionJournal
|
||||
::leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
|
||||
$set = TransactionJournal::leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
|
||||
->whereNull('transaction_journals.deleted_at')
|
||||
->where('transaction_types.type', TransactionType::OPENING_BALANCE)->get(['transaction_journals.*']);
|
||||
|
||||
|
@@ -63,7 +63,7 @@ class CreateLinkTypes extends Command
|
||||
$link = LinkType::where('name', $name)
|
||||
->first();
|
||||
if (null === $link) {
|
||||
$link = new LinkType;
|
||||
$link = new LinkType();
|
||||
$link->name = $name;
|
||||
$link->inward = $values[1];
|
||||
$link->outward = $values[0];
|
||||
|
@@ -58,8 +58,7 @@ class DeleteEmptyGroups extends Command
|
||||
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||
$start = microtime(true);
|
||||
$groupIds
|
||||
= TransactionGroup
|
||||
::leftJoin('transaction_journals', 'transaction_groups.id', '=', 'transaction_journals.transaction_group_id')
|
||||
= TransactionGroup::leftJoin('transaction_journals', 'transaction_groups.id', '=', 'transaction_journals.transaction_group_id')
|
||||
->whereNull('transaction_journals.id')->get(['transaction_groups.id'])->pluck('id')->toArray();
|
||||
|
||||
$total = count($groupIds);
|
||||
|
@@ -66,8 +66,7 @@ class DeleteEmptyJournals extends Command
|
||||
*/
|
||||
private function deleteUnevenJournals(): void
|
||||
{
|
||||
$set = Transaction
|
||||
::whereNull('deleted_at')
|
||||
$set = Transaction::whereNull('deleted_at')
|
||||
->groupBy('transactions.transaction_journal_id')
|
||||
->get([DB::raw('COUNT(transactions.transaction_journal_id) as the_count'), 'transaction_journal_id']);
|
||||
$total = 0;
|
||||
@@ -78,7 +77,6 @@ class DeleteEmptyJournals extends Command
|
||||
// uneven number, delete journal and transactions:
|
||||
try {
|
||||
TransactionJournal::find((int) $row->transaction_journal_id)->delete();
|
||||
|
||||
} catch (Exception $e) { // @phpstan-ignore-line
|
||||
Log::info(sprintf('Could not delete journal: %s', $e->getMessage()));
|
||||
}
|
||||
@@ -106,7 +104,6 @@ class DeleteEmptyJournals extends Command
|
||||
foreach ($set as $entry) {
|
||||
try {
|
||||
TransactionJournal::find($entry->id)->delete();
|
||||
|
||||
} catch (Exception $e) { // @phpstan-ignore-line
|
||||
Log::info(sprintf('Could not delete entry: %s', $e->getMessage()));
|
||||
}
|
||||
@@ -121,5 +118,4 @@ class DeleteEmptyJournals extends Command
|
||||
$end = round(microtime(true) - $start, 2);
|
||||
$this->info(sprintf('Verified empty journals in %s seconds', $end));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -72,8 +72,7 @@ class DeleteOrphanedTransactions extends Command
|
||||
private function deleteOrphanedTransactions(): void
|
||||
{
|
||||
$count = 0;
|
||||
$set = Transaction
|
||||
::leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
$set = Transaction::leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->whereNotNull('transaction_journals.deleted_at')
|
||||
->whereNull('transactions.deleted_at')
|
||||
->whereNotNull('transactions.id')
|
||||
@@ -109,8 +108,7 @@ class DeleteOrphanedTransactions extends Command
|
||||
private function deleteFromOrphanedAccounts(): void
|
||||
{
|
||||
$set
|
||||
= Transaction
|
||||
::leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')
|
||||
= Transaction::leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')
|
||||
->whereNotNull('accounts.deleted_at')
|
||||
->get(['transactions.*']);
|
||||
$count = 0;
|
||||
@@ -121,11 +119,9 @@ class DeleteOrphanedTransactions extends Command
|
||||
if ($journal) {
|
||||
try {
|
||||
$journal->delete();
|
||||
|
||||
} catch (Exception $e) { // @phpstan-ignore-line
|
||||
Log::info(sprintf('Could not delete journal %s', $e->getMessage()));
|
||||
}
|
||||
|
||||
}
|
||||
Transaction::where('transaction_journal_id', (int) $transaction->transaction_journal_id)->delete();
|
||||
$this->line(
|
||||
@@ -144,8 +140,7 @@ class DeleteOrphanedTransactions extends Command
|
||||
|
||||
private function deleteOrphanedJournals(): void
|
||||
{
|
||||
$set = TransactionJournal
|
||||
::leftJoin('transaction_groups', 'transaction_journals.transaction_group_id', 'transaction_groups.id')
|
||||
$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']);
|
||||
|
@@ -62,7 +62,6 @@ class DeleteZeroAmount extends Command
|
||||
$this->info(sprintf('Deleted transaction journal #%d because the amount is zero (0.00).', $journal->id));
|
||||
try {
|
||||
$journal->delete();
|
||||
|
||||
} catch (Exception $e) { // @phpstan-ignore-line
|
||||
$this->line($e->getMessage());
|
||||
}
|
||||
|
@@ -88,9 +88,10 @@ class EnableCurrencies extends Command
|
||||
$found = array_values(array_unique($found));
|
||||
$found = array_values(
|
||||
array_filter(
|
||||
$found, function (int $currencyId) {
|
||||
return $currencyId !== 0;
|
||||
}
|
||||
$found,
|
||||
function (int $currencyId) {
|
||||
return $currencyId !== 0;
|
||||
}
|
||||
)
|
||||
);
|
||||
$message = sprintf('%d different currencies are currently in use.', count($found));
|
||||
|
@@ -48,7 +48,7 @@ class FixAccountTypes extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'firefly-iii:fix-account-types';
|
||||
protected $signature = 'firefly-iii:fix-account-types';
|
||||
private int $count;
|
||||
private array $expected;
|
||||
private AccountFactory $factory;
|
||||
@@ -121,12 +121,10 @@ class FixAccountTypes extends Command
|
||||
$destAccountType = $destAccount->accountType->type;
|
||||
|
||||
if (!array_key_exists($type, $this->expected)) {
|
||||
|
||||
Log::info(sprintf('No source/destination info for transaction type %s.', $type));
|
||||
$this->info(sprintf('No source/destination info for transaction type %s.', $type));
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
if (!array_key_exists($sourceAccountType, $this->expected[$type])) {
|
||||
Log::debug(sprintf('Going to fix journal #%d', $journal->id));
|
||||
@@ -211,8 +209,12 @@ class FixAccountTypes extends Command
|
||||
$dest->account()->associate($result);
|
||||
$dest->save();
|
||||
$message = sprintf(
|
||||
'Transaction journal #%d, destination account changed from #%d ("%s") to #%d ("%s").', $journal->id, $oldDest->id, $oldDest->name,
|
||||
$result->id, $result->name
|
||||
'Transaction journal #%d, destination account changed from #%d ("%s") to #%d ("%s").',
|
||||
$journal->id,
|
||||
$oldDest->id,
|
||||
$oldDest->name,
|
||||
$result->id,
|
||||
$result->name
|
||||
);
|
||||
$this->info($message);
|
||||
Log::debug($message);
|
||||
@@ -227,8 +229,12 @@ class FixAccountTypes extends Command
|
||||
$source->account()->associate($result);
|
||||
$source->save();
|
||||
$message = sprintf(
|
||||
'Transaction journal #%d, source account changed from #%d ("%s") to #%d ("%s").', $journal->id, $oldSource->id, $oldSource->name,
|
||||
$result->id, $result->name
|
||||
'Transaction journal #%d, source account changed from #%d ("%s") to #%d ("%s").',
|
||||
$journal->id,
|
||||
$oldSource->id,
|
||||
$oldSource->name,
|
||||
$result->id,
|
||||
$result->name
|
||||
);
|
||||
$this->info($message);
|
||||
Log::debug($message);
|
||||
@@ -244,7 +250,6 @@ class FixAccountTypes extends Command
|
||||
Log::debug($message);
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -57,8 +57,7 @@ class FixGroupAccounts extends Command
|
||||
public function handle(): int
|
||||
{
|
||||
$groups = [];
|
||||
$res = TransactionJournal
|
||||
::groupBy('transaction_group_id')
|
||||
$res = TransactionJournal::groupBy('transaction_group_id')
|
||||
->get(['transaction_group_id', DB::raw('COUNT(transaction_group_id) as the_count')]);
|
||||
/** @var TransactionJournal $journal */
|
||||
foreach ($res as $journal) {
|
||||
@@ -66,7 +65,7 @@ class FixGroupAccounts extends Command
|
||||
$groups[] = (int) $journal->transaction_group_id;
|
||||
}
|
||||
}
|
||||
$handler = new UpdatedGroupEventHandler;
|
||||
$handler = new UpdatedGroupEventHandler();
|
||||
foreach ($groups as $groupId) {
|
||||
$group = TransactionGroup::find($groupId);
|
||||
$event = new UpdatedTransactionGroup($group);
|
||||
|
@@ -57,7 +57,6 @@ class FixIbans extends Command
|
||||
foreach ($accounts as $account) {
|
||||
$iban = $account->iban;
|
||||
if (str_contains($iban, ' ')) {
|
||||
|
||||
$iban = app('steam')->filterSpaces((string) $account->iban);
|
||||
if ('' !== $iban) {
|
||||
$account->iban = $iban;
|
||||
|
@@ -61,7 +61,6 @@ class FixPiggies extends Command
|
||||
|
||||
/** @var PiggyBankEvent $event */
|
||||
foreach ($set as $event) {
|
||||
|
||||
if (null === $event->transaction_journal_id) {
|
||||
continue;
|
||||
}
|
||||
|
@@ -52,7 +52,6 @@ class FixPostgresSequences extends Command
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
|
||||
if (DB::connection()->getName() !== 'pgsql') {
|
||||
$this->info('Command executed successfully.');
|
||||
|
||||
|
@@ -85,8 +85,7 @@ class FixTransactionTypes extends Command
|
||||
*/
|
||||
private function collectJournals(): Collection
|
||||
{
|
||||
return TransactionJournal
|
||||
::with(['transactionType', 'transactions', 'transactions.account', 'transactions.account.accountType'])
|
||||
return TransactionJournal::with(['transactionType', 'transactions', 'transactions.account', 'transactions.account.accountType'])
|
||||
->get();
|
||||
}
|
||||
|
||||
@@ -109,10 +108,15 @@ class FixTransactionTypes extends Command
|
||||
$expectedType = (string) config(sprintf('firefly.account_to_transaction.%s.%s', $source->accountType->type, $destination->accountType->type));
|
||||
if ($expectedType !== $type) {
|
||||
$this->line(
|
||||
sprintf('Transaction journal #%d was of type "%s" but is corrected to "%s" (%s -> %s)',
|
||||
$journal->id, $type, $expectedType,
|
||||
$source->accountType->type, $destination->accountType->type,
|
||||
));
|
||||
sprintf(
|
||||
'Transaction journal #%d was of type "%s" but is corrected to "%s" (%s -> %s)',
|
||||
$journal->id,
|
||||
$type,
|
||||
$expectedType,
|
||||
$source->accountType->type,
|
||||
$destination->accountType->type,
|
||||
)
|
||||
);
|
||||
$this->changeJournal($journal, $expectedType);
|
||||
|
||||
return true;
|
||||
|
@@ -47,7 +47,7 @@ class CreateFirstUser extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'firefly-iii:create-first-user {email}';
|
||||
protected $signature = 'firefly-iii:create-first-user {email}';
|
||||
private UserRepositoryInterface $repository;
|
||||
|
||||
/**
|
||||
@@ -97,6 +97,5 @@ class CreateFirstUser extends Command
|
||||
private function stupidLaravel(): void
|
||||
{
|
||||
$this->repository = app(UserRepositoryInterface::class);
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -56,7 +56,7 @@ class ExportData extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'firefly-iii:export-data
|
||||
protected $signature = 'firefly-iii:export-data
|
||||
{--user=1 : The user ID that the export should run for.}
|
||||
{--token= : The user\'s access token.}
|
||||
{--start= : First transaction to export. Defaults to your very first transaction. Only applies to transaction export.}
|
||||
@@ -230,8 +230,8 @@ class ExportData extends Command
|
||||
*/
|
||||
private function getAccountsParameter(): Collection
|
||||
{
|
||||
$final = new Collection;
|
||||
$accounts = new Collection;
|
||||
$final = new Collection();
|
||||
$accounts = new Collection();
|
||||
$accountList = $this->option('accounts');
|
||||
$types = [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE];
|
||||
if (null !== $accountList && '' !== (string) $accountList) {
|
||||
|
@@ -131,7 +131,6 @@ class ReportEmptyObjects extends Command
|
||||
|
||||
/** @var stdClass $entry */
|
||||
foreach ($set as $entry) {
|
||||
|
||||
$line = sprintf(
|
||||
'User #%d (%s) has tag #%d ("%s") which has no transaction journals.',
|
||||
$entry->user_id,
|
||||
|
@@ -34,7 +34,6 @@ use Schema;
|
||||
*/
|
||||
class ReportIntegrity extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
|
@@ -79,6 +79,5 @@ class ReportSum extends Command
|
||||
}
|
||||
$end = round(microtime(true) - $start, 2);
|
||||
$this->info(sprintf('Report on total sum finished in %s seconds', $end));
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -56,7 +56,7 @@ class ApplyRules extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature
|
||||
protected $signature
|
||||
= 'firefly-iii:apply-rules
|
||||
{--user=1 : The user ID.}
|
||||
{--token= : The user\'s access token.}
|
||||
@@ -161,13 +161,13 @@ class ApplyRules extends Command
|
||||
private function stupidLaravel(): void
|
||||
{
|
||||
$this->allRules = false;
|
||||
$this->accounts = new Collection;
|
||||
$this->accounts = new Collection();
|
||||
$this->ruleSelection = [];
|
||||
$this->ruleGroupSelection = [];
|
||||
$this->ruleRepository = app(RuleRepositoryInterface::class);
|
||||
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
|
||||
$this->acceptedAccounts = [AccountType::DEFAULT, AccountType::DEBT, AccountType::ASSET, AccountType::LOAN, AccountType::MORTGAGE];
|
||||
$this->groups = new Collection;
|
||||
$this->groups = new Collection();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -205,7 +205,7 @@ class ApplyRules extends Command
|
||||
|
||||
return false;
|
||||
}
|
||||
$finalList = new Collection;
|
||||
$finalList = new Collection();
|
||||
$accountList = explode(',', $accountString);
|
||||
|
||||
/** @var AccountRepositoryInterface $accountRepository */
|
||||
@@ -227,7 +227,6 @@ class ApplyRules extends Command
|
||||
$this->accounts = $finalList;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -325,7 +324,7 @@ class ApplyRules extends Command
|
||||
*/
|
||||
private function getRulesToApply(): Collection
|
||||
{
|
||||
$rulesToApply = new Collection;
|
||||
$rulesToApply = new Collection();
|
||||
/** @var RuleGroup $group */
|
||||
foreach ($this->groups as $group) {
|
||||
$rules = $this->ruleGroupRepository->getActiveStoreRules($group);
|
||||
|
@@ -129,7 +129,7 @@ class Cron extends Command
|
||||
*/
|
||||
private function recurringCronJob(bool $force, ?Carbon $date): void
|
||||
{
|
||||
$recurring = new RecurringCronjob;
|
||||
$recurring = new RecurringCronjob();
|
||||
$recurring->setForce($force);
|
||||
|
||||
// set date in cron job:
|
||||
@@ -156,7 +156,7 @@ class Cron extends Command
|
||||
*/
|
||||
private function autoBudgetCronJob(bool $force, ?Carbon $date): void
|
||||
{
|
||||
$autoBudget = new AutoBudgetCronjob;
|
||||
$autoBudget = new AutoBudgetCronjob();
|
||||
$autoBudget->setForce($force);
|
||||
// set date in cron job:
|
||||
if (null !== $date) {
|
||||
@@ -174,7 +174,6 @@ class Cron extends Command
|
||||
if ($autoBudget->jobSucceeded) {
|
||||
$this->info(sprintf('"Create auto budgets" cron ran with success: %s', $autoBudget->message));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,7 +183,7 @@ class Cron extends Command
|
||||
*/
|
||||
private function billWarningCronJob(bool $force, ?Carbon $date): void
|
||||
{
|
||||
$autoBudget = new BillWarningCronjob;
|
||||
$autoBudget = new BillWarningCronjob();
|
||||
$autoBudget->setForce($force);
|
||||
// set date in cron job:
|
||||
if (null !== $date) {
|
||||
@@ -202,7 +201,6 @@ class Cron extends Command
|
||||
if ($autoBudget->jobSucceeded) {
|
||||
$this->info(sprintf('"Send bill warnings" cron ran with success: %s', $autoBudget->message));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,7 +210,7 @@ class Cron extends Command
|
||||
*/
|
||||
private function exchangeRatesCronJob(bool $force, ?Carbon $date): void
|
||||
{
|
||||
$exchangeRates = new ExchangeRatesCronjob;
|
||||
$exchangeRates = new ExchangeRatesCronjob();
|
||||
$exchangeRates->setForce($force);
|
||||
// set date in cron job:
|
||||
if (null !== $date) {
|
||||
@@ -230,6 +228,5 @@ class Cron extends Command
|
||||
if ($exchangeRates->jobSucceeded) {
|
||||
$this->info(sprintf('"Exchange rates" cron ran with success: %s', $exchangeRates->message));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -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