mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-11 07:55:51 -06:00
Merge pull request #192 from roberthorlings/bugfix/abnamro-description-specifix
Bugfix in parsing specific descriptions
This commit is contained in:
commit
44a15551ba
@ -114,20 +114,28 @@ class AbnAmroDescription extends Specifix implements SpecifixInterface
|
||||
if (preg_match('/^SEPA(.{28})/', $this->data['description'], $matches)) {
|
||||
Log::debug('AbnAmroSpecifix: Description is structured as SEPA plain description.');
|
||||
|
||||
$type = $matches[1];
|
||||
$reference = '';
|
||||
$name = '';
|
||||
$newDescription = '';
|
||||
|
||||
// SEPA plain descriptions contain several key-value pairs, split by a colon
|
||||
preg_match_all('/([A-Za-z]+(?=:\s)):\s([A-Za-z 0-9._#-]+(?=\s))/', $this->data['description'], $matches, PREG_SET_ORDER);
|
||||
preg_match_all('/([A-Za-z]+(?=:\s)):\s([A-Za-z 0-9._#-]+(?=\s|$))/', $this->data['description'], $matches, PREG_SET_ORDER);
|
||||
|
||||
if (is_array($matches)) {
|
||||
foreach ($matches as $match) {
|
||||
$key = $match[1];
|
||||
$value = trim($match[2]);
|
||||
|
||||
Log::debug( "SEPA: $key - $value" );
|
||||
switch (strtoupper($key)) {
|
||||
case 'OMSCHRIJVING':
|
||||
$this->data['description'] = $value;
|
||||
$newDescription = $value;
|
||||
break;
|
||||
case 'NAAM':
|
||||
$this->data['opposing-account-name'] = $value;
|
||||
$this->data['opposing-account-name'] = $name = $value;
|
||||
break;
|
||||
case 'KENMERK':
|
||||
$reference = $value;
|
||||
break;
|
||||
case 'IBAN':
|
||||
$this->data['opposing-account-iban'] = $value;
|
||||
@ -137,6 +145,14 @@ class AbnAmroDescription extends Specifix implements SpecifixInterface
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set a new description for the current transaction. If none was given
|
||||
// set the description to type, name and reference
|
||||
if( $newDescription ) {
|
||||
$this->data['description'] = $newDescription;
|
||||
} else {
|
||||
$this->data[ 'description' ] = sprintf('%s - %s (%s)', $type, $name, $reference);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -155,6 +171,13 @@ class AbnAmroDescription extends Specifix implements SpecifixInterface
|
||||
if (preg_match_all('!\/([A-Z]{3,4})\/([^/]*)!', $this->data['description'], $matches, PREG_SET_ORDER)) {
|
||||
Log::debug('AbnAmroSpecifix: Description is structured as TRTP format.');
|
||||
|
||||
$type = '';
|
||||
$name = '';
|
||||
$reference = '';
|
||||
$newDescription = '';
|
||||
|
||||
// Search for properties specified in the TRTP format. If no description
|
||||
// is provided, use the type, name and reference as new description
|
||||
if (is_array($matches)) {
|
||||
foreach ($matches as $match) {
|
||||
$key = $match[1];
|
||||
@ -162,20 +185,34 @@ class AbnAmroDescription extends Specifix implements SpecifixInterface
|
||||
|
||||
switch (strtoupper($key)) {
|
||||
case 'NAME':
|
||||
$this->data['opposing-account-name'] = $value;
|
||||
$this->data['opposing-account-name'] = $name = $value;
|
||||
break;
|
||||
case 'REMI':
|
||||
$this->data['description'] = $value;
|
||||
$newDescription = $value;
|
||||
break;
|
||||
case 'IBAN':
|
||||
$this->data['opposing-account-iban'] = $value;
|
||||
break;
|
||||
case 'EREF':
|
||||
$reference = $value;
|
||||
break;
|
||||
case 'TRTP':
|
||||
$type = $value;
|
||||
break;
|
||||
default:
|
||||
// Ignore the rest
|
||||
}
|
||||
}
|
||||
|
||||
// Set a new description for the current transaction. If none was given
|
||||
// set the description to type, name and reference
|
||||
if( $newDescription ) {
|
||||
$this->data['description'] = $newDescription;
|
||||
} else {
|
||||
$this->data[ 'description' ] = sprintf('%s - %s (%s)', $type, $name, $reference);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user