Skip to content

Commit

Permalink
Improve logging #1607
Browse files Browse the repository at this point in the history
  • Loading branch information
JC5 committed Oct 31, 2018
1 parent 53ed5b2 commit b17f2f5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion app/Factory/TransactionJournalFactory.php
Expand Up @@ -92,12 +92,13 @@ public function create(array $data): TransactionJournal
/** @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();
Expand Down Expand Up @@ -127,6 +128,8 @@ public function create(array $data): TransactionJournal
// invalidate cache.
app('preferences')->mark();

$journal->temp_amount = $totalAmount;

return $journal;
}

Expand Down
2 changes: 1 addition & 1 deletion app/Import/Storage/ImportArrayStorage.php
Expand Up @@ -469,7 +469,7 @@ private function storeArray(): Collection
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);

Expand Down

0 comments on commit b17f2f5

Please sign in to comment.