From 1633994fbdf8c4e2609ba1d9e50f616e44d2b63d Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 13 Aug 2017 15:30:39 +0200 Subject: [PATCH] Slight change in amount handler. #760 --- app/Import/Object/ImportJournal.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/Import/Object/ImportJournal.php b/app/Import/Object/ImportJournal.php index 48b7d7df60..21bd535b8f 100644 --- a/app/Import/Object/ImportJournal.php +++ b/app/Import/Object/ImportJournal.php @@ -37,6 +37,8 @@ class ImportJournal public $budget; /** @var ImportCategory */ public $category; + /** @var ImportCurrency */ + public $currency; /** @var string */ public $description = ''; /** @var string */ @@ -51,8 +53,8 @@ class ImportJournal public $tags = []; /** @var string */ private $amount; - /** @var ImportCurrency */ - public $currency; + /** @var string */ + private $convertedAmount = null; /** @var string */ private $date = ''; /** @var string */ @@ -89,25 +91,25 @@ class ImportJournal */ public function getAmount(): string { - if (is_null($this->amount)) { + if (is_null($this->convertedAmount)) { /** @var ConverterInterface $amountConverter */ - $amountConverter = app(Amount::class); - $this->amount = $amountConverter->convert($this->amount); + $amountConverter = app(Amount::class); + $this->convertedAmount = $amountConverter->convert($this->amount); // modify foreach ($this->modifiers as $modifier) { $class = sprintf('FireflyIII\Import\Converter\%s', config(sprintf('csv.import_roles.%s.converter', $modifier['role']))); /** @var ConverterInterface $converter */ $converter = app($class); if ($converter->convert($modifier['value']) === -1) { - $this->amount = Steam::negative($this->amount); + $this->convertedAmount = Steam::negative($this->convertedAmount); } } } - if(bccomp($this->amount,'0') === 0) { + if (bccomp($this->convertedAmount, '0') === 0) { throw new FireflyException('Amount is zero.'); } - return $this->amount; + return $this->convertedAmount; } /**