mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 10:33:30 +00:00
Add new bank specific fixes.
This commit is contained in:
@@ -33,6 +33,9 @@ class Data
|
||||
/** @var array */
|
||||
protected $roles;
|
||||
|
||||
/** @var array */
|
||||
protected $specifix;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -44,6 +47,7 @@ class Data
|
||||
$this->sessionMap();
|
||||
$this->sessionRoles();
|
||||
$this->sessionMapped();
|
||||
$this->sessionSpecifix();
|
||||
}
|
||||
|
||||
protected function sessionHasHeaders()
|
||||
@@ -88,6 +92,13 @@ class Data
|
||||
}
|
||||
}
|
||||
|
||||
protected function sessionSpecifix()
|
||||
{
|
||||
if (Session::has('csv-specifix')) {
|
||||
$this->specifix = (array)Session::get('csv-specifix');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
@@ -231,5 +242,22 @@ class Data
|
||||
$this->roles = $roles;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getSpecifix()
|
||||
{
|
||||
return $this->specifix;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $specifix
|
||||
*/
|
||||
public function setSpecifix($specifix)
|
||||
{
|
||||
Session::put('csv-specifix', $specifix);
|
||||
$this->specifix = $specifix;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -37,6 +37,8 @@ class Importer
|
||||
protected $roles;
|
||||
/** @var int */
|
||||
protected $rows = 0;
|
||||
/** @var array */
|
||||
protected $specifix;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
@@ -72,6 +74,7 @@ class Importer
|
||||
$this->map = $this->data->getMap();
|
||||
$this->roles = $this->data->getRoles();
|
||||
$this->mapped = $this->data->getMapped();
|
||||
$this->specifix = $this->data->getSpecifix();
|
||||
|
||||
foreach ($this->data->getReader() as $index => $row) {
|
||||
if ($this->parseRow($index)) {
|
||||
@@ -174,8 +177,7 @@ class Importer
|
||||
{
|
||||
// do bank specific fixes (must be enabled but now all of them.
|
||||
|
||||
$set = Config::get('csv.specifix');
|
||||
foreach ($set as $className) {
|
||||
foreach ($this->getSpecifix() as $className) {
|
||||
/** @var SpecifixInterface $specifix */
|
||||
$specifix = App::make('FireflyIII\Helpers\Csv\Specifix\\' . $className);
|
||||
$specifix->setData($data);
|
||||
@@ -195,6 +197,14 @@ class Importer
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getSpecifix()
|
||||
{
|
||||
return $this->specifix;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
*
|
||||
@@ -304,4 +314,5 @@ class Importer
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
}
|
45
app/Helpers/Csv/Specifix/Dummy.php
Normal file
45
app/Helpers/Csv/Specifix/Dummy.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace FireflyIII\Helpers\Csv\Specifix;
|
||||
|
||||
/**
|
||||
* Class Dummy
|
||||
*
|
||||
* @package FireflyIII\Helpers\Csv\Specifix
|
||||
*/
|
||||
class Dummy
|
||||
{
|
||||
/** @var array */
|
||||
protected $data;
|
||||
|
||||
/** @var array */
|
||||
protected $row;
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function fix()
|
||||
{
|
||||
return $this->data;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*/
|
||||
public function setData($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $row
|
||||
*/
|
||||
public function setRow($row)
|
||||
{
|
||||
$this->row = $row;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -155,14 +155,17 @@ class CsvController extends Controller
|
||||
Session::forget('csv-mapped');
|
||||
Session::forget('csv-specifix');
|
||||
|
||||
// get values which are yet unsaveable or unmappable:
|
||||
$unsupported = [];
|
||||
// get list of supported specifix
|
||||
$specifix = [];
|
||||
foreach (Config::get('csv.specifix') as $entry) {
|
||||
$specifix[$entry] = trans('firefly.csv_specifix_' . $entry);
|
||||
}
|
||||
|
||||
// can actually upload?
|
||||
$uploadPossible = is_writable(storage_path('upload'));
|
||||
$path = storage_path('upload');
|
||||
|
||||
return view('csv.index', compact('subTitle', 'uploadPossible', 'path', 'unsupported'));
|
||||
return view('csv.index', compact('subTitle', 'uploadPossible', 'path', 'specifix'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -378,6 +381,7 @@ class CsvController extends Controller
|
||||
$settings = [];
|
||||
$settings['date-format'] = Input::get('date_format');
|
||||
$settings['has-headers'] = intval(Input::get('has_headers')) === 1;
|
||||
$settings['specifix'] = Input::get('specifix');
|
||||
$settings['map'] = [];
|
||||
$settings['mapped'] = [];
|
||||
$settings['roles'] = [];
|
||||
@@ -399,6 +403,7 @@ class CsvController extends Controller
|
||||
$this->data->setMap($settings['map']);
|
||||
$this->data->setMapped($settings['mapped']);
|
||||
$this->data->setRoles($settings['roles']);
|
||||
$this->data->setSpecifix($settings['specifix']);
|
||||
|
||||
return redirect(route('csv.column-roles'));
|
||||
|
||||
|
@@ -262,6 +262,27 @@ class ExpandedForm
|
||||
return $selectList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param array $list
|
||||
* @param null $selected
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function multiCheckbox($name, array $list = [], $selected = null, array $options = [])
|
||||
{
|
||||
$label = $this->label($name, $options);
|
||||
$options = $this->expandOptionArray($name, $label, $options);
|
||||
$classes = $this->getHolderClasses($name);
|
||||
$selected = $this->fillFieldValue($name, $selected);
|
||||
|
||||
unset($options['class']);
|
||||
$html = View::make('form.multiCheckbox', compact('classes', 'name', 'label', 'selected', 'options', 'list'))->render();
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param array $list
|
||||
|
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
return [
|
||||
'specifix' => [
|
||||
'RabobankDescription'
|
||||
'RabobankDescription',
|
||||
'Dummy'
|
||||
],
|
||||
'post_processors' => [
|
||||
'Description',
|
||||
|
@@ -145,7 +145,7 @@ return [
|
||||
'ExpandedForm' => [
|
||||
'is_safe' => [
|
||||
'date', 'text', 'select', 'balance', 'optionsList', 'checkbox', 'amount', 'tags', 'integer', 'textarea', 'location',
|
||||
'multiRadio','file'
|
||||
'multiRadio','file','multiCheckbox'
|
||||
]
|
||||
],
|
||||
'Form' => [
|
||||
|
@@ -39,7 +39,8 @@ return [
|
||||
'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 '
|
||||
'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.',
|
||||
@@ -106,6 +107,8 @@ return [
|
||||
'csv_column_sepa-db' => 'SEPA Direct Debet',
|
||||
'csv_column_tags-comma' => 'Tags (comma separated)',
|
||||
'csv_column_tags-space' => 'Tags (space separated)',
|
||||
'csv_specifix_RabobankDescription' => 'Select this when you\'re importing Rabobank CSV export files.',
|
||||
'csv_specifix_Dummy' => 'Checking this has no effect whatsoever.',
|
||||
|
||||
// create new stuff:
|
||||
'create_new_withdrawal' => 'Create new withdrawal',
|
||||
|
@@ -50,6 +50,7 @@ return [
|
||||
'has_headers' => 'Headers',
|
||||
'date_format' => 'Date format',
|
||||
'csv_config' => 'CSV import configuration',
|
||||
'specifix' => 'Bank- or file specific fixes',
|
||||
|
||||
'store_new_withdrawal' => 'Store new withdrawal',
|
||||
'store_new_deposit' => 'Store new deposit',
|
||||
|
@@ -100,6 +100,8 @@ return [
|
||||
'csv_process_text' => ':rows rijen zijn verwerkt.',
|
||||
'csv_import_with_errors' => 'Er was één fout. Deze foutmelding is mogelijk in het Engels.|Er zijn :errors fouten opgetreden. De foutmeldingen'
|
||||
. ' zijn mogelijk in het Engels.',
|
||||
'csv_specifix_RabobankDescription' => 'Vink dit aan als je Rabobank bestanden importeert.',
|
||||
'csv_specifix_Dummy' => 'Dit vinkje doet niks (dummy).',
|
||||
// create new stuff:
|
||||
'create_new_withdrawal' => 'Nieuwe uitgave',
|
||||
'create_new_deposit' => 'Nieuwe inkomsten',
|
||||
|
@@ -50,6 +50,7 @@ return [
|
||||
'has_headers' => 'Kolomnamen op de eerste rij?',
|
||||
'date_format' => 'Datumformaat',
|
||||
'csv_config' => 'Configuratiebestand',
|
||||
'specifix' => 'Bank- or of bestandsspecifieke opties',
|
||||
|
||||
'store_new_withdrawal' => 'Nieuwe uitgave opslaan',
|
||||
'store_new_deposit' => 'Nieuwe inkomsten opslaan',
|
||||
|
@@ -61,7 +61,7 @@
|
||||
|
||||
{{ ExpandedForm.file('csv_config',{helpText: 'csv_csv_config_file_help'|_}) }}
|
||||
|
||||
<!-- ExpandedForm.multiCheckbox('specifix',Config.get('csv.specifix')) -->
|
||||
{{ ExpandedForm.multiCheckbox('specifix', specifix) }}
|
||||
|
||||
{% if not uploadPossible %}
|
||||
<div class="form-group" id="csv_holder">
|
||||
|
17
resources/twig/form/multiCheckbox.twig
Normal file
17
resources/twig/form/multiCheckbox.twig
Normal file
@@ -0,0 +1,17 @@
|
||||
<div class="{{ classes }}" id="{{ name }}_holder">
|
||||
<label for="{{ options.id }}" class="col-sm-4 control-label">{{ label }}</label>
|
||||
|
||||
<div class="col-sm-8">
|
||||
{% for value,description in list %}
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
{{ Form.checkbox(name~'[]', value, (selected == value), options) }}
|
||||
{{ description }}
|
||||
</label>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% include 'form/help.twig' %}
|
||||
{% include 'form/feedback.twig' %}
|
||||
|
||||
</div>
|
||||
</div>
|
Reference in New Issue
Block a user