mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-09 14:18:59 +00:00
Replace log.
This commit is contained in:
@@ -28,5 +28,5 @@ parameters:
|
||||
|
||||
# The level 8 is the highest level. original was 5
|
||||
# 7 is more than enough, higher just leaves NULL things.
|
||||
level: 7
|
||||
level: 6
|
||||
|
||||
|
@@ -259,59 +259,6 @@ class BudgetController extends Controller
|
||||
return $return;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Function that processes each budget limit (per budget).
|
||||
// *
|
||||
// * If you have a budget limit in EUR, only transactions in EUR will be considered.
|
||||
// * If you have a budget limit in GBP, only transactions in GBP will be considered.
|
||||
// *
|
||||
// * If you have a budget limit in EUR, and a transaction in GBP, it will not be considered for the EUR budget limit.
|
||||
// *
|
||||
// * @throws FireflyException
|
||||
// */
|
||||
// private function budgetLimits(Budget $budget, Collection $limits): array
|
||||
// {
|
||||
// Log::debug(sprintf('Now in budgetLimits(#%d)', $budget->id));
|
||||
// $data = [];
|
||||
//
|
||||
// /** @var BudgetLimit $limit */
|
||||
// foreach ($limits as $limit) {
|
||||
// $data = array_merge($data, $this->processLimit($budget, $limit));
|
||||
// }
|
||||
//
|
||||
// return $data;
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * @throws FireflyException
|
||||
// */
|
||||
// private function processLimit(Budget $budget, BudgetLimit $limit): array
|
||||
// {
|
||||
// Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__));
|
||||
// $end = clone $limit->end_date;
|
||||
// $end->endOfDay();
|
||||
// $spent = $this->opsRepository->listExpenses($limit->start_date, $end, null, new Collection()->push($budget));
|
||||
// $limitCurrencyId = $limit->transaction_currency_id;
|
||||
//
|
||||
// /** @var array $entry */
|
||||
// // only spent the entry where the entry's currency matches the budget limit's currency
|
||||
// // so $filtered will only have 1 or 0 entries
|
||||
// $filtered = array_filter($spent, fn ($entry) => $entry['currency_id'] === $limitCurrencyId);
|
||||
// $result = $this->processExpenses($budget->id, $filtered, $limit->start_date, $end);
|
||||
// if (1 === count($result)) {
|
||||
// $compare = bccomp($limit->amount, (string)app('steam')->positive($result[$limitCurrencyId]['spent']));
|
||||
// $result[$limitCurrencyId]['budgeted'] = $limit->amount;
|
||||
// if (1 === $compare) {
|
||||
// // convert this amount into the primary currency:
|
||||
// $result[$limitCurrencyId]['left'] = bcadd($limit->amount, (string)$result[$limitCurrencyId]['spent']);
|
||||
// }
|
||||
// if ($compare <= 0) {
|
||||
// $result[$limitCurrencyId]['overspent'] = app('steam')->positive(bcadd($limit->amount, (string)$result[$limitCurrencyId]['spent']));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return $result;
|
||||
// }
|
||||
|
||||
private function filterLimit(int $currencyId, Collection $limits): ?BudgetLimit
|
||||
{
|
||||
|
@@ -107,11 +107,11 @@ class CategoryController extends Controller
|
||||
$type = $journal['transaction_type_type'];
|
||||
$currency = $currencies[$journalCurrencyId] ?? $this->currencyRepos->find($journalCurrencyId);
|
||||
$currencies[$journalCurrencyId] = $currency;
|
||||
$currencyId = (int)$currency->id;
|
||||
$currencyName = (string)$currency->name;
|
||||
$currencyCode = (string)$currency->code;
|
||||
$currencySymbol = (string)$currency->symbol;
|
||||
$currencyDecimalPlaces = (int)$currency->decimal_places;
|
||||
$currencyId = $currency->id;
|
||||
$currencyName = $currency->name;
|
||||
$currencyCode = $currency->code;
|
||||
$currencySymbol = $currency->symbol;
|
||||
$currencyDecimalPlaces = $currency->decimal_places;
|
||||
$amount = Steam::positive((string)$journal['amount']);
|
||||
$pcAmount = null;
|
||||
|
||||
@@ -120,11 +120,11 @@ class CategoryController extends Controller
|
||||
$pcAmount = $amount;
|
||||
}
|
||||
if ($this->convertToPrimary && $journalCurrencyId !== $this->primaryCurrency->id) {
|
||||
$currencyId = (int)$this->primaryCurrency->id;
|
||||
$currencyName = (string)$this->primaryCurrency->name;
|
||||
$currencyCode = (string)$this->primaryCurrency->code;
|
||||
$currencySymbol = (string)$this->primaryCurrency->symbol;
|
||||
$currencyDecimalPlaces = (int)$this->primaryCurrency->decimal_places;
|
||||
$currencyId = $this->primaryCurrency->id;
|
||||
$currencyName = $this->primaryCurrency->name;
|
||||
$currencyCode = $this->primaryCurrency->code;
|
||||
$currencySymbol = $this->primaryCurrency->symbol;
|
||||
$currencyDecimalPlaces = $this->primaryCurrency->decimal_places;
|
||||
$pcAmount = $converter->convert($currency, $this->primaryCurrency, $journal['date'], $amount);
|
||||
Log::debug(sprintf('Converted %s %s to %s %s', $journal['currency_code'], $amount, $this->primaryCurrency->code, $pcAmount));
|
||||
}
|
||||
@@ -141,10 +141,10 @@ class CategoryController extends Controller
|
||||
'currency_symbol' => $currencySymbol,
|
||||
'currency_decimal_places' => $currencyDecimalPlaces,
|
||||
'primary_currency_id' => (string)$this->primaryCurrency->id,
|
||||
'primary_currency_name' => (string)$this->primaryCurrency->name,
|
||||
'primary_currency_code' => (string)$this->primaryCurrency->code,
|
||||
'primary_currency_symbol' => (string)$this->primaryCurrency->symbol,
|
||||
'primary_currency_decimal_places' => (int)$this->primaryCurrency->decimal_places,
|
||||
'primary_currency_name' => $this->primaryCurrency->name,
|
||||
'primary_currency_code' => $this->primaryCurrency->code,
|
||||
'primary_currency_symbol' => $this->primaryCurrency->symbol,
|
||||
'primary_currency_decimal_places' => $this->primaryCurrency->decimal_places,
|
||||
'period' => null,
|
||||
'start_date' => $start->toAtomString(),
|
||||
'end_date' => $end->toAtomString(),
|
||||
|
@@ -34,6 +34,7 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CorrectsOpeningBalanceCurrencies extends Command
|
||||
{
|
||||
@@ -78,7 +79,7 @@ class CorrectsOpeningBalanceCurrencies extends Command
|
||||
$account = $this->getAccount($journal);
|
||||
if (!$account instanceof Account) {
|
||||
$message = sprintf('Transaction journal #%d has no valid account. Can\'t fix this line.', $journal->id);
|
||||
app('log')->warning($message);
|
||||
Log::warning($message);
|
||||
$this->friendlyError($message);
|
||||
|
||||
return 0;
|
||||
|
@@ -28,6 +28,7 @@ use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use FireflyIII\Enums\TransactionTypeEnum;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CorrectsTransferBudgets extends Command
|
||||
{
|
||||
@@ -53,13 +54,13 @@ class CorrectsTransferBudgets extends Command
|
||||
foreach ($set as $entry) {
|
||||
$message = sprintf('Transaction journal #%d is a %s, so has no longer a budget.', $entry->id, $entry->transactionType->type);
|
||||
$this->friendlyInfo($message);
|
||||
app('log')->debug($message);
|
||||
Log::debug($message);
|
||||
$entry->budgets()->sync([]);
|
||||
++$count;
|
||||
}
|
||||
if (0 !== $count) {
|
||||
$message = sprintf('Corrected %d invalid budget/journal entries (entry).', $count);
|
||||
app('log')->debug($message);
|
||||
Log::debug($message);
|
||||
$this->friendlyInfo($message);
|
||||
}
|
||||
|
||||
|
@@ -152,7 +152,7 @@ class CorrectsUnevenAmount extends Command
|
||||
$entry->the_sum
|
||||
);
|
||||
$this->friendlyWarning($message);
|
||||
app('log')->warning($message);
|
||||
Log::warning($message);
|
||||
++$this->count;
|
||||
|
||||
continue;
|
||||
@@ -230,7 +230,7 @@ class CorrectsUnevenAmount extends Command
|
||||
$message = sprintf('Sum of journal #%d is not zero, journal is broken and now fixed.', $journal->id);
|
||||
|
||||
$this->friendlyWarning($message);
|
||||
app('log')->warning($message);
|
||||
Log::warning($message);
|
||||
|
||||
$destination->amount = $amount;
|
||||
$destination->save();
|
||||
|
@@ -30,6 +30,7 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class RemovesEmptyJournals extends Command
|
||||
{
|
||||
@@ -68,8 +69,8 @@ class RemovesEmptyJournals extends Command
|
||||
$journal = TransactionJournal::find($row->transaction_journal_id);
|
||||
$journal?->delete();
|
||||
} catch (QueryException $e) {
|
||||
app('log')->info(sprintf('Could not delete journal: %s', $e->getMessage()));
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::info(sprintf('Could not delete journal: %s', $e->getMessage()));
|
||||
Log::error($e->getTraceAsString());
|
||||
}
|
||||
|
||||
Transaction::where('transaction_journal_id', $row->transaction_journal_id)->delete();
|
||||
@@ -96,8 +97,8 @@ class RemovesEmptyJournals extends Command
|
||||
$journal = TransactionJournal::find($entry->id);
|
||||
$journal?->delete();
|
||||
} catch (QueryException $e) {
|
||||
app('log')->info(sprintf('Could not delete entry: %s', $e->getMessage()));
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::info(sprintf('Could not delete entry: %s', $e->getMessage()));
|
||||
Log::error($e->getTraceAsString());
|
||||
}
|
||||
|
||||
$this->friendlyInfo(sprintf('Deleted empty transaction journal #%d', $entry->id));
|
||||
|
@@ -37,6 +37,7 @@ use FireflyIII\Support\Export\ExportDataGenerator;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Collection;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use InvalidArgumentException;
|
||||
|
||||
use function Safe\file_put_contents;
|
||||
@@ -189,7 +190,7 @@ class ExportsData extends Command
|
||||
try {
|
||||
$date = Carbon::createFromFormat('!Y-m-d', $this->option($field));
|
||||
} catch (InvalidArgumentException $e) {
|
||||
app('log')->error($e->getMessage());
|
||||
Log::error($e->getMessage());
|
||||
$this->friendlyError(sprintf('%s date "%s" must be formatted YYYY-MM-DD. Field will be ignored.', $field, $this->option('start')));
|
||||
$error = true;
|
||||
}
|
||||
@@ -200,7 +201,7 @@ class ExportsData extends Command
|
||||
}
|
||||
}
|
||||
if (null === $this->option($field)) {
|
||||
app('log')->info(sprintf('No date given in field "%s"', $field));
|
||||
Log::info(sprintf('No date given in field "%s"', $field));
|
||||
$error = true;
|
||||
}
|
||||
|
||||
|
@@ -43,6 +43,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use function Safe\mb_regex_encoding;
|
||||
use function Safe\json_encode;
|
||||
|
||||
@@ -95,7 +96,7 @@ class ForcesDecimalSize extends Command
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
app('log')->debug('Now in ForceDecimalSize::handle()');
|
||||
Log::debug('Now in ForceDecimalSize::handle()');
|
||||
$this->determineDatabaseType();
|
||||
|
||||
$this->friendlyError('Running this command is dangerous and can cause data loss.');
|
||||
|
@@ -27,6 +27,7 @@ namespace FireflyIII\Console\Commands\System;
|
||||
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use League\Flysystem\FilesystemException;
|
||||
|
||||
@@ -54,7 +55,7 @@ class VerifySecurityAlerts extends Command
|
||||
$disk = Storage::disk('resources');
|
||||
// Next line is ignored because it's a Laravel Facade.
|
||||
if (!$disk->has('alerts.json')) { // @phpstan-ignore-line
|
||||
app('log')->debug('No alerts.json file present.');
|
||||
Log::debug('No alerts.json file present.');
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -64,19 +65,19 @@ class VerifySecurityAlerts extends Command
|
||||
/** @var array $array */
|
||||
foreach ($json as $array) {
|
||||
if ($version === $array['version'] && true === $array['advisory']) {
|
||||
app('log')->debug(sprintf('Version %s has an alert!', $array['version']));
|
||||
Log::debug(sprintf('Version %s has an alert!', $array['version']));
|
||||
// add advisory to configuration.
|
||||
$this->saveSecurityAdvisory($array);
|
||||
|
||||
// depends on level
|
||||
if ('info' === $array['level']) {
|
||||
app('log')->debug('INFO level alert');
|
||||
Log::debug('INFO level alert');
|
||||
$this->friendlyInfo($array['message']);
|
||||
|
||||
return 0;
|
||||
}
|
||||
if ('warning' === $array['level']) {
|
||||
app('log')->debug('WARNING level alert');
|
||||
Log::debug('WARNING level alert');
|
||||
$this->friendlyWarning('------------------------ :o');
|
||||
$this->friendlyWarning($array['message']);
|
||||
$this->friendlyWarning('------------------------ :o');
|
||||
@@ -84,7 +85,7 @@ class VerifySecurityAlerts extends Command
|
||||
return 0;
|
||||
}
|
||||
if ('danger' === $array['level']) {
|
||||
app('log')->debug('DANGER level alert');
|
||||
Log::debug('DANGER level alert');
|
||||
$this->friendlyError('------------------------ :-(');
|
||||
$this->friendlyError($array['message']);
|
||||
$this->friendlyError('------------------------ :-(');
|
||||
@@ -95,7 +96,7 @@ class VerifySecurityAlerts extends Command
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
app('log')->debug(sprintf('No security alerts for version %s', $version));
|
||||
Log::debug(sprintf('No security alerts for version %s', $version));
|
||||
$this->friendlyPositive(sprintf('No security alerts for version %s', $version));
|
||||
|
||||
return 0;
|
||||
@@ -107,7 +108,7 @@ class VerifySecurityAlerts extends Command
|
||||
app('fireflyconfig')->delete('upgrade_security_message');
|
||||
app('fireflyconfig')->delete('upgrade_security_level');
|
||||
} catch (QueryException $e) {
|
||||
app('log')->debug(sprintf('Could not delete old security advisory, but thats OK: %s', $e->getMessage()));
|
||||
Log::debug(sprintf('Could not delete old security advisory, but thats OK: %s', $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +118,7 @@ class VerifySecurityAlerts extends Command
|
||||
app('fireflyconfig')->set('upgrade_security_message', $array['message']);
|
||||
app('fireflyconfig')->set('upgrade_security_level', $array['level']);
|
||||
} catch (QueryException $e) {
|
||||
app('log')->debug(sprintf('Could not save new security advisory, but thats OK: %s', $e->getMessage()));
|
||||
Log::debug(sprintf('Could not save new security advisory, but thats OK: %s', $e->getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -315,7 +315,7 @@ class ApplyRules extends Command
|
||||
// if in rule selection, or group in selection or all rules, it's included.
|
||||
$test = $this->includeRule($rule, $group);
|
||||
if (true === $test) {
|
||||
app('log')->debug(sprintf('Will include rule #%d "%s"', $rule->id, $rule->title));
|
||||
Log::debug(sprintf('Will include rule #%d "%s"', $rule->id, $rule->title));
|
||||
$rulesToApply->push($rule);
|
||||
}
|
||||
}
|
||||
|
@@ -76,8 +76,8 @@ class Cron extends Command
|
||||
try {
|
||||
$this->exchangeRatesCronJob($force, $date);
|
||||
} catch (FireflyException $e) {
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
$this->friendlyError($e->getMessage());
|
||||
}
|
||||
}
|
||||
@@ -87,8 +87,8 @@ class Cron extends Command
|
||||
try {
|
||||
$this->checkForUpdates($force);
|
||||
} catch (FireflyException $e) {
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
$this->friendlyError($e->getMessage());
|
||||
}
|
||||
}
|
||||
@@ -98,8 +98,8 @@ class Cron extends Command
|
||||
try {
|
||||
$this->recurringCronJob($force, $date);
|
||||
} catch (FireflyException $e) {
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
$this->friendlyError($e->getMessage());
|
||||
}
|
||||
}
|
||||
@@ -109,8 +109,8 @@ class Cron extends Command
|
||||
try {
|
||||
$this->autoBudgetCronJob($force, $date);
|
||||
} catch (FireflyException $e) {
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
$this->friendlyError($e->getMessage());
|
||||
}
|
||||
}
|
||||
@@ -120,8 +120,8 @@ class Cron extends Command
|
||||
try {
|
||||
$this->subscriptionWarningCronJob($force, $date);
|
||||
} catch (FireflyException $e) {
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
$this->friendlyError($e->getMessage());
|
||||
}
|
||||
}
|
||||
@@ -130,8 +130,8 @@ class Cron extends Command
|
||||
try {
|
||||
$this->webhookCronJob($force, $date);
|
||||
} catch (FireflyException $e) {
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
$this->friendlyError($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
@@ -31,6 +31,7 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Journal\JournalCLIRepositoryInterface;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddsTransactionIdentifiers extends Command
|
||||
@@ -147,7 +148,7 @@ class AddsTransactionIdentifiers extends Command
|
||||
->first()
|
||||
;
|
||||
} catch (QueryException $e) {
|
||||
app('log')->error($e->getMessage());
|
||||
Log::error($e->getMessage());
|
||||
$this->friendlyError('Firefly III could not find the "identifier" field in the "transactions" table.');
|
||||
$this->friendlyError(sprintf('This field is required for Firefly III version %s to run.', config('firefly.version')));
|
||||
$this->friendlyError('Please run "php artisan migrate --force" to add this field to the table.');
|
||||
|
@@ -31,6 +31,7 @@ use Illuminate\Console\Command;
|
||||
use Illuminate\Contracts\Encryption\DecryptException;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use JsonException;
|
||||
use stdClass;
|
||||
|
||||
@@ -96,7 +97,7 @@ class RemovesDatabaseDecryption extends Command
|
||||
try {
|
||||
$configVar = app('fireflyconfig')->get($configName, false);
|
||||
} catch (FireflyException $e) {
|
||||
app('log')->error($e->getMessage());
|
||||
Log::error($e->getMessage());
|
||||
}
|
||||
if (null !== $configVar) {
|
||||
return (bool) $configVar->data;
|
||||
@@ -129,8 +130,8 @@ class RemovesDatabaseDecryption extends Command
|
||||
} catch (FireflyException $e) {
|
||||
$message = sprintf('Could not decrypt field "%s" in row #%d of table "%s": %s', $field, $id, $table, $e->getMessage());
|
||||
$this->friendlyError($message);
|
||||
app('log')->error($message);
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($message);
|
||||
Log::error($e->getTraceAsString());
|
||||
}
|
||||
|
||||
// A separate routine for preferences table:
|
||||
@@ -175,9 +176,9 @@ class RemovesDatabaseDecryption extends Command
|
||||
} catch (JsonException $e) {
|
||||
$message = sprintf('Could not JSON decode preference row #%d: %s. This does not have to be a problem.', $id, $e->getMessage());
|
||||
$this->friendlyError($message);
|
||||
app('log')->warning($message);
|
||||
app('log')->warning($value);
|
||||
app('log')->warning($e->getTraceAsString());
|
||||
Log::warning($message);
|
||||
Log::warning($value);
|
||||
Log::warning($e->getTraceAsString());
|
||||
|
||||
return;
|
||||
}
|
||||
|
@@ -29,6 +29,7 @@ use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Attachment;
|
||||
use FireflyIII\Models\Note;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UpgradesAttachments extends Command
|
||||
{
|
||||
@@ -75,7 +76,7 @@ class UpgradesAttachments extends Command
|
||||
$att->description = '';
|
||||
$att->save();
|
||||
|
||||
app('log')->debug(sprintf('Migrated attachment #%s description to note #%d.', $att->id, $note->id));
|
||||
Log::debug(sprintf('Migrated attachment #%s description to note #%d.', $att->id, $note->id));
|
||||
++$count;
|
||||
}
|
||||
}
|
||||
|
@@ -27,6 +27,7 @@ namespace FireflyIII\Console\Commands\Upgrade;
|
||||
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use FireflyIII\Models\BudgetLimit;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UpgradesBudgetLimitPeriods extends Command
|
||||
{
|
||||
@@ -84,7 +85,7 @@ class UpgradesBudgetLimitPeriods extends Command
|
||||
$limit->end_date->format('Y-m-d')
|
||||
);
|
||||
$this->friendlyWarning($message);
|
||||
app('log')->warning($message);
|
||||
Log::warning($message);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -98,7 +99,7 @@ class UpgradesBudgetLimitPeriods extends Command
|
||||
$limit->end_date->format('Y-m-d'),
|
||||
$period
|
||||
);
|
||||
app('log')->debug($msg);
|
||||
Log::debug($msg);
|
||||
}
|
||||
|
||||
private function getLimitPeriod(BudgetLimit $limit): ?string
|
||||
|
@@ -28,6 +28,7 @@ use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\TransactionJournalMeta;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UpgradesJournalNotes extends Command
|
||||
{
|
||||
@@ -66,7 +67,7 @@ class UpgradesJournalNotes extends Command
|
||||
|
||||
$note->text = $meta->data;
|
||||
$note->save();
|
||||
app('log')->debug(sprintf('Migrated meta note #%d to Note #%d', $meta->id, $note->id));
|
||||
Log::debug(sprintf('Migrated meta note #%d to Note #%d', $meta->id, $note->id));
|
||||
$meta->delete();
|
||||
|
||||
++$count;
|
||||
|
@@ -35,6 +35,7 @@ use FireflyIII\Services\Internal\Destroy\TransactionGroupDestroyService;
|
||||
use FireflyIII\Services\Internal\Support\CreditRecalculateService;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UpgradesLiabilitiesEight extends Command
|
||||
{
|
||||
@@ -186,7 +187,7 @@ class UpgradesLiabilitiesEight extends Command
|
||||
|
||||
return;
|
||||
}
|
||||
app('log')->warning('Did not find opening balance.');
|
||||
Log::warning('Did not find opening balance.');
|
||||
}
|
||||
|
||||
private function deleteTransactions(Account $account): int
|
||||
|
@@ -38,6 +38,7 @@ use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UpgradesToGroups extends Command
|
||||
{
|
||||
@@ -127,11 +128,11 @@ class UpgradesToGroups extends Command
|
||||
{
|
||||
// double check transaction count.
|
||||
if ($journal->transactions->count() <= 2) {
|
||||
app('log')->debug(sprintf('Will not try to convert journal #%d because it has 2 or fewer transactions.', $journal->id));
|
||||
Log::debug(sprintf('Will not try to convert journal #%d because it has 2 or fewer transactions.', $journal->id));
|
||||
|
||||
return;
|
||||
}
|
||||
app('log')->debug(sprintf('Will now try to convert journal #%d', $journal->id));
|
||||
Log::debug(sprintf('Will now try to convert journal #%d', $journal->id));
|
||||
|
||||
$this->journalRepository->setUser($journal->user);
|
||||
$this->groupFactory->setUser($journal->user);
|
||||
@@ -144,15 +145,15 @@ class UpgradesToGroups extends Command
|
||||
];
|
||||
$destTransactions = $this->getDestinationTransactions($journal);
|
||||
|
||||
app('log')->debug(sprintf('Will use %d positive transactions to create a new group.', $destTransactions->count()));
|
||||
Log::debug(sprintf('Will use %d positive transactions to create a new group.', $destTransactions->count()));
|
||||
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($destTransactions as $transaction) {
|
||||
$data['transactions'][] = $this->generateTransaction($journal, $transaction);
|
||||
}
|
||||
app('log')->debug(sprintf('Now calling transaction journal factory (%d transactions in array)', count($data['transactions'])));
|
||||
Log::debug(sprintf('Now calling transaction journal factory (%d transactions in array)', count($data['transactions'])));
|
||||
$group = $this->groupFactory->create($data);
|
||||
app('log')->debug('Done calling transaction journal factory');
|
||||
Log::debug('Done calling transaction journal factory');
|
||||
|
||||
// delete the old transaction journal.
|
||||
$this->service->destroy($journal);
|
||||
@@ -160,7 +161,7 @@ class UpgradesToGroups extends Command
|
||||
++$this->count;
|
||||
|
||||
// report on result:
|
||||
app('log')->debug(
|
||||
Log::debug(
|
||||
sprintf(
|
||||
'Migrated journal #%d into group #%d with these journals: #%s',
|
||||
$journal->id,
|
||||
@@ -190,7 +191,7 @@ class UpgradesToGroups 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));
|
||||
Log::debug(sprintf('Now going to add transaction #%d to the array.', $transaction->id));
|
||||
$opposingTr = $this->findOpposingTransaction($journal, $transaction);
|
||||
|
||||
if (!$opposingTr instanceof Transaction) {
|
||||
@@ -282,8 +283,8 @@ class UpgradesToGroups extends Command
|
||||
static function (Transaction $subject) use ($transaction) {
|
||||
$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)));
|
||||
Log::debug(sprintf('Amount the same? %s', var_export($amount, true)));
|
||||
Log::debug(sprintf('ID the same? %s', var_export($identifier, true)));
|
||||
|
||||
return $amount && $identifier;
|
||||
}
|
||||
@@ -294,13 +295,13 @@ class UpgradesToGroups extends Command
|
||||
|
||||
private function getTransactionBudget(Transaction $left, Transaction $right): ?int
|
||||
{
|
||||
app('log')->debug('Now in getTransactionBudget()');
|
||||
Log::debug('Now in getTransactionBudget()');
|
||||
|
||||
// try to get a budget ID from the left transaction:
|
||||
/** @var null|Budget $budget */
|
||||
$budget = $left->budgets()->first();
|
||||
if (null !== $budget) {
|
||||
app('log')->debug(sprintf('Return budget #%d, from transaction #%d', $budget->id, $left->id));
|
||||
Log::debug(sprintf('Return budget #%d, from transaction #%d', $budget->id, $left->id));
|
||||
|
||||
return $budget->id;
|
||||
}
|
||||
@@ -309,11 +310,11 @@ class UpgradesToGroups extends Command
|
||||
/** @var null|Budget $budget */
|
||||
$budget = $right->budgets()->first();
|
||||
if (null !== $budget) {
|
||||
app('log')->debug(sprintf('Return budget #%d, from transaction #%d', $budget->id, $right->id));
|
||||
Log::debug(sprintf('Return budget #%d, from transaction #%d', $budget->id, $right->id));
|
||||
|
||||
return $budget->id;
|
||||
}
|
||||
app('log')->debug('Neither left or right have a budget, return NULL');
|
||||
Log::debug('Neither left or right have a budget, return NULL');
|
||||
|
||||
// if all fails, return NULL.
|
||||
return null;
|
||||
@@ -321,13 +322,13 @@ class UpgradesToGroups extends Command
|
||||
|
||||
private function getTransactionCategory(Transaction $left, Transaction $right): ?int
|
||||
{
|
||||
app('log')->debug('Now in getTransactionCategory()');
|
||||
Log::debug('Now in getTransactionCategory()');
|
||||
|
||||
// try to get a category ID from the left transaction:
|
||||
/** @var null|Category $category */
|
||||
$category = $left->categories()->first();
|
||||
if (null !== $category) {
|
||||
app('log')->debug(sprintf('Return category #%d, from transaction #%d', $category->id, $left->id));
|
||||
Log::debug(sprintf('Return category #%d, from transaction #%d', $category->id, $left->id));
|
||||
|
||||
return $category->id;
|
||||
}
|
||||
@@ -336,11 +337,11 @@ class UpgradesToGroups extends Command
|
||||
/** @var null|Category $category */
|
||||
$category = $right->categories()->first();
|
||||
if (null !== $category) {
|
||||
app('log')->debug(sprintf('Return category #%d, from transaction #%d', $category->id, $category->id));
|
||||
Log::debug(sprintf('Return category #%d, from transaction #%d', $category->id, $category->id));
|
||||
|
||||
return $category->id;
|
||||
}
|
||||
app('log')->debug('Neither left or right have a category, return NULL');
|
||||
Log::debug('Neither left or right have a category, return NULL');
|
||||
|
||||
// if all fails, return NULL.
|
||||
return null;
|
||||
@@ -354,7 +355,7 @@ class UpgradesToGroups extends Command
|
||||
$orphanedJournals = $this->cliRepository->getJournalsWithoutGroup();
|
||||
$total = count($orphanedJournals);
|
||||
if ($total > 0) {
|
||||
app('log')->debug(sprintf('Going to convert %d transaction journals. Please hold..', $total));
|
||||
Log::debug(sprintf('Going to convert %d transaction journals. Please hold..', $total));
|
||||
$this->friendlyInfo(sprintf('Going to convert %d transaction journals. Please hold..', $total));
|
||||
|
||||
/** @var array $array */
|
||||
|
@@ -33,6 +33,7 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalCLIRepositoryInterface;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UpgradesTransferCurrencies extends Command
|
||||
{
|
||||
@@ -262,7 +263,7 @@ class UpgradesTransferCurrencies extends Command
|
||||
// source account must have a currency preference.
|
||||
if (!$this->sourceCurrency instanceof TransactionCurrency) {
|
||||
$message = sprintf('Account #%d ("%s") must have currency preference but has none.', $this->sourceAccount->id, $this->sourceAccount->name);
|
||||
app('log')->error($message);
|
||||
Log::error($message);
|
||||
$this->friendlyError($message);
|
||||
|
||||
return true;
|
||||
@@ -275,7 +276,7 @@ class UpgradesTransferCurrencies extends Command
|
||||
$this->destinationAccount->id,
|
||||
$this->destinationAccount->name
|
||||
);
|
||||
app('log')->error($message);
|
||||
Log::error($message);
|
||||
$this->friendlyError($message);
|
||||
|
||||
return true;
|
||||
|
@@ -27,6 +27,7 @@ namespace FireflyIII\Console\Commands;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Trait VerifiesAccessToken.
|
||||
@@ -76,19 +77,19 @@ trait VerifiesAccessToken
|
||||
$user = $repository->find($userId);
|
||||
|
||||
if (null === $user) {
|
||||
app('log')->error(sprintf('verifyAccessToken(): no such user for input "%d"', $userId));
|
||||
Log::error(sprintf('verifyAccessToken(): no such user for input "%d"', $userId));
|
||||
|
||||
return false;
|
||||
}
|
||||
$accessToken = app('preferences')->getForUser($user, 'access_token');
|
||||
if (null === $accessToken) {
|
||||
app('log')->error(sprintf('User #%d has no access token, so cannot access command line options.', $userId));
|
||||
Log::error(sprintf('User #%d has no access token, so cannot access command line options.', $userId));
|
||||
|
||||
return false;
|
||||
}
|
||||
if ($accessToken->data !== $token) {
|
||||
app('log')->error(sprintf('Invalid access token for user #%d.', $userId));
|
||||
app('log')->error(sprintf('Token given is "%s", expected something else.', $token));
|
||||
Log::error(sprintf('Invalid access token for user #%d.', $userId));
|
||||
Log::error(sprintf('Token given is "%s", expected something else.', $token));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@@ -26,6 +26,7 @@ namespace FireflyIII\Console;
|
||||
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Override;
|
||||
|
||||
/**
|
||||
@@ -52,7 +53,7 @@ class Kernel extends ConsoleKernel
|
||||
{
|
||||
$schedule->call(
|
||||
static function (): void {
|
||||
app('log')->error(
|
||||
Log::error(
|
||||
'Firefly III no longer users the Laravel scheduler to do cron jobs! Please read the instructions at https://docs.firefly-iii.org/'
|
||||
);
|
||||
echo "\n";
|
||||
|
@@ -26,6 +26,7 @@ namespace FireflyIII\Events;
|
||||
|
||||
use FireflyIII\Models\TransactionGroup;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class DestroyedTransactionGroup.
|
||||
@@ -39,6 +40,6 @@ class DestroyedTransactionGroup extends Event
|
||||
*/
|
||||
public function __construct(public TransactionGroup $transactionGroup)
|
||||
{
|
||||
app('log')->debug(sprintf('Now in %s', __METHOD__));
|
||||
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||
}
|
||||
}
|
||||
|
@@ -29,6 +29,7 @@ use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Models\TransactionGroup;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class ChangedAmount
|
||||
@@ -45,7 +46,7 @@ class ChangedAmount extends Event
|
||||
*/
|
||||
public function __construct(PiggyBank $piggyBank, string $amount, public ?TransactionJournal $transactionJournal, public ?TransactionGroup $transactionGroup)
|
||||
{
|
||||
app('log')->debug(sprintf('Created piggy bank event for piggy bank #%d with amount %s', $piggyBank->id, $amount));
|
||||
Log::debug(sprintf('Created piggy bank event for piggy bank #%d with amount %s', $piggyBank->id, $amount));
|
||||
$this->piggyBank = $piggyBank;
|
||||
$this->amount = $amount;
|
||||
}
|
||||
|
@@ -26,6 +26,7 @@ namespace FireflyIII\Events\Model\Rule;
|
||||
|
||||
use FireflyIII\Models\RuleAction;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class RuleActionFailedOnArray
|
||||
@@ -36,6 +37,6 @@ class RuleActionFailedOnArray
|
||||
|
||||
public function __construct(public RuleAction $ruleAction, public array $journal, public string $error)
|
||||
{
|
||||
app('log')->debug('Created new RuleActionFailedOnArray');
|
||||
Log::debug('Created new RuleActionFailedOnArray');
|
||||
}
|
||||
}
|
||||
|
@@ -27,6 +27,7 @@ namespace FireflyIII\Events\Model\Rule;
|
||||
use FireflyIII\Models\RuleAction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class RuleActionFailedOnObject
|
||||
@@ -37,6 +38,6 @@ class RuleActionFailedOnObject
|
||||
|
||||
public function __construct(public RuleAction $ruleAction, public TransactionJournal $journal, public string $error)
|
||||
{
|
||||
app('log')->debug('Created new RuleActionFailedOnObject');
|
||||
Log::debug('Created new RuleActionFailedOnObject');
|
||||
}
|
||||
}
|
||||
|
@@ -29,6 +29,7 @@ use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class RequestedReportOnJournals
|
||||
@@ -44,7 +45,7 @@ class RequestedReportOnJournals
|
||||
*/
|
||||
public function __construct(public int $userId, public Collection $groups)
|
||||
{
|
||||
app('log')->debug('In event RequestedReportOnJournals.');
|
||||
Log::debug('In event RequestedReportOnJournals.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -26,6 +26,7 @@ namespace FireflyIII\Events\Test;
|
||||
|
||||
use FireflyIII\Notifications\Notifiables\OwnerNotifiable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class OwnerTestNotificationChannel
|
||||
{
|
||||
@@ -38,7 +39,7 @@ class OwnerTestNotificationChannel
|
||||
*/
|
||||
public function __construct(string $channel, public OwnerNotifiable $owner)
|
||||
{
|
||||
app('log')->debug(sprintf('Triggered OwnerTestNotificationChannel("%s")', $channel));
|
||||
Log::debug(sprintf('Triggered OwnerTestNotificationChannel("%s")', $channel));
|
||||
$this->channel = $channel;
|
||||
}
|
||||
}
|
||||
|
@@ -26,6 +26,7 @@ namespace FireflyIII\Events\Test;
|
||||
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UserTestNotificationChannel
|
||||
{
|
||||
@@ -38,7 +39,7 @@ class UserTestNotificationChannel
|
||||
*/
|
||||
public function __construct(string $channel, public User $user)
|
||||
{
|
||||
app('log')->debug(sprintf('Triggered UserTestNotificationChannel("%s")', $channel));
|
||||
Log::debug(sprintf('Triggered UserTestNotificationChannel("%s")', $channel));
|
||||
$this->channel = $channel;
|
||||
}
|
||||
}
|
||||
|
@@ -33,6 +33,7 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Override;
|
||||
use Throwable;
|
||||
@@ -65,7 +66,7 @@ class GracefulNotFoundHandler extends ExceptionHandler
|
||||
|
||||
switch ($name) {
|
||||
default:
|
||||
app('log')->warning(sprintf('GracefulNotFoundHandler cannot handle route with name "%s"', $name));
|
||||
Log::warning(sprintf('GracefulNotFoundHandler cannot handle route with name "%s"', $name));
|
||||
|
||||
return parent::render($request, $e);
|
||||
|
||||
@@ -152,7 +153,7 @@ class GracefulNotFoundHandler extends ExceptionHandler
|
||||
*/
|
||||
private function handleAccount(Request $request, Throwable $exception): Response
|
||||
{
|
||||
app('log')->debug('404 page is probably a deleted account. Redirect to overview of account types.');
|
||||
Log::debug('404 page is probably a deleted account. Redirect to overview of account types.');
|
||||
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
@@ -169,7 +170,7 @@ class GracefulNotFoundHandler extends ExceptionHandler
|
||||
/** @var null|Account $account */
|
||||
$account = $user->accounts()->withTrashed()->with(['accountType'])->find($accountId);
|
||||
if (null === $account) {
|
||||
app('log')->error(sprintf('Could not find account %d, so give big fat error.', $accountId));
|
||||
Log::error(sprintf('Could not find account %d, so give big fat error.', $accountId));
|
||||
|
||||
return parent::render($request, $exception);
|
||||
}
|
||||
@@ -187,7 +188,7 @@ class GracefulNotFoundHandler extends ExceptionHandler
|
||||
*/
|
||||
private function handleGroup(Request $request, Throwable $exception)
|
||||
{
|
||||
app('log')->debug('404 page is probably a deleted group. Redirect to overview of group types.');
|
||||
Log::debug('404 page is probably a deleted group. Redirect to overview of group types.');
|
||||
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
@@ -198,7 +199,7 @@ class GracefulNotFoundHandler extends ExceptionHandler
|
||||
/** @var null|TransactionGroup $group */
|
||||
$group = $user->transactionGroups()->withTrashed()->find($groupId);
|
||||
if (null === $group) {
|
||||
app('log')->error(sprintf('Could not find group %d, so give big fat error.', $groupId));
|
||||
Log::error(sprintf('Could not find group %d, so give big fat error.', $groupId));
|
||||
|
||||
return parent::render($request, $exception);
|
||||
}
|
||||
@@ -206,7 +207,7 @@ class GracefulNotFoundHandler extends ExceptionHandler
|
||||
/** @var null|TransactionJournal $journal */
|
||||
$journal = $group->transactionJournals()->withTrashed()->first();
|
||||
if (null === $journal) {
|
||||
app('log')->error(sprintf('Could not find journal for group %d, so give big fat error.', $groupId));
|
||||
Log::error(sprintf('Could not find journal for group %d, so give big fat error.', $groupId));
|
||||
|
||||
return parent::render($request, $exception);
|
||||
}
|
||||
@@ -227,7 +228,7 @@ class GracefulNotFoundHandler extends ExceptionHandler
|
||||
*/
|
||||
private function handleAttachment(Request $request, Throwable $exception)
|
||||
{
|
||||
app('log')->debug('404 page is probably a deleted attachment. Redirect to parent object.');
|
||||
Log::debug('404 page is probably a deleted attachment. Redirect to parent object.');
|
||||
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
@@ -238,7 +239,7 @@ class GracefulNotFoundHandler extends ExceptionHandler
|
||||
/** @var null|Attachment $attachment */
|
||||
$attachment = $user->attachments()->withTrashed()->find($attachmentId);
|
||||
if (null === $attachment) {
|
||||
app('log')->error(sprintf('Could not find attachment %d, so give big fat error.', $attachmentId));
|
||||
Log::error(sprintf('Could not find attachment %d, so give big fat error.', $attachmentId));
|
||||
|
||||
return parent::render($request, $exception);
|
||||
}
|
||||
@@ -260,7 +261,7 @@ class GracefulNotFoundHandler extends ExceptionHandler
|
||||
}
|
||||
}
|
||||
|
||||
app('log')->error(sprintf('Could not redirect attachment %d, its linked to a %s.', $attachmentId, $attachment->attachable_type));
|
||||
Log::error(sprintf('Could not redirect attachment %d, its linked to a %s.', $attachmentId, $attachment->attachable_type));
|
||||
|
||||
return parent::render($request, $exception);
|
||||
}
|
||||
|
@@ -36,6 +36,7 @@ use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Session\TokenMismatchException;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Validation\ValidationException as LaravelValidationException;
|
||||
use Laravel\Passport\Exceptions\OAuthServerException as LaravelOAuthException;
|
||||
use League\OAuth2\Server\Exception\OAuthServerException;
|
||||
@@ -98,51 +99,51 @@ class Handler extends ExceptionHandler
|
||||
{
|
||||
$expectsJson = $request->expectsJson();
|
||||
|
||||
app('log')->debug('Now in Handler::render()');
|
||||
Log::debug('Now in Handler::render()');
|
||||
|
||||
if ($e instanceof LaravelValidationException && $expectsJson) {
|
||||
// ignore it: controller will handle it.
|
||||
|
||||
app('log')->debug(sprintf('Return to parent to handle LaravelValidationException(%d)', $e->status));
|
||||
Log::debug(sprintf('Return to parent to handle LaravelValidationException(%d)', $e->status));
|
||||
|
||||
return parent::render($request, $e);
|
||||
}
|
||||
if ($e instanceof NotFoundHttpException && $expectsJson) {
|
||||
// JSON error:
|
||||
app('log')->debug('Return JSON not found error.');
|
||||
Log::debug('Return JSON not found error.');
|
||||
|
||||
return response()->json(['message' => 'Resource not found', 'exception' => 'NotFoundHttpException'], 404);
|
||||
}
|
||||
|
||||
if ($e instanceof AuthorizationException && $expectsJson) {
|
||||
// somehow Laravel handler does not catch this:
|
||||
app('log')->debug('Return JSON unauthorized error.');
|
||||
Log::debug('Return JSON unauthorized error.');
|
||||
|
||||
return response()->json(['message' => $e->getMessage(), 'exception' => 'AuthorizationException'], 401);
|
||||
}
|
||||
|
||||
if ($e instanceof AuthenticationException && $expectsJson) {
|
||||
// somehow Laravel handler does not catch this:
|
||||
app('log')->debug('Return JSON unauthenticated error.');
|
||||
Log::debug('Return JSON unauthenticated error.');
|
||||
|
||||
return response()->json(['message' => $e->getMessage(), 'exception' => 'AuthenticationException'], 401);
|
||||
}
|
||||
|
||||
if ($e instanceof OAuthServerException && $expectsJson) {
|
||||
app('log')->debug('Return JSON OAuthServerException.');
|
||||
Log::debug('Return JSON OAuthServerException.');
|
||||
|
||||
// somehow Laravel handler does not catch this:
|
||||
return response()->json(['message' => $e->getMessage(), 'exception' => 'OAuthServerException'], 401);
|
||||
}
|
||||
if ($e instanceof BadRequestHttpException) {
|
||||
app('log')->debug('Return JSON BadRequestHttpException.');
|
||||
Log::debug('Return JSON BadRequestHttpException.');
|
||||
|
||||
return response()->json(['message' => $e->getMessage(), 'exception' => 'HttpException'], 400);
|
||||
}
|
||||
|
||||
if ($e instanceof BadHttpHeaderException) {
|
||||
// is always API exception.
|
||||
app('log')->debug('Return JSON BadHttpHeaderException.');
|
||||
Log::debug('Return JSON BadHttpHeaderException.');
|
||||
|
||||
return response()->json(['message' => $e->getMessage(), 'exception' => 'BadHttpHeaderException'], $e->statusCode);
|
||||
}
|
||||
@@ -161,7 +162,7 @@ class Handler extends ExceptionHandler
|
||||
|
||||
$isDebug = (bool) config('app.debug', false);
|
||||
if ($isDebug) {
|
||||
app('log')->debug(sprintf('Return JSON %s with debug.', $e::class));
|
||||
Log::debug(sprintf('Return JSON %s with debug.', $e::class));
|
||||
|
||||
return response()->json(
|
||||
[
|
||||
@@ -174,7 +175,7 @@ class Handler extends ExceptionHandler
|
||||
$errorCode
|
||||
);
|
||||
}
|
||||
app('log')->debug(sprintf('Return JSON %s.', $e::class));
|
||||
Log::debug(sprintf('Return JSON %s.', $e::class));
|
||||
|
||||
return response()->json(
|
||||
['message' => sprintf('Internal Firefly III Exception: %s', $e->getMessage()), 'exception' => 'UndisclosedException'],
|
||||
@@ -183,7 +184,7 @@ class Handler extends ExceptionHandler
|
||||
}
|
||||
|
||||
if ($e instanceof NotFoundHttpException) {
|
||||
app('log')->debug('Refer to GracefulNotFoundHandler');
|
||||
Log::debug('Refer to GracefulNotFoundHandler');
|
||||
$handler = app(GracefulNotFoundHandler::class);
|
||||
|
||||
return $handler->render($request, $e);
|
||||
@@ -191,20 +192,20 @@ class Handler extends ExceptionHandler
|
||||
|
||||
// special view for database errors with extra instructions
|
||||
if ($e instanceof QueryException) {
|
||||
app('log')->debug('Return Firefly III database exception view.');
|
||||
Log::debug('Return Firefly III database exception view.');
|
||||
$isDebug = config('app.debug');
|
||||
|
||||
return response()->view('errors.DatabaseException', ['exception' => $e, 'debug' => $isDebug], 500);
|
||||
}
|
||||
|
||||
if ($e instanceof FireflyException || $e instanceof ErrorException || $e instanceof OAuthServerException) {
|
||||
app('log')->debug('Return Firefly III error view.');
|
||||
Log::debug('Return Firefly III error view.');
|
||||
$isDebug = config('app.debug');
|
||||
|
||||
return response()->view('errors.FireflyException', ['exception' => $e, 'debug' => $isDebug], 500);
|
||||
}
|
||||
|
||||
app('log')->debug(sprintf('Error "%s" has no Firefly III treatment, parent will handle.', $e::class));
|
||||
Log::debug(sprintf('Error "%s" has no Firefly III treatment, parent will handle.', $e::class));
|
||||
|
||||
return parent::render($request, $e);
|
||||
}
|
||||
|
@@ -72,16 +72,18 @@ class AccountFactory
|
||||
*/
|
||||
public function findOrCreate(string $accountName, string $accountType): Account
|
||||
{
|
||||
app('log')->debug(sprintf('findOrCreate("%s", "%s")', $accountName, $accountType));
|
||||
Log::debug(sprintf('findOrCreate("%s", "%s")', $accountName, $accountType));
|
||||
|
||||
$type = $this->accountRepository->getAccountTypeByType($accountType);
|
||||
if (!$type instanceof AccountType) {
|
||||
throw new FireflyException(sprintf('Cannot find account type "%s"', $accountType));
|
||||
}
|
||||
/** @var Account|null $return */
|
||||
$return = $this->user->accounts->where('account_type_id', $type->id)->where('name', $accountName)->first();
|
||||
|
||||
if (null === $return) {
|
||||
app('log')->debug('Found nothing. Will create a new one.');
|
||||
Log::debug('Found nothing. Will create a new one.');
|
||||
/** @var Account $return */
|
||||
$return = $this->create(
|
||||
[
|
||||
'user_id' => $this->user->id,
|
||||
@@ -104,7 +106,7 @@ class AccountFactory
|
||||
*/
|
||||
public function create(array $data): Account
|
||||
{
|
||||
app('log')->debug('Now in AccountFactory::create()');
|
||||
Log::debug('Now in AccountFactory::create()');
|
||||
$type = $this->getAccountType($data);
|
||||
$data['iban'] = $this->filterIban($data['iban'] ?? null);
|
||||
|
||||
@@ -146,18 +148,18 @@ class AccountFactory
|
||||
}
|
||||
}
|
||||
if (null === $result) {
|
||||
app('log')->warning(sprintf('Found NO account type based on %d and "%s"', $accountTypeId, $accountTypeName));
|
||||
Log::warning(sprintf('Found NO account type based on %d and "%s"', $accountTypeId, $accountTypeName));
|
||||
|
||||
throw new FireflyException(sprintf('AccountFactory::create() was unable to find account type #%d ("%s").', $accountTypeId, $accountTypeName));
|
||||
}
|
||||
app('log')->debug(sprintf('Found account type based on %d and "%s": "%s"', $accountTypeId, $accountTypeName, $result->type));
|
||||
Log::debug(sprintf('Found account type based on %d and "%s": "%s"', $accountTypeId, $accountTypeName, $result->type));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function find(string $accountName, string $accountType): ?Account
|
||||
{
|
||||
app('log')->debug(sprintf('Now in AccountFactory::find("%s", "%s")', $accountName, $accountType));
|
||||
Log::debug(sprintf('Now in AccountFactory::find("%s", "%s")', $accountName, $accountType));
|
||||
$type = AccountType::whereType($accountType)->first();
|
||||
|
||||
/** @var null|Account */
|
||||
@@ -204,16 +206,16 @@ class AccountFactory
|
||||
try {
|
||||
$this->storeOpeningBalance($account, $data);
|
||||
} catch (FireflyException $e) {
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
}
|
||||
|
||||
// create credit liability data (only liabilities)
|
||||
try {
|
||||
$this->storeCreditLiability($account, $data);
|
||||
} catch (FireflyException $e) {
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
}
|
||||
|
||||
// create notes
|
||||
@@ -319,22 +321,22 @@ class AccountFactory
|
||||
*/
|
||||
private function storeCreditLiability(Account $account, array $data): void
|
||||
{
|
||||
app('log')->debug('storeCreditLiability');
|
||||
Log::debug('storeCreditLiability');
|
||||
$account->refresh();
|
||||
$accountType = $account->accountType->type;
|
||||
$direction = $this->accountRepository->getMetaValue($account, 'liability_direction');
|
||||
$valid = config('firefly.valid_liabilities');
|
||||
if (in_array($accountType, $valid, true)) {
|
||||
app('log')->debug('Is a liability with credit ("i am owed") direction.');
|
||||
Log::debug('Is a liability with credit ("i am owed") direction.');
|
||||
if ($this->validOBData($data)) {
|
||||
app('log')->debug('Has valid CL data.');
|
||||
Log::debug('Has valid CL data.');
|
||||
$openingBalance = $data['opening_balance'];
|
||||
$openingBalanceDate = $data['opening_balance_date'];
|
||||
// store credit transaction.
|
||||
$this->updateCreditTransaction($account, $direction, $openingBalance, $openingBalanceDate);
|
||||
}
|
||||
if (!$this->validOBData($data)) {
|
||||
app('log')->debug('Does NOT have valid CL data, deletr any CL transaction.');
|
||||
Log::debug('Does NOT have valid CL data, deletr any CL transaction.');
|
||||
$this->deleteCreditTransaction($account);
|
||||
}
|
||||
}
|
||||
|
@@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Casts\SeparateTimezoneCaster;
|
||||
use FireflyIII\Handlers\Observer\BudgetLimitObserver;
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
@@ -33,6 +34,13 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* Class BudgetLimit
|
||||
*
|
||||
* @property TransactionCurrency $transactionCurrency
|
||||
* @property Carbon $start_date
|
||||
* @property Carbon $end_date
|
||||
*/
|
||||
#[ObservedBy([BudgetLimitObserver::class])]
|
||||
class BudgetLimit extends Model
|
||||
{
|
||||
@@ -50,10 +58,9 @@ class BudgetLimit extends Model
|
||||
if (auth()->check()) {
|
||||
$budgetLimitId = (int)$value;
|
||||
$budgetLimit = self::where('budget_limits.id', $budgetLimitId)
|
||||
->leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id')
|
||||
->where('budgets.user_id', auth()->user()->id)
|
||||
->first(['budget_limits.*'])
|
||||
;
|
||||
->leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id')
|
||||
->where('budgets.user_id', auth()->user()->id)
|
||||
->first(['budget_limits.*']);
|
||||
if (null !== $budgetLimit) {
|
||||
return $budgetLimit;
|
||||
}
|
||||
@@ -86,14 +93,14 @@ class BudgetLimit extends Model
|
||||
protected function amount(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn ($value) => (string)$value,
|
||||
get: static fn($value) => (string)$value,
|
||||
);
|
||||
}
|
||||
|
||||
protected function budgetId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn ($value) => (int)$value,
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -113,7 +120,7 @@ class BudgetLimit extends Model
|
||||
protected function transactionCurrencyId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn ($value) => (int)$value,
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Casts\SeparateTimezoneCaster;
|
||||
use FireflyIII\Handlers\Observer\RecurrenceObserver;
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
@@ -38,6 +39,10 @@ use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* @property Carbon $first_date
|
||||
* @property Carbon|null $latest_date
|
||||
*/
|
||||
#[ObservedBy([RecurrenceObserver::class])]
|
||||
class Recurrence extends Model
|
||||
{
|
||||
|
@@ -35,6 +35,9 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* @property User $user
|
||||
*/
|
||||
#[ObservedBy([RuleObserver::class])]
|
||||
class Rule extends Model
|
||||
{
|
||||
|
@@ -35,6 +35,9 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* @property User $user
|
||||
*/
|
||||
#[ObservedBy([RuleGroupObserver::class])]
|
||||
class RuleGroup extends Model
|
||||
{
|
||||
|
@@ -32,8 +32,16 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
|
||||
/**
|
||||
* @property User $user
|
||||
* @property UserGroup $userGroup
|
||||
* @property Collection<TransactionJournal> $transactionJournals
|
||||
*/
|
||||
#[ObservedBy([TransactionGroupObserver::class])]
|
||||
class TransactionGroup extends Model
|
||||
{
|
||||
@@ -50,13 +58,13 @@ class TransactionGroup extends Model
|
||||
*/
|
||||
public static function routeBinder(string $value): self
|
||||
{
|
||||
app('log')->debug(sprintf('Now in %s("%s")', __METHOD__, $value));
|
||||
Log::debug(sprintf('Now in %s("%s")', __METHOD__, $value));
|
||||
if (auth()->check()) {
|
||||
$groupId = (int)$value;
|
||||
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
app('log')->debug(sprintf('User authenticated as %s', $user->email));
|
||||
Log::debug(sprintf('User authenticated as %s', $user->email));
|
||||
|
||||
/** @var null|TransactionGroup $group */
|
||||
$group = $user->transactionGroups()
|
||||
@@ -64,12 +72,12 @@ class TransactionGroup extends Model
|
||||
->where('transaction_groups.id', $groupId)->first(['transaction_groups.*'])
|
||||
;
|
||||
if (null !== $group) {
|
||||
app('log')->debug(sprintf('Found group #%d.', $group->id));
|
||||
Log::debug(sprintf('Found group #%d.', $group->id));
|
||||
|
||||
return $group;
|
||||
}
|
||||
}
|
||||
app('log')->debug('Found no group.');
|
||||
Log::debug('Found no group.');
|
||||
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
@@ -47,6 +47,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method EloquentBuilder|static before()
|
||||
* @method EloquentBuilder|static after()
|
||||
* @method static EloquentBuilder|static query()
|
||||
* @property TransactionGroup $transactionGroup
|
||||
*/
|
||||
#[ObservedBy([TransactionJournalObserver::class])]
|
||||
class TransactionJournal extends Model
|
||||
|
@@ -442,8 +442,6 @@ class Navigation
|
||||
Log::error(sprintf('No date formats for frequency "%s"!', $repeatFrequency));
|
||||
|
||||
throw new FireflyException(sprintf('No date formats for frequency "%s"!', $repeatFrequency));
|
||||
|
||||
return $date->format('Y-m-d');
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user