-
Notifications
You must be signed in to change notification settings - Fork 25
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
Chargeback transfers fail to be parsed #18
Comments
thanks for reporting that issue. |
Sorry, neither can I give you an example MT940 file (these are bank statements of our clients) nor can I put in the time to do an actual PR, since I'm not allowed to do that during my work time. However, I can give the single line in question:
(Both seen in real world MT940 files) I managed to fix the issue for myself using
As a monkey patch. It works because For information on the OCMT / CHGS stuff see https://www.kontopruef.de/mt940s.shtml (german), section :61:, subfield 9 "Ursprungsbetrag und Gebührenbetrag". |
ok. thanks for the specific line of the statement, that's already helpful. Maybe if you get time in the future to optimize it during you work, let me know. Then we can add tests for that case and if your change can make it into a new release you can be sure your version is upgradeable. Thanks for reporting, if anyone else sees similar statements please comment on this issue. |
fixed ✔️ |
In case of chargebacks there are additional informations in the :61: fields (
OCMT
andCHGS
data).The current regular expression completely fails in parsing these :61: lines because of that additional data.
Changing the regular expression of
Cmxl::Fields::Transaction
to/^(?<date>\d{6})(?<entry_date>\d{4})?(?<storno_flag>R?)(?<funds_code>[CD]{1})(?<currency_letter>[a-zA-Z])?(?<amount>\d{1,12},\d{0,2})(?<swift_code>(?:N|F).{3})(?<reference>NONREF|.{0,16})((?:\/\/)(?<bank_reference>[^\r\n]*))?((?:[\r\n])?((?:\/OCMT\/)(?<ocmt>[^\/]*)(?:\/)(?:\/CHGS\/)(?<chgs>[^\/]*)(?:\/)))?/i
fixes that and additionally gives the OCMT and CHGS fields.
The changed part is: the whole bank reference group is now optional and can contain any characters except for CR-LF. After that there may be an additional block separated by CR-LF containing
/OCMT/3a15num
with an optional slash at the end followed by/CHGS/3a15num
with an optional slash at the end.The text was updated successfully, but these errors were encountered: