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

Parse MT940 loses data when new line ist between code-characters #98

Open
Makku01 opened this issue Feb 15, 2018 · 3 comments
Open

Parse MT940 loses data when new line ist between code-characters #98

Makku01 opened this issue Feb 15, 2018 · 3 comments

Comments

@Makku01
Copy link

Makku01 commented Feb 15, 2018

166?00GUTSCHRIFT?109251?20SVWZ+Rechnung xxx?30DEUTDEDB276?3 1DE1127xxxxx40011xxxxxx?32Testfirma GmbH

This is the description in the MT940 Class as it enters the function protected function parseDescription($descr)

As you see, after the BIC the code for accountnumber is splitted by a newline: xxxx?3[new line]1
So the parser can't parse the accountnumber and it's displayed as empty.

I've added the following to line 155 ofMT940.php

//search for newlines in codes from 10-63 and remove them foreach($prepared as $key => $value){ $keystring = (string) $key; if(strlen ($keystring) == 2){ $first = substr($keystring,0,1); $last = substr($keystring,-1,1); $descr = str_replace("$first\r\n$last", "$first$last", $descr); } }
This will remove the newlines in all codes with two digits from 10 to 63.
As I'm not a php expert, this code is working for me and i'd like know wether it is suitable!

@Makku01 Makku01 changed the title Parse MT940 loses data when new line ist between Parse MT940 loses data when new line ist between code-characters Feb 15, 2018
@Philipp91
Copy link
Contributor

I cannot reproduce your issue. So far, I haven't looked at your proposed fix, but I'm happy to do so once I understand the issue. Are you testing with the latest released version (1.0.4) or the code in the master branch?

I copied the current parseDescription() code from master to phpfiddle.org (here's a copy: https://gist.github.com/Philipp91/2acbff5835a0365b84dc26079d2d935e) and ran it with your example. I inserted the line break \r\n in the position you indicated (hope I got that right). I'm getting the following output:

Array
(
    [description] => Array
        (
            [SVWZ] => Rechnung xxx
        )

    [booking_text] => GUTSCHRIFT
    [primanoten_nr] => 9251
    [description_1] => SVWZ+Rechnung xxx
    [bank_code] => DEUTDEDB276
    [account_number] => DE1127xxxxx40011xxxxxx
    [name] => Testfirma GmbH
    [text_key_addition] => 
    [description_2] => 
)

In particular, the account_number is present.

What am I missing?

@ampaze
Copy link

ampaze commented Jan 16, 2019

@Makku01 Could you try https://github.com/nemiah/phpFinTS? I just made some fixes concerning a similar problem.

@Makku01
Copy link
Author

Makku01 commented Jan 16, 2019

@Philipp91 Please try your GIST without the charcters for the new line as in:

print_r(parseDescription("166?00GUTSCHRIFT?109251?20SVWZ+Rechnung xxx?30DEUTDEDB276?3 1DE1127xxxxx40011xxxxxx?32Testfirma GmbH"));

As you'll see, the Account Number is empty.

PS: Sorry for the delayed reply!
@ampaze I'll try it soon, Thanks!

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

3 participants