mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Initial code base for new CSV import.
This commit is contained in:
parent
beda6ec3a9
commit
5a79bc0a99
@ -2,7 +2,14 @@
|
||||
|
||||
namespace FireflyIII\Http\Controllers;
|
||||
|
||||
use Crypt;
|
||||
use FireflyIII\Http\Requests;
|
||||
use FireflyIII\Http\Requests\ImportUploadRequest;
|
||||
use FireflyIII\Import\Importer\ImporterInterface;
|
||||
use FireflyIII\Models\ImportJob;
|
||||
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||
use SplFileObject;
|
||||
use Storage;
|
||||
use View;
|
||||
|
||||
/**
|
||||
@ -22,6 +29,26 @@ class ImportController extends Controller
|
||||
View::share('title', trans('firefly.import_data'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ImportJob $job
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function configure(ImportJob $job)
|
||||
{
|
||||
// create proper importer (depends on job)
|
||||
$type = $job->file_type;
|
||||
/** @var ImporterInterface $importer */
|
||||
$importer = app('FireflyIII\Import\Importer\\' . ucfirst($type) . 'Importer');
|
||||
$importer->setJob($job);
|
||||
$importer->configure();
|
||||
$data = $importer->getConfigurationData();
|
||||
|
||||
return view('import.' . $type . '.configure', compact('data', 'job'));
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
@ -38,4 +65,27 @@ class ImportController extends Controller
|
||||
|
||||
return view('import.index', compact('subTitle', 'subTitleIcon', 'importFileTypes', 'defaultImportType'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ImportUploadRequest $request
|
||||
* @param ImportJobRepositoryInterface $repository
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
*/
|
||||
public function upload(ImportUploadRequest $request, ImportJobRepositoryInterface $repository)
|
||||
{
|
||||
// create import job:
|
||||
$type = $request->get('import_file_type');
|
||||
$job = $repository->create($type);
|
||||
$upload = $request->files->get('import_file');
|
||||
$newName = $job->key . '.upload';
|
||||
$uploaded = new SplFileObject($upload->getRealPath());
|
||||
$content = $uploaded->fread($uploaded->getSize());
|
||||
$contentEncrypted = Crypt::encrypt($content);
|
||||
$disk = Storage::disk('upload');
|
||||
$disk->put($newName, $contentEncrypted);
|
||||
|
||||
return redirect(route('import.configure', [$job->key]));
|
||||
|
||||
}
|
||||
}
|
||||
|
46
app/Http/Requests/ImportUploadRequest.php
Normal file
46
app/Http/Requests/ImportUploadRequest.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* ImportUploadRequest.php
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Auth;
|
||||
|
||||
/**
|
||||
* Class ImportUploadRequest
|
||||
*
|
||||
*
|
||||
* @package FireflyIII\Http\Requests
|
||||
*/
|
||||
class ImportUploadRequest extends Request
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
// Only allow logged in users
|
||||
return Auth::check();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
$types = array_keys(config('firefly.import_formats'));
|
||||
|
||||
return [
|
||||
'import_file' => 'required|file',
|
||||
'import_file_type' => 'required|in:' . join(',', $types),
|
||||
];
|
||||
|
||||
}
|
||||
}
|
@ -223,8 +223,9 @@ Route::group(
|
||||
/**
|
||||
* IMPORT CONTROLLER
|
||||
*/
|
||||
Route::get('/import', ['uses' => 'ImportController@index', 'as' => 'import.index']);
|
||||
Route::post('/import/upload', ['uses' => 'ImportController@upload', 'as' => 'import.upload']);
|
||||
Route::get('/import', ['uses' => 'ImportController@index','as' => 'import.index']);
|
||||
Route::post('/import/upload', ['uses' => 'ImportController@upload','as' => 'import.upload']);
|
||||
Route::get('/import/configure/{importJob}', ['uses' => 'ImportController@configure','as' => 'import.configure']);
|
||||
|
||||
/**
|
||||
* Help Controller
|
||||
|
81
app/Import/Importer/CsvImporter.php
Normal file
81
app/Import/Importer/CsvImporter.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
* CsvImporter.php
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace FireflyIII\Import\Importer;
|
||||
|
||||
|
||||
use ExpandedForm;
|
||||
use FireflyIII\Import\Role\Map;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\ImportJob;
|
||||
|
||||
/**
|
||||
* Class CsvImporter
|
||||
*
|
||||
* @package FireflyIII\Import\Importer
|
||||
*/
|
||||
class CsvImporter implements ImporterInterface
|
||||
{
|
||||
/** @var ImportJob */
|
||||
public $job;
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function configure(): bool
|
||||
{
|
||||
// need to do nothing, for now.
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getConfigurationData(): array
|
||||
{
|
||||
$crud = app('FireflyIII\Crud\Account\AccountCrudInterface');
|
||||
$accounts = $crud->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
||||
$delimiters = [
|
||||
',' => trans('form.csv_comma'),
|
||||
';' => trans('form.csv_semicolon'),
|
||||
'tab' => trans('form.csv_tab'),
|
||||
];
|
||||
|
||||
$data = [
|
||||
'accounts' => ExpandedForm::makeSelectList($accounts),
|
||||
'specifix' => [],
|
||||
'delimiters' => $delimiters,
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ImportJob $job
|
||||
*/
|
||||
public function setJob(ImportJob $job)
|
||||
{
|
||||
$this->job = $job;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Map thing used to allow the user to
|
||||
* define roles for each entry.
|
||||
*
|
||||
* @return Map
|
||||
*/
|
||||
public function prepareRoles(): Map
|
||||
{
|
||||
return 'do not work';
|
||||
exit;
|
||||
}
|
||||
}
|
52
app/Import/Importer/ImporterInterface.php
Normal file
52
app/Import/Importer/ImporterInterface.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* ImporterInterface.php
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace FireflyIII\Import\Importer;
|
||||
|
||||
use FireflyIII\Import\Role\Map;
|
||||
use FireflyIII\Models\ImportJob;
|
||||
|
||||
/**
|
||||
* Interface ImporterInterface
|
||||
*
|
||||
* @package FireflyIII\Import\Importer
|
||||
*/
|
||||
interface ImporterInterface
|
||||
{
|
||||
/**
|
||||
* After uploading, and after setJob(), prepare anything that is
|
||||
* necessary for the configure() line.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function configure(): bool;
|
||||
|
||||
/**
|
||||
* Returns any data necessary to do the configuration.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getConfigurationData(): array;
|
||||
|
||||
/**
|
||||
* Returns a Map thing used to allow the user to
|
||||
* define roles for each entry.
|
||||
*
|
||||
* @return Map
|
||||
*/
|
||||
public function prepareRoles(): Map;
|
||||
|
||||
/**
|
||||
* @param ImportJob $job
|
||||
*
|
||||
*/
|
||||
public function setJob(ImportJob $job);
|
||||
}
|
18
app/Import/Role/Map.php
Normal file
18
app/Import/Role/Map.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* Map.php
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace FireflyIII\Import\Role;
|
||||
|
||||
|
||||
class Map
|
||||
{
|
||||
|
||||
}
|
18
app/Import/Role/Role.php
Normal file
18
app/Import/Role/Role.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* Role.php
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace FireflyIII\Import\Role;
|
||||
|
||||
|
||||
class Role
|
||||
{
|
||||
|
||||
}
|
75
app/Models/ImportJob.php
Normal file
75
app/Models/ImportJob.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/**
|
||||
* ImportJob.php
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Auth;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* Class ImportJob
|
||||
*
|
||||
* @package FireflyIII\Models
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $user_id
|
||||
* @property string $key
|
||||
* @property string $file_type
|
||||
* @property string $status
|
||||
* @property-read \FireflyIII\User $user
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\ImportJob whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\ImportJob whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\ImportJob whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\ImportJob whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\ImportJob whereKey($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\ImportJob whereFileType($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\ImportJob whereStatus($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class ImportJob extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
*
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public static function routeBinder($value)
|
||||
{
|
||||
if (Auth::check()) {
|
||||
$model = self::where('key', $value)->where('user_id', Auth::user()->id)->first();
|
||||
if (!is_null($model)) {
|
||||
return $model;
|
||||
}
|
||||
}
|
||||
throw new NotFoundHttpException;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $status
|
||||
*/
|
||||
public function change($status)
|
||||
{
|
||||
$this->status = $status;
|
||||
$this->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('FireflyIII\User');
|
||||
}
|
||||
}
|
@ -31,6 +31,27 @@ class ExportJobServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->exportJob();
|
||||
$this->importJob();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function exportJob()
|
||||
{
|
||||
|
||||
$this->app->bind(
|
||||
'FireflyIII\Repositories\ExportJob\ExportJobRepositoryInterface',
|
||||
function (Application $app, array $arguments) {
|
||||
@ -46,13 +67,20 @@ class ExportJobServiceProvider extends ServiceProvider
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
private function importJob()
|
||||
{
|
||||
//
|
||||
$this->app->bind(
|
||||
'FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface',
|
||||
function (Application $app, array $arguments) {
|
||||
if (!isset($arguments[0]) && $app->auth->check()) {
|
||||
return app('FireflyIII\Repositories\ImportJob\ImportJobRepository', [$app->auth->user()]);
|
||||
}
|
||||
if (!isset($arguments[0]) && !$app->auth->check()) {
|
||||
throw new FireflyException('There is no user present.');
|
||||
}
|
||||
|
||||
return app('FireflyIII\Repositories\ImportJob\ImportJobRepository', $arguments);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
81
app/Repositories/ImportJob/ImportJobRepository.php
Normal file
81
app/Repositories/ImportJob/ImportJobRepository.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
* ImportJobRepository.php
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace FireflyIII\Repositories\ImportJob;
|
||||
|
||||
use FireflyIII\Models\ImportJob;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Class ImportJobRepository
|
||||
*
|
||||
* @package FireflyIII\Repositories\ImportJob
|
||||
*/
|
||||
class ImportJobRepository implements ImportJobRepositoryInterface
|
||||
{
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* ExportJobRepository constructor.
|
||||
*
|
||||
* @param User $user
|
||||
*/
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $fileType
|
||||
*
|
||||
* @return ImportJob
|
||||
*/
|
||||
public function create(string $fileType): ImportJob
|
||||
{
|
||||
$count = 0;
|
||||
while ($count < 30) {
|
||||
$key = Str::random(12);
|
||||
$existing = $this->findByKey($key);
|
||||
if (is_null($existing->id)) {
|
||||
$importJob = new ImportJob;
|
||||
$importJob->user()->associate($this->user);
|
||||
$importJob->file_type = $fileType;
|
||||
$importJob->key = Str::random(12);
|
||||
$importJob->status = 'import_status_never_started';
|
||||
$importJob->save();
|
||||
|
||||
// breaks the loop:
|
||||
return $importJob;
|
||||
}
|
||||
$count++;
|
||||
|
||||
}
|
||||
|
||||
return new ImportJob;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
*
|
||||
* @return ImportJob
|
||||
*/
|
||||
public function findByKey(string $key): ImportJob
|
||||
{
|
||||
$result = $this->user->importJobs()->where('key', $key)->first();
|
||||
if (is_null($result)) {
|
||||
return new ImportJob;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
36
app/Repositories/ImportJob/ImportJobRepositoryInterface.php
Normal file
36
app/Repositories/ImportJob/ImportJobRepositoryInterface.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* ImportJobRepositoryInterface.php
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace FireflyIII\Repositories\ImportJob;
|
||||
|
||||
use FireflyIII\Models\ImportJob;
|
||||
|
||||
/**
|
||||
* Interface ImportJobRepositoryInterface
|
||||
*
|
||||
* @package FireflyIII\Repositories\ImportJob
|
||||
*/
|
||||
interface ImportJobRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* @param string $fileType
|
||||
*
|
||||
* @return ImportJob
|
||||
*/
|
||||
public function create(string $fileType): ImportJob;
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
*
|
||||
* @return ImportJob
|
||||
*/
|
||||
public function findByKey(string $key): ImportJob;
|
||||
}
|
@ -54,6 +54,7 @@ use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\User whereBlocked($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\User whereBlockedCode($value)
|
||||
* @mixin \Eloquent
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\ImportJob[] $importjobs
|
||||
*/
|
||||
class User extends Authenticatable
|
||||
{
|
||||
@ -145,6 +146,14 @@ class User extends Authenticatable
|
||||
return $this->hasMany('FireflyIII\Models\ExportJob');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function importjobs(): HasMany
|
||||
{
|
||||
return $this->hasMany('FireflyIII\Models\ImportJob');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the user has a role by its name.
|
||||
*
|
||||
|
@ -180,8 +180,8 @@ return [
|
||||
|
||||
|
||||
// own stuff:
|
||||
// Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,
|
||||
// Barryvdh\Debugbar\ServiceProvider::class,
|
||||
Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,
|
||||
Barryvdh\Debugbar\ServiceProvider::class,
|
||||
'DaveJamesMiller\Breadcrumbs\ServiceProvider',
|
||||
'TwigBridge\ServiceProvider',
|
||||
'PragmaRX\Google2FA\Vendor\Laravel\ServiceProvider',
|
||||
|
@ -126,6 +126,7 @@ return [
|
||||
'rule' => 'FireflyIII\Models\Rule',
|
||||
'ruleGroup' => 'FireflyIII\Models\RuleGroup',
|
||||
'jobKey' => 'FireflyIII\Models\ExportJob',
|
||||
'importJob' => 'FireflyIII\Models\ImportJob',
|
||||
// lists
|
||||
'accountList' => 'FireflyIII\Support\Binder\AccountList',
|
||||
'budgetList' => 'FireflyIII\Support\Binder\BudgetList',
|
||||
|
44
database/migrations/2016_05_23_173524_changes_for_v391.php
Normal file
44
database/migrations/2016_05_23_173524_changes_for_v391.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class ChangesForV391
|
||||
*/
|
||||
class ChangesForV391 extends Migration
|
||||
{
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('import_jobs');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
// new table "import_jobs"
|
||||
Schema::create(
|
||||
'import_jobs', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->string('key', 12)->unique();
|
||||
$table->string('file_type', 12);
|
||||
$table->string('status', 45);
|
||||
|
||||
// connect rule groups to users
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
@ -326,97 +326,12 @@ return [
|
||||
'title_transfer' => 'Transfers',
|
||||
'title_transfers' => 'Transfers',
|
||||
|
||||
|
||||
// csv import:
|
||||
'csv_import' => 'Import CSV file',
|
||||
'csv' => 'CSV',
|
||||
'csv_index_title' => 'Upload and import a CSV file',
|
||||
'csv_define_column_roles' => 'Define column roles',
|
||||
'csv_map_values' => 'Map found values to existing values',
|
||||
'csv_download_config' => 'Download CSV configuration file.',
|
||||
'csv_index_text' => 'This form allows you to import a CSV file with transactions into Firefly. It is based on the excellent CSV importer made by the folks at <a href="https://www.atlassian.com/">Atlassian</a>. Simply upload your CSV file and follow the instructions. If you would like to learn more, please click on the <i class="fa fa-question-circle"></i> button at the top of this page.',
|
||||
'csv_index_beta_warning' => 'This tool is very much in beta. Please proceed with caution',
|
||||
'csv_header_help' => 'Check this box when your CSV file\'s first row consists of column names, not actual data',
|
||||
'csv_date_help' => 'Date time format in your CSV. Follow the format like <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.',
|
||||
'csv_csv_file_help' => 'Select the CSV file here. You can only upload one file at a time',
|
||||
'csv_csv_config_file_help' => 'Select your CSV import configuration here. If you do not know what this is, ignore it. It will be explained later.',
|
||||
'csv_upload_button' => 'Start importing CSV',
|
||||
'csv_column_roles_title' => 'Define column roles',
|
||||
'csv_column_roles_text' => 'Firefly does not know what each column means. You need to indicate what every column is. Please check out the example data if you\'re not sure yourself. Click on the question mark (top right of the page) to learn what each column means. If you want to map imported data onto existing data in Firefly, use the checkbox. The next step will show you what this button does.',
|
||||
'csv_column_roles_table' => 'Column roles',
|
||||
'csv_column' => 'CSV column',
|
||||
'csv_column_name' => 'CSV column name',
|
||||
'csv_column_example' => 'Column example data',
|
||||
'csv_column_role' => 'Column contains?',
|
||||
'csv_do_map_value' => 'Map value?',
|
||||
'csv_continue' => 'Continue to the next step',
|
||||
'csv_go_back' => 'Go back to the previous step',
|
||||
'csv_map_title' => 'Map found values to existing values',
|
||||
'csv_map_text' => 'This page allows you to map the values from the CSV file to existing entries in your database. This ensures that accounts and other things won\'t be created twice.',
|
||||
'csv_field_value' => 'Field value from CSV',
|
||||
'csv_field_mapped_to' => 'Must be mapped to...',
|
||||
'csv_do_not_map' => 'Do not map this value',
|
||||
'csv_download_config_title' => 'Download CSV configuration',
|
||||
'csv_download_config_text' => 'Everything you\'ve just set up can be downloaded as a configuration file. Click the button to do so.',
|
||||
'csv_more_information_text' => 'If the import fails, you can use this configuration file so you don\'t have to start all over again. But, if the import succeeds, it will be easier to upload similar CSV files.',
|
||||
'csv_do_download_config' => 'Download configuration file.',
|
||||
'csv_empty_description' => '(empty description)',
|
||||
'csv_upload_form' => 'CSV upload form',
|
||||
'csv_index_unsupported_warning' => 'The CSV importer is yet incapable of doing the following:',
|
||||
'csv_unsupported_map' => 'The importer cannot map the column ":columnRole" to existing values in the database.',
|
||||
'csv_unsupported_value' => 'The importer does not know how to handle values in columns marked as ":columnRole".',
|
||||
'csv_cannot_store_value' => 'The importer has not reserved space for columns marked ":columnRole" and will be incapable of processing them.',
|
||||
'csv_process_title' => 'CSV import finished!',
|
||||
'csv_process_text' => 'The CSV importer has finished and has processed :rows rows',
|
||||
'csv_row' => 'Row',
|
||||
'csv_import_with_errors' => 'There was one error.|There were :errors errors.',
|
||||
'csv_error_see_logs' => 'Check the log files to see details.',
|
||||
'csv_process_new_entries' => 'Firefly has created :imported new transaction(s).',
|
||||
'csv_start_over' => 'Import again',
|
||||
'csv_to_index' => 'Back home',
|
||||
'csv_upload_not_writeable' => 'Cannot write to the path mentioned here. Cannot upload',
|
||||
'csv_column__ignore' => '(ignore this column)',
|
||||
'csv_column_account-iban' => 'Asset account (IBAN)',
|
||||
'csv_column_account-id' => 'Asset account ID (matching Firefly)',
|
||||
'csv_column_account-name' => 'Asset account (name)',
|
||||
'csv_column_amount' => 'Amount',
|
||||
'csv_column_amount-comma-separated' => 'Amount (comma as decimal separator)',
|
||||
'csv_column_bill-id' => 'Bill ID (matching Firefly)',
|
||||
'csv_column_bill-name' => 'Bill name',
|
||||
'csv_column_budget-id' => 'Budget ID (matching Firefly)',
|
||||
'csv_column_budget-name' => 'Budget name',
|
||||
'csv_column_category-id' => 'Category ID (matching Firefly)',
|
||||
'csv_column_category-name' => 'Category name',
|
||||
'csv_column_currency-code' => 'Currency code (ISO 4217)',
|
||||
'csv_column_currency-id' => 'Currency ID (matching Firefly)',
|
||||
'csv_column_currency-name' => 'Currency name (matching Firefly)',
|
||||
'csv_column_currency-symbol' => 'Currency symbol (matching Firefly)',
|
||||
'csv_column_date-rent' => 'Rent calculation date',
|
||||
'csv_column_date-transaction' => 'Date',
|
||||
'csv_column_description' => 'Description',
|
||||
'csv_column_opposing-iban' => 'Opposing account (IBAN)',
|
||||
'csv_column_opposing-id' => 'Opposing account ID (matching Firefly)',
|
||||
'csv_column_opposing-name' => 'Opposing account (name)',
|
||||
'csv_column_rabo-debet-credit' => 'Rabobank specific debet/credit indicator',
|
||||
'csv_column_ing-debet-credit' => 'ING specific debet/credit indicator',
|
||||
'csv_column_sepa-ct-id' => 'SEPA Credit Transfer end-to-end ID',
|
||||
'csv_column_sepa-ct-op' => 'SEPA Credit Transfer opposing account',
|
||||
'csv_column_sepa-db' => 'SEPA Direct Debet',
|
||||
'csv_column_tags-comma' => 'Tags (comma separated)',
|
||||
'csv_column_tags-space' => 'Tags (space separated)',
|
||||
'csv_column_account-number' => 'Asset account (account number)',
|
||||
'csv_column_opposing-number' => 'Opposing account (account number)',
|
||||
'csv_specifix_RabobankDescription' => 'Select this when you\'re importing Rabobank CSV export files.',
|
||||
'csv_specifix_AbnAmroDescription' => 'Select this when you\'re importing ABN AMRO CSV export files.',
|
||||
'csv_specifix_Dummy' => 'Checking this has no effect whatsoever.',
|
||||
'csv_import_account_help' => 'If your CSV file does NOT contain information about your asset account(s), use this dropdown to select to which account the transactions in the CSV belong to.',
|
||||
'csv_delimiter_help' => 'Choose the field delimiter that is used in your input file. If not sure, comma is the safest option.',
|
||||
'csv_date_parse_error' => 'Could not parse a valid date from ":value", using the format ":format". Are you sure your CSV is correct?',
|
||||
'could_not_recover' => 'Could not continue from the previous step. Your progress has been lost :(. The log files will tell you what happened.',
|
||||
'must_select_roles' => 'You must select some roles for your file content, or the process cannot continue.',
|
||||
'invalid_mapping' => 'You have submitted an invalid mapping. The process cannot continue.',
|
||||
'no_file_uploaded' => 'It seems you did not upload a file.',
|
||||
|
||||
// import routine
|
||||
'import_data' => 'Import data',
|
||||
'import' => 'Import',
|
||||
'import_intro_text' => 'Some intro here',
|
||||
'import_file_help' => 'Select your file',
|
||||
|
||||
|
||||
// create new stuff:
|
||||
'create_new_withdrawal' => 'Create new withdrawal',
|
||||
|
@ -71,13 +71,9 @@ return [
|
||||
'code' => 'Code',
|
||||
'iban' => 'IBAN',
|
||||
'accountNumber' => 'Account number',
|
||||
'csv' => 'CSV file',
|
||||
'has_headers' => 'Headers',
|
||||
'date_format' => 'Date format',
|
||||
'csv_config' => 'CSV import configuration',
|
||||
'specifix' => 'Bank- or file specific fixes',
|
||||
'csv_import_account' => 'Default import account',
|
||||
'csv_delimiter' => 'CSV field delimiter',
|
||||
'attachments[]' => 'Attachments',
|
||||
'store_new_withdrawal' => 'Store new withdrawal',
|
||||
'store_new_deposit' => 'Store new deposit',
|
||||
@ -102,9 +98,6 @@ return [
|
||||
'include_config' => 'Include configuration file',
|
||||
'include_old_uploads' => 'Include imported data',
|
||||
'accounts' => 'Export transactions from these accounts',
|
||||
'csv_comma' => 'A comma (,)',
|
||||
'csv_semicolon' => 'A semicolon (;)',
|
||||
'csv_tab' => 'A tab (invisible)',
|
||||
'delete_account' => 'Delete account ":name"',
|
||||
'delete_bill' => 'Delete bill ":name"',
|
||||
'delete_budget' => 'Delete budget ":name"',
|
||||
|
@ -55,11 +55,6 @@ return [
|
||||
'categories-show' => 'categories.show',
|
||||
'categories-show-date' => 'categories.show.date',
|
||||
'categories-noCategory' => 'categories.noCategory',
|
||||
'csv-index' => 'csv.index',
|
||||
'csv-column-roles' => 'csv.column-roles',
|
||||
'csv-map' => 'csv.map',
|
||||
'csv-download-config-page' => 'csv.download-config-page',
|
||||
'csv-process' => 'csv.process',
|
||||
'currency-index' => 'currency.index',
|
||||
'currency-create' => 'currency.create',
|
||||
'currency-edit' => 'currency.edit',
|
||||
|
84
resources/views/import/csv/configure.twig
Normal file
84
resources/views/import/csv/configure.twig
Normal file
@ -0,0 +1,84 @@
|
||||
{% extends "./layout/default.twig" %}
|
||||
|
||||
{% block breadcrumbs %}
|
||||
{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, job) }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">{{ 'import_csv_configure_title'|_ }}</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<p>
|
||||
{{ 'import_csv_configure_intro' }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form class="form-horizontal" action="#" method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">{{ 'import_csv_configure_form'|_ }}</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
|
||||
{{ ExpandedForm.checkbox('has_headers',1,null,{helpText: 'csv_header_help'|_}) }}
|
||||
{{ ExpandedForm.text('date_format','Ymd',{helpText: trans('firefly.csv_date_help', {dateExample: phpdate('Ymd')}) }) }}
|
||||
{{ ExpandedForm.select('csv_delimiter', data.delimiters, 0, {helpText: 'csv_delimiter_help'|_} ) }}
|
||||
|
||||
{{ ExpandedForm.file('csv_config',{helpText: 'csv_csv_config_file_help'|_}) }}
|
||||
|
||||
{{ ExpandedForm.select('csv_import_account', data.accounts, 0, {helpText: 'csv_import_account_help'|_} ) }}
|
||||
|
||||
{{ ExpandedForm.multiCheckbox('specifix', data.specifix) }}
|
||||
|
||||
|
||||
|
||||
{% if not uploadPossible %}
|
||||
<div class="form-group" id="csv_holder">
|
||||
<div class="col-sm-4">
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-sm-8">
|
||||
<pre>{{ path }}</pre>
|
||||
<p class="text-danger">
|
||||
{{ 'csv_upload_not_writeable'|_ }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="box">
|
||||
<div class="box-body">
|
||||
<button type="submit" class="pull-right btn btn-success">
|
||||
{{ 'csv_upload_button'|_ }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
|
||||
{% endblock %}
|
@ -25,7 +25,7 @@
|
||||
<input name="_token" type="hidden" value="{{ csrf_token() }}">
|
||||
|
||||
<div class="col-lg-6 col-md-8 col-sm-12 col-xs-12">
|
||||
{{ ExpandedForm.file('import_file',{helpText: 'import_file_help'|_}) }}
|
||||
{{ ExpandedForm.file('import_file', {helpText: 'import_file_help'|_}) }}
|
||||
|
||||
{{ ExpandedForm.select('import_file_type', importFileTypes, defaultImportType, {'helpText' : 'import_file_type_help'|_}) }}
|
||||
|
||||
|
@ -110,8 +110,7 @@
|
||||
</li>
|
||||
|
||||
<!-- import and export -->
|
||||
<li class="{{ activeRoutePartial('export') }} {{ activeRoutePartial('csv') }} treeview">
|
||||
|
||||
<li class="{{ activeRoutePartial('export') }} {{ activeRoutePartial('import') }} treeview">
|
||||
<a href="#">
|
||||
<i class="fa fa-arrows-alt fa-fw"></i>
|
||||
<span>
|
||||
@ -120,12 +119,9 @@
|
||||
<i class="fa fa-angle-left pull-right"></i>
|
||||
</a>
|
||||
<ul class="treeview-menu">
|
||||
{% if Config.get('firefly.csv_import_enabled') %}
|
||||
<li class="{{ activeRoutePartial('csv') }}">
|
||||
<a href="{{ route('csv.index') }}"><i class="fa fa-file-text-o fa-fw"></i> {{ 'csv_import'|_ }}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
<li class="{{ activeRoutePartial('import') }}">
|
||||
<a href="{{ route('import.index') }}"><i class="fa fa-archive fa-fw"></i> {{ 'import_data'|_ }}</a>
|
||||
</li>
|
||||
<li class="{{ activeRoutePartial('export') }}">
|
||||
<a href="{{ route('export.index') }}"><i class="fa fa-file-archive-o fa-fw"></i> {{ 'export_data'|_ }}</a>
|
||||
</li>
|
||||
|
Loading…
Reference in New Issue
Block a user