mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Scrutiniser will now include duplicate code.
This commit is contained in:
parent
001d72a484
commit
516725456f
@ -24,25 +24,16 @@ class OpposingAccount implements PostProcessorInterface
|
||||
*/
|
||||
public function process()
|
||||
{
|
||||
Log::debug('Start post processing opposing account');
|
||||
// first priority. try to find the account based on ID,
|
||||
// if any.
|
||||
// first priority. try to find the account based on ID, if any.
|
||||
if ($this->data['opposing-account-id'] instanceof Account) {
|
||||
Log::debug('opposing-account-id is an account (#' . $this->data['opposing-account-id']->id . ': ' . $this->data['opposing-account-id']->name . ')');
|
||||
$this->data['opposing-account-object'] = $this->data['opposing-account-id'];
|
||||
Log::debug('Done post processing opposing account.');
|
||||
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
// second: try to find the account based on IBAN, if any.
|
||||
if ($this->data['opposing-account-iban'] instanceof Account) {
|
||||
Log::debug(
|
||||
'opposing-account-iban is an account (#' .
|
||||
$this->data['opposing-account-iban']->id . ': ' . $this->data['opposing-account-iban']->name . ')'
|
||||
);
|
||||
$this->data['opposing-account-object'] = $this->data['opposing-account-iban'];
|
||||
Log::debug('Done post processing opposing account.');
|
||||
|
||||
return $this->data;
|
||||
}
|
||||
@ -54,44 +45,27 @@ class OpposingAccount implements PostProcessorInterface
|
||||
|
||||
|
||||
if (is_string($this->data['opposing-account-iban']) && strlen($this->data['opposing-account-iban']) > 0) {
|
||||
Log::debug('opposing-account-iban is an IBAN string (' . $this->data['opposing-account-iban'] . ')');
|
||||
if ($result) {
|
||||
Log::debug('opposing-account-iban is a valid IBAN string!');
|
||||
Log::debug('Go to parseIbanString()');
|
||||
$this->data['opposing-account-object'] = $this->parseIbanString();
|
||||
Log::debug('Done post processing opposing account.');
|
||||
|
||||
return $this->data;
|
||||
} else {
|
||||
Log::debug('opposing-account-iban is NOT a valid IBAN string!');
|
||||
}
|
||||
}
|
||||
|
||||
// third: try to find account based on name, if any.
|
||||
if ($this->data['opposing-account-name'] instanceof Account) {
|
||||
Log::debug(
|
||||
'opposing-account-name is an Account (#' .
|
||||
$this->data['opposing-account-name']->id . ': ' . $this->data['opposing-account-name']->name . ') '
|
||||
);
|
||||
$this->data['opposing-account-object'] = $this->data['opposing-account-name'];
|
||||
Log::debug('Done post processing opposing account.');
|
||||
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
if (is_string($this->data['opposing-account-name'])) {
|
||||
Log::debug('Opposing account name is a string: ' . $this->data['opposing-account-name']);
|
||||
Log::debug('Go to parseNameString');
|
||||
$this->data['opposing-account-object'] = $this->parseNameString();
|
||||
Log::debug('Done post processing opposing account.');
|
||||
|
||||
return $this->data;
|
||||
}
|
||||
Log::debug('Done post processing opposing account.');
|
||||
|
||||
return null;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -107,13 +81,11 @@ class OpposingAccount implements PostProcessorInterface
|
||||
*/
|
||||
protected function parseIbanString()
|
||||
{
|
||||
Log::debug('Parse IBAN string!');
|
||||
// create by name and/or iban.
|
||||
$accountType = $this->getAccountType();
|
||||
$accounts = Auth::user()->accounts()->get();
|
||||
foreach ($accounts as $entry) {
|
||||
if ($entry->iban == $this->data['opposing-account-iban']) {
|
||||
Log::debug('Found existing account with this IBAN: (#' . $entry->id . ': ' . $entry->name . ')');
|
||||
|
||||
return $entry;
|
||||
}
|
||||
@ -130,7 +102,6 @@ class OpposingAccount implements PostProcessorInterface
|
||||
'active' => true,
|
||||
]
|
||||
);
|
||||
Log::debug('Created new (' . $accountType->type . ')B account with this IBAN: (#' . $account->id . ': ' . $account->name . ')');
|
||||
|
||||
return $account;
|
||||
}
|
||||
@ -180,9 +151,6 @@ class OpposingAccount implements PostProcessorInterface
|
||||
]
|
||||
);
|
||||
|
||||
Log::debug('Created a new (' . $accountType->type . ')A account with this name (#' . $account->id . ': ' . $account->name . ')');
|
||||
|
||||
|
||||
return $account;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user