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 */
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;
}
}

View File

@@ -37,6 +37,8 @@ class Importer
protected $roles;
/** @var int */
protected $rows = 0;
/** @var array */
protected $specifix;
/**
* @return array
@@ -69,9 +71,10 @@ class Importer
{
set_time_limit(0);
$this->map = $this->data->getMap();
$this->roles = $this->data->getRoles();
$this->mapped = $this->data->getMapped();
$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;
}
}

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-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'));

View File

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