This commit is contained in:
James Cole
2017-09-30 13:16:12 +02:00
parent d0054e657e
commit 134f21bada

View File

@@ -35,16 +35,15 @@ class ImportStorage
/** @var Collection */ /** @var Collection */
public $journals; public $journals;
/** @var int */ /** @var int */
protected $defaultCurrencyId = 1; protected $defaultCurrencyId = 1; // yes, hard coded
/** @var string */
private $dateFormat = 'Ymd'; // yes, hard coded
/** @var ImportJob */ /** @var ImportJob */
protected $job; protected $job;
/** @var Collection */ /** @var Collection */
private $objects;
/** @var Collection */
protected $rules; protected $rules;
/** @var string */
private $dateFormat = 'Ymd';
/** @var Collection */
private $objects;
/** @var array */ /** @var array */
private $transfers = []; private $transfers = [];
@@ -214,29 +213,31 @@ class ImportStorage
$amount = app('steam')->positive($parameters['amount']); $amount = app('steam')->positive($parameters['amount']);
$names = [$parameters['asset'], $parameters['opposing']]; $names = [$parameters['asset'], $parameters['opposing']];
$transfer = []; $transfer = [];
$hit = false; $hits = 0;
sort($names); sort($names);
foreach ($this->transfers as $transfer) { foreach ($this->transfers as $transfer) {
if ($parameters['description'] === $transfer['description']) { if ($parameters['description'] === $transfer['description']) {
$hit = true; $hits++;
} }
if ($names === $transfer['names']) { if ($names === $transfer['names']) {
$hit = true; $hits++;
} }
if (bccomp($amount, $transfer['amount']) === 0) { if (bccomp($amount, $transfer['amount']) === 0) {
$hit = true; $hits++;
} }
if ($parameters['date'] === $transfer['date']) { if ($parameters['date'] === $transfer['date']) {
$hit = true; $hits++;
} }
} }
if ($hit === true) { if ($hits === 4) {
Log::error( Log::error(
'There already is a transfer imported with these properties. Compare existing with new. ', ['existing' => $transfer, 'new' => $parameters] 'There already is a transfer imported with these properties. Compare existing with new. ', ['existing' => $transfer, 'new' => $parameters]
); );
return true;
} }
return $hit; return false;
} }
} }