Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Add debug info and update routine for multiple accounts.
James Cole039e8d6e1757
diff --git a/app/Factory/TransactionFactory.php b/app/Factory/TransactionFactory.phpindex d908467baf..c7944e8198 100644--- a/app/Factory/TransactionFactory.php+++ b/app/Factory/TransactionFactory.php@@ -62,6 +62,7 @@ class TransactionFactorythrow new FireflyException('Cannot store transaction without currency information.');}$data['foreign_amount'] = '' === (string)$data['foreign_amount'] ? null : $data['foreign_amount'];+ Log::debug(sprintf('Create transaction for account #%d ("%s") with amount %s', $data['account']->id, $data['account']->name, $data['amount']));return Transaction::create([@@ -96,10 +97,12 @@ class TransactionFactory// type of source account depends on journal type:$sourceType = $this->accountType($journal, 'source');+ Log::debug(sprintf('Expect source account to be of type %s', $sourceType));$sourceAccount = $this->findAccount($sourceType, $data['source_id'], $data['source_name']);// same for destination account:$destinationType = $this->accountType($journal, 'destination');+ Log::debug(sprintf('Expect source destination to be of type %s', $destinationType));$destinationAccount = $this->findAccount($destinationType, $data['destination_id'], $data['destination_name']);// first make a "negative" (source) transaction based on the data in the array.$source = $this->create(diff --git a/app/Factory/TransactionJournalFactory.php b/app/Factory/TransactionJournalFactory.phpindex da9e311be1..fbee73ea96 100644--- a/app/Factory/TransactionJournalFactory.php+++ b/app/Factory/TransactionJournalFactory.php@@ -52,6 +52,7 @@ class TransactionJournalFactory// store basic journal first.$type = $this->findTransactionType($data['type']);$defaultCurrency = app('amount')->getDefaultCurrencyByUser($this->user);+ Log::debug(sprintf('Going to store a %s', $type->type));$journal = TransactionJournal::create(['user_id' => $data['user'],diff --git a/app/Models/TransactionType.php b/app/Models/TransactionType.phpindex dbbb775f7e..67a1b906e1 100644--- a/app/Models/TransactionType.php+++ b/app/Models/TransactionType.php@@ -29,6 +29,7 @@ use FireflyIII\Models\TransactionJournal;/*** Class TransactionType.+ * @property string $type*/class TransactionType extends Model{diff --git a/app/Services/Internal/Support/TransactionServiceTrait.php b/app/Services/Internal/Support/TransactionServiceTrait.phpindex 1355afebbe..3c02b991cd 100644--- a/app/Services/Internal/Support/TransactionServiceTrait.php+++ b/app/Services/Internal/Support/TransactionServiceTrait.php@@ -108,6 +108,8 @@ trait TransactionServiceTrait$repository = app(AccountRepositoryInterface::class);$repository->setUser($this->user);+ Log::debug(sprintf('Going to find account #%d ("%s")', $accountId, $accountName));+if (null === $expectedType) {return $repository->findNull($accountId);}diff --git a/app/Support/Import/Routine/Spectre/StageAuthenticatedHandler.php b/app/Support/Import/Routine/Spectre/StageAuthenticatedHandler.phpindex 3daea6cf72..49bd98579e 100644--- a/app/Support/Import/Routine/Spectre/StageAuthenticatedHandler.php+++ b/app/Support/Import/Routine/Spectre/StageAuthenticatedHandler.php@@ -69,13 +69,13 @@ class StageAuthenticatedHandlerforeach ($logins as $loginArray) {$loginId = $loginArray['id'] ?? -1;if ($loginId === $selectedLogin) {- Log::debug('Selected login is in the array with logins.');$login = new Login($loginArray);+ Log::debug(sprintf('Selected login "%s" ("%s") which is in the array with logins.', $login->getProviderName(), $login->getCountryCode()));}}if (null === $login) {- Log::debug('Login is null, simply use the first one from the array.');$login = new Login($logins[0]);+ Log::debug(sprintf('Login is null, simply use the first one "%s" ("%s") from the array.', $login->getProviderName(), $login->getCountryCode()));}// with existing login we can grab accounts from this login.@@ -83,6 +83,7 @@ class StageAuthenticatedHandler$config['accounts'] = [];/** @var Account $account */foreach ($accounts as $account) {+ Log::debug(sprintf('Found account #%d ("%s") within Login.', $account->getId(), $account->getName()));$config['accounts'][] = $account->toArray();}$this->repository->setConfiguration($this->importJob, $config);@@ -125,6 +126,7 @@ class StageAuthenticatedHandler*/private function getLogins(): array{+ Log::debug('Now in StageAuthenticatedHandler::getLogins().');$customer = $this->getCustomer($this->importJob);/** @var ListLoginsRequest $request */@@ -134,6 +136,9 @@ class StageAuthenticatedHandler$request->call();$logins = $request->getLogins();$return = [];++ Log::debug(sprintf('Found %d logins in users Spectre account.', \count($logins)));+/** @var Login $login */foreach ($logins as $login) {$return[] = $login->toArray();diff --git a/app/Support/Import/Routine/Spectre/StageImportDataHandler.php b/app/Support/Import/Routine/Spectre/StageImportDataHandler.phpindex dd12d32255..d8fe9ad981 100644--- a/app/Support/Import/Routine/Spectre/StageImportDataHandler.php+++ b/app/Support/Import/Routine/Spectre/StageImportDataHandler.php@@ -64,17 +64,27 @@ class StageImportDataHandlerthrow new FireflyException('There are no accounts in this import job. Cannot continue.'); // @codeCoverageIgnore}$toImport = $config['account_mapping'] ?? [];+ $totalSet = [[]];foreach ($toImport as $spectreId => $localId) {if ((int)$localId > 0) {Log::debug(sprintf('Will get transactions from Spectre account #%d and save them in Firefly III account #%d', $spectreId, $localId));$spectreAccount = $this->getSpectreAccount((int)$spectreId);$localAccount = $this->getLocalAccount((int)$localId);- $set = $this->getTransactions($spectreAccount, $localAccount);- $this->repository->setTransactions($this->importJob, $set);+ $merge = $this->getTransactions($spectreAccount, $localAccount);+ $totalSet[] = $merge;+ Log::debug(+ sprintf('Found %d transactions in account "%s" (%s)', \count($merge), $spectreAccount->getName(), $spectreAccount->getCurrencyCode())+ );+ continue;}+ Log::debug(sprintf('Local account is = zero, will not import from Spectr account with ID #%d', $spectreId));}+ $totalSet = array_merge(...$totalSet);+ Log::debug(sprintf('Found %d transactions in total.', \count($totalSet)));+ $this->repository->setTransactions($this->importJob, $totalSet);}+/*** @param ImportJob $importJob*@@ -151,9 +161,11 @@ class StageImportDataHandlerbreak;case 'original_amount':$foreignAmount = $value;+ Log::debug(sprintf('Foreign amount is now %s', $value));break;case 'original_currency_code':$foreignCurrencyCode = $value;+ Log::debug(sprintf('Foreign currency code is now %s', $value));break;default:$notes .= $key . ': ' . $value . ' ' . "\n"; // for newline in Markdown.