mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-26 05:26:17 +00:00
More code for import.
This commit is contained in:
@@ -13,6 +13,7 @@ namespace FireflyIII\Import\Importer;
|
||||
|
||||
|
||||
use ExpandedForm;
|
||||
use FireflyIII\Crud\Account\AccountCrud;
|
||||
use FireflyIII\Import\Role\Map;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\ImportJob;
|
||||
@@ -50,12 +51,23 @@ class CsvImporter implements ImporterInterface
|
||||
'tab' => trans('form.csv_tab'),
|
||||
];
|
||||
|
||||
$specifics = [];
|
||||
|
||||
// collect specifics.
|
||||
foreach (config('firefly.csv_import_specifics') as $name => $className) {
|
||||
$specifics[$name] = [
|
||||
'name' => $className::getName(),
|
||||
'description' => $className::getDescription(),
|
||||
];
|
||||
}
|
||||
|
||||
$data = [
|
||||
'accounts' => ExpandedForm::makeSelectList($accounts),
|
||||
'specifix' => [],
|
||||
'delimiters' => $delimiters,
|
||||
'upload_path' => storage_path('upload'),
|
||||
'is_upload_possible' => is_writable(storage_path('upload')),
|
||||
'specifics' => $specifics,
|
||||
];
|
||||
|
||||
return $data;
|
||||
@@ -73,6 +85,40 @@ class CsvImporter implements ImporterInterface
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function saveImportConfiguration(array $data): bool
|
||||
{
|
||||
/** @var AccountCrud $repository */
|
||||
$repository = app(AccountCrud::class);
|
||||
$account = $repository->find(intval($data['csv_import_account']));
|
||||
$configuration = [
|
||||
'date_format' => $data['date_format'],
|
||||
'csv_delimiter' => $data['csv_delimiter'],
|
||||
'csv_import_account' => 0,
|
||||
'specifics' => [],
|
||||
];
|
||||
|
||||
if (!is_null($account->id)) {
|
||||
$configuration['csv_import_account'] = $account->id;
|
||||
}
|
||||
// loop specifics.
|
||||
if (is_array($data['specifics'])) {
|
||||
foreach ($data['specifics'] as $name => $enabled) {
|
||||
$configuration['specifics'][] = $name;
|
||||
}
|
||||
}
|
||||
$this->job->configuration = $configuration;
|
||||
$this->job->save();
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ImportJob $job
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user