Various code cleanup and fixed alignments.

This commit is contained in:
James Cole
2024-01-01 14:43:56 +01:00
parent 1368aafe5f
commit f963ac63f1
443 changed files with 3668 additions and 3672 deletions

View File

@@ -44,8 +44,8 @@ class AccountCurrencies extends Command
public const string CONFIG_NAME = '480_account_currencies';
protected $description = 'Give all accounts proper currency info.';
protected $signature = 'firefly-iii:account-currencies {--F|force : Force the execution of this command.}';
protected $description = 'Give all accounts proper currency info.';
protected $signature = 'firefly-iii:account-currencies {--F|force : Force the execution of this command.}';
private AccountRepositoryInterface $accountRepos;
private int $count;
private UserRepositoryInterface $userRepos;
@@ -109,7 +109,7 @@ class AccountCurrencies extends Command
private function updateCurrenciesForUser(User $user): void
{
$this->accountRepos->setUser($user);
$accounts = $this->accountRepos->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
$accounts = $this->accountRepos->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
// get user's currency preference:
$defaultCurrency = app('amount')->getDefaultCurrencyByUserGroup($user->userGroup);

View File

@@ -36,9 +36,9 @@ class AppendBudgetLimitPeriods extends Command
public const string CONFIG_NAME = '550_budget_limit_periods';
protected $description = 'Append budget limits with their (estimated) timeframe.';
protected $description = 'Append budget limits with their (estimated) timeframe.';
protected $signature = 'firefly-iii:budget-limit-periods {--F|force : Force the execution of this command.}';
protected $signature = 'firefly-iii:budget-limit-periods {--F|force : Force the execution of this command.}';
/**
* Execute the console command.
@@ -76,7 +76,7 @@ class AppendBudgetLimitPeriods extends Command
private function fixLimit(BudgetLimit $limit): void
{
$period = $this->getLimitPeriod($limit);
$period = $this->getLimitPeriod($limit);
if (null === $period) {
$message = sprintf(
@@ -93,7 +93,7 @@ class AppendBudgetLimitPeriods extends Command
$limit->period = $period;
$limit->save();
$msg = sprintf(
$msg = sprintf(
'Budget limit #%d (%s - %s) period is "%s".',
$limit->id,
$limit->start_date->format('Y-m-d'),

View File

@@ -40,9 +40,9 @@ class BackToJournals extends Command
public const string CONFIG_NAME = '480_back_to_journals';
protected $description = 'Move meta data back to journals, not individual transactions.';
protected $description = 'Move meta data back to journals, not individual transactions.';
protected $signature = 'firefly-iii:back-to-journals {--F|force : Force the execution of this command.}';
protected $signature = 'firefly-iii:back-to-journals {--F|force : Force the execution of this command.}';
/**
* Execute the console command.
@@ -126,7 +126,7 @@ class BackToJournals extends Command
{
// grab category from first transaction
/** @var null|Transaction $transaction */
$transaction = $journal->transactions->first();
$transaction = $journal->transactions->first();
if (null === $transaction) {
$this->friendlyInfo(sprintf('Transaction journal #%d has no transactions. Will be fixed later.', $journal->id));
@@ -134,7 +134,7 @@ class BackToJournals extends Command
}
/** @var null|Budget $budget */
$budget = $transaction->budgets->first();
$budget = $transaction->budgets->first();
/** @var null|Budget $journalBudget */
$journalBudget = $journal->budgets->first();
@@ -159,7 +159,7 @@ class BackToJournals extends Command
$journals = new Collection();
$allIds = $this->getIdsForCategories();
$chunks = array_chunk($allIds, 500);
$chunks = array_chunk($allIds, 500);
foreach ($chunks as $chunk) {
$collected = TransactionJournal::whereIn('id', $chunk)->with(['transactions', 'categories', 'transactions.categories'])->get();
$journals = $journals->merge($collected);
@@ -192,7 +192,7 @@ class BackToJournals extends Command
{
// grab category from first transaction
/** @var null|Transaction $transaction */
$transaction = $journal->transactions->first();
$transaction = $journal->transactions->first();
if (null === $transaction) {
$this->friendlyInfo(sprintf('Transaction journal #%d has no transactions. Will be fixed later.', $journal->id));
@@ -200,7 +200,7 @@ class BackToJournals extends Command
}
/** @var null|Category $category */
$category = $transaction->categories->first();
$category = $transaction->categories->first();
/** @var null|Category $journalCategory */
$journalCategory = $journal->categories->first();

View File

@@ -39,9 +39,9 @@ class BudgetLimitCurrency extends Command
public const string CONFIG_NAME = '480_bl_currency';
protected $description = 'Give budget limits a currency';
protected $description = 'Give budget limits a currency';
protected $signature = 'firefly-iii:bl-currency {--F|force : Force the execution of this command.}';
protected $signature = 'firefly-iii:bl-currency {--F|force : Force the execution of this command.}';
/**
* Execute the console command.

View File

@@ -38,8 +38,8 @@ class CCLiabilities extends Command
use ShowsFriendlyMessages;
public const string CONFIG_NAME = '480_cc_liabilities';
protected $description = 'Convert old credit card liabilities.';
protected $signature = 'firefly-iii:cc-liabilities {--F|force : Force the execution of this command.}';
protected $description = 'Convert old credit card liabilities.';
protected $signature = 'firefly-iii:cc-liabilities {--F|force : Force the execution of this command.}';
/**
* Execute the console command.

View File

@@ -119,8 +119,8 @@ class DecryptDatabase extends Command
if (null === $original) {
return;
}
$id = (int)$row->id;
$value = '';
$id = (int)$row->id;
$value = '';
try {
$value = $this->tryDecrypt($original);

View File

@@ -36,7 +36,7 @@ class FixPostgresSequences extends Command
protected $description = 'Fixes issues with PostgreSQL sequences.';
protected $signature = 'firefly-iii:fix-pgsql-sequences';
protected $signature = 'firefly-iii:fix-pgsql-sequences';
/**
* Execute the console command.

View File

@@ -38,9 +38,9 @@ class MigrateAttachments extends Command
public const string CONFIG_NAME = '480_migrate_attachments';
protected $description = 'Migrates attachment meta-data.';
protected $description = 'Migrates attachment meta-data.';
protected $signature = 'firefly-iii:migrate-attachments {--F|force : Force the execution of this command.}';
protected $signature = 'firefly-iii:migrate-attachments {--F|force : Force the execution of this command.}';
/**
* Execute the console command.
@@ -49,7 +49,7 @@ class MigrateAttachments extends Command
*/
public function handle(): int
{
$start = microtime(true);
$start = microtime(true);
if ($this->isExecuted() && true !== $this->option('force')) {
$this->friendlyInfo('This command has already been executed.');
@@ -65,12 +65,12 @@ class MigrateAttachments extends Command
$attDescription = (string)$att->description;
if ('' !== $attDescription) {
// find or create note:
$note = $att->notes()->first();
$note = $att->notes()->first();
if (null === $note) {
$note = new Note();
$note->noteable()->associate($att);
}
$note->text = $attDescription;
$note->text = $attDescription;
$note->save();
// clear description:
@@ -87,7 +87,7 @@ class MigrateAttachments extends Command
if (0 !== $count) {
$this->friendlyInfo(sprintf('Updated %d attachment(s).', $count));
}
$end = round(microtime(true) - $start, 2);
$end = round(microtime(true) - $start, 2);
$this->friendlyInfo(sprintf('Migrated attachment notes in %s seconds.', $end));
$this->markAsExecuted();

View File

@@ -37,9 +37,9 @@ class MigrateJournalNotes extends Command
public const string CONFIG_NAME = '480_migrate_notes';
protected $description = 'Migrate notes for transaction journals.';
protected $description = 'Migrate notes for transaction journals.';
protected $signature = 'firefly-iii:migrate-notes {--F|force : Force the execution of this command.}';
protected $signature = 'firefly-iii:migrate-notes {--F|force : Force the execution of this command.}';
/**
* Execute the console command.
@@ -59,8 +59,8 @@ class MigrateJournalNotes extends Command
/** @var TransactionJournalMeta $meta */
foreach ($set as $meta) {
$journal = $meta->transactionJournal;
$note = $journal->notes()->first();
$journal = $meta->transactionJournal;
$note = $journal->notes()->first();
if (null === $note) {
$note = new Note();
$note->noteable()->associate($journal);
@@ -81,7 +81,7 @@ class MigrateJournalNotes extends Command
$this->friendlyInfo(sprintf('Migrated %d note(s).', $count));
}
$end = round(microtime(true) - $start, 2);
$end = round(microtime(true) - $start, 2);
$this->friendlyInfo(sprintf('Migrated notes in %s seconds.', $end));
$this->markAsExecuted();

View File

@@ -39,9 +39,9 @@ class MigrateRecurrenceMeta extends Command
public const string CONFIG_NAME = '481_migrate_recurrence_meta';
protected $description = 'Migrate recurrence meta data';
protected $description = 'Migrate recurrence meta data';
protected $signature = 'firefly-iii:migrate-recurrence-meta {--F|force : Force the execution of this command.}';
protected $signature = 'firefly-iii:migrate-recurrence-meta {--F|force : Force the execution of this command.}';
/**
* Execute the console command.
@@ -79,7 +79,7 @@ class MigrateRecurrenceMeta extends Command
private function migrateMetaData(): int
{
$count = 0;
$count = 0;
// get all recurrence meta data:
$collection = RecurrenceMeta::with('recurrence')->get();
@@ -94,7 +94,7 @@ class MigrateRecurrenceMeta extends Command
private function migrateEntry(RecurrenceMeta $meta): int
{
/** @var null|Recurrence $recurrence */
$recurrence = $meta->recurrence;
$recurrence = $meta->recurrence;
if (null === $recurrence) {
return 0;
}
@@ -102,7 +102,7 @@ class MigrateRecurrenceMeta extends Command
if (null === $firstTransaction) {
return 0;
}
$value = $meta->value;
$value = $meta->value;
if ('tags' === $meta->name) {
$array = explode(',', $meta->value);

View File

@@ -25,9 +25,6 @@ declare(strict_types=1);
namespace FireflyIII\Console\Commands\Upgrade;
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Models\Recurrence;
use FireflyIII\Models\RecurrenceTransaction;
use FireflyIII\Models\TransactionType;
use Illuminate\Console\Command;
/**
@@ -39,9 +36,9 @@ class MigrateRecurrenceType extends Command
public const string CONFIG_NAME = '550_migrate_recurrence_type';
protected $description = 'Migrate transaction type of recurring transaction.';
protected $description = 'Migrate transaction type of recurring transaction.';
protected $signature = 'firefly-iii:migrate-recurrence-type {--F|force : Force the execution of this command.}';
protected $signature = 'firefly-iii:migrate-recurrence-type {--F|force : Force the execution of this command.}';
/**
* Execute the console command.
@@ -66,7 +63,6 @@ class MigrateRecurrenceType extends Command
return (bool)$configVar?->data;
}
private function markAsExecuted(): void
{
app('fireflyconfig')->set(self::CONFIG_NAME, true);

View File

@@ -38,9 +38,9 @@ class MigrateTagLocations extends Command
public const string CONFIG_NAME = '500_migrate_tag_locations';
protected $description = 'Migrate tag locations.';
protected $description = 'Migrate tag locations.';
protected $signature = 'firefly-iii:migrate-tag-locations {--F|force : Force the execution of this command.}';
protected $signature = 'firefly-iii:migrate-tag-locations {--F|force : Force the execution of this command.}';
/**
* Execute the console command.
@@ -94,9 +94,9 @@ class MigrateTagLocations extends Command
$location->locatable()->associate($tag);
$location->save();
$tag->longitude = null;
$tag->latitude = null;
$tag->zoomLevel = null;
$tag->longitude = null;
$tag->latitude = null;
$tag->zoomLevel = null;
$tag->save();
}

View File

@@ -47,8 +47,8 @@ class MigrateToGroups extends Command
use ShowsFriendlyMessages;
public const string CONFIG_NAME = '480_migrated_to_groups';
protected $description = 'Migrates a pre-4.7.8 transaction structure to the 4.7.8+ transaction structure.';
protected $signature = 'firefly-iii:migrate-to-groups {--F|force : Force the migration, even if it fired before.}';
protected $description = 'Migrates a pre-4.7.8 transaction structure to the 4.7.8+ transaction structure.';
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;
@@ -157,7 +157,7 @@ class MigrateToGroups extends Command
$data['transactions'][] = $this->generateTransaction($journal, $transaction);
}
app('log')->debug(sprintf('Now calling transaction journal factory (%d transactions in array)', count($data['transactions'])));
$group = $this->groupFactory->create($data);
$group = $this->groupFactory->create($data);
app('log')->debug('Done calling transaction journal factory');
// delete the old transaction journal.
@@ -215,7 +215,7 @@ class MigrateToGroups extends Command
private function generateTransaction(TransactionJournal $journal, Transaction $transaction): array
{
app('log')->debug(sprintf('Now going to add transaction #%d to the array.', $transaction->id));
$opposingTr = $this->findOpposingTransaction($journal, $transaction);
$opposingTr = $this->findOpposingTransaction($journal, $transaction);
if (null === $opposingTr) {
$this->friendlyError(
@@ -256,8 +256,8 @@ class MigrateToGroups extends Command
$invoiceDate = $this->cliRepository->getMetaDate($journal, 'invoice_date');
// overrule journal category with transaction category.
$budgetId = $this->getTransactionBudget($transaction, $opposingTr) ?? $budgetId;
$categoryId = $this->getTransactionCategory($transaction, $opposingTr) ?? $categoryId;
$budgetId = $this->getTransactionBudget($transaction, $opposingTr) ?? $budgetId;
$categoryId = $this->getTransactionCategory($transaction, $opposingTr) ?? $categoryId;
return [
'type' => strtolower($journal->transactionType->type),

View File

@@ -44,9 +44,9 @@ class MigrateToRules extends Command
public const string CONFIG_NAME = '480_bills_to_rules';
protected $description = 'Migrate bills to rules.';
protected $description = 'Migrate bills to rules.';
protected $signature = 'firefly-iii:bills-to-rules {--F|force : Force the execution of this command.}';
protected $signature = 'firefly-iii:bills-to-rules {--F|force : Force the execution of this command.}';
private BillRepositoryInterface $billRepository;
private int $count;
private RuleGroupRepositoryInterface $ruleGroupRepository;
@@ -137,7 +137,7 @@ class MigrateToRules extends Command
]
);
}
$bills = $this->billRepository->getBills();
$bills = $this->billRepository->getBills();
/** @var Bill $bill */
foreach ($bills as $bill) {
@@ -153,8 +153,8 @@ class MigrateToRules extends Command
$languageString = null !== $language->data && !is_array($language->data) ? (string)$language->data : 'en_US';
// get match thing:
$match = implode(' ', explode(',', $bill->match));
$newRule = [
$match = implode(' ', explode(',', $bill->match));
$newRule = [
'rule_group_id' => $ruleGroup->id,
'active' => true,
'strict' => false,
@@ -197,7 +197,7 @@ class MigrateToRules extends Command
$this->ruleRepository->store($newRule);
// update bill:
$newBillData = [
$newBillData = [
'currency_id' => $bill->transaction_currency_id,
'name' => $bill->name,
'match' => 'MIGRATED_TO_RULES',

View File

@@ -43,8 +43,8 @@ class OtherCurrenciesCorrections extends Command
use ShowsFriendlyMessages;
public const string CONFIG_NAME = '480_other_currencies';
protected $description = 'Update all journal currency information.';
protected $signature = 'firefly-iii:other-currencies {--F|force : Force the execution of this command.}';
protected $description = 'Update all journal currency information.';
protected $signature = 'firefly-iii:other-currencies {--F|force : Force the execution of this command.}';
private array $accountCurrencies;
private AccountRepositoryInterface $accountRepos;
private JournalCLIRepositoryInterface $cliRepos;
@@ -120,7 +120,7 @@ class OtherCurrenciesCorrections extends Command
$this->journalRepos->setUser($journal->user);
$this->cliRepos->setUser($journal->user);
$leadTransaction = $this->getLeadTransaction($journal);
$leadTransaction = $this->getLeadTransaction($journal);
if (null === $leadTransaction) {
$this->friendlyError(sprintf('Could not reliably determine which transaction is in the lead for transaction journal #%d.', $journal->id));
@@ -128,8 +128,8 @@ class OtherCurrenciesCorrections extends Command
return;
}
$account = $leadTransaction->account;
$currency = $this->getCurrency($account);
$account = $leadTransaction->account;
$currency = $this->getCurrency($account);
if (null === $currency) {
$this->friendlyError(
sprintf(
@@ -217,14 +217,14 @@ class OtherCurrenciesCorrections extends Command
private function getCurrency(Account $account): ?TransactionCurrency
{
$accountId = $account->id;
$accountId = $account->id;
if (array_key_exists($accountId, $this->accountCurrencies) && 0 === $this->accountCurrencies[$accountId]) {
return null;
}
if (array_key_exists($accountId, $this->accountCurrencies) && $this->accountCurrencies[$accountId] instanceof TransactionCurrency) {
return $this->accountCurrencies[$accountId];
}
$currency = $this->accountRepos->getAccountCurrency($account);
$currency = $this->accountRepos->getAccountCurrency($account);
if (null === $currency) {
$this->accountCurrencies[$accountId] = 0;

View File

@@ -37,9 +37,9 @@ class RenameAccountMeta extends Command
public const string CONFIG_NAME = '480_rename_account_meta';
protected $description = 'Rename account meta-data to new format.';
protected $description = 'Rename account meta-data to new format.';
protected $signature = 'firefly-iii:rename-account-meta {--F|force : Force the execution of this command.}';
protected $signature = 'firefly-iii:rename-account-meta {--F|force : Force the execution of this command.}';
/**
* Execute the console command.

View File

@@ -39,8 +39,8 @@ class TransactionIdentifier extends Command
use ShowsFriendlyMessages;
public const string CONFIG_NAME = '480_transaction_identifier';
protected $description = 'Fixes transaction identifiers.';
protected $signature = 'firefly-iii:transaction-identifiers {--F|force : Force the execution of this command.}';
protected $description = 'Fixes transaction identifiers.';
protected $signature = 'firefly-iii:transaction-identifiers {--F|force : Force the execution of this command.}';
private JournalCLIRepositoryInterface $cliRepository;
private int $count;
@@ -130,8 +130,8 @@ class TransactionIdentifier extends Command
$opposing->identifier = $identifier;
$transaction->save();
$opposing->save();
$exclude[] = $transaction->id;
$exclude[] = $opposing->id;
$exclude[] = $transaction->id;
$exclude[] = $opposing->id;
++$this->count;
}
++$identifier;

View File

@@ -41,8 +41,8 @@ class TransferCurrenciesCorrections extends Command
use ShowsFriendlyMessages;
public const string CONFIG_NAME = '480_transfer_currencies';
protected $description = 'Updates transfer currency information.';
protected $signature = 'firefly-iii:transfer-currencies {--F|force : Force the execution of this command.}';
protected $description = 'Updates transfer currency information.';
protected $signature = 'firefly-iii:transfer-currencies {--F|force : Force the execution of this command.}';
private array $accountCurrencies;
private AccountRepositoryInterface $accountRepos;
private JournalCLIRepositoryInterface $cliRepos;
@@ -219,14 +219,14 @@ class TransferCurrenciesCorrections extends Command
private function getCurrency(Account $account): ?TransactionCurrency
{
$accountId = $account->id;
$accountId = $account->id;
if (array_key_exists($accountId, $this->accountCurrencies) && 0 === $this->accountCurrencies[$accountId]) {
return null;
}
if (array_key_exists($accountId, $this->accountCurrencies) && $this->accountCurrencies[$accountId] instanceof TransactionCurrency) {
return $this->accountCurrencies[$accountId];
}
$currency = $this->accountRepos->getAccountCurrency($account);
$currency = $this->accountRepos->getAccountCurrency($account);
if (null === $currency) {
$this->accountCurrencies[$accountId] = 0;
@@ -321,7 +321,7 @@ class TransferCurrenciesCorrections extends Command
&& null === $this->sourceTransaction->foreign_amount
&& (int)$this->sourceTransaction->transaction_currency_id !== $this->sourceCurrency->id
) {
$message = sprintf(
$message = sprintf(
'Transaction #%d has a currency setting #%d that should be #%d. Amount remains %s, currency is changed.',
$this->sourceTransaction->id,
$this->sourceTransaction->transaction_currency_id,
@@ -367,7 +367,7 @@ class TransferCurrenciesCorrections extends Command
&& null === $this->destinationTransaction->foreign_amount
&& (int)$this->destinationTransaction->transaction_currency_id !== $this->destinationCurrency->id
) {
$message = sprintf(
$message = sprintf(
'Transaction #%d has a currency setting #%d that should be #%d. Amount remains %s, currency is changed.',
$this->destinationTransaction->id,
$this->destinationTransaction->transaction_currency_id,
@@ -390,8 +390,8 @@ class TransferCurrenciesCorrections extends Command
{
if ($this->destinationCurrency->id === $this->sourceCurrency->id) {
// update both transactions to match:
$this->sourceTransaction->foreign_amount = null;
$this->sourceTransaction->foreign_currency_id = null;
$this->sourceTransaction->foreign_amount = null;
$this->sourceTransaction->foreign_currency_id = null;
$this->destinationTransaction->foreign_amount = null;
$this->destinationTransaction->foreign_currency_id = null;

View File

@@ -41,9 +41,9 @@ class UpgradeCurrencyPreferences extends Command
public const string CONFIG_NAME = '610_upgrade_currency_prefs';
protected $description = 'Upgrade user currency preferences';
protected $description = 'Upgrade user currency preferences';
protected $signature = 'firefly-iii:upgrade-currency-preferences {--F|force : Force the execution of this command.}';
protected $signature = 'firefly-iii:upgrade-currency-preferences {--F|force : Force the execution of this command.}';
/**
* Execute the console command.
@@ -83,7 +83,7 @@ class UpgradeCurrencyPreferences extends Command
$this->upgradeGroupPreferences($group);
}
$users = User::get();
$users = User::get();
/** @var User $user */
foreach ($users as $user) {
@@ -107,8 +107,8 @@ class UpgradeCurrencyPreferences extends Command
private function upgradeUserPreferences(User $user): void
{
$currencies = TransactionCurrency::get();
$enabled = new Collection();
$currencies = TransactionCurrency::get();
$enabled = new Collection();
/** @var TransactionCurrency $currency */
foreach ($currencies as $currency) {

View File

@@ -42,8 +42,8 @@ class UpgradeLiabilities extends Command
use ShowsFriendlyMessages;
public const string CONFIG_NAME = '560_upgrade_liabilities';
protected $description = 'Upgrade liabilities to new 5.6.0 structure.';
protected $signature = 'firefly-iii:upgrade-liabilities {--F|force : Force the execution of this command.}';
protected $description = 'Upgrade liabilities to new 5.6.0 structure.';
protected $signature = 'firefly-iii:upgrade-liabilities {--F|force : Force the execution of this command.}';
/**
* Execute the console command.
@@ -102,7 +102,7 @@ class UpgradeLiabilities extends Command
private function upgradeLiability(Account $account): void
{
/** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class);
$repository = app(AccountRepositoryInterface::class);
$repository->setUser($account->user);
// get opening balance, and correct if necessary.
@@ -113,7 +113,7 @@ class UpgradeLiabilities extends Command
}
// add liability direction property (if it does not yet exist!)
$value = $repository->getMetaValue($account, 'liability_direction');
$value = $repository->getMetaValue($account, 'liability_direction');
if (null === $value) {
/** @var AccountMetaFactory $factory */
$factory = app(AccountMetaFactory::class);

View File

@@ -43,8 +43,8 @@ class UpgradeLiabilitiesEight extends Command
use ShowsFriendlyMessages;
public const string CONFIG_NAME = '600_upgrade_liabilities';
protected $description = 'Upgrade liabilities to new 6.0.0 structure.';
protected $signature = 'firefly-iii:liabilities-600 {--F|force : Force the execution of this command.}';
protected $description = 'Upgrade liabilities to new 6.0.0 structure.';
protected $signature = 'firefly-iii:liabilities-600 {--F|force : Force the execution of this command.}';
/**
* Execute the console command.
@@ -105,7 +105,7 @@ class UpgradeLiabilitiesEight extends Command
$repository = app(AccountRepositoryInterface::class);
$repository->setUser($account->user);
$direction = $repository->getMetaValue($account, 'liability_direction');
$direction = $repository->getMetaValue($account, 'liability_direction');
if ('credit' === $direction && $this->hasBadOpening($account)) {
$this->deleteCreditTransaction($account);
$this->reverseOpeningBalance($account);
@@ -131,7 +131,7 @@ class UpgradeLiabilitiesEight extends Command
if (null === $openingJournal) {
return false;
}
$liabilityJournal = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
$liabilityJournal = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->where('transactions.account_id', $account->id)
->where('transaction_journals.transaction_type_id', $liabilityType->id)
->first(['transaction_journals.*'])
@@ -168,17 +168,17 @@ class UpgradeLiabilitiesEight extends Command
$openingBalanceType = TransactionType::whereType(TransactionType::OPENING_BALANCE)->first();
/** @var TransactionJournal $openingJournal */
$openingJournal = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
$openingJournal = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->where('transactions.account_id', $account->id)
->where('transaction_journals.transaction_type_id', $openingBalanceType->id)
->first(['transaction_journals.*'])
;
/** @var null|Transaction $source */
$source = $openingJournal->transactions()->where('amount', '<', 0)->first();
$source = $openingJournal->transactions()->where('amount', '<', 0)->first();
/** @var null|Transaction $dest */
$dest = $openingJournal->transactions()->where('amount', '>', 0)->first();
$dest = $openingJournal->transactions()->where('amount', '>', 0)->first();
if (null !== $source && null !== $dest) {
$sourceId = $source->account_id;
$destId = $dest->account_id;