Improve logging #1607

This commit is contained in:
James Cole 2018-10-31 16:33:03 +01:00
parent 53ed5b2975
commit b17f2f5d1f
2 changed files with 5 additions and 2 deletions

View File

@ -92,12 +92,13 @@ class TransactionJournalFactory
/** @var TransactionFactory $factory */ /** @var TransactionFactory $factory */
$factory = app(TransactionFactory::class); $factory = app(TransactionFactory::class);
$factory->setUser($this->user); $factory->setUser($this->user);
$totalAmount= '0';
Log::debug(sprintf('Found %d transactions in array.', \count($data['transactions']))); Log::debug(sprintf('Found %d transactions in array.', \count($data['transactions'])));
/** @var array $trData */ /** @var array $trData */
foreach ($data['transactions'] as $index => $trData) { foreach ($data['transactions'] as $index => $trData) {
Log::debug(sprintf('Now storing transaction %d of %d', $index + 1, \count($data['transactions']))); Log::debug(sprintf('Now storing transaction %d of %d', $index + 1, \count($data['transactions'])));
$factory->createPair($journal, $trData); $factory->createPair($journal, $trData);
$totalAmount = bcadd($totalAmount, $trData['amount'] ?? '0');
} }
$journal->completed = true; $journal->completed = true;
$journal->save(); $journal->save();
@ -127,6 +128,8 @@ class TransactionJournalFactory
// invalidate cache. // invalidate cache.
app('preferences')->mark(); app('preferences')->mark();
$journal->temp_amount = $totalAmount;
return $journal; return $journal;
} }

View File

@ -469,7 +469,7 @@ class ImportArrayStorage
continue; 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)); Log::debug(sprintf('Stored as journal #%d', $journal->id));
$collection->push($journal); $collection->push($journal);