From b17f2f5d1f677fe492c5f30ba0836a082af095ff Mon Sep 17 00:00:00 2001 From: James Cole Date: Wed, 31 Oct 2018 16:33:03 +0100 Subject: [PATCH] Improve logging #1607 --- app/Factory/TransactionJournalFactory.php | 5 ++++- app/Import/Storage/ImportArrayStorage.php | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/Factory/TransactionJournalFactory.php b/app/Factory/TransactionJournalFactory.php index da8a3ffbc1..5a18efccfc 100644 --- a/app/Factory/TransactionJournalFactory.php +++ b/app/Factory/TransactionJournalFactory.php @@ -92,12 +92,13 @@ class TransactionJournalFactory /** @var TransactionFactory $factory */ $factory = app(TransactionFactory::class); $factory->setUser($this->user); - + $totalAmount= '0'; Log::debug(sprintf('Found %d transactions in array.', \count($data['transactions']))); /** @var array $trData */ foreach ($data['transactions'] as $index => $trData) { Log::debug(sprintf('Now storing transaction %d of %d', $index + 1, \count($data['transactions']))); $factory->createPair($journal, $trData); + $totalAmount = bcadd($totalAmount, $trData['amount'] ?? '0'); } $journal->completed = true; $journal->save(); @@ -127,6 +128,8 @@ class TransactionJournalFactory // invalidate cache. app('preferences')->mark(); + $journal->temp_amount = $totalAmount; + return $journal; } diff --git a/app/Import/Storage/ImportArrayStorage.php b/app/Import/Storage/ImportArrayStorage.php index 6f7601a78d..6458bdfda4 100644 --- a/app/Import/Storage/ImportArrayStorage.php +++ b/app/Import/Storage/ImportArrayStorage.php @@ -469,7 +469,7 @@ class ImportArrayStorage continue; } - Log::info(sprintf('Stored #%d: "%s" (ID #%d)', $index, $journal->description, $journal->id)); + Log::info(sprintf('Stored #%d: "%s" %s (ID #%d)', $index, $journal->description, round($journal->temp_amount, 2), $journal->id)); Log::debug(sprintf('Stored as journal #%d', $journal->id)); $collection->push($journal);