Fixed Rabo importer.

This commit is contained in:
James Cole
2015-07-09 19:23:49 +02:00
parent 5df09dab09
commit 20cffd0502
2 changed files with 19 additions and 2 deletions

View File

@@ -24,6 +24,10 @@ class OpposingAccount implements PostProcessorInterface
*/ */
public function process() public function process()
{ {
// three values:
// opposing-account-id, opposing-account-iban, opposing-account-name
$result = $this->checkIdNameObject(); $result = $this->checkIdNameObject();
if (!is_null($result)) { if (!is_null($result)) {
return $result; return $result;
@@ -56,11 +60,13 @@ class OpposingAccount implements PostProcessorInterface
protected function checkIdNameObject() protected function checkIdNameObject()
{ {
if ($this->data['opposing-account-id'] instanceof Account) { // first priority. try to find the account based on ID, if any if ($this->data['opposing-account-id'] instanceof Account) { // first priority. try to find the account based on ID, if any
Log::debug('OpposingAccountPostProcession: opposing-account-id is an Account.');
$this->data['opposing-account-object'] = $this->data['opposing-account-id']; $this->data['opposing-account-object'] = $this->data['opposing-account-id'];
return $this->data; return $this->data;
} }
if ($this->data['opposing-account-iban'] instanceof Account) { // second: try to find the account based on IBAN, if any. if ($this->data['opposing-account-iban'] instanceof Account) { // second: try to find the account based on IBAN, if any.
Log::debug('OpposingAccountPostProcession: opposing-account-iban is an Account.');
$this->data['opposing-account-object'] = $this->data['opposing-account-iban']; $this->data['opposing-account-object'] = $this->data['opposing-account-iban'];
return $this->data; return $this->data;
@@ -75,9 +81,12 @@ class OpposingAccount implements PostProcessorInterface
protected function checkIbanString() protected function checkIbanString()
{ {
$rules = ['iban' => 'iban']; $rules = ['iban' => 'iban'];
$check = ['iban' => $this->data['opposing-account-iban']]; $iban = $this->data['opposing-account-iban'];
$check = ['iban' => $iban];
$validator = Validator::make($check, $rules); $validator = Validator::make($check, $rules);
if (!$validator->fails()) { if (is_string($iban) && strlen($iban) > 0 && !$validator->fails()) {
Log::debug('OpposingAccountPostProcession: opposing-account-iban is a string (' . $this->data['opposing-account-iban'] . ').');
$this->data['opposing-account-object'] = $this->parseIbanString(); $this->data['opposing-account-object'] = $this->parseIbanString();
return $this->data; return $this->data;
@@ -95,12 +104,14 @@ class OpposingAccount implements PostProcessorInterface
$accounts = Auth::user()->accounts()->get(); $accounts = Auth::user()->accounts()->get();
foreach ($accounts as $entry) { foreach ($accounts as $entry) {
if ($entry->iban == $this->data['opposing-account-iban']) { if ($entry->iban == $this->data['opposing-account-iban']) {
Log::debug('OpposingAccountPostProcession: opposing-account-iban matches an Account.');
return $entry; return $entry;
} }
} }
$account = $this->createAccount(); $account = $this->createAccount();
return $account; return $account;
} }
@@ -123,6 +134,7 @@ class OpposingAccount implements PostProcessorInterface
'active' => true, 'active' => true,
] ]
); );
Log::debug('OpposingAccountPostProcession: created a new account.');
return $account; return $account;
} }
@@ -153,11 +165,13 @@ class OpposingAccount implements PostProcessorInterface
protected function checkNameString() protected function checkNameString()
{ {
if ($this->data['opposing-account-name'] instanceof Account) { // third: try to find account based on name, if any. if ($this->data['opposing-account-name'] instanceof Account) { // third: try to find account based on name, if any.
Log::debug('OpposingAccountPostProcession: opposing-account-name is an Account.');
$this->data['opposing-account-object'] = $this->data['opposing-account-name']; $this->data['opposing-account-object'] = $this->data['opposing-account-name'];
return $this->data; return $this->data;
} }
if (is_string($this->data['opposing-account-name'])) { if (is_string($this->data['opposing-account-name'])) {
$this->data['opposing-account-object'] = $this->parseNameString(); $this->data['opposing-account-object'] = $this->parseNameString();
return $this->data; return $this->data;

View File

@@ -65,6 +65,9 @@ class FireflyValidator extends Validator
if (!is_string($value)) { if (!is_string($value)) {
return false; return false;
} }
if (is_null($value)) {
return false;
}
if (strlen($value) === 0) { if (strlen($value) === 0) {
return false; return false;