From ce5af7b1d920e1633d0b26485f20a07bedf4df3d Mon Sep 17 00:00:00 2001 From: Tom van der Werf Date: Mon, 3 Oct 2016 17:08:24 +0000 Subject: [PATCH 1/3] Better descriptions for ING accounts --- app/Import/Converter/Description.php | 1 + app/Import/Specifics/IngDescription.php | 110 ++++++++++++++++++++++++ config/csv.php | 1 + 3 files changed, 112 insertions(+) create mode 100644 app/Import/Specifics/IngDescription.php 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', From dc22802deca13d5aef62bfc17057ddde2de5caa1 Mon Sep 17 00:00:00 2001 From: Tom van der Werf Date: Tue, 4 Oct 2016 17:30:49 +0000 Subject: [PATCH 2/3] removed some debug commands --- app/Import/Converter/Description.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Import/Converter/Description.php b/app/Import/Converter/Description.php index 2e8135e50b..d7a2cde245 100644 --- a/app/Import/Converter/Description.php +++ b/app/Import/Converter/Description.php @@ -29,7 +29,6 @@ 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); From d7fef45a56017721b9f912bf6f6009f620006b9d Mon Sep 17 00:00:00 2001 From: Tom van der Werf Date: Tue, 4 Oct 2016 17:50:01 +0000 Subject: [PATCH 3/3] added some comments --- app/Import/Specifics/IngDescription.php | 42 +++++++++++++------------ 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/app/Import/Specifics/IngDescription.php b/app/Import/Specifics/IngDescription.php index 4f19ce3e93..15595084f3 100644 --- a/app/Import/Specifics/IngDescription.php +++ b/app/Import/Specifics/IngDescription.php @@ -16,7 +16,9 @@ namespace FireflyIII\Import\Specifics; * * Parses the description from CSV files for Ing bank accounts. * - * With Mutation 'InternetBankieren', 'Incasso' and Overschrijving remove Name and IBAN from description + * With Mutation 'InternetBankieren', 'Overschrijving', 'Verzamelbetaling' and 'Incasso' the + * Name of Opposing account the Opposing IBAN number are in the Description + * This class will remove them * Add Name in description by 'Betaalautomaat' so those are easily recognizable * * @package FireflyIII\Import\Specifics @@ -31,7 +33,7 @@ class IngDescription implements SpecificInterface */ public static function getDescription(): string { - return 'Fixes Ing descriptions.'; + return 'Create better descriptions in ING import files.'; } /** @@ -39,7 +41,7 @@ class IngDescription implements SpecificInterface */ public static function getName(): string { - return 'Ing description'; + return 'ING description'; } /** @@ -50,56 +52,56 @@ class IngDescription implements SpecificInterface public function run(array $row): array { $this->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 + if (count($this->row) >= 8) { // check if the array is correct + switch ($this->row[4]) { // Get value for the mutation type + case 'GT': // InternetBanieren + case 'OV': // Overschrijving + case 'VZ': // Verzamelbetaling + case 'IC': // Incasso $this->removeIBANIngDescription(); $this->removeNameIngDescription(); break; - case 'BA' ://Betaalautomaat + case 'BA' : // Betaalautomaat $this->addNameIngDescription(); break; } } -//var_dump($this->row);die; - return $this->row; } /** - * Parses the current description without the IBAN in the description + * Remove IBAN number out of the description + * Default description of Description is: Naam: Omschrijving: IBAN: * - * @return always true + * @return bool true */ protected function removeIBANIngDescription() { - // Try remove the iban number from the third cell 'IBAN: NL00XXXX0000000 ' + // Try replace the iban number with nothing. The IBAN nr is found in the third row $this->row[8] = preg_replace('/\sIBAN:\s'.$this->row[3].'/', '', $this->row[8]); return true; } /** - * Parses the current description without the name + * Remove name from the description (Remove everything before the description incl the word 'Omschrijving' ) * - * @return bool always true + * @return bool true */ protected function removeNameIngDescription() { - // Try remove the name + // Try remove everything bevore the 'Omschrijving' $this->row[8] = preg_replace('/.+Omschrijving: /', '', $this->row[8]); return true; } /** - * Parses the current description without the name and IBAN + * Add the Opposing name from cell 1 in the description for Betaalautomaten + * Otherwise the description is only: 'Pasvolgnr: Transactie: Term:' * - * @return bool true if the description is GEA/BEA-format, false otherwise + * @return bool true */ protected function addNameIngDescription() {