diff --git a/app/Api/V1/Controllers/Chart/AccountController.php b/app/Api/V1/Controllers/Chart/AccountController.php index f3219657770..a725c7cfb77 100644 --- a/app/Api/V1/Controllers/Chart/AccountController.php +++ b/app/Api/V1/Controllers/Chart/AccountController.php @@ -81,7 +81,6 @@ public function overview(ChartRequest $request): JsonResponse // move date to end of day $queryParameters['start']->startOfDay(); $queryParameters['end']->endOfDay(); - // Log::debug(sprintf('dashboard(), convert to primary: %s', var_export($this->convertToPrimary, true))); // loop each account, and collect info: /** @var Account $account */ diff --git a/app/Api/V1/Controllers/Chart/BalanceController.php b/app/Api/V1/Controllers/Chart/BalanceController.php index d589be1661c..f8cec294bdf 100644 --- a/app/Api/V1/Controllers/Chart/BalanceController.php +++ b/app/Api/V1/Controllers/Chart/BalanceController.php @@ -31,7 +31,6 @@ class BalanceController extends Controller private GroupCollectorInterface $collector; private AccountRepositoryInterface $repository; - // private TransactionCurrency $default; public function __construct() { diff --git a/app/Api/V1/Controllers/Chart/BudgetController.php b/app/Api/V1/Controllers/Chart/BudgetController.php index 4102693d363..1f6597b36c3 100644 --- a/app/Api/V1/Controllers/Chart/BudgetController.php +++ b/app/Api/V1/Controllers/Chart/BudgetController.php @@ -248,7 +248,6 @@ private function processExpenses(int $budgetId, array $spent, Carbon $start, Car ]; $currentBudgetArray = $block['budgets'][$budgetId]; - // var_dump($return); /** @var array $journal */ foreach ($currentBudgetArray['transaction_journals'] as $journal) { $return[$currencyId]['spent'] = bcadd($return[$currencyId]['spent'], (string)$journal['amount']); diff --git a/app/Api/V1/Controllers/Controller.php b/app/Api/V1/Controllers/Controller.php index 196cca92902..1fca75ecaee 100644 --- a/app/Api/V1/Controllers/Controller.php +++ b/app/Api/V1/Controllers/Controller.php @@ -283,7 +283,6 @@ final protected function jsonApiObject(string $key, array|Model $object, Abstrac $baseUrl = sprintf('%s/api/v1', request()->getSchemeAndHttpHost()); $manager->setSerializer(new JsonApiSerializer($baseUrl)); - // $transformer->collectMetaData(new Collection([$object])); $resource = new Item($object, $transformer, $key); diff --git a/app/Api/V1/Controllers/Summary/BasicController.php b/app/Api/V1/Controllers/Summary/BasicController.php index 096ed01db77..070432af628 100644 --- a/app/Api/V1/Controllers/Summary/BasicController.php +++ b/app/Api/V1/Controllers/Summary/BasicController.php @@ -106,7 +106,6 @@ public function basic(DateRequest $request): JsonResponse $billData = $this->getSubscriptionInformation($start, $end); $spentData = $this->getLeftToSpendInfo($start, $end); $netWorthData = $this->getNetWorthInfo($end); - // $balanceData = []; // $billData = []; // $spentData = []; // $netWorthData = []; @@ -278,7 +277,7 @@ private function getBalanceInformation(Carbon $start, Carbon $end): array 'sub_title' => '', ]; } - if (0 === count($return)) { + if (empty($return)) { $currency = $this->primaryCurrency; // create objects for big array. $return[] = [ @@ -386,7 +385,6 @@ private function getSubscriptionInformation(Carbon $start, Carbon $end): array $unpaidAmount = $newUnpaidAmount; } - // var_dump($paidAmount); // var_dump($unpaidAmount); // exit; @@ -431,7 +429,7 @@ private function getSubscriptionInformation(Carbon $start, Carbon $end): array } Log::debug(sprintf('Done with getBillInformation("%s", "%s")', $start->format('Y-m-d'), $end->format('Y-m-d-'))); - if (0 === count($return)) { + if (empty($return)) { $currency = $this->primaryCurrency; unset($info, $amount); @@ -530,7 +528,7 @@ private function getLeftToSpendInfo(Carbon $start, Carbon $end): array ]; } unset($leftToSpend); - if (0 === count($return)) { + if (empty($return)) { $days = (int) $start->diffInDays($end, true) + 1; // a small trick to get every expense in this period, regardless of budget. $spent = $this->opsRepository->sumExpenses($start, $end, null, new Collection()); @@ -633,7 +631,7 @@ function (Account $account) { 'sub_title' => '', ]; } - if (0 === count($return)) { + if (empty($return)) { $return[] = [ 'key' => sprintf('net-worth-in-%s', $this->primaryCurrency->code), 'title' => trans('firefly.box_net_worth_in_currency', ['currency' => $this->primaryCurrency->symbol]), diff --git a/app/Api/V1/Requests/Chart/ChartRequest.php b/app/Api/V1/Requests/Chart/ChartRequest.php index 2ef933a1c21..55aea133ebf 100644 --- a/app/Api/V1/Requests/Chart/ChartRequest.php +++ b/app/Api/V1/Requests/Chart/ChartRequest.php @@ -76,7 +76,6 @@ static function (Validator $validator): void { // validate transaction query data. $data = $validator->getData(); if (!array_key_exists('accounts', $data)) { - // $validator->errors()->add('accounts', trans('validation.filled', ['attribute' => 'accounts'])); return; } if (!is_array($data['accounts'])) { diff --git a/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.php b/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.php index f16c5215902..4e3044686ca 100644 --- a/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.php @@ -113,7 +113,7 @@ private function getRepetitionData(): ?array } $return[] = $current; } - if (0 === count($return)) { + if (empty($return)) { return null; } @@ -195,7 +195,6 @@ public function withValidator(Validator $validator): void { $validator->after( function (Validator $validator): void { - // $this->validateOneRecurrenceTransaction($validator); // $this->validateOneRepetitionUpdate($validator); /** @var Recurrence $recurrence */ diff --git a/app/Console/Commands/Correction/CorrectsUnevenAmount.php b/app/Console/Commands/Correction/CorrectsUnevenAmount.php index 30a6107fe19..4f69ec0fad0 100644 --- a/app/Console/Commands/Correction/CorrectsUnevenAmount.php +++ b/app/Console/Commands/Correction/CorrectsUnevenAmount.php @@ -258,7 +258,6 @@ private function isForeignCurrencyTransfer(TransactionJournal $journal): bool // dest amount = source foreign currency // dest currency = source foreign currency - // Log::debug(sprintf('[a] %s', bccomp(app('steam')->positive($source->amount), app('steam')->positive($destination->foreign_amount)))); // Log::debug(sprintf('[b] %s', bccomp(app('steam')->positive($destination->amount), app('steam')->positive($source->foreign_amount)))); // Log::debug(sprintf('[c] %s', var_export($source->transaction_currency_id === $destination->foreign_currency_id,true))); // Log::debug(sprintf('[d] %s', var_export((int) $destination->transaction_currency_id ===(int) $source->foreign_currency_id, true))); @@ -406,7 +405,6 @@ private function convertOldStyleTransactions(): void $source->foreign_currency_id = $currency; $source->saveQuietly(); $source->refresh(); - // Log::debug(sprintf('source->amount = %s', $source->amount)); // Log::debug(sprintf('source->transaction_currency_id = %s', $source->transaction_currency_id)); // Log::debug(sprintf('source->foreign_amount = %s', $source->foreign_amount)); // Log::debug(sprintf('source->foreign_currency_id = %s', $source->foreign_currency_id)); @@ -426,7 +424,6 @@ private function convertOldStyleTransactions(): void $destination->balance_dirty = true; $destination->saveQuietly(); $destination->refresh(); - // Log::debug(sprintf('destination->amount = %s', $destination->amount)); // Log::debug(sprintf('destination->transaction_currency_id = %s', $destination->transaction_currency_id)); // Log::debug(sprintf('destination->foreign_amount = %s', $destination->foreign_amount)); // Log::debug(sprintf('destination->foreign_currency_id = %s', $destination->foreign_currency_id)); diff --git a/app/Console/Commands/Correction/RemovesOrphanedTransactions.php b/app/Console/Commands/Correction/RemovesOrphanedTransactions.php index f44ee5fb0d1..825301c6f39 100644 --- a/app/Console/Commands/Correction/RemovesOrphanedTransactions.php +++ b/app/Console/Commands/Correction/RemovesOrphanedTransactions.php @@ -65,7 +65,6 @@ private function deleteOrphanedJournals(): void ; $count = $set->count(); if (0 === $count) { - // $this->friendlyPositive('No orphaned journals.'); return; } diff --git a/app/Entities/AccountBalance.php b/app/Entities/AccountBalance.php index b7e62471261..fa5bda53a14 100644 --- a/app/Entities/AccountBalance.php +++ b/app/Entities/AccountBalance.php @@ -36,7 +36,6 @@ public static function fromArray(): self { $balance = new self(); $balance->id = (string) random_int(1, 1000); - // $balance->name = (string) random_int(1, 1000); $balance->amount = (string) random_int(1, 1000); $balance->currencyId = '1'; diff --git a/app/Factory/PiggyBankFactory.php b/app/Factory/PiggyBankFactory.php index 539e1999b8b..b5d24d31728 100644 --- a/app/Factory/PiggyBankFactory.php +++ b/app/Factory/PiggyBankFactory.php @@ -290,7 +290,7 @@ public function linkToAccountIds(PiggyBank $piggyBank, array $accounts): void } } Log::debug(sprintf('Link information: %s', json_encode($toBeLinked))); - if (0 !== count($toBeLinked)) { + if (!empty($toBeLinked)) { Log::debug('Syncing accounts to piggy bank.'); $piggyBank->accounts()->sync($toBeLinked); $piggyBank->refresh(); @@ -302,7 +302,7 @@ public function linkToAccountIds(PiggyBank $piggyBank, array $accounts): void event(new ChangedAmount($piggyBank, bcsub($newSavedAmount, $oldSavedAmount), null, null)); } } - if (0 === count($toBeLinked)) { + if (empty($toBeLinked)) { Log::warning('No accounts to link to piggy bank, will not change whatever is there now.'); } } diff --git a/app/Factory/TransactionJournalMetaFactory.php b/app/Factory/TransactionJournalMetaFactory.php index 56dd79d1e05..c3419db0f42 100644 --- a/app/Factory/TransactionJournalMetaFactory.php +++ b/app/Factory/TransactionJournalMetaFactory.php @@ -34,13 +34,11 @@ class TransactionJournalMetaFactory { public function updateOrCreate(array $data): ?TransactionJournalMeta { - // app('log')->debug('In updateOrCreate()'); $value = $data['data']; /** @var null|TransactionJournalMeta $entry */ $entry = $data['journal']->transactionJournalMeta()->where('name', $data['name'])->first(); if (null === $value && null !== $entry) { - // app('log')->debug('Value is empty, delete meta value.'); $entry->delete(); return null; @@ -62,7 +60,6 @@ public function updateOrCreate(array $data): ?TransactionJournalMeta } if (null === $entry) { - // app('log')->debug('Will create new object.'); app('log')->debug(sprintf('Going to create new meta-data entry to store "%s".', $data['name'])); $entry = new TransactionJournalMeta(); $entry->transactionJournal()->associate($data['journal']); diff --git a/app/Generator/Report/Audit/MonthReportGenerator.php b/app/Generator/Report/Audit/MonthReportGenerator.php index bc02d217a83..dad07706125 100644 --- a/app/Generator/Report/Audit/MonthReportGenerator.php +++ b/app/Generator/Report/Audit/MonthReportGenerator.php @@ -179,7 +179,7 @@ public function getAuditReport(Account $account, Carbon $date): array return [ 'journals' => $journals, 'currency' => $currency, - 'exists' => 0 !== count($journals), + 'exists' => !empty($journals), 'end' => $this->end->isoFormat((string) trans('config.month_and_day_moment_js', [], $locale)), 'endBalance' => Steam::finalAccountBalance($account, $this->end)['balance'], 'dayBefore' => $date->isoFormat((string) trans('config.month_and_day_moment_js', [], $locale)), diff --git a/app/Handlers/Events/BillEventHandler.php b/app/Handlers/Events/BillEventHandler.php index 6a96bf29a75..79be40aa550 100644 --- a/app/Handlers/Events/BillEventHandler.php +++ b/app/Handlers/Events/BillEventHandler.php @@ -70,7 +70,7 @@ public function warnAboutOverdueSubscriptions(WarnUserAboutOverdueSubscriptions return; } Log::debug(sprintf('Will warn about %d overdue subscription(s).', count($toBeWarned))); - if (0 === count($toBeWarned)) { + if (empty($toBeWarned)) { Log::debug('No overdue subscriptions to warn about.'); return; diff --git a/app/Handlers/Observer/AccountObserver.php b/app/Handlers/Observer/AccountObserver.php index b29983ada59..08639f3ab62 100644 --- a/app/Handlers/Observer/AccountObserver.php +++ b/app/Handlers/Observer/AccountObserver.php @@ -43,7 +43,6 @@ class AccountObserver { public function created(Account $account): void { - // Log::debug('Observe "created" of an account.'); $this->updatePrimaryCurrencyAmount($account); } @@ -67,7 +66,6 @@ private function updatePrimaryCurrencyAmount(Account $account): void $account->native_virtual_balance = null; } $account->saveQuietly(); - // Log::debug('Account primary currency virtual balance is updated.'); } /** @@ -107,7 +105,6 @@ public function deleting(Account $account): void public function updated(Account $account): void { - // Log::debug('Observe "updated" of an account.'); $this->updatePrimaryCurrencyAmount($account); } } diff --git a/app/Handlers/Observer/AvailableBudgetObserver.php b/app/Handlers/Observer/AvailableBudgetObserver.php index 02fc32d0b18..3519288f7a8 100644 --- a/app/Handlers/Observer/AvailableBudgetObserver.php +++ b/app/Handlers/Observer/AvailableBudgetObserver.php @@ -33,14 +33,12 @@ class AvailableBudgetObserver { public function created(AvailableBudget $availableBudget): void { - // Log::debug('Observe "created" of an available budget.'); $this->updatePrimaryCurrencyAmount($availableBudget); } private function updatePrimaryCurrencyAmount(AvailableBudget $availableBudget): void { if (!Amount::convertToPrimary($availableBudget->user)) { - // Log::debug('Do not update primary currency available amount of the available budget.'); return; } @@ -58,7 +56,6 @@ private function updatePrimaryCurrencyAmount(AvailableBudget $availableBudget): public function updated(AvailableBudget $availableBudget): void { - // Log::debug('Observe "updated" of an available budget.'); $this->updatePrimaryCurrencyAmount($availableBudget); } } diff --git a/app/Handlers/Observer/BillObserver.php b/app/Handlers/Observer/BillObserver.php index 9d7d5f96723..24b2a2886a7 100644 --- a/app/Handlers/Observer/BillObserver.php +++ b/app/Handlers/Observer/BillObserver.php @@ -37,7 +37,6 @@ class BillObserver { public function created(Bill $bill): void { - // Log::debug('Observe "created" of a bill.'); $this->updatePrimaryCurrencyAmount($bill); } @@ -65,7 +64,6 @@ public function deleting(Bill $bill): void $repository = app(AttachmentRepositoryInterface::class); $repository->setUser($bill->user); - // app('log')->debug('Observe "deleting" of a bill.'); /** @var Attachment $attachment */ foreach ($bill->attachments()->get() as $attachment) { $repository->destroy($attachment); @@ -75,7 +73,6 @@ public function deleting(Bill $bill): void public function updated(Bill $bill): void { - // Log::debug('Observe "updated" of a bill.'); $this->updatePrimaryCurrencyAmount($bill); } } diff --git a/app/Handlers/Observer/BudgetLimitObserver.php b/app/Handlers/Observer/BudgetLimitObserver.php index f6fcc85f03e..807c5565019 100644 --- a/app/Handlers/Observer/BudgetLimitObserver.php +++ b/app/Handlers/Observer/BudgetLimitObserver.php @@ -59,7 +59,6 @@ public function created(BudgetLimit $budgetLimit): void private function updatePrimaryCurrencyAmount(BudgetLimit $budgetLimit): void { if (!Amount::convertToPrimary($budgetLimit->budget->user)) { - // Log::debug('Do not update primary currency amount of the budget limit.'); return; } diff --git a/app/Handlers/Observer/TransactionObserver.php b/app/Handlers/Observer/TransactionObserver.php index a5c5fefd732..3867213a2d6 100644 --- a/app/Handlers/Observer/TransactionObserver.php +++ b/app/Handlers/Observer/TransactionObserver.php @@ -83,7 +83,6 @@ public function deleting(?Transaction $transaction): void public function updated(Transaction $transaction): void { - // Log::debug('Observe "updated" of a transaction.'); if (true === config('firefly.feature_flags.running_balance_column') && true === self::$recalculate) { if (1 === bccomp($transaction->amount, '0')) { Log::debug('Trigger recalculateForJournal'); diff --git a/app/Helpers/Collector/Extensions/AccountCollection.php b/app/Helpers/Collector/Extensions/AccountCollection.php index 2328b5dabcf..c00c90b3c10 100644 --- a/app/Helpers/Collector/Extensions/AccountCollection.php +++ b/app/Helpers/Collector/Extensions/AccountCollection.php @@ -179,7 +179,6 @@ static function (EloquentBuilder $query) use ($accountIds): void { // @phpstan-i $query->orWhereIn('destination.account_id', $accountIds); } ); - // app('log')->debug(sprintf('GroupCollector: setAccounts: %s', implode(', ', $accountIds))); } return $this; @@ -232,7 +231,6 @@ static function (EloquentBuilder $query) use ($accountIds): void { // @phpstan-i $query->whereNotIn('destination.account_id', $accountIds); } ); - // app('log')->debug(sprintf('GroupCollector: setAccounts: %s', implode(', ', $accountIds))); } return $this; diff --git a/app/Helpers/Collector/Extensions/AttachmentCollection.php b/app/Helpers/Collector/Extensions/AttachmentCollection.php index 7738fd305fe..f907b993727 100644 --- a/app/Helpers/Collector/Extensions/AttachmentCollection.php +++ b/app/Helpers/Collector/Extensions/AttachmentCollection.php @@ -93,7 +93,6 @@ private function joinAttachmentTables(): void ->where( static function (EloquentBuilder $q1): void { // @phpstan-ignore-line $q1->where('attachments.attachable_type', TransactionJournal::class); - // $q1->where('attachments.uploaded', true); $q1->whereNull('attachments.deleted_at'); $q1->orWhereNull('attachments.attachable_type'); } diff --git a/app/Helpers/Collector/Extensions/MetaCollection.php b/app/Helpers/Collector/Extensions/MetaCollection.php index 5e6dd7e85cc..095d9f6755a 100644 --- a/app/Helpers/Collector/Extensions/MetaCollection.php +++ b/app/Helpers/Collector/Extensions/MetaCollection.php @@ -328,7 +328,6 @@ public function externalUrlDoesNotStart(string $url): GroupCollectorInterface $this->joinMetaDataTables(); $url = (string) json_encode($url); $url = str_replace('\\', '\\\\', rtrim($url, '"')); - // var_dump($url); $this->query->where('journal_meta.name', '=', 'external_url'); $this->query->whereNotLike('journal_meta.data', sprintf('%s%%', $url)); @@ -352,7 +351,6 @@ public function externalUrlStarts(string $url): GroupCollectorInterface $this->joinMetaDataTables(); $url = (string) json_encode($url); $url = str_replace('\\', '\\\\', rtrim($url, '"')); - // var_dump($url); $this->query->where('journal_meta.name', '=', 'external_url'); $this->query->whereLike('journal_meta.data', sprintf('%s%%', $url)); @@ -403,7 +401,6 @@ public function internalReferenceContains(string $internalReference): GroupColle { $internalReference = (string) json_encode($internalReference); $internalReference = str_replace('\\', '\\\\', trim($internalReference, '"')); - // var_dump($internalReference); // exit; $this->joinMetaDataTables(); diff --git a/app/Helpers/Collector/GroupCollector.php b/app/Helpers/Collector/GroupCollector.php index 59b27487309..b8cb436063a 100644 --- a/app/Helpers/Collector/GroupCollector.php +++ b/app/Helpers/Collector/GroupCollector.php @@ -368,7 +368,7 @@ public function excludeIds(array $groupIds): GroupCollectorInterface */ public function excludeJournalIds(array $journalIds): GroupCollectorInterface { - if (0 !== count($journalIds)) { + if (!empty($journalIds)) { // make all integers. $integerIDs = array_map('intval', $journalIds); @@ -383,7 +383,7 @@ public function excludeJournalIds(array $journalIds): GroupCollectorInterface */ public function excludeSearchWords(array $array): GroupCollectorInterface { - if (0 === count($array)) { + if (empty($array)) { Log::debug('No excluded search words provided, skipping.'); return $this; @@ -871,7 +871,6 @@ public function getPaginatedGroups(): LengthAwarePaginator public function setLimit(int $limit): GroupCollectorInterface { $this->limit = $limit; - // app('log')->debug(sprintf('GroupCollector: The limit is now %d', $limit)); return $this; } @@ -941,7 +940,7 @@ public function setIds(array $groupIds): GroupCollectorInterface */ public function setJournalIds(array $journalIds): GroupCollectorInterface { - if (0 !== count($journalIds)) { + if (!empty($journalIds)) { // make all integers. $integerIDs = array_map('intval', $journalIds); Log::debug(sprintf('GroupCollector: setJournalIds: %s', implode(', ', $integerIDs))); @@ -969,7 +968,6 @@ public function setPage(int $page): GroupCollectorInterface { $page = 0 === $page ? 1 : $page; $this->page = $page; - // app('log')->debug(sprintf('GroupCollector: page is now %d', $page)); return $this; } @@ -979,7 +977,7 @@ public function setPage(int $page): GroupCollectorInterface */ public function setSearchWords(array $array): GroupCollectorInterface { - if (0 === count($array)) { + if (empty($array)) { Log::debug('No words in array'); return $this; @@ -1062,7 +1060,6 @@ public function setUser(User $user): GroupCollectorInterface */ private function startQuery(): void { - // app('log')->debug('GroupCollector::startQuery'); $this->query = $this->user // ->transactionGroups() // ->leftJoin('transaction_journals', 'transaction_journals.transaction_group_id', 'transaction_groups.id') @@ -1126,7 +1123,6 @@ public function setUserGroup(UserGroup $userGroup): GroupCollectorInterface */ private function startQueryForGroup(): void { - // app('log')->debug('GroupCollector::startQuery'); $this->query = $this->userGroup ->transactionJournals() ->leftJoin('transaction_groups', 'transaction_journals.transaction_group_id', 'transaction_groups.id') diff --git a/app/Helpers/Fiscal/FiscalHelper.php b/app/Helpers/Fiscal/FiscalHelper.php index 13c9d14bdc0..748574c4735 100644 --- a/app/Helpers/Fiscal/FiscalHelper.php +++ b/app/Helpers/Fiscal/FiscalHelper.php @@ -46,7 +46,6 @@ public function __construct() */ public function endOfFiscalYear(Carbon $date): Carbon { - // app('log')->debug(sprintf('Now in endOfFiscalYear(%s).', $date->format('Y-m-d'))); $endDate = $this->startOfFiscalYear($date); if (true === $this->useCustomFiscalYear) { // add 1 year and sub 1 day @@ -56,7 +55,6 @@ public function endOfFiscalYear(Carbon $date): Carbon if (false === $this->useCustomFiscalYear) { $endDate->endOfYear(); } - // app('log')->debug(sprintf('Result of endOfFiscalYear(%s) = %s', $date->format('Y-m-d'), $endDate->format('Y-m-d'))); return $endDate; } @@ -86,7 +84,6 @@ public function startOfFiscalYear(Carbon $date): Carbon $startDate->startOfYear(); } - // app('log')->debug(sprintf('Result of startOfFiscalYear(%s) = %s', $date->format('Y-m-d'), $startDate->format('Y-m-d'))); return $startDate; } diff --git a/app/Helpers/Report/NetWorth.php b/app/Helpers/Report/NetWorth.php index c3a2f0592cc..4c10702c65b 100644 --- a/app/Helpers/Report/NetWorth.php +++ b/app/Helpers/Report/NetWorth.php @@ -82,7 +82,6 @@ public function byAccounts(Collection $accounts, Carbon $date): array /** @var Account $account */ foreach ($accounts as $account) { - // Log::debug(sprintf('Now at account #%d ("%s")', $account->id, $account->name)); $currency = $this->accountRepository->getAccountCurrency($account) ?? $primary; $usePrimary = $convertToPrimary && $primary->id !== $currency->id; $currency = $usePrimary ? $primary : $currency; @@ -98,7 +97,6 @@ public function byAccounts(Collection $accounts, Carbon $date): array $balance = '' !== (string) $account->virtual_balance ? bcsub($balance, (string) $account->virtual_balance) : $balance; $primaryBalance = '' !== (string) $account->native_virtual_balance ? bcsub($primaryBalance, (string) $account->native_virtual_balance) : $primaryBalance; $amountToUse = $usePrimary ? $primaryBalance : $balance; - // Log::debug(sprintf('Will use %s %s', $currencyCode, $amountToUse)); $netWorth[$currencyCode] ??= [ 'balance' => '0', diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index 07abf76b4db..df3c9eaf9c4 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -225,7 +225,6 @@ public function update(UserFormRequest $request, User $user) app('log')->debug('Actually here'); $data = $request->getUserData(); - // var_dump($data); // update password if (array_key_exists('password', $data) && '' !== $data['password']) { diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.php index 00f387d7c46..f81fc6e902b 100644 --- a/app/Http/Controllers/Chart/AccountController.php +++ b/app/Http/Controllers/Chart/AccountController.php @@ -121,7 +121,6 @@ public function expenseAccounts(): JsonResponse Log::debug('Done collecting balances'); // loop the accounts, then check for balance and currency info. foreach ($accounts as $account) { - // Log::debug(sprintf('[a] Now in account #%d ("%s")', $account->id, $account->name)); $expenses = $endBalances[$account->id] ?? false; if (false === $expenses) { Log::error(sprintf('Found no end balance for account #%d', $account->id)); @@ -135,23 +134,19 @@ public function expenseAccounts(): JsonResponse */ foreach ($expenses as $key => $endBalance) { if (!$this->convertToPrimary && 'pc_balance' === $key) { - // Log::debug(sprintf('[a] Will skip expense array "%s"', $key)); continue; } if ($this->convertToPrimary && 'pc_balance' !== $key) { - // Log::debug(sprintf('[b] Will skip expense array "%s"', $key)); continue; } - // Log::debug(sprintf('Will process expense array "%s" with amount %s', $key, $endBalance)); $searchCode = $this->convertToPrimary ? $this->primaryCurrency->code : $key; $searchCode = 'balance' === $searchCode || 'pc_balance' === $searchCode ? $this->primaryCurrency->code : $searchCode; // Log::debug(sprintf('Search code is %s', $searchCode)); // see if there is an accompanying start amount. // grab the difference and find the currency. $startBalance = ($startBalances[$account->id][$key] ?? '0'); - // Log::debug(sprintf('Start balance is %s', $startBalance)); $diff = bcsub($endBalance, $startBalance); $currencies[$searchCode] ??= $this->currencyRepository->findByCode($searchCode); if (0 !== bccomp($diff, '0')) { @@ -382,7 +377,6 @@ public function frontpage(AccountRepositoryInterface $repository): JsonResponse $start = clone session('start', today(config('app.timezone'))->startOfMonth()); $end = clone session('end', today(config('app.timezone'))->endOfMonth()); $defaultSet = $repository->getAccountsByType([AccountTypeEnum::DEFAULT->value, AccountTypeEnum::ASSET->value])->pluck('id')->toArray(); - // Log::debug('Default set is ', $defaultSet); $frontpage = Preferences::get('frontpageAccounts', $defaultSet); $frontpageArray = !is_array($frontpage->data) ? [] : $frontpage->data; Log::debug('Frontpage preference set is ', $frontpageArray); @@ -536,7 +530,6 @@ public function period(Account $account, Carbon $start, Carbon $end): JsonRespon Log::debug(sprintf('Start of loop, $carbon is %s', $carbon->format('Y-m-d H:i:s'))); while ($end->gte($current)) { $momentBalance = $previous; - // $theDate = $current->format('Y-m-d'); Log::debug(sprintf('Now at %s, with momentBalance %s', $current->format('Y-m-d H:i:s'), json_encode($momentBalance))); // loop over the array with balances, find one that is earlier or on the same day. @@ -662,7 +655,6 @@ public function revenueAccounts(): JsonResponse // loop the accounts, then check for balance and currency info. foreach ($accounts as $account) { - // Log::debug(sprintf('[b] Now in account #%d ("%s")', $account->id, $account->name)); $expenses = $endBalances[$account->id] ?? false; if (false === $expenses) { Log::error(sprintf('Found no end balance for account #%d', $account->id)); @@ -676,23 +668,19 @@ public function revenueAccounts(): JsonResponse */ foreach ($expenses as $key => $endBalance) { if (!$this->convertToPrimary && 'pc_balance' === $key) { - // Log::debug(sprintf('[a] Will skip expense array "%s"', $key)); continue; } if ($this->convertToPrimary && 'pc_balance' !== $key) { - // Log::debug(sprintf('[b] Will skip expense array "%s"', $key)); continue; } - // Log::debug(sprintf('Will process expense array "%s" with amount %s', $key, $endBalance)); $searchCode = $this->convertToPrimary ? $this->primaryCurrency->code : $key; $searchCode = 'balance' === $searchCode || 'pc_balance' === $searchCode ? $this->primaryCurrency->code : $searchCode; // Log::debug(sprintf('Search code is %s', $searchCode)); // see if there is an accompanying start amount. // grab the difference and find the currency. $startBalance = ($startBalances[$account->id][$key] ?? '0'); - // Log::debug(sprintf('Start balance is %s', $startBalance)); $diff = bcsub($endBalance, $startBalance); $currencies[$searchCode] ??= $this->currencyRepository->findByCode($searchCode); if (0 !== bccomp($diff, '0')) { diff --git a/app/Http/Controllers/Chart/BudgetController.php b/app/Http/Controllers/Chart/BudgetController.php index 49433fb8ebc..d10005689bc 100644 --- a/app/Http/Controllers/Chart/BudgetController.php +++ b/app/Http/Controllers/Chart/BudgetController.php @@ -190,7 +190,6 @@ public function budgetLimit(Budget $budget, BudgetLimit $budgetLimit): JsonRespo $data['datasets'][0]['currency_symbol'] = $currency->symbol; $data['datasets'][0]['currency_code'] = $currency->code; $cache->store($data); - // var_dump($data);exit; return response()->json($data); } diff --git a/app/Http/Controllers/Chart/ExpenseReportController.php b/app/Http/Controllers/Chart/ExpenseReportController.php index d3806d846e1..2a2565d5b8f 100644 --- a/app/Http/Controllers/Chart/ExpenseReportController.php +++ b/app/Http/Controllers/Chart/ExpenseReportController.php @@ -180,7 +180,7 @@ public function mainChart(Collection $accounts, Collection $expense, Carbon $sta $newSet[$key] = $entry; } } - if (0 === count($newSet)) { + if (empty($newSet)) { $newSet = $chartData; } $data = $this->generator->multiSet($newSet); diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index dc282fbc074..4df5ca80332 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -86,7 +86,6 @@ public function __construct() // overrule v2 layout back to v1. if ('true' === request()->get('force_default_layout') && 'v2' === config('view.layout')) { - // config('view.layout','v1'); Config::set('view.layout', 'v1'); View::getFinder()->setPaths([realpath(base_path('resources/views'))]); // @phpstan-ignore-line } diff --git a/app/Http/Controllers/Json/BoxController.php b/app/Http/Controllers/Json/BoxController.php index ff3f5e8c83d..efd2a2dc1d9 100644 --- a/app/Http/Controllers/Json/BoxController.php +++ b/app/Http/Controllers/Json/BoxController.php @@ -123,7 +123,7 @@ public function balance(CurrencyRepositoryInterface $repository): JsonResponse $incomes[$currencyId] = app('amount')->formatAnything($currency, $incomes[$currencyId] ?? '0', false); $expenses[$currencyId] = app('amount')->formatAnything($currency, $expenses[$currencyId] ?? '0', false); } - if (0 === count($sums)) { + if (empty($sums)) { $currency = $this->primaryCurrency; $sums[$this->primaryCurrency->id] = app('amount')->formatAnything($this->primaryCurrency, '0', false); $incomes[$this->primaryCurrency->id] = app('amount')->formatAnything($this->primaryCurrency, '0', false); diff --git a/app/Http/Controllers/Json/FrontpageController.php b/app/Http/Controllers/Json/FrontpageController.php index f66864866b4..30133279fe8 100644 --- a/app/Http/Controllers/Json/FrontpageController.php +++ b/app/Http/Controllers/Json/FrontpageController.php @@ -84,7 +84,7 @@ public function piggyBanks(PiggyBankRepositoryInterface $repository): JsonRespon ); $html = ''; - if (0 !== count($info)) { + if (!empty($info)) { try { $convertToPrimary = $this->convertToPrimary; $primary = $this->primaryCurrency; diff --git a/app/Http/Controllers/Report/BudgetController.php b/app/Http/Controllers/Report/BudgetController.php index 2b26e165011..1de9c91173d 100644 --- a/app/Http/Controllers/Report/BudgetController.php +++ b/app/Http/Controllers/Report/BudgetController.php @@ -291,7 +291,6 @@ public function period(Collection $accounts, Carbon $start, Carbon $end) $cache->addProperty('budget-period-report'); $cache->addProperty($accounts->pluck('id')->toArray()); if ($cache->has()) { - // return $cache->get(); } $periods = Navigation::listOfPeriods($start, $end); diff --git a/app/Http/Controllers/Rule/CreateController.php b/app/Http/Controllers/Rule/CreateController.php index 107042d458a..6d1f0e7b4aa 100644 --- a/app/Http/Controllers/Rule/CreateController.php +++ b/app/Http/Controllers/Rule/CreateController.php @@ -115,7 +115,6 @@ public function create(Request $request, ?RuleGroup $ruleGroup = null) } $oldTriggers = $this->parseFromOperators($operators); } - // var_dump($oldTriggers);exit; // restore actions and triggers from old input: if (is_array($request->old()) && count($request->old()) > 0) { diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php index a0319eb8cd0..a678c879ed3 100644 --- a/app/Http/Middleware/Authenticate.php +++ b/app/Http/Middleware/Authenticate.php @@ -80,7 +80,7 @@ public function handle($request, Closure $next, ...$guards) */ protected function authenticate($request, array $guards) { - if (0 === count($guards)) { + if (empty($guards)) { // go for default guard: // @noinspection PhpUndefinedMethodInspection if ($this->auth->check()) { @@ -129,7 +129,6 @@ private function validateBlockedUser(?User $user, array $guards): void app('log')->warning('User is null, throw exception?'); } if ($user instanceof User) { - // app('log')->debug(get_class($user)); if (1 === (int) $user->blocked) { $message = (string) trans('firefly.block_account_logout'); if ('email_changed' === $user->blocked_code) { diff --git a/app/Http/Middleware/Installer.php b/app/Http/Middleware/Installer.php index f7d38232caa..a221f43559e 100644 --- a/app/Http/Middleware/Installer.php +++ b/app/Http/Middleware/Installer.php @@ -57,7 +57,6 @@ public function handle($request, Closure $next) $url = $request->url(); $strpos = stripos($url, '/install'); if (false !== $strpos) { - // Log::debug(sprintf('URL is %s, will NOT run installer middleware', $url)); return $next($request); } @@ -82,7 +81,6 @@ public function handle($request, Closure $next) */ private function hasNoTables(): bool { - // Log::debug('Now in routine hasNoTables()'); try { DB::table('users')->count(); @@ -106,7 +104,6 @@ private function hasNoTables(): bool throw new FireflyException(sprintf('Could not access the database: %s', $message), 0, $e); } - // Log::debug('Everything seems OK with the tables.'); return false; } @@ -147,7 +144,6 @@ private function oldDBVersion(): bool return true; } - // Log::info(sprintf('Configured DB version (%d) equals expected DB version (%d)', $dbVersion, $configVersion)); return false; } @@ -177,7 +173,6 @@ private function oldVersion(): bool return true; } - // Log::info(sprintf('Installed Firefly III version (%s) equals expected Firefly III version (%s)', $dbVersion, $configVersion)); return false; } diff --git a/app/Jobs/WarnAboutBills.php b/app/Jobs/WarnAboutBills.php index 155454790ea..470ba12dd34 100644 --- a/app/Jobs/WarnAboutBills.php +++ b/app/Jobs/WarnAboutBills.php @@ -182,7 +182,7 @@ private function getDates(Bill $bill): array private function needsOverdueAlert(array $dates): bool { $count = count($dates['pay_dates']) - count($dates['paid_dates']); - if (0 === $count || 0 === count($dates['pay_dates'])) { + if (0 === $count || empty($dates['pay_dates'])) { return false; } // the earliest date in the list of pay dates must be 48hrs or more ago. @@ -200,7 +200,7 @@ private function needsOverdueAlert(array $dates): bool private function sendOverdueAlerts(User $user, array $overdue): void { - if (count($overdue) > 0) { + if (!empty($overdue)) { Log::debug(sprintf('Will now send warning about overdue bill for user #%d.', $user->id)); event(new WarnUserAboutOverdueSubscriptions($user, $overdue)); } diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.php index 609d7dc3534..936fc65701d 100644 --- a/app/Models/TransactionJournal.php +++ b/app/Models/TransactionJournal.php @@ -171,7 +171,7 @@ protected function transactionTypes(EloquentBuilder $query, array $types): void if (!self::isJoined($query, 'transaction_types')) { $query->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id'); } - if (0 !== count($types)) { + if (!empty($types)) { $query->whereIn('transaction_types.type', $types); } } diff --git a/app/Notifications/Test/OwnerTestNotificationNtfy.php b/app/Notifications/Test/OwnerTestNotificationNtfy.php index 9f72e8544bd..7f75ba0a3f1 100644 --- a/app/Notifications/Test/OwnerTestNotificationNtfy.php +++ b/app/Notifications/Test/OwnerTestNotificationNtfy.php @@ -31,7 +31,6 @@ use Ntfy\Message; use Wijourdil\NtfyNotificationChannel\Channels\NtfyChannel; -// use Illuminate\Notifications\Slack\SlackMessage; /** * Class TestNotification diff --git a/app/Notifications/Test/OwnerTestNotificationPushover.php b/app/Notifications/Test/OwnerTestNotificationPushover.php index 0e2c444f013..feeb9880150 100644 --- a/app/Notifications/Test/OwnerTestNotificationPushover.php +++ b/app/Notifications/Test/OwnerTestNotificationPushover.php @@ -31,7 +31,6 @@ use NotificationChannels\Pushover\PushoverChannel; use NotificationChannels\Pushover\PushoverMessage; -// use Illuminate\Notifications\Slack\SlackMessage; /** * Class TestNotification diff --git a/app/Notifications/Test/OwnerTestNotificationSlack.php b/app/Notifications/Test/OwnerTestNotificationSlack.php index 7a0a6e40dea..2f2afee9cd6 100644 --- a/app/Notifications/Test/OwnerTestNotificationSlack.php +++ b/app/Notifications/Test/OwnerTestNotificationSlack.php @@ -29,7 +29,6 @@ use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; -// use Illuminate\Notifications\Slack\SlackMessage; /** * Class TestNotification @@ -53,7 +52,6 @@ public function toArray(OwnerNotifiable $notifiable): array public function toSlack(OwnerNotifiable $notifiable): SlackMessage { return new SlackMessage()->content((string) trans('email.admin_test_subject')); - // return new SlackMessage()->text((string) trans('email.admin_test_subject'))->to($url); } /** diff --git a/app/Notifications/Test/UserTestNotificationNtfy.php b/app/Notifications/Test/UserTestNotificationNtfy.php index babcb459f81..6e9e388e8d4 100644 --- a/app/Notifications/Test/UserTestNotificationNtfy.php +++ b/app/Notifications/Test/UserTestNotificationNtfy.php @@ -31,7 +31,6 @@ use Ntfy\Message; use Wijourdil\NtfyNotificationChannel\Channels\NtfyChannel; -// use Illuminate\Notifications\Slack\SlackMessage; /** * Class TestNotification diff --git a/app/Notifications/Test/UserTestNotificationPushover.php b/app/Notifications/Test/UserTestNotificationPushover.php index e963b4bca97..7870d9ff86b 100644 --- a/app/Notifications/Test/UserTestNotificationPushover.php +++ b/app/Notifications/Test/UserTestNotificationPushover.php @@ -31,7 +31,6 @@ use NotificationChannels\Pushover\PushoverChannel; use NotificationChannels\Pushover\PushoverMessage; -// use Illuminate\Notifications\Slack\SlackMessage; /** * Class TestNotification diff --git a/app/Notifications/Test/UserTestNotificationSlack.php b/app/Notifications/Test/UserTestNotificationSlack.php index 59cedc0b4cf..2d8ef659bc7 100644 --- a/app/Notifications/Test/UserTestNotificationSlack.php +++ b/app/Notifications/Test/UserTestNotificationSlack.php @@ -29,7 +29,6 @@ use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; -// use Illuminate\Notifications\Slack\SlackMessage; /** * Class TestNotification @@ -53,7 +52,6 @@ public function toArray(User $user): array public function toSlack(User $user): SlackMessage { return new SlackMessage()->content((string) trans('email.admin_test_subject')); - // return new SlackMessage()->text((string) trans('email.admin_test_subject'))->to($url); } /** diff --git a/app/Policies/UserPolicy.php b/app/Policies/UserPolicy.php index 169efb81093..7af549d352a 100644 --- a/app/Policies/UserPolicy.php +++ b/app/Policies/UserPolicy.php @@ -34,13 +34,11 @@ class UserPolicy public function view(User $user, User $user1): bool { return true; - // return auth()->check() && $user->id === $account->user_id; } public function viewAccounts(User $user): bool { return true; - // return auth()->check(); } /** @@ -51,6 +49,5 @@ public function viewAccounts(User $user): bool public function viewAny(): bool { return true; - // return auth()->check(); } } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 263342b7533..0688c775d18 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -44,7 +44,6 @@ class AppServiceProvider extends ServiceProvider public function boot(): void { Schema::defaultStringLength(191); - // Passport::$clientUuids = false; Response::macro('api', function (array $value) { $headers = [ 'Cache-Control' => 'no-store', @@ -94,7 +93,6 @@ public function boot(): void public function register(): void { Passport::ignoreRoutes(); - // Passport::ignoreMigrations(); // Sanctum::ignoreMigrations(); } } diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index afd301bf228..69816d4d0e5 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -118,7 +118,7 @@ static function (EloquentBuilder $q1) use ($number): void { ) ; - if (0 !== count($types)) { + if (!empty($types)) { $dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id'); $dbQuery->whereIn('account_types.type', $types); } @@ -132,7 +132,7 @@ public function findByIbanNull(string $iban, array $types): ?Account $iban = Steam::filterSpaces($iban); $query = $this->user->accounts()->where('iban', '!=', '')->whereNotNull('iban'); - if (0 !== count($types)) { + if (!empty($types)) { $query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id'); $query->whereIn('account_types.type', $types); } @@ -145,7 +145,7 @@ public function findByName(string $name, array $types): ?Account { $query = $this->user->accounts(); - if (0 !== count($types)) { + if (!empty($types)) { $query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id'); $query->whereIn('account_types.type', $types); } @@ -183,7 +183,7 @@ public function getAccountsById(array $accountIds): Collection { $query = $this->user->accounts(); - if (0 !== count($accountIds)) { + if (!empty($accountIds)) { $query->whereIn('accounts.id', $accountIds); } $query->orderBy('accounts.order', 'ASC'); @@ -203,7 +203,7 @@ public function getActiveAccountsByType(array $types): Collection 'attachments', ] ); - if (0 !== count($types)) { + if (!empty($types)) { $query->accountTypeIn($types); } $query->where('active', true); @@ -267,7 +267,7 @@ public function getInactiveAccountsByType(array $types): Collection }, ] ); - if (0 !== count($types)) { + if (!empty($types)) { $query->accountTypeIn($types); } $query->where('active', 0); @@ -480,19 +480,19 @@ public function getAccountsByType(array $types, ?array $sort = []): Collection { $res = array_intersect([AccountTypeEnum::ASSET->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value], $types); $query = $this->user->accounts(); - if (0 !== count($types)) { + if (!empty($types)) { $query->accountTypeIn($types); } // add sort parameters. At this point they're filtered to allowed fields to sort by: - if (0 !== count($sort)) { + if (!empty($sort)) { foreach ($sort as $param) { $query->orderBy($param[0], $param[1]); } } - if (0 === count($sort)) { - if (0 !== count($res)) { + if (empty($sort)) { + if (!empty($res)) { $query->orderBy('accounts.order', 'ASC'); } $query->orderBy('accounts.active', 'DESC'); @@ -636,7 +636,7 @@ public function searchAccount(string $query, array $types, int $limit): Collecti $dbQuery->whereLike('name', $search); } } - if (0 !== count($types)) { + if (!empty($types)) { $dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id'); $dbQuery->whereIn('account_types.type', $types); } @@ -672,7 +672,7 @@ static function (EloquentBuilder $q2) use ($search): void { ); } } - if (0 !== count($types)) { + if (!empty($types)) { $dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id'); $dbQuery->whereIn('account_types.type', $types); } diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.php index 99c484f4a8e..97fc8fad632 100644 --- a/app/Repositories/Bill/BillRepository.php +++ b/app/Repositories/Bill/BillRepository.php @@ -307,7 +307,6 @@ public function getPaginator(int $size): LengthAwarePaginator */ public function getPaidDatesInRange(Bill $bill, Carbon $start, Carbon $end): Collection { - // app('log')->debug('Now in getPaidDatesInRange()'); Log::debug(sprintf('Search for linked journals between %s and %s', $start->toW3cString(), $end->toW3cString())); @@ -568,9 +567,7 @@ public function sumPaidInRange(Carbon $start, Carbon $end): array // get currency from transaction as well. $return[(int) $transactionCurrency->id]['sum'] = bcadd($return[(int) $transactionCurrency->id]['sum'], Amount::getAmountFromJournalObject($transactionJournal)); - // $setAmount = bcadd($setAmount, Amount::getAmountFromJournalObject($transactionJournal)); } - // Log::debug(sprintf('Bill #%d ("%s") with %d transaction(s) and sum %s %s', $bill->id, $bill->name, $set->count(), $currency->code, $setAmount)); // $return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], $setAmount); // Log::debug(sprintf('Total sum is now %s', $return[$currency->id]['sum'])); } @@ -605,16 +602,13 @@ public function sumUnpaidInRange(Carbon $start, Carbon $end): array /** @var Bill $bill */ foreach ($bills as $bill) { - // app('log')->debug(sprintf('Processing bill #%d ("%s")', $bill->id, $bill->name)); $dates = $this->getPayDatesInRange($bill, $start, $end); $count = $bill->transactionJournals()->after($start)->before($end)->count(); $total = $dates->count() - $count; - // app('log')->debug(sprintf('Pay dates: %d, count: %d, left: %d', $dates->count(), $count, $total)); // app('log')->debug('dates', $dates->toArray()); $minField = $convertToPrimary && $bill->transactionCurrency->id !== $primary->id ? 'native_amount_min' : 'amount_min'; $maxField = $convertToPrimary && $bill->transactionCurrency->id !== $primary->id ? 'native_amount_max' : 'amount_max'; - // Log::debug(sprintf('min field is %s, max field is %s', $minField, $maxField)); if ($total > 0) { $currency = $convertToPrimary && $bill->transactionCurrency->id !== $primary->id ? $primary : $bill->transactionCurrency; @@ -642,21 +636,17 @@ public function getPayDatesInRange(Bill $bill, Carbon $start, Carbon $end): Coll { $set = new Collection(); $currentStart = clone $start; - // app('log')->debug(sprintf('Now at bill "%s" (%s)', $bill->name, $bill->repeat_freq)); // app('log')->debug(sprintf('First currentstart is %s', $currentStart->format('Y-m-d'))); while ($currentStart <= $end) { - // app('log')->debug(sprintf('Currentstart is now %s.', $currentStart->format('Y-m-d'))); $nextExpectedMatch = $this->nextDateMatch($bill, $currentStart); // app('log')->debug(sprintf('Next Date match after %s is %s', $currentStart->format('Y-m-d'), $nextExpectedMatch->format('Y-m-d'))); if ($nextExpectedMatch > $end) {// If nextExpectedMatch is after end, we continue break; } $set->push(clone $nextExpectedMatch); - // app('log')->debug(sprintf('Now %d dates in set.', $set->count())); $nextExpectedMatch->addDay(); - // app('log')->debug(sprintf('Currentstart (%s) has become %s.', $currentStart->format('Y-m-d'), $nextExpectedMatch->format('Y-m-d'))); $currentStart = clone $nextExpectedMatch; } diff --git a/app/Repositories/ExchangeRate/ExchangeRateRepository.php b/app/Repositories/ExchangeRate/ExchangeRateRepository.php index 1fecb036fd4..c953320d4dc 100644 --- a/app/Repositories/ExchangeRate/ExchangeRateRepository.php +++ b/app/Repositories/ExchangeRate/ExchangeRateRepository.php @@ -52,7 +52,6 @@ public function getAll(): Collection #[Override] public function getRates(TransactionCurrency $from, TransactionCurrency $to): Collection { - // orderBy('date', 'DESC')->toRawSql(); return $this->userGroup->currencyExchangeRates() ->where(function (Builder $q1) use ($from, $to): void { diff --git a/app/Repositories/PiggyBank/ModifiesPiggyBanks.php b/app/Repositories/PiggyBank/ModifiesPiggyBanks.php index 658ca6e1c83..2d6eab2e55d 100644 --- a/app/Repositories/PiggyBank/ModifiesPiggyBanks.php +++ b/app/Repositories/PiggyBank/ModifiesPiggyBanks.php @@ -332,7 +332,6 @@ public function updateNote(PiggyBank $piggyBank, string $note): void public function setOrder(PiggyBank $piggyBank, int $newOrder): bool { $oldOrder = $piggyBank->order; - // Log::debug(sprintf('Will move piggy bank #%d ("%s") from %d to %d', $piggyBank->id, $piggyBank->name, $oldOrder, $newOrder)); if ($newOrder > $oldOrder) { PiggyBank::leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id') ->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id') diff --git a/app/Repositories/Recurring/RecurringRepository.php b/app/Repositories/Recurring/RecurringRepository.php index e12a543e388..b7d302c3cc6 100644 --- a/app/Repositories/Recurring/RecurringRepository.php +++ b/app/Repositories/Recurring/RecurringRepository.php @@ -322,7 +322,7 @@ public function getTransactions(Recurrence $recurrence): Collection foreach ($journalMeta as $journalId) { $search[] = (int) $journalId; } - if (0 === count($search)) { + if (empty($search)) { return new Collection(); } diff --git a/app/Repositories/UserGroups/Account/AccountRepository.php b/app/Repositories/UserGroups/Account/AccountRepository.php index 418f16ef8b6..11c70f1d5f2 100644 --- a/app/Repositories/UserGroups/Account/AccountRepository.php +++ b/app/Repositories/UserGroups/Account/AccountRepository.php @@ -55,7 +55,7 @@ class AccountRepository implements AccountRepositoryInterface public function countAccounts(array $types): int { $query = $this->userGroup->accounts(); - if (0 !== count($types)) { + if (!empty($types)) { $query->accountTypeIn($types); } @@ -77,7 +77,7 @@ static function (EloquentBuilder $q1) use ($number): void { ) ; - if (0 !== count($types)) { + if (!empty($types)) { $dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id'); $dbQuery->whereIn('account_types.type', $types); } @@ -91,7 +91,7 @@ public function findByIbanNull(string $iban, array $types): ?Account $iban = Steam::filterSpaces($iban); $query = $this->userGroup->accounts()->where('iban', '!=', '')->whereNotNull('iban'); - if (0 !== count($types)) { + if (!empty($types)) { $query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id'); $query->whereIn('account_types.type', $types); } @@ -104,7 +104,7 @@ public function findByName(string $name, array $types): ?Account { $query = $this->userGroup->accounts(); - if (0 !== count($types)) { + if (!empty($types)) { $query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id'); $query->whereIn('account_types.type', $types); } @@ -189,7 +189,7 @@ public function getAccountsById(array $accountIds): Collection { $query = $this->userGroup->accounts(); - if (0 !== count($accountIds)) { + if (!empty($accountIds)) { $query->whereIn('accounts.id', $accountIds); } $query->orderBy('accounts.order', 'ASC'); @@ -203,20 +203,20 @@ public function getAccountsById(array $accountIds): Collection public function getAccountsInOrder(array $types, array $sort, int $startRow, int $endRow): Collection { $query = $this->userGroup->accounts(); - if (0 !== count($types)) { + if (!empty($types)) { $query->accountTypeIn($types); } $query->skip($startRow); $query->take($endRow - $startRow); // add sort parameters. At this point they're filtered to allowed fields to sort by: - if (0 !== count($sort)) { + if (!empty($sort)) { foreach ($sort as $label => $direction) { $query->orderBy(sprintf('accounts.%s', $label), $direction); } } - if (0 === count($sort)) { + if (empty($sort)) { $query->orderBy('accounts.order', 'ASC'); $query->orderBy('accounts.active', 'DESC'); $query->orderBy('accounts.name', 'ASC'); @@ -228,7 +228,7 @@ public function getAccountsInOrder(array $types, array $sort, int $startRow, int public function getActiveAccountsByType(array $types): Collection { $query = $this->userGroup->accounts(); - if (0 !== count($types)) { + if (!empty($types)) { $query->accountTypeIn($types); } $query->where('active', true); @@ -253,7 +253,7 @@ public function getLastActivity(Collection $accounts): array public function getMetaValues(Collection $accounts, array $fields): Collection { $query = AccountMeta::whereIn('account_id', $accounts->pluck('id')->toArray()); - if (count($fields) > 0) { + if (!empty($fields)) { $query->whereIn('name', $fields); } @@ -326,7 +326,7 @@ public function getAccountsByType(array $types, ?array $sort = [], ?array $filte $sortable = ['name', 'active']; // TODO yes this is a duplicate array. $res = array_intersect([AccountTypeEnum::ASSET->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value], $types); $query = $this->userGroup->accounts(); - if (0 !== count($types)) { + if (!empty($types)) { $query->accountTypeIn($types); } @@ -348,7 +348,7 @@ public function getAccountsByType(array $types, ?array $sort = [], ?array $filte // add sort parameters. At this point they're filtered to allowed fields to sort by: $hasActiveColumn = array_key_exists('active', $sort); - if (count($sort) > 0) { + if (!empty($sort)) { if (false === $hasActiveColumn) { $query->orderBy('accounts.active', 'DESC'); } @@ -359,8 +359,8 @@ public function getAccountsByType(array $types, ?array $sort = [], ?array $filte } } - if (0 === count($sort)) { - if (0 !== count($res)) { + if (empty($sort)) { + if (!empty($res)) { $query->orderBy('accounts.active', 'DESC'); } $query->orderBy('accounts.order', 'ASC'); @@ -404,7 +404,7 @@ public function searchAccount(string $query, array $types, int $page, int $limit }); } - if (0 !== count($types)) { + if (!empty($types)) { $dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id'); $dbQuery->whereIn('account_types.type', $types); } diff --git a/app/Repositories/UserGroups/Bill/BillRepository.php b/app/Repositories/UserGroups/Bill/BillRepository.php index defdaaba0d8..5b4f7815957 100644 --- a/app/Repositories/UserGroups/Bill/BillRepository.php +++ b/app/Repositories/UserGroups/Bill/BillRepository.php @@ -186,21 +186,17 @@ public function getPayDatesInRange(Bill $bill, Carbon $start, Carbon $end): Coll { $set = new Collection(); $currentStart = clone $start; - // app('log')->debug(sprintf('Now at bill "%s" (%s)', $bill->name, $bill->repeat_freq)); // app('log')->debug(sprintf('First currentstart is %s', $currentStart->format('Y-m-d'))); while ($currentStart <= $end) { - // app('log')->debug(sprintf('Currentstart is now %s.', $currentStart->format('Y-m-d'))); $nextExpectedMatch = $this->nextDateMatch($bill, $currentStart); // app('log')->debug(sprintf('Next Date match after %s is %s', $currentStart->format('Y-m-d'), $nextExpectedMatch->format('Y-m-d'))); if ($nextExpectedMatch > $end) {// If nextExpectedMatch is after end, we continue break; } $set->push(clone $nextExpectedMatch); - // app('log')->debug(sprintf('Now %d dates in set.', $set->count())); $nextExpectedMatch->addDay(); - // app('log')->debug(sprintf('Currentstart (%s) has become %s.', $currentStart->format('Y-m-d'), $nextExpectedMatch->format('Y-m-d'))); $currentStart = clone $nextExpectedMatch; } diff --git a/app/Repositories/UserGroups/Category/CategoryRepository.php b/app/Repositories/UserGroups/Category/CategoryRepository.php index 2b93a540cf7..ccb0fd198f3 100644 --- a/app/Repositories/UserGroups/Category/CategoryRepository.php +++ b/app/Repositories/UserGroups/Category/CategoryRepository.php @@ -40,7 +40,7 @@ class CategoryRepository implements CategoryRepositoryInterface public function searchCategory(array $query, int $limit): Collection { $search = $this->userGroup->categories(); - if (count($query) > 0) { + if (!empty($query)) { // split query on spaces just in case: $search->where(function (EloquentBuilder $q) use ($query): void { foreach ($query as $line) { diff --git a/app/Repositories/UserGroups/ExchangeRate/ExchangeRateRepository.php b/app/Repositories/UserGroups/ExchangeRate/ExchangeRateRepository.php index 3dc1d6a7972..a4e7a8c6e05 100644 --- a/app/Repositories/UserGroups/ExchangeRate/ExchangeRateRepository.php +++ b/app/Repositories/UserGroups/ExchangeRate/ExchangeRateRepository.php @@ -56,7 +56,6 @@ public function getAll(): Collection #[Override] public function getRates(TransactionCurrency $from, TransactionCurrency $to): Collection { - // orderBy('date', 'DESC')->toRawSql(); return $this->userGroup->currencyExchangeRates() ->where(function (Builder $q1) use ($from, $to): void { diff --git a/app/Repositories/UserGroups/Journal/JournalRepository.php b/app/Repositories/UserGroups/Journal/JournalRepository.php index 8926573acdc..e602c0f9ea2 100644 --- a/app/Repositories/UserGroups/Journal/JournalRepository.php +++ b/app/Repositories/UserGroups/Journal/JournalRepository.php @@ -42,7 +42,7 @@ public function searchJournalDescriptions(array $query, int $limit): Collection $search = $this->userGroup->transactionJournals() ->orderBy('date', 'DESC') ; - if (count($query) > 0) { + if (!empty($query)) { // split query on spaces just in case: $search->where(function (EloquentBuilder $q) use ($query): void { foreach ($query as $line) { diff --git a/app/Repositories/UserGroups/Tag/TagRepository.php b/app/Repositories/UserGroups/Tag/TagRepository.php index 49f9c2e044a..2d276710a24 100644 --- a/app/Repositories/UserGroups/Tag/TagRepository.php +++ b/app/Repositories/UserGroups/Tag/TagRepository.php @@ -40,7 +40,7 @@ class TagRepository implements TagRepositoryInterface public function searchTag(array $query, int $limit): Collection { $search = $this->userGroup->tags(); - if (count($query) > 0) { + if (!empty($query)) { // split query on spaces just in case: $search->where(function (EloquentBuilder $q) use ($query): void { foreach ($query as $line) { diff --git a/app/Rules/IsFilterValueIn.php b/app/Rules/IsFilterValueIn.php index e167bdb79c0..a9a73c52105 100644 --- a/app/Rules/IsFilterValueIn.php +++ b/app/Rules/IsFilterValueIn.php @@ -50,6 +50,5 @@ public function validate(string $attribute, mixed $value, Closure $fail): void if (!in_array($value, $this->values, true)) { $fail('validation.filter_must_be_in')->translate(['filter' => $this->key, 'values' => implode(', ', $this->values)]); } - // $fail('validation.filter_not_string')->translate(['filter' => $this->key]); } } diff --git a/app/Services/Internal/Support/CreditRecalculateService.php b/app/Services/Internal/Support/CreditRecalculateService.php index da77efb15aa..01d5723cba3 100644 --- a/app/Services/Internal/Support/CreditRecalculateService.php +++ b/app/Services/Internal/Support/CreditRecalculateService.php @@ -172,7 +172,6 @@ private function processWorkAccount(Account $account): void } $startOfDebt = $this->repository->getOpeningBalanceAmount($account, false) ?? '0'; $leftOfDebt = app('steam')->positive($startOfDebt); - // Log::debug(sprintf('Start of debt is "%s", so initial left of debt is "%s"', app('steam')->bcround($startOfDebt, 2), app('steam')->bcround($leftOfDebt, 2))); /** @var AccountMetaFactory $factory */ $factory = app(AccountMetaFactory::class); @@ -180,7 +179,6 @@ private function processWorkAccount(Account $account): void // amount is positive or negative, doesn't matter. $factory->crud($account, 'start_of_debt', $startOfDebt); - // Log::debug(sprintf('Debt direction is "%s"', $direction)); // now loop all transactions (except opening balance and credit thing) $transactions = $account->transactions() @@ -189,11 +187,9 @@ private function processWorkAccount(Account $account): void ->get(['transactions.*']) ; $total = $transactions->count(); - // Log::debug(sprintf('Found %d transaction(s) to process.', $total)); /** @var Transaction $transaction */ foreach ($transactions as $transaction) { - // Log::debug(sprintf('[%d/%d] Processing transaction.', $index + 1, $total)); $leftOfDebt = $this->processTransaction($account, $direction, $transaction, $leftOfDebt); } $factory->crud($account, 'current_debt', $leftOfDebt); @@ -229,7 +225,6 @@ private function validateOpeningBalance(Account $account, TransactionJournal $op return; } - // Log::debug('Opening balance is valid'); } /** @@ -254,19 +249,15 @@ private function processTransaction(Account $account, string $direction, Transac $foreignCurrency = $transaction->foreignCurrency; $accountCurrency = $this->repository->getAccountCurrency($account); $type = $journal->transactionType->type; - // Log::debug(sprintf('Left of debt is: %s', app('steam')->bcround($leftOfDebt, 2))); if ('' === $direction) { - // Log::warning('Direction is empty, so do nothing.'); return $leftOfDebt; } if (TransactionTypeEnum::LIABILITY_CREDIT->value === $type || TransactionTypeEnum::OPENING_BALANCE->value === $type) { - // Log::warning(sprintf('Transaction type is "%s", so do nothing.', $type)); return $leftOfDebt; } - // Log::debug(sprintf('Liability direction is "%s"', $direction)); // amount to use depends on the currency: $usedAmount = $this->getAmountToUse($transaction, $accountCurrency, $foreignCurrency); @@ -278,52 +269,44 @@ private function processTransaction(Account $account, string $direction, Transac $usedAmount = app('steam')->positive($usedAmount); return bcadd($leftOfDebt, (string) $usedAmount); - // Log::debug(sprintf('Case 1 (withdrawal into credit liability): %s + %s = %s', app('steam')->bcround($leftOfDebt, 2), app('steam')->bcround($usedAmount, 2), app('steam')->bcround($result, 2))); } if ($isSameAccount && $isCredit && $this->isWithdrawalOut($usedAmount, $type)) { // case 2 $usedAmount = app('steam')->positive($usedAmount); return bcsub($leftOfDebt, (string) $usedAmount); - // Log::debug(sprintf('Case 2 (withdrawal away from liability): %s - %s = %s', app('steam')->bcround($leftOfDebt, 2), app('steam')->bcround($usedAmount, 2), app('steam')->bcround($result, 2))); } if ($isSameAccount && $isCredit && $this->isDepositOut($usedAmount, $type)) { // case 3 $usedAmount = app('steam')->positive($usedAmount); return bcsub($leftOfDebt, (string) $usedAmount); - // Log::debug(sprintf('Case 3 (deposit away from liability): %s - %s = %s', app('steam')->bcround($leftOfDebt, 2), app('steam')->bcround($usedAmount, 2), app('steam')->bcround($result, 2))); } if ($isSameAccount && $isCredit && $this->isDepositIn($usedAmount, $type)) { // case 4 $usedAmount = app('steam')->positive($usedAmount); return bcadd($leftOfDebt, (string) $usedAmount); - // Log::debug(sprintf('Case 4 (deposit into credit liability): %s + %s = %s', app('steam')->bcround($leftOfDebt, 2), app('steam')->bcround($usedAmount, 2), app('steam')->bcround($result, 2))); } if ($isSameAccount && $isCredit && $this->isTransferIn($usedAmount, $type)) { // case 5 $usedAmount = app('steam')->positive($usedAmount); return bcadd($leftOfDebt, (string) $usedAmount); - // Log::debug(sprintf('Case 5 (transfer into credit liability): %s + %s = %s', app('steam')->bcround($leftOfDebt, 2), app('steam')->bcround($usedAmount, 2), app('steam')->bcround($result, 2))); } if ($isSameAccount && $isDebit && $this->isWithdrawalIn($usedAmount, $type)) { // case 6 $usedAmount = app('steam')->positive($usedAmount); return bcsub($leftOfDebt, (string) $usedAmount); - // Log::debug(sprintf('Case 6 (withdrawal into debit liability): %s - %s = %s', app('steam')->bcround($leftOfDebt, 2), app('steam')->bcround($usedAmount, 2), app('steam')->bcround($result, 2))); } if ($isSameAccount && $isDebit && $this->isDepositOut($usedAmount, $type)) { // case 7 $usedAmount = app('steam')->positive($usedAmount); return bcadd($leftOfDebt, (string) $usedAmount); - // Log::debug(sprintf('Case 7 (deposit away from liability): %s + %s = %s', app('steam')->bcround($leftOfDebt, 2), app('steam')->bcround($usedAmount, 2), app('steam')->bcround($result, 2))); } if ($isSameAccount && $isDebit && $this->isWithdrawalOut($usedAmount, $type)) { // case 8 $usedAmount = app('steam')->positive($usedAmount); return bcadd($leftOfDebt, (string) $usedAmount); - // Log::debug(sprintf('Case 8 (withdrawal away from liability): %s + %s = %s', app('steam')->bcround($leftOfDebt, 2), app('steam')->bcround($usedAmount, 2), app('steam')->bcround($result, 2))); } if ($isSameAccount && $isDebit && $this->isTransferIn($usedAmount, $type)) { // case 9 @@ -346,7 +329,6 @@ private function processTransaction(Account $account, string $direction, Transac $usedAmount = app('steam')->negative($usedAmount); return bcadd($leftOfDebt, (string) $usedAmount); - // Log::debug(sprintf('Case X (all other cases): %s + %s = %s', app('steam')->bcround($leftOfDebt, 2), app('steam')->bcround($usedAmount, 2), app('steam')->bcround($result, 2))); } Log::warning(sprintf('[-1] Catch-all, should not happen. Left of debt = %s', app('steam')->bcround($leftOfDebt, 2))); @@ -357,10 +339,8 @@ private function processTransaction(Account $account, string $direction, Transac private function getAmountToUse(Transaction $transaction, TransactionCurrency $accountCurrency, ?TransactionCurrency $foreignCurrency): string { $usedAmount = $transaction->amount; - // Log::debug(sprintf('Amount of transaction is %s', app('steam')->bcround($usedAmount, 2))); if ($foreignCurrency instanceof TransactionCurrency && $foreignCurrency->id === $accountCurrency->id) { $usedAmount = $transaction->foreign_amount; - // Log::debug(sprintf('Overruled by foreign amount. Amount of transaction is now %s', app('steam')->bcround($usedAmount, 2))); } return $usedAmount; diff --git a/app/Services/Internal/Support/JournalServiceTrait.php b/app/Services/Internal/Support/JournalServiceTrait.php index d0de5db9df7..33a79999b4a 100644 --- a/app/Services/Internal/Support/JournalServiceTrait.php +++ b/app/Services/Internal/Support/JournalServiceTrait.php @@ -127,7 +127,7 @@ private function findAccountById(array $data, array $types): ?Account return $search; } - if (null !== $search && 0 === count($types)) { + if (null !== $search && empty($types)) { Log::debug( sprintf('Found "account_id" object: #%d, "%s" of type %s (2)', $search->id, $search->name, $search->accountType->type) ); @@ -288,7 +288,6 @@ private function createAccount(?Account $account, array $data, string $preferred } - // $data['name'] = $data['name'] ?? '(no name)'; $account = $this->accountRepository->store( [ diff --git a/app/Services/Internal/Support/RecurringTransactionTrait.php b/app/Services/Internal/Support/RecurringTransactionTrait.php index 6ac399f6e5d..be812578ee0 100644 --- a/app/Services/Internal/Support/RecurringTransactionTrait.php +++ b/app/Services/Internal/Support/RecurringTransactionTrait.php @@ -305,7 +305,7 @@ protected function updatePiggyBank(RecurrenceTransaction $transaction, int $pigg protected function updateTags(RecurrenceTransaction $transaction, array $tags): void { - if (0 !== count($tags)) { + if (!empty($tags)) { /** @var null|RecurrenceMeta $entry */ $entry = $transaction->recurrenceTransactionMeta()->where('name', 'tags')->first(); if (null === $entry) { @@ -314,7 +314,7 @@ protected function updateTags(RecurrenceTransaction $transaction, array $tags): $entry->value = json_encode($tags); $entry->save(); } - if (0 === count($tags)) { + if (empty($tags)) { // delete if present $transaction->recurrenceTransactionMeta()->where('name', 'tags')->delete(); } diff --git a/app/Services/Internal/Update/GroupUpdateService.php b/app/Services/Internal/Update/GroupUpdateService.php index 384f3049384..e656ec243d5 100644 --- a/app/Services/Internal/Update/GroupUpdateService.php +++ b/app/Services/Internal/Update/GroupUpdateService.php @@ -68,7 +68,7 @@ public function update(TransactionGroup $transactionGroup, array $data): Transac ); } - if (0 === count($transactions)) { + if (empty($transactions)) { Log::debug('No transactions submitted, do nothing.'); return $transactionGroup; @@ -94,7 +94,7 @@ public function update(TransactionGroup $transactionGroup, array $data): Transac $updated = $this->updateTransactions($transactionGroup, $transactions); Log::debug('Array of updated IDs: ', $updated); - if (0 === count($updated)) { + if (empty($updated)) { Log::error('There were no transactions updated or created. Will not delete anything.'); $transactionGroup->touch(); $transactionGroup->refresh(); @@ -105,7 +105,7 @@ public function update(TransactionGroup $transactionGroup, array $data): Transac $result = array_diff($existing, $updated); Log::debug('Result of DIFF: ', $result); - if (count($result) > 0) { + if (!empty($result)) { /** @var string $deletedId */ foreach ($result as $deletedId) { /** @var TransactionJournal $journal */ @@ -133,7 +133,7 @@ private function updateTransactionJournal( array $data ): void { Log::debug(sprintf('Now in %s', __METHOD__)); - if (0 === count($data)) { + if (empty($data)) { return; } if (1 === count($data) && array_key_exists('transaction_journal_id', $data)) { diff --git a/app/Services/Internal/Update/RecurrenceUpdateService.php b/app/Services/Internal/Update/RecurrenceUpdateService.php index 7cad86a146f..f9a54044227 100644 --- a/app/Services/Internal/Update/RecurrenceUpdateService.php +++ b/app/Services/Internal/Update/RecurrenceUpdateService.php @@ -129,7 +129,7 @@ private function setNoteText(Recurrence $recurrence, string $text): void private function updateRepetitions(Recurrence $recurrence, array $repetitions): void { $originalCount = $recurrence->recurrenceRepetitions()->count(); - if (0 === count($repetitions)) { + if (empty($repetitions)) { // won't drop repetition, rather avoid. return; } @@ -201,7 +201,7 @@ private function updateTransactions(Recurrence $recurrence, array $transactions) app('log')->debug('Now in updateTransactions()'); $originalCount = $recurrence->recurrenceTransactions()->count(); app('log')->debug(sprintf('Original count is %d', $originalCount)); - if (0 === count($transactions)) { + if (empty($transactions)) { // won't drop transactions, rather avoid. app('log')->warning('No transactions to update, too scared to continue!'); @@ -233,7 +233,7 @@ private function updateTransactions(Recurrence $recurrence, array $transactions) unset($first); } // if they are both empty, we can safely loop all combinations and update them. - if (0 === count($originalTransactions) && 0 === count($transactions)) { + if (empty($originalTransactions) && empty($transactions)) { foreach ($combinations as $combination) { $this->updateCombination($recurrence, $combination); } diff --git a/app/Support/Amount.php b/app/Support/Amount.php index c0c40ac390d..63941e5bff3 100644 --- a/app/Support/Amount.php +++ b/app/Support/Amount.php @@ -108,7 +108,6 @@ public function getAmountFromJournal(array $journal): string // fallback, the transaction has a foreign amount in $currency. if ($convertToPrimary && null !== $journal['foreign_amount'] && $currency->id === (int)$journal['foreign_currency_id']) { $amount = $journal['foreign_amount']; - // Log::debug(sprintf('Overruled, amount is now %s', $amount)); } return (string)$amount; diff --git a/app/Support/Export/ExportDataGenerator.php b/app/Support/Export/ExportDataGenerator.php index ad0f0b4b712..ef024a218b0 100644 --- a/app/Support/Export/ExportDataGenerator.php +++ b/app/Support/Export/ExportDataGenerator.php @@ -835,7 +835,7 @@ public function setAccounts(Collection $accounts): void private function mergeTags(array $tags): string { - if (0 === count($tags)) { + if (empty($tags)) { return ''; } $smol = []; diff --git a/app/Support/Http/Api/ExchangeRateConverter.php b/app/Support/Http/Api/ExchangeRateConverter.php index 1ff60dbaaa9..dac91fb991c 100644 --- a/app/Support/Http/Api/ExchangeRateConverter.php +++ b/app/Support/Http/Api/ExchangeRateConverter.php @@ -39,7 +39,6 @@ */ class ExchangeRateConverter { - // use ConvertsExchangeRates; private bool $ignoreSettings = false; private array $prepared = []; private int $queryCount = 0; @@ -79,12 +78,10 @@ public function enabled(): bool public function getCurrencyRate(TransactionCurrency $from, TransactionCurrency $to, Carbon $date): string { if (false === $this->enabled()) { - // Log::debug('ExchangeRateConverter: disabled, return "1".'); return '1'; } if ($from->id === $to->id) { - // Log::debug('ExchangeRateConverter: From and to are the same, return "1".'); return '1'; } @@ -232,24 +229,20 @@ private function getEuroRate(TransactionCurrency $currency, Carbon $date): strin $rate = $this->getFromDB($currency->id, $euroId, $date->format('Y-m-d')); if (null !== $rate) { - // app('log')->debug(sprintf('Rate for %s to EUR is %s.', $currency->code, $rate)); return $rate; } $rate = $this->getFromDB($euroId, $currency->id, $date->format('Y-m-d')); if (null !== $rate) { return bcdiv('1', $rate); - // app('log')->debug(sprintf('Inverted rate for %s to EUR is %s.', $currency->code, $rate)); // return $rate; } // grab backup values from config file: $backup = config(sprintf('cer.rates.%s', $currency->code)); if (null !== $backup) { return bcdiv('1', (string) $backup); - // app('log')->debug(sprintf('Backup rate for %s to EUR is %s.', $currency->code, $backup)); // return $backup; } - // app('log')->debug(sprintf('No rate for %s to EUR.', $currency->code)); return '0'; } diff --git a/app/Support/JsonApi/Enrichments/AccountEnrichment.php b/app/Support/JsonApi/Enrichments/AccountEnrichment.php index c1a162d8fc5..8112a402edd 100644 --- a/app/Support/JsonApi/Enrichments/AccountEnrichment.php +++ b/app/Support/JsonApi/Enrichments/AccountEnrichment.php @@ -290,7 +290,6 @@ private function appendCollectedData(): void // get the current balance: $date = $this->getDate(); - // $finalBalance = Steam::finalAccountBalance($item, $date, $this->primaryCurrency, $this->convertToPrimary); $finalBalance = $this->balances[$id]; Log::debug(sprintf('Call finalAccountBalance(%s) with date/time "%s"', var_export($this->convertToPrimary, true), $date->toIso8601String()), $finalBalance); diff --git a/app/Support/JsonApi/Enrichments/PiggyBankEnrichment.php b/app/Support/JsonApi/Enrichments/PiggyBankEnrichment.php index 62a0ecb11df..c2d61e76610 100644 --- a/app/Support/JsonApi/Enrichments/PiggyBankEnrichment.php +++ b/app/Support/JsonApi/Enrichments/PiggyBankEnrichment.php @@ -29,7 +29,6 @@ class PiggyBankEnrichment implements EnrichmentInterface private array $currencyIds = []; private array $currencies = []; private array $accountIds = []; - // private array $accountCurrencies = []; private array $notes = []; private array $mappedObjects = []; private TransactionCurrency $primaryCurrency; @@ -121,7 +120,6 @@ private function collectIds(): void if (!array_key_exists($currencyId, $this->currencies)) { $this->currencies[$currencyId] = TransactionCurrency::find($currencyId); } - // $this->accountCurrencies[$accountId] = $this->currencies[$currencyId]; } // get account info. diff --git a/app/Support/JsonApi/Enrichments/PiggyBankEventEnrichment.php b/app/Support/JsonApi/Enrichments/PiggyBankEventEnrichment.php index 76ea5318f4e..0abb6566fdd 100644 --- a/app/Support/JsonApi/Enrichments/PiggyBankEventEnrichment.php +++ b/app/Support/JsonApi/Enrichments/PiggyBankEventEnrichment.php @@ -28,12 +28,10 @@ class PiggyBankEventEnrichment implements EnrichmentInterface private array $piggyBankIds = []; private array $accountCurrencies = []; private array $currencies = []; - // private bool $convertToPrimary = false; // private TransactionCurrency $primaryCurrency; public function __construct() { - // $this->convertToPrimary = Amount::convertToPrimary(); // $this->primaryCurrency = Amount::getPrimaryCurrency(); } diff --git a/app/Support/JsonApi/Enrichments/RecurringEnrichment.php b/app/Support/JsonApi/Enrichments/RecurringEnrichment.php index 989e9ea9247..81ff6a9cf55 100644 --- a/app/Support/JsonApi/Enrichments/RecurringEnrichment.php +++ b/app/Support/JsonApi/Enrichments/RecurringEnrichment.php @@ -343,7 +343,6 @@ private function processTransactions(array $transactions): array $transaction['primary_currency_symbol'] = $this->primaryCurrency->symbol; $transaction['primary_currency_decimal_places'] = $this->primaryCurrency->decimal_places; - // $transaction['foreign_currency_id'] = null; $transaction['foreign_currency_name'] = null; $transaction['foreign_currency_code'] = null; $transaction['foreign_currency_symbol'] = null; @@ -480,7 +479,7 @@ private function collectTransactionMetaData(): void private function collectBillInfo(array $billIds): void { - if (0 === count($billIds)) { + if (empty($billIds)) { return; } $ids = Arr::pluck($billIds, 'bill_id'); @@ -498,7 +497,7 @@ private function collectBillInfo(array $billIds): void private function collectPiggyBankInfo(array $piggyBankIds): void { - if (0 === count($piggyBankIds)) { + if (empty($piggyBankIds)) { return; } $ids = Arr::pluck($piggyBankIds, 'piggy_bank_id'); @@ -516,7 +515,7 @@ private function collectPiggyBankInfo(array $piggyBankIds): void private function collectCategoryIdInfo(array $categoryIds): void { - if (0 === count($categoryIds)) { + if (empty($categoryIds)) { return; } $ids = Arr::pluck($categoryIds, 'category_id'); @@ -537,7 +536,7 @@ private function collectCategoryIdInfo(array $categoryIds): void */ private function collectCategoryNameInfo(array $categoryNames): void { - if (0 === count($categoryNames)) { + if (empty($categoryNames)) { return; } $factory = app(CategoryFactory::class); @@ -555,7 +554,7 @@ private function collectCategoryNameInfo(array $categoryNames): void private function collectBudgetInfo(array $budgetIds): void { - if (0 === count($budgetIds)) { + if (empty($budgetIds)) { return; } $ids = Arr::pluck($budgetIds, 'budget_id'); diff --git a/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php b/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php index 88307e028d8..ea40e357a0d 100644 --- a/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php +++ b/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php @@ -345,7 +345,6 @@ protected function lastPaidDate(Bill $subscription, Collection $dates, Carbon $d private function getLastPaidDate(array $paidData): ?Carbon { - // Log::debug('getLastPaidDate()'); $return = null; foreach ($paidData as $entry) { if (null !== $return) { diff --git a/app/Support/Navigation.php b/app/Support/Navigation.php index d88b01ba38b..bc9e5f7052d 100644 --- a/app/Support/Navigation.php +++ b/app/Support/Navigation.php @@ -162,7 +162,6 @@ public function blockPeriods(Carbon $start, Carbon $end, string $range): array public function startOfPeriod(Carbon $theDate, string $repeatFreq): Carbon { $date = clone $theDate; - // Log::debug(sprintf('Now in startOfPeriod("%s", "%s")', $date->toIso8601String(), $repeatFreq)); $functionMap = [ '1D' => 'startOfDay', 'daily' => 'startOfDay', @@ -187,7 +186,6 @@ public function startOfPeriod(Carbon $theDate, string $repeatFreq): Carbon if (array_key_exists($repeatFreq, $functionMap)) { $function = $functionMap[$repeatFreq]; - // Log::debug(sprintf('Function is ->%s()', $function)); if (array_key_exists($function, $parameterMap)) { // Log::debug(sprintf('Parameter map, function becomes ->%s(%s)', $function, implode(', ', $parameterMap[$function]))); $date->{$function}($parameterMap[$function][0]); // @phpstan-ignore-line @@ -204,7 +202,6 @@ public function startOfPeriod(Carbon $theDate, string $repeatFreq): Carbon if ('half-year' === $repeatFreq || '6M' === $repeatFreq) { $skipTo = $date->month > 7 ? 6 : 0; $date->startOfYear()->addMonths($skipTo); - // Log::debug(sprintf('Custom call for "%s": addMonths(%d)', $repeatFreq, $skipTo)); // Log::debug(sprintf('Result is "%s"', $date->toIso8601String())); return $date; @@ -221,13 +218,11 @@ public function startOfPeriod(Carbon $theDate, string $repeatFreq): Carbon default => null, }; if (null !== $result) { - // Log::debug(sprintf('Result is "%s"', $date->toIso8601String())); return $result; } if ('custom' === $repeatFreq) { - // Log::debug(sprintf('Custom, result is "%s"', $date->toIso8601String())); return $date; // the date is already at the start. } @@ -239,7 +234,6 @@ public function startOfPeriod(Carbon $theDate, string $repeatFreq): Carbon public function endOfPeriod(Carbon $end, string $repeatFreq): Carbon { $currentEnd = clone $end; - // Log::debug(sprintf('Now in endOfPeriod("%s", "%s").', $currentEnd->toIso8601String(), $repeatFreq)); $functionMap = [ '1D' => 'endOfDay', @@ -328,7 +322,6 @@ public function endOfPeriod(Carbon $end, string $repeatFreq): Carbon if (in_array($repeatFreq, $subDay, true)) { $currentEnd->subDay(); } - // Log::debug(sprintf('Final result: %s', $currentEnd->toIso8601String())); return $currentEnd; } @@ -494,14 +487,11 @@ public function preferredCarbonFormat(Carbon $start, Carbon $end): string { $format = 'Y-m-d'; $diff = $start->diffInMonths($end, true); - // Log::debug(sprintf('preferredCarbonFormat(%s, %s) = %f', $start->format('Y-m-d'), $end->format('Y-m-d'), $diff)); if ($diff >= 1.001 && $diff < 12.001) { - // Log::debug(sprintf('Return Y-m because %s', $diff)); $format = 'Y-m'; } if ($diff >= 12.001) { - // Log::debug(sprintf('Return Y because %s', $diff)); return 'Y'; } diff --git a/app/Support/Preferences.php b/app/Support/Preferences.php index 41dbe8f9dd2..242c581c9ea 100644 --- a/app/Support/Preferences.php +++ b/app/Support/Preferences.php @@ -91,7 +91,6 @@ public function getForUser(User $user, string $name, null|array|bool|int|string } if (null !== $preference) { - // Log::debug(sprintf('Found preference #%d for user #%d: %s', $preference->id, $user->id, $name)); return $preference; } @@ -220,7 +219,6 @@ public function getEncrypted(string $name, mixed $default = null): ?Preference return null; } if ('' === $result->data) { - // Log::warning(sprintf('Empty encrypted preference found: "%s"', $name)); return $result; } @@ -232,7 +230,6 @@ public function getEncrypted(string $name, mixed $default = null): ?Preference Log::debug('Set data to NULL'); $result->data = null; } - // Log::error(sprintf('Could not decrypt preference "%s": %s', $name, $e->getMessage())); return $result; } @@ -244,7 +241,6 @@ public function getEncryptedForUser(User $user, string $name, null|array|bool|in { $result = $this->getForUser($user, $name, $default); if ('' === $result->data) { - // Log::warning(sprintf('Empty encrypted preference found: "%s"', $name)); return $result; } @@ -256,7 +252,6 @@ public function getEncryptedForUser(User $user, string $name, null|array|bool|in Log::debug('Set data to NULL'); $result->data = null; } - // Log::error(sprintf('Could not decrypt preference "%s": %s', $name, $e->getMessage())); return $result; } @@ -287,7 +282,6 @@ public function lastActivity(): string $instance = PreferencesSingleton::getInstance(); $pref = $instance->getPreference('last_activity'); if (null !== $pref) { - // Log::debug(sprintf('Found last activity in singleton: %s', $pref)); return $pref; } $lastActivity = microtime(); diff --git a/app/Support/Report/Summarizer/TransactionSummarizer.php b/app/Support/Report/Summarizer/TransactionSummarizer.php index a1ab2abf07d..2a2e8bd8f0f 100644 --- a/app/Support/Report/Summarizer/TransactionSummarizer.php +++ b/app/Support/Report/Summarizer/TransactionSummarizer.php @@ -76,7 +76,6 @@ public function groupByCurrencyId(array $journals, string $method = 'negative', $usePrimary = $this->default->id !== (int) $journal['currency_id']; $useForeign = $this->default->id === (int) $journal['foreign_currency_id']; if ($usePrimary) { - // Log::debug(sprintf('Journal #%d switches to primary currency amount (original is %s)', $journal['transaction_journal_id'], $journal['currency_code'])); $field = 'pc_amount'; $currencyId = $this->default->id; $currencyName = $this->default->name; @@ -85,7 +84,6 @@ public function groupByCurrencyId(array $journals, string $method = 'negative', $currencyDecimalPlaces = $this->default->decimal_places; } if ($useForeign) { - // Log::debug(sprintf('Journal #%d switches to foreign amount (foreign is %s)', $journal['transaction_journal_id'], $journal['foreign_currency_code'])); $field = 'foreign_amount'; $currencyId = (int) $journal['foreign_currency_id']; $currencyName = $journal['foreign_currency_name']; @@ -145,7 +143,6 @@ public function groupByCurrencyId(array $journals, string $method = 'negative', } } - // $array[$currencyId]['sum'] = bcadd($array[$currencyId]['sum'], app('steam')->{$method}($amount)); // Log::debug(sprintf('Journal #%d adds amount %s %s', $journal['transaction_journal_id'], $currencyCode, $amount)); } Log::debug('End of sumExpenses.', $array); diff --git a/app/Support/Repositories/Recurring/FiltersWeekends.php b/app/Support/Repositories/Recurring/FiltersWeekends.php index 222879cc298..e93d9b9bbfc 100644 --- a/app/Support/Repositories/Recurring/FiltersWeekends.php +++ b/app/Support/Repositories/Recurring/FiltersWeekends.php @@ -53,7 +53,6 @@ protected function filterWeekends(RecurrenceRepetition $repetition, array $dates if (!$isWeekend) { $return[] = clone $date; - // app('log')->debug(sprintf('Date is %s, not a weekend date.', $date->format('D d M Y'))); continue; } @@ -80,7 +79,6 @@ protected function filterWeekends(RecurrenceRepetition $repetition, array $dates continue; } - // app('log')->debug(sprintf('Date is %s, removed from final result', $date->format('D d M Y'))); } // filter unique dates diff --git a/app/Support/Search/QueryParser/Node.php b/app/Support/Search/QueryParser/Node.php index 31412cfdab8..6114d91b44f 100644 --- a/app/Support/Search/QueryParser/Node.php +++ b/app/Support/Search/QueryParser/Node.php @@ -79,11 +79,9 @@ public function equals(self $compare): bool public function isProhibited(bool $flipFlag): bool { if ($flipFlag) { - // Log::debug(sprintf('This %s is (flipped) now prohibited: %s',get_class($this), var_export(!$this->prohibited, true))); return !$this->prohibited; } - // Log::debug(sprintf('This %s is (not flipped) now prohibited: %s',get_class($this), var_export($this->prohibited, true))); return $this->prohibited; } diff --git a/app/Support/Search/QueryParser/QueryParser.php b/app/Support/Search/QueryParser/QueryParser.php index c9072f970b1..93ec7c92a75 100644 --- a/app/Support/Search/QueryParser/QueryParser.php +++ b/app/Support/Search/QueryParser/QueryParser.php @@ -71,7 +71,6 @@ private function buildNextNode(bool $isSubquery): NodeResult while ($this->position < strlen($this->query)) { $char = $this->query[$this->position]; - // Log::debug(sprintf('Char #%d: %s', $this->position, $char)); // If we're in a quoted string, we treat all characters except another quote as ordinary characters if ($inQuotes) { diff --git a/app/Support/Steam.php b/app/Support/Steam.php index 0d1cca50fad..f4244507325 100644 --- a/app/Support/Steam.php +++ b/app/Support/Steam.php @@ -63,7 +63,6 @@ public function bcround(?string $number, int $precision = 0): string $number = sprintf('%.12f', $number); } - // Log::debug(sprintf('Trying bcround("%s",%d)', $number, $precision)); if (str_contains($number, '.')) { if ('-' !== $number[0]) { return bcadd($number, '0.'.str_repeat('0', $precision).'5', $precision); @@ -90,7 +89,7 @@ public function filterAccountBalances(array $total, Account $account, bool $conv public function filterAccountBalance(array $set, Account $account, bool $convertToPrimary, ?TransactionCurrency $currency = null): array { Log::debug(sprintf('filterAccountBalance(#%d)', $account->id), $set); - if (0 === count($set)) { + if (empty($set)) { Log::debug(sprintf('Return empty array for account #%d', $account->id)); return []; @@ -350,7 +349,7 @@ public function accountsBalancesOptimized(Collection $accounts, Carbon $date, ?T $accountSum = array_filter($arrayOfSums, function ($entry) use ($account) { return $entry['account_id'] === $account->id; }); - if (0 === count($accountSum)) { + if (empty($accountSum)) { $result[$account->id] = $return; continue; @@ -367,12 +366,10 @@ public function accountsBalancesOptimized(Collection $accounts, Carbon $date, ?T $return['balance'] = $sumsByCode[$currency->code] ?? '0'; if (!$convertToPrimary) { unset($return['pc_balance']); - // Log::debug(sprintf('Set balance to %s, unset pc_balance', $return['balance'])); } // if there is a request to convert, convert to "pc_balance" and use "balance" for whichever amount is in the primary currency. if ($convertToPrimary) { $return['pc_balance'] = $this->convertAllBalances($sumsByCode, $primary, $date); - // Log::debug(sprintf('Set pc_balance to %s', $return['pc_balance'])); } // either way, the balance is always combined with the virtual balance: @@ -383,16 +380,13 @@ public function accountsBalancesOptimized(Collection $accounts, Carbon $date, ?T $converter = new ExchangeRateConverter(); $pcVirtualBalance = $converter->convert($currency, $primary, $date, $virtualBalance); $return['pc_balance'] = bcadd($pcVirtualBalance, $return['pc_balance']); - // Log::debug(sprintf('Primary virtual balance makes the primary total %s', $return['pc_balance'])); } if (!$convertToPrimary) { // if not, also increase the balance + primary balance for consistency. $return['balance'] = bcadd($return['balance'], $virtualBalance); - // Log::debug(sprintf('Virtual balance makes the (primary currency) total %s', $return['balance'])); } $final = array_merge($return, $sumsByCode); $result[$account->id] = $final; - // Log::debug('Final balance is', $final); } return $result; @@ -420,9 +414,7 @@ public function finalAccountBalance(Account $account, Carbon $date, ?Transaction if ($cache->has()) { Log::debug(sprintf('CACHED finalAccountBalance(#%d, %s)', $account->id, $date->format('Y-m-d H:i:s'))); - // return $cache->get(); } - // Log::debug(sprintf('finalAccountBalance(#%d, %s)', $account->id, $date->format('Y-m-d H:i:s'))); if (null === $convertToPrimary) { $convertToPrimary = Amount::convertToPrimary($account->user); } @@ -457,7 +449,6 @@ public function finalAccountBalance(Account $account, Carbon $date, ?Transaction $return['balance'] = $others[$currency->code] ?? '0'; if (!$convertToPrimary) { unset($return['pc_balance']); - // Log::debug(sprintf('Set balance to %s, unset pc_balance', $return['balance'])); } // if there is a request to convert, convert to "pc_balance" and use "balance" for whichever amount is in the primary currency. if ($convertToPrimary) { @@ -473,15 +464,12 @@ public function finalAccountBalance(Account $account, Carbon $date, ?Transaction $converter = new ExchangeRateConverter(); $pcVirtualBalance = $converter->convert($currency, $primary, $date, $virtualBalance); $return['pc_balance'] = bcadd($pcVirtualBalance, $return['pc_balance']); - // Log::debug(sprintf('Primary virtual balance makes the primary total %s', $return['pc_balance'])); } if (!$convertToPrimary) { // if not, also increase the balance + primary balance for consistency. $return['balance'] = bcadd($return['balance'], $virtualBalance); - // Log::debug(sprintf('Virtual balance makes the (primary currency) total %s', $return['balance'])); } $final = array_merge($return, $others); - // Log::debug('Final balance is', $final); $cache->store($final); return $final; @@ -639,7 +627,6 @@ public function getLocaleArray(string $locale): array */ public function getSafePreviousUrl(): string { - // Log::debug(sprintf('getSafePreviousUrl: "%s"', session()->previousUrl())); return session()->previousUrl() ?? route('index'); } @@ -648,7 +635,6 @@ public function getSafePreviousUrl(): string */ public function getSafeUrl(string $unknownUrl, string $safeUrl): string { - // Log::debug(sprintf('getSafeUrl(%s, %s)', $unknownUrl, $safeUrl)); $returnUrl = $safeUrl; $unknownHost = parse_url($unknownUrl, PHP_URL_HOST); $safeHost = parse_url($safeUrl, PHP_URL_HOST); diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php index b2c4fc9bcb4..9f46bf679b8 100644 --- a/app/Support/Twig/General.php +++ b/app/Support/Twig/General.php @@ -104,7 +104,6 @@ static function (?Account $account): string { } return implode(', ', $strings); - // return app('steam')->balance($account, $date); } ); } diff --git a/app/TransactionRules/Actions/SetCategory.php b/app/TransactionRules/Actions/SetCategory.php index c546dcad1a9..590dd4d2d4a 100644 --- a/app/TransactionRules/Actions/SetCategory.php +++ b/app/TransactionRules/Actions/SetCategory.php @@ -85,7 +85,6 @@ public function actOnArray(array $journal): bool $oldCategory = $object->categories()->first(); $oldCategoryName = $oldCategory?->name; if ((int) $oldCategory?->id === $category->id) { - // event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.already_linked_to_category', ['name' => $category->name]))); return false; } diff --git a/app/TransactionRules/Engine/SearchRuleEngine.php b/app/TransactionRules/Engine/SearchRuleEngine.php index f8f8700a7e2..d01fe5618ac 100644 --- a/app/TransactionRules/Engine/SearchRuleEngine.php +++ b/app/TransactionRules/Engine/SearchRuleEngine.php @@ -295,7 +295,6 @@ static function (array $group) { } return sprintf('%d%s', $group['id'], $str); - // Log::debug(sprintf('Return key: %s ', $key)); } ); diff --git a/database/seeders/TransactionCurrencySeeder.php b/database/seeders/TransactionCurrencySeeder.php index e29de2d63c6..fc6bde601b7 100644 --- a/database/seeders/TransactionCurrencySeeder.php +++ b/database/seeders/TransactionCurrencySeeder.php @@ -68,7 +68,6 @@ public function run(): void $currencies[] = ['code' => 'JPY', 'name' => 'Japanese yen', 'symbol' => '¥', 'decimal_places' => 0]; $currencies[] = ['code' => 'CNY', 'name' => 'Chinese yuan', 'symbol' => '¥', 'decimal_places' => 2]; $currencies[] = ['code' => 'KRW', 'name' => 'South Korean won','symbol' => '₩', 'decimal_places' => 2,]; - // $currencies[] = ['code' => 'RMB', 'name' => 'Chinese yuan', 'symbol' => '¥', 'decimal_places' => 2]; $currencies[] = ['code' => 'RUB', 'name' => 'Russian ruble', 'symbol' => '₽', 'decimal_places' => 2]; $currencies[] = ['code' => 'INR', 'name' => 'Indian rupee', 'symbol' => '₹', 'decimal_places' => 2]; diff --git a/resources/assets/v1/src/app.js b/resources/assets/v1/src/app.js index 7a39d988a39..29e0a4a9bd0 100644 --- a/resources/assets/v1/src/app.js +++ b/resources/assets/v1/src/app.js @@ -24,7 +24,7 @@ */ try { - window.$ = window.jQuery = require('jquery'); + globalThis.$ = globalThis.jQuery = require('jquery'); require('bootstrap-sass'); } catch (e) { diff --git a/resources/assets/v1/src/app_vue.js b/resources/assets/v1/src/app_vue.js index 42910613f43..84702e496e4 100644 --- a/resources/assets/v1/src/app_vue.js +++ b/resources/assets/v1/src/app_vue.js @@ -25,8 +25,8 @@ import Vue from 'vue'; import VueI18n from 'vue-i18n' import * as uiv from 'uiv'; -window.vuei18n = VueI18n; -window.uiv = uiv; +globalThis.vuei18n = VueI18n; +globalThis.uiv = uiv; Vue.use(vuei18n); Vue.use(uiv); -window.Vue = Vue; +globalThis.Vue = Vue; diff --git a/resources/assets/v1/src/bootstrap.js b/resources/assets/v1/src/bootstrap.js index ecf244473ff..425566e5b20 100644 --- a/resources/assets/v1/src/bootstrap.js +++ b/resources/assets/v1/src/bootstrap.js @@ -24,9 +24,9 @@ * CSRF token as a header based on the value of the "XSRF" token cookie. */ -window.axios = require('axios'); +globalThis.axios = require('axios'); -window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; +globalThis.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; /** * Next we will register the CSRF Token as a common header with Axios so that @@ -37,7 +37,7 @@ window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; let token = document.head.querySelector('meta[name="csrf-token"]'); if (token) { - window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content; + globalThis.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content; } else { console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token'); } diff --git a/resources/assets/v1/src/components/administrations/Edit.vue b/resources/assets/v1/src/components/administrations/Edit.vue index 24890c96ea2..b901e52ebde 100644 --- a/resources/assets/v1/src/components/administrations/Edit.vue +++ b/resources/assets/v1/src/components/administrations/Edit.vue @@ -110,8 +110,8 @@ export default { }; }, mounted() { - const page = window.location.href.split('/'); - const administrationId = parseInt(page[page.length - 1]); + const page = globalThis.location.href.split('/'); + const administrationId = Number.parseInt(page[page.length - 1]); this.downloadAdministration(administrationId); }, methods: { @@ -121,7 +121,7 @@ export default { this.administration = { id: current.id, title: current.attributes.title, - currency_id: parseInt(current.attributes.primary_currency_id), + currency_id: Number.parseInt(current.attributes.primary_currency_id), currency_code: current.attributes.primary_currency_code, currency_name: current.attributes.primary_currency_name, }; @@ -143,13 +143,13 @@ export default { // collect data let data = { title: this.administration.title, - primary_currency_id: parseInt(this.administration.currency_id), + primary_currency_id: Number.parseInt(this.administration.currency_id), }; // post! axios.put('./api/v1/user-groups/' + this.administration.id, data).then((response) => { - let administrationId = parseInt(response.data.data.id); - window.location.href = './administrations?user_group_id=' + administrationId + '&message=updated'; + let administrationId = Number.parseInt(response.data.data.id); + globalThis.location.href = './administrations?user_group_id=' + administrationId + '&message=updated'; }).catch((error) => { this.error_message = error.response.data.message; diff --git a/resources/assets/v1/src/components/exchange-rates/Index.vue b/resources/assets/v1/src/components/exchange-rates/Index.vue index 2a656ae5df5..381e0d784e1 100644 --- a/resources/assets/v1/src/components/exchange-rates/Index.vue +++ b/resources/assets/v1/src/components/exchange-rates/Index.vue @@ -104,7 +104,7 @@ export default { } if (response.data.meta.pagination.current_page < response.data.meta.pagination.total_pages) { - this.downloadCurrencies(parseInt(response.data.meta.pagination.current_page) + 1); + this.downloadCurrencies(Number.parseInt(response.data.meta.pagination.current_page) + 1); } }); }, diff --git a/resources/assets/v1/src/components/exchange-rates/Rates.vue b/resources/assets/v1/src/components/exchange-rates/Rates.vue index 0ac13a94ad0..9aef1eaf058 100644 --- a/resources/assets/v1/src/components/exchange-rates/Rates.vue +++ b/resources/assets/v1/src/components/exchange-rates/Rates.vue @@ -217,14 +217,14 @@ export default { mounted() { // get from and to code from URL this.newDate = format(new Date, 'yyyy-MM-dd'); - let parts = window.location.href.split('/'); + let parts = globalThis.location.href.split('/'); this.from_code = parts[parts.length - 2]; this.to_code = parts[parts.length - 1]; - const params = new Proxy(new URLSearchParams(window.location.search), { + const params = new Proxy(new URLSearchParams(globalThis.location.search), { get: (searchParams, prop) => searchParams.get(prop), }); - this.page = parseInt(params.page ?? 1); + this.page = Number.parseInt(params.page ?? 1); this.downloadCurrencies(); @@ -276,12 +276,10 @@ export default { } }, deleteRate: function (index) { - // console.log(this.rates[index].key); let parts = this.spliceKey(this.rates[index].key); if (0 === parts.length) { return; } - // console.log(parts); // delete A to B axios.delete("./api/v1/exchange-rates/" + parts.from + '/' + parts.to + '/' + format(parts.date, 'yyyy-MM-dd')); @@ -316,7 +314,6 @@ export default { } }); axios.get("./api/v1/currencies/" + this.to_code).then((response) => { - // console.log(response.data.data); this.to = { id: response.data.data.id, code: response.data.data.attributes.code, @@ -339,16 +336,13 @@ export default { let rate_id = current.id; let inverse_id = '0'; let key = from_code + '_' + to_code + '_' + format(date, 'yyyy-MM-dd'); - // console.log('Key is now "' + key + '"'); // perhaps the returned rate is actually the inverse rate. if (from_code === this.to_code && to_code === this.from_code) { - // console.log('Inverse rate found!'); key = to_code + '_' + from_code + '_' + format(date, 'yyyy-MM-dd'); rate = ''; inverse = current.attributes.rate; inverse_id = current.id; - // console.log('Key updated to "' + key + '"'); } if (!this.tempRates.hasOwnProperty(key)) { @@ -378,10 +372,9 @@ export default { } } - this.totalPages = parseInt(response.data.meta.pagination.total_pages); + this.totalPages = Number.parseInt(response.data.meta.pagination.total_pages); this.loading = false; this.rates = Object.values(this.tempRates); - // console.log('Do not download more pages. Now on page ' + this.page + ' of ' + this.totalPages); }); } }, diff --git a/resources/assets/v1/src/components/form/Checkbox.vue b/resources/assets/v1/src/components/form/Checkbox.vue index 3d05fa8acb6..baf17e8855e 100644 --- a/resources/assets/v1/src/components/form/Checkbox.vue +++ b/resources/assets/v1/src/components/form/Checkbox.vue @@ -59,7 +59,6 @@ export default { }, methods: { handleInput() { - // console.log(this.active); this.$emit('input', this.active); }, }, diff --git a/resources/assets/v1/src/components/form/UserGroupCurrency.vue b/resources/assets/v1/src/components/form/UserGroupCurrency.vue index fbd483b69db..750b71f558b 100644 --- a/resources/assets/v1/src/components/form/UserGroupCurrency.vue +++ b/resources/assets/v1/src/components/form/UserGroupCurrency.vue @@ -95,7 +95,7 @@ export default { } if (response.data.meta.pagination.current_page < response.data.meta.pagination.total_pages) { - this.downloadCurrencies(parseInt(response.data.meta.pagination.current_page) + 1); + this.downloadCurrencies(Number.parseInt(response.data.meta.pagination.current_page) + 1); } }); }, diff --git a/resources/assets/v1/src/components/transactions/AccountSelect.vue b/resources/assets/v1/src/components/transactions/AccountSelect.vue index 4e3f3b1b1b1..7754df46116 100644 --- a/resources/assets/v1/src/components/transactions/AccountSelect.vue +++ b/resources/assets/v1/src/components/transactions/AccountSelect.vue @@ -107,13 +107,11 @@ export default { } }, ready() { - // console.log('ready(): this.name = this.accountName (' + this.accountName + ')'); this.name = this.accountName; }, mounted() { this.target = this.$refs.input; this.updateACURI(this.allowedTypes.join(',')); - // console.log('mounted(): this.name = this.accountName (' + this.accountName + ')'); this.name = this.accountName; this.triggerTransactionType(); }, @@ -123,7 +121,6 @@ export default { this.triggerTransactionType(); }, accountName() { - // console.log('AccountSelect watch accountName!'); this.name = this.accountName; }, accountTypeFilters() { @@ -176,22 +173,17 @@ export default { '?types=' + types + '&query='; - // console.log('Auto complete URI is now ' + this.accountAutoCompleteURI); }, hasError: function () { return this.error.length > 0; }, triggerTransactionType: function () { - // console.log('On triggerTransactionType(' + this.inputName + ')'); if (null === this.name) { - // console.log('this.name is NULL.'); } if (null === this.transactionType) { - // console.log('Transaction type is NULL.'); return; } if ('' === this.transactionType) { - // console.log('Transaction type is "".'); return; } this.inputDisabled = false; @@ -216,13 +208,10 @@ export default { } }, selectedItem: function (e) { - // console.log('In SelectedItem()'); if (typeof this.name === 'undefined') { - // console.log('Is undefined'); return; } if (typeof this.name === 'string') { - // console.log('Is a string.'); //this.trType = null; this.$emit('clear:value'); } @@ -233,7 +222,6 @@ export default { this.$emit('select:account', this.name); }, clearSource: function (e) { - // console.log('clearSource()'); //props.value = ''; this.name = ''; // some event? diff --git a/resources/assets/v1/src/components/transactions/Amount.vue b/resources/assets/v1/src/components/transactions/Amount.vue index d1b358e3111..7a5dcb9aba0 100644 --- a/resources/assets/v1/src/components/transactions/Amount.vue +++ b/resources/assets/v1/src/components/transactions/Amount.vue @@ -78,7 +78,6 @@ export default { return this.error.length > 0; }, changeData: function () { - //console.log('Triggered amount changeData()'); let transactionType = this.transactionType; // reset of all are empty: if (!transactionType && !this.source.name && !this.destination.name) { @@ -130,23 +129,18 @@ export default { }, watch: { source: function () { - // console.log('amount: watch source triggered'); this.changeData(); }, value: function () { - // console.log('amount: value changed'); }, destination: function () { - // console.log('amount: watch destination triggered'); this.changeData(); }, transactionType: function () { - // console.log('amount: watch transaction type triggered'); this.changeData(); } }, mounted() { - // console.log('amount: mounted'); this.changeData(); } } diff --git a/resources/assets/v1/src/components/transactions/Bill.vue b/resources/assets/v1/src/components/transactions/Bill.vue index fd2daa8645b..30c977ffa16 100644 --- a/resources/assets/v1/src/components/transactions/Bill.vue +++ b/resources/assets/v1/src/components/transactions/Bill.vue @@ -61,7 +61,6 @@ export default { no_bill: String, }, mounted() { - // console.log('bill: mounted'); this.loadBills(); }, data() { @@ -72,7 +71,6 @@ export default { }, watch: { value: function () { - // console.log('bill: value changed to ' + this.value); this.selected = this.value; } }, diff --git a/resources/assets/v1/src/components/transactions/Budget.vue b/resources/assets/v1/src/components/transactions/Budget.vue index 259752d435e..2d24445bc80 100644 --- a/resources/assets/v1/src/components/transactions/Budget.vue +++ b/resources/assets/v1/src/components/transactions/Budget.vue @@ -71,7 +71,6 @@ export default { }, watch: { value: function () { - // console.log('budget: value changed to ' + this.value); this.selected = this.value; } }, diff --git a/resources/assets/v1/src/components/transactions/Category.vue b/resources/assets/v1/src/components/transactions/Category.vue index 990798f6d7f..5c3f910e212 100644 --- a/resources/assets/v1/src/components/transactions/Category.vue +++ b/resources/assets/v1/src/components/transactions/Category.vue @@ -145,7 +145,6 @@ export default { }, clearCategory: function () { - //props.value = ''; this.name = ''; this.$refs.input.value = ''; this.$emit('input', this.$refs.input.value); @@ -169,7 +168,6 @@ export default { handleEnter: function (e) { // TODO feels sloppy if (e.keyCode === 13) { - //e.preventDefault(); } } } diff --git a/resources/assets/v1/src/components/transactions/CreateTransaction.vue b/resources/assets/v1/src/components/transactions/CreateTransaction.vue index c1969353be3..6cbabe5e883 100644 --- a/resources/assets/v1/src/components/transactions/CreateTransaction.vue +++ b/resources/assets/v1/src/components/transactions/CreateTransaction.vue @@ -280,23 +280,23 @@ export default { }, methods: { prefillSourceAccount() { - if (0 === window.sourceId) { + if (0 === globalThis.sourceId) { return; } - this.getAccount(window.sourceId, 'source_account'); + this.getAccount(globalThis.sourceId, 'source_account'); }, prefillDestinationAccount() { if (0 === destinationId) { return; } - this.getAccount(window.destinationId, 'destination_account'); + this.getAccount(globalThis.destinationId, 'destination_account'); }, getAccount(accountId, slot) { const uri = './api/v1/accounts/' + accountId + '?_token=' + document.head.querySelector('meta[name="csrf-token"]').content; axios.get(uri).then(response => { let model = response.data.data.attributes; model.type = this.fullAccountType(model.type, model.liability_type); - model.id = parseInt(response.data.data.id); + model.id = Number.parseInt(response.data.data.id); if ('source_account' === slot) { this.selectedSourceAccount(0, model); } @@ -323,7 +323,6 @@ export default { return arr[searchType] ?? searchType; }, convertData: function () { - // console.log('Now in convertData()'); let data = { 'apply_rules': this.applyRules, 'fire_webhooks': this.fireWebhooks, @@ -344,7 +343,6 @@ export default { // the presence of a source or destination account firstSource = this.transactions[0].source_account.type; firstDestination = this.transactions[0].destination_account.type; - // console.log('Type of first source is ' + firstSource); if ('invalid' === transactionType && ['asset', 'Asset account', 'Loan', 'Debt', 'Mortgage'].includes(firstSource)) { transactionType = 'withdrawal'; @@ -368,7 +366,6 @@ export default { return data; }, convertDataRow(row, index, transactionType) { - // console.log('Now in convertDataRow()'); let tagList = []; let foreignAmount = null; let foreignCurrency = null; @@ -391,12 +388,12 @@ export default { // if type is 'withdrawal' and destination is empty, cash withdrawal. if (transactionType === 'withdrawal' && '' === destName) { - destId = window.cashAccountId; + destId = globalThis.cashAccountId; } // if type is 'deposit' and source is empty, cash deposit. if (transactionType === 'deposit' && '' === sourceName) { - sourceId = window.cashAccountId; + sourceId = globalThis.cashAccountId; } // if index is over 0 and type is withdrawal or transfer, take source from index 0. @@ -420,7 +417,7 @@ export default { } // set foreign currency info: - if (row.foreign_amount.amount !== '' && parseFloat(row.foreign_amount.amount) !== .00) { + if (row.foreign_amount.amount !== '' && Number.parseFloat(row.foreign_amount.amount) !== .00) { foreignAmount = row.foreign_amount.amount; foreignCurrency = row.foreign_amount.currency_id; } @@ -480,20 +477,19 @@ export default { currentArray.foreign_currency_id = foreignCurrency; } // set budget id and piggy ID. - if (parseInt(row.budget) > 0) { - currentArray.budget_id = parseInt(row.budget); + if (Number.parseInt(row.budget) > 0) { + currentArray.budget_id = Number.parseInt(row.budget); } - if (parseInt(row.bill) > 0) { - currentArray.bill_id = parseInt(row.bill); + if (Number.parseInt(row.bill) > 0) { + currentArray.bill_id = Number.parseInt(row.bill); } - if (parseInt(row.piggy_bank) > 0) { - currentArray.piggy_bank_id = parseInt(row.piggy_bank); + if (Number.parseInt(row.piggy_bank) > 0) { + currentArray.piggy_bank_id = Number.parseInt(row.piggy_bank); } return currentArray; }, // submit transaction submit(e) { - // console.log('Now in submit()'); const uri = './api/v1/transactions?_token=' + document.head.querySelector('meta[name="csrf-token"]').content; const data = this.convertData(); @@ -504,7 +500,6 @@ export default { // console.log('Did a successful POST'); // this method will ultimately send the user on (or not). if (0 === this.collectAttachmentData(response)) { - // console.log('Will now go to redirectUser()'); this.redirectUser(response.data.data.id, response.data.data); } }).catch(error => { @@ -530,7 +525,6 @@ export default { return div.innerHTML; }, redirectUser(groupId, transactionData) { - // console.log('In redirectUser()'); // console.log(transactionData); let title = null === transactionData.attributes.group_title ? transactionData.attributes.transactions[0].description : transactionData.attributes.group_title; // console.log('Title is "' + title + '"'); @@ -547,7 +541,6 @@ export default { this.resetTransactions(); // do a short time out? setTimeout(() => this.addTransactionToArray(), 50); - //this.addTransactionToArray(); } // clear errors: @@ -557,13 +550,11 @@ export default { let button = $('#submitButton'); button.removeAttr('disabled'); } else { - //console.log('Will redirect to previous URL. (' + previousUrl + ')'); - window.location.href = window.previousUrl + '?transaction_group_id=' + groupId + '&message=created'; + globalThis.location.href = globalThis.previousUrl + '?transaction_group_id=' + groupId + '&message=created'; } }, collectAttachmentData(response) { - // console.log('Now incollectAttachmentData()'); let groupId = response.data.data.id; // reverse list of transactions? @@ -594,7 +585,6 @@ export default { } } let count = toBeUploaded.length; - // console.log('Found ' + toBeUploaded.length + ' attachments.'); // loop all uploads. for (const key in toBeUploaded) { @@ -638,31 +628,26 @@ export default { }; axios.post(uri, data) .then(response => { - // console.log('Created attachment #' + key); // console.log('Uploading attachment #' + key); const uploadUri = './api/v1/attachments/' + response.data.data.id + '/upload'; axios.post(uploadUri, fileData[key].content) .then(attachmentResponse => { - // console.log('Uploaded attachment #' + key); uploads++; if (uploads === count) { // finally we can redirect the user onwards. // console.log('FINAL UPLOAD'); this.redirectUser(groupId, transactionData); } - // console.log('Upload complete!'); return true; }).catch(error => { console.error('Could not upload'); console.error(error); - // console.log('Uploaded attachment #' + key); uploads++; if (uploads === count) { // finally we can redirect the user onwards. // console.log('FINAL UPLOAD'); this.redirectUser(groupId, transactionData); } - // console.log('Upload complete!'); return false; }); }).catch(error => { @@ -674,7 +659,6 @@ export default { // console.log('FINAL UPLOAD'); this.redirectUser(groupId, transactionData); } - // console.log('Upload complete!'); return false; }); } @@ -686,7 +670,6 @@ export default { setDefaultErrors: function () { for (const key in this.transactions) { if (this.transactions.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) { - // console.log('Set default errors for key ' + key); //this.transactions[key].description this.transactions[key].errors = { source_account: [], @@ -737,7 +720,7 @@ export default { } if (key !== 'group_title') { // lol dumbest way to explode "transactions.0.something" ever. - transactionIndex = parseInt(key.split('.')[1]); + transactionIndex = Number.parseInt(key.split('.')[1]); fieldName = key.split('.')[2]; // set error in this object thing. switch (fieldName) { @@ -784,13 +767,11 @@ export default { } }, resetTransactions: function () { - // console.log('Now in resetTransactions()'); this.transactions = []; this.group_title = ''; }, addTransactionToArray: function (e) { - // console.log('Now in addTransactionToArray()'); this.transactions.push({ description: "", date: "", @@ -871,7 +852,6 @@ export default { let today = new Date(); this.transactions[0].date = today.getFullYear() + '-' + ("0" + (today.getMonth() + 1)).slice(-2) + '-' + ("0" + today.getDate()).slice(-2) + 'T'+ ("0" + today.getHours()).slice(-2) +':' + ("0" + today.getMinutes()).slice(-2); - //console.log(this.transactions[0].date); // call for extra clear thing: // this.clearSource(0); @@ -887,7 +867,6 @@ export default { deleteTransaction: function (index, event) { event.preventDefault(); - // console.log('Remove transaction.'); this.transactions.splice(index, 1); }, limitSourceType: function (type) { @@ -904,7 +883,6 @@ export default { }, selectedSourceAccount: function (index, model) { - // console.log('Now in selectedSourceAccount()'); if (typeof model === 'string') { //console.log('model is string.') // cant change types, only name. @@ -930,13 +908,11 @@ export default { } // force types on destination selector. - this.transactions[index].destination_account.allowed_types = window.allowedOpposingTypes.source[model.type]; + this.transactions[index].destination_account.allowed_types = globalThis.allowedOpposingTypes.source[model.type]; } - //console.log('Transactions:'); //console.log(this.transactions); }, selectedDestinationAccount: function (index, model) { - // console.log('Now in selectedDestinationAccount()'); if (typeof model === 'string') { // cant change types, only name. this.transactions[index].destination_account.name = model; @@ -960,7 +936,7 @@ export default { } // force types on destination selector. - this.transactions[index].source_account.allowed_types = window.allowedOpposingTypes.destination[model.type]; + this.transactions[index].source_account.allowed_types = globalThis.allowedOpposingTypes.destination[model.type]; } }, clearSource: function (index) { diff --git a/resources/assets/v1/src/components/transactions/CustomAttachments.vue b/resources/assets/v1/src/components/transactions/CustomAttachments.vue index b140dbda4d2..de64ddde552 100644 --- a/resources/assets/v1/src/components/transactions/CustomAttachments.vue +++ b/resources/assets/v1/src/components/transactions/CustomAttachments.vue @@ -56,7 +56,6 @@ export default { error: Array }, mounted: function () { - // window.addEventListener('paste', e => { // this.$refs.input.files = e.clipboardData.files; // }); }, diff --git a/resources/assets/v1/src/components/transactions/CustomDate.vue b/resources/assets/v1/src/components/transactions/CustomDate.vue index f90617dfc9e..dc389e93cd2 100644 --- a/resources/assets/v1/src/components/transactions/CustomDate.vue +++ b/resources/assets/v1/src/components/transactions/CustomDate.vue @@ -64,7 +64,6 @@ export default { return this.error.length > 0; }, clearDate: function () { - //props.value = ''; this.name = ''; this.$refs.date.value = ''; this.$emit('input', this.$refs.date.value); diff --git a/resources/assets/v1/src/components/transactions/CustomString.vue b/resources/assets/v1/src/components/transactions/CustomString.vue index 75dd3fb8c36..4fde39161b9 100644 --- a/resources/assets/v1/src/components/transactions/CustomString.vue +++ b/resources/assets/v1/src/components/transactions/CustomString.vue @@ -61,7 +61,6 @@ export default { this.$emit('input', this.$refs.str.value); }, clearField: function () { - //props.value = ''; this.name = ''; this.$refs.str.value = ''; this.$emit('input', this.$refs.str.value); diff --git a/resources/assets/v1/src/components/transactions/CustomTransactionFields.vue b/resources/assets/v1/src/components/transactions/CustomTransactionFields.vue index e55fcf00146..6abfd877dd0 100644 --- a/resources/assets/v1/src/components/transactions/CustomTransactionFields.vue +++ b/resources/assets/v1/src/components/transactions/CustomTransactionFields.vue @@ -119,7 +119,6 @@ export default { }, getPreference() { - // Vue.component('custom-date', (resolve) => { // console.log('loaded'); // }); diff --git a/resources/assets/v1/src/components/transactions/EditTransaction.vue b/resources/assets/v1/src/components/transactions/EditTransaction.vue index 1855355d7c9..da48a1708a8 100644 --- a/resources/assets/v1/src/components/transactions/EditTransaction.vue +++ b/resources/assets/v1/src/components/transactions/EditTransaction.vue @@ -287,11 +287,9 @@ export default { groupId: Number }, mounted() { - // console.log('EditTransaction: mounted()'); this.getGroup(); }, ready() { - // console.log('EditTransaction: ready()'); }, methods: { positiveAmount(amount) { @@ -337,7 +335,6 @@ export default { this.transactions[index].destination_account.name = model; return; } - // console.log('selectedDestinationAccount'); this.transactions[index].destination_account = { id: model.id, name: model.name, @@ -354,7 +351,6 @@ export default { this.transactions[index].destination_account.currency_code = model.account_currency_code; this.transactions[index].destination_account.currency_decimal_places = model.account_currency_decimal_places; } - // console.log('Selected destination account currency ID = ' + this.transactions[index].destination_account.currency_id); }, clearSource(index) { // reset source account: @@ -407,17 +403,14 @@ export default { this.selectedSourceAccount(index, this.transactions[index].source_account); } - // console.log('Destination allowed types after:'); // console.log(this.transactions[index].destination_account.allowed_types); }, getGroup() { - // console.log('EditTransaction: getGroup()'); - const page = window.location.href.split('/'); - const groupId = parseInt(page[page.length - 1]); + const page = globalThis.location.href.split('/'); + const groupId = Number.parseInt(page[page.length - 1]); const uri = './api/v1/transactions/' + groupId; - // console.log(uri); // fill in transactions array. axios.get(uri) @@ -430,7 +423,6 @@ export default { }); }, processIncomingGroup(data) { - // console.log('EditTransaction: processIncomingGroup()'); this.group_title = data.attributes.group_title; let transactions = data.attributes.transactions.reverse(); for (let key in transactions) { @@ -448,7 +440,6 @@ export default { return null; }, processIncomingGroupRow(transaction) { - //console.log('EditTransaction: processIncomingGroupRow()'); this.setTransactionType(transaction.type); if (true === transaction.reconciled) { @@ -461,13 +452,12 @@ export default { newTags.push({text: transaction.tags[key], tiClasses: []}); } } - // console.log('source allowed types for a ' + transaction.type); - //console.log(window.expectedSourceTypes.source[transaction.type]); - // console.log(window.expectedSourceTypes.source[this.ucFirst(transaction.type)]); + //console.log(globalThis.expectedSourceTypes.source[transaction.type]); + // console.log(globalThis.expectedSourceTypes.source[this.ucFirst(transaction.type)]); // console.log('destination allowed types for a ' + transaction.type); - // console.log(window.expectedSourceTypes.destination[this.ucFirst(transaction.type)]); - if (typeof window.expectedSourceTypes === 'undefined') { - console.error('window.expectedSourceTypes is unexpectedly empty.') + // console.log(globalThis.expectedSourceTypes.destination[this.ucFirst(transaction.type)]); + if (typeof globalThis.expectedSourceTypes === 'undefined') { + console.error('globalThis.expectedSourceTypes is unexpectedly empty.') } let result = { transaction_journal_id: transaction.transaction_journal_id, @@ -529,7 +519,7 @@ export default { currency_name: transaction.currency_name, currency_code: transaction.currency_code, currency_decimal_places: transaction.currency_decimal_places, - allowed_types: window.expectedSourceTypes.source[this.ucFirst(transaction.type)] + allowed_types: globalThis.expectedSourceTypes.source[this.ucFirst(transaction.type)] }, destination_account: { id: transaction.destination_id, @@ -539,10 +529,9 @@ export default { currency_name: transaction.currency_name, currency_code: transaction.currency_code, currency_decimal_places: transaction.currency_decimal_places, - allowed_types: window.expectedSourceTypes.destination[this.ucFirst(transaction.type)] + allowed_types: globalThis.expectedSourceTypes.destination[this.ucFirst(transaction.type)] } }; - // console.log('Source currency id is ' + result.source_account.currency_id); // console.log('Destination currency id is ' + result.destination_account.currency_id); // if transaction type is transfer, the destination currency_id etc. MUST match the actual account currency info. @@ -555,13 +544,11 @@ export default { result.destination_account.currency_name = transaction.foreign_currency_name; result.destination_account.currency_code = transaction.foreign_currency_code; result.destination_account.currency_decimal_places = transaction.foreign_currency_decimal_places; - // console.log('Set destination currency_id to ' + result.destination_account.currency_id); } // if the transaction type is a deposit, but the source account is a liability, the source // account currency must not be overruled. if('deposit' === transaction.type && ['Loan', 'Debt', 'Mortgage'].includes(transaction.source_type)) { - // console.log('Overrule for deposit from liability to ' + transaction.foreign_currency_id); result.destination_account.currency_id = transaction.foreign_currency_id; result.destination_account.currency_name = transaction.foreign_currency_name; result.destination_account.currency_code = transaction.foreign_currency_code; @@ -575,19 +562,16 @@ export default { this.transactions.push(result); }, limitSourceType: function (type) { - // let i; // for (i = 0; i < this.transactions.length; i++) { // this.transactions[i].source_account.allowed_types = [type]; // } }, limitDestinationType: function (type) { - // let i; // for (i = 0; i < this.transactions.length; i++) { // this.transactions[i].destination_account.allowed_types = [type]; // } }, convertData: function () { - // console.log('start of convertData'); let data = { 'apply_rules': this.applyRules, 'fire_webhooks': this.fireWebhooks, @@ -610,12 +594,10 @@ export default { firstDestination = this.transactions[0].destination_account.type; if ('invalid' === transactionType && ['Asset account', 'Loan', 'Debt', 'Mortgage'].includes(firstSource)) { - //console.log('Assumed this is a withdrawal.'); transactionType = 'withdrawal'; } if ('invalid' === transactionType && ['Asset account', 'Loan', 'Debt', 'Mortgage'].includes(firstDestination)) { - //console.log('Assumed this is a deposit.'); transactionType = 'deposit'; } @@ -627,17 +609,14 @@ export default { } // if transaction type is deposit BUT the source account is a liability, the currency ID must be the SOURCE account ID. if ('deposit' === transactionType && ['Loan', 'Debt', 'Mortgage'].includes(firstSource)) { - // console.log('Overruled currency ID to ' + this.transactions[0].source_account.currency_id); currencyId = this.transactions[0].source_account.currency_id; } - // console.log('Final currency ID = ' + currencyId); for (let key in this.transactions) { if (this.transactions.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) { data.transactions.push(this.convertDataRow(this.transactions[key], key, transactionType, currencyId)); } } - //console.log(data); // console.log('end of convertData'); return data; }, @@ -667,7 +646,6 @@ export default { // } row.currency_id = currencyId; - // console.log('Final currency ID = ' + currencyId); date = row.date; if (index > 0) { @@ -676,12 +654,12 @@ export default { // if type is 'withdrawal' and destination is empty, cash withdrawal. if (transactionType === 'withdrawal' && '' === destName) { - destId = window.cashAccountId; + destId = globalThis.cashAccountId; } // if type is 'deposit' and source is empty, cash deposit. if (transactionType === 'deposit' && '' === sourceName) { - sourceId = window.cashAccountId; + sourceId = globalThis.cashAccountId; } // if index is over 0 and type is withdrawal or transfer, take source from index 0. @@ -705,12 +683,11 @@ export default { } } // set foreign currency info: - if (typeof row.foreign_amount.amount !== 'undefined' && row.foreign_amount.amount.toString() !== '' && parseFloat(row.foreign_amount.amount) !== .00) { + if (typeof row.foreign_amount.amount !== 'undefined' && row.foreign_amount.amount.toString() !== '' && Number.parseFloat(row.foreign_amount.amount) !== .00) { foreignAmount = row.foreign_amount.amount; foreignCurrency = row.foreign_amount.currency_id; } if (foreignCurrency === row.currency_id) { - // console.log('reset foreign currencyto NULL because ' + foreignCurrency + ' = ' + row.currency_id); foreignAmount = null; foreignCurrency = null; } @@ -729,7 +706,6 @@ export default { row.amount = String(row.amount).replace(',', '.'); } - // console.log('Reconciled is ' + row.reconciled); currentArray = { @@ -772,16 +748,16 @@ export default { } // set budget id and piggy ID. - currentArray.budget_id = parseInt(row.budget); - if (parseInt(row.bill) > 0) { - currentArray.bill_id = parseInt(row.bill); + currentArray.budget_id = Number.parseInt(row.budget); + if (Number.parseInt(row.bill) > 0) { + currentArray.bill_id = Number.parseInt(row.bill); } - if (0 === parseInt(row.bill)) { + if (0 === Number.parseInt(row.bill)) { currentArray.bill_id = null; } - if (parseInt(row.piggy_bank) > 0) { - currentArray.piggy_bank_id = parseInt(row.piggy_bank); + if (Number.parseInt(row.piggy_bank) > 0) { + currentArray.piggy_bank_id = Number.parseInt(row.piggy_bank); } if (this.isReconciled && !this.storeAsNew && true === row.reconciled) { // drop content from array: @@ -802,12 +778,11 @@ export default { return currentArray; }, submit: function (e) { - // console.log('Submit!'); let button = $('#submitButton'); button.prop("disabled", true); - const page = window.location.href.split('/'); - const groupId = parseInt(page[page.length - 1]); + const page = globalThis.location.href.split('/'); + const groupId = Number.parseInt(page[page.length - 1]); let uri = './api/v1/transactions/' + groupId + '?_token=' + document.head.querySelector('meta[name="csrf-token"]').content; let method = 'PUT'; if (this.storeAsNew) { @@ -817,13 +792,11 @@ export default { method = 'POST'; } const data = this.convertData(); - // console.log('POST!'); axios({ method: method, url: uri, data: data, }).then(response => { - // console.log('Response!'); if (0 === this.collectAttachmentData(response)) { const title = response.data.data.attributes.group_title ?? response.data.data.attributes.transactions[0].description; this.redirectUser(response.data.data.id, title); @@ -840,11 +813,9 @@ export default { if (e) { e.preventDefault(); } - // console.log('DONE with method.'); }, redirectUser(groupId, title) { - // console.log('Now in redirectUser'); if (this.returnAfter) { this.setDefaultErrors(); // do message if update or new: @@ -863,16 +834,14 @@ export default { } } else { if (this.storeAsNew) { - window.location.href = window.previousUrl + '?transaction_group_id=' + groupId + '&message=created'; + globalThis.location.href = globalThis.previousUrl + '?transaction_group_id=' + groupId + '&message=created'; } else { - window.location.href = window.previousUrl + '?transaction_group_id=' + groupId + '&message=updated'; + globalThis.location.href = globalThis.previousUrl + '?transaction_group_id=' + groupId + '&message=updated'; } } - // console.log('End of redirectUser'); }, collectAttachmentData(response) { - // console.log('Now incollectAttachmentData()'); let groupId = response.data.data.id; // array of all files to be uploaded: @@ -904,7 +873,6 @@ export default { } } let count = toBeUploaded.length; - // console.log('Found ' + toBeUploaded.length + ' attachments.'); // loop all uploads. for (const key in toBeUploaded) { @@ -930,7 +898,6 @@ export default { })(toBeUploaded[key], key, this); } } - // console.log('Done with collectAttachmentData()'); return count; }, @@ -949,19 +916,16 @@ export default { }; axios.post(uri, data) .then(response => { - // console.log('Created attachment #' + key); // console.log('Uploading attachment #' + key); const uploadUri = './api/v1/attachments/' + response.data.data.id + '/upload'; axios.post(uploadUri, fileData[key].content) .then(secondResponse => { - // console.log('Uploaded attachment #' + key); uploads++; if (uploads === count) { // finally we can redirect the user onwards. // console.log('FINAL UPLOAD'); this.redirectUser(groupId, null); } - // console.log('Upload complete!'); return true; }).catch(error => { console.error('Could not upload file.'); @@ -971,7 +935,6 @@ export default { if (uploads === count) { this.redirectUser(groupId, null); } - // console.error(error); return false; }); }).catch(error => { @@ -983,7 +946,6 @@ export default { // console.log('FINAL UPLOAD'); this.redirectUser(groupId, null); } - // console.log('Upload complete!'); return false; }); } @@ -1090,12 +1052,10 @@ export default { // console.log('Transactions length = ' + count); // also set accounts from previous entry, if present. if (this.transactions.length > 1) { - // console.log('Adding split.'); this.transactions[count - 1].source_account = this.transactions[count - 2].source_account; this.transactions[count - 1].destination_account = this.transactions[count - 2].destination_account; this.transactions[count - 1].date = this.transactions[count - 2].date; } - // console.log('Transactions length now = ' + this.transactions.length); if (e) { e.preventDefault(); @@ -1119,7 +1079,7 @@ export default { } if (key !== 'group_title') { // lol dumbest way to explode "transactions.0.something" ever. - transactionIndex = parseInt(key.split('.')[1]); + transactionIndex = Number.parseInt(key.split('.')[1]); fieldName = key.split('.')[2]; // set error in this object thing. switch (fieldName) { @@ -1133,7 +1093,6 @@ export default { this.transactions[transactionIndex].errors[fieldName] = errors.errors[key]; break; case 'external_url': - //console.log('Found ext error in field "' + fieldName + '": ' + errors.errors[key]); this.transactions[transactionIndex].errors.custom_errors[fieldName] = errors.errors[key]; break; case 'source_name': diff --git a/resources/assets/v1/src/components/transactions/ForeignAmountSelect.vue b/resources/assets/v1/src/components/transactions/ForeignAmountSelect.vue index 3f61bec9ede..93c4eb38d66 100644 --- a/resources/assets/v1/src/components/transactions/ForeignAmountSelect.vue +++ b/resources/assets/v1/src/components/transactions/ForeignAmountSelect.vue @@ -32,7 +32,7 @@