diff --git a/app/Import/Converter/Description.php b/app/Import/Converter/Description.php index d7a2cde245..2e8135e50b 100644 --- a/app/Import/Converter/Description.php +++ b/app/Import/Converter/Description.php @@ -29,6 +29,7 @@ class Description extends BasicConverter implements ConverterInterface // this should replace all control characters // but leave utf8 intact: $value = preg_replace('/[\x00-\x1F\x80-\x9F]/u', '', $value); + $value = $value; $this->setCertainty(100); return strval($value); diff --git a/app/Import/Specifics/IngDescription.php b/app/Import/Specifics/IngDescription.php new file mode 100644 index 0000000000..4f19ce3e93 --- /dev/null +++ b/app/Import/Specifics/IngDescription.php @@ -0,0 +1,110 @@ +row = $row; + if (count($this->row) >= 8) { // check if the array is correct + switch ($this->row[4]) { //update Decription only for the next Mutations + case 'GT': // InternetBanieren + case 'OV': // OV + case 'VZ': // Verzamelbetaling + case 'IC'://Incasso + $this->removeIBANIngDescription(); + $this->removeNameIngDescription(); + break; + case 'BA' ://Betaalautomaat + $this->addNameIngDescription(); + break; + } + } + +//var_dump($this->row);die; + + return $this->row; + } + + /** + * Parses the current description without the IBAN in the description + * + * @return always true + */ + protected function removeIBANIngDescription() + { + // Try remove the iban number from the third cell 'IBAN: NL00XXXX0000000 ' + $this->row[8] = preg_replace('/\sIBAN:\s'.$this->row[3].'/', '', $this->row[8]); + return true; + } + + + /** + * Parses the current description without the name + * + * @return bool always true + */ + protected function removeNameIngDescription() + { + // Try remove the name + $this->row[8] = preg_replace('/.+Omschrijving: /', '', $this->row[8]); + return true; + } + + + /** + * Parses the current description without the name and IBAN + * + * @return bool true if the description is GEA/BEA-format, false otherwise + */ + protected function addNameIngDescription() + { + $this->row[8] = $this->row[1]. " " . $this->row[8]; + return true; + } + +} diff --git a/config/csv.php b/config/csv.php index 6fc0ffa20a..4cd4835d83 100644 --- a/config/csv.php +++ b/config/csv.php @@ -8,6 +8,7 @@ return [ * Configuration for the CSV specifics. */ 'import_specifics' => [ + 'IngDescription' => 'FireflyIII\Import\Specifics\IngDescription', 'RabobankDescription' => 'FireflyIII\Import\Specifics\RabobankDescription', 'AbnAmroDescription' => 'FireflyIII\Import\Specifics\AbnAmroDescription', 'PresidentsChoice' => 'FireflyIII\Import\Specifics\PresidentsChoice',