Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing of the transaction description: Missing information #40

Open
bell430 opened this issue Jan 25, 2017 · 4 comments
Open

Parsing of the transaction description: Missing information #40

bell430 opened this issue Jan 25, 2017 · 4 comments

Comments

@bell430
Copy link

bell430 commented Jan 25, 2017

Hi @mschindler83,

first of all: Great work! I really love this tool.

I used it with comdirect bank and found an issue with the MT940-parser. I some cases, the reponse contains a divider-string within the description section, although it is still the same transaction. As a result there are parts of the name and/or description missing. Here an example:

RAW-Response (divided and personal information taken out):

Array
(
[0] =>
[1] => 20:MT940-1701250150
[2] => 21:NONREF
[3] => 25:20041144/418311700EUR
[4] => 28C:0/1
[5] => 60F:C170123EUR1921,44
[6] => 61:1701230123DR139,63NMSCNONREF//POS 3393590253
[7] => 86:820?20ÃœBERTRAG/ÃœBERWEISUNG?21RECHNUNGSNR. 17/27?22END-TO-END-REF.
[8] => ?23NICHT ANGEGEBEN?24Ref. J9217021C1831775/2?30GENODEF1HTR?31DExxxxxxxxxxx?32DR. MEIER
[9] => 61:1701230123DR69,58NMSCNONREF//POS 3394043541
[10] => 62M:C170124EUR1199,64
)

The information from index 8 is completely lost, as the parser expects it to be part of index 7.

My workaround is as follows:

MT940.php:

protected function parseToArray()
    {
....
	$transaction = substr($day[$i], 3);
	$description = substr($day[$i + 1], 3);
	//WORKAROUND:
	if (substr($day[$i+2],0,1)=="?" && substr($day[$i+2],2,1)!=":") {
	    	//add missing line
	    	$description.=$day[$i+2];
	}

As I'm not a php-expert, I'm pretty sure that you can find a much more flexible and elegant solutions for this issue. I just wanted to show my workaround for better unterstanding. Also I'm not aware about problems which could arise from this code, when using it with other banks.

Thanks and best regards!

Edit:
It's even worse. The parser has a problem with the divider-string that comdirect returns. Comdirect is sometimes sending "\r\n" in the middle of a description. If then a "-" is accidently right behind it (as it belongs to the description), the parser threats it as a new transaction.

@pvonauf
Copy link

pvonauf commented Feb 3, 2017

Hi,

I referred to this issue in issue #23 .
As I am not a php expert either, I think there is a better solution to this than mine. I got it to work in the meantime (not sure if it always works).

I still however have an issue with two arrays being created accross one single transaction. This leadsto` an incomplete description1.
Now I found a way to solve this by replacing following line in line 59 of MT940.php

Original line:
$days = explode($divider . '-', $this->rawData);

New line:
$days=preg_split('/([\r\n][-][\r\n]|[\r\n][-][+])/', $this->rawData);

The old line does not work because my raw data (Deutsche Bank) looks like this sometimes (replaced some stuff):
:86:105?20EREF+LA-12431-2017-01-02-11?21-27-02-8?22MREF+N1/13002/14/2
-H?23CRED+DExxZZZxxxxxxxxxxx?24SVWZ+01.17 Autom. Sollstell?25ung
1/3002/14/2, DG li, Stp?26l. 24 xxxxxxxxxxxx 16?27ABWA+WEG Fr
xxxxxxxxx. 16 W?30BYLADEM1001?31DE00000000000000999999?32WEG xxx
xxxxxxxxx. 16 Xxxxxx?33n

The point is the \r\n- in this case. Here it continues with the description "H?23CRED+DExxZZZxxxxxxxxxxx?2 ...". In other cases I saw it would either be only "-" or "-+...". But I'm not sure if these will be the only cases?

My new line does not consider @@ as a separator - didn't get it to work with the $divider variable :-(

@Philipp91
Copy link
Contributor

This can potentially be solved by the structured description. I added code to actually expose it here: #48

@mgrundkoetter
Copy link

The Problem is, that there may be lines starting with "-", so the line
$days = explode($divider . '-', $this->rawData); will cut the rest apart. I have a workaround for this: $days = preg_split('%^-$%', $this->rawData);, for which I will create a PR.

mgrundkoetter added a commit to mgrundkoetter/fints-hbci-php that referenced this issue May 3, 2017
- added new test for fix
- added phpunit as dev requirement in composer file
mschindler83 added a commit that referenced this issue May 5, 2017
@dsentker
Copy link
Contributor

The workaround from @mgrundkoetter has helped me, too. Thank you for that.
It seems that this fix is not part of v1.0.4. Is there a reason why the fix has not yet been adopted?

roben pushed a commit to roben/fints-hbci-php that referenced this issue Sep 18, 2019
Fix postbank and tan mechanisms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants