Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Catch the error in #760
James Colef9c85d4d8186
diff --git a/app/Import/Object/ImportJournal.php b/app/Import/Object/ImportJournal.phpindex a72f574f28..48b7d7df60 100644--- a/app/Import/Object/ImportJournal.php+++ b/app/Import/Object/ImportJournal.php@@ -85,6 +85,7 @@ class ImportJournal/*** @return string+ * @throws FireflyException*/public function getAmount(): string{@@ -102,6 +103,9 @@ class ImportJournal}}}+ if(bccomp($this->amount,'0') === 0) {+ throw new FireflyException('Amount is zero.');+ }return $this->amount;}diff --git a/app/Import/Storage/ImportStorage.php b/app/Import/Storage/ImportStorage.phpindex 50980ad2a9..598380a06b 100644--- a/app/Import/Storage/ImportStorage.php+++ b/app/Import/Storage/ImportStorage.php@@ -11,6 +11,8 @@ declare(strict_types=1);namespace FireflyIII\Import\Storage;+use ErrorException;+use Exception;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Import\Object\ImportJournal;use FireflyIII\Models\ImportJob;@@ -95,7 +97,7 @@ class ImportStoragefunction (ImportJournal $importJournal, int $index) {try {$this->storeImportJournal($index, $importJournal);- } catch (FireflyException $e) {+ } catch (FireflyException | ErrorException | Exception $e) {$this->errors->push($e->getMessage());Log::error(sprintf('Cannot import row #%d because: %s', $index, $e->getMessage()));}diff --git a/app/Import/Storage/ImportSupport.php b/app/Import/Storage/ImportSupport.phpindex 38b444b98e..aa7b1dbf99 100644--- a/app/Import/Storage/ImportSupport.php+++ b/app/Import/Storage/ImportSupport.php@@ -214,7 +214,7 @@ trait ImportSupport*/private function getTransactionType(string $amount, Account $account): string{- $transactionType = '';+ $transactionType = TransactionType::WITHDRAWAL;// amount is negative, it's a withdrawal, opposing is an expense:if (bccomp($amount, '0') === -1) {$transactionType = TransactionType::WITHDRAWAL;