From 9b0a890531d5b277a980f503f7cf64a9d47ab204 Mon Sep 17 00:00:00 2001 From: Ruben Verhoef Date: Sun, 23 Feb 2020 18:37:41 +0100 Subject: [PATCH 1/6] Add also "Divers" transaction type --- app/Import/Specifics/IngDescription.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Import/Specifics/IngDescription.php b/app/Import/Specifics/IngDescription.php index 7d554388ea..a2cb15027e 100644 --- a/app/Import/Specifics/IngDescription.php +++ b/app/Import/Specifics/IngDescription.php @@ -76,8 +76,9 @@ class IngDescription implements SpecificInterface case 'OV': // Overschrijving case 'VZ': // Verzamelbetaling case 'IC': // Incasso - $this->removeIBANIngDescription(); - $this->removeNameIngDescription(); + case 'DV': // Divers + $this->removeIBANIngDescription(); // Remove "IBAN:", because it is already at "Tegenrekening" + $this->removeNameIngDescription(); // Remove "Naam:", because it is already at "Naam/ Omschrijving" // if "tegenrekening" empty, copy the description. Primitive, but it works. $this->copyDescriptionToOpposite(); break; From 21fcb6f853afef6011336e4639957ef55c65b14a Mon Sep 17 00:00:00 2001 From: Ruben Verhoef Date: Sun, 23 Feb 2020 18:38:21 +0100 Subject: [PATCH 2/6] Correctly remove the "Naam" and it's value --- app/Import/Specifics/IngDescription.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/Import/Specifics/IngDescription.php b/app/Import/Specifics/IngDescription.php index a2cb15027e..4a1eac5bf2 100644 --- a/app/Import/Specifics/IngDescription.php +++ b/app/Import/Specifics/IngDescription.php @@ -111,12 +111,11 @@ class IngDescription implements SpecificInterface } /** - * Remove name from the description (Remove everything before the description incl the word 'Omschrijving' ). + * Remove "Naam" (and its value) from the description. */ protected function removeNameIngDescription(): void { - // Try remove everything before the 'Omschrijving' - $this->row[8] = preg_replace('/.+Omschrijving: /', '', $this->row[8]); + $this->row[8] = preg_replace('/Naam:.*?([a-zA-Z\/]+:)/', '$1', $this->row[8]); } /** From 23ec5cbaa7d6384fda1bc62790d8846c8e30e0d3 Mon Sep 17 00:00:00 2001 From: Ruben Verhoef Date: Sun, 23 Feb 2020 18:39:39 +0100 Subject: [PATCH 3/6] Remove "Omschrijving" but not it's value, only the word. --- app/Import/Specifics/IngDescription.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/Import/Specifics/IngDescription.php b/app/Import/Specifics/IngDescription.php index 4a1eac5bf2..7f6115763a 100644 --- a/app/Import/Specifics/IngDescription.php +++ b/app/Import/Specifics/IngDescription.php @@ -79,6 +79,7 @@ class IngDescription implements SpecificInterface case 'DV': // Divers $this->removeIBANIngDescription(); // Remove "IBAN:", because it is already at "Tegenrekening" $this->removeNameIngDescription(); // Remove "Naam:", because it is already at "Naam/ Omschrijving" + $this->removeIngDescription(); // Remove "Omschrijving", but not the value from description // if "tegenrekening" empty, copy the description. Primitive, but it works. $this->copyDescriptionToOpposite(); break; @@ -100,6 +101,14 @@ class IngDescription implements SpecificInterface $this->row[8] = $this->row[1] . ' ' . $this->row[8]; } + /** + * Remove "Omschrijving" (and NOT its value) from the description. + */ + protected function removeIngDescription(): void + { + $this->row[8] = preg_replace('/Omschrijving: /', '', $this->row[8]); + } + /** * Remove IBAN number out of the description * Default description of Description is: Naam: Omschrijving: IBAN: . From 62d74e05f26ac14eac17fcd064905d37f78027c7 Mon Sep 17 00:00:00 2001 From: Ruben Verhoef Date: Sun, 23 Feb 2020 18:41:16 +0100 Subject: [PATCH 4/6] Fix saving accounts copy of account number to row 1 and name to row 3 --- app/Import/Specifics/IngDescription.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/app/Import/Specifics/IngDescription.php b/app/Import/Specifics/IngDescription.php index 7f6115763a..e4f2cb5944 100644 --- a/app/Import/Specifics/IngDescription.php +++ b/app/Import/Specifics/IngDescription.php @@ -80,8 +80,7 @@ class IngDescription implements SpecificInterface $this->removeIBANIngDescription(); // Remove "IBAN:", because it is already at "Tegenrekening" $this->removeNameIngDescription(); // Remove "Naam:", because it is already at "Naam/ Omschrijving" $this->removeIngDescription(); // Remove "Omschrijving", but not the value from description - // if "tegenrekening" empty, copy the description. Primitive, but it works. - $this->copyDescriptionToOpposite(); + $this->MoveSavingsAccount(); // Move savings account number and name break; case 'BA': // Betaalautomaat $this->addNameIngDescription(); @@ -128,13 +127,22 @@ class IngDescription implements SpecificInterface } /** - * Copy description to name of opposite account. + * Move savings account number to column 1 and name to column 3. */ - private function copyDescriptionToOpposite(): void + private function MoveSavingsAccount(): void { - $search = ['Naar Oranje Spaarrekening ', 'Afschrijvingen']; + $matches = array(); if ('' === (string)$this->row[3]) { - $this->row[3] = trim(str_ireplace($search, '', $this->row[8])); + if (preg_match('/(Naar|Van) (.*rekening) ([0-9]+)/', $this->row[8], $matches)) { + $matches[3] = sprintf("%010d", $matches[3]); + $this->row[1] = $matches[2]; // Savings account name + $this->row[3] = $matches[3]; // Savings account number + $this->row[8] = preg_replace('/(Naar|Van) (.*rekening) ([0-9]+)/', '', $this->row[8]); // Remove the savings account content from description + } elseif (preg_match('/(Naar|Van) (.*rekening) ([0-9]+)/', $this->row[1], $matches)) { + $matches[3] = sprintf("%010d", $matches[3]); + $this->row[1] = $matches[2]; // Savings account name + $this->row[3] = $matches[3]; // Savings account number + } } } } From a32c484fd5a875fda7668ce0cd27e46c716b5a5f Mon Sep 17 00:00:00 2001 From: Ruben Verhoef Date: Sun, 23 Feb 2020 18:45:56 +0100 Subject: [PATCH 5/6] fix typo row -> column --- app/Import/Specifics/IngDescription.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Import/Specifics/IngDescription.php b/app/Import/Specifics/IngDescription.php index e4f2cb5944..c94936d826 100644 --- a/app/Import/Specifics/IngDescription.php +++ b/app/Import/Specifics/IngDescription.php @@ -114,7 +114,7 @@ class IngDescription implements SpecificInterface */ protected function removeIBANIngDescription(): void { - // Try replace the iban number with nothing. The IBAN nr is found in the third row + // Try replace the iban number with nothing. The IBAN nr is found in the third column $this->row[8] = preg_replace('/\sIBAN:\s' . $this->row[3] . '/', '', $this->row[8]); } From 75ee331f3641af867b6d30947c36e907e544c9a1 Mon Sep 17 00:00:00 2001 From: Ruben Verhoef Date: Sun, 23 Feb 2020 18:46:17 +0100 Subject: [PATCH 6/6] Move "Valutadatum" to own column The new column has no name right now, need to fix this --- app/Import/Specifics/IngDescription.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/Import/Specifics/IngDescription.php b/app/Import/Specifics/IngDescription.php index c94936d826..35b3f63df1 100644 --- a/app/Import/Specifics/IngDescription.php +++ b/app/Import/Specifics/IngDescription.php @@ -70,6 +70,7 @@ class IngDescription implements SpecificInterface public function run(array $row): array { $this->row = array_values($row); + array_push($this->row); // New column for "Valutadatum" if (count($this->row) >= 8) { // check if the array is correct switch ($this->row[4]) { // Get value for the mutation type case 'GT': // InternetBankieren @@ -80,9 +81,11 @@ class IngDescription implements SpecificInterface $this->removeIBANIngDescription(); // Remove "IBAN:", because it is already at "Tegenrekening" $this->removeNameIngDescription(); // Remove "Naam:", because it is already at "Naam/ Omschrijving" $this->removeIngDescription(); // Remove "Omschrijving", but not the value from description + $this->moveValutadatumDescription(); // Move "Valutadatum" from description to new column $this->MoveSavingsAccount(); // Move savings account number and name break; case 'BA': // Betaalautomaat + $this->moveValutadatumDescription(); // Move "Valutadatum" from description to new column $this->addNameIngDescription(); break; } @@ -126,6 +129,17 @@ class IngDescription implements SpecificInterface $this->row[8] = preg_replace('/Naam:.*?([a-zA-Z\/]+:)/', '$1', $this->row[8]); } + /** + * Move "Valutadatum" from the description to new column. + */ + protected function moveValutadatumDescription(): void + { + $matches = array(); + preg_match('/Valutadatum: ([0-9-]+)/', $this->row[8], $matches); + $this->row[9] = date("Ymd", strtotime($matches[1])); + $this->row[8] = preg_replace('/Valutadatum: [0-9-]+/', '', $this->row[8]); + } + /** * Move savings account number to column 1 and name to column 3. */