mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-18 18:44:16 +00:00
Implemented additional ABNAMRO description formats
This commit is contained in:
@@ -27,10 +27,16 @@ class AbnAmroDescription
|
|||||||
public function fix()
|
public function fix()
|
||||||
{
|
{
|
||||||
$this->handleAmount();
|
$this->handleAmount();
|
||||||
$this->parseSepaDescription();
|
|
||||||
|
// Try to parse the description in known formats.
|
||||||
|
$parsed = $this->parseSepaDescription() || $this->parseTRTPDescription() || $this->parseGEABEADescription() || $this->parseABNAMRODescription();
|
||||||
|
|
||||||
|
// If the description could not be parsed, specify an unknown opposing account, as an opposing account is required
|
||||||
|
if( !$parsed ) {
|
||||||
|
$this->data[ "opposing-account-name" ] = trans('unknown');
|
||||||
|
}
|
||||||
|
|
||||||
return $this->data;
|
return $this->data;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -87,7 +93,8 @@ class AbnAmroDescription
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add the type to the description
|
// Add the type to the description
|
||||||
$this->data['description'] .= ' (' . $type . ')';
|
if( $type )
|
||||||
|
$this->data['description'] .= ' (' . $type . ')';
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -95,89 +102,80 @@ class AbnAmroDescription
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***
|
/**
|
||||||
*
|
* Parses the current description in TRTP format
|
||||||
def ParseDescription(desc):
|
* @return boolean true if the description is TRTP format, false otherwise
|
||||||
values = None
|
*/
|
||||||
### SEPA PLAIN: SEPA iDEAL IBAN: NL12RABO0121212212 BIC: RABONL2U Naam: Silver Ocean B.V. Omschrijving: 1232138 1232131233 412321 iBOOD.com iBOOD.com B.V. Kenmerk: 12-12-2014 21:03 002000 0213123238
|
protected function parseTRTPDescription()
|
||||||
sepa = re.findall(r"(?P<SEPA>^SEPA.{28})", desc, re.I)
|
{
|
||||||
if (sepa):
|
// See if the current description is formatted in TRTP format
|
||||||
values = {}
|
if( preg_match_all( "!\/([A-Z]{3,4})\/([^/]*)!", $this->data[ "description" ], $matches, PREG_SET_ORDER ) ) {
|
||||||
value = sepa[0]
|
Log::debug('AbnAmroSpecifix: Description is structured as TRTP format.');
|
||||||
values["TRTP"] = value.strip()
|
|
||||||
values["EREF"] = ""
|
|
||||||
values["REMI"] = ""
|
|
||||||
sepa = re.findall(r"(?P<NAME>[A-Za-z]+(?=:\s)):\s(?P<VALUE>[A-Za-z 0-9.-]+(?=\s))", desc, re.I)
|
|
||||||
for line in sepa:
|
|
||||||
key = line[0]
|
|
||||||
if key.upper() == 'OMSCHRIJVING':
|
|
||||||
key = 'REMI'
|
|
||||||
if key.upper() == 'KENMERK':
|
|
||||||
key = 'EREF'
|
|
||||||
if key.upper() == 'NAAM':
|
|
||||||
key = 'NAME'
|
|
||||||
value = line[1]
|
|
||||||
values[key] = value.strip()
|
|
||||||
# print (values)
|
|
||||||
# continue
|
|
||||||
if len(values["REMI"]) > 19:
|
|
||||||
values["REMI"] = values["REMI"][0:18] + values["REMI"][19:]
|
|
||||||
if values["REMI"] == "":
|
|
||||||
values["REMI"] = values["TRTP"]
|
|
||||||
|
|
||||||
### TRTP ENCODED: /TRTP/SEPA OVERBOEKING/IBAN/NL23ABNA0000000000/BIC/ABNANL2A/NAME/baasd dsdsT CJ/REMI/Nullijn/EREF/NOTPROVIDED
|
foreach( $matches as $match ) {
|
||||||
trtp = re.findall(r"\/(?P<NAME>[A-Z]{3,4})\/(?P<VALUE>.*?(?:(?=\/[A-Z]{3,4}\/)|$))",desc, re.I)
|
$key = $match[1];
|
||||||
if (trtp):
|
$value = trim($match[2]);
|
||||||
values = {}
|
|
||||||
values["EREF"] = ""
|
|
||||||
values["REMI"] = ""
|
|
||||||
for line in trtp:
|
|
||||||
key = line[0]
|
|
||||||
value = line[1]
|
|
||||||
values[key] = value.strip()
|
|
||||||
# print (values)
|
|
||||||
# continue
|
|
||||||
if values["REMI"] == "":
|
|
||||||
values["REMI"] = values["TRTP"]
|
|
||||||
|
|
||||||
### BEA: BEA NR:00AJ01 31.01.01/19.54 Van HarenSchoenen132 UDE,PAS333
|
switch( strtoupper($key) ) {
|
||||||
trtp = re.findall(r"(?P<TRTP>[BG]EA) +(?P<EREF>NR:[a-zA-Z:0-9]+) +(?P<DATE>[0-9.\/]+) +(?P<NAAM>[^,]*)", desc, re.I)
|
case 'TRTP':
|
||||||
if (trtp):
|
$type = $value;
|
||||||
values = {}
|
break;
|
||||||
values["TRTP"] = str(trtp[0][0]).strip()
|
case 'NAME':
|
||||||
values["NAME"] = str(trtp[0][3]).strip()
|
$this->data['opposing-account-name'] = $value;
|
||||||
values["EREF"] = str(trtp[0][1]).strip()
|
break;
|
||||||
values["DATE"] = str(trtp[0][2]).strip()
|
case 'REMI':
|
||||||
values["REMI"] = values["TRTP"] + " " + values["NAME"]
|
$this->data['description'] = $value;
|
||||||
# print (values)
|
break;
|
||||||
# continue
|
case 'IBAN':
|
||||||
|
$this->data['opposing-account-iban'] = $value;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// Ignore the rest
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
### OLD: 12.21.22.222 BNP aaaaaaa aaaaaa SCH BETALINGSKENM. 2323233232323323 MAAND* APRIL 01 REF* 1212121-42-41
|
// Add the type to the description
|
||||||
trtp = re.findall(r"^ ?(?P<IBAN>[0-9.]{12,15})\W+(?P<NAAM>.{32})", desc, re.I)
|
if( $type )
|
||||||
if (trtp):
|
$this->data['description'] .= ' (' . $type . ')';
|
||||||
values = {}
|
|
||||||
values["TRTP"] = "OLD"
|
return true;
|
||||||
values["IBAN"] = str(trtp[0][0]).strip()
|
}
|
||||||
values["NAME"] = str(trtp[0][1]).strip()
|
|
||||||
values["EREF"] = ""
|
return false;
|
||||||
values["REMI"] = values["TRTP"] + " " + values["NAME"]
|
}
|
||||||
# print (values)
|
|
||||||
# continue
|
/**
|
||||||
### ABN AMRO Bank N.V. Prive pakket 3,25
|
* Parses the current description in GEA/BEA format
|
||||||
abn = re.findall(r"^ABN AMRO.{24} (?P<DESC>.*)", desc, re.I)
|
* @return boolean true if the description is GEA/BEAformat, false otherwise
|
||||||
if (abn):
|
*/
|
||||||
values = {}
|
protected function parseGEABEADescription()
|
||||||
values["TRTP"] = "ABN AMBRO"
|
{
|
||||||
values["NAME"] = "ABN AMBRO"
|
// See if the current description is formatted in GEA/BEA format
|
||||||
values["EREF"] = str(abn[0]).strip()
|
if( preg_match( "/([BG]EA) +(NR:[a-zA-Z:0-9]+) +([0-9.\/]+) +([^,]*)/", $this->data[ "description" ], $matches ) ) {
|
||||||
values["REMI"] = values["EREF"]
|
Log::debug('AbnAmroSpecifix: Description is structured as GEA or BEA format.');
|
||||||
# print (values)
|
|
||||||
# continue
|
$this->data[ "opposing-account-name" ] = $matches[4];
|
||||||
if (values == None):
|
$this->data[ "description" ] = $matches[4] . " (" . $matches[1] . ")";
|
||||||
# print ("Unkown: ### %s ###" % ( desc ))
|
}
|
||||||
return None
|
|
||||||
return values *
|
return false;
|
||||||
*
|
}
|
||||||
*/
|
|
||||||
|
/**
|
||||||
|
* Parses the current description with costs from ABN AMRO itself
|
||||||
|
* @return boolean true if the description is GEA/BEAformat, false otherwise
|
||||||
|
*/
|
||||||
|
protected function parseABNAMRODescription()
|
||||||
|
{
|
||||||
|
// See if the current description is formatted in ABN AMRO format
|
||||||
|
if( preg_match( "/ABN AMRO.{24} (.*)/", $this->data[ "description" ], $matches ) ) {
|
||||||
|
Log::debug('AbnAmroSpecifix: Description is structured as costs from ABN AMRO itself.');
|
||||||
|
|
||||||
|
$this->data[ "opposing-account-name" ] = "ABN AMRO";
|
||||||
|
$this->data[ "description" ] = $matches[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user