Add new bank specific fixes.

This commit is contained in:
James Cole
2015-07-06 20:21:55 +02:00
parent af13d1943f
commit c555e28988
13 changed files with 471 additions and 336 deletions

View File

@@ -33,6 +33,9 @@ class Data
/** @var array */ /** @var array */
protected $roles; protected $roles;
/** @var array */
protected $specifix;
/** /**
* *
*/ */
@@ -44,6 +47,7 @@ class Data
$this->sessionMap(); $this->sessionMap();
$this->sessionRoles(); $this->sessionRoles();
$this->sessionMapped(); $this->sessionMapped();
$this->sessionSpecifix();
} }
protected function sessionHasHeaders() 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 * @return string
*/ */
@@ -231,5 +242,22 @@ class Data
$this->roles = $roles; $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;
}
} }

View File

@@ -37,6 +37,8 @@ class Importer
protected $roles; protected $roles;
/** @var int */ /** @var int */
protected $rows = 0; protected $rows = 0;
/** @var array */
protected $specifix;
/** /**
* @return array * @return array
@@ -72,6 +74,7 @@ class Importer
$this->map = $this->data->getMap(); $this->map = $this->data->getMap();
$this->roles = $this->data->getRoles(); $this->roles = $this->data->getRoles();
$this->mapped = $this->data->getMapped(); $this->mapped = $this->data->getMapped();
$this->specifix = $this->data->getSpecifix();
foreach ($this->data->getReader() as $index => $row) { foreach ($this->data->getReader() as $index => $row) {
if ($this->parseRow($index)) { if ($this->parseRow($index)) {
@@ -174,8 +177,7 @@ class Importer
{ {
// do bank specific fixes (must be enabled but now all of them. // do bank specific fixes (must be enabled but now all of them.
$set = Config::get('csv.specifix'); foreach ($this->getSpecifix() as $className) {
foreach ($set as $className) {
/** @var SpecifixInterface $specifix */ /** @var SpecifixInterface $specifix */
$specifix = App::make('FireflyIII\Helpers\Csv\Specifix\\' . $className); $specifix = App::make('FireflyIII\Helpers\Csv\Specifix\\' . $className);
$specifix->setData($data); $specifix->setData($data);
@@ -195,6 +197,14 @@ class Importer
return $data; return $data;
} }
/**
* @return array
*/
public function getSpecifix()
{
return $this->specifix;
}
/** /**
* @param $data * @param $data
* *
@@ -304,4 +314,5 @@ class Importer
{ {
$this->data = $data; $this->data = $data;
} }
} }

View 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;
}
}

View File

@@ -155,14 +155,17 @@ class CsvController extends Controller
Session::forget('csv-mapped'); Session::forget('csv-mapped');
Session::forget('csv-specifix'); Session::forget('csv-specifix');
// get values which are yet unsaveable or unmappable: // get list of supported specifix
$unsupported = []; $specifix = [];
foreach (Config::get('csv.specifix') as $entry) {
$specifix[$entry] = trans('firefly.csv_specifix_' . $entry);
}
// can actually upload? // can actually upload?
$uploadPossible = is_writable(storage_path('upload')); $uploadPossible = is_writable(storage_path('upload'));
$path = 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 = [];
$settings['date-format'] = Input::get('date_format'); $settings['date-format'] = Input::get('date_format');
$settings['has-headers'] = intval(Input::get('has_headers')) === 1; $settings['has-headers'] = intval(Input::get('has_headers')) === 1;
$settings['specifix'] = Input::get('specifix');
$settings['map'] = []; $settings['map'] = [];
$settings['mapped'] = []; $settings['mapped'] = [];
$settings['roles'] = []; $settings['roles'] = [];
@@ -399,6 +403,7 @@ class CsvController extends Controller
$this->data->setMap($settings['map']); $this->data->setMap($settings['map']);
$this->data->setMapped($settings['mapped']); $this->data->setMapped($settings['mapped']);
$this->data->setRoles($settings['roles']); $this->data->setRoles($settings['roles']);
$this->data->setSpecifix($settings['specifix']);
return redirect(route('csv.column-roles')); return redirect(route('csv.column-roles'));

View File

@@ -262,6 +262,27 @@ class ExpandedForm
return $selectList; 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 $name
* @param array $list * @param array $list

View File

@@ -1,7 +1,8 @@
<?php <?php
return [ return [
'specifix' => [ 'specifix' => [
'RabobankDescription' 'RabobankDescription',
'Dummy'
], ],
'post_processors' => [ 'post_processors' => [
'Description', 'Description',

View File

@@ -145,7 +145,7 @@ return [
'ExpandedForm' => [ 'ExpandedForm' => [
'is_safe' => [ 'is_safe' => [
'date', 'text', 'select', 'balance', 'optionsList', 'checkbox', 'amount', 'tags', 'integer', 'textarea', 'location', 'date', 'text', 'select', 'balance', 'optionsList', 'checkbox', 'amount', 'tags', 'integer', 'textarea', 'location',
'multiRadio','file' 'multiRadio','file','multiCheckbox'
] ]
], ],
'Form' => [ 'Form' => [

View File

@@ -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_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_upload_button' => 'Start importing CSV',
'csv_column_roles_title' => 'Define column roles', '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' . '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. ' . ' 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.', . 'The next step will show you what this button does.',
@@ -106,6 +107,8 @@ return [
'csv_column_sepa-db' => 'SEPA Direct Debet', 'csv_column_sepa-db' => 'SEPA Direct Debet',
'csv_column_tags-comma' => 'Tags (comma separated)', 'csv_column_tags-comma' => 'Tags (comma separated)',
'csv_column_tags-space' => 'Tags (space 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 stuff:
'create_new_withdrawal' => 'Create new withdrawal', 'create_new_withdrawal' => 'Create new withdrawal',

View File

@@ -50,6 +50,7 @@ return [
'has_headers' => 'Headers', 'has_headers' => 'Headers',
'date_format' => 'Date format', 'date_format' => 'Date format',
'csv_config' => 'CSV import configuration', 'csv_config' => 'CSV import configuration',
'specifix' => 'Bank- or file specific fixes',
'store_new_withdrawal' => 'Store new withdrawal', 'store_new_withdrawal' => 'Store new withdrawal',
'store_new_deposit' => 'Store new deposit', 'store_new_deposit' => 'Store new deposit',

View File

@@ -100,6 +100,8 @@ return [
'csv_process_text' => ':rows rijen zijn verwerkt.', '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' '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.', . ' 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 stuff:
'create_new_withdrawal' => 'Nieuwe uitgave', 'create_new_withdrawal' => 'Nieuwe uitgave',
'create_new_deposit' => 'Nieuwe inkomsten', 'create_new_deposit' => 'Nieuwe inkomsten',

View File

@@ -50,6 +50,7 @@ return [
'has_headers' => 'Kolomnamen op de eerste rij?', 'has_headers' => 'Kolomnamen op de eerste rij?',
'date_format' => 'Datumformaat', 'date_format' => 'Datumformaat',
'csv_config' => 'Configuratiebestand', 'csv_config' => 'Configuratiebestand',
'specifix' => 'Bank- or of bestandsspecifieke opties',
'store_new_withdrawal' => 'Nieuwe uitgave opslaan', 'store_new_withdrawal' => 'Nieuwe uitgave opslaan',
'store_new_deposit' => 'Nieuwe inkomsten opslaan', 'store_new_deposit' => 'Nieuwe inkomsten opslaan',

View File

@@ -61,7 +61,7 @@
{{ ExpandedForm.file('csv_config',{helpText: 'csv_csv_config_file_help'|_}) }} {{ ExpandedForm.file('csv_config',{helpText: 'csv_csv_config_file_help'|_}) }}
<!-- ExpandedForm.multiCheckbox('specifix',Config.get('csv.specifix')) --> {{ ExpandedForm.multiCheckbox('specifix', specifix) }}
{% if not uploadPossible %} {% if not uploadPossible %}
<div class="form-group" id="csv_holder"> <div class="form-group" id="csv_holder">

View 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>