mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 18:54:58 +00:00 
			
		
		
		
	Better descriptions for ING accounts
This commit is contained in:
		| @@ -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); | ||||
|   | ||||
							
								
								
									
										110
									
								
								app/Import/Specifics/IngDescription.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										110
									
								
								app/Import/Specifics/IngDescription.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,110 @@ | ||||
| <?php | ||||
| /** | ||||
|  * IngDescription.php | ||||
|  * Copyright (C) 2016 thegrumpydictator@gmail.com | ||||
|  * | ||||
|  * This software may be modified and distributed under the terms | ||||
|  * of the MIT license.  See the LICENSE file for details. | ||||
|  */ | ||||
|  | ||||
| declare(strict_types = 1); | ||||
|  | ||||
| namespace FireflyIII\Import\Specifics; | ||||
|  | ||||
| /** | ||||
|  * Class IngDescription | ||||
|  * | ||||
|  * Parses the description from CSV files for Ing bank accounts. | ||||
|  * | ||||
|  * With Mutation 'InternetBankieren', 'Incasso' and Overschrijving remove Name and IBAN from description | ||||
|  * Add Name in description by 'Betaalautomaat' so those are easily recognizable | ||||
|  * | ||||
|  * @package FireflyIII\Import\Specifics | ||||
|  */ | ||||
| class IngDescription implements SpecificInterface | ||||
| { | ||||
|     /** @var  array */ | ||||
|     public $row; | ||||
|  | ||||
|     /** | ||||
|      * @return string | ||||
|      */ | ||||
|     public static function getDescription(): string | ||||
|     { | ||||
|         return 'Fixes Ing descriptions.'; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @return string | ||||
|      */ | ||||
|     public static function getName(): string | ||||
|     { | ||||
|         return 'Ing description'; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param array $row | ||||
|      * | ||||
|      * @return array | ||||
|      */ | ||||
|     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 | ||||
|                     $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; | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -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', | ||||
|   | ||||
		Reference in New Issue
	
	Block a user