Finish up bunq import routine.

This commit is contained in:
James Cole
2018-03-24 18:55:02 +01:00
parent 3c9b7c07af
commit 6a6482dc7f
24 changed files with 696 additions and 79 deletions

View File

@@ -302,4 +302,5 @@ class AccountRepository implements AccountRepositoryInterface
return $journal;
}
}

View File

@@ -66,6 +66,7 @@ interface AccountRepositoryInterface
* @param string $number
* @param array $types
*
* @deprecated
* @return Account
*/
public function findByAccountNumber(string $number, array $types): Account;
@@ -74,14 +75,24 @@ interface AccountRepositoryInterface
* @param string $iban
* @param array $types
*
* @deprecated
* @return Account
*/
public function findByIban(string $iban, array $types): Account;
/**
* @param string $iban
* @param array $types
*
* @return Account|null
*/
public function findByIbanNull(string $iban, array $types): ?Account;
/**
* @param string $name
* @param array $types
*
* @deprecated
* @return Account|null
*/
public function findByName(string $name, array $types): ?Account;

View File

@@ -41,6 +41,7 @@ trait FindAccountsTrait
/**
* @param $accountId
*
* @deprecated
* @return Account
*/
public function find(int $accountId): Account
@@ -58,6 +59,7 @@ trait FindAccountsTrait
* @param string $number
* @param array $types
*
*
* @deprecated
* @return Account
*/
@@ -109,10 +111,37 @@ trait FindAccountsTrait
return new Account;
}
/**
* @param string $iban
* @param array $types
*
* @return Account|null
*/
public function findByIbanNull(string $iban, array $types): ?Account
{
$query = $this->user->accounts()->where('iban', '!=', '')->whereNotNull('iban');
if (count($types) > 0) {
$query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
$query->whereIn('account_types.type', $types);
}
$accounts = $query->get(['accounts.*']);
/** @var Account $account */
foreach ($accounts as $account) {
if ($account->iban === $iban) {
return $account;
}
}
return null;
}
/**
* @param string $name
* @param array $types
*
* @deprecated
* @return Account|null
*/
public function findByName(string $name, array $types): ?Account