mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 08:35:00 +00:00
Code cleanup
This commit is contained in:
@@ -115,7 +115,7 @@ class CorrectOpeningBalanceCurrencies extends Command
|
||||
{
|
||||
$currency = $this->getCurrency($account);
|
||||
$count = 0;
|
||||
if ((int)$journal->transaction_currency_id !== $currency->id) {
|
||||
if ((int) $journal->transaction_currency_id !== $currency->id) {
|
||||
$journal->transaction_currency_id = $currency->id;
|
||||
$journal->save();
|
||||
$count = 1;
|
||||
|
@@ -65,7 +65,7 @@ class DeleteEmptyJournals extends Command
|
||||
|
||||
/** @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 {
|
||||
|
@@ -103,7 +103,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->friendlyWarning(
|
||||
|
@@ -77,7 +77,7 @@ class EnableCurrencies extends Command
|
||||
->where('account_meta.name', 'currency_id')->groupBy('data')->get(['data'])
|
||||
;
|
||||
foreach ($meta as $entry) {
|
||||
$found[] = (int)$entry->data;
|
||||
$found[] = (int) $entry->data;
|
||||
}
|
||||
|
||||
// get all from journals:
|
||||
@@ -85,7 +85,7 @@ class EnableCurrencies extends Command
|
||||
->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
|
||||
@@ -95,8 +95,8 @@ class EnableCurrencies extends Command
|
||||
->get(['transactions.transaction_currency_id', 'transactions.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
|
||||
|
@@ -74,7 +74,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)
|
||||
|
@@ -53,8 +53,8 @@ class FixGroupAccounts extends Command
|
||||
|
||||
/** @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();
|
||||
|
@@ -62,7 +62,7 @@ class FixLongDescriptions extends Command
|
||||
|
||||
/** @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->friendlyWarning(sprintf('Truncated description of transaction group #%d', $group->id));
|
||||
|
@@ -92,7 +92,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->friendlyWarning(
|
||||
sprintf(
|
||||
|
@@ -62,6 +62,113 @@ class FixUnevenAmount extends Command
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function convertOldStyleTransfers(): void
|
||||
{
|
||||
Log::debug('convertOldStyleTransfers()');
|
||||
// select transactions with a foreign amount and a foreign currency. and it's a transfer. and they are different.
|
||||
$transactions = Transaction::distinct()
|
||||
->leftJoin('transaction_journals', 'transaction_journals.id', 'transactions.transaction_journal_id')
|
||||
->leftJoin('transaction_types', 'transaction_types.id', 'transaction_journals.transaction_type_id')
|
||||
->where('transaction_types.type', TransactionTypeEnum::TRANSFER->value)
|
||||
->whereNotNull('foreign_currency_id')
|
||||
->whereNotNull('foreign_amount')->get(['transactions.transaction_journal_id'])
|
||||
;
|
||||
$count = 0;
|
||||
|
||||
Log::debug(sprintf('Found %d potential journal(s)', $transactions->count()));
|
||||
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($transactions as $transaction) {
|
||||
/** @var null|TransactionJournal $journal */
|
||||
$journal = TransactionJournal::find($transaction->transaction_journal_id);
|
||||
if (null === $journal) {
|
||||
Log::debug('Found no journal, continue.');
|
||||
|
||||
continue;
|
||||
}
|
||||
// needs to be a transfer.
|
||||
if (TransactionType::TRANSFER !== $journal->transactionType->type) {
|
||||
Log::debug('Must be a transfer, continue.');
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
/** @var null|Transaction $destination */
|
||||
$destination = $journal->transactions()->where('amount', '>', 0)->first();
|
||||
|
||||
/** @var null|Transaction $source */
|
||||
$source = $journal->transactions()->where('amount', '<', 0)->first();
|
||||
if (null === $destination || null === $source) {
|
||||
Log::debug('Source or destination transaction is NULL, continue.');
|
||||
|
||||
// will be picked up later.
|
||||
continue;
|
||||
}
|
||||
if ($source->transaction_currency_id === $destination->transaction_currency_id) {
|
||||
Log::debug('Ready to swap data between transactions.');
|
||||
$destination->foreign_currency_id = $source->transaction_currency_id;
|
||||
$destination->foreign_amount = app('steam')->positive($source->amount);
|
||||
$destination->transaction_currency_id = $source->foreign_currency_id;
|
||||
$destination->amount = app('steam')->positive($source->foreign_amount);
|
||||
$destination->balance_dirty = true;
|
||||
$source->balance_dirty = true;
|
||||
$destination->save();
|
||||
$source->save();
|
||||
$this->friendlyWarning(sprintf('Corrected foreign amounts of transfer #%d.', $journal->id));
|
||||
++$count;
|
||||
}
|
||||
}
|
||||
if (0 === $count) {
|
||||
$this->friendlyPositive('No "old style" foreign currency transfers.');
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private function fixUnevenAmounts(): void
|
||||
{
|
||||
$journals = \DB::table('transactions')
|
||||
->groupBy('transaction_journal_id')
|
||||
->whereNull('deleted_at')
|
||||
->get(['transaction_journal_id', \DB::raw('SUM(amount) AS the_sum')])
|
||||
;
|
||||
|
||||
/** @var \stdClass $entry */
|
||||
foreach ($journals as $entry) {
|
||||
$sum = (string) $entry->the_sum;
|
||||
if (!is_numeric($sum)
|
||||
|| '' === $sum // @phpstan-ignore-line
|
||||
|| str_contains($sum, 'e')
|
||||
|| str_contains($sum, ',')) {
|
||||
$message = sprintf(
|
||||
'Journal #%d has an invalid sum ("%s"). No sure what to do.',
|
||||
$entry->transaction_journal_id,
|
||||
$entry->the_sum
|
||||
);
|
||||
$this->friendlyWarning($message);
|
||||
app('log')->warning($message);
|
||||
++$this->count;
|
||||
|
||||
continue;
|
||||
}
|
||||
$res = -1;
|
||||
|
||||
try {
|
||||
$res = bccomp($sum, '0');
|
||||
} catch (\ValueError $e) {
|
||||
$this->friendlyError(sprintf('Could not bccomp("%s", "0").', $sum));
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
}
|
||||
if (0 !== $res) {
|
||||
$this->fixJournal($entry->transaction_journal_id);
|
||||
}
|
||||
}
|
||||
if (0 === $this->count) {
|
||||
$this->friendlyPositive('Database amount integrity is OK');
|
||||
}
|
||||
}
|
||||
|
||||
private function fixJournal(int $param): void
|
||||
{
|
||||
// one of the transactions is bad.
|
||||
@@ -130,78 +237,6 @@ class FixUnevenAmount extends Command
|
||||
++$this->count;
|
||||
}
|
||||
|
||||
private function fixUnevenAmounts(): void
|
||||
{
|
||||
$journals = \DB::table('transactions')
|
||||
->groupBy('transaction_journal_id')
|
||||
->whereNull('deleted_at')
|
||||
->get(['transaction_journal_id', \DB::raw('SUM(amount) AS the_sum')])
|
||||
;
|
||||
|
||||
/** @var \stdClass $entry */
|
||||
foreach ($journals as $entry) {
|
||||
$sum = (string) $entry->the_sum;
|
||||
if (!is_numeric($sum)
|
||||
|| '' === $sum // @phpstan-ignore-line
|
||||
|| str_contains($sum, 'e')
|
||||
|| str_contains($sum, ',')) {
|
||||
$message = sprintf(
|
||||
'Journal #%d has an invalid sum ("%s"). No sure what to do.',
|
||||
$entry->transaction_journal_id,
|
||||
$entry->the_sum
|
||||
);
|
||||
$this->friendlyWarning($message);
|
||||
app('log')->warning($message);
|
||||
++$this->count;
|
||||
|
||||
continue;
|
||||
}
|
||||
$res = -1;
|
||||
|
||||
try {
|
||||
$res = bccomp($sum, '0');
|
||||
} catch (\ValueError $e) {
|
||||
$this->friendlyError(sprintf('Could not bccomp("%s", "0").', $sum));
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
}
|
||||
if (0 !== $res) {
|
||||
$this->fixJournal($entry->transaction_journal_id);
|
||||
}
|
||||
}
|
||||
if (0 === $this->count) {
|
||||
$this->friendlyPositive('Database amount integrity is OK');
|
||||
}
|
||||
}
|
||||
|
||||
private function matchCurrencies(): void
|
||||
{
|
||||
$journals = TransactionJournal::leftJoin('transactions', 'transaction_journals.id', 'transactions.transaction_journal_id')
|
||||
->where('transactions.transaction_currency_id', '!=', \DB::raw('transaction_journals.transaction_currency_id'))
|
||||
->get(['transaction_journals.*'])
|
||||
;
|
||||
|
||||
$count = 0;
|
||||
|
||||
/** @var TransactionJournal $journal */
|
||||
foreach ($journals as $journal) {
|
||||
if (!$this->isForeignCurrencyTransfer($journal)) {
|
||||
Transaction::where('transaction_journal_id', $journal->id)->update(['transaction_currency_id' => $journal->transaction_currency_id]);
|
||||
++$count;
|
||||
|
||||
continue;
|
||||
}
|
||||
Log::debug(sprintf('Can skip foreign currency transfer #%d.', $journal->id));
|
||||
}
|
||||
if (0 === $count) {
|
||||
$this->friendlyPositive('Journal currency integrity is OK');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->friendlyPositive(sprintf('Fixed %d journal(s) with mismatched currencies.', $journals->count()));
|
||||
}
|
||||
|
||||
private function isForeignCurrencyTransfer(TransactionJournal $journal): bool
|
||||
{
|
||||
if (TransactionType::TRANSFER !== $journal->transactionType->type) {
|
||||
@@ -236,66 +271,31 @@ class FixUnevenAmount extends Command
|
||||
return false;
|
||||
}
|
||||
|
||||
private function convertOldStyleTransfers(): void
|
||||
private function matchCurrencies(): void
|
||||
{
|
||||
Log::debug('convertOldStyleTransfers()');
|
||||
// select transactions with a foreign amount and a foreign currency. and it's a transfer. and they are different.
|
||||
$transactions = Transaction::distinct()
|
||||
->leftJoin('transaction_journals', 'transaction_journals.id', 'transactions.transaction_journal_id')
|
||||
->leftJoin('transaction_types', 'transaction_types.id', 'transaction_journals.transaction_type_id')
|
||||
->where('transaction_types.type', TransactionTypeEnum::TRANSFER->value)
|
||||
->whereNotNull('foreign_currency_id')
|
||||
->whereNotNull('foreign_amount')->get(['transactions.transaction_journal_id'])
|
||||
$journals = TransactionJournal::leftJoin('transactions', 'transaction_journals.id', 'transactions.transaction_journal_id')
|
||||
->where('transactions.transaction_currency_id', '!=', \DB::raw('transaction_journals.transaction_currency_id'))
|
||||
->get(['transaction_journals.*'])
|
||||
;
|
||||
$count = 0;
|
||||
|
||||
Log::debug(sprintf('Found %d potential journal(s)', $transactions->count()));
|
||||
$count = 0;
|
||||
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($transactions as $transaction) {
|
||||
/** @var null|TransactionJournal $journal */
|
||||
$journal = TransactionJournal::find($transaction->transaction_journal_id);
|
||||
if (null === $journal) {
|
||||
Log::debug('Found no journal, continue.');
|
||||
|
||||
continue;
|
||||
}
|
||||
// needs to be a transfer.
|
||||
if (TransactionType::TRANSFER !== $journal->transactionType->type) {
|
||||
Log::debug('Must be a transfer, continue.');
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
/** @var null|Transaction $destination */
|
||||
$destination = $journal->transactions()->where('amount', '>', 0)->first();
|
||||
|
||||
/** @var null|Transaction $source */
|
||||
$source = $journal->transactions()->where('amount', '<', 0)->first();
|
||||
if (null === $destination || null === $source) {
|
||||
Log::debug('Source or destination transaction is NULL, continue.');
|
||||
|
||||
// will be picked up later.
|
||||
continue;
|
||||
}
|
||||
if ($source->transaction_currency_id === $destination->transaction_currency_id) {
|
||||
Log::debug('Ready to swap data between transactions.');
|
||||
$destination->foreign_currency_id = $source->transaction_currency_id;
|
||||
$destination->foreign_amount = app('steam')->positive($source->amount);
|
||||
$destination->transaction_currency_id = $source->foreign_currency_id;
|
||||
$destination->amount = app('steam')->positive($source->foreign_amount);
|
||||
$destination->balance_dirty = true;
|
||||
$source->balance_dirty = true;
|
||||
$destination->save();
|
||||
$source->save();
|
||||
$this->friendlyWarning(sprintf('Corrected foreign amounts of transfer #%d.', $journal->id));
|
||||
/** @var TransactionJournal $journal */
|
||||
foreach ($journals as $journal) {
|
||||
if (!$this->isForeignCurrencyTransfer($journal)) {
|
||||
Transaction::where('transaction_journal_id', $journal->id)->update(['transaction_currency_id' => $journal->transaction_currency_id]);
|
||||
++$count;
|
||||
|
||||
continue;
|
||||
}
|
||||
Log::debug(sprintf('Can skip foreign currency transfer #%d.', $journal->id));
|
||||
}
|
||||
if (0 === $count) {
|
||||
$this->friendlyPositive('No "old style" foreign currency transfers.');
|
||||
$this->friendlyPositive('Journal currency integrity is OK');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->friendlyPositive(sprintf('Fixed %d journal(s) with mismatched currencies.', $journals->count()));
|
||||
}
|
||||
}
|
||||
|
@@ -181,17 +181,6 @@ class RecalculateNativeAmounts extends Command
|
||||
Log::debug(sprintf('Recalculated %d auto budgets.', $set->count()));
|
||||
}
|
||||
|
||||
private function recalculateBills(UserGroup $userGroup, TransactionCurrency $currency): void
|
||||
{
|
||||
$set = $userGroup->bills()->where('transaction_currency_id', '!=', $currency->id)->get();
|
||||
|
||||
/** @var Bill $bill */
|
||||
foreach ($set as $bill) {
|
||||
$bill->touch();
|
||||
}
|
||||
Log::debug(sprintf('Recalculated %d bills.', $set->count()));
|
||||
}
|
||||
|
||||
private function recalculateAvailableBudgets(UserGroup $userGroup, TransactionCurrency $currency): void
|
||||
{
|
||||
Log::debug('Start with available budgets.');
|
||||
@@ -204,6 +193,17 @@ class RecalculateNativeAmounts extends Command
|
||||
Log::debug(sprintf('Recalculated %d available budgets.', $set->count()));
|
||||
}
|
||||
|
||||
private function recalculateBills(UserGroup $userGroup, TransactionCurrency $currency): void
|
||||
{
|
||||
$set = $userGroup->bills()->where('transaction_currency_id', '!=', $currency->id)->get();
|
||||
|
||||
/** @var Bill $bill */
|
||||
foreach ($set as $bill) {
|
||||
$bill->touch();
|
||||
}
|
||||
Log::debug(sprintf('Recalculated %d bills.', $set->count()));
|
||||
}
|
||||
|
||||
private function calculateTransactions(UserGroup $userGroup, TransactionCurrency $currency): void
|
||||
{
|
||||
// custom query because of the potential size of this update.
|
||||
|
@@ -231,7 +231,7 @@ class ExportData extends Command
|
||||
{
|
||||
$final = new Collection();
|
||||
$accounts = new Collection();
|
||||
$accountList = (string)$this->option('accounts');
|
||||
$accountList = (string) $this->option('accounts');
|
||||
$types = [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE];
|
||||
if ('' !== $accountList) {
|
||||
$accountIds = explode(',', $accountList);
|
||||
@@ -260,7 +260,7 @@ class ExportData extends Command
|
||||
*/
|
||||
private function getExportDirectory(): string
|
||||
{
|
||||
$directory = (string)$this->option('export_directory');
|
||||
$directory = (string) $this->option('export_directory');
|
||||
if ('' === $directory) {
|
||||
$directory = './';
|
||||
}
|
||||
|
@@ -45,34 +45,35 @@ class AddTimezonesToDates extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'firefly-iii:add-timezones-to-dates';
|
||||
public static array $models
|
||||
= [
|
||||
AccountBalance::class => ['date'], // done
|
||||
AvailableBudget::class => ['start_date', 'end_date'], // done
|
||||
Bill::class => ['date', 'end_date', 'extension_date'], // done
|
||||
BudgetLimit::class => ['start_date', 'end_date'], // done
|
||||
CurrencyExchangeRate::class => ['date'], // done
|
||||
InvitedUser::class => ['expires'],
|
||||
PiggyBankEvent::class => ['date'],
|
||||
PiggyBankRepetition::class => ['start_date', 'target_date'],
|
||||
PiggyBank::class => ['start_date', 'target_date'], // done
|
||||
Recurrence::class => ['first_date', 'repeat_until', 'latest_date'],
|
||||
Tag::class => ['date'],
|
||||
TransactionJournal::class => ['date'],
|
||||
];
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Make sure all dates have a timezone.';
|
||||
protected $description = 'Make sure all dates have a timezone.';
|
||||
|
||||
public static array $models = [
|
||||
AccountBalance::class => ['date'], // done
|
||||
AvailableBudget::class => ['start_date', 'end_date'], // done
|
||||
Bill::class => ['date', 'end_date', 'extension_date'], // done
|
||||
BudgetLimit::class => ['start_date', 'end_date'], // done
|
||||
CurrencyExchangeRate::class => ['date'], // done
|
||||
InvitedUser::class => ['expires'],
|
||||
PiggyBankEvent::class => ['date'],
|
||||
PiggyBankRepetition::class => ['start_date', 'target_date'],
|
||||
PiggyBank::class => ['start_date', 'target_date'], // done
|
||||
Recurrence::class => ['first_date', 'repeat_until', 'latest_date'],
|
||||
Tag::class => ['date'],
|
||||
TransactionJournal::class => ['date'],
|
||||
];
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'firefly-iii:add-timezones-to-dates';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
|
@@ -35,13 +35,6 @@ class ConvertDatesToUTC extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'firefly-iii:migrate-to-utc';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
@@ -49,6 +42,13 @@ class ConvertDatesToUTC extends Command
|
||||
*/
|
||||
protected $description = 'Convert stored dates to UTC.';
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'firefly-iii:migrate-to-utc';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
|
@@ -130,17 +130,17 @@ class ForceDecimalSize extends Command
|
||||
private function correctAmounts(): void
|
||||
{
|
||||
// if sqlite, add function?
|
||||
if ('sqlite' === (string)config('database.default')) {
|
||||
if ('sqlite' === (string) config('database.default')) {
|
||||
DB::connection()->getPdo()->sqliteCreateFunction('REGEXP', static function ($pattern, $value) {
|
||||
mb_regex_encoding('UTF-8');
|
||||
$pattern = trim($pattern, '"');
|
||||
|
||||
return (false !== mb_ereg($pattern, (string)$value)) ? 1 : 0;
|
||||
return (false !== mb_ereg($pattern, (string) $value)) ? 1 : 0;
|
||||
});
|
||||
}
|
||||
|
||||
if (!in_array((string)config('database.default'), ['mysql', 'pgsql', 'sqlite'], true)) {
|
||||
$this->friendlyWarning(sprintf('Skip correcting amounts, does not support "%s"...', (string)config('database.default')));
|
||||
if (!in_array((string) config('database.default'), ['mysql', 'pgsql', 'sqlite'], true)) {
|
||||
$this->friendlyWarning(sprintf('Skip correcting amounts, does not support "%s"...', (string) config('database.default')));
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -236,7 +236,7 @@ class ForceDecimalSize extends Command
|
||||
/** @var Builder $query */
|
||||
$query = Account::leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')
|
||||
->where('account_meta.name', 'currency_id')
|
||||
->where('account_meta.data', json_encode((string)$currency->id))
|
||||
->where('account_meta.data', json_encode((string) $currency->id))
|
||||
;
|
||||
$query->where(static function (Builder $q) use ($fields, $currency, $operator, $cast, $regularExpression): void {
|
||||
foreach ($fields as $field) {
|
||||
@@ -264,7 +264,7 @@ class ForceDecimalSize extends Command
|
||||
}
|
||||
// fix $field by rounding it down correctly.
|
||||
$pow = 10 ** $currency->decimal_places;
|
||||
$correct = bcdiv((string)round($value * $pow), (string)$pow, 12);
|
||||
$correct = bcdiv((string) round($value * $pow), (string) $pow, 12);
|
||||
$this->friendlyInfo(sprintf('Account #%d has %s with value "%s", this has been corrected to "%s".', $account->id, $field, $value, $correct));
|
||||
Account::find($account->id)->update([$field => $correct]);
|
||||
}
|
||||
@@ -313,7 +313,7 @@ class ForceDecimalSize extends Command
|
||||
}
|
||||
// fix $field by rounding it down correctly.
|
||||
$pow = 10 ** $currency->decimal_places;
|
||||
$correct = bcdiv((string)round($value * $pow), (string)$pow, 12);
|
||||
$correct = bcdiv((string) round($value * $pow), (string) $pow, 12);
|
||||
$this->friendlyWarning(sprintf('%s #%d has %s with value "%s", this has been corrected to "%s".', $table, $item->id, $field, $value, $correct));
|
||||
$class::find($item->id)->update([$field => $correct]);
|
||||
}
|
||||
@@ -334,7 +334,7 @@ class ForceDecimalSize extends Command
|
||||
->leftJoin('accounts', 'piggy_banks.account_id', '=', 'accounts.id')
|
||||
->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')
|
||||
->where('account_meta.name', 'currency_id')
|
||||
->where('account_meta.data', json_encode((string)$currency->id))
|
||||
->where('account_meta.data', json_encode((string) $currency->id))
|
||||
->where(static function (Builder $q) use ($fields, $currency, $cast, $operator, $regularExpression): void {
|
||||
foreach ($fields as $field) {
|
||||
$q->orWhere(
|
||||
@@ -363,7 +363,7 @@ class ForceDecimalSize extends Command
|
||||
}
|
||||
// fix $field by rounding it down correctly.
|
||||
$pow = 10 ** $currency->decimal_places;
|
||||
$correct = bcdiv((string)round($value * $pow), (string)$pow, 12);
|
||||
$correct = bcdiv((string) round($value * $pow), (string) $pow, 12);
|
||||
$this->friendlyWarning(
|
||||
sprintf('Piggy bank event #%d has %s with value "%s", this has been corrected to "%s".', $item->id, $field, $value, $correct)
|
||||
);
|
||||
@@ -387,7 +387,7 @@ class ForceDecimalSize extends Command
|
||||
->leftJoin('accounts', 'piggy_banks.account_id', '=', 'accounts.id')
|
||||
->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')
|
||||
->where('account_meta.name', 'currency_id')
|
||||
->where('account_meta.data', json_encode((string)$currency->id))
|
||||
->where('account_meta.data', json_encode((string) $currency->id))
|
||||
->where(static function (Builder $q) use ($fields, $currency, $operator, $cast, $regularExpression): void {
|
||||
foreach ($fields as $field) {
|
||||
$q->orWhere(
|
||||
@@ -416,7 +416,7 @@ class ForceDecimalSize extends Command
|
||||
}
|
||||
// fix $field by rounding it down correctly.
|
||||
$pow = 10 ** $currency->decimal_places;
|
||||
$correct = bcdiv((string)round($value * $pow), (string)$pow, 12);
|
||||
$correct = bcdiv((string) round($value * $pow), (string) $pow, 12);
|
||||
$this->friendlyWarning(
|
||||
sprintf('Piggy bank repetition #%d has %s with value "%s", this has been corrected to "%s".', $item->id, $field, $value, $correct)
|
||||
);
|
||||
@@ -438,7 +438,7 @@ class ForceDecimalSize extends Command
|
||||
$query = PiggyBank::leftJoin('accounts', 'piggy_banks.account_id', '=', 'accounts.id')
|
||||
->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')
|
||||
->where('account_meta.name', 'currency_id')
|
||||
->where('account_meta.data', json_encode((string)$currency->id))
|
||||
->where('account_meta.data', json_encode((string) $currency->id))
|
||||
->where(static function (Builder $q) use ($fields, $currency, $operator, $cast, $regularExpression): void {
|
||||
foreach ($fields as $field) {
|
||||
$q->orWhere(
|
||||
@@ -467,7 +467,7 @@ class ForceDecimalSize extends Command
|
||||
}
|
||||
// fix $field by rounding it down correctly.
|
||||
$pow = 10 ** $currency->decimal_places;
|
||||
$correct = bcdiv((string)round($value * $pow), (string)$pow, 12);
|
||||
$correct = bcdiv((string) round($value * $pow), (string) $pow, 12);
|
||||
$this->friendlyWarning(sprintf('Piggy bank #%d has %s with value "%s", this has been corrected to "%s".', $item->id, $field, $value, $correct));
|
||||
PiggyBank::find($item->id)->update([$field => $correct]);
|
||||
}
|
||||
@@ -499,8 +499,8 @@ class ForceDecimalSize extends Command
|
||||
continue;
|
||||
}
|
||||
// fix $field by rounding it down correctly.
|
||||
$pow = (float)10 ** $currency->decimal_places;
|
||||
$correct = bcdiv((string)round((float)$value * $pow), (string)$pow, 12);
|
||||
$pow = (float) 10 ** $currency->decimal_places;
|
||||
$correct = bcdiv((string) round((float) $value * $pow), (string) $pow, 12);
|
||||
$this->friendlyWarning(sprintf('Transaction #%d has amount with value "%s", this has been corrected to "%s".', $item->id, $value, $correct));
|
||||
Transaction::find($item->id)->update(['amount' => $correct]);
|
||||
}
|
||||
@@ -527,8 +527,8 @@ class ForceDecimalSize extends Command
|
||||
continue;
|
||||
}
|
||||
// fix $field by rounding it down correctly.
|
||||
$pow = (float)10 ** $currency->decimal_places;
|
||||
$correct = bcdiv((string)round((float)$value * $pow), (string)$pow, 12);
|
||||
$pow = (float) 10 ** $currency->decimal_places;
|
||||
$correct = bcdiv((string) round((float) $value * $pow), (string) $pow, 12);
|
||||
$this->friendlyWarning(
|
||||
sprintf('Transaction #%d has foreign amount with value "%s", this has been corrected to "%s".', $item->id, $value, $correct)
|
||||
);
|
||||
@@ -539,7 +539,7 @@ class ForceDecimalSize extends Command
|
||||
private function updateDecimals(): void
|
||||
{
|
||||
$this->friendlyInfo('Going to force the size of DECIMAL columns. Please hold.');
|
||||
$type = (string)config('database.default');
|
||||
$type = (string) config('database.default');
|
||||
|
||||
/**
|
||||
* @var string $name
|
||||
|
@@ -71,8 +71,8 @@ class ScanAttachments extends Command
|
||||
exit(1);
|
||||
}
|
||||
file_put_contents($tempFileName, $decryptedContent);
|
||||
$attachment->md5 = (string)md5_file($tempFileName);
|
||||
$attachment->mime = (string)mime_content_type($tempFileName);
|
||||
$attachment->md5 = (string) md5_file($tempFileName);
|
||||
$attachment->mime = (string) mime_content_type($tempFileName);
|
||||
$attachment->save();
|
||||
$this->friendlyInfo(sprintf('Fixed attachment #%d', $attachment->id));
|
||||
}
|
||||
|
@@ -59,7 +59,7 @@ class UpgradeFireflyInstructions extends Command
|
||||
*/
|
||||
private function updateInstructions(): void
|
||||
{
|
||||
$version = (string)config('firefly.version');
|
||||
$version = (string) config('firefly.version');
|
||||
|
||||
/** @var array $config */
|
||||
$config = config('upgrade.text.upgrade');
|
||||
@@ -69,12 +69,12 @@ class UpgradeFireflyInstructions extends Command
|
||||
foreach (array_keys($config) as $compare) {
|
||||
// if string starts with:
|
||||
if (str_starts_with($version, $compare)) {
|
||||
$text = (string)$config[$compare];
|
||||
$text = (string) $config[$compare];
|
||||
}
|
||||
}
|
||||
|
||||
// validate some settings.
|
||||
if ('' === $text && 'local' === (string)config('app.env')) {
|
||||
if ('' === $text && 'local' === (string) config('app.env')) {
|
||||
$text = 'Please set APP_ENV=production for a safer environment.';
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ class UpgradeFireflyInstructions extends Command
|
||||
*/
|
||||
private function installInstructions(): void
|
||||
{
|
||||
$version = (string)config('firefly.version');
|
||||
$version = (string) config('firefly.version');
|
||||
|
||||
/** @var array $config */
|
||||
$config = config('upgrade.text.install');
|
||||
@@ -189,12 +189,12 @@ class UpgradeFireflyInstructions extends Command
|
||||
foreach (array_keys($config) as $compare) {
|
||||
// if string starts with:
|
||||
if (str_starts_with($version, $compare)) {
|
||||
$text = (string)$config[$compare];
|
||||
$text = (string) $config[$compare];
|
||||
}
|
||||
}
|
||||
|
||||
// validate some settings.
|
||||
if ('' === $text && 'local' === (string)config('app.env')) {
|
||||
if ('' === $text && 'local' === (string) config('app.env')) {
|
||||
$text = 'Please set APP_ENV=production for a safer environment.';
|
||||
}
|
||||
|
||||
|
@@ -201,7 +201,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);
|
||||
@@ -228,7 +228,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;
|
||||
}
|
||||
@@ -250,7 +250,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;
|
||||
}
|
||||
|
@@ -62,7 +62,7 @@ class Cron extends Command
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
$this->friendlyError(sprintf('"%s" is not a valid date', $this->option('date')));
|
||||
}
|
||||
$force = (bool)$this->option('force'); // @phpstan-ignore-line
|
||||
$force = (bool) $this->option('force'); // @phpstan-ignore-line
|
||||
|
||||
// Fire exchange rates cron job.
|
||||
if (true === config('cer.download_enabled') && ($doAll || $this->option('download-cer'))) {
|
||||
|
@@ -93,7 +93,7 @@ class AccountCurrencies extends Command
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
|
||||
return (bool)$configVar?->data;
|
||||
return (bool) $configVar?->data;
|
||||
}
|
||||
|
||||
private function updateAccountCurrencies(): void
|
||||
@@ -124,9 +124,9 @@ class AccountCurrencies extends Command
|
||||
private function updateAccount(Account $account, TransactionCurrency $currency): void
|
||||
{
|
||||
$this->accountRepos->setUser($account->user);
|
||||
$accountCurrency = (int)$this->accountRepos->getMetaValue($account, 'currency_id');
|
||||
$accountCurrency = (int) $this->accountRepos->getMetaValue($account, 'currency_id');
|
||||
$openingBalance = $this->accountRepos->getOpeningBalance($account);
|
||||
$obCurrency = (int)$openingBalance?->transaction_currency_id;
|
||||
$obCurrency = (int) $openingBalance?->transaction_currency_id;
|
||||
|
||||
// both 0? set to default currency:
|
||||
if (0 === $accountCurrency && 0 === $obCurrency) {
|
||||
|
@@ -62,7 +62,7 @@ class AppendBudgetLimitPeriods extends Command
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
|
||||
return (bool)$configVar->data;
|
||||
return (bool) $configVar->data;
|
||||
}
|
||||
|
||||
private function theresNoLimit(): void
|
||||
@@ -111,7 +111,7 @@ class AppendBudgetLimitPeriods extends Command
|
||||
return 'daily';
|
||||
}
|
||||
// is weekly
|
||||
if ('1' === $limit->start_date->format('N') && '7' === $limit->end_date->format('N') && 6 === (int)$limit->end_date->diffInDays($limit->start_date, true)) {
|
||||
if ('1' === $limit->start_date->format('N') && '7' === $limit->end_date->format('N') && 6 === (int) $limit->end_date->diffInDays($limit->start_date, true)) {
|
||||
return 'weekly';
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ class AppendBudgetLimitPeriods extends Command
|
||||
if (
|
||||
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
|
||||
&& 2 === (int)$limit->start_date->diffInMonths($limit->end_date, true)
|
||||
&& 2 === (int) $limit->start_date->diffInMonths($limit->end_date, true)
|
||||
) {
|
||||
return 'quarterly';
|
||||
}
|
||||
@@ -140,7 +140,7 @@ class AppendBudgetLimitPeriods extends Command
|
||||
if (
|
||||
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 === (int)$limit->start_date->diffInMonths($limit->end_date, true)
|
||||
&& 5 === (int) $limit->start_date->diffInMonths($limit->end_date, true)
|
||||
) {
|
||||
return 'half_year';
|
||||
}
|
||||
|
@@ -73,14 +73,14 @@ class BackToJournals extends Command
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(MigrateToGroups::CONFIG_NAME, false);
|
||||
|
||||
return (bool)$configVar->data;
|
||||
return (bool) $configVar->data;
|
||||
}
|
||||
|
||||
private function isExecuted(): bool
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
|
||||
return (bool)$configVar->data;
|
||||
return (bool) $configVar->data;
|
||||
}
|
||||
|
||||
private function migrateAll(): void
|
||||
|
@@ -92,7 +92,7 @@ class BudgetLimitCurrency extends Command
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
if (null !== $configVar) {
|
||||
return (bool)$configVar->data;
|
||||
return (bool) $configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@@ -88,7 +88,7 @@ class CCLiabilities extends Command
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
|
||||
return (bool)$configVar?->data;
|
||||
return (bool) $configVar?->data;
|
||||
}
|
||||
|
||||
private function markAsExecuted(): void
|
||||
|
@@ -59,12 +59,6 @@ class CorrectAccountBalance extends Command
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function correctBalanceAmounts(): void
|
||||
{
|
||||
return;
|
||||
AccountBalanceCalculator::recalculateAll(true);
|
||||
}
|
||||
|
||||
private function isExecuted(): bool
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
@@ -76,4 +70,10 @@ class CorrectAccountBalance extends Command
|
||||
{
|
||||
app('fireflyconfig')->set(self::CONFIG_NAME, true);
|
||||
}
|
||||
|
||||
private function correctBalanceAmounts(): void
|
||||
{
|
||||
return;
|
||||
AccountBalanceCalculator::recalculateAll(true);
|
||||
}
|
||||
}
|
||||
|
@@ -97,7 +97,7 @@ class DecryptDatabase extends Command
|
||||
app('log')->error($e->getMessage());
|
||||
}
|
||||
if (null !== $configVar) {
|
||||
return (bool)$configVar->data;
|
||||
return (bool) $configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -119,7 +119,7 @@ class DecryptDatabase extends Command
|
||||
if (null === $original) {
|
||||
return;
|
||||
}
|
||||
$id = (int)$row->id;
|
||||
$id = (int) $row->id;
|
||||
$value = '';
|
||||
|
||||
try {
|
||||
|
@@ -63,7 +63,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();
|
||||
@@ -99,7 +99,7 @@ class MigrateAttachments extends Command
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
if (null !== $configVar) {
|
||||
return (bool)$configVar->data;
|
||||
return (bool) $configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@@ -93,7 +93,7 @@ class MigrateJournalNotes extends Command
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
if (null !== $configVar) {
|
||||
return (bool)$configVar->data;
|
||||
return (bool) $configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@@ -71,7 +71,7 @@ class MigrateRecurrenceMeta extends Command
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
if (null !== $configVar) {
|
||||
return (bool)$configVar->data;
|
||||
return (bool) $configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@@ -60,7 +60,7 @@ class MigrateRecurrenceType extends Command
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
|
||||
return (bool)$configVar?->data;
|
||||
return (bool) $configVar?->data;
|
||||
}
|
||||
|
||||
private function markAsExecuted(): void
|
||||
|
@@ -63,7 +63,7 @@ class MigrateRuleActions extends Command
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
if (null !== $configVar) {
|
||||
return (bool)$configVar->data;
|
||||
return (bool) $configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@@ -62,7 +62,7 @@ class MigrateTagLocations extends Command
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
if (null !== $configVar) {
|
||||
return (bool)$configVar->data;
|
||||
return (bool) $configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@@ -105,7 +105,7 @@ class MigrateToGroups extends Command
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
if (null !== $configVar) {
|
||||
return (bool)$configVar->data;
|
||||
return (bool) $configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -288,7 +288,7 @@ class MigrateToGroups extends Command
|
||||
{
|
||||
$set = $journal->transactions->filter(
|
||||
static function (Transaction $subject) use ($transaction) {
|
||||
$amount = (float)$transaction->amount * -1 === (float)$subject->amount; // intentional float
|
||||
$amount = (float) $transaction->amount * -1 === (float) $subject->amount; // intentional float
|
||||
$identifier = $transaction->identifier === $subject->identifier;
|
||||
app('log')->debug(sprintf('Amount the same? %s', var_export($amount, true)));
|
||||
app('log')->debug(sprintf('ID the same? %s', var_export($identifier, true)));
|
||||
|
@@ -106,7 +106,7 @@ class MigrateToRules extends Command
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
if (null !== $configVar) {
|
||||
return (bool)$configVar->data;
|
||||
return (bool) $configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -125,15 +125,15 @@ class MigrateToRules extends Command
|
||||
|
||||
/** @var Preference $lang */
|
||||
$lang = app('preferences')->getForUser($user, 'language', 'en_US');
|
||||
$language = null !== $lang->data && !is_array($lang->data) ? (string)$lang->data : 'en_US';
|
||||
$groupTitle = (string)trans('firefly.rulegroup_for_bills_title', [], $language);
|
||||
$language = null !== $lang->data && !is_array($lang->data) ? (string) $lang->data : 'en_US';
|
||||
$groupTitle = (string) trans('firefly.rulegroup_for_bills_title', [], $language);
|
||||
$ruleGroup = $this->ruleGroupRepository->findByTitle($groupTitle);
|
||||
|
||||
if (null === $ruleGroup) {
|
||||
$ruleGroup = $this->ruleGroupRepository->store(
|
||||
[
|
||||
'title' => (string)trans('firefly.rulegroup_for_bills_title', [], $language),
|
||||
'description' => (string)trans('firefly.rulegroup_for_bills_description', [], $language),
|
||||
'title' => (string) trans('firefly.rulegroup_for_bills_title', [], $language),
|
||||
'description' => (string) trans('firefly.rulegroup_for_bills_description', [], $language),
|
||||
'active' => true,
|
||||
]
|
||||
);
|
||||
@@ -151,7 +151,7 @@ class MigrateToRules extends Command
|
||||
if ('MIGRATED_TO_RULES' === $bill->match) {
|
||||
return;
|
||||
}
|
||||
$languageString = null !== $language->data && !is_array($language->data) ? (string)$language->data : 'en_US';
|
||||
$languageString = null !== $language->data && !is_array($language->data) ? (string) $language->data : 'en_US';
|
||||
|
||||
// get match thing:
|
||||
$match = implode(' ', explode(',', $bill->match));
|
||||
@@ -160,8 +160,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], $languageString),
|
||||
'description' => (string)trans('firefly.rule_for_bill_description', ['name' => $bill->name], $languageString),
|
||||
'title' => (string) trans('firefly.rule_for_bill_title', ['name' => $bill->name], $languageString),
|
||||
'description' => (string) trans('firefly.rule_for_bill_description', ['name' => $bill->name], $languageString),
|
||||
'trigger' => 'store-journal',
|
||||
'triggers' => [
|
||||
[
|
||||
|
@@ -239,11 +239,6 @@ class OtherCurrenciesCorrections extends Command
|
||||
return $currency;
|
||||
}
|
||||
|
||||
private function markAsExecuted(): void
|
||||
{
|
||||
app('fireflyconfig')->set(self::CONFIG_NAME, true);
|
||||
}
|
||||
|
||||
private function isMultiCurrency(Account $account): bool
|
||||
{
|
||||
$value = $this->accountRepos->getMetaValue($account, 'is_multi_currency', false);
|
||||
@@ -253,4 +248,9 @@ class OtherCurrenciesCorrections extends Command
|
||||
|
||||
return '1' === $value;
|
||||
}
|
||||
|
||||
private function markAsExecuted(): void
|
||||
{
|
||||
app('fireflyconfig')->set(self::CONFIG_NAME, true);
|
||||
}
|
||||
}
|
||||
|
@@ -90,7 +90,7 @@ class RenameAccountMeta extends Command
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
if (null !== $configVar) {
|
||||
return (bool)$configVar->data;
|
||||
return (bool) $configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@@ -106,7 +106,7 @@ class TransactionIdentifier extends Command
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
if (null !== $configVar) {
|
||||
return (bool)$configVar->data;
|
||||
return (bool) $configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@@ -114,7 +114,7 @@ class TransferCurrenciesCorrections extends Command
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
if (null !== $configVar) {
|
||||
return (bool)$configVar->data;
|
||||
return (bool) $configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -320,7 +320,7 @@ class TransferCurrenciesCorrections extends Command
|
||||
{
|
||||
if (null !== $this->sourceCurrency
|
||||
&& null === $this->sourceTransaction->foreign_amount
|
||||
&& (int)$this->sourceTransaction->transaction_currency_id !== $this->sourceCurrency->id
|
||||
&& (int) $this->sourceTransaction->transaction_currency_id !== $this->sourceCurrency->id
|
||||
) {
|
||||
$message = sprintf(
|
||||
'Transaction #%d has a currency setting #%d that should be #%d. Amount remains %s, currency is changed.',
|
||||
@@ -366,7 +366,7 @@ class TransferCurrenciesCorrections extends Command
|
||||
{
|
||||
if (null !== $this->destinationCurrency
|
||||
&& null === $this->destinationTransaction->foreign_amount
|
||||
&& (int)$this->destinationTransaction->transaction_currency_id !== $this->destinationCurrency->id
|
||||
&& (int) $this->destinationTransaction->transaction_currency_id !== $this->destinationCurrency->id
|
||||
) {
|
||||
$message = sprintf(
|
||||
'Transaction #%d has a currency setting #%d that should be #%d. Amount remains %s, currency is changed.',
|
||||
@@ -469,7 +469,7 @@ class TransferCurrenciesCorrections extends Command
|
||||
*/
|
||||
private function fixTransactionJournalCurrency(TransactionJournal $journal): void
|
||||
{
|
||||
if ((int)$journal->transaction_currency_id !== $this->sourceCurrency->id) {
|
||||
if ((int) $journal->transaction_currency_id !== $this->sourceCurrency->id) {
|
||||
$oldCurrencyCode = $journal->transactionCurrency->code ?? '(nothing)';
|
||||
$journal->transaction_currency_id = $this->sourceCurrency->id;
|
||||
$message = sprintf(
|
||||
|
@@ -68,7 +68,7 @@ class UpgradeCurrencyPreferences extends Command
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
if (null !== $configVar) {
|
||||
return (bool)$configVar->data;
|
||||
return (bool) $configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -138,7 +138,7 @@ class UpgradeCurrencyPreferences extends Command
|
||||
}
|
||||
|
||||
if (null !== $preference->data && !is_array($preference->data)) {
|
||||
return (string)$preference->data;
|
||||
return (string) $preference->data;
|
||||
}
|
||||
|
||||
return 'EUR';
|
||||
|
@@ -84,9 +84,9 @@ class UpgradeDatabase extends Command
|
||||
$this->call($command, $args);
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
|
@@ -66,7 +66,7 @@ class UpgradeLiabilities extends Command
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
if (null !== $configVar) {
|
||||
return (bool)$configVar->data;
|
||||
return (bool) $configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@@ -66,7 +66,7 @@ class UpgradeLiabilitiesEight extends Command
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
if (null !== $configVar) {
|
||||
return (bool)$configVar->data;
|
||||
return (bool) $configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@@ -39,9 +39,8 @@ class UpgradeMultiPiggyBanks extends Command
|
||||
protected $description = 'Upgrade piggybanks so they can use multiple accounts.';
|
||||
|
||||
protected $signature = 'firefly-iii:upgrade-multi-piggies {--F|force : Force the execution of this command.}';
|
||||
|
||||
private PiggyBankRepositoryInterface $repository;
|
||||
private AccountRepositoryInterface $accountRepository;
|
||||
private PiggyBankRepositoryInterface $repository;
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -71,11 +70,6 @@ class UpgradeMultiPiggyBanks extends Command
|
||||
return false;
|
||||
}
|
||||
|
||||
private function markAsExecuted(): void
|
||||
{
|
||||
app('fireflyconfig')->set(self::CONFIG_NAME, true);
|
||||
}
|
||||
|
||||
private function upgradePiggyBanks(): void
|
||||
{
|
||||
$this->repository = app(PiggyBankRepositoryInterface::class);
|
||||
@@ -109,4 +103,9 @@ class UpgradeMultiPiggyBanks extends Command
|
||||
$piggyBank->piggyBankRepetitions()->delete();
|
||||
|
||||
}
|
||||
|
||||
private function markAsExecuted(): void
|
||||
{
|
||||
app('fireflyconfig')->set(self::CONFIG_NAME, true);
|
||||
}
|
||||
}
|
||||
|
@@ -40,7 +40,7 @@ trait VerifiesAccessToken
|
||||
*/
|
||||
public function getUser(): User
|
||||
{
|
||||
$userId = (int)$this->option('user');
|
||||
$userId = (int) $this->option('user');
|
||||
|
||||
/** @var UserRepositoryInterface $repository */
|
||||
$repository = app(UserRepositoryInterface::class);
|
||||
@@ -68,8 +68,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);
|
||||
|
Reference in New Issue
Block a user