mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
Catch the error in #760
This commit is contained in:
@@ -85,6 +85,7 @@ class ImportJournal
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
public function getAmount(): string
|
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;
|
return $this->amount;
|
||||||
}
|
}
|
||||||
|
@@ -11,6 +11,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Import\Storage;
|
namespace FireflyIII\Import\Storage;
|
||||||
|
|
||||||
|
use ErrorException;
|
||||||
|
use Exception;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Import\Object\ImportJournal;
|
use FireflyIII\Import\Object\ImportJournal;
|
||||||
use FireflyIII\Models\ImportJob;
|
use FireflyIII\Models\ImportJob;
|
||||||
@@ -95,7 +97,7 @@ class ImportStorage
|
|||||||
function (ImportJournal $importJournal, int $index) {
|
function (ImportJournal $importJournal, int $index) {
|
||||||
try {
|
try {
|
||||||
$this->storeImportJournal($index, $importJournal);
|
$this->storeImportJournal($index, $importJournal);
|
||||||
} catch (FireflyException $e) {
|
} catch (FireflyException | ErrorException | Exception $e) {
|
||||||
$this->errors->push($e->getMessage());
|
$this->errors->push($e->getMessage());
|
||||||
Log::error(sprintf('Cannot import row #%d because: %s', $index, $e->getMessage()));
|
Log::error(sprintf('Cannot import row #%d because: %s', $index, $e->getMessage()));
|
||||||
}
|
}
|
||||||
|
@@ -214,7 +214,7 @@ trait ImportSupport
|
|||||||
*/
|
*/
|
||||||
private function getTransactionType(string $amount, Account $account): string
|
private function getTransactionType(string $amount, Account $account): string
|
||||||
{
|
{
|
||||||
$transactionType = '';
|
$transactionType = TransactionType::WITHDRAWAL;
|
||||||
// amount is negative, it's a withdrawal, opposing is an expense:
|
// amount is negative, it's a withdrawal, opposing is an expense:
|
||||||
if (bccomp($amount, '0') === -1) {
|
if (bccomp($amount, '0') === -1) {
|
||||||
$transactionType = TransactionType::WITHDRAWAL;
|
$transactionType = TransactionType::WITHDRAWAL;
|
||||||
|
Reference in New Issue
Block a user