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

@@ -43,7 +43,7 @@ class UpdateRequest implements UpdateRequestInterface
*/
public function getUpdateInformation(string $channel): array
{
Log::debug(sprintf('Now in getUpdateInformation(%s)', $channel));
app('log')->debug(sprintf('Now in getUpdateInformation(%s)', $channel));
$information = [
'level' => 'error',
'message' => (string)trans('firefly.unknown_error'),
@@ -70,7 +70,7 @@ class UpdateRequest implements UpdateRequestInterface
*/
private function contactServer(string $channel): array
{
Log::debug(sprintf('Now in contactServer(%s)', $channel));
app('log')->debug(sprintf('Now in contactServer(%s)', $channel));
// always fall back to current version:
$return = [
'version' => config('firefly.version'),
@@ -80,7 +80,7 @@ class UpdateRequest implements UpdateRequestInterface
];
$url = config('firefly.update_endpoint');
Log::debug(sprintf('Going to call %s', $url));
app('log')->debug(sprintf('Going to call %s', $url));
try {
$client = new Client();
$options = [
@@ -140,7 +140,7 @@ class UpdateRequest implements UpdateRequestInterface
*/
private function parseResult(array $information): array
{
Log::debug('Now in parseResult()', $information);
app('log')->debug('Now in parseResult()', $information);
$return = [
'level' => 'error',
'message' => (string)trans('firefly.unknown_error'),
@@ -155,13 +155,13 @@ class UpdateRequest implements UpdateRequestInterface
$compare = version_compare($latest, $current);
Log::debug(sprintf('Current version is "%s", latest is "%s", result is: %d', $current, $latest, $compare));
app('log')->debug(sprintf('Current version is "%s", latest is "%s", result is: %d', $current, $latest, $compare));
// -1: you're running a newer version:
if (-1 === $compare) {
$return['level'] = 'info';
$return['message'] = (string)trans('firefly.update_newer_version_alert', ['your_version' => $current, 'new_version' => $latest]);
Log::debug('User is running a newer version', $return);
app('log')->debug('User is running a newer version', $return);
return $return;
}
@@ -169,7 +169,7 @@ class UpdateRequest implements UpdateRequestInterface
if (0 === $compare) {
$return['level'] = 'info';
$return['message'] = (string)trans('firefly.update_current_version_alert', ['version' => $current]);
Log::debug('User is the current version.', $return);
app('log')->debug('User is the current version.', $return);
return $return;
}
@@ -191,7 +191,7 @@ class UpdateRequest implements UpdateRequestInterface
'days' => $expectedDiff,
]
);
Log::debug('Release is very fresh.', $return);
app('log')->debug('Release is very fresh.', $return);
return $return;
}
@@ -206,22 +206,22 @@ class UpdateRequest implements UpdateRequestInterface
'date' => $released->isoFormat((string)trans('config.month_and_day_js')),
]
);
Log::debug('New release is old enough.');
app('log')->debug('New release is old enough.');
// add warning in case of alpha or beta:
// append warning if beta or alpha.
$isBeta = $information['is_beta'] ?? false;
if (true === $isBeta) {
$return['message'] = sprintf('%s %s', $return['message'], trans('firefly.update_version_beta'));
Log::debug('New release is also a beta!');
app('log')->debug('New release is also a beta!');
}
$isAlpha = $information['is_alpha'] ?? false;
if (true === $isAlpha) {
$return['message'] = sprintf('%s %s', $return['message'], trans('firefly.update_version_alpha'));
Log::debug('New release is also a alpha!');
app('log')->debug('New release is also a alpha!');
}
Log::debug('New release is here!', $return);
app('log')->debug('New release is here!', $return);
// send event, this may result in a notification.
event(new NewVersionAvailable($return['message']));

View File

@@ -75,7 +75,7 @@ class AccountDestroyService
*/
private function destroyOpeningBalance(Account $account): void
{
Log::debug(sprintf('Searching for opening balance for account #%d "%s"', $account->id, $account->name));
app('log')->debug(sprintf('Searching for opening balance for account #%d "%s"', $account->id, $account->name));
$set = $account->transactions()
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
@@ -83,7 +83,7 @@ class AccountDestroyService
->get(['transactions.transaction_journal_id']);
if ($set->count() > 0) {
$journalId = (int)$set->first()->transaction_journal_id;
Log::debug(sprintf('Found opening balance journal with ID #%d', $journalId));
app('log')->debug(sprintf('Found opening balance journal with ID #%d', $journalId));
// get transactions with this journal (should be just one):
$transactions = Transaction::where('transaction_journal_id', $journalId)
@@ -91,9 +91,9 @@ class AccountDestroyService
->get();
/** @var Transaction $transaction */
foreach ($transactions as $transaction) {
Log::debug(sprintf('Found transaction with ID #%d', $transaction->id));
app('log')->debug(sprintf('Found transaction with ID #%d', $transaction->id));
$ibAccount = $transaction->account;
Log::debug(sprintf('Connected to account #%d "%s"', $ibAccount->id, $ibAccount->name));
app('log')->debug(sprintf('Connected to account #%d "%s"', $ibAccount->id, $ibAccount->name));
$ibAccount->accountMeta()->delete();
$transaction->delete();
@@ -114,7 +114,7 @@ class AccountDestroyService
*/
public function moveTransactions(Account $account, Account $moveTo): void
{
Log::debug(sprintf('Move from account #%d to #%d', $account->id, $moveTo->id));
app('log')->debug(sprintf('Move from account #%d to #%d', $account->id, $moveTo->id));
DB::table('transactions')->where('account_id', $account->id)->update(['account_id' => $moveTo->id]);
$collection = Transaction::groupBy('transaction_journal_id', 'account_id')
@@ -133,7 +133,7 @@ class AccountDestroyService
$journalId = (int)$row->transaction_journal_id;
$journal = $user->transactionJournals()->find($journalId);
if (null !== $journal) {
Log::debug(sprintf('Deleted journal #%d because it has the same source as destination.', $journal->id));
app('log')->debug(sprintf('Deleted journal #%d because it has the same source as destination.', $journal->id));
$service->destroy($journal);
}
}
@@ -158,14 +158,14 @@ class AccountDestroyService
/** @var JournalDestroyService $service */
$service = app(JournalDestroyService::class);
Log::debug('Now trigger account delete response #' . $account->id);
app('log')->debug('Now trigger account delete response #' . $account->id);
/** @var Transaction $transaction */
foreach ($account->transactions()->get() as $transaction) {
Log::debug('Now at transaction #' . $transaction->id);
app('log')->debug('Now at transaction #' . $transaction->id);
/** @var TransactionJournal $journal */
$journal = $transaction->transactionJournal()->first();
if (null !== $journal) {
Log::debug('Call for deletion of journal #' . $journal->id);
app('log')->debug('Call for deletion of journal #' . $journal->id);
$service->destroy($journal);
}
}

View File

@@ -41,17 +41,17 @@ class JournalDestroyService
*/
public function destroy(TransactionJournal $journal): void
{
Log::debug(sprintf('Now in %s', __METHOD__));
app('log')->debug(sprintf('Now in %s', __METHOD__));
/** @var Transaction $transaction */
foreach ($journal->transactions()->get() as $transaction) {
Log::debug(sprintf('Will now delete transaction #%d', $transaction->id));
app('log')->debug(sprintf('Will now delete transaction #%d', $transaction->id));
$transaction->delete();
}
// also delete journal_meta entries.
/** @var TransactionJournalMeta $meta */
foreach ($journal->transactionJournalMeta()->get() as $meta) {
Log::debug(sprintf('Will now delete meta-entry #%d', $meta->id));
app('log')->debug(sprintf('Will now delete meta-entry #%d', $meta->id));
$meta->delete();
}

View File

@@ -39,7 +39,7 @@ class TransactionGroupDestroyService
*/
public function destroy(TransactionGroup $transactionGroup): void
{
Log::debug(sprintf('Now in %s', __METHOD__));
app('log')->debug(sprintf('Now in %s', __METHOD__));
/** @var JournalDestroyService $service */
$service = app(JournalDestroyService::class);
foreach ($transactionGroup->transactionJournals as $journal) {

View File

@@ -204,11 +204,11 @@ trait AccountServiceTrait
}
if ('' !== $data['opening_balance'] && array_key_exists('opening_balance_date', $data) && '' !== $data['opening_balance_date']
&& $data['opening_balance_date'] instanceof Carbon) {
Log::debug('Array has valid opening balance data.');
app('log')->debug('Array has valid opening balance data.');
return true;
}
Log::debug('Array does not have valid opening balance data.');
app('log')->debug('Array does not have valid opening balance data.');
return false;
}
@@ -224,7 +224,7 @@ trait AccountServiceTrait
*/
protected function createOBGroup(Account $account, array $data): TransactionGroup
{
Log::debug('Now going to create an OB group.');
app('log')->debug('Now going to create an OB group.');
$language = app('preferences')->getForUser($account->user, 'language', 'en_US')->data;
$sourceId = null;
$sourceName = null;
@@ -234,19 +234,19 @@ trait AccountServiceTrait
// amount is positive.
if (1 === bccomp($amount, '0')) {
Log::debug(sprintf('Amount is %s, which is positive. Source is a new IB account, destination is #%d', $amount, $account->id));
app('log')->debug(sprintf('Amount is %s, which is positive. Source is a new IB account, destination is #%d', $amount, $account->id));
$sourceName = trans('firefly.initial_balance_description', ['account' => $account->name], $language);
$destId = $account->id;
}
// amount is not positive
if (-1 === bccomp($amount, '0')) {
Log::debug(sprintf('Amount is %s, which is negative. Destination is a new IB account, source is #%d', $amount, $account->id));
app('log')->debug(sprintf('Amount is %s, which is negative. Destination is a new IB account, source is #%d', $amount, $account->id));
$destName = trans('firefly.initial_balance_account', ['account' => $account->name], $language);
$sourceId = $account->id;
}
// amount is 0
if (0 === bccomp($amount, '0')) {
Log::debug('Amount is zero, so will not make an OB group.');
app('log')->debug('Amount is zero, so will not make an OB group.');
throw new FireflyException('Amount for new opening balance was unexpectedly 0.');
}
@@ -289,7 +289,7 @@ trait AccountServiceTrait
],
],
];
Log::debug('Going for submission in createOBGroup', $submission);
app('log')->debug('Going for submission in createOBGroup', $submission);
/** @var TransactionGroupFactory $factory */
$factory = app(TransactionGroupFactory::class);
@@ -313,11 +313,11 @@ trait AccountServiceTrait
*/
protected function deleteCreditTransaction(Account $account): void
{
Log::debug(sprintf('deleteCreditTransaction() for account #%d', $account->id));
app('log')->debug(sprintf('deleteCreditTransaction() for account #%d', $account->id));
$creditGroup = $this->getCreditTransaction($account);
if (null !== $creditGroup) {
Log::debug('Credit journal found, delete journal.');
app('log')->debug('Credit journal found, delete journal.');
/** @var TransactionGroupDestroyService $service */
$service = app(TransactionGroupDestroyService::class);
$service->destroy($creditGroup);
@@ -333,7 +333,7 @@ trait AccountServiceTrait
*/
protected function getCreditTransaction(Account $account): ?TransactionGroup
{
Log::debug(sprintf('Now at %s', __METHOD__));
app('log')->debug(sprintf('Now at %s', __METHOD__));
return $this->accountRepository->getCreditTransactionGroup($account);
}
@@ -345,12 +345,12 @@ trait AccountServiceTrait
*/
protected function deleteOBGroup(Account $account): void
{
Log::debug(sprintf('deleteOB() for account #%d', $account->id));
app('log')->debug(sprintf('deleteOB() for account #%d', $account->id));
$openingBalanceGroup = $this->getOBGroup($account);
// opening balance data? update it!
if (null !== $openingBalanceGroup) {
Log::debug('Opening balance journal found, delete journal.');
app('log')->debug('Opening balance journal found, delete journal.');
/** @var TransactionGroupDestroyService $service */
$service = app(TransactionGroupDestroyService::class);
$service->destroy($openingBalanceGroup);
@@ -410,10 +410,10 @@ trait AccountServiceTrait
*/
protected function updateCreditTransaction(Account $account, string $direction, string $openingBalance, Carbon $openingBalanceDate): TransactionGroup
{
Log::debug(sprintf('Now in %s', __METHOD__));
app('log')->debug(sprintf('Now in %s', __METHOD__));
if (0 === bccomp($openingBalance, '0')) {
Log::debug('Amount is zero, so will not update liability credit/debit group.');
app('log')->debug('Amount is zero, so will not update liability credit/debit group.');
throw new FireflyException('Amount for update liability credit/debit was unexpectedly 0.');
}
// if direction is "debit" (i owe this debt), amount is negative.
@@ -471,10 +471,10 @@ trait AccountServiceTrait
*/
protected function createCreditTransaction(Account $account, string $openingBalance, Carbon $openingBalanceDate): TransactionGroup
{
Log::debug('Now going to create an createCreditTransaction.');
app('log')->debug('Now going to create an createCreditTransaction.');
if (0 === bccomp($openingBalance, '0')) {
Log::debug('Amount is zero, so will not make an liability credit group.');
app('log')->debug('Amount is zero, so will not make an liability credit group.');
throw new FireflyException('Amount for new liability credit was unexpectedly 0.');
}
@@ -534,7 +534,7 @@ trait AccountServiceTrait
],
],
];
Log::debug('Going for submission in createCreditTransaction', $submission);
app('log')->debug('Going for submission in createCreditTransaction', $submission);
/** @var TransactionGroupFactory $factory */
$factory = app(TransactionGroupFactory::class);
@@ -622,13 +622,13 @@ trait AccountServiceTrait
*/
protected function updateOBGroupV2(Account $account, string $openingBalance, Carbon $openingBalanceDate): TransactionGroup
{
Log::debug(sprintf('Now in %s', __METHOD__));
app('log')->debug(sprintf('Now in %s', __METHOD__));
// create if not exists:
$obGroup = $this->getOBGroup($account);
if (null === $obGroup) {
return $this->createOBGroupV2($account, $openingBalance, $openingBalanceDate);
}
Log::debug('Update OB group');
app('log')->debug('Update OB group');
// if exists, update:
$currency = $this->accountRepository->getAccountCurrency($account);
@@ -646,7 +646,7 @@ trait AccountServiceTrait
// if amount is negative:
if (1 === bccomp('0', $openingBalance)) {
Log::debug('Amount is negative.');
app('log')->debug('Amount is negative.');
// account transaction loses money:
$accountTransaction->amount = app('steam')->negative($openingBalance);
$accountTransaction->transaction_currency_id = $currency->id;
@@ -656,7 +656,7 @@ trait AccountServiceTrait
$obTransaction->transaction_currency_id = $currency->id;
}
if (-1 === bccomp('0', $openingBalance)) {
Log::debug('Amount is positive.');
app('log')->debug('Amount is positive.');
// account gains money:
$accountTransaction->amount = app('steam')->positive($openingBalance);
$accountTransaction->transaction_currency_id = $currency->id;
@@ -685,7 +685,7 @@ trait AccountServiceTrait
*/
protected function createOBGroupV2(Account $account, string $openingBalance, Carbon $openingBalanceDate): TransactionGroup
{
Log::debug('Now going to create an OB group.');
app('log')->debug('Now going to create an OB group.');
$language = app('preferences')->getForUser($account->user, 'language', 'en_US')->data;
$sourceId = null;
$sourceName = null;
@@ -694,19 +694,19 @@ trait AccountServiceTrait
// amount is positive.
if (1 === bccomp($openingBalance, '0')) {
Log::debug(sprintf('Amount is %s, which is positive. Source is a new IB account, destination is #%d', $openingBalance, $account->id));
app('log')->debug(sprintf('Amount is %s, which is positive. Source is a new IB account, destination is #%d', $openingBalance, $account->id));
$sourceName = trans('firefly.initial_balance_description', ['account' => $account->name], $language);
$destId = $account->id;
}
// amount is not positive
if (-1 === bccomp($openingBalance, '0')) {
Log::debug(sprintf('Amount is %s, which is negative. Destination is a new IB account, source is #%d', $openingBalance, $account->id));
app('log')->debug(sprintf('Amount is %s, which is negative. Destination is a new IB account, source is #%d', $openingBalance, $account->id));
$destName = trans('firefly.initial_balance_account', ['account' => $account->name], $language);
$sourceId = $account->id;
}
// amount is 0
if (0 === bccomp($openingBalance, '0')) {
Log::debug('Amount is zero, so will not make an OB group.');
app('log')->debug('Amount is zero, so will not make an OB group.');
throw new FireflyException('Amount for new opening balance was unexpectedly 0.');
}
@@ -749,7 +749,7 @@ trait AccountServiceTrait
],
],
];
Log::debug('Going for submission in createOBGroupV2', $submission);
app('log')->debug('Going for submission in createOBGroupV2', $submission);
/** @var TransactionGroupFactory $factory */
$factory = app(TransactionGroupFactory::class);

View File

@@ -52,7 +52,7 @@ trait BillServiceTrait
/** @var RuleAction $ruleAction */
foreach ($set as $ruleAction) {
Log::debug(sprintf('Updated rule action #%d to search for new bill name "%s"', $ruleAction->id, $newName));
app('log')->debug(sprintf('Updated rule action #%d to search for new bill name "%s"', $ruleAction->id, $newName));
$ruleAction->action_value = $newName;
$ruleAction->save();
}

View File

@@ -59,7 +59,7 @@ trait JournalServiceTrait
protected function getAccount(string $transactionType, string $direction, array $data): ?Account
{
// some debug logging:
Log::debug(sprintf('Now in getAccount(%s)', $direction), $data);
app('log')->debug(sprintf('Now in getAccount(%s)', $direction), $data);
// expected type of source account, in order of preference
/** @var array $array */
@@ -69,7 +69,7 @@ trait JournalServiceTrait
// and now try to find it, based on the type of transaction.
$message = 'Transaction = %s, %s account should be in: %s. Direction is %s.';
Log::debug(sprintf($message, $transactionType, $direction, implode(', ', $expectedTypes[$transactionType] ?? ['UNKNOWN']), $direction));
app('log')->debug(sprintf($message, $transactionType, $direction, implode(', ', $expectedTypes[$transactionType] ?? ['UNKNOWN']), $direction));
$result = $this->findAccountById($data, $expectedTypes[$transactionType]);
$result = $this->findAccountByIban($result, $data, $expectedTypes[$transactionType]);
@@ -83,7 +83,7 @@ trait JournalServiceTrait
// this account. In such a case, the name search must be retried with a new name.
if (null !== $nameResult && null === $numberResult && null === $ibanResult && '' !== (string)$data['iban'] && '' !== (string)$nameResult->iban) {
$data['name'] = sprintf('%s (%s)', $data['name'], $data['iban']);
Log::debug(sprintf('Search again using the new name, "%s".', $data['name']));
app('log')->debug(sprintf('Search again using the new name, "%s".', $data['name']));
$result = $this->findAccountByName(null, $data, $expectedTypes[$transactionType]);
}
@@ -94,7 +94,7 @@ trait JournalServiceTrait
// if the result is NULL but the ID is set, an account could exist of the wrong type.
// that data can be used to create a new account of the right type.
if (null === $result && null !== $data['id'] && null !== $creatableType) {
Log::debug(sprintf('Account #%d may exist and be of the wrong type, use data to create one of the right type.', $data['id']));
app('log')->debug(sprintf('Account #%d may exist and be of the wrong type, use data to create one of the right type.', $data['id']));
$temp = $this->findAccountById(['id' => $data['id']], []);
if (null !== $temp) {
$tempData = [
@@ -107,11 +107,11 @@ trait JournalServiceTrait
}
}
if (null === $result && null !== $creatableType) {
Log::debug('If nothing is found, create it.');
app('log')->debug('If nothing is found, create it.');
$result = $this->createAccount($result, $data, $creatableType);
}
if (null === $result) {
Log::debug('If cant be created, return cash account.');
app('log')->debug('If cant be created, return cash account.');
$result = $this->getCashAccount($result, $data, $expectedTypes[$transactionType]);
}
return $result;
@@ -129,19 +129,19 @@ trait JournalServiceTrait
if (null !== $data['id']) {
$search = $this->accountRepository->find((int)$data['id']);
if (null !== $search && in_array($search->accountType->type, $types, true)) {
Log::debug(
app('log')->debug(
sprintf('Found "account_id" object: #%d, "%s" of type %s (1)', $search->id, $search->name, $search->accountType->type)
);
return $search;
}
if (null !== $search && 0 === count($types)) {
Log::debug(
app('log')->debug(
sprintf('Found "account_id" object: #%d, "%s" of type %s (2)', $search->id, $search->name, $search->accountType->type)
);
return $search;
}
}
Log::debug(sprintf('Found no account by ID #%d of types', $data['id']), $types);
app('log')->debug(sprintf('Found no account by ID #%d of types', $data['id']), $types);
return null;
}
@@ -155,11 +155,11 @@ trait JournalServiceTrait
private function findAccountByIban(?Account $account, array $data, array $types): ?Account
{
if (null !== $account) {
Log::debug(sprintf('Already have account #%d ("%s"), return that.', $account->id, $account->name));
app('log')->debug(sprintf('Already have account #%d ("%s"), return that.', $account->id, $account->name));
return $account;
}
if (null === $data['iban'] || '' === $data['iban']) {
Log::debug('IBAN is empty, will not search for IBAN.');
app('log')->debug('IBAN is empty, will not search for IBAN.');
return null;
}
// find by preferred type.
@@ -168,11 +168,11 @@ trait JournalServiceTrait
$source = $source ?? $this->accountRepository->findByIbanNull($data['iban'], $types);
if (null !== $source) {
Log::debug(sprintf('Found "account_iban" object: #%d, %s', $source->id, $source->name));
app('log')->debug(sprintf('Found "account_iban" object: #%d, %s', $source->id, $source->name));
return $source;
}
Log::debug(sprintf('Found no account with IBAN "%s" of expected types', $data['iban']), $types);
app('log')->debug(sprintf('Found no account with IBAN "%s" of expected types', $data['iban']), $types);
return null;
}
@@ -186,11 +186,11 @@ trait JournalServiceTrait
private function findAccountByNumber(?Account $account, array $data, array $types): ?Account
{
if (null !== $account) {
Log::debug(sprintf('Already have account #%d ("%s"), return that.', $account->id, $account->name));
app('log')->debug(sprintf('Already have account #%d ("%s"), return that.', $account->id, $account->name));
return $account;
}
if (null === $data['number'] || '' === $data['number']) {
Log::debug('Account number is empty, will not search for account number.');
app('log')->debug('Account number is empty, will not search for account number.');
return null;
}
// find by preferred type.
@@ -200,12 +200,12 @@ trait JournalServiceTrait
$source = $source ?? $this->accountRepository->findByAccountNumber((string)$data['number'], $types);
if (null !== $source) {
Log::debug(sprintf('Found account: #%d, %s', $source->id, $source->name));
app('log')->debug(sprintf('Found account: #%d, %s', $source->id, $source->name));
return $source;
}
Log::debug(sprintf('Found no account with account number "%s" of expected types', $data['number']), $types);
app('log')->debug(sprintf('Found no account with account number "%s" of expected types', $data['number']), $types);
return null;
}
@@ -219,11 +219,11 @@ trait JournalServiceTrait
private function findAccountByName(?Account $account, array $data, array $types): ?Account
{
if (null !== $account) {
Log::debug(sprintf('Already have account #%d ("%s"), return that.', $account->id, $account->name));
app('log')->debug(sprintf('Already have account #%d ("%s"), return that.', $account->id, $account->name));
return $account;
}
if (null === $data['name'] || '' === $data['name']) {
Log::debug('Account name is empty, will not search for account name.');
app('log')->debug('Account name is empty, will not search for account name.');
return null;
}
@@ -234,11 +234,11 @@ trait JournalServiceTrait
$source = $source ?? $this->accountRepository->findByName($data['name'], $types);
if (null !== $source) {
Log::debug(sprintf('Found "account_name" object: #%d, %s', $source->id, $source->name));
app('log')->debug(sprintf('Found "account_name" object: #%d, %s', $source->id, $source->name));
return $source;
}
Log::debug(sprintf('Found no account with account name "%s" of expected types', $data['name']), $types);
app('log')->debug(sprintf('Found no account with account name "%s" of expected types', $data['name']), $types);
return null;
}
@@ -271,10 +271,10 @@ trait JournalServiceTrait
*/
private function createAccount(?Account $account, array $data, string $preferredType): ?Account
{
Log::debug('Now in createAccount()', $data);
app('log')->debug('Now in createAccount()', $data);
// return new account.
if (null !== $account) {
Log::debug(
app('log')->debug(
sprintf(
'Was given %s account #%d ("%s") so will simply return that.',
$account->accountType->type,
@@ -290,17 +290,17 @@ trait JournalServiceTrait
}
// fix name of account if only IBAN is given:
if ('' === (string)$data['name'] && '' !== (string)$data['iban']) {
Log::debug(sprintf('Account name is now IBAN ("%s")', $data['iban']));
app('log')->debug(sprintf('Account name is now IBAN ("%s")', $data['iban']));
$data['name'] = $data['iban'];
}
// fix name of account if only number is given:
if ('' === (string)$data['name'] && '' !== (string)$data['number']) {
Log::debug(sprintf('Account name is now account number ("%s")', $data['number']));
app('log')->debug(sprintf('Account name is now account number ("%s")', $data['number']));
$data['name'] = $data['number'];
}
// if name is still NULL, return NULL.
if ('' === (string)$data['name']) {
Log::debug('Account name is still NULL, return NULL.');
app('log')->debug('Account name is still NULL, return NULL.');
return null;
}
//$data['name'] = $data['name'] ?? '(no name)';
@@ -348,7 +348,7 @@ trait JournalServiceTrait
&& in_array(AccountType::CASH, $types, true)) {
$account = $this->accountRepository->getCashAccount();
}
Log::debug('Cannot return cash account, return input instead.');
app('log')->debug('Cannot return cash account, return input instead.');
return $account;
}
@@ -363,7 +363,7 @@ trait JournalServiceTrait
if ('' === $amount) {
throw new FireflyException(sprintf('The amount cannot be an empty string: "%s"', $amount));
}
Log::debug(sprintf('Now in getAmount("%s")', $amount));
app('log')->debug(sprintf('Now in getAmount("%s")', $amount));
if (0 === bccomp('0', $amount)) {
throw new FireflyException(sprintf('The amount seems to be zero: "%s"', $amount));
}
@@ -379,21 +379,21 @@ trait JournalServiceTrait
protected function getForeignAmount(?string $amount): ?string
{
if (null === $amount) {
Log::debug('No foreign amount info in array. Return NULL');
app('log')->debug('No foreign amount info in array. Return NULL');
return null;
}
if ('' === $amount) {
Log::debug('Foreign amount is empty string, return NULL.');
app('log')->debug('Foreign amount is empty string, return NULL.');
return null;
}
if (0 === bccomp('0', $amount)) {
Log::debug('Foreign amount is 0.0, return NULL.');
app('log')->debug('Foreign amount is 0.0, return NULL.');
return null;
}
Log::debug(sprintf('Foreign amount is %s', $amount));
app('log')->debug(sprintf('Foreign amount is %s', $amount));
return $amount;
}
@@ -413,7 +413,7 @@ trait JournalServiceTrait
}
$budget = $this->budgetRepository->findBudget($data['budget_id'], $data['budget_name']);
if (null !== $budget) {
Log::debug(sprintf('Link budget #%d to journal #%d', $budget->id, $journal->id));
app('log')->debug(sprintf('Link budget #%d to journal #%d', $budget->id, $journal->id));
$journal->budgets()->sync([$budget->id]);
return;
@@ -432,7 +432,7 @@ trait JournalServiceTrait
{
$category = $this->categoryRepository->findCategory($data['category_id'], $data['category_name']);
if (null !== $category) {
Log::debug(sprintf('Link category #%d to journal #%d', $category->id, $journal->id));
app('log')->debug(sprintf('Link category #%d to journal #%d', $category->id, $journal->id));
$journal->categories()->sync([$category->id]);
return;
@@ -458,7 +458,7 @@ trait JournalServiceTrait
}
$note->text = $notes;
$note->save();
Log::debug(sprintf('Stored notes for journal #%d', $journal->id));
app('log')->debug(sprintf('Stored notes for journal #%d', $journal->id));
return;
}
@@ -478,18 +478,18 @@ trait JournalServiceTrait
*/
protected function storeTags(TransactionJournal $journal, ?array $tags): void
{
Log::debug('Now in storeTags()', $tags ?? []);
app('log')->debug('Now in storeTags()', $tags ?? []);
$this->tagFactory->setUser($journal->user);
$set = [];
if (!is_array($tags)) {
Log::debug('Tags is not an array, break.');
app('log')->debug('Tags is not an array, break.');
return;
}
Log::debug('Start of loop.');
app('log')->debug('Start of loop.');
foreach ($tags as $string) {
$string = (string)$string;
Log::debug(sprintf('Now at tag "%s"', $string));
app('log')->debug(sprintf('Now at tag "%s"', $string));
if ('' !== $string) {
$tag = $this->tagFactory->findOrCreate($string);
if (null !== $tag) {
@@ -498,8 +498,8 @@ trait JournalServiceTrait
}
}
$set = array_unique($set);
Log::debug('End of loop.');
Log::debug(sprintf('Total nr. of tags: %d', count($tags)), $tags);
app('log')->debug('End of loop.');
app('log')->debug(sprintf('Total nr. of tags: %d', count($tags)), $tags);
$journal->tags()->sync($set);
}
}

View File

@@ -107,9 +107,9 @@ trait RecurringTransactionTrait
*/
protected function createTransactions(Recurrence $recurrence, array $transactions): void
{
Log::debug('Now in createTransactions()');
app('log')->debug('Now in createTransactions()');
foreach ($transactions as $index => $array) {
Log::debug(sprintf('Now at transaction #%d', $index));
app('log')->debug(sprintf('Now at transaction #%d', $index));
$sourceTypes = config(sprintf('firefly.expected_source_types.source.%s', $recurrence->transactionType->type));
$destTypes = config(sprintf('firefly.expected_source_types.destination.%s', $recurrence->transactionType->type));
$source = $this->findAccount($sourceTypes, $array['source_id'], null);
@@ -123,7 +123,7 @@ trait RecurringTransactionTrait
$currency = app('amount')->getDefaultCurrencyByUser($recurrence->user);
}
Log::debug(
app('log')->debug(
sprintf('Will set the validator type to %s based on the type of the recurrence (#%d).', $recurrence->transactionType->type, $recurrence->id)
);
@@ -366,7 +366,7 @@ trait RecurringTransactionTrait
*/
protected function deleteTransactions(Recurrence $recurrence): void
{
Log::debug('deleteTransactions()');
app('log')->debug('deleteTransactions()');
/** @var RecurrenceTransaction $transaction */
foreach ($recurrence->recurrenceTransactions as $transaction) {
$transaction->recurrenceTransactionMeta()->delete();

View File

@@ -75,7 +75,7 @@ class AccountUpdateService
*/
public function update(Account $account, array $data): Account
{
Log::debug(sprintf('Now in %s', __METHOD__));
app('log')->debug(sprintf('Now in %s', __METHOD__));
$this->accountRepository->setUser($account->user);
$this->user = $account->user;
$account = $this->updateAccount($account, $data);
@@ -198,21 +198,21 @@ class AccountUpdateService
{
// skip if no order info
if (!array_key_exists('order', $data) || $data['order'] === $account->order) {
Log::debug(sprintf('Account order will not be touched because its not set or already at %d.', $account->order));
app('log')->debug(sprintf('Account order will not be touched because its not set or already at %d.', $account->order));
return $account;
}
// skip if not of orderable type.
$type = $account->accountType->type;
if (!in_array($type, [AccountType::ASSET, AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT], true)) {
Log::debug('Will not change order of this account.');
app('log')->debug('Will not change order of this account.');
return $account;
}
// get account type ID's because a join and an update is hard:
$oldOrder = (int)$account->order;
$newOrder = $data['order'];
Log::debug(sprintf('Order is set to be updated from %s to %s', $oldOrder, $newOrder));
app('log')->debug(sprintf('Order is set to be updated from %s to %s', $oldOrder, $newOrder));
$list = $this->getTypeIds([AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT]);
if ($type === AccountType::ASSET) {
$list = $this->getTypeIds([AccountType::ASSET]);
@@ -224,7 +224,7 @@ class AccountUpdateService
->whereIn('accounts.account_type_id', $list)
->decrement('order');
$account->order = $newOrder;
Log::debug(sprintf('Order of account #%d ("%s") is now %d', $account->id, $account->name, $newOrder));
app('log')->debug(sprintf('Order of account #%d ("%s") is now %d', $account->id, $account->name, $newOrder));
$account->save();
return $account;
@@ -235,7 +235,7 @@ class AccountUpdateService
->whereIn('accounts.account_type_id', $list)
->increment('order');
$account->order = $newOrder;
Log::debug(sprintf('Order of account #%d ("%s") is now %d', $account->id, $account->name, $newOrder));
app('log')->debug(sprintf('Order of account #%d ("%s") is now %d', $account->id, $account->name, $newOrder));
$account->save();
return $account;
@@ -341,17 +341,17 @@ class AccountUpdateService
return;
}
$array = $preference->data;
Log::debug('Old array is: ', $array);
Log::debug(sprintf('Must remove : %d', $account->id));
app('log')->debug('Old array is: ', $array);
app('log')->debug(sprintf('Must remove : %d', $account->id));
$removeAccountId = (int)$account->id;
$new = [];
foreach ($array as $value) {
if ((int)$value !== $removeAccountId) {
Log::debug(sprintf('Will include: %d', $value));
app('log')->debug(sprintf('Will include: %d', $value));
$new[] = (int)$value;
}
}
Log::debug('Final new array is', $new);
app('log')->debug('Final new array is', $new);
app('preferences')->setForUser($account->user, 'frontpageAccounts', $new);
}
}

View File

@@ -214,17 +214,17 @@ class BillUpdateService
*/
private function updateBillTriggers(Bill $bill, array $oldData, array $newData): void
{
Log::debug(sprintf('Now in updateBillTriggers(%d, "%s")', $bill->id, $bill->name));
app('log')->debug(sprintf('Now in updateBillTriggers(%d, "%s")', $bill->id, $bill->name));
/** @var BillRepositoryInterface $repository */
$repository = app(BillRepositoryInterface::class);
$repository->setUser($bill->user);
$rules = $repository->getRulesForBill($bill);
if (0 === $rules->count()) {
Log::debug('Found no rules.');
app('log')->debug('Found no rules.');
return;
}
Log::debug(sprintf('Found %d rules', $rules->count()));
app('log')->debug(sprintf('Found %d rules', $rules->count()));
$fields = [
'name' => 'description_contains',
'amount_min' => 'amount_more',
@@ -236,7 +236,7 @@ class BillUpdateService
continue;
}
if ($oldData[$field] === $newData[$field]) {
Log::debug(sprintf('Field %s is unchanged ("%s"), continue.', $field, $oldData[$field]));
app('log')->debug(sprintf('Field %s is unchanged ("%s"), continue.', $field, $oldData[$field]));
continue;
}
$this->updateRules($rules, $ruleTriggerKey, $oldData[$field], $newData[$field]);
@@ -255,14 +255,14 @@ class BillUpdateService
foreach ($rules as $rule) {
$trigger = $this->getRuleTrigger($rule, $key);
if (null !== $trigger && $trigger->trigger_value === $oldValue) {
Log::debug(sprintf('Updated rule trigger #%d from value "%s" to value "%s"', $trigger->id, $oldValue, $newValue));
app('log')->debug(sprintf('Updated rule trigger #%d from value "%s" to value "%s"', $trigger->id, $oldValue, $newValue));
$trigger->trigger_value = $newValue;
$trigger->save();
continue;
}
if (null !== $trigger && $trigger->trigger_value !== $oldValue && in_array($key, ['amount_more', 'amount_less'], true)
&& 0 === bccomp($trigger->trigger_value, $oldValue)) {
Log::debug(sprintf('Updated rule trigger #%d from value "%s" to value "%s"', $trigger->id, $oldValue, $newValue));
app('log')->debug(sprintf('Updated rule trigger #%d from value "%s" to value "%s"', $trigger->id, $oldValue, $newValue));
$trigger->trigger_value = $newValue;
$trigger->save();
}

View File

@@ -94,12 +94,12 @@ class CategoryUpdateService
->whereIn('rule_triggers.trigger_type', $types)
->where('rule_triggers.trigger_value', $oldName)
->get(['rule_triggers.*']);
Log::debug(sprintf('Found %d triggers to update.', $triggers->count()));
app('log')->debug(sprintf('Found %d triggers to update.', $triggers->count()));
/** @var RuleTrigger $trigger */
foreach ($triggers as $trigger) {
$trigger->trigger_value = $newName;
$trigger->save();
Log::debug(sprintf('Updated trigger %d: %s', $trigger->id, $trigger->trigger_value));
app('log')->debug(sprintf('Updated trigger %d: %s', $trigger->id, $trigger->trigger_value));
}
}
@@ -115,12 +115,12 @@ class CategoryUpdateService
->whereIn('rule_actions.action_type', $types)
->where('rule_actions.action_value', $oldName)
->get(['rule_actions.*']);
Log::debug(sprintf('Found %d actions to update.', $actions->count()));
app('log')->debug(sprintf('Found %d actions to update.', $actions->count()));
/** @var RuleAction $action */
foreach ($actions as $action) {
$action->action_value = $newName;
$action->save();
Log::debug(sprintf('Updated action %d: %s', $action->id, $action->action_value));
app('log')->debug(sprintf('Updated action %d: %s', $action->id, $action->action_value));
}
}

View File

@@ -51,13 +51,13 @@ class GroupUpdateService
*/
public function update(TransactionGroup $transactionGroup, array $data): TransactionGroup
{
Log::debug(sprintf('Now in %s', __METHOD__));
Log::debug('Now in group update service', $data);
app('log')->debug(sprintf('Now in %s', __METHOD__));
app('log')->debug('Now in group update service', $data);
/** @var array $transactions */
$transactions = $data['transactions'] ?? [];
// update group name.
if (array_key_exists('group_title', $data)) {
Log::debug(sprintf('Update transaction group #%d title.', $transactionGroup->id));
app('log')->debug(sprintf('Update transaction group #%d title.', $transactionGroup->id));
$oldTitle = $transactionGroup->title;
$transactionGroup->title = $data['group_title'];
$transactionGroup->save();
@@ -74,7 +74,7 @@ class GroupUpdateService
if (0 === count($transactions)) {
Log::debug('No transactions submitted, do nothing.');
app('log')->debug('No transactions submitted, do nothing.');
return $transactionGroup;
}
@@ -82,7 +82,7 @@ class GroupUpdateService
if (1 === count($transactions) && 1 === $transactionGroup->transactionJournals()->count()) {
/** @var TransactionJournal $first */
$first = $transactionGroup->transactionJournals()->first();
Log::debug(
app('log')->debug(
sprintf('Will now update journal #%d (only journal in group #%d)', $first->id, $transactionGroup->id)
);
$this->updateTransactionJournal($transactionGroup, $first, reset($transactions));
@@ -92,11 +92,11 @@ class GroupUpdateService
return $transactionGroup;
}
Log::debug('Going to update split group.');
app('log')->debug('Going to update split group.');
$existing = $transactionGroup->transactionJournals->pluck('id')->toArray();
$updated = $this->updateTransactions($transactionGroup, $transactions);
Log::debug('Array of updated IDs: ', $updated);
app('log')->debug('Array of updated IDs: ', $updated);
if (0 === count($updated)) {
app('log')->error('There were no transactions updated or created. Will not delete anything.');
@@ -107,7 +107,7 @@ class GroupUpdateService
}
$result = array_diff($existing, $updated);
Log::debug('Result of DIFF: ', $result);
app('log')->debug('Result of DIFF: ', $result);
if (count($result) > 0) {
/** @var string $deletedId */
foreach ($result as $deletedId) {
@@ -137,7 +137,7 @@ class GroupUpdateService
TransactionJournal $journal,
array $data
): void {
Log::debug(sprintf('Now in %s', __METHOD__));
app('log')->debug(sprintf('Now in %s', __METHOD__));
if (0 === count($data)) {
return;
}
@@ -163,7 +163,7 @@ class GroupUpdateService
*/
private function updateTransactions(TransactionGroup $transactionGroup, array $transactions): array
{
Log::debug(sprintf('Now in %s', __METHOD__));
app('log')->debug(sprintf('Now in %s', __METHOD__));
// updated or created transaction journals:
$updated = [];
/**
@@ -171,28 +171,28 @@ class GroupUpdateService
* @var array $transaction
*/
foreach ($transactions as $index => $transaction) {
Log::debug(sprintf('Now at #%d of %d', ($index + 1), count($transactions)), $transaction);
app('log')->debug(sprintf('Now at #%d of %d', ($index + 1), count($transactions)), $transaction);
$journalId = (int)($transaction['transaction_journal_id'] ?? 0);
/** @var TransactionJournal|null $journal */
$journal = $transactionGroup->transactionJournals()->find($journalId);
if (null === $journal) {
Log::debug('This entry has no existing journal: make a new split.');
app('log')->debug('This entry has no existing journal: make a new split.');
// force the transaction type on the transaction data.
// by plucking it from another journal in the group:
if (!array_key_exists('type', $transaction)) {
Log::debug('No transaction type is indicated.');
app('log')->debug('No transaction type is indicated.');
/** @var TransactionJournal|null $randomJournal */
$randomJournal = $transactionGroup->transactionJournals()->inRandomOrder()->with(
['transactionType']
)->first();
if (null !== $randomJournal) {
$transaction['type'] = $randomJournal->transactionType->type;
Log::debug(sprintf('Transaction type set to %s.', $transaction['type']));
app('log')->debug(sprintf('Transaction type set to %s.', $transaction['type']));
}
}
Log::debug('Call createTransactionJournal');
app('log')->debug('Call createTransactionJournal');
$newJournal = $this->createTransactionJournal($transactionGroup, $transaction);
Log::debug('Done calling createTransactionJournal');
app('log')->debug('Done calling createTransactionJournal');
if (null !== $newJournal) {
$updated[] = $newJournal->id;
}
@@ -201,10 +201,10 @@ class GroupUpdateService
}
}
if (null !== $journal) {
Log::debug('Call updateTransactionJournal');
app('log')->debug('Call updateTransactionJournal');
$this->updateTransactionJournal($transactionGroup, $journal, $transaction);
$updated[] = $journal->id;
Log::debug('Done calling updateTransactionJournal');
app('log')->debug('Done calling updateTransactionJournal');
}
}

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.');

View File

@@ -99,7 +99,7 @@ class RecurrenceUpdateService
// update all repetitions
if (array_key_exists('repetitions', $data)) {
Log::debug('Will update repetitions array');
app('log')->debug('Will update repetitions array');
// update each repetition or throw error yay
$this->updateRepetitions($recurrence, $data['repetitions'] ?? []);
}
@@ -148,14 +148,14 @@ class RecurrenceUpdateService
}
// user added or removed repetitions, delete all and recreate:
if ($originalCount !== count($repetitions)) {
Log::debug('Delete existing repetitions and create new ones.');
app('log')->debug('Delete existing repetitions and create new ones.');
$this->deleteRepetitions($recurrence);
$this->createRepetitions($recurrence, $repetitions);
return;
}
// loop all and try to match them:
Log::debug('Loop and find');
app('log')->debug('Loop and find');
foreach ($repetitions as $current) {
$match = $this->matchRepetition($recurrence, $current);
if (null === $match) {
@@ -186,7 +186,7 @@ class RecurrenceUpdateService
{
$originalCount = $recurrence->recurrenceRepetitions()->count();
if (1 === $originalCount) {
Log::debug('Return the first one');
app('log')->debug('Return the first one');
/** @var RecurrenceRepetition|null */
return $recurrence->recurrenceRepetitions()->first();
}
@@ -219,9 +219,9 @@ class RecurrenceUpdateService
*/
private function updateTransactions(Recurrence $recurrence, array $transactions): void
{
Log::debug('Now in updateTransactions()');
app('log')->debug('Now in updateTransactions()');
$originalCount = $recurrence->recurrenceTransactions()->count();
Log::debug(sprintf('Original count is %d', $originalCount));
app('log')->debug(sprintf('Original count is %d', $originalCount));
if (0 === count($transactions)) {
// won't drop transactions, rather avoid.
app('log')->warning('No transactions to update, too scared to continue!');
@@ -235,7 +235,7 @@ class RecurrenceUpdateService
foreach ($originalTransactions as $i => $originalTransaction) {
foreach ($transactions as $ii => $submittedTransaction) {
if (array_key_exists('id', $submittedTransaction) && (int)$originalTransaction['id'] === (int)$submittedTransaction['id']) {
Log::debug(sprintf('Match original transaction #%d with an entry in the submitted array.', $originalTransaction['id']));
app('log')->debug(sprintf('Match original transaction #%d with an entry in the submitted array.', $originalTransaction['id']));
$combinations[] = [
'original' => $originalTransaction,
'submitted' => $submittedTransaction,
@@ -250,7 +250,7 @@ class RecurrenceUpdateService
*/
if (1 === count($originalTransactions) && 1 === count($transactions)) {
$first = array_shift($originalTransactions);
Log::debug(sprintf('One left of each, link them (ID is #%d)', $first['id']));
app('log')->debug(sprintf('One left of each, link them (ID is #%d)', $first['id']));
$combinations[] = [
'original' => $first,
'submitted' => array_shift($transactions),
@@ -265,7 +265,7 @@ class RecurrenceUpdateService
}
// anything left in the original transactions array can be deleted.
foreach ($originalTransactions as $original) {
Log::debug(sprintf('Original transaction #%d is unmatched, delete it!', $original['id']));
app('log')->debug(sprintf('Original transaction #%d is unmatched, delete it!', $original['id']));
$this->deleteTransaction($recurrence, (int)$original['id']);
}
// anything left is new.
@@ -284,7 +284,7 @@ class RecurrenceUpdateService
$submitted = $combination['submitted'];
/** @var RecurrenceTransaction $transaction */
$transaction = $recurrence->recurrenceTransactions()->find($original['id']);
Log::debug(sprintf('Now in updateCombination(#%d)', $original['id']));
app('log')->debug(sprintf('Now in updateCombination(#%d)', $original['id']));
$currencyFactory = app(TransactionCurrencyFactory::class);
@@ -336,13 +336,13 @@ class RecurrenceUpdateService
// reset category if name is set but empty:
// can be removed when v1 is retired.
if (array_key_exists('category_name', $submitted) && '' === (string)$submitted['category_name']) {
Log::debug('Category name is submitted but is empty. Set category to be empty.');
app('log')->debug('Category name is submitted but is empty. Set category to be empty.');
$submitted['category_name'] = null;
$submitted['category_id'] = 0;
}
if (array_key_exists('category_id', $submitted)) {
Log::debug(sprintf('Category ID is submitted, set category to be %d.', (int)$submitted['category_id']));
app('log')->debug(sprintf('Category ID is submitted, set category to be %d.', (int)$submitted['category_id']));
$this->setCategory($transaction, (int)$submitted['category_id']);
}
@@ -362,7 +362,7 @@ class RecurrenceUpdateService
*/
private function deleteTransaction(Recurrence $recurrence, int $transactionId): void
{
Log::debug(sprintf('Will delete transaction #%d in recurrence #%d.', $transactionId, $recurrence->id));
app('log')->debug(sprintf('Will delete transaction #%d in recurrence #%d.', $transactionId, $recurrence->id));
$recurrence->recurrenceTransactions()->where('id', $transactionId)->delete();
}
}

View File

@@ -57,8 +57,8 @@ class PwndVerifierV2 implements Verifier
'timeout' => 3.1415,
];
Log::debug(sprintf('hash prefix is %s', $prefix));
Log::debug(sprintf('rest is %s', $rest));
app('log')->debug(sprintf('hash prefix is %s', $prefix));
app('log')->debug(sprintf('rest is %s', $rest));
try {
$client = new Client();
@@ -68,17 +68,17 @@ class PwndVerifierV2 implements Verifier
return true;
}
Log::debug(sprintf('Status code returned is %d', $res->getStatusCode()));
app('log')->debug(sprintf('Status code returned is %d', $res->getStatusCode()));
if (404 === $res->getStatusCode()) {
return true;
}
$strpos = stripos($res->getBody()->getContents(), $rest);
if (false === $strpos) {
Log::debug(sprintf('%s was not found in result body. Return true.', $rest));
app('log')->debug(sprintf('%s was not found in result body. Return true.', $rest));
return true;
}
Log::debug(sprintf('Found %s, return FALSE.', $rest));
app('log')->debug(sprintf('Found %s, return FALSE.', $rest));
return false;
}

View File

@@ -77,7 +77,7 @@ class StandardWebhookSender implements WebhookSenderInterface
return;
}
Log::debug(sprintf('Trying to send webhook message #%d', $this->message->id));
app('log')->debug(sprintf('Trying to send webhook message #%d', $this->message->id));
try {
$json = json_encode($this->message->message, JSON_THROW_ON_ERROR);
@@ -139,9 +139,9 @@ class StandardWebhookSender implements WebhookSenderInterface
$this->message->sent = true;
$this->message->save();
Log::debug(sprintf('Webhook message #%d was sent. Status code %d', $this->message->id, $res->getStatusCode()));
Log::debug(sprintf('Webhook request body size: %d bytes', strlen($json)));
Log::debug(sprintf('Response body: %s', $res->getBody()));
app('log')->debug(sprintf('Webhook message #%d was sent. Status code %d', $this->message->id, $res->getStatusCode()));
app('log')->debug(sprintf('Webhook request body size: %d bytes', strlen($json)));
app('log')->debug(sprintf('Response body: %s', $res->getBody()));
}
/**