New code for double transfer routine. #797

This commit is contained in:
James Cole 2017-09-05 06:43:33 +02:00
parent a942313f85
commit 068b9e388f
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E

View File

@ -210,24 +210,29 @@ 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;
sort($names); sort($names);
foreach ($this->transfers as $transfer) { foreach ($this->transfers as $transfer) {
if ($parameters['description'] !== $transfer['description']) { if ($parameters['description'] === $transfer['description']) {
return false; $hit = true;
} }
if ($names !== $transfer['names']) { if ($names === $transfer['names']) {
return false; $hit = true;
} }
if (bccomp($amount, $transfer['amount']) !== 0) { if (bccomp($amount, $transfer['amount']) === 0) {
return false; $hit = true;
} }
if ($parameters['date'] !== $transfer['date']) { if ($parameters['date'] === $transfer['date']) {
return false; $hit = true;
} }
} }
Log::error('There already is a transfer imported with these properties. Compare existing with new. ', ['existing' => $transfer, 'new' => $parameters]); if ($hit === true) {
Log::error(
'There already is a transfer imported with these properties. Compare existing with new. ', ['existing' => $transfer, 'new' => $parameters]
);
}
return true; return $hit;
} }
} }