railslove / cmxl

your friendly MT940 SWIFT file parser for bank statements
http://railslove.com
MIT License
46 stars 25 forks source link

Negative Debit #34

Closed LQkkeN closed 4 years ago

LQkkeN commented 5 years ago

I have a case like this: :61:1908150815D-104,12NMSCNONREF//010F214191270328

It fails to parse correctly, likely because of the D-104,12. I'm not certain that's correct or not though. I guess it comes down to the - being allowed or not. Perhaps you've seen such a case before?

bumi commented 4 years ago

sorry for the late reply. sadly I do not know about that case. Do you know if some MT940 specs supports this?

LQkkeN commented 4 years ago

This is my only experience with the format, so I unfortunately don't 😕

Uepsilon commented 4 years ago

I don't think that the - is a negative sign but is the placeholder for the currency (not valid though). the amount itself cannot be negative as it's numerical.

i like that source for quick reference: https://www.kontopruef.de/mt940s.shtml

LQkkeN commented 4 years ago

I ended up doing this on each line:

# Replace `D-100,00` with `RD100,00`
content.gsub!(/D-/, 'RD')

# Replace `C-100,00` with `RC100,00`
content.gsub!(/C-/, 'RC')

And it has worked so far 🤷‍♂

bumi commented 4 years ago

:+1:

Uepsilon commented 4 years ago

@LQkkeN have you checked if the - is really meant to be a negative sign and not a broken currency? if so all is well but if not this makes things worse as you return incorrect statements

LQkkeN commented 4 years ago

Yes 😆