2016-07-15 15:26:08 -05:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* AssetAccountIbans.php
|
|
|
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
|
|
|
*
|
2016-10-04 23:52:15 -05:00
|
|
|
* This software may be modified and distributed under the terms of the
|
|
|
|
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
|
|
|
*
|
|
|
|
* See the LICENSE file for details.
|
2016-07-15 15:26:08 -05:00
|
|
|
*/
|
|
|
|
|
2017-04-09 00:44:22 -05:00
|
|
|
declare(strict_types=1);
|
2016-07-15 15:26:08 -05:00
|
|
|
|
|
|
|
namespace FireflyIII\Import\Mapper;
|
|
|
|
|
|
|
|
use FireflyIII\Models\Account;
|
|
|
|
use FireflyIII\Models\AccountType;
|
2016-10-10 00:49:39 -05:00
|
|
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
2016-07-15 15:26:08 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class AssetAccounts
|
|
|
|
*
|
|
|
|
* @package FireflyIII\Import\Mapper
|
|
|
|
*/
|
|
|
|
class AssetAccountIbans implements MapperInterface
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getMap(): array
|
|
|
|
{
|
2016-10-10 00:49:39 -05:00
|
|
|
/** @var AccountRepositoryInterface $accountRepository */
|
|
|
|
$accountRepository = app(AccountRepositoryInterface::class);
|
|
|
|
$set = $accountRepository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
|
|
|
$topList = [];
|
|
|
|
$list = [];
|
2016-07-15 15:26:08 -05:00
|
|
|
|
|
|
|
/** @var Account $account */
|
|
|
|
foreach ($set as $account) {
|
|
|
|
$iban = $account->iban ?? '';
|
|
|
|
if (strlen($iban) > 0) {
|
|
|
|
$topList[$account->id] = $account->iban . ' (' . $account->name . ')';
|
|
|
|
}
|
2017-07-15 09:41:07 -05:00
|
|
|
if (strlen($iban) === 0) {
|
2016-07-15 15:26:08 -05:00
|
|
|
$list[$account->id] = $account->name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
asort($topList);
|
|
|
|
asort($list);
|
|
|
|
|
|
|
|
$list = $topList + $list;
|
2017-06-23 23:57:24 -05:00
|
|
|
$list = [0 => trans('csv.map_do_not_map')] + $list;
|
2016-07-15 15:26:08 -05:00
|
|
|
|
|
|
|
return $list;
|
|
|
|
|
|
|
|
}
|
2016-08-12 08:10:03 -05:00
|
|
|
}
|