Remove static references

This commit is contained in:
James Cole
2023-10-29 06:33:43 +01:00
parent 075d459b7c
commit 4f2159b54d
205 changed files with 1287 additions and 1287 deletions

View File

@@ -125,7 +125,7 @@ class AppendBudgetLimitPeriods extends Command
$limit->end_date->format('Y-m-d'),
$period
);
Log::debug($msg);
app('log')->debug($msg);
}
/**

View File

@@ -92,7 +92,7 @@ class MigrateAttachments extends Command
$att->description = '';
$att->save();
Log::debug(sprintf('Migrated attachment #%s description to note #%d.', $att->id, $note->id));
app('log')->debug(sprintf('Migrated attachment #%s description to note #%d.', $att->id, $note->id));
$count++;
}
}

View File

@@ -82,7 +82,7 @@ class MigrateJournalNotes extends Command
$note->text = $meta->data;
$note->save();
Log::debug(sprintf('Migrated meta note #%d to Note #%d', $meta->id, $note->id));
app('log')->debug(sprintf('Migrated meta note #%d to Note #%d', $meta->id, $note->id));
$meta->delete();
$count++;

View File

@@ -151,11 +151,11 @@ class MigrateToGroups extends Command
{
// double check transaction count.
if ($journal->transactions->count() <= 2) {
Log::debug(sprintf('Will not try to convert journal #%d because it has 2 or less transactions.', $journal->id));
app('log')->debug(sprintf('Will not try to convert journal #%d because it has 2 or less transactions.', $journal->id));
return;
}
Log::debug(sprintf('Will now try to convert journal #%d', $journal->id));
app('log')->debug(sprintf('Will now try to convert journal #%d', $journal->id));
$this->journalRepository->setUser($journal->user);
$this->groupFactory->setUser($journal->user);
@@ -193,11 +193,11 @@ class MigrateToGroups extends Command
$paymentDate = $this->cliRepository->getMetaDate($journal, 'payment_date');
$invoiceDate = $this->cliRepository->getMetaDate($journal, 'invoice_date');
Log::debug(sprintf('Will use %d positive transactions to create a new group.', $destTransactions->count()));
app('log')->debug(sprintf('Will use %d positive transactions to create a new group.', $destTransactions->count()));
/** @var Transaction $transaction */
foreach ($destTransactions as $transaction) {
Log::debug(sprintf('Now going to add transaction #%d to the array.', $transaction->id));
app('log')->debug(sprintf('Now going to add transaction #%d to the array.', $transaction->id));
$opposingTr = $this->findOpposingTransaction($journal, $transaction);
if (null === $opposingTr) {
@@ -256,9 +256,9 @@ class MigrateToGroups extends Command
$data['transactions'][] = $tArray;
}
Log::debug(sprintf('Now calling transaction journal factory (%d transactions in array)', count($data['transactions'])));
app('log')->debug(sprintf('Now calling transaction journal factory (%d transactions in array)', count($data['transactions'])));
$group = $this->groupFactory->create($data);
Log::debug('Done calling transaction journal factory');
app('log')->debug('Done calling transaction journal factory');
// delete the old transaction journal.
$this->service->destroy($journal);
@@ -266,7 +266,7 @@ class MigrateToGroups extends Command
$this->count++;
// report on result:
Log::debug(
app('log')->debug(
sprintf(
'Migrated journal #%d into group #%d with these journals: #%s',
$journal->id,
@@ -310,8 +310,8 @@ class MigrateToGroups extends Command
static function (Transaction $subject) use ($transaction) {
$amount = (float)$transaction->amount * -1 === (float)$subject->amount; // intentional float
$identifier = $transaction->identifier === $subject->identifier;
Log::debug(sprintf('Amount the same? %s', var_export($amount, true)));
Log::debug(sprintf('ID the same? %s', var_export($identifier, true)));
app('log')->debug(sprintf('Amount the same? %s', var_export($amount, true)));
app('log')->debug(sprintf('ID the same? %s', var_export($identifier, true)));
return $amount && $identifier;
}
@@ -328,13 +328,13 @@ class MigrateToGroups extends Command
*/
private function getTransactionBudget(Transaction $left, Transaction $right): ?int
{
Log::debug('Now in getTransactionBudget()');
app('log')->debug('Now in getTransactionBudget()');
// try to get a budget ID from the left transaction:
/** @var Budget|null $budget */
$budget = $left->budgets()->first();
if (null !== $budget) {
Log::debug(sprintf('Return budget #%d, from transaction #%d', $budget->id, $left->id));
app('log')->debug(sprintf('Return budget #%d, from transaction #%d', $budget->id, $left->id));
return (int)$budget->id;
}
@@ -343,11 +343,11 @@ class MigrateToGroups extends Command
/** @var Budget|null $budget */
$budget = $right->budgets()->first();
if (null !== $budget) {
Log::debug(sprintf('Return budget #%d, from transaction #%d', $budget->id, $right->id));
app('log')->debug(sprintf('Return budget #%d, from transaction #%d', $budget->id, $right->id));
return (int)$budget->id;
}
Log::debug('Neither left or right have a budget, return NULL');
app('log')->debug('Neither left or right have a budget, return NULL');
// if all fails, return NULL.
return null;
@@ -361,13 +361,13 @@ class MigrateToGroups extends Command
*/
private function getTransactionCategory(Transaction $left, Transaction $right): ?int
{
Log::debug('Now in getTransactionCategory()');
app('log')->debug('Now in getTransactionCategory()');
// try to get a category ID from the left transaction:
/** @var Category|null $category */
$category = $left->categories()->first();
if (null !== $category) {
Log::debug(sprintf('Return category #%d, from transaction #%d', $category->id, $left->id));
app('log')->debug(sprintf('Return category #%d, from transaction #%d', $category->id, $left->id));
return (int)$category->id;
}
@@ -376,11 +376,11 @@ class MigrateToGroups extends Command
/** @var Category|null $category */
$category = $right->categories()->first();
if (null !== $category) {
Log::debug(sprintf('Return category #%d, from transaction #%d', $category->id, $category->id));
app('log')->debug(sprintf('Return category #%d, from transaction #%d', $category->id, $category->id));
return (int)$category->id;
}
Log::debug('Neither left or right have a category, return NULL');
app('log')->debug('Neither left or right have a category, return NULL');
// if all fails, return NULL.
return null;
@@ -394,7 +394,7 @@ class MigrateToGroups extends Command
$orphanedJournals = $this->cliRepository->getJournalsWithoutGroup();
$total = count($orphanedJournals);
if ($total > 0) {
Log::debug(sprintf('Going to convert %d transaction journals. Please hold..', $total));
app('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 */
foreach ($orphanedJournals as $array) {