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

@@ -140,8 +140,8 @@ class JournalUpdateService
*/
public function update(): void
{
Log::debug(sprintf('Now in %s', __METHOD__));
Log::debug(sprintf('Now in JournalUpdateService for journal #%d.', $this->transactionJournal->id));
app('log')->debug(sprintf('Now in %s', __METHOD__));
app('log')->debug(sprintf('Now in JournalUpdateService for journal #%d.', $this->transactionJournal->id));
$this->data['reconciled'] = array_key_exists('reconciled', $this->data) ? $this->data['reconciled'] : false;
@@ -194,7 +194,7 @@ class JournalUpdateService
*/
private function hasValidSourceAccount(): bool
{
Log::debug('Now in hasValidSourceAccount().');
app('log')->debug('Now in hasValidSourceAccount().');
$sourceId = $this->data['source_id'] ?? null;
$sourceName = $this->data['source_name'] ?? null;
@@ -206,7 +206,7 @@ class JournalUpdateService
// make new account validator.
$expectedType = $this->getExpectedType();
Log::debug(sprintf('Expected type (new or unchanged) is %s', $expectedType));
app('log')->debug(sprintf('Expected type (new or unchanged) is %s', $expectedType));
// make a new validator.
/** @var AccountValidator $validator */
@@ -215,7 +215,7 @@ class JournalUpdateService
$validator->setUser($this->transactionJournal->user);
$result = $validator->validateSource(['id' => $sourceId]);
Log::debug(
app('log')->debug(
sprintf('hasValidSourceAccount(%d, "%s") will return %s', $sourceId, $sourceName, var_export($result, true))
);
@@ -266,7 +266,7 @@ class JournalUpdateService
0
)->first();
}
Log::debug(sprintf('getSourceTransaction: %s', $this->sourceTransaction->amount));
app('log')->debug(sprintf('getSourceTransaction: %s', $this->sourceTransaction->amount));
return $this->sourceTransaction;
}
@@ -282,7 +282,7 @@ class JournalUpdateService
*/
private function getExpectedType(): string
{
Log::debug('Now in getExpectedType()');
app('log')->debug('Now in getExpectedType()');
if ($this->hasFields(['type'])) {
return ucfirst('opening-balance' === $this->data['type'] ? 'opening balance' : $this->data['type']);
}
@@ -295,12 +295,12 @@ class JournalUpdateService
*/
private function hasValidDestinationAccount(): bool
{
Log::debug('Now in hasValidDestinationAccount().');
app('log')->debug('Now in hasValidDestinationAccount().');
$destId = $this->data['destination_id'] ?? null;
$destName = $this->data['destination_name'] ?? null;
if (!$this->hasFields(['destination_id', 'destination_name'])) {
Log::debug('No destination info submitted, grab the original data.');
app('log')->debug('No destination info submitted, grab the original data.');
$destination = $this->getOriginalDestinationAccount();
$destId = $destination->id;
$destName = $destination->name;
@@ -308,7 +308,7 @@ class JournalUpdateService
// make new account validator.
$expectedType = $this->getExpectedType();
Log::debug(sprintf('Expected type (new or unchanged) is %s', $expectedType));
app('log')->debug(sprintf('Expected type (new or unchanged) is %s', $expectedType));
// make a new validator.
/** @var AccountValidator $validator */
@@ -317,7 +317,7 @@ class JournalUpdateService
$validator->setUser($this->transactionJournal->user);
$validator->source = $this->getValidSourceAccount();
$result = $validator->validateDestination(['id' => $destId, 'name' => $destName]);
Log::debug(
app('log')->debug(
sprintf(
'hasValidDestinationAccount(%d, "%s") will return %s',
$destId,
@@ -366,7 +366,7 @@ class JournalUpdateService
*/
private function getValidSourceAccount(): Account
{
Log::debug('Now in getValidSourceAccount().');
app('log')->debug('Now in getValidSourceAccount().');
if (!$this->hasFields(['source_id', 'source_name'])) {
return $this->getOriginalSourceAccount();
@@ -389,7 +389,7 @@ class JournalUpdateService
$result = $this->getOriginalSourceAccount();
}
Log::debug(sprintf('getValidSourceAccount() will return #%d ("%s")', $result->id, $result->name));
app('log')->debug(sprintf('getValidSourceAccount() will return #%d ("%s")', $result->id, $result->name));
return $result;
}
@@ -420,8 +420,8 @@ class JournalUpdateService
// refresh transactions.
$this->sourceTransaction->refresh();
$this->destinationTransaction->refresh();
Log::debug(sprintf('Will set source to #%d ("%s")', $source->id, $source->name));
Log::debug(sprintf('Will set dest to #%d ("%s")', $destination->id, $destination->name));
app('log')->debug(sprintf('Will set source to #%d ("%s")', $source->id, $source->name));
app('log')->debug(sprintf('Will set dest to #%d ("%s")', $destination->id, $destination->name));
}
/**
@@ -431,7 +431,7 @@ class JournalUpdateService
*/
private function getValidDestinationAccount(): Account
{
Log::debug('Now in getValidDestinationAccount().');
app('log')->debug('Now in getValidDestinationAccount().');
if (!$this->hasFields(['destination_id', 'destination_name'])) {
return $this->getOriginalDestinationAccount();
@@ -447,7 +447,7 @@ class JournalUpdateService
// make new account validator.
$expectedType = $this->getExpectedType();
Log::debug(sprintf('Expected type (new or unchanged) is %s', $expectedType));
app('log')->debug(sprintf('Expected type (new or unchanged) is %s', $expectedType));
try {
$result = $this->getAccount($expectedType, 'destination', $destInfo);
} catch (FireflyException $e) {
@@ -463,10 +463,10 @@ class JournalUpdateService
*/
private function updateType(): void
{
Log::debug('Now in updateType()');
app('log')->debug('Now in updateType()');
if ($this->hasFields(['type'])) {
$type = 'opening-balance' === $this->data['type'] ? 'opening balance' : $this->data['type'];
Log::debug(
app('log')->debug(
sprintf(
'Trying to change journal #%d from a %s to a %s.',
$this->transactionJournal->id,
@@ -479,7 +479,7 @@ class JournalUpdateService
$typeFactory = app(TransactionTypeFactory::class);
$result = $typeFactory->find($this->data['type']);
if (null !== $result) {
Log::debug('Changed transaction type!');
app('log')->debug('Changed transaction type!');
$this->transactionJournal->transaction_type_id = $result->id;
$this->transactionJournal->save();
@@ -488,7 +488,7 @@ class JournalUpdateService
return;
}
Log::debug('No type field present.');
app('log')->debug('No type field present.');
}
/**
@@ -507,7 +507,7 @@ class JournalUpdateService
$billName = (string)($this->data['bill_name'] ?? '');
$bill = $this->billRepository->findBill($billId, $billName);
$this->transactionJournal->bill_id = $bill?->id;
Log::debug('Updated bill ID');
app('log')->debug('Updated bill ID');
}
}
@@ -530,7 +530,7 @@ class JournalUpdateService
$value = new Carbon($value);
}
// do some parsing.
Log::debug(sprintf('Create date value from string "%s".', $value));
app('log')->debug(sprintf('Create date value from string "%s".', $value));
}
event(
new TriggeredAuditLog(
@@ -543,7 +543,7 @@ class JournalUpdateService
);
$this->transactionJournal->$fieldName = $value;
Log::debug(sprintf('Updated %s', $fieldName));
app('log')->debug(sprintf('Updated %s', $fieldName));
}
}
@@ -554,7 +554,7 @@ class JournalUpdateService
{
// update category
if ($this->hasFields(['category_id', 'category_name'])) {
Log::debug('Will update category.');
app('log')->debug('Will update category.');
$this->storeCategory($this->transactionJournal, new NullArrayObject($this->data));
}
@@ -567,7 +567,7 @@ class JournalUpdateService
{
// update budget
if ($this->hasFields(['budget_id', 'budget_name'])) {
Log::debug('Will update budget.');
app('log')->debug('Will update budget.');
$this->storeBudget($this->transactionJournal, new NullArrayObject($this->data));
}
// is transfer? remove budget
@@ -582,7 +582,7 @@ class JournalUpdateService
private function updateTags(): void
{
if ($this->hasFields(['tags'])) {
Log::debug('Will update tags.');
app('log')->debug('Will update tags.');
$tags = $this->data['tags'] ?? null;
$this->storeTags($this->transactionJournal, $tags);
}
@@ -618,13 +618,13 @@ class JournalUpdateService
// update meta fields.
// first string
if ($this->hasFields($this->metaString)) {
Log::debug('Meta string fields are present.');
app('log')->debug('Meta string fields are present.');
$this->updateMetaFields();
}
// then date fields.
if ($this->hasFields($this->metaDate)) {
Log::debug('Meta date fields are present.');
app('log')->debug('Meta date fields are present.');
$this->updateMetaDateFields();
}
}
@@ -640,7 +640,7 @@ class JournalUpdateService
foreach ($this->metaString as $field) {
if ($this->hasFields([$field])) {
$value = '' === $this->data[$field] ? null : $this->data[$field];
Log::debug(sprintf('Field "%s" is present ("%s"), try to update it.', $field, $value));
app('log')->debug(sprintf('Field "%s" is present ("%s"), try to update it.', $field, $value));
$set = [
'journal' => $this->transactionJournal,
'name' => $field,
@@ -664,11 +664,11 @@ class JournalUpdateService
try {
$value = '' === (string)$this->data[$field] ? null : new Carbon($this->data[$field]);
} catch (InvalidDateException $e) {
Log::debug(sprintf('%s is not a valid date value: %s', $this->data[$field], $e->getMessage()));
app('log')->debug(sprintf('%s is not a valid date value: %s', $this->data[$field], $e->getMessage()));
return;
}
Log::debug(sprintf('Field "%s" is present ("%s"), try to update it.', $field, $value));
app('log')->debug(sprintf('Field "%s" is present ("%s"), try to update it.', $field, $value));
$set = [
'journal' => $this->transactionJournal,
'name' => $field,
@@ -707,7 +707,7 @@ class JournalUpdateService
// refresh transactions.
$this->sourceTransaction->refresh();
$this->destinationTransaction->refresh();
Log::debug(sprintf('Updated currency to #%d (%s)', $currency->id, $currency->code));
app('log')->debug(sprintf('Updated currency to #%d (%s)', $currency->id, $currency->code));
}
}
@@ -716,17 +716,17 @@ class JournalUpdateService
*/
private function updateAmount(): void
{
Log::debug(sprintf('Now in %s', __METHOD__));
app('log')->debug(sprintf('Now in %s', __METHOD__));
if (!$this->hasFields(['amount'])) {
return;
}
$value = $this->data['amount'] ?? '';
Log::debug(sprintf('Amount is now "%s"', $value));
app('log')->debug(sprintf('Amount is now "%s"', $value));
try {
$amount = $this->getAmount($value);
} catch (FireflyException $e) {
Log::debug(sprintf('getAmount("%s") returns error: %s', $value, $e->getMessage()));
app('log')->debug(sprintf('getAmount("%s") returns error: %s', $value, $e->getMessage()));
return;
}
@@ -739,7 +739,7 @@ class JournalUpdateService
// refresh transactions.
$this->sourceTransaction->refresh();
$this->destinationTransaction->refresh();
Log::debug(sprintf('Updated amount to "%s"', $amount));
app('log')->debug(sprintf('Updated amount to "%s"', $amount));
}
/**
@@ -780,7 +780,7 @@ class JournalUpdateService
$dest->foreign_amount = app('steam')->positive($foreignAmount);
$dest->save();
Log::debug(
app('log')->debug(
sprintf(
'Update foreign info to %s (#%d) %s',
$foreignCurrency->code,
@@ -803,7 +803,7 @@ class JournalUpdateService
$dest->foreign_currency_id = null;
$dest->foreign_amount = null;
$dest->save();
Log::debug(sprintf('Foreign amount is "%s" so remove foreign amount info.', $amount));
app('log')->debug(sprintf('Foreign amount is "%s" so remove foreign amount info.', $amount));
}
app('log')->info('Not enough info to update foreign currency info.');