mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Lots of new code for the Spectre routine.
This commit is contained in:
parent
1732ce63f3
commit
04953b5645
@ -78,7 +78,6 @@ class JobConfigurationController extends Controller
|
||||
|
||||
return redirect(route('import.index'));
|
||||
}
|
||||
|
||||
Log::debug(sprintf('Now in JobConfigurationController::index() with job "%s" and status "%s"', $importJob->key, $importJob->status));
|
||||
|
||||
// if provider has no config, just push it through:
|
||||
|
153
app/Import/JobConfiguration/SpectreJobConfiguration.php
Normal file
153
app/Import/JobConfiguration/SpectreJobConfiguration.php
Normal file
@ -0,0 +1,153 @@
|
||||
<?php
|
||||
/**
|
||||
* SpectreJobConfiguration.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Import\JobConfiguration;
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\ImportJob;
|
||||
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||
use FireflyIII\Support\Import\JobConfiguration\Spectre\AuthenticateConfig;
|
||||
use FireflyIII\Support\Import\JobConfiguration\Spectre\AuthenticatedConfigHandler;
|
||||
use FireflyIII\Support\Import\JobConfiguration\Spectre\ChooseAccount;
|
||||
use FireflyIII\Support\Import\JobConfiguration\Spectre\ChooseLoginHandler;
|
||||
use FireflyIII\Support\Import\JobConfiguration\Spectre\NewConfig;
|
||||
use FireflyIII\Support\Import\JobConfiguration\Spectre\SpectreJobConfig;
|
||||
use Illuminate\Support\MessageBag;
|
||||
|
||||
/**
|
||||
* Class SpectreJobConfiguration
|
||||
*
|
||||
* @package FireflyIII\Import\JobConfiguration
|
||||
*/
|
||||
class SpectreJobConfiguration implements JobConfigurationInterface
|
||||
{
|
||||
/** @var SpectreJobConfig */
|
||||
private $handler;
|
||||
/** @var ImportJob */
|
||||
private $importJob;
|
||||
/** @var ImportJobRepositoryInterface */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* ConfiguratorInterface constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true when the initial configuration for this job is complete.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function configurationComplete(): bool
|
||||
{
|
||||
return $this->handler->configurationComplete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Store any data from the $data array into the job. Anything in the message bag will be flashed
|
||||
* as an error to the user, regardless of its content.
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @return MessageBag
|
||||
*/
|
||||
public function configureJob(array $data): MessageBag
|
||||
{
|
||||
return $this->handler->configureJob($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the data required for the next step in the job configuration.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getNextData(): array
|
||||
{
|
||||
return $this->handler->getNextData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the view of the next step in the job configuration.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNextView(): string
|
||||
{
|
||||
return $this->handler->getNextView();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ImportJob $importJob
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function setImportJob(ImportJob $importJob): void
|
||||
{
|
||||
$this->importJob = $importJob;
|
||||
$this->repository = app(ImportJobRepositoryInterface::class);
|
||||
$this->repository->setUser($importJob->user);
|
||||
$this->handler = $this->getHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SpectreJobConfig
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function getHandler(): SpectreJobConfig
|
||||
{
|
||||
$handler = null;
|
||||
switch ($this->importJob->stage) {
|
||||
case 'new':
|
||||
$handler = app(NewConfig::class);
|
||||
$handler->setImportJob($this->importJob);
|
||||
break;
|
||||
case 'authenticate':
|
||||
/** @var SpectreJobConfig $handler */
|
||||
$handler = app(AuthenticateConfig::class);
|
||||
$handler->setImportJob($this->importJob);
|
||||
break;
|
||||
case 'choose-login':
|
||||
/** @var SpectreJobConfig $handler */
|
||||
$handler = app(ChooseLoginHandler::class);
|
||||
$handler->setImportJob($this->importJob);
|
||||
break;
|
||||
case 'authenticated':
|
||||
/** @var AuthenticatedConfigHandler $handler */
|
||||
$handler = app(AuthenticatedConfigHandler::class);
|
||||
$handler->setImportJob($this->importJob);
|
||||
break;
|
||||
case 'choose-account':
|
||||
/** @var ChooseAccount $handler */
|
||||
$handler = app(ChooseAccount::class);
|
||||
$handler->setImportJob($this->importJob);
|
||||
break;
|
||||
default:
|
||||
throw new FireflyException(sprintf('Firefly III cannot create a configuration handler for stage "%s"', $this->importJob->stage));
|
||||
|
||||
}
|
||||
|
||||
return $handler;
|
||||
}
|
||||
}
|
@ -25,6 +25,9 @@ namespace FireflyIII\Import\Routine;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\ImportJob;
|
||||
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||
use FireflyIII\Support\Import\Routine\Spectre\ImportDataHandler;
|
||||
use FireflyIII\Support\Import\Routine\Spectre\ManageLoginsHandler;
|
||||
use FireflyIII\Support\Import\Routine\Spectre\StageAuthenticatedHandler;
|
||||
use FireflyIII\Support\Import\Routine\Spectre\StageNewHandler;
|
||||
|
||||
/**
|
||||
@ -54,21 +57,59 @@ class SpectreRoutine implements RoutineInterface
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$valid = ['ready_to_run','error']; // should be only ready_to_run
|
||||
if(in_array($this->importJob->status, $valid)) {
|
||||
$valid = ['ready_to_run']; // should be only ready_to_run
|
||||
if (in_array($this->importJob->status, $valid)) {
|
||||
switch ($this->importJob->stage) {
|
||||
default:
|
||||
throw new FireflyException(sprintf('SpectreRoutine cannot handle stage "%s".', $this->importJob->stage));
|
||||
case 'new':
|
||||
case 'authenticate':
|
||||
/** @var StageNewHandler $handler */
|
||||
$handler = app(StageNewHandler::class);
|
||||
$handler->setImportJob($this->importJob);
|
||||
$handler->run();
|
||||
$this->repository->setStage($this->importJob, 'authenticate');
|
||||
var_dump($this->repository->getConfiguration($this->importJob));
|
||||
exit;
|
||||
$this->repository->setStage($this->importJob, 'manage-logins');
|
||||
break;
|
||||
case 'authenticate':
|
||||
// set job to require config.
|
||||
$this->repository->setStatus($this->importJob, 'need_job_config');
|
||||
|
||||
return;
|
||||
case 'manage-logins':
|
||||
// list all of the users logins.
|
||||
$handler = new ManageLoginsHandler;
|
||||
$handler->setImportJob($this->importJob);
|
||||
$handler->run();
|
||||
|
||||
// if count logins is zero, go to authenticate stage
|
||||
if ($handler->countLogins === 0) {
|
||||
$this->repository->setStage($this->importJob, 'authenticate');
|
||||
$this->repository->setStatus($this->importJob, 'ready_to_run');
|
||||
|
||||
return;
|
||||
}
|
||||
// or return to config to select login.
|
||||
$this->repository->setStage($this->importJob, 'choose-login');
|
||||
$this->repository->setStatus($this->importJob, 'need_job_config');
|
||||
break;
|
||||
case 'authenticated':
|
||||
// get accounts from login, store in job.
|
||||
$handler = new StageAuthenticatedHandler;
|
||||
$handler->setImportJob($this->importJob);
|
||||
$handler->run();
|
||||
|
||||
// return to config to select account(s).
|
||||
$this->repository->setStage($this->importJob, 'choose-account');
|
||||
$this->repository->setStatus($this->importJob, 'need_job_config');
|
||||
break;
|
||||
case 'go-for-import':
|
||||
// user has chosen account mapping. Should now be ready to import data.
|
||||
//$this->repository->setStatus($this->importJob, 'running');
|
||||
//$this->repository->setStage($this->importJob, 'do_import');
|
||||
$handler = new ImportDataHandler;
|
||||
$handler->setImportJob($this->importJob);
|
||||
$handler->run();
|
||||
$this->repository->setStatus($this->importJob, 'provider_finished');
|
||||
$this->repository->setStage($this->importJob, 'final');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ namespace FireflyIII\Models;
|
||||
|
||||
use Crypt;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Contracts\Encryption\DecryptException;
|
||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@ -31,16 +32,14 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Query\JoinClause;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Log;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\AccountMeta;
|
||||
use FireflyIII\User;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* Class Account.
|
||||
*
|
||||
* @property string $name
|
||||
* @property string $iban
|
||||
*/
|
||||
class Account extends Model
|
||||
{
|
||||
|
@ -30,6 +30,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* Class ImportJob.
|
||||
*
|
||||
* @property array $configuration
|
||||
* @property User $user
|
||||
*/
|
||||
class ImportJob extends Model
|
||||
|
@ -354,12 +354,13 @@ class ImportJobRepository implements ImportJobRepositoryInterface
|
||||
*/
|
||||
public function setConfiguration(ImportJob $job, array $configuration): ImportJob
|
||||
{
|
||||
Log::debug(sprintf('Incoming config for job "%s" is: ', $job->key), $configuration);
|
||||
Log::debug('Updating configuration...');
|
||||
//Log::debug(sprintf('Incoming config for job "%s" is: ', $job->key), $configuration);
|
||||
$currentConfig = $job->configuration;
|
||||
$newConfig = array_merge($currentConfig, $configuration);
|
||||
$job->configuration = $newConfig;
|
||||
$job->save();
|
||||
Log::debug(sprintf('Set config of job "%s" to: ', $job->key), $newConfig);
|
||||
//Log::debug(sprintf('Set config of job "%s" to: ', $job->key), $newConfig);
|
||||
|
||||
return $job;
|
||||
}
|
||||
|
@ -49,6 +49,40 @@ class Account extends SpectreObject
|
||||
/** @var Carbon */
|
||||
private $updatedAt;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getNature(): string
|
||||
{
|
||||
return $this->nature;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getBalance(): float
|
||||
{
|
||||
return $this->balance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCurrencyCode(): string
|
||||
{
|
||||
return $this->currencyCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getExtra(): array
|
||||
{
|
||||
return $this->extra;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Account constructor.
|
||||
*
|
||||
|
@ -68,6 +68,49 @@ class Login extends SpectreObject
|
||||
/** @var Carbon */
|
||||
private $updatedAt;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCountryCode(): string
|
||||
{
|
||||
return $this->countryCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Carbon
|
||||
*/
|
||||
public function getLastSuccessAt(): Carbon
|
||||
{
|
||||
return $this->lastSuccessAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProviderName(): string
|
||||
{
|
||||
return $this->providerName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getStatus(): string
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Carbon
|
||||
*/
|
||||
public function getUpdatedAt(): Carbon
|
||||
{
|
||||
return $this->updatedAt;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Login constructor.
|
||||
*
|
||||
@ -129,7 +172,7 @@ class Login extends SpectreObject
|
||||
'id' => $this->id,
|
||||
'last_attempt' => $this->lastAttempt->toArray(),
|
||||
'last_success_at' => $this->lastSuccessAt->toIso8601String(),
|
||||
'next_refresh_possible_at' => $this->nextRefreshPossibleAt,
|
||||
'next_refresh_possible_at' => $this->nextRefreshPossibleAt->toIso8601String(),
|
||||
'provider_code' => $this->providerCode,
|
||||
'provider_id' => $this->providerId,
|
||||
'provider_name' => $this->providerName,
|
||||
|
@ -26,6 +26,7 @@ namespace FireflyIII\Services\Spectre\Request;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Services\Spectre\Object\Customer;
|
||||
use FireflyIII\Services\Spectre\Object\Login;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
@ -64,12 +65,19 @@ class ListLoginsRequest extends SpectreRequest
|
||||
} else {
|
||||
Log::debug('No next page.');
|
||||
}
|
||||
|
||||
$collection = new Collection;
|
||||
// store logins:
|
||||
/** @var array $loginArray */
|
||||
foreach ($response['data'] as $loginArray) {
|
||||
$this->logins[] = new Login($loginArray);
|
||||
$collection->push(new Login($loginArray));
|
||||
}
|
||||
// sort logins by date created:
|
||||
$sorted = $collection->sortByDesc(
|
||||
function (Login $login) {
|
||||
return $login->getUpdatedAt()->timestamp;
|
||||
}
|
||||
);
|
||||
$this->logins = $sorted->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,109 @@
|
||||
<?php
|
||||
/**
|
||||
* AuthenticateConfig.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Import\JobConfiguration\Spectre;
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\ImportJob;
|
||||
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||
use FireflyIII\Services\Spectre\Object\Token;
|
||||
use Illuminate\Support\MessageBag;
|
||||
|
||||
/**
|
||||
* Class AuthenticateConfig
|
||||
*
|
||||
* @package FireflyIII\Support\Import\JobConfiguration\Spectre
|
||||
*/
|
||||
class AuthenticateConfig implements SpectreJobConfig
|
||||
{
|
||||
/** @var ImportJob */
|
||||
private $importJob;
|
||||
/** @var ImportJobRepositoryInterface */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* Return true when this stage is complete.
|
||||
*
|
||||
* always returns false.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function configurationComplete(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the job configuration.
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @return MessageBag
|
||||
*/
|
||||
public function configureJob(array $data): MessageBag
|
||||
{
|
||||
// does nothing
|
||||
return new MessageBag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data for config view.
|
||||
*
|
||||
* @return array
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function getNextData(): array
|
||||
{
|
||||
// next data only makes sure the job is ready for the next stage.
|
||||
$this->repository->setStatus($this->importJob, 'ready_to_run');
|
||||
$this->repository->setStage($this->importJob, 'authenticated');
|
||||
$config = $this->importJob->configuration;
|
||||
$token = isset($config['token']) ? new Token($config['token']) : null;
|
||||
if (null !== $token) {
|
||||
return ['token-url' => $token->getConnectUrl()];
|
||||
}
|
||||
throw new FireflyException('The import routine cannot continue without a Spectre token. Apologies.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view for this stage.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNextView(): string
|
||||
{
|
||||
return 'import.spectre.redirect';
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the import job.
|
||||
*
|
||||
* @param ImportJob $importJob
|
||||
*/
|
||||
public function setImportJob(ImportJob $importJob): void
|
||||
{
|
||||
$this->importJob = $importJob;
|
||||
$this->repository = app(ImportJobRepositoryInterface::class);
|
||||
$this->repository->setUser($importJob->user);
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* AuthenticatedConfigHandler.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Import\JobConfiguration\Spectre;
|
||||
|
||||
|
||||
use FireflyIII\Models\ImportJob;
|
||||
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||
use Illuminate\Support\MessageBag;
|
||||
|
||||
class AuthenticatedConfigHandler implements SpectreJobConfig
|
||||
{
|
||||
/** @var ImportJob */
|
||||
private $importJob;
|
||||
/** @var ImportJobRepositoryInterface */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* Return true when this stage is complete.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function configurationComplete(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the job configuration.
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @return MessageBag
|
||||
*/
|
||||
public function configureJob(array $data): MessageBag
|
||||
{
|
||||
return new MessageBag();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data for config view.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getNextData(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view for this stage.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNextView(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the import job.
|
||||
*
|
||||
* @param ImportJob $importJob
|
||||
*/
|
||||
public function setImportJob(ImportJob $importJob): void
|
||||
{
|
||||
$this->importJob = $importJob;
|
||||
$this->repository = app(ImportJobRepositoryInterface::class);
|
||||
$this->repository->setUser($importJob->user);
|
||||
}
|
||||
}
|
241
app/Support/Import/JobConfiguration/Spectre/ChooseAccount.php
Normal file
241
app/Support/Import/JobConfiguration/Spectre/ChooseAccount.php
Normal file
@ -0,0 +1,241 @@
|
||||
<?php
|
||||
/**
|
||||
* ChooseAccount.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Import\JobConfiguration\Spectre;
|
||||
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Account as AccountModel;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\ImportJob;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||
use FireflyIII\Services\Spectre\Object\Account as SpectreAccount;
|
||||
use FireflyIII\Services\Spectre\Object\Login;
|
||||
use Illuminate\Support\MessageBag;
|
||||
|
||||
/**
|
||||
* Class ChooseAccount
|
||||
*
|
||||
* @package FireflyIII\Support\Import\JobConfiguration\Spectre
|
||||
*/
|
||||
class ChooseAccount implements SpectreJobConfig
|
||||
{
|
||||
|
||||
/** @var AccountRepositoryInterface */
|
||||
private $accountRepository;
|
||||
/** @var CurrencyRepositoryInterface */
|
||||
private $currencyRepository;
|
||||
/** @var ImportJob */
|
||||
private $importJob;
|
||||
/** @var ImportJobRepositoryInterface */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* Return true when this stage is complete.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function configurationComplete(): bool
|
||||
{
|
||||
$config = $this->importJob->configuration;
|
||||
$importAccounts = $config['account_mapping'] ?? [];
|
||||
$complete = \count($importAccounts) > 0 && $importAccounts !== [0 => 0];
|
||||
if ($complete) {
|
||||
$this->repository->setStage($this->importJob, 'go-for-import');
|
||||
}
|
||||
|
||||
return $complete;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the job configuration.
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @return MessageBag
|
||||
*/
|
||||
public function configureJob(array $data): MessageBag
|
||||
{
|
||||
$config = $this->importJob->configuration;
|
||||
$mapping = $data['account_mapping'] ?? [];
|
||||
$final = [];
|
||||
foreach ($mapping as $spectreId => $fireflyIIIId) {
|
||||
// validate each
|
||||
$spectreId = $this->validSpectreAccount((int)$spectreId);
|
||||
$accountId = $this->validFireflyIIIAccount((int)$fireflyIIIId);
|
||||
$final[$spectreId] = $accountId;
|
||||
|
||||
}
|
||||
$messages = new MessageBag;
|
||||
$config['account_mapping'] = $final;
|
||||
|
||||
$this->repository->setConfiguration($this->importJob, $config);
|
||||
if (\count($final) === 0 || $final === [0 => 0]) {
|
||||
$messages->add('count', trans('import.spectre_no_mapping'));
|
||||
}
|
||||
|
||||
return $messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data for config view.
|
||||
*
|
||||
* @return array
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function getNextData(): array
|
||||
{
|
||||
$config = $this->importJob->configuration;
|
||||
$accounts = $config['accounts'] ?? [];
|
||||
if (\count($accounts) === 0) {
|
||||
throw new FireflyException('It seems you have no accounts with this bank. The import cannot continue.');
|
||||
}
|
||||
$converted = [];
|
||||
foreach ($accounts as $accountArray) {
|
||||
$converted[] = new SpectreAccount($accountArray);
|
||||
}
|
||||
|
||||
// get the provider that was used.
|
||||
$login = null;
|
||||
$logins = $config['all-logins'] ?? [];
|
||||
$selected = $config['selected-login'] ?? 0;
|
||||
if (\count($logins) === 0) {
|
||||
throw new FireflyException('It seems you have no configured logins in this import job. The import cannot continue.');
|
||||
}
|
||||
if ($selected === 0) {
|
||||
$login = new Login($logins[0]);
|
||||
}
|
||||
if ($selected !== 0) {
|
||||
foreach ($logins as $loginArray) {
|
||||
$loginId = $loginArray['id'] ?? -1;
|
||||
if ($loginId === $selected) {
|
||||
$login = new Login($loginArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (null === $login) {
|
||||
throw new FireflyException('Was not able to determine which login to use. The import cannot continue.');
|
||||
}
|
||||
|
||||
// list the users accounts:
|
||||
$accounts = $this->accountRepository->getAccountsByType([AccountType::ASSET]);
|
||||
|
||||
$array = [];
|
||||
/** @var AccountModel $account */
|
||||
foreach ($accounts as $account) {
|
||||
$accountId = $account->id;
|
||||
$currencyId = (int)$this->accountRepository->getMetaValue($account, 'currency_id');
|
||||
$currency = $this->getCurrency($currencyId);
|
||||
$array[$accountId] = [
|
||||
'name' => $account->name,
|
||||
'iban' => $account->iban,
|
||||
'code' => $currency->code,
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'accounts' => $converted,
|
||||
'ff_accounts' => $array,
|
||||
'login' => $login,
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view for this stage.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNextView(): string
|
||||
{
|
||||
return 'import.spectre.accounts';
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the import job.
|
||||
*
|
||||
* @param ImportJob $importJob
|
||||
*/
|
||||
public function setImportJob(ImportJob $importJob): void
|
||||
{
|
||||
$this->importJob = $importJob;
|
||||
$this->repository = app(ImportJobRepositoryInterface::class);
|
||||
$this->accountRepository = app(AccountRepositoryInterface::class);
|
||||
$this->currencyRepository = app(CurrencyRepositoryInterface::class);
|
||||
$this->repository->setUser($importJob->user);
|
||||
$this->currencyRepository->setUser($importJob->user);
|
||||
$this->accountRepository->setUser($importJob->user);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $currencyId
|
||||
*
|
||||
* @return TransactionCurrency
|
||||
*/
|
||||
private function getCurrency(int $currencyId): TransactionCurrency
|
||||
{
|
||||
$currency = $this->currencyRepository->findNull($currencyId);
|
||||
if (null === $currency) {
|
||||
return app('amount')->getDefaultCurrencyByUser($this->importJob->user);
|
||||
}
|
||||
|
||||
return $currency;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $accountId
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function validFireflyIIIAccount(int $accountId): int
|
||||
{
|
||||
$account = $this->accountRepository->findNull($accountId);
|
||||
if (null === $account) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $accountId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $accountId
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function validSpectreAccount(int $accountId): int
|
||||
{
|
||||
$config = $this->importJob->configuration;
|
||||
$accounts = $config['accounts'] ?? [];
|
||||
foreach ($accounts as $account) {
|
||||
if ((int)$account['id'] === $accountId) {
|
||||
return $accountId;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -0,0 +1,205 @@
|
||||
<?php
|
||||
/**
|
||||
* ChooseLoginHandler.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Import\JobConfiguration\Spectre;
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\ImportJob;
|
||||
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||
use FireflyIII\Services\Spectre\Object\Customer;
|
||||
use FireflyIII\Services\Spectre\Object\Login;
|
||||
use FireflyIII\Services\Spectre\Object\Token;
|
||||
use FireflyIII\Services\Spectre\Request\CreateTokenRequest;
|
||||
use FireflyIII\Services\Spectre\Request\ListCustomersRequest;
|
||||
use FireflyIII\Services\Spectre\Request\NewCustomerRequest;
|
||||
use Illuminate\Support\MessageBag;
|
||||
use Log;
|
||||
|
||||
|
||||
/**
|
||||
* Class ChooseLoginHandler
|
||||
*
|
||||
* @package FireflyIII\Support\Import\JobConfiguration\Spectre
|
||||
*/
|
||||
class ChooseLoginHandler implements SpectreJobConfig
|
||||
{
|
||||
/** @var ImportJob */
|
||||
private $importJob;
|
||||
/** @var ImportJobRepositoryInterface */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* Return true when this stage is complete.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function configurationComplete(): bool
|
||||
{
|
||||
$config = $this->importJob->configuration;
|
||||
if(isset($config['selected-login'])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the job configuration.
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @return MessageBag
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function configureJob(array $data): MessageBag
|
||||
{
|
||||
$selectedLogin = (int)$data['spectre_login_id'];
|
||||
$config = $this->importJob->configuration;
|
||||
$config['selected-login'] = $selectedLogin;
|
||||
$this->repository->setConfiguration($this->importJob, $config);
|
||||
|
||||
// if selected login is zero, create a new one.
|
||||
if ($selectedLogin === 0) {
|
||||
$customer = $this->getCustomer();
|
||||
// get a token for the user and redirect to next stage
|
||||
$token = $this->getToken($customer);
|
||||
$config['token'] = $token->toArray();
|
||||
$this->repository->setConfiguration($this->importJob, $config);
|
||||
// move job to correct stage to redirect to Spectre:
|
||||
$this->repository->setStage($this->importJob, 'authenticate');
|
||||
return new MessageBag;
|
||||
|
||||
}
|
||||
$this->repository->setStage($this->importJob, 'authenticated');
|
||||
return new MessageBag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data for config view.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getNextData(): array
|
||||
{
|
||||
$config = $this->importJob->configuration;
|
||||
$data = ['logins' => []];
|
||||
$logins = $config['all-logins'] ?? [];
|
||||
foreach ($logins as $login) {
|
||||
$data['logins'][] = new Login($login);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view for this stage.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNextView(): string
|
||||
{
|
||||
return 'import.spectre.choose-login';
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the import job.
|
||||
*
|
||||
* @param ImportJob $importJob
|
||||
*/
|
||||
public function setImportJob(ImportJob $importJob): void
|
||||
{
|
||||
$this->importJob = $importJob;
|
||||
$this->repository = app(ImportJobRepositoryInterface::class);
|
||||
$this->repository->setUser($importJob->user);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Customer
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function getCustomer(): Customer
|
||||
{
|
||||
Log::debug('Now in stageNewHandler::getCustomer()');
|
||||
$customer = $this->getExistingCustomer();
|
||||
if (null === $customer) {
|
||||
Log::debug('The customer is NULL, will fire a newCustomerRequest.');
|
||||
$newCustomerRequest = new NewCustomerRequest($this->importJob->user);
|
||||
$customer = $newCustomerRequest->getCustomer();
|
||||
|
||||
}
|
||||
Log::debug('The customer is not null.');
|
||||
|
||||
return $customer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Customer|null
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function getExistingCustomer(): ?Customer
|
||||
{
|
||||
Log::debug('Now in getExistingCustomer()');
|
||||
$preference = app('preferences')->getForUser($this->importJob->user, 'spectre_customer');
|
||||
if (null !== $preference) {
|
||||
Log::debug('Customer is in user configuration');
|
||||
$customer = new Customer($preference->data);
|
||||
|
||||
return $customer;
|
||||
}
|
||||
Log::debug('Customer is not in user config');
|
||||
$customer = null;
|
||||
$getCustomerRequest = new ListCustomersRequest($this->importJob->user);
|
||||
$getCustomerRequest->call();
|
||||
$customers = $getCustomerRequest->getCustomers();
|
||||
|
||||
Log::debug(sprintf('Found %d customer(s)', \count($customers)));
|
||||
/** @var Customer $current */
|
||||
foreach ($customers as $current) {
|
||||
if ('default_ff3_customer' === $current->getIdentifier()) {
|
||||
$customer = $current;
|
||||
Log::debug('Found the correct customer.');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $customer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Customer $customer
|
||||
*
|
||||
* @throws FireflyException
|
||||
* @return Token
|
||||
*/
|
||||
private function getToken(Customer $customer): Token
|
||||
{
|
||||
Log::debug('Now in ChooseLoginsHandler::getToken()');
|
||||
$request = new CreateTokenRequest($this->importJob->user);
|
||||
$request->setUri(route('import.job.status.index', [$this->importJob->key]));
|
||||
$request->setCustomer($customer);
|
||||
$request->call();
|
||||
Log::debug('Call to get token is finished');
|
||||
|
||||
return $request->getToken();
|
||||
}
|
||||
}
|
89
app/Support/Import/JobConfiguration/Spectre/NewConfig.php
Normal file
89
app/Support/Import/JobConfiguration/Spectre/NewConfig.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/**
|
||||
* NewConfig.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Import\JobConfiguration\Spectre;
|
||||
|
||||
|
||||
use FireflyIII\Models\ImportJob;
|
||||
use Illuminate\Support\MessageBag;
|
||||
|
||||
/**
|
||||
* Class NewConfig
|
||||
*
|
||||
* @package FireflyIII\Support\Import\JobConfiguration\Spectre
|
||||
*/
|
||||
class NewConfig implements SpectreJobConfig
|
||||
{
|
||||
|
||||
/**
|
||||
* Return true when this stage is complete.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function configurationComplete(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the job configuration.
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @return MessageBag
|
||||
*/
|
||||
public function configureJob(array $data): MessageBag
|
||||
{
|
||||
return new MessageBag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data for config view.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getNextData(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view for this stage.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNextView(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the import job.
|
||||
*
|
||||
* @param ImportJob $importJob
|
||||
*/
|
||||
public function setImportJob(ImportJob $importJob): void
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* SpectreJobConfig.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Import\JobConfiguration\Spectre;
|
||||
|
||||
|
||||
use FireflyIII\Models\ImportJob;
|
||||
use Illuminate\Support\MessageBag;
|
||||
|
||||
interface SpectreJobConfig
|
||||
{
|
||||
/**
|
||||
* Return true when this stage is complete.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function configurationComplete(): bool;
|
||||
|
||||
|
||||
/**
|
||||
* Store the job configuration.
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @return MessageBag
|
||||
*/
|
||||
public function configureJob(array $data): MessageBag;
|
||||
|
||||
/**
|
||||
* Get data for config view.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getNextData(): array;
|
||||
|
||||
/**
|
||||
* Get the view for this stage.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNextView(): string;
|
||||
|
||||
/**
|
||||
* Set the import job.
|
||||
*
|
||||
* @param ImportJob $importJob
|
||||
*/
|
||||
public function setImportJob(ImportJob $importJob): void;
|
||||
|
||||
}
|
62
app/Support/Import/Routine/Spectre/ImportDataHandler.php
Normal file
62
app/Support/Import/Routine/Spectre/ImportDataHandler.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* ImportDataHandler.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Import\Routine\Spectre;
|
||||
|
||||
|
||||
use FireflyIII\Models\ImportJob;
|
||||
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||
|
||||
/**
|
||||
* Class ImportDataHandler
|
||||
*
|
||||
* @package FireflyIII\Support\Import\Routine\Spectre
|
||||
*/
|
||||
class ImportDataHandler
|
||||
{
|
||||
/** @var ImportJob */
|
||||
private $importJob;
|
||||
/** @var ImportJobRepositoryInterface */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
die('here we are');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ImportJob $importJob
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setImportJob(ImportJob $importJob): void
|
||||
{
|
||||
$this->importJob = $importJob;
|
||||
$this->repository = app(ImportJobRepositoryInterface::class);
|
||||
$this->repository->setUser($importJob->user);
|
||||
}
|
||||
}
|
133
app/Support/Import/Routine/Spectre/ManageLoginsHandler.php
Normal file
133
app/Support/Import/Routine/Spectre/ManageLoginsHandler.php
Normal file
@ -0,0 +1,133 @@
|
||||
<?php
|
||||
/**
|
||||
* ManageLoginsHandler.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Import\Routine\Spectre;
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\ImportJob;
|
||||
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||
use FireflyIII\Services\Spectre\Object\Customer;
|
||||
use FireflyIII\Services\Spectre\Object\Login;
|
||||
use FireflyIII\Services\Spectre\Request\ListCustomersRequest;
|
||||
use FireflyIII\Services\Spectre\Request\ListLoginsRequest;
|
||||
use FireflyIII\Services\Spectre\Request\NewCustomerRequest;
|
||||
use Log;
|
||||
|
||||
class ManageLoginsHandler
|
||||
{
|
||||
|
||||
|
||||
public $countLogins = 0;
|
||||
/** @var ImportJob */
|
||||
private $importJob;
|
||||
/** @var ImportJobRepositoryInterface */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* Tasks for this stage:
|
||||
*
|
||||
* - List all of the users logins.
|
||||
* - If zero, return to "get-token" stage and make user make a login. That stage redirects here.
|
||||
* - If one or more, list and let user select.
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$customer = $this->getCustomer();
|
||||
|
||||
$request = new ListLoginsRequest($this->importJob->user);
|
||||
$request->setCustomer($customer);
|
||||
$request->call();
|
||||
|
||||
$list = $request->getLogins();
|
||||
|
||||
// count is zero?
|
||||
$this->countLogins = \count($list);
|
||||
if ($this->countLogins > 0) {
|
||||
$store = [];
|
||||
/** @var Login $login */
|
||||
foreach ($list as $login) {
|
||||
$store[] = $login->toArray();
|
||||
}
|
||||
$config = $this->repository->getConfiguration($this->importJob);
|
||||
$config['all-logins'] = $store;
|
||||
$this->repository->setConfiguration($this->importJob, $config);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ImportJob $importJob
|
||||
*/
|
||||
public function setImportJob(ImportJob $importJob): void
|
||||
{
|
||||
$this->importJob = $importJob;
|
||||
$this->repository = app(ImportJobRepositoryInterface::class);
|
||||
$this->repository->setUser($importJob->user);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Customer
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function getCustomer(): Customer
|
||||
{
|
||||
Log::debug('Now in manageLoginsHandler::getCustomer()');
|
||||
$customer = $this->getExistingCustomer();
|
||||
if (null === $customer) {
|
||||
Log::debug('The customer is NULL, will fire a newCustomerRequest.');
|
||||
$newCustomerRequest = new NewCustomerRequest($this->importJob->user);
|
||||
$customer = $newCustomerRequest->getCustomer();
|
||||
|
||||
}
|
||||
Log::debug('The customer is not null.');
|
||||
|
||||
return $customer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Customer|null
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function getExistingCustomer(): ?Customer
|
||||
{
|
||||
Log::debug('Now in getExistingCustomer()');
|
||||
$customer = null;
|
||||
$getCustomerRequest = new ListCustomersRequest($this->importJob->user);
|
||||
$getCustomerRequest->call();
|
||||
$customers = $getCustomerRequest->getCustomers();
|
||||
|
||||
Log::debug(sprintf('Found %d customer(s)', \count($customers)));
|
||||
/** @var Customer $current */
|
||||
foreach ($customers as $current) {
|
||||
if ('default_ff3_customer' === $current->getIdentifier()) {
|
||||
$customer = $current;
|
||||
Log::debug('Found the correct customer.');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $customer;
|
||||
}
|
||||
|
||||
}
|
105
app/Support/Import/Routine/Spectre/StageAuthenticatedHandler.php
Normal file
105
app/Support/Import/Routine/Spectre/StageAuthenticatedHandler.php
Normal file
@ -0,0 +1,105 @@
|
||||
<?php
|
||||
/**
|
||||
* StageAuthenticatedHandler.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Import\Routine\Spectre;
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\ImportJob;
|
||||
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||
use FireflyIII\Services\Spectre\Object\Account;
|
||||
use FireflyIII\Services\Spectre\Object\Login;
|
||||
use FireflyIII\Services\Spectre\Request\ListAccountsRequest;
|
||||
|
||||
class StageAuthenticatedHandler
|
||||
{
|
||||
/** @var ImportJob */
|
||||
private $importJob;
|
||||
/** @var ImportJobRepositoryInterface */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* User has selected a login (a bank). Will grab all accounts from this bank.
|
||||
* Then make user pick some to import from.
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// grab a list of logins.
|
||||
$config = $this->importJob->configuration;
|
||||
$logins = $config['all-logins'] ?? [];
|
||||
if (\count($logins) === 0) {
|
||||
throw new FireflyException('StageAuthenticatedHandler expects more than 0 logins. Apologies, the import has stopped.');
|
||||
}
|
||||
|
||||
$selectedLogin = $config['selected-login'];
|
||||
$login = null;
|
||||
foreach ($logins as $loginArray) {
|
||||
$loginId = $loginArray['id'] ?? -1;
|
||||
if ($loginId === $selectedLogin) {
|
||||
$login = new Login($loginArray);
|
||||
}
|
||||
}
|
||||
if (null === $login) {
|
||||
$login = new Login($logins[0]);
|
||||
}
|
||||
|
||||
// with existing login we can grab accounts from this login.
|
||||
$accounts = $this->getAccounts($login);
|
||||
$config['accounts'] = [];
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
$config['accounts'][] = $account->toArray();
|
||||
}
|
||||
$this->repository->setConfiguration($this->importJob, $config);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ImportJob $importJob
|
||||
*/
|
||||
public function setImportJob(ImportJob $importJob): void
|
||||
{
|
||||
$this->importJob = $importJob;
|
||||
$this->repository = app(ImportJobRepositoryInterface::class);
|
||||
$this->repository->setUser($importJob->user);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Login $login
|
||||
*
|
||||
* @return array
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function getAccounts(Login $login): array
|
||||
{
|
||||
$request = new ListAccountsRequest($this->importJob->user);
|
||||
$request->setLogin($login);
|
||||
$request->call();
|
||||
$accounts = $request->getAccounts();
|
||||
|
||||
return $accounts;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -61,11 +61,14 @@ class StageNewHandler
|
||||
{
|
||||
Log::debug('Now in stageNewHandler::run()');
|
||||
$customer = $this->getCustomer();
|
||||
// get token using customer.
|
||||
$token = $this->getToken($customer);
|
||||
|
||||
// get token using customer.
|
||||
app('preferences')->setForUser($this->importJob->user, 'spectre_customer', $customer->toArray());
|
||||
app('preferences')->setForUser($this->importJob->user, 'spectre_token', $token->toArray());
|
||||
|
||||
// store token in the job.
|
||||
$config = $this->repository->getConfiguration($this->importJob);
|
||||
|
||||
$this->repository->setConfiguration($this->importJob, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -122,23 +125,6 @@ class StageNewHandler
|
||||
return $customer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Customer $customer
|
||||
*
|
||||
* @throws FireflyException
|
||||
* @return Token
|
||||
*/
|
||||
private function getToken(Customer $customer): Token
|
||||
{
|
||||
Log::debug('Now in getToken()');
|
||||
$request = new CreateTokenRequest($this->importJob->user);
|
||||
$request->setUri(route('import.job.status.index', [$this->importJob->key]));
|
||||
$request->setCustomer($customer);
|
||||
$request->call();
|
||||
Log::debug('Call to get token is finished');
|
||||
|
||||
return $request->getToken();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -88,9 +88,9 @@ return [
|
||||
'is_demo_site' => false,
|
||||
],
|
||||
'encryption' => null === env('USE_ENCRYPTION') || env('USE_ENCRYPTION') === true,
|
||||
'version' => '4.7.3.2',
|
||||
'version' => '4.7.4',
|
||||
'api_version' => '0.3',
|
||||
'db_version' => 3,
|
||||
'db_version' => 4,
|
||||
'maxUploadSize' => 15242880,
|
||||
'allowedMimes' => [
|
||||
/* plain files */
|
||||
|
@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
use FireflyIII\Import\JobConfiguration\FakeJobConfiguration;
|
||||
use FireflyIII\Import\JobConfiguration\FileJobConfiguration;
|
||||
use FireflyIII\Import\JobConfiguration\SpectreJobConfiguration;
|
||||
use FireflyIII\Import\Prerequisites\FakePrerequisites;
|
||||
use FireflyIII\Import\Prerequisites\SpectrePrerequisites;
|
||||
use FireflyIII\Import\Routine\FakeRoutine;
|
||||
@ -87,7 +88,7 @@ return [
|
||||
'fake' => true,
|
||||
'file' => true,
|
||||
'bunq' => false,
|
||||
'spectre' => false,
|
||||
'spectre' => true,
|
||||
'plaid' => false,
|
||||
'quovo' => false,
|
||||
'yodlee' => false,
|
||||
@ -97,7 +98,7 @@ return [
|
||||
'fake' => FakeJobConfiguration::class,
|
||||
'file' => FileJobConfiguration::class,
|
||||
'bunq' => false,
|
||||
'spectre' => false,
|
||||
'spectre' => SpectreJobConfiguration::class,
|
||||
'plaid' => false,
|
||||
'quovo' => false,
|
||||
'yodlee' => false,
|
||||
|
7
public/js/ff/import/status_v2.js
vendored
7
public/js/ff/import/status_v2.js
vendored
@ -66,11 +66,12 @@ function reportJobJSONDone(data) {
|
||||
recheckJobJSONStatus();
|
||||
break;
|
||||
case "need_job_config":
|
||||
console.log("Will redirect user to " + jobConfigurationUri);
|
||||
// redirect user to configuration for this job.
|
||||
window.location.replace(jobConfigurationUri);
|
||||
break;
|
||||
case 'error':
|
||||
reportJobError();
|
||||
reportJobError(data);
|
||||
break;
|
||||
case 'provider_finished':
|
||||
// call routine to store stuff:
|
||||
@ -251,7 +252,7 @@ function reportJobPOSTFailure(xhr, status, error) {
|
||||
/**
|
||||
* Show error to user.
|
||||
*/
|
||||
function reportJobError() {
|
||||
function reportJobError(data) {
|
||||
console.log('In reportJobError()');
|
||||
// cancel checking again for job status:
|
||||
clearTimeout(timeOutId);
|
||||
@ -262,7 +263,7 @@ function reportJobError() {
|
||||
// show fatal error box:
|
||||
$('.fatal_error').show();
|
||||
|
||||
$('.fatal_error_txt').text('Job reports error. Please start again. Apologies.');
|
||||
$('.fatal_error_txt').text('Job reports error. Please start again. Apologies. Error message is: ' + data.report_txt);
|
||||
// show error box.
|
||||
}
|
||||
|
||||
|
@ -24,195 +24,229 @@ declare(strict_types=1);
|
||||
|
||||
return [
|
||||
// ALL breadcrumbs and subtitles:
|
||||
'index_breadcrumb' => 'Import data into Firefly III',
|
||||
'prerequisites_breadcrumb_fake' => 'Prerequisites for the fake import provider',
|
||||
'prerequisites_breadcrumb_spectre' => 'Prerequisites for Spectre',
|
||||
'job_configuration_breadcrumb' => 'Configuration for ":key"',
|
||||
'job_status_breadcrumb' => 'Import status for ":key"',
|
||||
'cannot_create_for_provider' => 'Firefly III cannot create a job for the ":provider"-provider.',
|
||||
'index_breadcrumb' => 'Import data into Firefly III',
|
||||
'prerequisites_breadcrumb_fake' => 'Prerequisites for the fake import provider',
|
||||
'prerequisites_breadcrumb_spectre' => 'Prerequisites for Spectre',
|
||||
'job_configuration_breadcrumb' => 'Configuration for ":key"',
|
||||
'job_status_breadcrumb' => 'Import status for ":key"',
|
||||
'cannot_create_for_provider' => 'Firefly III cannot create a job for the ":provider"-provider.',
|
||||
|
||||
// index page:
|
||||
'general_index_title' => 'Import a file',
|
||||
'general_index_intro' => 'Welcome to Firefly III\'s import routine. There are a few ways of importing data into Firefly III, displayed here as buttons.',
|
||||
'general_index_title' => 'Import a file',
|
||||
'general_index_intro' => 'Welcome to Firefly III\'s import routine. There are a few ways of importing data into Firefly III, displayed here as buttons.',
|
||||
// import provider strings (index):
|
||||
'button_fake' => 'Fake an import',
|
||||
'button_file' => 'Import a file',
|
||||
'button_bunq' => 'Import from bunq',
|
||||
'button_spectre' => 'Import using Spectre',
|
||||
'button_plaid' => 'Import using Plaid',
|
||||
'button_yodlee' => 'Import using Yodlee',
|
||||
'button_quovo' => 'Import using Quovo',
|
||||
'button_fake' => 'Fake an import',
|
||||
'button_file' => 'Import a file',
|
||||
'button_bunq' => 'Import from bunq',
|
||||
'button_spectre' => 'Import using Spectre',
|
||||
'button_plaid' => 'Import using Plaid',
|
||||
'button_yodlee' => 'Import using Yodlee',
|
||||
'button_quovo' => 'Import using Quovo',
|
||||
// global config box (index)
|
||||
'global_config_title' => 'Global import configuration',
|
||||
'global_config_text' => 'In the future, this box will feature preferences that apply to ALL import providers above.',
|
||||
'global_config_title' => 'Global import configuration',
|
||||
'global_config_text' => 'In the future, this box will feature preferences that apply to ALL import providers above.',
|
||||
// prerequisites box (index)
|
||||
'need_prereq_title' => 'Import prerequisites',
|
||||
'need_prereq_intro' => 'Some import methods need your attention before they can be used. For example, they might require special API keys or application secrets. You can configure them here. The icon indicates if these prerequisites have been met.',
|
||||
'do_prereq_fake' => 'Prerequisites for the fake provider',
|
||||
'do_prereq_file' => 'Prerequisites for file imports',
|
||||
'do_prereq_bunq' => 'Prerequisites for imports from bunq',
|
||||
'do_prereq_spectre' => 'Prerequisites for imports using Spectre',
|
||||
'do_prereq_plaid' => 'Prerequisites for imports using Plaid',
|
||||
'do_prereq_yodlee' => 'Prerequisites for imports using Yodlee',
|
||||
'do_prereq_quovo' => 'Prerequisites for imports using Quovo',
|
||||
'need_prereq_title' => 'Import prerequisites',
|
||||
'need_prereq_intro' => 'Some import methods need your attention before they can be used. For example, they might require special API keys or application secrets. You can configure them here. The icon indicates if these prerequisites have been met.',
|
||||
'do_prereq_fake' => 'Prerequisites for the fake provider',
|
||||
'do_prereq_file' => 'Prerequisites for file imports',
|
||||
'do_prereq_bunq' => 'Prerequisites for imports from bunq',
|
||||
'do_prereq_spectre' => 'Prerequisites for imports using Spectre',
|
||||
'do_prereq_plaid' => 'Prerequisites for imports using Plaid',
|
||||
'do_prereq_yodlee' => 'Prerequisites for imports using Yodlee',
|
||||
'do_prereq_quovo' => 'Prerequisites for imports using Quovo',
|
||||
// provider config box (index)
|
||||
'can_config_title' => 'Import configuration',
|
||||
'can_config_intro' => 'Some import methods can be configured to your liking. They have extra settings you can tweak.',
|
||||
'do_config_fake' => 'Configuration for the fake provider',
|
||||
'do_config_file' => 'Configuration for file imports',
|
||||
'do_config_bunq' => 'Configuration for bunq imports',
|
||||
'do_config_spectre' => 'Configuration for imports from Spectre',
|
||||
'do_config_plaid' => 'Configuration for imports from Plaid',
|
||||
'do_config_yodlee' => 'Configuration for imports from Yodlee',
|
||||
'do_config_quovo' => 'Configuration for imports from Quovo',
|
||||
'can_config_title' => 'Import configuration',
|
||||
'can_config_intro' => 'Some import methods can be configured to your liking. They have extra settings you can tweak.',
|
||||
'do_config_fake' => 'Configuration for the fake provider',
|
||||
'do_config_file' => 'Configuration for file imports',
|
||||
'do_config_bunq' => 'Configuration for bunq imports',
|
||||
'do_config_spectre' => 'Configuration for imports from Spectre',
|
||||
'do_config_plaid' => 'Configuration for imports from Plaid',
|
||||
'do_config_yodlee' => 'Configuration for imports from Yodlee',
|
||||
'do_config_quovo' => 'Configuration for imports from Quovo',
|
||||
|
||||
// prerequisites:
|
||||
'prereq_fake_title' => 'Prerequisites for an import from the fake import provider',
|
||||
'prereq_fake_text' => 'This fake provider requires a fake API key. It must be 32 characters long. You can use this one: 123456789012345678901234567890AA',
|
||||
'prereq_spectre_title' => 'Prerequisites for an import using the Spectre API',
|
||||
'prereq_spectre_text' => 'In order to import data using the Spectre API (v4), you must provide Firefly III with two secret values. They can be found on the <a href="https://www.saltedge.com/clients/profile/secrets">secrets page</a>.',
|
||||
'prereq_spectre_pub' => 'Likewise, the Spectre API needs to know the public key you see below. Without it, it will not recognize you. Please enter this public key on your <a href="https://www.saltedge.com/clients/profile/secrets">secrets page</a>.',
|
||||
'prereq_fake_title' => 'Prerequisites for an import from the fake import provider',
|
||||
'prereq_fake_text' => 'This fake provider requires a fake API key. It must be 32 characters long. You can use this one: 123456789012345678901234567890AA',
|
||||
'prereq_spectre_title' => 'Prerequisites for an import using the Spectre API',
|
||||
'prereq_spectre_text' => 'In order to import data using the Spectre API (v4), you must provide Firefly III with two secret values. They can be found on the <a href="https://www.saltedge.com/clients/profile/secrets">secrets page</a>.',
|
||||
'prereq_spectre_pub' => 'Likewise, the Spectre API needs to know the public key you see below. Without it, it will not recognize you. Please enter this public key on your <a href="https://www.saltedge.com/clients/profile/secrets">secrets page</a>.',
|
||||
// prerequisites success messages:
|
||||
'prerequisites_saved_for_fake' => 'Fake API key stored successfully!',
|
||||
'prerequisites_saved_for_spectre' => 'App ID and secret stored!',
|
||||
'prerequisites_saved_for_fake' => 'Fake API key stored successfully!',
|
||||
'prerequisites_saved_for_spectre' => 'App ID and secret stored!',
|
||||
|
||||
// job configuration:
|
||||
'job_config_apply_rules_title' => 'Job configuration - apply your rules?',
|
||||
'job_config_apply_rules_text' => 'Once the fake provider has run, your rules can be applied to the transactions. This adds time to the import.',
|
||||
'job_config_input' => 'Your input',
|
||||
'job_config_apply_rules_title' => 'Job configuration - apply your rules?',
|
||||
'job_config_apply_rules_text' => 'Once the fake provider has run, your rules can be applied to the transactions. This adds time to the import.',
|
||||
'job_config_input' => 'Your input',
|
||||
// job configuration for the fake provider:
|
||||
'job_config_fake_artist_title' => 'Enter album name',
|
||||
'job_config_fake_artist_text' => 'Many import routines have a few configuration steps you must go through. In the case of the fake import provider, you must answer some weird questions. In this case, enter "David Bowie" to continue.',
|
||||
'job_config_fake_song_title' => 'Enter song name',
|
||||
'job_config_fake_song_text' => 'Mention the song "Golden years" to continue with the fake import.',
|
||||
'job_config_fake_album_title' => 'Enter album name',
|
||||
'job_config_fake_album_text' => 'Some import routines require extra data halfway through the import. In the case of the fake import provider, you must answer some weird questions. Enter "Station to station" to continue.',
|
||||
'job_config_fake_artist_title' => 'Enter album name',
|
||||
'job_config_fake_artist_text' => 'Many import routines have a few configuration steps you must go through. In the case of the fake import provider, you must answer some weird questions. In this case, enter "David Bowie" to continue.',
|
||||
'job_config_fake_song_title' => 'Enter song name',
|
||||
'job_config_fake_song_text' => 'Mention the song "Golden years" to continue with the fake import.',
|
||||
'job_config_fake_album_title' => 'Enter album name',
|
||||
'job_config_fake_album_text' => 'Some import routines require extra data halfway through the import. In the case of the fake import provider, you must answer some weird questions. Enter "Station to station" to continue.',
|
||||
// job configuration form the file provider
|
||||
'job_config_file_upload_title' => 'Import setup (1/4) - Upload your file',
|
||||
'job_config_file_upload_text' => 'This routine will help you import files from your bank into Firefly III. ',
|
||||
'job_config_file_upload_help' => 'Select your file. Please make sure the file is UTF-8 encoded.',
|
||||
'job_config_file_upload_config_help' => 'If you have previously imported data into Firefly III, you may have a configuration file, which will pre-set configuration values for you. For some banks, other users have kindly provided their <a href="https://github.com/firefly-iii/import-configurations/wiki">configuration file</a>',
|
||||
'job_config_file_upload_type_help' => 'Select the type of file you will upload',
|
||||
'job_config_file_upload_submit' => 'Upload files',
|
||||
'import_file_type_csv' => 'CSV (comma separated values)',
|
||||
'file_not_utf8' => 'The file you have uploaded is not encoded as UTF-8 or ASCII. Firefly III cannot handle such files. Please use Notepad++ or Sublime to convert your file to UTF-8.',
|
||||
'job_config_uc_title' => 'Import setup (2/4) - Basic file setup',
|
||||
'job_config_uc_text' => 'To be able to import your file correctly, please validate the options below.',
|
||||
'job_config_uc_header_help' => 'Check this box if the first row of your CSV file are the column titles.',
|
||||
'job_config_uc_date_help' => 'Date time format in your file. Follow the format as <a href="https://secure.php.net/manual/en/datetime.createfromformat.php#refsect1-datetime.createfromformat-parameters">this page</a> indicates. The default value will parse dates that look like this: :dateExample.',
|
||||
'job_config_uc_delimiter_help' => 'Choose the field delimiter that is used in your input file. If not sure, comma is the safest option.',
|
||||
'job_config_uc_account_help' => 'If your file does NOT contain information about your asset account(s), use this dropdown to select to which account the transactions in the file belong to.',
|
||||
'job_config_uc_apply_rules_title' => 'Apply rules',
|
||||
'job_config_uc_apply_rules_text' => 'Applies your rules to every imported transaction. Note that this slows the import significantly.',
|
||||
'job_config_uc_specifics_title' => 'Bank-specific options',
|
||||
'job_config_uc_specifics_txt' => 'Some banks deliver badly formatted files. Firefly III can fix those automatically. If your bank delivers such files but it\'s not listed here, please open an issue on GitHub.',
|
||||
'job_config_uc_submit' => 'Continue',
|
||||
'invalid_import_account' => 'You have selected an invalid account to import into.',
|
||||
'job_config_file_upload_title' => 'Import setup (1/4) - Upload your file',
|
||||
'job_config_file_upload_text' => 'This routine will help you import files from your bank into Firefly III. ',
|
||||
'job_config_file_upload_help' => 'Select your file. Please make sure the file is UTF-8 encoded.',
|
||||
'job_config_file_upload_config_help' => 'If you have previously imported data into Firefly III, you may have a configuration file, which will pre-set configuration values for you. For some banks, other users have kindly provided their <a href="https://github.com/firefly-iii/import-configurations/wiki">configuration file</a>',
|
||||
'job_config_file_upload_type_help' => 'Select the type of file you will upload',
|
||||
'job_config_file_upload_submit' => 'Upload files',
|
||||
'import_file_type_csv' => 'CSV (comma separated values)',
|
||||
'file_not_utf8' => 'The file you have uploaded is not encoded as UTF-8 or ASCII. Firefly III cannot handle such files. Please use Notepad++ or Sublime to convert your file to UTF-8.',
|
||||
'job_config_uc_title' => 'Import setup (2/4) - Basic file setup',
|
||||
'job_config_uc_text' => 'To be able to import your file correctly, please validate the options below.',
|
||||
'job_config_uc_header_help' => 'Check this box if the first row of your CSV file are the column titles.',
|
||||
'job_config_uc_date_help' => 'Date time format in your file. Follow the format as <a href="https://secure.php.net/manual/en/datetime.createfromformat.php#refsect1-datetime.createfromformat-parameters">this page</a> indicates. The default value will parse dates that look like this: :dateExample.',
|
||||
'job_config_uc_delimiter_help' => 'Choose the field delimiter that is used in your input file. If not sure, comma is the safest option.',
|
||||
'job_config_uc_account_help' => 'If your file does NOT contain information about your asset account(s), use this dropdown to select to which account the transactions in the file belong to.',
|
||||
'job_config_uc_apply_rules_title' => 'Apply rules',
|
||||
'job_config_uc_apply_rules_text' => 'Applies your rules to every imported transaction. Note that this slows the import significantly.',
|
||||
'job_config_uc_specifics_title' => 'Bank-specific options',
|
||||
'job_config_uc_specifics_txt' => 'Some banks deliver badly formatted files. Firefly III can fix those automatically. If your bank delivers such files but it\'s not listed here, please open an issue on GitHub.',
|
||||
'job_config_uc_submit' => 'Continue',
|
||||
'invalid_import_account' => 'You have selected an invalid account to import into.',
|
||||
// job configuration for Spectre:
|
||||
'job_config_spectre_login_title' => 'Choose your login',
|
||||
'job_config_spectre_login_text' => 'Firefly III has found :count existing login(s) in your Spectre account. Which one would you like to use to import from?',
|
||||
'spectre_login_status_active' => 'Active',
|
||||
'spectre_login_status_inactive' => 'Inactive',
|
||||
'spectre_login_status_disabled' => 'Disabled',
|
||||
'spectre_login_new_login' => 'Login with another bank, or one of these banks with different credentials.',
|
||||
'job_config_spectre_accounts_title' => 'Select accounts to import from',
|
||||
'job_config_spectre_accounts_text' => 'You have selected ":name" (:country). You have :count account(s) available from this provider. Please select the Firefly III asset account(s) where the transactions from these accounts should be stored. Remember, in order to import data both the Firefly III account and the ":name"-account must have the same currency.',
|
||||
'spectre_no_supported_accounts' => 'You cannot import from this account due to a currency mismatch.',
|
||||
'spectre_do_not_import' => '(do not import)',
|
||||
'spectre_no_mapping' => 'It seems you have not selected any accounts to import from.',
|
||||
|
||||
// keys from "extra" array:
|
||||
'spectre_extra_key_iban' => 'IBAN',
|
||||
'spectre_extra_key_swift' => 'SWIFT',
|
||||
'spectre_extra_key_status' => 'Status',
|
||||
'spectre_extra_key_card_type' => 'Card type',
|
||||
'spectre_extra_key_account_name' => 'Account name',
|
||||
'spectre_extra_key_client_name' => 'Client name',
|
||||
'spectre_extra_key_account_number' => 'Account number',
|
||||
'spectre_extra_key_blocked_amount' => 'Blocked amount',
|
||||
'spectre_extra_key_available_amount' => 'Available amount',
|
||||
'spectre_extra_key_credit_limit' => 'Credit limit',
|
||||
'spectre_extra_key_interest_rate' => 'Interest rate',
|
||||
'spectre_extra_key_expiry_date' => 'Expiry date',
|
||||
'spectre_extra_key_open_date' => 'Open date',
|
||||
'spectre_extra_key_current_time' => 'Current time',
|
||||
'spectre_extra_key_current_date' => 'Current date',
|
||||
'spectre_extra_key_cards' => 'Cards',
|
||||
'spectre_extra_key_units' => 'Units',
|
||||
'spectre_extra_key_unit_price' => 'Unit price',
|
||||
'spectre_extra_key_transactions_count' => 'Transaction count',
|
||||
|
||||
// specifics:
|
||||
'specific_ing_name' => 'ING NL',
|
||||
'specific_ing_descr' => 'Create better descriptions in ING exports',
|
||||
'specific_sns_name' => 'SNS / Volksbank NL',
|
||||
'specific_sns_descr' => 'Trim quotes from SNS / Volksbank export files',
|
||||
'specific_abn_name' => 'ABN AMRO NL',
|
||||
'specific_abn_descr' => 'Fixes potential problems with ABN AMRO files',
|
||||
'specific_rabo_name' => 'Rabobank NL',
|
||||
'specific_rabo_descr' => 'Fixes potential problems with Rabobank files',
|
||||
'specific_pres_name' => 'President\'s Choice Financial CA',
|
||||
'specific_pres_descr' => 'Fixes potential problems with PC files',
|
||||
'specific_ing_name' => 'ING NL',
|
||||
'specific_ing_descr' => 'Create better descriptions in ING exports',
|
||||
'specific_sns_name' => 'SNS / Volksbank NL',
|
||||
'specific_sns_descr' => 'Trim quotes from SNS / Volksbank export files',
|
||||
'specific_abn_name' => 'ABN AMRO NL',
|
||||
'specific_abn_descr' => 'Fixes potential problems with ABN AMRO files',
|
||||
'specific_rabo_name' => 'Rabobank NL',
|
||||
'specific_rabo_descr' => 'Fixes potential problems with Rabobank files',
|
||||
'specific_pres_name' => 'President\'s Choice Financial CA',
|
||||
'specific_pres_descr' => 'Fixes potential problems with PC files',
|
||||
// job configuration for file provider (stage: roles)
|
||||
'job_config_roles_title' => 'Import setup (3/4) - Define each column\'s role',
|
||||
'job_config_roles_text' => 'Each column in your CSV file contains certain data. Please indicate what kind of data the importer should expect. The option to "map" data means that you will link each entry found in the column to a value in your database. An often mapped column is the column that contains the IBAN of the opposing account. That can be easily matched to IBAN\'s present in your database already.',
|
||||
'job_config_roles_submit' => 'Continue',
|
||||
'job_config_roles_column_name' => 'Name of column',
|
||||
'job_config_roles_column_example' => 'Column example data',
|
||||
'job_config_roles_column_role' => 'Column data meaning',
|
||||
'job_config_roles_do_map_value' => 'Map these values',
|
||||
'job_config_roles_no_example' => 'No example data available',
|
||||
'job_config_roles_fa_warning' => 'If you mark a column as containing an amount in a foreign currency, you must also set the column that contains which currency it is.',
|
||||
'job_config_roles_rwarning' => 'At the very least, mark one column as the amount-column. It is advisable to also select a column for the description, date and the opposing account.',
|
||||
'job_config_roles_colum_count' => 'Column',
|
||||
'job_config_roles_title' => 'Import setup (3/4) - Define each column\'s role',
|
||||
'job_config_roles_text' => 'Each column in your CSV file contains certain data. Please indicate what kind of data the importer should expect. The option to "map" data means that you will link each entry found in the column to a value in your database. An often mapped column is the column that contains the IBAN of the opposing account. That can be easily matched to IBAN\'s present in your database already.',
|
||||
'job_config_roles_submit' => 'Continue',
|
||||
'job_config_roles_column_name' => 'Name of column',
|
||||
'job_config_roles_column_example' => 'Column example data',
|
||||
'job_config_roles_column_role' => 'Column data meaning',
|
||||
'job_config_roles_do_map_value' => 'Map these values',
|
||||
'job_config_roles_no_example' => 'No example data available',
|
||||
'job_config_roles_fa_warning' => 'If you mark a column as containing an amount in a foreign currency, you must also set the column that contains which currency it is.',
|
||||
'job_config_roles_rwarning' => 'At the very least, mark one column as the amount-column. It is advisable to also select a column for the description, date and the opposing account.',
|
||||
'job_config_roles_colum_count' => 'Column',
|
||||
// job config for the file provider (stage: mapping):
|
||||
'job_config_map_title' => 'Import setup (4/4) - Connect import data to Firefly III data',
|
||||
'job_config_map_text' => 'In the following tables, the left value shows you information found in your uploaded file. It is your task to map this value, if possible, to a value already present in your database. Firefly will stick to this mapping. If there is no value to map to, or you do not wish to map the specific value, select nothing.',
|
||||
'job_config_map_nothing' => 'There is no data present in your file that you can map to existing values. Please press "Start the import" to continue.',
|
||||
'job_config_field_value' => 'Field value',
|
||||
'job_config_field_mapped' => 'Mapped to',
|
||||
'map_do_not_map' => '(do not map)',
|
||||
'job_config_map_submit' => 'Start the import',
|
||||
'job_config_map_title' => 'Import setup (4/4) - Connect import data to Firefly III data',
|
||||
'job_config_map_text' => 'In the following tables, the left value shows you information found in your uploaded file. It is your task to map this value, if possible, to a value already present in your database. Firefly will stick to this mapping. If there is no value to map to, or you do not wish to map the specific value, select nothing.',
|
||||
'job_config_map_nothing' => 'There is no data present in your file that you can map to existing values. Please press "Start the import" to continue.',
|
||||
'job_config_field_value' => 'Field value',
|
||||
'job_config_field_mapped' => 'Mapped to',
|
||||
'map_do_not_map' => '(do not map)',
|
||||
'job_config_map_submit' => 'Start the import',
|
||||
|
||||
|
||||
// import status page:
|
||||
'import_with_key' => 'Import with key \':key\'',
|
||||
'status_wait_title' => 'Please hold...',
|
||||
'status_wait_text' => 'This box will disappear in a moment.',
|
||||
'status_running_title' => 'The import is running',
|
||||
'status_job_running' => 'Please wait, running the import...',
|
||||
'status_job_storing' => 'Please wait, storing data...',
|
||||
'status_job_rules' => 'Please wait, running rules...',
|
||||
'status_fatal_title' => 'Fatal error',
|
||||
'status_fatal_text' => 'The import has suffered from an error it could not recover from. Apologies!',
|
||||
'status_fatal_more' => 'This (possibly very cryptic) error message is complemented by log files, which you can find on your hard drive, or in the Docker container where you run Firefly III from.',
|
||||
'status_finished_title' => 'Import finished',
|
||||
'status_finished_text' => 'The import has finished.',
|
||||
'finished_with_errors' => 'There were some errors during the import. Please review them carefully.',
|
||||
'unknown_import_result' => 'Unknown import result',
|
||||
'result_no_transactions' => 'No transactions have been imported. Perhaps they were all duplicates is simply no transactions where present to be imported. Perhaps the error message below can tell you what happened.',
|
||||
'result_one_transaction' => 'Exactly one transaction has been imported. It is stored under tag <a href=":route" class="label label-success" style="font-size:100%;font-weight:normal;">:tag</a> where you can inspect it further.',
|
||||
'result_many_transactions' => 'Firefly III has imported :count transactions. They are stored under tag <a href=":route" class="label label-success" style="font-size:100%;font-weight:normal;">:tag</a> where you can inspect them further.',
|
||||
'import_with_key' => 'Import with key \':key\'',
|
||||
'status_wait_title' => 'Please hold...',
|
||||
'status_wait_text' => 'This box will disappear in a moment.',
|
||||
'status_running_title' => 'The import is running',
|
||||
'status_job_running' => 'Please wait, running the import...',
|
||||
'status_job_storing' => 'Please wait, storing data...',
|
||||
'status_job_rules' => 'Please wait, running rules...',
|
||||
'status_fatal_title' => 'Fatal error',
|
||||
'status_fatal_text' => 'The import has suffered from an error it could not recover from. Apologies!',
|
||||
'status_fatal_more' => 'This (possibly very cryptic) error message is complemented by log files, which you can find on your hard drive, or in the Docker container where you run Firefly III from.',
|
||||
'status_finished_title' => 'Import finished',
|
||||
'status_finished_text' => 'The import has finished.',
|
||||
'finished_with_errors' => 'There were some errors during the import. Please review them carefully.',
|
||||
'unknown_import_result' => 'Unknown import result',
|
||||
'result_no_transactions' => 'No transactions have been imported. Perhaps they were all duplicates is simply no transactions where present to be imported. Perhaps the log files can tell you what happened. If you import data regularly, this is normal.',
|
||||
'result_one_transaction' => 'Exactly one transaction has been imported. It is stored under tag <a href=":route" class="label label-success" style="font-size:100%;font-weight:normal;">:tag</a> where you can inspect it further.',
|
||||
'result_many_transactions' => 'Firefly III has imported :count transactions. They are stored under tag <a href=":route" class="label label-success" style="font-size:100%;font-weight:normal;">:tag</a> where you can inspect them further.',
|
||||
|
||||
|
||||
// general errors and warnings:
|
||||
'bad_job_status' => 'To access this page, your import job cannot have status ":status".',
|
||||
'bad_job_status' => 'To access this page, your import job cannot have status ":status".',
|
||||
|
||||
// column roles for CSV import:
|
||||
'column__ignore' => '(ignore this column)',
|
||||
'column_account-iban' => 'Asset account (IBAN)',
|
||||
'column_account-id' => 'Asset account ID (matching FF3)',
|
||||
'column_account-name' => 'Asset account (name)',
|
||||
'column_amount' => 'Amount',
|
||||
'column_amount_foreign' => 'Amount (in foreign currency)',
|
||||
'column_amount_debit' => 'Amount (debit column)',
|
||||
'column_amount_credit' => 'Amount (credit column)',
|
||||
'column_amount-comma-separated' => 'Amount (comma as decimal separator)',
|
||||
'column_bill-id' => 'Bill ID (matching FF3)',
|
||||
'column_bill-name' => 'Bill name',
|
||||
'column_budget-id' => 'Budget ID (matching FF3)',
|
||||
'column_budget-name' => 'Budget name',
|
||||
'column_category-id' => 'Category ID (matching FF3)',
|
||||
'column_category-name' => 'Category name',
|
||||
'column_currency-code' => 'Currency code (ISO 4217)',
|
||||
'column_foreign-currency-code' => 'Foreign currency code (ISO 4217)',
|
||||
'column_currency-id' => 'Currency ID (matching FF3)',
|
||||
'column_currency-name' => 'Currency name (matching FF3)',
|
||||
'column_currency-symbol' => 'Currency symbol (matching FF3)',
|
||||
'column_date-interest' => 'Interest calculation date',
|
||||
'column_date-book' => 'Transaction booking date',
|
||||
'column_date-process' => 'Transaction process date',
|
||||
'column_date-transaction' => 'Date',
|
||||
'column_date-due' => 'Transaction due date',
|
||||
'column_date-payment' => 'Transaction payment date',
|
||||
'column_date-invoice' => 'Transaction invoice date',
|
||||
'column_description' => 'Description',
|
||||
'column_opposing-iban' => 'Opposing account (IBAN)',
|
||||
'column_opposing-bic' => 'Opposing account (BIC)',
|
||||
'column_opposing-id' => 'Opposing account ID (matching FF3)',
|
||||
'column_external-id' => 'External ID',
|
||||
'column_opposing-name' => 'Opposing account (name)',
|
||||
'column_rabo-debit-credit' => 'Rabobank specific debit/credit indicator',
|
||||
'column_ing-debit-credit' => 'ING specific debit/credit indicator',
|
||||
'column_sepa-ct-id' => 'SEPA end-to-end Identifier',
|
||||
'column_sepa-ct-op' => 'SEPA Opposing Account Identifier',
|
||||
'column_sepa-db' => 'SEPA Mandate Identifier',
|
||||
'column_sepa-cc' => 'SEPA Clearing Code',
|
||||
'column_sepa-ci' => 'SEPA Creditor Identifier',
|
||||
'column_sepa-ep' => 'SEPA External Purpose',
|
||||
'column_sepa-country' => 'SEPA Country Code',
|
||||
'column_tags-comma' => 'Tags (comma separated)',
|
||||
'column_tags-space' => 'Tags (space separated)',
|
||||
'column_account-number' => 'Asset account (account number)',
|
||||
'column_opposing-number' => 'Opposing account (account number)',
|
||||
'column_note' => 'Note(s)',
|
||||
'column_internal-reference' => 'Internal reference',
|
||||
'column__ignore' => '(ignore this column)',
|
||||
'column_account-iban' => 'Asset account (IBAN)',
|
||||
'column_account-id' => 'Asset account ID (matching FF3)',
|
||||
'column_account-name' => 'Asset account (name)',
|
||||
'column_amount' => 'Amount',
|
||||
'column_amount_foreign' => 'Amount (in foreign currency)',
|
||||
'column_amount_debit' => 'Amount (debit column)',
|
||||
'column_amount_credit' => 'Amount (credit column)',
|
||||
'column_amount-comma-separated' => 'Amount (comma as decimal separator)',
|
||||
'column_bill-id' => 'Bill ID (matching FF3)',
|
||||
'column_bill-name' => 'Bill name',
|
||||
'column_budget-id' => 'Budget ID (matching FF3)',
|
||||
'column_budget-name' => 'Budget name',
|
||||
'column_category-id' => 'Category ID (matching FF3)',
|
||||
'column_category-name' => 'Category name',
|
||||
'column_currency-code' => 'Currency code (ISO 4217)',
|
||||
'column_foreign-currency-code' => 'Foreign currency code (ISO 4217)',
|
||||
'column_currency-id' => 'Currency ID (matching FF3)',
|
||||
'column_currency-name' => 'Currency name (matching FF3)',
|
||||
'column_currency-symbol' => 'Currency symbol (matching FF3)',
|
||||
'column_date-interest' => 'Interest calculation date',
|
||||
'column_date-book' => 'Transaction booking date',
|
||||
'column_date-process' => 'Transaction process date',
|
||||
'column_date-transaction' => 'Date',
|
||||
'column_date-due' => 'Transaction due date',
|
||||
'column_date-payment' => 'Transaction payment date',
|
||||
'column_date-invoice' => 'Transaction invoice date',
|
||||
'column_description' => 'Description',
|
||||
'column_opposing-iban' => 'Opposing account (IBAN)',
|
||||
'column_opposing-bic' => 'Opposing account (BIC)',
|
||||
'column_opposing-id' => 'Opposing account ID (matching FF3)',
|
||||
'column_external-id' => 'External ID',
|
||||
'column_opposing-name' => 'Opposing account (name)',
|
||||
'column_rabo-debit-credit' => 'Rabobank specific debit/credit indicator',
|
||||
'column_ing-debit-credit' => 'ING specific debit/credit indicator',
|
||||
'column_sepa-ct-id' => 'SEPA end-to-end Identifier',
|
||||
'column_sepa-ct-op' => 'SEPA Opposing Account Identifier',
|
||||
'column_sepa-db' => 'SEPA Mandate Identifier',
|
||||
'column_sepa-cc' => 'SEPA Clearing Code',
|
||||
'column_sepa-ci' => 'SEPA Creditor Identifier',
|
||||
'column_sepa-ep' => 'SEPA External Purpose',
|
||||
'column_sepa-country' => 'SEPA Country Code',
|
||||
'column_tags-comma' => 'Tags (comma separated)',
|
||||
'column_tags-space' => 'Tags (space separated)',
|
||||
'column_account-number' => 'Asset account (account number)',
|
||||
'column_opposing-number' => 'Opposing account (account number)',
|
||||
'column_note' => 'Note(s)',
|
||||
'column_internal-reference' => 'Internal reference',
|
||||
|
||||
// status of import:
|
||||
// 'status_wait_title' => 'Please hold...',
|
||||
@ -403,7 +437,6 @@ return [
|
||||
// 'spectre_accounts_title' => 'Select accounts to import from',
|
||||
// 'spectre_accounts_text' => 'Each account on the left below has been found by Spectre and can be imported into Firefly III. Please select the asset account that should hold any given transactions. If you do not wish to import from any particular account, remove the check from the checkbox.',
|
||||
// 'spectre_do_import' => 'Yes, import from this account',
|
||||
// 'spectre_no_supported_accounts' => 'You cannot import from this account due to a currency mismatch.',
|
||||
//
|
||||
// // keys from "extra" array:
|
||||
// 'spectre_extra_key_iban' => 'IBAN',
|
||||
|
@ -119,4 +119,7 @@ return [
|
||||
'file_type' => 'File type',
|
||||
'attached_to' => 'Attached to',
|
||||
'file_exists' => 'File exists',
|
||||
'spectre_bank' => 'Bank',
|
||||
'spectre_last_use' => 'Last login',
|
||||
'spectre_status' => 'Status',
|
||||
];
|
||||
|
@ -5,22 +5,21 @@
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<form class="form-horizontal" action="{{ route('import.configure.post',[job.key]) }}" method="post">
|
||||
<form class="form-horizontal" action="{{ route('import.job.configuration.post',[importJob.key]) }}" method="post">
|
||||
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
|
||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||
<div class="box box-default">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">{{ trans('import.spectre_accounts_title') }}</h3>
|
||||
<h3 class="box-title">{{ trans('import.job_config_spectre_accounts_title') }}</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<div class="row">
|
||||
<div class="col-lg-8">
|
||||
<p>
|
||||
{{ trans('import.spectre_accounts_text')|raw }}
|
||||
{{ trans('import.job_config_spectre_accounts_text', {count: data.accounts|length,country: data.login.getCountryCode(),name: data.login.getProviderName()}) }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<table class="table table-bordered table-striped">
|
||||
@ -28,46 +27,40 @@
|
||||
<tr>
|
||||
<th>{{ trans('list.account_on_spectre') }}</th>
|
||||
<th>{{ trans('list.account') }}</th>
|
||||
<th>{{ trans('list.do_import') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for account in data.config.accounts %}
|
||||
{% for account in data.accounts %}
|
||||
<tr>
|
||||
<td>
|
||||
<input type="hidden" name="spectre_account_id[]" value="{{ account.id }}" />
|
||||
{{ account.nature|capitalize }} "<strong>{{ account.name }}</strong>" ({{ formatAmountBySymbol(account.balance, account.currency_code~' ') }})<br />
|
||||
{% for name, value in account.extra %}
|
||||
{{ account.getNature()|capitalize }} "<strong>{{ account.getName() }}</strong>"
|
||||
({{ formatAmountBySymbol(account.getBalance(), account.getCurrencyCode()~' ') }})<br/>
|
||||
{% set currentIban = '' %}
|
||||
{% for name, value in account.getExtra() %}
|
||||
{% if not value is iterable and name != 'sort_code' and name !='current_date' and name != 'available_amount' and name !='current_time' and name != 'last_posted_transaction_id' %}
|
||||
{{ trans('import.spectre_extra_key_'~name) }}: {{ value }}<br />
|
||||
{{ trans('import.spectre_extra_key_'~name) }}: {{ value }}<br/>
|
||||
{% endif %}
|
||||
{% if name == 'available_amount' %}
|
||||
{{ trans('import.spectre_extra_key_'~name) }}: {{ formatAmountBySymbol(value, account.currency_code~' ') }}
|
||||
{{ trans('import.spectre_extra_key_'~name) }}: {{ formatAmountBySymbol(value, account.getCurrencyCode()~' ') }}
|
||||
{% endif %}
|
||||
{% if name == 'iban' %}
|
||||
{% set currentIban = value %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</td>
|
||||
<td>
|
||||
{% if account.options|length > 0 %}
|
||||
<select class="form-control" name="import[{{ account.id }}]">
|
||||
{% for id,name in account.options %}
|
||||
<option value="{{ id }}" label="{{ name }}">{{ name }}</option>
|
||||
<select class="form-control" name="account_mapping[{{ account.getId() }}]">
|
||||
<option value="0" label="{{ trans('import.spectre_do_not_import') }}">
|
||||
{{ trans('import.spectre_do_not_import') }}
|
||||
</option>
|
||||
{% for ffId, ffAccount in data.ff_accounts %}
|
||||
{% if ffAccount.code == account.getCurrencyCode() %}
|
||||
<option value="{{ ffId }}"{% if currentIban != '' and currentIban == ffAccount.iban %} selected{% endif %}>
|
||||
{{ ffAccount.name }}{% if ffAccount.iban !='' %} ({{ ffAccount.iban }}){% endif %}
|
||||
</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
{% else %}
|
||||
<em>
|
||||
{{ trans('import.spectre_no_supported_accounts') }}
|
||||
</em>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if account.options|length > 0 %}
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" value="1" name="do_import[{{ account.id }}]" checked>
|
||||
{{ trans('import.spectre_do_import') }}
|
||||
</label>
|
||||
</div>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@ -76,7 +69,6 @@
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
|
87
resources/views/import/spectre/choose-login.twig
Normal file
87
resources/views/import/spectre/choose-login.twig
Normal file
@ -0,0 +1,87 @@
|
||||
{% extends "./layout/default" %}
|
||||
|
||||
{% block breadcrumbs %}
|
||||
{{ Breadcrumbs.render }}
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<form class="form-horizontal" action="{{ route('import.job.configuration.post',[importJob.key]) }}" method="post">
|
||||
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
|
||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||
<div class="box box-default">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">{{ trans('import.job_config_spectre_login_title') }}</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<div class="row">
|
||||
<div class="col-lg-8">
|
||||
<p>
|
||||
{{ trans('import.job_config_spectre_login_text', {count: data.logins|length}) }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<table class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th> </th>
|
||||
<th>{{ trans('list.spectre_bank') }}</th>
|
||||
<th>{{ trans('list.spectre_last_use') }}</th>
|
||||
<th>{{ trans('list.spectre_status') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for login in data.logins %}
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<input
|
||||
{% if login.getStatus() == 'disabled' %}disabled{% endif %}
|
||||
|
||||
id="{{ login.getId() }}" type="radio" name="spectre_login_id" value="{{ login.getId() }}">
|
||||
</td>
|
||||
<td>
|
||||
<label for="{{ login.getId() }}">
|
||||
{{ login.getProviderName() }} ({{ login.getCountryCode() }})
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
{{ login.getLastSuccessAt().formatLocalized(monthAndDayFormat) }}<br>
|
||||
{{ login.getUpdatedAt().format("Y-m-d H:i:s") }}<br>
|
||||
</td>
|
||||
<td>
|
||||
{{ trans('import.spectre_login_status_'~login.getStatus()) }}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
<tr>
|
||||
<td>
|
||||
<input id="new_login" type="radio" name="spectre_login_id" value="00">
|
||||
</td>
|
||||
<td colspan="3">
|
||||
<label for="new_login"><em>
|
||||
{{ trans('import.spectre_login_new_login') }}
|
||||
</em>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
<button type="submit" class="btn pull-right btn-success">
|
||||
{{ ('submit')|_ }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% block scripts %}
|
||||
{% endblock %}
|
||||
{% block styles %}
|
||||
{% endblock %}
|
Loading…
Reference in New Issue
Block a user