mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-18 12:28:46 +00:00
Optimised some code.
This commit is contained in:
@@ -32,17 +32,13 @@ class AccountId extends BasicConverter implements ConverterInterface
|
||||
{
|
||||
$value = intval(trim($value));
|
||||
Log::debug('Going to convert using AssetAccountId', ['value' => $value]);
|
||||
|
||||
if ($value === 0) {
|
||||
$this->setCertainty(0);
|
||||
|
||||
return new Account;
|
||||
}
|
||||
|
||||
/** @var AccountCrudInterface $repository */
|
||||
$repository = app(AccountCrudInterface::class, [$this->user]);
|
||||
|
||||
|
||||
if (isset($this->mapping[$value])) {
|
||||
Log::debug('Found account in mapping. Should exist.', ['value' => $value, 'map' => $this->mapping[$value]]);
|
||||
$account = $repository->find(intval($this->mapping[$value]));
|
||||
@@ -54,20 +50,15 @@ class AccountId extends BasicConverter implements ConverterInterface
|
||||
return $account;
|
||||
}
|
||||
}
|
||||
|
||||
// not mapped? Still try to find it first:
|
||||
$account = $repository->find($value);
|
||||
$account = $repository->find($value);// not mapped? Still try to find it first:
|
||||
if (!is_null($account->id)) {
|
||||
$this->setCertainty(90);
|
||||
|
||||
Log::debug('Found account by ID ', ['id' => $account->id]);
|
||||
|
||||
return $account;
|
||||
}
|
||||
$this->setCertainty(0); // should not really happen. If the ID does not match FF, what is FF supposed to do?
|
||||
|
||||
$this->setCertainty(0);
|
||||
|
||||
// should not really happen. If the ID does not match FF, what is FF supposed to do?
|
||||
return new Account;
|
||||
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ class CurrencySymbol extends BasicConverter implements ConverterInterface
|
||||
$value = trim($value);
|
||||
Log::debug('Going to convert using CurrencySymbol', ['value' => $value]);
|
||||
|
||||
if ($value === 0) {
|
||||
if (strlen($value) === 0) {
|
||||
$this->setCertainty(0);
|
||||
return new TransactionCurrency;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@ class ImportEntry
|
||||
public $amount;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param string $role
|
||||
* @param string $value
|
||||
@@ -34,6 +36,8 @@ class ImportEntry
|
||||
*/
|
||||
public function importValue(string $role, string $value, int $certainty, $convertedValue)
|
||||
{
|
||||
Log::debug('Going to import', ['role' => $role, 'value' => $value, 'certainty' => $certainty]);
|
||||
|
||||
switch ($role) {
|
||||
default:
|
||||
Log::error('Import entry cannot handle object.', ['role' => $role]);
|
||||
@@ -41,11 +45,12 @@ class ImportEntry
|
||||
break;
|
||||
|
||||
case 'amount':
|
||||
/*
|
||||
* Easy enough.
|
||||
*/
|
||||
$this->setAmount($convertedValue);
|
||||
return;
|
||||
case 'account-id':
|
||||
|
||||
break;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user